Fixing a crash caused by D4393955

Reviewed By: javache

Differential Revision: D4403858

fbshipit-source-id: c930aa108d27c1bd1b36364530d2953bcd4664ad
This commit is contained in:
Dan Caspi
2017-01-11 09:29:50 -08:00
committed by Facebook Github Bot
parent d2de604721
commit ad0493c6c2
2 changed files with 9 additions and 2 deletions

View File

@@ -540,7 +540,7 @@ RCT_EXPORT_MODULE()
if (JSC_JSSamplingProfilerEnabled(self->_bridge.jsContext.JSGlobalContextRef)) {
JSContext *context = self->_bridge.jsContext;
// Allow to toggle the sampling profiler through RN's dev menu
[self->_bridge.devMenu addItem:[RCTDevMenuItem buttonItemWithTitle:@"Start / Stop JS Sampling Profiler" handler:^{
[items addObject:[RCTDevMenuItem buttonItemWithTitle:@"Start / Stop JS Sampling Profiler" handler:^{
JSGlobalContextRef globalContext = context.JSGlobalContextRef;
// JSPokeSamplingProfiler() toggles the profiling process
JSValueRef jsResult = JSC_JSPokeSamplingProfiler(globalContext);

View File

@@ -40,6 +40,9 @@
#ifdef WITH_JSC_EXTRA_TRACING
#include "JSCLegacyProfiler.h"
#include "JSCLegacyTracing.h"
#endif
#if !defined(__APPLE__) && defined(WITH_JSC_EXTRA_TRACING)
#include <JavaScriptCore/API/JSProfilerPrivate.h>
#endif
@@ -278,7 +281,11 @@ void JSCExecutor::initOnJSVMThread() throw(JSException) {
PerfLogging::installNativeHooks(m_context);
#endif
initSamplingProfilerOnMainJSCThread(m_context);
#if defined(__APPLE__) || defined(WITH_JSC_EXTRA_TRACING)
if (JSC_JSSamplingProfilerEnabled(m_context)) {
initSamplingProfilerOnMainJSCThread(m_context);
}
#endif
#ifdef WITH_FB_MEMORY_PROFILING
addNativeMemoryHooks(m_context);