Skip to content

Commit

Permalink
facebook#6 Notify SamplingProfiler of the main MachineThread
Browse files Browse the repository at this point in the history
Reviewed By: bnham

Differential Revision: D3503444

fbshipit-source-id: a2e9a692cd5badac5a15416844c8497f88021a5e
  • Loading branch information
lukaspiatkowski authored and Morgan Pretty committed Aug 24, 2016
1 parent 2cf0fee commit d4adc8f
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ReactCommon/cxxreact/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ react_library(
'JSCLegacyTracing.cpp',
'JSCMemory.cpp',
'JSCPerfStats.cpp',
'JSCSamplingProfiler.cpp',
'JSCTracing.cpp',
'JSCWebWorker.cpp',
'MethodCall.cpp',
Expand All @@ -130,6 +131,7 @@ react_library(
'JSCLegacyTracing.h',
'JSCMemory.h',
'JSCPerfStats.h',
'JSCSamplingProfiler.h',
'JSCTracing.h',
],
exported_headers = [
Expand Down
4 changes: 4 additions & 0 deletions ReactCommon/cxxreact/JSCExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#include "SystraceSection.h"
#include "Value.h"

#include "JSCSamplingProfiler.h"

#if defined(WITH_JSC_EXTRA_TRACING) || DEBUG
#include "JSCTracing.h"
#endif
Expand Down Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions ReactCommon/cxxreact/JSCSamplingProfiler.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright 2004-present Facebook. All Rights Reserved.

#ifdef WITH_JSC_EXTRA_TRACING

#include "JSCSamplingProfiler.h"

#include <JavaScriptCore/API/JSProfilerPrivate.h>

namespace facebook {
namespace react {

void initSamplingProfilerOnMainJSCThread(JSGlobalContextRef ctx) {
JSStartSamplingProfilingOnMainJSCThread(ctx);
}

}
}

#endif // WITH_JSC_EXTRA_TRACING
16 changes: 16 additions & 0 deletions ReactCommon/cxxreact/JSCSamplingProfiler.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright 2004-present Facebook. All Rights Reserved.

#pragma once

#ifdef WITH_JSC_EXTRA_TRACING

#include <JavaScriptCore/JSContextRef.h>

namespace facebook {
namespace react {

void initSamplingProfilerOnMainJSCThread(JSGlobalContextRef ctx);
}
}

#endif // WITH_JSC_EXTRA_TRACING

0 comments on commit d4adc8f

Please sign in to comment.