From 7c97008fa81a60c999ca935db1093c76dcdf7172 Mon Sep 17 00:00:00 2001 From: Alexey Lang Date: Thu, 16 Feb 2017 11:30:39 -0800 Subject: [PATCH] Support QuickPerformanceLogger.js in the old bridge Reviewed By: javache Differential Revision: D4566647 fbshipit-source-id: 1a6448b89b14f4ce9f2192e9f7b4e28b8dcb52b7 --- .../Performance/QuickPerformanceLogger.js | 22 +++++++++++++++++++ React/Executors/RCTJSCExecutor.mm | 5 +++++ 2 files changed, 27 insertions(+) diff --git a/Libraries/Performance/QuickPerformanceLogger.js b/Libraries/Performance/QuickPerformanceLogger.js index 42f75f688..70a7e350a 100644 --- a/Libraries/Performance/QuickPerformanceLogger.js +++ b/Libraries/Performance/QuickPerformanceLogger.js @@ -51,6 +51,28 @@ var QuickPerformanceLogger = { } }, + markerTag(markerId, tag, opts) { + if (typeof markerId !== 'number' || typeof tag !== 'string') { + return; + } + if (global.nativeQPLMarkerTag) { + opts = fixOpts(opts); + global.nativeQPLMarkerTag(markerId, opts.instanceKey, tag); + } + }, + + markerAnnotate(markerId, annotationKey, annotationValue, opts) { + if (typeof markerId !== 'number' || + typeof annotationKey !== 'string' || + typeof annotationValue !== 'string') { + return; + } + if (global.nativeQPLMarkerAnnotate) { + opts = fixOpts(opts); + global.nativeQPLMarkerAnnotate(markerId, opts.instanceKey, annotationKey, annotationValue); + } + }, + markerCancel(markerId, opts) { if (typeof markerId !== 'number') { return; diff --git a/React/Executors/RCTJSCExecutor.mm b/React/Executors/RCTJSCExecutor.mm index 8477e87b5..3fe8ca9a3 100644 --- a/React/Executors/RCTJSCExecutor.mm +++ b/React/Executors/RCTJSCExecutor.mm @@ -40,6 +40,9 @@ RCT_EXTERN NSString *const RCTFBJSValueClassKey = @"_RCTFBJSValueClassKey"; static NSString *const RCTJSCProfilerEnabledDefaultsKey = @"RCTJSCProfilerEnabled"; +__attribute__((weak)) void RCTFBQuickPerformanceLoggerConfigureHooks(JSContext *context); +void RCTFBQuickPerformanceLoggerConfigureHooks(JSContext *context) { } + struct __attribute__((packed)) ModuleData { uint32_t offset; uint32_t size; @@ -356,6 +359,8 @@ static NSThread *newJavaScriptThread(void) threadDictionary[RCTFBJSValueClassKey] = JSC_JSValue(contextRef); } + RCTFBQuickPerformanceLoggerConfigureHooks(context); + __weak RCTJSCExecutor *weakSelf = self; context[@"nativeRequireModuleConfig"] = ^NSArray *(NSString *moduleName) { RCTJSCExecutor *strongSelf = weakSelf;