diff --git a/ReactCommon/cxxreact/BUCK b/ReactCommon/cxxreact/BUCK index 46b19ea4e34c9a..61767e0fd91ed4 100644 --- a/ReactCommon/cxxreact/BUCK +++ b/ReactCommon/cxxreact/BUCK @@ -117,6 +117,7 @@ react_library( 'JSCLegacyTracing.cpp', 'JSCMemory.cpp', 'JSCPerfStats.cpp', + 'JSCSamplingProfiler.cpp', 'JSCTracing.cpp', 'JSCWebWorker.cpp', 'MethodCall.cpp', @@ -130,6 +131,7 @@ react_library( 'JSCLegacyTracing.h', 'JSCMemory.h', 'JSCPerfStats.h', + 'JSCSamplingProfiler.h', 'JSCTracing.h', ], exported_headers = [ diff --git a/ReactCommon/cxxreact/JSCExecutor.cpp b/ReactCommon/cxxreact/JSCExecutor.cpp index 8a2402776e16b6..25efa9f3ecb120 100644 --- a/ReactCommon/cxxreact/JSCExecutor.cpp +++ b/ReactCommon/cxxreact/JSCExecutor.cpp @@ -20,6 +20,8 @@ #include "SystraceSection.h" #include "Value.h" +#include "JSCSamplingProfiler.h" + #if defined(WITH_JSC_EXTRA_TRACING) || DEBUG #include "JSCTracing.h" #endif @@ -223,6 +225,8 @@ void JSCExecutor::initOnJSVMThread() throw(JSException) { addNativeProfilingHooks(m_context); addNativeTracingLegacyHooks(m_context); PerfLogging::installNativeHooks(m_context); + + initSamplingProfilerOnMainJSCThread(m_context); #endif #ifdef WITH_FB_MEMORY_PROFILING diff --git a/ReactCommon/cxxreact/JSCSamplingProfiler.cpp b/ReactCommon/cxxreact/JSCSamplingProfiler.cpp new file mode 100644 index 00000000000000..936ee41e028fe3 --- /dev/null +++ b/ReactCommon/cxxreact/JSCSamplingProfiler.cpp @@ -0,0 +1,19 @@ +// Copyright 2004-present Facebook. All Rights Reserved. + +#ifdef WITH_JSC_EXTRA_TRACING + +#include "JSCSamplingProfiler.h" + +#include + +namespace facebook { +namespace react { + +void initSamplingProfilerOnMainJSCThread(JSGlobalContextRef ctx) { + JSStartSamplingProfilingOnMainJSCThread(ctx); +} + +} +} + +#endif // WITH_JSC_EXTRA_TRACING diff --git a/ReactCommon/cxxreact/JSCSamplingProfiler.h b/ReactCommon/cxxreact/JSCSamplingProfiler.h new file mode 100644 index 00000000000000..ec8d4e8751fc0b --- /dev/null +++ b/ReactCommon/cxxreact/JSCSamplingProfiler.h @@ -0,0 +1,16 @@ +// Copyright 2004-present Facebook. All Rights Reserved. + +#pragma once + +#ifdef WITH_JSC_EXTRA_TRACING + +#include + +namespace facebook { +namespace react { + +void initSamplingProfilerOnMainJSCThread(JSGlobalContextRef ctx); +} +} + +#endif // WITH_JSC_EXTRA_TRACING