From e8cbc4f893d262fb139fbc9f15d0355f3062fc89 Mon Sep 17 00:00:00 2001 From: Marc Horowitz Date: Thu, 18 Oct 2018 00:47:06 -0700 Subject: [PATCH] iOS files removed for switch to JSI Summary: JSI+JSCRuntime replaces direct use of JSC. This is like the previous diff, except for iOS. Reviewed By: RSNara Differential Revision: D9369108 fbshipit-source-id: 4ed2c0d660ba2a30edf699d95278c72cabcc9203 --- React/Base/RCTJSCErrorHandling.h | 31 -------------- React/Base/RCTJSCErrorHandling.mm | 41 ------------------ React/CxxBridge/RCTJSCHelpers.h | 15 ------- React/CxxBridge/RCTJSCHelpers.mm | 50 ---------------------- React/Modules/RCTJSCSamplingProfiler.h | 21 --------- React/Modules/RCTJSCSamplingProfiler.m | 59 -------------------------- 6 files changed, 217 deletions(-) delete mode 100644 React/Base/RCTJSCErrorHandling.h delete mode 100644 React/Base/RCTJSCErrorHandling.mm delete mode 100644 React/CxxBridge/RCTJSCHelpers.h delete mode 100644 React/CxxBridge/RCTJSCHelpers.mm delete mode 100644 React/Modules/RCTJSCSamplingProfiler.h delete mode 100644 React/Modules/RCTJSCSamplingProfiler.m diff --git a/React/Base/RCTJSCErrorHandling.h b/React/Base/RCTJSCErrorHandling.h deleted file mode 100644 index a48f8f59960..00000000000 --- a/React/Base/RCTJSCErrorHandling.h +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#import - -#import - -/** - Translates a given exception into an NSError. - - @param exception The JavaScript exception object to translate into an NSError. This must be - a JavaScript Error object, otherwise no stack trace information will be available. - - @return The translated NSError object - - - The JS exception's name property is incorporated in the NSError's localized description - - The JS exception's message property is the NSError's failure reason - - The JS exception's unsymbolicated stack trace is available via the NSError userInfo's RCTJSExceptionUnsymbolicatedStackTraceKey - */ -RCT_EXTERN NSError *RCTNSErrorFromJSError(JSValue *exception); - -/** - Translates a given exception into an NSError. - - @see RCTNSErrorFromJSError for details - */ -RCT_EXTERN NSError *RCTNSErrorFromJSErrorRef(JSValueRef exceptionRef, JSGlobalContextRef ctx); diff --git a/React/Base/RCTJSCErrorHandling.mm b/React/Base/RCTJSCErrorHandling.mm deleted file mode 100644 index f6d57427e91..00000000000 --- a/React/Base/RCTJSCErrorHandling.mm +++ /dev/null @@ -1,41 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#include "RCTJSCErrorHandling.h" - -#import - -#import "RCTAssert.h" -#import "RCTJSStackFrame.h" -#import "RCTLog.h" - -NSString *const RCTJSExceptionUnsymbolicatedStackTraceKey = @"RCTJSExceptionUnsymbolicatedStackTraceKey"; - -NSError *RCTNSErrorFromJSError(JSValue *exception) -{ - NSMutableDictionary *userInfo = [NSMutableDictionary dictionary]; - userInfo[NSLocalizedDescriptionKey] = [NSString stringWithFormat:@"Unhandled JS Exception: %@", [exception[@"name"] toString] ?: @"Unknown"]; - NSString *const exceptionMessage = [exception[@"message"] toString]; - if ([exceptionMessage length]) { - userInfo[NSLocalizedFailureReasonErrorKey] = exceptionMessage; - } - NSString *const stack = [exception[@"stack"] toString]; - if ([@"undefined" isEqualToString:stack]) { - RCTLogWarn(@"Couldn't get stack trace for %@:%@", exception[@"sourceURL"], exception[@"line"]); - } else if ([stack length]) { - NSArray *const unsymbolicatedFrames = [RCTJSStackFrame stackFramesWithLines:stack]; - userInfo[RCTJSStackTraceKey] = unsymbolicatedFrames; - } - return [NSError errorWithDomain:RCTErrorDomain code:1 userInfo:userInfo]; -} - -NSError *RCTNSErrorFromJSErrorRef(JSValueRef exceptionRef, JSGlobalContextRef ctx) -{ - JSContext *context = [JSC_JSContext(ctx) contextWithJSGlobalContextRef:ctx]; - JSValue *exception = [JSC_JSValue(ctx) valueWithJSValueRef:exceptionRef inContext:context]; - return RCTNSErrorFromJSError(exception); -} diff --git a/React/CxxBridge/RCTJSCHelpers.h b/React/CxxBridge/RCTJSCHelpers.h deleted file mode 100644 index 0ef272c8d11..00000000000 --- a/React/CxxBridge/RCTJSCHelpers.h +++ /dev/null @@ -1,15 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#pragma once - -/** - * This must be invoked on iOS to set up platform dependencies before - * creating an instance of JSCExecutor. - */ - -void RCTPrepareJSCExecutor(); diff --git a/React/CxxBridge/RCTJSCHelpers.mm b/React/CxxBridge/RCTJSCHelpers.mm deleted file mode 100644 index 2bdbcd7cdd6..00000000000 --- a/React/CxxBridge/RCTJSCHelpers.mm +++ /dev/null @@ -1,50 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#include "RCTJSCHelpers.h" - -#import - -#import -#import -#import -#import -#import - -using namespace facebook::react; - -namespace { - -JSValueRef nativeLoggingHook( - JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, - const JSValueRef arguments[], JSValueRef *exception) { - RCTLogLevel level = RCTLogLevelInfo; - if (argumentCount > 1) { - level = MAX(level, (RCTLogLevel)Value(ctx, arguments[1]).asNumber()); - } - if (argumentCount > 0) { - JSContext *contextObj = contextForGlobalContextRef(JSC_JSContextGetGlobalContext(ctx)); - JSValue *msg = [JSC_JSValue(ctx) valueWithJSValueRef:arguments[0] inContext:contextObj]; - _RCTLogJavaScriptInternal(level, [msg toString]); - } - return Value::makeUndefined(ctx); -} - -JSValueRef nativePerformanceNow( - JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, - const JSValueRef arguments[], JSValueRef *exception) { - return Value::makeNumber(ctx, CACurrentMediaTime() * 1000); -} - -} - -void RCTPrepareJSCExecutor() { - ReactMarker::logTaggedMarker = [](const ReactMarker::ReactMarkerId, const char *tag) {}; - JSCNativeHooks::loggingHook = nativeLoggingHook; - JSCNativeHooks::nowHook = nativePerformanceNow; - JSCNativeHooks::installPerfHooks = RCTFBQuickPerformanceLoggerConfigureHooks; -} diff --git a/React/Modules/RCTJSCSamplingProfiler.h b/React/Modules/RCTJSCSamplingProfiler.h deleted file mode 100644 index 50fb4c5b1f2..00000000000 --- a/React/Modules/RCTJSCSamplingProfiler.h +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#import - -#import - -@interface RCTJSCSamplingProfiler : NSObject - -/** - * Receives a JSON string containing the result of a JSC CPU Profiling run, - * and sends them to the packager to be symbolicated and saved to disk. - * It is safe to call this method from any thread. - */ -- (void)operationCompletedWithResults:(NSString *)results; - -@end diff --git a/React/Modules/RCTJSCSamplingProfiler.m b/React/Modules/RCTJSCSamplingProfiler.m deleted file mode 100644 index f7fc7ebda88..00000000000 --- a/React/Modules/RCTJSCSamplingProfiler.m +++ /dev/null @@ -1,59 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#import "RCTJSCSamplingProfiler.h" - -#import "RCTBridge.h" -#import "RCTLog.h" - -@implementation RCTJSCSamplingProfiler - -@synthesize methodQueue = _methodQueue; -@synthesize bridge = _bridge; - -RCT_EXPORT_MODULE(RCTJSCSamplingProfiler); - -#ifdef RCT_PROFILE -RCT_EXPORT_METHOD(operationComplete:(__unused int)token result:(id)profileData error:(id)error) -{ - if (error) { - RCTLogError(@"JSC Sampling profiler ended with error: %@", error); - return; - } - - // Create a POST request with all of the datas - NSURL *url = [NSURL URLWithString:@"/jsc-profile" relativeToURL:self.bridge.bundleURL]; - NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url - cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData - timeoutInterval:60]; - [request setHTTPMethod:@"POST"]; - [request setHTTPBody:[profileData dataUsingEncoding:NSUTF8StringEncoding]]; - - // Send the request - NSURLSession *session = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]]; - NSURLSessionDataTask *sessionDataTask = [session dataTaskWithRequest:request completionHandler:^(__unused NSData *data, __unused NSURLResponse *response, NSError *sessionError) { - if (sessionError) { - RCTLogWarn(@"JS CPU Profile data failed to send. Is the packager server running locally?\nDetails: %@", error); - } else { - RCTLogInfo(@"JS CPU Profile data sent successfully."); - } - }]; - - [sessionDataTask resume]; -} - -- (void)operationCompletedWithResults:(NSString *)results -{ - // Send the results to the packager, using the module's queue. - dispatch_async(self.methodQueue, ^{ - [self operationComplete:0 result:results error:nil]; - }); -} - -#endif - -@end