mirror of
https://github.com/status-im/react-native.git
synced 2025-02-27 16:40:38 +00:00
Redo cookie map for nativeTraceBeginAsyncSection
Reviewed By: javache Differential Revision: D3528604 fbshipit-source-id: 0feff3a09214af7c9c193733a5ad05d7de0dd21d
This commit is contained in:
parent
dd5bb7b9e0
commit
2b397c5094
@ -13,6 +13,7 @@
|
|||||||
#import <memory>
|
#import <memory>
|
||||||
#import <pthread.h>
|
#import <pthread.h>
|
||||||
#import <string>
|
#import <string>
|
||||||
|
#import <unordered_map>
|
||||||
|
|
||||||
#import <UIKit/UIDevice.h>
|
#import <UIKit/UIDevice.h>
|
||||||
|
|
||||||
@ -63,6 +64,16 @@ struct RandomAccessBundleStartupCode {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if RCT_PROFILE
|
||||||
|
@interface RCTCookieMap : NSObject
|
||||||
|
{
|
||||||
|
@package
|
||||||
|
std::unordered_map<NSUInteger, NSUInteger> _cookieMap;
|
||||||
|
}
|
||||||
|
@end
|
||||||
|
@implementation RCTCookieMap @end
|
||||||
|
#endif
|
||||||
|
|
||||||
@interface RCTJavaScriptContext : NSObject <RCTInvalidating>
|
@interface RCTJavaScriptContext : NSObject <RCTInvalidating>
|
||||||
|
|
||||||
@property (nonatomic, strong, readonly) JSContext *context;
|
@property (nonatomic, strong, readonly) JSContext *context;
|
||||||
@ -129,7 +140,6 @@ RCT_NOT_IMPLEMENTED(-(instancetype)init)
|
|||||||
{
|
{
|
||||||
RCTJavaScriptContext *_context;
|
RCTJavaScriptContext *_context;
|
||||||
NSThread *_javaScriptThread;
|
NSThread *_javaScriptThread;
|
||||||
CFMutableDictionaryRef _cookieMap;
|
|
||||||
|
|
||||||
RandomAccessBundleData _randomAccessBundle;
|
RandomAccessBundleData _randomAccessBundle;
|
||||||
JSValueRef _batchedBridgeRef;
|
JSValueRef _batchedBridgeRef;
|
||||||
@ -327,7 +337,6 @@ static void RCTInstallJSCProfiler(RCTBridge *bridge, JSContextRef context)
|
|||||||
{
|
{
|
||||||
__weak RCTJSCExecutor *weakSelf = self;
|
__weak RCTJSCExecutor *weakSelf = self;
|
||||||
|
|
||||||
_cookieMap = CFDictionaryCreateMutable(NULL, 0, NULL, NULL);
|
|
||||||
__weak RCTBridge *weakBridge = _bridge;
|
__weak RCTBridge *weakBridge = _bridge;
|
||||||
#ifndef __clang_analyzer__
|
#ifndef __clang_analyzer__
|
||||||
_bridge.flowIDMap = CFDictionaryCreateMutable(NULL, 0, NULL, NULL);
|
_bridge.flowIDMap = CFDictionaryCreateMutable(NULL, 0, NULL, NULL);
|
||||||
@ -390,25 +399,6 @@ static void RCTInstallJSCProfiler(RCTBridge *bridge, JSContextRef context)
|
|||||||
};
|
};
|
||||||
|
|
||||||
#if RCT_PROFILE
|
#if RCT_PROFILE
|
||||||
context[@"nativeTraceBeginAsyncSection"] = ^(uint64_t tag, NSString *name, NSUInteger cookie) {
|
|
||||||
RCTJSCExecutor *strongSelf2 = weakSelf;
|
|
||||||
if (!strongSelf2) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
NSUInteger newCookie = RCTProfileBeginAsyncEvent(tag, name, nil);
|
|
||||||
CFDictionarySetValue(strongSelf2->_cookieMap, (const void *)cookie, (const void *)newCookie);
|
|
||||||
};
|
|
||||||
|
|
||||||
context[@"nativeTraceEndAsyncSection"] = ^(uint64_t tag, NSString *name, NSUInteger cookie) {
|
|
||||||
RCTJSCExecutor *strongSelf2 = weakSelf;
|
|
||||||
if (!strongSelf2) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
NSUInteger newCookie = (NSUInteger)CFDictionaryGetValue(strongSelf2->_cookieMap, (const void *)cookie);
|
|
||||||
RCTProfileEndAsyncEvent(tag, @"js,async", newCookie, name, @"JS async", nil);
|
|
||||||
CFDictionaryRemoveValue(strongSelf2->_cookieMap, (const void *)cookie);
|
|
||||||
};
|
|
||||||
|
|
||||||
context[@"nativeTraceBeginAsyncFlow"] = ^(__unused uint64_t tag, __unused NSString *name, int64_t cookie) {
|
context[@"nativeTraceBeginAsyncFlow"] = ^(__unused uint64_t tag, __unused NSString *name, int64_t cookie) {
|
||||||
if (RCTProfileIsProfiling()) {
|
if (RCTProfileIsProfiling()) {
|
||||||
[weakBridge.flowIDMapLock lock];
|
[weakBridge.flowIDMapLock lock];
|
||||||
@ -480,6 +470,20 @@ static void RCTInstallJSCProfiler(RCTBridge *bridge, JSContextRef context)
|
|||||||
context[@"nativeTraceEndSection"] = ^(NSNumber *tag) {
|
context[@"nativeTraceEndSection"] = ^(NSNumber *tag) {
|
||||||
RCT_PROFILE_END_EVENT(tag.longLongValue, @"console", nil);
|
RCT_PROFILE_END_EVENT(tag.longLongValue, @"console", nil);
|
||||||
};
|
};
|
||||||
|
RCTCookieMap *cookieMap = [RCTCookieMap new];
|
||||||
|
context[@"nativeTraceBeginAsyncSection"] = ^(uint64_t tag, NSString *name, NSUInteger cookie) {
|
||||||
|
NSUInteger newCookie = RCTProfileBeginAsyncEvent(tag, name, nil);
|
||||||
|
cookieMap->_cookieMap.insert({cookie, newCookie});
|
||||||
|
};
|
||||||
|
context[@"nativeTraceEndAsyncSection"] = ^(uint64_t tag, NSString *name, NSUInteger cookie) {
|
||||||
|
NSUInteger newCookie = 0;
|
||||||
|
const auto &it = cookieMap->_cookieMap.find(cookie);
|
||||||
|
if (it != cookieMap->_cookieMap.end()) {
|
||||||
|
newCookie = it->second;
|
||||||
|
cookieMap->_cookieMap.erase(it);
|
||||||
|
}
|
||||||
|
RCTProfileEndAsyncEvent(tag, @"js,async", newCookie, name, @"JS async", nil);
|
||||||
|
};
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -521,10 +525,6 @@ static void RCTInstallJSCProfiler(RCTBridge *bridge, JSContextRef context)
|
|||||||
RCTJSCWrapperRelease(_jscWrapper);
|
RCTJSCWrapperRelease(_jscWrapper);
|
||||||
_jscWrapper = NULL;
|
_jscWrapper = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_cookieMap) {
|
|
||||||
CFRelease(_cookieMap);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)flushedQueue:(RCTJavaScriptCallback)onComplete
|
- (void)flushedQueue:(RCTJavaScriptCallback)onComplete
|
||||||
|
Loading…
x
Reference in New Issue
Block a user