react-native-macos/ReactCommon/jsi
Xuan Huang bddff73790 Introduce drainMicrotasks to JSI
Summary:
Changelog:
[Internal][Added] - Introduce drainMicrotasks to JSI

This diff proposed a new JSI API `drainMicrotasks` to define
how hosts may integrate with the JSVMs' internal microtask
queue (a.k.a. job queue) and hence their native Promise.

The name `drainMicrotasks` is slightly preferred over `drainJobs`
to favor *host-friendliness* over *engine-friendliness*.

This diff auto implement the new API in JSC and Hermes as stubs
to make sure things compiled.

Please refer to the doc-comments in the `jsi.h` for a detailed
documentation on the semantics and the design of this API.

### Notes on the existing APIs from JSVMs

The presence of such queue and APIs to operate on them are
ubiquitous:
- Hermes: `Runtime::drainJobs`
- V8: `MicrotaskQueue::PerformCheckpoint`
- JSC: `VM::drainMicrotasks`
- QuickJS: `JS_ExecutePendingJob`

The only exception is ChakraCore, which requires hosts to provide
the queue and set up the `JsSetPromiseContinuationCallback`,
but a JSI implementation can provide that queue trivially.

### Extra note on ECMA-262

ECMA-262 changed the spec at Mar 2020 from "asking an ECMAScript
implementation to maintain a Job Queue" to "Ask the embedder to
define its event loop, including the job queue" so technically:
- the internal approach is closer to the old spec.
- the ChakraCore approach is closer to the current spec.

Reviewed By: mhorowitz

Differential Revision: D27727920

fbshipit-source-id: b839b959facbc009f7d14b781e9287c46ea64373
2021-04-23 02:43:06 -07:00
..
jsi Introduce drainMicrotasks to JSI 2021-04-23 02:43:06 -07:00
.clang-tidy The life-changing magic of clang-tidying up 2020-02-04 11:09:30 -08:00
Android.mk RNTester Android: always compile Fabric files 2020-12-21 22:43:36 -08:00
BUCK Enable C++ 17 in React Native 2021-04-01 04:50:59 -07:00
JSCRuntime.cpp Introduce drainMicrotasks to JSI 2021-04-23 02:43:06 -07:00
JSCRuntime.h Tidy up license headers [3/n] 2019-10-16 10:06:34 -07:00
React-jsi.podspec Resolve "fatal: not a git repository" error outside of git repositories 2021-04-15 13:30:31 -07:00