Permalink
Browse files

JSIExecutor Bundle Splitting Support

Reviewed By: mhorowitz

Differential Revision: D6847638

fbshipit-source-id: d9ae3d182d6f07bcac81cfd06dcc19f8139bb1e4
  • Loading branch information...
fromcelticpark authored and facebook-github-bot committed Feb 9, 2018
1 parent 854c233 commit 1a1a956831aec93a4fe2c6e2f63f558271fb466b
Showing with 8 additions and 33 deletions.
  1. +8 −5 ReactCommon/cxxreact/JSCExecutor.cpp
  2. +0 −20 ReactCommon/cxxreact/JSCUtils.cpp
  3. +0 −8 ReactCommon/cxxreact/JSCUtils.h
@@ -689,11 +689,14 @@ namespace facebook {
return JSC_JSValueMakeUndefined(m_context);
}
JSValueRef JSCExecutor::nativeRequire(
size_t argumentCount,
const JSValueRef arguments[]) {
uint32_t bundleId, moduleId;
std::tie(bundleId, moduleId) = parseNativeRequireParameters(m_context, arguments, argumentCount);
JSValueRef JSCExecutor::nativeRequire(size_t count, const JSValueRef arguments[]) {
if (count > 2 || count == 0) {
throw std::invalid_argument("Got wrong number of args");
}
uint32_t moduleId = folly::to<uint32_t>(Value(m_context, arguments[0]).getNumberOrThrow());
uint32_t bundleId = count == 2 ? folly::to<uint32_t>(Value(m_context, arguments[1]).getNumberOrThrow()) : 0;
ReactMarker::logMarker(ReactMarker::NATIVE_REQUIRE_START);
loadModule(bundleId, moduleId);
ReactMarker::logMarker(ReactMarker::NATIVE_REQUIRE_STOP);
@@ -15,25 +15,5 @@ String jsStringFromBigString(JSContextRef ctx, const JSBigString& bigstr) {
}
}
std::pair<uint32_t, uint32_t> parseNativeRequireParameters(
const JSGlobalContextRef& context,
const JSValueRef arguments[],
size_t argumentCount) {
uint32_t moduleId = 0, bundleId = 0;
// use "getNumber" & "folly::to" to throw explicitely in case of an overflow
// error during conversion
if (argumentCount == 1) {
moduleId = folly::to<uint32_t>(Value(context, arguments[0]).getNumberOrThrow());
} else if (argumentCount == 2) {
moduleId = folly::to<uint32_t>(Value(context, arguments[0]).getNumberOrThrow());
bundleId = folly::to<uint32_t>(Value(context, arguments[1]).getNumberOrThrow());
} else {
throw std::invalid_argument("Got wrong number of args");
}
return std::make_pair(bundleId, moduleId);
}
}
}
@@ -11,13 +11,5 @@ namespace react {
String jsStringFromBigString(JSContextRef ctx, const JSBigString& bigstr);
/**
* Parses "nativeRequire" parameters
* and returns pair of "bundle id" & "module id" values
*/
std::pair<uint32_t, uint32_t> parseNativeRequireParameters(const JSGlobalContextRef& context,
const JSValueRef arguments[],
size_t argumentCount);
}
}

0 comments on commit 1a1a956

Please sign in to comment.