Support BC in JSCExecutor on iOS
Reviewed By: amnn Differential Revision: D4558676 fbshipit-source-id: 1ec2b1a5a8df08074ba06162ab2585f02d1d214b
This commit is contained in:
parent
8987d86718
commit
61785ee00c
|
@ -23,6 +23,7 @@
|
|||
#include <inspector/Inspector.h>
|
||||
#endif
|
||||
|
||||
#include "JSBundleType.h"
|
||||
#include "Platform.h"
|
||||
#include "SystraceSection.h"
|
||||
#include "JSCNativeModules.h"
|
||||
|
@ -408,6 +409,7 @@ void JSCExecutor::loadApplicationScript(std::unique_ptr<const JSBigString> scrip
|
|||
ReactMarker::logMarker("RUN_JS_BUNDLE_START");
|
||||
String jsSourceURL(m_context, sourceURL.c_str());
|
||||
|
||||
// TODO t15069155: reduce the number of overrides here
|
||||
#ifdef WITH_FBJSCEXTENSIONS
|
||||
if (auto fileStr = dynamic_cast<const JSBigFileString *>(script.get())) {
|
||||
JSLoadSourceStatus jsStatus;
|
||||
|
@ -441,8 +443,24 @@ void JSCExecutor::loadApplicationScript(std::unique_ptr<const JSBigString> scrip
|
|||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#elif defined(__APPLE__)
|
||||
BundleHeader header{};
|
||||
memcpy(&header, script->c_str(), std::min(script->size(), sizeof(BundleHeader)));
|
||||
auto scriptTag = parseTypeFromHeader(header);
|
||||
|
||||
if (scriptTag == ScriptTag::BCBundle) {
|
||||
using file_ptr = std::unique_ptr<FILE, decltype(&fclose)>;
|
||||
file_ptr source(fopen(sourceURL.c_str(), "r"), fclose);
|
||||
int sourceFD = fileno(source.get());
|
||||
|
||||
JSValueRef jsError;
|
||||
JSValueRef result = JSC_JSEvaluateBytecodeBundle(m_context, NULL, sourceFD, jsSourceURL, &jsError);
|
||||
if (result == nullptr) {
|
||||
formatAndThrowJSException(m_context, jsError, jsSourceURL);
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
#ifdef WITH_FBSYSTRACE
|
||||
fbsystrace_begin_section(
|
||||
TRACE_TAG_REACT_CXX_BRIDGE,
|
||||
|
@ -458,12 +476,14 @@ void JSCExecutor::loadApplicationScript(std::unique_ptr<const JSBigString> scrip
|
|||
#endif
|
||||
|
||||
evaluateScript(m_context, jsScript, jsSourceURL);
|
||||
}
|
||||
|
||||
// TODO(luk): t13903306 Remove this check once we make native modules working for java2js
|
||||
if (m_delegate) {
|
||||
bindBridge();
|
||||
flush();
|
||||
}
|
||||
|
||||
ReactMarker::logMarker("CREATE_REACT_CONTEXT_END");
|
||||
ReactMarker::logMarker("RUN_JS_BUNDLE_END");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue