mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-03-30 17:33:21 +08:00
Add new FileSourceProvider
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
This commit is contained in:
committed by
Facebook Github Bot 9
parent
e5650560c0
commit
5d06918d07
@@ -253,10 +253,33 @@ void JSCExecutor::terminateOnJSVMThread() {
|
||||
m_context = nullptr;
|
||||
}
|
||||
|
||||
#ifdef WITH_FBJSCEXTENSIONS
|
||||
static void loadApplicationSource(
|
||||
const JSGlobalContextRef context,
|
||||
const JSBigMmapString* script,
|
||||
const std::string& sourceURL) {
|
||||
String jsSourceURL(sourceURL.c_str());
|
||||
bool is8bit = script->encoding() == JSBigMmapString::Encoding::Ascii || script->encoding() == JSBigMmapString::Encoding::Utf8;
|
||||
JSSourceCodeRef sourceCode = JSCreateSourceCode(script->fd(), script->size(), jsSourceURL, script->hash(), is8bit);
|
||||
evaluateSourceCode(context, sourceCode, jsSourceURL);
|
||||
JSReleaseSourceCode(sourceCode);
|
||||
}
|
||||
#endif
|
||||
|
||||
void JSCExecutor::loadApplicationScript(std::unique_ptr<const JSBigString> script, std::string sourceURL) throw(JSException) {
|
||||
SystraceSection s("JSCExecutor::loadApplicationScript",
|
||||
"sourceURL", sourceURL);
|
||||
|
||||
#ifdef WITH_FBJSCEXTENSIONS
|
||||
if (auto source = dynamic_cast<const JSBigMmapString *>(script.get())) {
|
||||
loadApplicationSource(m_context, source, sourceURL);
|
||||
bindBridge();
|
||||
flush();
|
||||
ReactMarker::logMarker("CREATE_REACT_CONTEXT_END");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef WITH_FBSYSTRACE
|
||||
fbsystrace_begin_section(
|
||||
TRACE_TAG_REACT_CXX_BRIDGE,
|
||||
|
||||
Reference in New Issue
Block a user