Setting runtime options for JSC on iOS
Reviewed By: michalgr Differential Revision: D4104084 fbshipit-source-id: 517f833343948c59e5f77cede8a60574ca1e40c0
This commit is contained in:
parent
b6a38e80e0
commit
47d9cb4dac
|
@ -339,6 +339,7 @@ static NSThread *newJavaScriptThread(void)
|
||||||
[self->_performanceLogger markStopForTag:RCTPLJSCWrapperOpenLibrary];
|
[self->_performanceLogger markStopForTag:RCTPLJSCWrapperOpenLibrary];
|
||||||
|
|
||||||
RCTAssert(self->_context == nil, @"Didn't expect to set up twice");
|
RCTAssert(self->_context == nil, @"Didn't expect to set up twice");
|
||||||
|
self->_jscWrapper->configureJSCForIOS();
|
||||||
context = [self->_jscWrapper->JSContext new];
|
context = [self->_jscWrapper->JSContext new];
|
||||||
self->_context = [[RCTJavaScriptContext alloc] initWithJSContext:context onThread:self->_javaScriptThread];
|
self->_context = [[RCTJavaScriptContext alloc] initWithJSContext:context onThread:self->_javaScriptThread];
|
||||||
[[NSNotificationCenter defaultCenter] postNotificationName:RCTJavaScriptContextCreatedNotification
|
[[NSNotificationCenter defaultCenter] postNotificationName:RCTJavaScriptContextCreatedNotification
|
||||||
|
@ -990,6 +991,7 @@ static NSData *loadRAMBundle(NSURL *sourceURL, NSError **error, RandomAccessBund
|
||||||
- (void)_createContext
|
- (void)_createContext
|
||||||
{
|
{
|
||||||
_jscWrapper = RCTJSCWrapperCreate(_useCustomJSCLibrary);
|
_jscWrapper = RCTJSCWrapperCreate(_useCustomJSCLibrary);
|
||||||
|
_jscWrapper->configureJSCForIOS();
|
||||||
_context = [_jscWrapper->JSContext new];
|
_context = [_jscWrapper->JSContext new];
|
||||||
installBasicSynchronousHooksOnContext(_context);
|
installBasicSynchronousHooksOnContext(_context);
|
||||||
dispatch_semaphore_signal(_semaphore);
|
dispatch_semaphore_signal(_semaphore);
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
|
|
||||||
#import "RCTDefines.h"
|
#import "RCTDefines.h"
|
||||||
|
|
||||||
|
typedef void (*voidWithNoParamsFuncType)();
|
||||||
typedef JSStringRef (*JSStringCreateWithCFStringFuncType)(CFStringRef);
|
typedef JSStringRef (*JSStringCreateWithCFStringFuncType)(CFStringRef);
|
||||||
typedef JSStringRef (*JSStringCreateWithUTF8CStringFuncType)(const char *);
|
typedef JSStringRef (*JSStringCreateWithUTF8CStringFuncType)(const char *);
|
||||||
typedef void (*JSStringReleaseFuncType)(JSStringRef);
|
typedef void (*JSStringReleaseFuncType)(JSStringRef);
|
||||||
|
@ -50,6 +51,7 @@ typedef struct RCTJSCWrapper {
|
||||||
JSValueIsNullFuncType JSValueIsNull;
|
JSValueIsNullFuncType JSValueIsNull;
|
||||||
JSEvaluateScriptFuncType JSEvaluateScript;
|
JSEvaluateScriptFuncType JSEvaluateScript;
|
||||||
JSEvaluateBytecodeBundleFuncType JSEvaluateBytecodeBundle;
|
JSEvaluateBytecodeBundleFuncType JSEvaluateBytecodeBundle;
|
||||||
|
voidWithNoParamsFuncType configureJSCForIOS;
|
||||||
const int32_t JSBytecodeFileFormatVersion;
|
const int32_t JSBytecodeFileFormatVersion;
|
||||||
Class JSContext;
|
Class JSContext;
|
||||||
Class JSValue;
|
Class JSValue;
|
||||||
|
|
|
@ -27,6 +27,10 @@ UNIMPLEMENTED_SYSTEM_JSC_FUNCTION(JSEvaluateBytecodeBundle)
|
||||||
|
|
||||||
#undef UNIMPLEMENTED_SYSTEM_JSC_FUNCTION
|
#undef UNIMPLEMENTED_SYSTEM_JSC_FUNCTION
|
||||||
|
|
||||||
|
// A no-op function, to replace void functions that do no exist in the system JSC
|
||||||
|
// with a function that does nothing.
|
||||||
|
static void noOpSystemJSCFunc(void *args...){ }
|
||||||
|
|
||||||
void __attribute__((visibility("hidden"),weak)) RCTCustomJSCInit(__unused void *handle) {
|
void __attribute__((visibility("hidden"),weak)) RCTCustomJSCInit(__unused void *handle) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -70,8 +74,9 @@ static RCTJSCWrapper *RCTSetUpSystemLibraryPointers()
|
||||||
.JSValueIsUndefined = JSValueIsUndefined,
|
.JSValueIsUndefined = JSValueIsUndefined,
|
||||||
.JSValueIsNull = JSValueIsNull,
|
.JSValueIsNull = JSValueIsNull,
|
||||||
.JSEvaluateScript = JSEvaluateScript,
|
.JSEvaluateScript = JSEvaluateScript,
|
||||||
.JSBytecodeFileFormatVersion = JSNoBytecodeFileFormatVersion,
|
|
||||||
.JSEvaluateBytecodeBundle = (JSEvaluateBytecodeBundleFuncType)UnimplementedJSEvaluateBytecodeBundle,
|
.JSEvaluateBytecodeBundle = (JSEvaluateBytecodeBundleFuncType)UnimplementedJSEvaluateBytecodeBundle,
|
||||||
|
.configureJSCForIOS = (voidWithNoParamsFuncType)noOpSystemJSCFunc,
|
||||||
|
.JSBytecodeFileFormatVersion = JSNoBytecodeFileFormatVersion,
|
||||||
.JSContext = [JSContext class],
|
.JSContext = [JSContext class],
|
||||||
.JSValue = [JSValue class],
|
.JSValue = [JSValue class],
|
||||||
};
|
};
|
||||||
|
@ -100,6 +105,7 @@ static RCTJSCWrapper *RCTSetUpCustomLibraryPointers()
|
||||||
.JSValueIsNull = (JSValueIsNullFuncType)dlsym(libraryHandle, "JSValueIsNull"),
|
.JSValueIsNull = (JSValueIsNullFuncType)dlsym(libraryHandle, "JSValueIsNull"),
|
||||||
.JSEvaluateScript = (JSEvaluateScriptFuncType)dlsym(libraryHandle, "JSEvaluateScript"),
|
.JSEvaluateScript = (JSEvaluateScriptFuncType)dlsym(libraryHandle, "JSEvaluateScript"),
|
||||||
.JSEvaluateBytecodeBundle = (JSEvaluateBytecodeBundleFuncType)dlsym(libraryHandle, "JSEvaluateBytecodeBundle"),
|
.JSEvaluateBytecodeBundle = (JSEvaluateBytecodeBundleFuncType)dlsym(libraryHandle, "JSEvaluateBytecodeBundle"),
|
||||||
|
.configureJSCForIOS = (voidWithNoParamsFuncType)dlsym(libraryHandle, "configureJSCForIOS"),
|
||||||
.JSBytecodeFileFormatVersion = *(const int32_t *)dlsym(libraryHandle, "JSBytecodeFileFormatVersion"),
|
.JSBytecodeFileFormatVersion = *(const int32_t *)dlsym(libraryHandle, "JSBytecodeFileFormatVersion"),
|
||||||
.JSContext = (__bridge Class)dlsym(libraryHandle, "OBJC_CLASS_$_JSContext"),
|
.JSContext = (__bridge Class)dlsym(libraryHandle, "OBJC_CLASS_$_JSContext"),
|
||||||
.JSValue = (__bridge Class)dlsym(libraryHandle, "OBJC_CLASS_$_JSValue"),
|
.JSValue = (__bridge Class)dlsym(libraryHandle, "OBJC_CLASS_$_JSValue"),
|
||||||
|
|
Loading…
Reference in New Issue