From 1a7c231ef35812e8d4a79cd2482c69b10c52dc4a Mon Sep 17 00:00:00 2001 From: Pieter De Baets Date: Mon, 5 Sep 2016 11:11:37 -0700 Subject: [PATCH] Remove last arg from RCTProfileEnd, make macro's function-like Reviewed By: tadeuzagallo Differential Revision: D3801302 fbshipit-source-id: 297a58db876366e21e232094c1361aa0dcd9016d --- React/Base/RCTBatchedBridge.m | 38 ++++++++++++++----------------- React/Base/RCTBridge.m | 2 +- React/Base/RCTDisplayLink.m | 2 +- React/Base/RCTModuleData.mm | 24 +++++++++---------- React/Base/RCTModuleMethod.m | 4 ++++ React/Base/RCTPerformanceLogger.m | 2 +- React/Base/RCTRootView.m | 2 +- React/Executors/RCTJSCExecutor.mm | 34 +++++++++++++-------------- React/Modules/RCTUIManager.m | 9 ++++---- React/Profiler/RCTProfile.h | 14 +++++------- React/Profiler/RCTProfile.m | 37 ++++++++---------------------- 11 files changed, 73 insertions(+), 95 deletions(-) diff --git a/React/Base/RCTBatchedBridge.m b/React/Base/RCTBatchedBridge.m index 2302466220..1128b3590a 100644 --- a/React/Base/RCTBatchedBridge.m +++ b/React/Base/RCTBatchedBridge.m @@ -146,7 +146,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithDelegate:(id)dele [performanceLogger markStartForTag:RCTPLNativeModulePrepareConfig]; config = [weakSelf moduleConfig]; [performanceLogger markStopForTag:RCTPLNativeModulePrepareConfig]; - RCT_PROFILE_END_EVENT(0, @"", nil); + RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @""); } }); @@ -174,7 +174,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithDelegate:(id)dele } }); - RCT_PROFILE_END_EVENT(0, @"", nil); + RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @""); } - (void)loadSource:(RCTSourceLoadBlock)_onSourceLoad @@ -334,7 +334,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithDelegate:(id)dele _javaScriptExecutor = (id)module; } } - RCT_PROFILE_END_EVENT(0, @"", nil); + RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @""); // The executor is a bridge module, but we want it to be instantiated before // any other module has access to the bridge, in case they need the JS thread. @@ -352,7 +352,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithDelegate:(id)dele // NOTE: _javaScriptExecutor is a weak reference _javaScriptExecutor = executorModule; } - RCT_PROFILE_END_EVENT(0, @"", nil); + RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @""); // Set up moduleData for automatically-exported modules RCT_PROFILE_BEGIN_EVENT(0, @"ModuleData", nil); @@ -388,7 +388,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithDelegate:(id)dele _moduleDataByID = [moduleDataByID copy]; _moduleDataByName = [moduleDataByName copy]; _moduleClassesByID = [moduleClassesByID copy]; - RCT_PROFILE_END_EVENT(0, @"", nil); + RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @""); // Synchronously set up the pre-initialized modules RCT_PROFILE_BEGIN_EVENT(0, @"extraModules", nil); @@ -404,7 +404,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithDelegate:(id)dele (void)[moduleData instance]; } } - RCT_PROFILE_END_EVENT(0, @"", nil); + RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @""); // From this point on, RCTDidInitializeModuleNotification notifications will // be sent the first time a module is accessed. @@ -413,7 +413,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithDelegate:(id)dele [self prepareModulesWithDispatchGroup:dispatchGroup]; [_performanceLogger markStopForTag:RCTPLNativeModuleInit]; - RCT_PROFILE_END_EVENT(0, @"", nil); + RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @""); } - (void)prepareModulesWithDispatchGroup:(dispatch_group_t)dispatchGroup @@ -471,7 +471,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithDelegate:(id)dele } [_performanceLogger setValue:_modulesInitializedOnMainQueue forTag:RCTPLNativeModuleMainThreadUsesCount]; - RCT_PROFILE_END_EVENT(0, @"", nil); + RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @""); } - (void)whitelistedModulesDidChange @@ -580,7 +580,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithDelegate:(id)dele for (dispatch_block_t call in pendingCalls) { call(); } - RCT_PROFILE_END_EVENT(0, @"", nil); + RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @""); } - (void)stopLoadingWithError:(NSError *)error @@ -676,7 +676,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithBundleURL:(__unused NSURL *)bundleUR block(); } - RCT_PROFILE_END_EVENT(0, @"", nil); + RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @""); }]; } else if (queue) { dispatch_async(queue, block); @@ -780,7 +780,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithBundleURL:(__unused NSURL *)bundleUR completion(); } } queue:RCTJSThread]; - RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"", nil); + RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @""); } /** @@ -833,13 +833,8 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithBundleURL:(__unused NSURL *)bundleUR RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways, @"FetchApplicationScriptCallbacks", nil); [self->_javaScriptExecutor flushedQueue:^(id json, NSError *error) { - RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"js_call,init", @{ - @"json": RCTNullIfNil(json), - @"error": RCTNullIfNil(error), - }); - + RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"js_call,init"); [self handleBuffer:json batchEnded:YES]; - onComplete(error); }]; }]; @@ -957,9 +952,12 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithBundleURL:(__unused NSURL *)bundleUR dispatch_block_t block = ^{ RCTProfileEndFlowEvent(); - RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways, @"-[RCTBatchedBridge handleBuffer:]", nil); NSOrderedSet *calls = [buckets objectForKey:queue]; + RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways, @"-[RCTBatchedBridge handleBuffer:]", (@{ + @"calls": @(calls.count), + })); + @autoreleasepool { for (NSNumber *indexObj in calls) { NSUInteger index = indexObj.unsignedIntegerValue; @@ -978,9 +976,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithBundleURL:(__unused NSURL *)bundleUR } } - RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"objc_call,dispatch_async", @{ - @"calls": @(calls.count), - }); + RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"objc_call,dispatch_async"); }; [self dispatchBlock:block queue:queue]; diff --git a/React/Base/RCTBridge.m b/React/Base/RCTBridge.m index c4ccf4e668..16086005bb 100644 --- a/React/Base/RCTBridge.m +++ b/React/Base/RCTBridge.m @@ -251,7 +251,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init) [self createBatchedBridge]; - RCT_PROFILE_END_EVENT(0, @"", nil); + RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @""); } - (void)createBatchedBridge diff --git a/React/Base/RCTDisplayLink.m b/React/Base/RCTDisplayLink.m index 7042dc0b69..a53d35701f 100644 --- a/React/Base/RCTDisplayLink.m +++ b/React/Base/RCTDisplayLink.m @@ -127,7 +127,7 @@ RCTProfileImmediateEvent(RCTProfileTagAlways, @"JS Thread Tick", displayLink.timestamp, 'g'); - RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"objc_call", nil); + RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"objc_call"); } - (void)updateJSDisplayLinkState diff --git a/React/Base/RCTModuleData.mm b/React/Base/RCTModuleData.mm index e92aff4429..340badc50e 100644 --- a/React/Base/RCTModuleData.mm +++ b/React/Base/RCTModuleData.mm @@ -94,7 +94,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init); } RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways, @"[RCTModuleData setUpInstanceAndBridge] [_moduleClass new]", @{ @"moduleClass": NSStringFromClass(_moduleClass) }); _instance = [_moduleClass new]; - RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"", nil); + RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @""); if (!_instance) { // Module init returned nil, probably because automatic instantatiation // of the module is not supported, and it is supposed to be passed in to @@ -118,7 +118,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init); [self setUpMethodQueue]; } - RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"", nil); + RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @""); // This is called outside of the lock in order to prevent deadlock issues // because the logic in `finishSetupForInstance` can cause @@ -151,7 +151,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init); "permitted. You must either @synthesize the bridge property, " "or provide your own setter method.", self.name); } - RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"", nil); + RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @""); } } @@ -164,7 +164,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init); [[NSNotificationCenter defaultCenter] postNotificationName:RCTDidInitializeModuleNotification object:_bridge userInfo:@{@"module": _instance}]; - RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"", nil); + RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @""); } } @@ -194,7 +194,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init); } } } - RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"", nil); + RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @""); } } @@ -208,7 +208,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init); - (id)instance { if (!_setupComplete) { - RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways, [NSString stringWithFormat:@"[RCTModuleData instanceForClass:%@]", _moduleClass], nil); + RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways, ([NSString stringWithFormat:@"[RCTModuleData instanceForClass:%@]", _moduleClass]), nil); if (_requiresMainQueueSetup) { // The chances of deadlock here are low, because module init very rarely // calls out to other threads, however we can't control when a module might @@ -225,11 +225,11 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init); [self setUpInstanceAndBridge]; }, YES); #pragma clang diagnostic pop - RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"", nil); + RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @""); } else { [self setUpInstanceAndBridge]; } - RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"", nil); + RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @""); } return _instance; } @@ -281,7 +281,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init); - (void)gatherConstants { if (_hasConstantsToExport && !_constantsToExport) { - RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways, [NSString stringWithFormat:@"[RCTModuleData gatherConstants] %@", _moduleClass], nil); + RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways, ([NSString stringWithFormat:@"[RCTModuleData gatherConstants] %@", _moduleClass]), nil); (void)[self instance]; if (!RCTIsMainQueue()) { RCTLogWarn(@"Required dispatch_sync to load constants for %@. This may lead to deadlocks", _moduleClass); @@ -292,7 +292,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init); self->_constantsToExport = [self->_instance constantsToExport] ?: @{}; }, YES); #pragma clang diagnostic pop - RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"", nil); + RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @""); } } @@ -306,7 +306,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init); return (id)kCFNull; // Nothing to export } - RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways, [NSString stringWithFormat:@"[RCTModuleData config] %@", _moduleClass], nil); + RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways, ([NSString stringWithFormat:@"[RCTModuleData config] %@", _moduleClass]), nil); NSMutableArray *methods = self.methods.count ? [NSMutableArray new] : nil; NSMutableArray *promiseMethods = nil; @@ -335,7 +335,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init); RCTNullIfNil(promiseMethods), RCTNullIfNil(syncMethods) ]; - RCT_PROFILE_END_EVENT(RCTProfileTagAlways, ([NSString stringWithFormat:@"[RCTModuleData config] %@", _moduleClass]), nil); + RCT_PROFILE_END_EVENT(RCTProfileTagAlways, ([NSString stringWithFormat:@"[RCTModuleData config] %@", _moduleClass])); return config; } diff --git a/React/Base/RCTModuleMethod.m b/React/Base/RCTModuleMethod.m index 1395bc9c46..517dcc2558 100644 --- a/React/Base/RCTModuleMethod.m +++ b/React/Base/RCTModuleMethod.m @@ -18,6 +18,7 @@ #import "RCTLog.h" #import "RCTParserUtils.h" #import "RCTUtils.h" +#import "RCTProfile.h" typedef BOOL (^RCTArgumentBlock)(RCTBridge *, NSUInteger, id); @@ -399,7 +400,10 @@ SEL RCTParseMethodSignature(NSString *methodSignature, NSArray_bridge configForModuleName:moduleName]; NSString *result = config ? RCTJSONStringify(config, NULL) : nil; - RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"js_call,config", @{ @"moduleName": moduleName }); + RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"js_call,config"); return result; }; @@ -444,7 +444,7 @@ static NSThread *newJavaScriptThread(void) RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways, @"nativeFlushQueueImmediate", nil); [strongSelf->_bridge handleBuffer:calls batchEnded:NO]; - RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"js_call", nil); + RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"js_call"); }; context[@"nativeCallSyncHook"] = ^id(NSUInteger module, NSUInteger method, NSArray *args) { @@ -455,7 +455,7 @@ static NSThread *newJavaScriptThread(void) RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways, @"nativeCallSyncHook", nil); id result = [strongSelf->_bridge callNativeModule:module method:method params:args]; - RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"js_call,config", nil); + RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"js_call,config"); return result; }; @@ -543,7 +543,7 @@ static void installBasicSynchronousHooksOnContext(JSContext *context) RCT_PROFILE_BEGIN_EVENT(tag.longLongValue, profileName, args); }; context[@"nativeTraceEndSection"] = ^(NSNumber *tag) { - RCT_PROFILE_END_EVENT(tag.longLongValue, @"console", nil); + RCT_PROFILE_END_EVENT(tag.longLongValue, @"console"); }; RCTCookieMap *cookieMap = [RCTCookieMap new]; context[@"nativeTraceBeginAsyncSection"] = ^(uint64_t tag, NSString *name, NSUInteger cookie) { @@ -557,7 +557,7 @@ static void installBasicSynchronousHooksOnContext(JSContext *context) newCookie = it->second; cookieMap->_cookieMap.erase(it); } - RCTProfileEndAsyncEvent(tag, @"js,async", newCookie, name, @"JS async", nil); + RCTProfileEndAsyncEvent(tag, @"js,async", newCookie, name, @"JS async"); }; #endif } @@ -654,7 +654,7 @@ static void installBasicSynchronousHooksOnContext(JSContext *context) return; } - RCT_PROFILE_BEGIN_EVENT(0, @"executeJSCall", @{@"method": method, @"args": arguments}); + RCT_PROFILE_BEGIN_EVENT(0, @"executeJSCall", (@{@"method": method, @"args": arguments})); RCTJSCWrapper *jscWrapper = strongSelf->_jscWrapper; JSContext *context = strongSelf->_context.context; @@ -711,7 +711,7 @@ static void installBasicSynchronousHooksOnContext(JSContext *context) } } - RCT_PROFILE_END_EVENT(0, @"js_call", nil); + RCT_PROFILE_END_EVENT(0, @"js_call"); onComplete(objcValue, error); }]; @@ -785,7 +785,7 @@ static NSData *loadPossiblyBundledApplicationScript(NSData *script, NSURL *sourc script = nullTerminatedScript; } - RCT_PROFILE_END_EVENT(0, @"", nil); + RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @""); return script; } @@ -798,8 +798,9 @@ static void registerNativeRequire(JSContext *context, RCTJSCExecutor *executor) static NSError *executeApplicationScript(NSData *script, NSURL *sourceURL, RCTJSCWrapper *jscWrapper, RCTPerformanceLogger *performanceLogger, JSGlobalContextRef ctx) { - RCT_PROFILE_BEGIN_EVENT(0, @"executeApplicationScript / execute script", - @{ @"url": sourceURL.absoluteString, @"size": @(script.length) }); + RCT_PROFILE_BEGIN_EVENT(0, @"executeApplicationScript / execute script", (@{ + @"url": sourceURL.absoluteString, @"size": @(script.length) + })); [performanceLogger markStartForTag:RCTPLScriptExecution]; JSValueRef jsError = NULL; JSStringRef execJSString = jscWrapper->JSStringCreateWithUTF8CString((const char *)script.bytes); @@ -809,7 +810,7 @@ static NSError *executeApplicationScript(NSData *script, NSURL *sourceURL, RCTJS jscWrapper->JSStringRelease(execJSString); [performanceLogger markStopForTag:RCTPLScriptExecution]; NSError *error = result ? nil : RCTNSErrorFromJSError(jscWrapper, ctx, jsError); - RCT_PROFILE_END_EVENT(0, @"js_call", nil); + RCT_PROFILE_END_EVENT(0, @"js_call"); return error; } @@ -872,7 +873,7 @@ static NSError *executeApplicationScript(NSData *script, NSURL *sourceURL, RCTJS error = RCTNSErrorFromJSError(jscWrapper, ctx, jsError); } } - RCT_PROFILE_END_EVENT(0, @"js_call,json_call", nil); + RCT_PROFILE_END_EVENT(0, @"js_call,json_call"); if (onComplete) { onComplete(error); @@ -923,8 +924,7 @@ static void executeRandomAccessModule(RCTJSCExecutor *executor, uint32_t moduleI [_performanceLogger addValue:1 forTag:RCTPLRAMNativeRequiresCount]; [_performanceLogger appendStartForTag:RCTPLRAMNativeRequires]; - RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways, - [@"nativeRequire_" stringByAppendingFormat:@"%@", moduleID], nil); + RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways, ([@"nativeRequire_" stringByAppendingFormat:@"%@", moduleID]), nil); const uint32_t ID = [moduleID unsignedIntValue]; @@ -941,7 +941,7 @@ static void executeRandomAccessModule(RCTJSCExecutor *executor, uint32_t moduleI executeRandomAccessModule(self, ID, NSSwapLittleIntToHost(moduleData->offset), size); } - RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"js_call", nil); + RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"js_call"); [_performanceLogger appendStopForTag:RCTPLRAMNativeRequires]; } diff --git a/React/Modules/RCTUIManager.m b/React/Modules/RCTUIManager.m index a5915872b2..f27c76d77e 100644 --- a/React/Modules/RCTUIManager.m +++ b/React/Modules/RCTUIManager.m @@ -278,7 +278,7 @@ RCT_EXPORT_MODULE() self->_bridge = nil; [[NSNotificationCenter defaultCenter] removeObserver:self]; - RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"", nil); + RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @""); }); } @@ -1150,7 +1150,9 @@ RCT_EXPORT_METHOD(dispatchViewManagerCommand:(nonnull NSNumber *)reactTag RCTProfileBeginFlowEvent(); dispatch_async(dispatch_get_main_queue(), ^{ RCTProfileEndFlowEvent(); - RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways, @"-[UIManager flushUIBlocks]", nil); + RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways, @"-[UIManager flushUIBlocks]", (@{ + @"count": @(previousPendingUIBlocks.count), + })); @try { for (RCTViewManagerUIBlock block in previousPendingUIBlocks) { block(self, self->_viewRegistry); @@ -1159,9 +1161,6 @@ RCT_EXPORT_METHOD(dispatchViewManagerCommand:(nonnull NSNumber *)reactTag @catch (NSException *exception) { RCTLogError(@"Exception thrown while executing UI block: %@", exception); } - RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"objc_call", @{ - @"count": @(previousPendingUIBlocks.count), - }); }); } } diff --git a/React/Profiler/RCTProfile.h b/React/Profiler/RCTProfile.h index 4a9aafaab2..74dd230942 100644 --- a/React/Profiler/RCTProfile.h +++ b/React/Profiler/RCTProfile.h @@ -69,12 +69,12 @@ RCT_EXTERN void _RCTProfileBeginEvent(NSThread *calleeThread, uint64_t tag, NSString *name, NSDictionary *args); -#define RCT_PROFILE_BEGIN_EVENT(...) \ +#define RCT_PROFILE_BEGIN_EVENT(tag, name, args) \ do { \ if (RCTProfileIsProfiling()) { \ NSThread *__calleeThread = [NSThread currentThread]; \ NSTimeInterval __time = CACurrentMediaTime(); \ - _RCTProfileBeginEvent(__calleeThread, __time, __VA_ARGS__); \ + _RCTProfileBeginEvent(__calleeThread, __time, tag, name, args); \ } \ } while(0) @@ -87,16 +87,15 @@ RCT_EXTERN void _RCTProfileEndEvent(NSThread *calleeThread, NSString *threadName, NSTimeInterval time, uint64_t tag, - NSString *category, - NSDictionary *args); + NSString *category); -#define RCT_PROFILE_END_EVENT(...) \ +#define RCT_PROFILE_END_EVENT(tag, category) \ do { \ if (RCTProfileIsProfiling()) { \ NSThread *__calleeThread = [NSThread currentThread]; \ NSString *__threadName = RCTCurrentThreadName(); \ NSTimeInterval __time = CACurrentMediaTime(); \ - _RCTProfileEndEvent(__calleeThread, __threadName, __time, __VA_ARGS__); \ + _RCTProfileEndEvent(__calleeThread, __threadName, __time, tag, category); \ } \ } while(0) @@ -116,8 +115,7 @@ RCT_EXTERN void RCTProfileEndAsyncEvent(uint64_t tag, NSString *category, NSUInteger cookie, NSString *name, - NSString *threadName, - NSDictionary *args); + NSString *threadName); /** * An event that doesn't have a duration (i.e. Notification, VSync, etc) diff --git a/React/Profiler/RCTProfile.m b/React/Profiler/RCTProfile.m index 8a63d99d56..7a9edf8be8 100644 --- a/React/Profiler/RCTProfile.m +++ b/React/Profiler/RCTProfile.m @@ -136,22 +136,6 @@ static NSDictionary *RCTProfileGetMemoryUsage(void) } } -static NSDictionary *RCTProfileMergeArgs(NSDictionary *args0, NSDictionary *args1) -{ - args0 = RCTNilIfNull(args0); - args1 = RCTNilIfNull(args1); - - if (!args0 && args1) { - args0 = args1; - } else if (args0 && args1) { - NSMutableDictionary *d = [args0 mutableCopy]; - [d addEntriesFromDictionary:args1]; - args0 = [d copy]; - } - - return RCTNullIfNil(args0); -} - #pragma mark - Module hooks static const char *RCTProfileProxyClassName(Class class) @@ -207,13 +191,13 @@ void RCTProfileTrampolineStart(id self, SEL cmd) * block. */ Class klass = [self class]; - RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways, [NSString stringWithFormat:@"-[%s %s]", class_getName(klass), sel_getName(cmd)], nil); + RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways, ([NSString stringWithFormat:@"-[%s %s]", class_getName(klass), sel_getName(cmd)]), nil); } RCT_EXTERN void RCTProfileTrampolineEnd(void); void RCTProfileTrampolineEnd(void) { - RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"objc_call,modules,auto", nil); + RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"objc_call,modules,auto"); } static UIView *(*originalCreateView)(RCTComponentData *, SEL, NSNumber *); @@ -331,7 +315,7 @@ void RCTProfileHookModules(RCTBridge *bridge) } queue:moduleData.methodQueue]; } } - RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"", nil); + RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @""); } static void RCTProfileUnhookInstance(id instance) @@ -569,13 +553,12 @@ void _RCTProfileEndEvent( NSString *threadName, NSTimeInterval time, uint64_t tag, - NSString *category, - NSDictionary *args + NSString *category ) { CHECK(); if (callbacks != NULL) { - callbacks->end_section(tag, args.count, RCTProfileSystraceArgsFromNSDictionary(args)); + callbacks->end_section(tag, 0, nil); return; } @@ -589,7 +572,6 @@ void _RCTProfileEndEvent( } NSNumber *start = event[0]; - RCTProfileAddEvent(RCTProfileTraceEvents, @"tid": threadName, @"name": event[1], @@ -597,7 +579,7 @@ void _RCTProfileEndEvent( @"ph": @"X", @"ts": start, @"dur": @(RCTProfileTimestamp(time).doubleValue - start.doubleValue), - @"args": RCTProfileMergeArgs(event[2], args), + @"args": event[2], ); }); } @@ -634,13 +616,12 @@ void RCTProfileEndAsyncEvent( NSString *category, NSUInteger cookie, NSString *name, - NSString *threadName, - NSDictionary *args + NSString *threadName ) { CHECK(); if (callbacks != NULL) { - callbacks->end_async_section(tag, name.UTF8String, (int)(cookie % INT_MAX), args.count, RCTProfileSystraceArgsFromNSDictionary(args)); + callbacks->end_async_section(tag, name.UTF8String, (int)(cookie % INT_MAX), 0, nil); return; } @@ -659,7 +640,7 @@ void RCTProfileEndAsyncEvent( @"ph": @"X", @"ts": event[0], @"dur": @(endTimestamp.doubleValue - [event[0] doubleValue]), - @"args": RCTProfileMergeArgs(event[2], args), + @"args": event[2], ); [RCTProfileOngoingEvents removeObjectForKey:@(cookie)]; }