From edb9fce9c3378ffe7b036f1e3bdf89e86979ab64 Mon Sep 17 00:00:00 2001 From: Lukas Piatkowski Date: Fri, 15 Jul 2016 11:51:10 -0700 Subject: [PATCH] #6 Notify SamplingProfiler of the main MachineThread Reviewed By: bnham Differential Revision: D3503444 fbshipit-source-id: a2e9a692cd5badac5a15416844c8497f88021a5e --- ReactCommon/cxxreact/BUCK | 2 ++ ReactCommon/cxxreact/JSCExecutor.cpp | 4 ++++ ReactCommon/cxxreact/JSCSamplingProfiler.cpp | 19 +++++++++++++++++++ ReactCommon/cxxreact/JSCSamplingProfiler.h | 16 ++++++++++++++++ 4 files changed, 41 insertions(+) create mode 100644 ReactCommon/cxxreact/JSCSamplingProfiler.cpp create mode 100644 ReactCommon/cxxreact/JSCSamplingProfiler.h 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