react-native-macos/ReactCommon/jsiexecutor
Xuan Huang 7310847758 Perform Engine Microtasks in JSIExecutor
Summary:
Changelog: [Internal]

This diff introduce a helper `performMicrotaskCheckpoint` to
repetitively invoke `jsi::Runtime::drainMicrotasks` to exhaust
the microtasks queue provided by JS VMs. Please refer to `jsi.h`
for more details about the behavior of the API.

Conceptually, the checkpoint needs to be performed whenever the
JS stack is considered empty. In practice, we can just make a
call whenever RN is returned from C++->JS calls.

In the current RN, this happened in JSIExecutor:
- `::callFunction` => `callFunctionReturnFlushedQueue_-> call`
- `::invokeCallback` => `invokeCallbackAndReturnFlushedQueue_-> call`
- `::flush` => `flushedQueue_->call`

Each of them invoke a bound method on the JS bridge object. Note
that `setImmediate` callbacks are executed before they returned.
This means immmediates are invoked before engine microtasks. This
is okay because the priority between `setImmediate` and engine
"microtask" are not defined. (`setImmediate` is non-standard and RN
already treat `setImmediate` in a similar priority as microtask
for the existing Promise polyfill.)

Reviewed By: RSNara

Differential Revision: D27729702

fbshipit-source-id: b64b3705d2ff5100075d860c89f03a847369b7ac
2021-04-23 02:43:06 -07:00
..
jsireact Perform Engine Microtasks in JSIExecutor 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 Rename <ReactCommon/NativeModulePerfLogger.h> to <reactperflogger/NativeModulePerfLogger.h> 2020-05-15 15:25:23 -07:00
BUCK use xplat BUCK attribution 2020-05-15 21:55:52 -07:00
React-jsiexecutor.podspec Resolve "fatal: not a git repository" error outside of git repositories 2021-04-15 13:30:31 -07:00