Only configure nativeInjectHMRUpdate in DEBUG builds

Reviewed By: martinbigio

Differential Revision: D3944601

fbshipit-source-id: 8b98b7ae9a10c1e95d0ae80f6bbd90675d7c3ef5
This commit is contained in:
Pieter De Baets 2016-09-30 12:18:58 -07:00 committed by Facebook Github Bot
parent 67f9d92478
commit 6ee319d8eb
1 changed files with 16 additions and 14 deletions

View File

@ -81,13 +81,20 @@ inline JSObjectCallAsFunctionCallback exceptionWrapMethod() {
}
#if DEBUG
static JSValueRef nativeInjectHMRUpdate(
JSContextRef ctx,
JSObjectRef function,
JSObjectRef thisObject,
size_t argumentCount,
const JSValueRef arguments[],
JSValueRef *exception);
JSValueRef *exception) {
String execJSString = Value(ctx, arguments[0]).toString();
String jsURL = Value(ctx, arguments[1]).toString();
evaluateScript(ctx, execJSString, jsURL);
return JSValueMakeUndefined(ctx);
}
#endif
std::unique_ptr<JSExecutor> JSCExecutorFactory::createJSExecutor(
std::shared_ptr<ExecutorDelegate> delegate, std::shared_ptr<MessageQueueThread> jsQueue) {
@ -189,6 +196,7 @@ void JSCExecutor::initOnJSVMThread() throw(JSException) {
configureJSCForAndroid(m_jscConfig);
#endif
// Create a custom global class, so we can store data in it later using JSObjectSetPrivate
JSClassRef globalClass = nullptr;
{
SystraceSection s("JSClassCreate");
@ -205,15 +213,21 @@ void JSCExecutor::initOnJSVMThread() throw(JSException) {
installNativeHook<&JSCExecutor::nativeRequireModuleConfig>("nativeRequireModuleConfig");
installNativeHook<&JSCExecutor::nativeFlushQueueImmediate>("nativeFlushQueueImmediate");
installNativeHook<&JSCExecutor::nativeCallSyncHook>("nativeCallSyncHook");
// Websorker support
installNativeHook<&JSCExecutor::nativeStartWorker>("nativeStartWorker");
installNativeHook<&JSCExecutor::nativePostMessageToWorker>("nativePostMessageToWorker");
installNativeHook<&JSCExecutor::nativeTerminateWorker>("nativeTerminateWorker");
installGlobalFunction(m_context, "nativeInjectHMRUpdate", nativeInjectHMRUpdate);
installNativeHook<&JSCExecutor::nativeCallSyncHook>("nativeCallSyncHook");
installGlobalFunction(m_context, "nativeLoggingHook", JSNativeHooks::loggingHook);
installGlobalFunction(m_context, "nativePerformanceNow", JSNativeHooks::nowHook);
#if DEBUG
installGlobalFunction(m_context, "nativeInjectHMRUpdate", nativeInjectHMRUpdate);
#endif
#if defined(WITH_JSC_EXTRA_TRACING) || DEBUG
addNativeTracingHooks(m_context);
#endif
@ -762,16 +776,4 @@ JSValueRef JSCExecutor::nativeCallSyncHook(
return Value::fromDynamic(m_context, result.result);
}
static JSValueRef nativeInjectHMRUpdate(
JSContextRef ctx,
JSObjectRef function,
JSObjectRef thisObject,
size_t argumentCount,
const JSValueRef arguments[], JSValueRef *exception) {
String execJSString = Value(ctx, arguments[0]).toString();
String jsURL = Value(ctx, arguments[1]).toString();
evaluateScript(ctx, execJSString, jsURL);
return JSValueMakeUndefined(ctx);
}
} }