mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-05-18 04:13:51 +08:00
Fix optimized bundle stuff.
Reviewed By: davidaurelio, tadeuzagallo Differential Revision: D3563710 fbshipit-source-id: 2b0a982d388ee5f44b806f8e561ef49a3fd8c8ca
This commit is contained in:
committed by
Facebook Github Bot 7
parent
0c0ac6e21c
commit
3c0f428f05
@@ -254,15 +254,38 @@ void JSCExecutor::terminateOnJSVMThread() {
|
||||
}
|
||||
|
||||
#ifdef WITH_FBJSCEXTENSIONS
|
||||
static void loadApplicationSource(
|
||||
const JSGlobalContextRef context,
|
||||
const JSBigMmapString* script,
|
||||
const std::string& sourceURL) {
|
||||
void JSCExecutor::loadApplicationScript(
|
||||
std::string bundlePath,
|
||||
std::string sourceURL,
|
||||
int flags) {
|
||||
SystraceSection s("JSCExecutor::loadApplicationScript",
|
||||
"sourceURL", sourceURL);
|
||||
|
||||
if ((flags & UNPACKED_JS_SOURCE) == 0) {
|
||||
throw std::runtime_error("Optimized bundle with no unpacked js source");
|
||||
}
|
||||
|
||||
auto jsScriptBigString = JSBigMmapString::fromOptimizedBundle(bundlePath);
|
||||
if (jsScriptBigString->encoding() != JSBigMmapString::Encoding::Ascii) {
|
||||
LOG(WARNING) << "Bundle is not ASCII encoded - falling back to the slow path";
|
||||
return loadApplicationScript(std::move(jsScriptBigString), 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);
|
||||
JSSourceCodeRef sourceCode = JSCreateSourceCode(
|
||||
jsScriptBigString->fd(),
|
||||
jsScriptBigString->size(),
|
||||
jsSourceURL,
|
||||
jsScriptBigString->hash(),
|
||||
true);
|
||||
SCOPE_EXIT { JSReleaseSourceCode(sourceCode); };
|
||||
|
||||
evaluateSourceCode(m_context, sourceCode, jsSourceURL);
|
||||
|
||||
bindBridge();
|
||||
|
||||
flush();
|
||||
ReactMarker::logMarker("CREATE_REACT_CONTEXT_END");
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -270,16 +293,6 @@ void JSCExecutor::loadApplicationScript(std::unique_ptr<const JSBigString> scrip
|
||||
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