Reverted commit D3545345

Reviewed By: tadeuzagallo

Differential Revision: D3545345

fbshipit-source-id: d655918be7dcadaf8143800497e85f3de44bd48a
This commit is contained in:
David Aurelio
2016-07-14 10:43:23 -07:00
committed by Facebook Github Bot 6
parent 7d2b5714af
commit df01215006
18 changed files with 158 additions and 199 deletions

View File

@@ -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,