Summary:
**Motivation**
I'm working on a project that uses React Native and needs to add direct synchronous bindings to native stuff through the JavaScriptCore C API. This is because it's performance-sensitive and would benefit from the quickest JS->C path. It does this using cross-platform C++ code that works on both iOS and Android. Most of the infrastructure for getting access to the JSC context is already in React Native actually, just had to add a few more things.
(lexs you mentioned to tag you in this pull request)
**Test plan**
Modify the JavaScriptCore context through the `JSContextRef` returned (eg. add an object at global scope) and verify that it exists in JavaScript.
Closes https://github.com/facebook/react-native/pull/10399
Differential Revision: D4080945
Pulled By: lexs
fbshipit-source-id: 6659b7a01e09fd84475adde183c1d3aca2d4cf09
Summary: Instead of sending a list of modules over to JS on startup (and actually blocking script execution) instead provide a proxy object that constructs each of these lazily.
Reviewed By: lexs
Differential Revision: D3936979
fbshipit-source-id: 71bde822f01eb17a29f56c5e60e95e98e207d74d
Summary: Get rid of the old behaviour of JSON encoding in `nativeRequireModuleConfig` and consistently use the same names for function types "async/promise/sync"
Reviewed By: lexs
Differential Revision: D3819348
fbshipit-source-id: fc798a5abcaf6a3ef9d95bd8654afa7825c83967
Summary:
JSC's utf16 -> utf8 conversion crashes on encountering bad utf16. Instead, use our own conversion (conveniently copied from fbjni).
Original fix thanks to rigdern (https://github.com/facebook/react-native/pull/9302)
Reviewed By: mhorowitz
Differential Revision: D3746947
fbshipit-source-id: 29887ca720f6a2b074f01f853bad28a083b273bc
Summary:
We have a lot of small-ish calls to JSC and within the bridge that add up during TTI. This gives us a way to measure them in aggregate in a reasonable way.
From the comments:
MicroProfiler is a performance profiler for measuring the cumulative impact of
a large number of small-ish calls. This is normally a problem for standard profilers
like Systrace because the overhead of the profiler itself skews the timings you
are able to collect. This is especially a problem when doing nested calls to
profiled functions, as the parent calls will contain the overhead of their profiling
plus the overhead of all their childrens' profiling.
MicroProfiler attempts to be low overhead by 1) aggregating timings in memory and
2) trying to remove estimated profiling overhead from the returned timings.
To remove estimated overhead, at the beginning of each trace we calculate the
average cost of profiling a no-op code section, as well as invoking the average
cost of invoking the system clock. The former is subtracted out for each child
profiler section that is invoked within a parent profiler section. The latter is
subtracted from each section, child or not.
The usage is similar to Systrace: you put a MICRO_PROFILER_BLOCK in the block you want to profile and C++ RAII will handle timing it.
After MicroProfiler::stopProfiling() is called, a table of tracing data is emitted
to glog (which shows up in logcat on Android).
Differential Revision: D3635319
fbshipit-source-id: 01390b8ac76a68dd425cba2adfdde6e4957440cc
Summary: Add a new interface to JSC that allows loading a file lazily from disk, i.e. using mmap, instead of loading the whole file upfront and copying into the VM.
Reviewed By: michalgr
Differential Revision: D3534042
fbshipit-source-id: 98b193cc7b7e33248073e2556ea94ce3391507c7