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
This commit is contained in:
Marc Horowitz 2018-10-18 00:47:06 -07:00 коммит произвёл Facebook Github Bot
Родитель 7ffb406517
Коммит e8cbc4f893
6 изменённых файлов: 0 добавлений и 217 удалений

Просмотреть файл

@ -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 <JavaScriptCore/JavaScriptCore.h>
#import <React/RCTDefines.h>
/**
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);

Просмотреть файл

@ -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 <jschelpers/JavaScriptCore.h>
#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<RCTJSStackFrame *> *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);
}

Просмотреть файл

@ -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();

Просмотреть файл

@ -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 <Foundation/Foundation.h>
#import <React/RCTBridge+Private.h>
#import <React/RCTCxxUtils.h>
#import <React/RCTLog.h>
#import <cxxreact/Platform.h>
#import <jschelpers/Value.h>
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;
}

Просмотреть файл

@ -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 <Foundation/Foundation.h>
#import <React/RCTBridgeModule.h>
@interface RCTJSCSamplingProfiler : NSObject <RCTBridgeModule>
/**
* 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

Просмотреть файл

@ -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