mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-05-11 10:38:00 +08:00
Reverted commit D3545345
Reviewed By: tadeuzagallo Differential Revision: D3545345 fbshipit-source-id: d655918be7dcadaf8143800497e85f3de44bd48a
This commit is contained in:
committed by
Facebook Github Bot 6
parent
7d2b5714af
commit
df01215006
@@ -254,37 +254,15 @@ void JSCExecutor::terminateOnJSVMThread() {
|
||||
}
|
||||
|
||||
#ifdef WITH_FBJSCEXTENSIONS
|
||||
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) {
|
||||
throw std::runtime_error("Optimized bundle needs to be ascii encoded");
|
||||
}
|
||||
|
||||
static void loadApplicationSource(
|
||||
const JSGlobalContextRef context,
|
||||
const JSBigMmapString* script,
|
||||
const std::string& sourceURL) {
|
||||
String jsSourceURL(sourceURL.c_str());
|
||||
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");
|
||||
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
|
||||
|
||||
@@ -292,6 +270,16 @@ 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