diff --git a/RNTester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.java b/RNTester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.java index 4d23c496aee2..1ce0ba95da77 100644 --- a/RNTester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.java +++ b/RNTester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.java @@ -21,7 +21,6 @@ import com.facebook.react.bridge.ReactMarkerConstants; import com.facebook.react.shell.MainReactPackage; import com.facebook.react.v8executor.V8ExecutorFactory; -import com.facebook.react.jscexecutor.JSCExecutorFactory; import com.facebook.react.views.text.ReactFontManager; @@ -73,30 +72,6 @@ public List getPackages() { new MainReactPackage() ); } - - @Override - public JavaScriptExecutorFactory getJavaScriptExecutorFactory() { - ReactMarker.addListener(new RNTesterReactMarker()); - // We use the name of the device and the app for debugging & metrics - String appName = getPackageName(); - String deviceName = getFriendlyDeviceName(); - - File jseDir = getApplicationContext().getDir("jse", Context.MODE_PRIVATE); - File jsDataStore = new File(jseDir, JSE_CACHING_DIRECTORY_NAME); - String jseCacheDirectoryPath = ""; - if ((jsDataStore.exists() && jsDataStore.isDirectory()) || jsDataStore.mkdirs()) { - jseCacheDirectoryPath = jsDataStore.getAbsolutePath(); - } - if(BuildConfig.JS_ENGINE_USED.equals("V8")){ - return new V8ExecutorFactory(appName, deviceName, new V8ExecutorFactory.V8ConfigParams(jseCacheDirectoryPath, V8ExecutorFactory.V8ConfigParams.CacheType.CodeCache, false)); - } - else if(BuildConfig.JS_ENGINE_USED.equals("JSC")){ - return new JSCExecutorFactory(appName, deviceName); - } - else{ - return null; - } - } }; @Override diff --git a/ReactAndroid/ReactAndroid.nuspec b/ReactAndroid/ReactAndroid.nuspec index 9fc15d113447..7cfdf6e973fa 100644 --- a/ReactAndroid/ReactAndroid.nuspec +++ b/ReactAndroid/ReactAndroid.nuspec @@ -37,11 +37,6 @@ - - - - - @@ -88,11 +83,6 @@ - - - - - @@ -124,7 +114,6 @@ - diff --git a/ReactAndroid/build.gradle b/ReactAndroid/build.gradle index ebec4331499e..951a2f255d2c 100644 --- a/ReactAndroid/build.gradle +++ b/ReactAndroid/build.gradle @@ -40,13 +40,8 @@ def boostPath = dependenciesPath ?: System.getenv("REACT_NATIVE_BOOST_PATH") ?: def DoubleConversionPath = '../double-conversion' def FollyPath = '..' def GlogPath = '..' -def JSCPath = '../jsc' def V8Path = 'packages/ReactNative.V8.Android.7.0.276.32-v1' - -// Set the value of JSEngineUsed as 'V8' or 'JSC' to enable the respective engine -def JSEngineUsed = 'V8' - task createNativeDepsDirectories { downloadsDir.mkdirs() thirdPartyNdkDir.mkdirs() @@ -130,34 +125,30 @@ task prepareGlog(dependsOn: createNativeDepsDirectories, type: Copy) { // Create Android.mk library module based on jsc from npm task prepareJSC { - if (JSEngineUsed=='JSC'){ - doLast { - def jscPackageRoot = file("$projectDir/../node_modules/jsc-android/dist") - if (!jscPackageRoot.exists()) { - // For an app to build from RN source, the jsc-android is located at /path/to/app/node_modules - // and $projectDir may located at /path/to/app/node_modules/react-native/ReactAndroid - jscPackageRoot = file("$projectDir/../../jsc-android/dist") - } - def jscAAR = fileTree(jscPackageRoot).matching({ it.include "**/android-jsc/**/*.aar" }).singleFile - def soFiles = zipTree(jscAAR).matching({ it.include "**/*.so" }) - - def headerFiles = fileTree(jscPackageRoot).matching({ it.include "**/include/*.h" }) - - copy { - from(soFiles) - from(headerFiles) - from("src/main/jni/third-party/jsc/Android.mk") - - filesMatching("**/*.h", { it.path = "JavaScriptCore/${it.name}" }) - - includeEmptyDirs(false) - into("$thirdPartyNdkDir/jsc") - - } - } - } -} + doLast { + def jscPackageRoot = file("$projectDir/../node_modules/jsc-android/dist") + if (!jscPackageRoot.exists()) { + // For an app to build from RN source, the jsc-android is located at /path/to/app/node_modules + // and $projectDir may located at /path/to/app/node_modules/react-native/ReactAndroid + jscPackageRoot = file("$projectDir/../../jsc-android/dist") + } + def jscAAR = fileTree(jscPackageRoot).matching({ it.include "**/android-jsc/**/*.aar" }).singleFile + def soFiles = zipTree(jscAAR).matching({ it.include "**/*.so" }) + + def headerFiles = fileTree(jscPackageRoot).matching({ it.include "**/include/*.h" }) + copy { + from(soFiles) + from(headerFiles) + from("src/main/jni/third-party/jsc/Android.mk") + + filesMatching("**/*.h", { it.path = "JavaScriptCore/${it.name}" }) + + includeEmptyDirs(false) + into("$thirdPartyNdkDir/jsc") + } + } +} task downloadNdkBuildDependencies { if (!boostPath) { dependsOn(downloadBoost) @@ -225,7 +216,7 @@ def getNdkBuildFullPath() { return ndkBuildFullPath } -task buildReactNdkLib(dependsOn: [prepareJSC, prepareBoost, prepareDoubleConversion, prepareFolly, prepareGlog], type: Exec) { +task buildReactNdkLib(dependsOn: [prepareBoost, prepareDoubleConversion, prepareFolly, prepareGlog], type: Exec) { inputs.dir("$projectDir/../ReactCommon") inputs.dir("src/main/jni") outputs.dir("$buildDir/react-ndk/all") @@ -239,9 +230,8 @@ task buildReactNdkLib(dependsOn: [prepareJSC, prepareBoost, prepareDoubleConvers "V8_NUGET_DIR=$projectDir/$V8Path", "REACT_COMMON_DIR=$projectDir/../ReactCommon", "REACT_SRC_DIR=$projectDir/src/main/java/com/facebook/react", - "JS_ENGINE=$JSEngineUsed", - '-C', file("src/main/jni/react/jni").absolutePath, - '--jobs', project.findProperty("jobs") ?: Runtime.runtime.availableProcessors() + "-C", file("src/main/jni/react/jni").absolutePath, + "--jobs", project.findProperty("jobs") ?: Runtime.runtime.availableProcessors() ) } @@ -302,7 +292,6 @@ android { } buildConfigField("boolean", "IS_INTERNAL_BUILD", "false") - buildConfigField("String", "JS_ENGINE_USED", "\"$JSEngineUsed\"") buildConfigField("int", "EXOPACKAGE_FLAGS", "0") resValue "integer", "react_native_dev_server_port", reactNativeDevServerPort() diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManagerBuilder.java b/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManagerBuilder.java index d9fe2b260156..4865ca7a07cf 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManagerBuilder.java +++ b/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManagerBuilder.java @@ -11,7 +11,6 @@ import android.app.Application; import com.facebook.infer.annotation.Assertions; import com.facebook.react.bridge.JSBundleLoader; -import com.facebook.react.bridge.JSCJavaScriptExecutorFactory; import com.facebook.react.bridge.JSIModulePackage; import com.facebook.react.bridge.JavaScriptExecutorFactory; import com.facebook.react.bridge.NativeModuleCallExceptionHandler; @@ -22,6 +21,7 @@ import com.facebook.react.devsupport.interfaces.DevBundleDownloadListener; import com.facebook.react.devsupport.interfaces.DevSupportManager; import com.facebook.react.jscexecutor.JSCExecutorFactory; +import com.facebook.react.v8executor.V8ExecutorFactory; import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler; import com.facebook.react.packagerconnection.RequestHandler; import com.facebook.react.uimanager.UIImplementationProvider; @@ -276,7 +276,7 @@ public ReactInstanceManager build() { mCurrentActivity, mDefaultHardwareBackBtnHandler, mJavaScriptExecutorFactory == null - ? new JSCJavaScriptExecutorFactory(appName, deviceName) + ? new V8ExecutorFactory(appName, deviceName) : mJavaScriptExecutorFactory, (mJSBundleLoader == null && mJSBundleAssetUrl != null) ? JSBundleLoader.createAssetLoader( diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactBridge.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactBridge.java index 2a60aceccc24..789f9ba326aa 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactBridge.java +++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactBridge.java @@ -13,45 +13,26 @@ import com.facebook.soloader.SoLoader; import com.facebook.systrace.Systrace; -import com.facebook.react.BuildConfig; - public class ReactBridge { private static volatile long sLoadStartTime = 0; private static volatile long sLoadEndTime = 0; private static boolean sDidInit = false; - - // Office implementation of RN can work with two JS Engines: V8 and JSC. - // There is a compile time flag to decide which one will be used and V8 is the default one. - // We are exposing an API from ReactBridge so that consumer can choose JSC if required. - private static boolean sUseJSC = false; - - public static void staticInit() { + public synchronized static void staticInit() { if (sDidInit) { return; } sDidInit = true; - if(BuildConfig.JS_ENGINE_USED.equals("JSC")){ - sUseJSC = true; - } - sLoadStartTime = SystemClock.uptimeMillis(); Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "ReactBridge.staticInit::load:reactnativejni"); ReactMarker.logMarker(ReactMarkerConstants.LOAD_REACT_NATIVE_SO_FILE_START); - if (sUseJSC) { - SoLoader.loadLibrary("icu_common"); - SoLoader.loadLibrary("jsc"); - } - else { - SoLoader.loadLibrary("v8_libbase.cr"); - SoLoader.loadLibrary("v8_libplatform.cr"); - SoLoader.loadLibrary("v8.cr"); - } + SoLoader.loadLibrary("v8_libbase.cr"); + SoLoader.loadLibrary("v8_libplatform.cr"); + SoLoader.loadLibrary("v8.cr"); SoLoader.loadLibrary("glog_init"); - SoLoader.loadLibrary("privatedata"); SoLoader.loadLibrary("fb"); SoLoader.loadLibrary("yoga"); SoLoader.loadLibrary("reactnativejni"); diff --git a/ReactAndroid/src/main/jni/react/jni/Android.mk b/ReactAndroid/src/main/jni/react/jni/Android.mk index d9f03d18900a..264e08cd3731 100644 --- a/ReactAndroid/src/main/jni/react/jni/Android.mk +++ b/ReactAndroid/src/main/jni/react/jni/Android.mk @@ -17,17 +17,15 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH) # ./../ == react LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../.. - LOCAL_CFLAGS += -fexceptions -frtti -Wno-unused-lambda-capture LOCAL_LDLIBS += -landroid # The dynamic libraries (.so files) that this module depends on. - -LOCAL_SHARED_LIBRARIES := libfolly_json libfb libglog_init libyoga libprivatedata +LOCAL_SHARED_LIBRARIES := libfolly_json libfb libglog_init libyoga # The static libraries (.a files) that this module depends on. -LOCAL_STATIC_LIBRARIES := libreactnative jsi libjscallinvokerholder +LOCAL_STATIC_LIBRARIES := libreactnative libjscallinvokerholder # Name of this module. # @@ -35,39 +33,8 @@ LOCAL_STATIC_LIBRARIES := libreactnative jsi libjscallinvokerholder # LOCAL_SHARED_LIBRARIES variable. LOCAL_MODULE := reactnativejni -LOCAL_SRC_FILES := \ - CatalystInstanceImpl.cpp \ - CxxModuleWrapper.cpp \ - JavaModuleWrapper.cpp \ - JReactMarker.cpp \ - JSLogging.cpp \ - JMessageQueueThread.cpp \ - JSLoader.cpp \ - JniJSModulesUnbundle.cpp \ - MethodInvoker.cpp \ - ModuleRegistryBuilder.cpp \ - NativeArray.cpp \ - NativeCommon.cpp \ - NativeDeltaClient.cpp \ - NativeMap.cpp \ - OnLoad.cpp \ - ProxyExecutor.cpp \ - ReadableNativeArray.cpp \ - ReadableNativeMap.cpp \ - WritableNativeArray.cpp \ - WritableNativeMap.cpp \ - -LOCAL_V8_FILES := \ - InstanceManager.cpp \ - AndroidV8Factory.cpp - -ifeq ($(JS_ENGINE), V8) - LOCAL_SRC_FILES += $(LOCAL_V8_FILES) - LOCAL_STATIC_LIBRARIES += v8runtime -else ifeq ($(JS_ENGINE), JSC) - LOCAL_SHARED_LIBRARIES += libjsc - LOCAL_STATIC_LIBRARIES += jscruntime -endif +# Compile all local c++ files. +LOCAL_SRC_FILES := $(wildcard *.cpp) # Build the files in this directory as a shared library include $(BUILD_SHARED_LIBRARY) @@ -84,16 +51,11 @@ include $(BUILD_SHARED_LIBRARY) # Whenever you encounter an include //Android.mk, you # tell andorid-ndk to compile the module in / according # to the specification inside //Android.mk. - -$(call import-module,cxxreact) -$(call import-module,privatedata) +$(call import-module,folly) $(call import-module,fb) $(call import-module,fbgloginit) -$(call import-module,folly) -ifeq ($(JS_ENGINE), JSC) - $(call import-module,jsc) -endif $(call import-module,yogajni) +$(call import-module,cxxreact) $(call import-module,jsi) $(call import-module,jsiexecutor) $(call import-module,jscallinvoker) @@ -103,9 +65,4 @@ include $(REACT_SRC_DIR)/turbomodule/core/jni/Android.mk # TODO(ramanpreet): # Why doesn't this import-module call generate a jscexecutor.so file? # $(call import-module,jscexecutor) - -ifeq ($(JS_ENGINE), JSC) - include $(REACT_SRC_DIR)/jscexecutor/Android.mk -else ifeq ($(JS_ENGINE), V8) - include $(REACT_SRC_DIR)/v8executor/Android.mk -endif \ No newline at end of file +include $(REACT_SRC_DIR)/v8executor/Android.mk \ No newline at end of file diff --git a/ReactAndroid/src/main/jni/react/jni/AndroidJSCFactory.cpp b/ReactAndroid/src/main/jni/react/jni/AndroidJSCFactory.cpp deleted file mode 100644 index e2b38d6ef620..000000000000 --- a/ReactAndroid/src/main/jni/react/jni/AndroidJSCFactory.cpp +++ /dev/null @@ -1,125 +0,0 @@ -// Copyright (c) 2004-present, Facebook, Inc. - -// This source code is licensed under the MIT license found in the -// LICENSE file in the root directory of this source tree. - -#include - -#include - -#include -#include -#include -#include -#include -#include - -#include "JSCPerfLogging.h" -#include "JSLogging.h" -#include "JReactMarker.h" - -using namespace facebook::jni; - -namespace facebook { -namespace react { - -namespace { - -ExceptionHandling::ExtractedEror extractJniError(const std::exception& ex, const char *context) { - auto jniEx = dynamic_cast(&ex); - if (!jniEx) { - return {}; - } - - auto stackTrace = jniEx->getThrowable()->getStackTrace(); - std::ostringstream stackStr; - for (int i = 0, count = stackTrace->size(); i < count; ++i) { - auto frame = stackTrace->getElement(i); - - auto methodName = folly::to(frame->getClassName(), ".", - frame->getMethodName()); - - // Cut off stack traces at the Android looper, to keep them simple - if (methodName == "android.os.Looper.loop") { - break; - } - - stackStr << std::move(methodName) << '@' << frame->getFileName(); - if (frame->getLineNumber() > 0) { - stackStr << ':' << frame->getLineNumber(); - } - stackStr << std::endl; - } - - auto msg = folly::to("Java exception in '", context, "'\n\n", jniEx->what()); - return {.message = msg, .stack = stackStr.str()}; -} - -JSValueRef nativePerformanceNow( - JSContextRef ctx, - JSObjectRef function, - JSObjectRef thisObject, - size_t argumentCount, - const JSValueRef arguments[], JSValueRef *exception) { - static const int64_t NANOSECONDS_IN_SECOND = 1000000000LL; - static const int64_t NANOSECONDS_IN_MILLISECOND = 1000000LL; - - // Since SystemClock.uptimeMillis() is commonly used for performance measurement in Java - // and uptimeMillis() internally uses clock_gettime(CLOCK_MONOTONIC), - // we use the same API here. - // We need that to make sure we use the same time system on both JS and Java sides. - // Links to the source code: - // https://android.googlesource.com/platform/frameworks/native/+/jb-mr1-release/libs/utils/SystemClock.cpp - // https://android.googlesource.com/platform/system/core/+/master/libutils/Timers.cpp - struct timespec now; - clock_gettime(CLOCK_MONOTONIC, &now); - int64_t nano = now.tv_sec * NANOSECONDS_IN_SECOND + now.tv_nsec; - return Value::makeNumber(ctx, (nano / (double)NANOSECONDS_IN_MILLISECOND)); -} - -JSValueRef nativeLoggingHook( - JSContextRef ctx, - JSObjectRef function, - JSObjectRef thisObject, - size_t argumentCount, - const JSValueRef arguments[], - JSValueRef* exception) { - android_LogPriority logLevel = ANDROID_LOG_DEBUG; - if (argumentCount > 1) { - int level = (int)Value(ctx, arguments[1]).asNumber(); - // The lowest log level we get from JS is 0. We shift and cap it to be - // in the range the Android logging method expects. - logLevel = std::min( - static_cast(level + ANDROID_LOG_DEBUG), - ANDROID_LOG_FATAL); - } - if (argumentCount > 0) { - String message = Value(ctx, arguments[0]).toString(); - reactAndroidLoggingHook(message.str(), logLevel); - } - return Value::makeUndefined(ctx); -} - -} - -namespace detail { - -void injectJSExecutorAndroidPlatform() { - // Inject some behavior into react/ - JReactMarker::setLogPerfMarkerIfNeeded(); - ExceptionHandling::platformErrorExtractor = extractJniError; - JSCNativeHooks::loggingHook = nativeLoggingHook; - JSCNativeHooks::nowHook = nativePerformanceNow; - JSCNativeHooks::installPerfHooks = addNativePerfLoggingHooks; -} - -} - -std::unique_ptr makeAndroidJSCExecutorFactory( - const folly::dynamic& jscConfig) { - detail::injectJSCExecutorAndroidPlatform(); - return folly::make_unique(std::move(jscConfig)); -} - -} -} \ No newline at end of file diff --git a/ReactAndroid/src/main/jni/react/jni/AndroidJSCFactory.h b/ReactAndroid/src/main/jni/react/jni/AndroidJSCFactory.h deleted file mode 100644 index b478986a7fdd..000000000000 --- a/ReactAndroid/src/main/jni/react/jni/AndroidJSCFactory.h +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) 2004-present, Facebook, Inc. - -// This source code is licensed under the MIT license found in the -// LICENSE file in the root directory of this source tree. - -#pragma once - -#include -#include - -namespace folly { - -struct dynamic; - -} - -namespace facebook { -namespace react { - -class JSExecutorFactory; - -namespace detail { - -// This is only exposed so instrumentation tests can call it. -void injectJSExecutorAndroidPlatform(); - -} - -std::unique_ptr makeAndroidJSCExecutorFactory( - const folly::dynamic& jscConfig); - -} -} \ No newline at end of file diff --git a/ReactAndroid/src/main/jni/react/jni/AndroidV8Factory.cpp b/ReactAndroid/src/main/jni/react/jni/AndroidV8Factory.cpp deleted file mode 100644 index bca9f98a74a8..000000000000 --- a/ReactAndroid/src/main/jni/react/jni/AndroidV8Factory.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include - -#include -#include -#include -#include - -#include "JReactMarker.h" - -// using namespace facebook::jni; - -namespace facebook { -namespace react { - -namespace detail { -void injectJSExecutorAndroidPlatform() { - // Inject some behavior into react/ - JReactMarker::setLogPerfMarkerIfNeeded(); - //TODO (VSO:2298684) : AndroidJSCFactory.cpp is doing a lot of things in this api, - // we will fill that in aforementioned VSO task. -} -} - -std::unique_ptr makeAndroidJSCExecutorFactory( - const folly::dynamic& jscConfig) { - detail::injectJSExecutorAndroidPlatform(); - return folly::make_unique(jscConfig); -} - -}} \ No newline at end of file diff --git a/ReactAndroid/src/main/jni/react/jni/InstanceManager.cpp b/ReactAndroid/src/main/jni/react/jni/InstanceManager.cpp deleted file mode 100644 index fd6643fe7e0c..000000000000 --- a/ReactAndroid/src/main/jni/react/jni/InstanceManager.cpp +++ /dev/null @@ -1,102 +0,0 @@ -#include -#include - -#include "AndroidJSCFactory.h" -#include "JSLoader.h" - -#include "InstanceManager.h" - -namespace facebook { namespace react { - -struct DefaultInstanceCallback final : public InstanceCallback -{ - void onBatchComplete() override {} - void incrementPendingJSCalls() override {} - void decrementPendingJSCalls() override {} -}; - -// If the provided url begins with "/" then it represents a file in file system. -bool IsJSBundleFilePath(const std::string& bundleUrl) -{ - std::size_t index = bundleUrl.find("/"); - if (index == 0) - { - return true; - } - - return false; -} - -std::shared_ptr CreateReactInstance( - AAssetManager* assetManager, - std::string&& jsBundleFile, - std::vector&& platformBundles, - std::vector>>&& cxxModules, - std::shared_ptr&& jsQueue, - std::shared_ptr&& /*nativeQueue*/) noexcept -{ - auto instance = std::make_shared(); - - std::vector> modules; - - // Add app provided modules. - for (auto& cxxModule : cxxModules) - { - modules.push_back(std::make_unique(instance, - move(std::get<0>(cxxModule)), - move(std::get<1>(cxxModule)), - move(std::get<2>(cxxModule)))); - } - - // Empty configuration, this is not getting used in V8 Executor flow. - folly::dynamic jscConfig = folly::dynamic::object; - - std::unique_ptr jsExecutorFactory{ makeAndroidJSCExecutorFactory(jscConfig) }; - std::unique_ptr moduleRegistry{ std::make_unique(std::move(modules)) }; - - // Initialize bridge. - instance->initializeBridge(std::make_unique(), - nullptr, - std::move(jsExecutorFactory), - std::move(jsQueue), - std::move(moduleRegistry)); - - // Load all required JS scripts. - - // First load platform bundles. - for (auto& platformBundle : platformBundles) - { - if (!platformBundle.BundleUrl.empty()) - { - std::unique_ptr script; - if (IsJSBundleFilePath(platformBundle.BundleUrl)) - { - // Load from file system. - script = JSBigFileString::fromPath(platformBundle.BundleUrl); - } - else - { - // Load from Assets. - script = loadScriptFromAssets(assetManager, platformBundle.BundleUrl); - } - instance->loadScriptFromString(std::move(script), std::move(platformBundle.BundleUrl), true /*synchronously*/); - } - } - - // Now load user bundle. - std::unique_ptr script; - if (IsJSBundleFilePath(jsBundleFile)) - { - // Load from file system. - script = JSBigFileString::fromPath(jsBundleFile); - } - else - { - // Load from Assets. - script = loadScriptFromAssets(assetManager, jsBundleFile); - } - instance->loadScriptFromString(std::move(script), jsBundleFile, false); - return instance; -} - -}}//namespace facebook::react diff --git a/ReactAndroid/src/main/jni/react/jni/InstanceManager.h b/ReactAndroid/src/main/jni/react/jni/InstanceManager.h deleted file mode 100644 index f7f9871193b1..000000000000 --- a/ReactAndroid/src/main/jni/react/jni/InstanceManager.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once -#include - -#include -#include -#include -#include -#include - -namespace facebook { namespace react { - -std::shared_ptr CreateReactInstance( - AAssetManager* assetManager, - std::string&& jsBundleFile, - std::vector>>&& cxxModules, - std::shared_ptr&& jsQueue, - std::shared_ptr&& nativeQueue) noexcept; - -}} //namespace facebook::react diff --git a/ReactAndroid/src/main/jni/react/jni/JSLoader.cpp b/ReactAndroid/src/main/jni/react/jni/JSLoader.cpp index d001f600cfbb..8f18dbc7f806 100644 --- a/ReactAndroid/src/main/jni/react/jni/JSLoader.cpp +++ b/ReactAndroid/src/main/jni/react/jni/JSLoader.cpp @@ -45,7 +45,7 @@ std::unique_ptr loadScriptFromAssets( manager, assetName.c_str(), AASSET_MODE_STREAMING); // Optimized for sequential read: see AssetManager.java for docs - if (asset) { + if (asset) { auto buf = folly::make_unique(AAsset_getLength(asset)); size_t offset = 0; int readbytes; diff --git a/ReactAndroid/src/main/jni/react/jni/OnLoad.cpp b/ReactAndroid/src/main/jni/react/jni/OnLoad.cpp index 65583688bd15..c754eb12b162 100644 --- a/ReactAndroid/src/main/jni/react/jni/OnLoad.cpp +++ b/ReactAndroid/src/main/jni/react/jni/OnLoad.cpp @@ -11,7 +11,6 @@ #include #include -#include "AndroidJSCFactory.h" #include "CatalystInstanceImpl.h" #include "CxxModuleWrapper.h" #include "JavaScriptExecutorHolder.h" @@ -32,27 +31,6 @@ namespace react { namespace { -// TODO: can we avoid these wrapper classes, and instead specialize the logic in CatalystInstanceImpl -class JSCJavaScriptExecutorHolder : public HybridClass { - public: - static constexpr auto kJavaDescriptor = "Lcom/facebook/react/bridge/JSCJavaScriptExecutor;"; - - static local_ref initHybrid(alias_ref, ReadableNativeMap* jscConfig) { - return makeCxxInstance(makeAndroidJSCExecutorFactory(jscConfig->consume())); - } - - static void registerNatives() { - registerHybrid({ - makeNativeMethod("initHybrid", JSCJavaScriptExecutorHolder::initHybrid), - }); - } - - private: - friend HybridBase; - using HybridBase::HybridBase; -}; - struct JavaJSExecutor : public JavaClass { static constexpr auto kJavaDescriptor = "Lcom/facebook/react/bridge/JavaJSExecutor;"; }; @@ -86,7 +64,6 @@ extern "C" JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { return initialize(vm, [] { gloginit::initialize(); FLAGS_minloglevel = 0; - JSCJavaScriptExecutorHolder::registerNatives(); ProxyJavaScriptExecutorHolder::registerNatives(); CatalystInstanceImpl::registerNatives(); CxxModuleWrapperBase::registerNatives(); diff --git a/ReactCommon/cxxreact/Android.mk b/ReactCommon/cxxreact/Android.mk index 21231debaabc..e72045c4521b 100644 --- a/ReactCommon/cxxreact/Android.mk +++ b/ReactCommon/cxxreact/Android.mk @@ -9,42 +9,18 @@ include $(CLEAR_VARS) LOCAL_MODULE := reactnative -LOCAL_SRC_FILES := \ - CxxNativeModule.cpp \ - Instance.cpp \ - JSBigString.cpp \ - JSBundleType.cpp \ - JSDeltaBundleClient.cpp \ - JSExecutor.cpp \ - JSIndexedRAMBundle.cpp \ - MethodCall.cpp \ - ModuleRegistry.cpp \ - NativeToJsBridge.cpp \ - Platform.cpp \ - RAMBundleRegistry.cpp \ - ReactMarker.cpp \ - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/.. +LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) + +LOCAL_C_INCLUDES := $(LOCAL_PATH)/.. LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES) LOCAL_CFLAGS := \ -DLOG_TAG=\"ReactNative\" -LOCAL_CFLAGS += -fexceptions -frtti -Wno-unused-lambda-capture -Wno-unused-variable +LOCAL_CFLAGS += -fexceptions -frtti -Wno-unused-lambda-capture LOCAL_STATIC_LIBRARIES := boost jsi -LOCAL_SHARED_LIBRARIES := jsinspector libfb libfolly_json libglog - -LOCAL_V8_FILES := \ - File.cpp \ - V8NativeModules.cpp \ - V8Executor.cpp - -ifeq ($(JS_ENGINE), V8) - LOCAL_SRC_FILES += $(LOCAL_V8_FILES) - LOCAL_STATIC_LIBRARIES := v8helpers - LOCAL_SHARED_LIBRARIES += libv8 libv8platform libv8base -endif +LOCAL_SHARED_LIBRARIES := jsinspector libfolly_json glog include $(BUILD_STATIC_LIBRARY) @@ -52,11 +28,4 @@ $(call import-module,fb) $(call import-module,folly) $(call import-module,glog) $(call import-module,jsi) -$(call import-module,jsinspector) -$(call import-module,privatedata) -ifeq ($(JS_ENGINE), V8) - $(call import-module,v8) - $(call import-module,v8base) - $(call import-module,v8helpers) - $(call import-module,v8platform) -endif \ No newline at end of file +$(call import-module,jsinspector) \ No newline at end of file diff --git a/ReactCommon/cxxreact/File.cpp b/ReactCommon/cxxreact/File.cpp deleted file mode 100644 index e22ef42f7bcd..000000000000 --- a/ReactCommon/cxxreact/File.cpp +++ /dev/null @@ -1,134 +0,0 @@ -#include "File.h" -#include -#include -#include -#include -#include -#include - -using namespace std; - -namespace rnv8 { -bool File::Exists(const string& path) { - std::ifstream infile(path.c_str()); - return infile.good(); -} -string File::ReadText(const string& filePath) { - long len; - bool isNew; - const char* content = ReadText(filePath, len, isNew); - - string s(content, len); - - if (isNew) { - delete[] content; - } - - return s; -} - -void* File::ReadBinary(const string& filePath, long& length) { - length = 0; - if (!File::Exists(filePath)) { - return nullptr; - } - - auto file = fopen(filePath.c_str(), READ_BINARY); - if (!file) { - ReactMarker::logTaggedMarker(ReactMarker::BYTECODE_READ_FAILED, strerror(errno)); - return nullptr; - } - - if (fseek(file, 0, SEEK_END) == -1) { - ReactMarker::logTaggedMarker(ReactMarker::BYTECODE_READ_FAILED, strerror(errno)); - } - - length = ftell(file); - if(length == -1) { - ReactMarker::logTaggedMarker(ReactMarker::BYTECODE_READ_FAILED, strerror(errno)); - } - - rewind(file); - uint8_t* data = new uint8_t[length]; - - int readBytes = fread(data, sizeof(uint8_t), length, file); - if (readBytes != length) { - ReactMarker::logTaggedMarker(ReactMarker::BYTECODE_READ_FAILED, strerror(errno)); - } - - fclose(file); - - return data; -} - -bool File::WriteBinary(const string& filePath, const void* data, long length) { - - auto file = fopen(filePath.c_str(), WRITE_BINARY); - //LOGD("V8Executor::WriteBinary entry %s", filePath.c_str()); - if (!file) { - //LOGD("V8Executor::WriteBinary file is NULL %s", strerror(errno)); - return false; - } - //LOGD("V8Executor::WriteBinary after file open "); - long writtenBytes = fwrite(data, sizeof(uint8_t), length, file); - fclose(file); - //LOGD("V8Executor::WriteBinary after file write "); - return writtenBytes == length; -} - -const char* File::ReadText(const string& filePath, long& charLength, bool& isNew) { - FILE* file = fopen(filePath.c_str(), "rb"); - fseek(file, 0, SEEK_END); - - charLength = ftell(file); - isNew = charLength > BUFFER_SIZE; - - rewind(file); - - if (isNew) { - char* newBuffer = new char[charLength]; - fread(newBuffer, 1, charLength, file); - fclose(file); - - return newBuffer; - } - - fread(Buffer, 1, charLength, file); - fclose(file); - - return Buffer; -} - -MemoryMappedFile MemoryMappedFile::Open(const char* filePath) { - void* memory = nullptr; - long length = 0; - if (FILE* file = fopen(filePath, "r+")) { - if (fseek(file, 0, SEEK_END) == 0) { - length = ftell(file); - if (length >= 0) { - memory = mmap(NULL, length, PROT_READ, MAP_SHARED, fileno(file), 0); - if (memory == MAP_FAILED) { - memory = nullptr; - } - } - } - fclose(file); - } - return MemoryMappedFile(memory, length); -} - -MemoryMappedFile::MemoryMappedFile(void* memory, size_t size) - : - memory(memory), size(size) { -} - -MemoryMappedFile::~MemoryMappedFile() { - int result = munmap(this->memory, this->size); - assert(result == 0); -} - -char* File::Buffer = new char[BUFFER_SIZE]; - -const char* File::WRITE_BINARY = "wb"; -const char* File::READ_BINARY = "rb"; -} diff --git a/ReactCommon/cxxreact/File.h b/ReactCommon/cxxreact/File.h deleted file mode 100644 index 896e992edb4d..000000000000 --- a/ReactCommon/cxxreact/File.h +++ /dev/null @@ -1,32 +0,0 @@ - -#ifndef JNI_FILE_H_ -#define JNI_FILE_H_ - -#include - -namespace rnv8 { -struct MemoryMappedFile final { - static MemoryMappedFile Open(const char* filePath); - MemoryMappedFile(void* memory, size_t size); - ~MemoryMappedFile(); - - void* memory = nullptr; - size_t size = 0; -}; - -class File { - public: - static const char* ReadText(const std::string& filePath, long& length, bool& isNew); - static std::string ReadText(const std::string& filePath); - static bool Exists(const std::string& filePath); - static bool WriteBinary(const std::string& filePath, const void* inData, long length); - static void* ReadBinary(const std::string& filePath, long& length); - private: - static const int BUFFER_SIZE = 1024 * 1024; - static char* Buffer; - static const char* WRITE_BINARY; - static const char* READ_BINARY; -}; -} - -#endif /* JNI_FILE_H_ */ diff --git a/ReactCommon/cxxreact/V8Executor.cpp b/ReactCommon/cxxreact/V8Executor.cpp deleted file mode 100644 index e1092fb44818..000000000000 --- a/ReactCommon/cxxreact/V8Executor.cpp +++ /dev/null @@ -1,800 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if defined(WITH_FB_JSC_TUNING) && defined(__ANDROID__) -#include -#endif - -#include "Instance.h" -#include "Platform.h" -#include "SystraceSection.h" -#include "JSModulesUnbundle.h" -#include "ModuleRegistry.h" -#include "V8Executor.h" -#include "V8NativeModules.h" -#include "v8.h" -#include "File.h" -#include "libplatform/libplatform.h" - -using namespace rnv8; - -const char* MODULE_PROLOGUE = "(function(module, exports, require, __filename, __dirname){ "; -const char* MODULE_EPILOGUE = "\n})"; - -namespace v8 { - -#define THROW_RUNTIME_ERROR(INFO) do { \ - LOGW("THROW_RUNTIME_ERROR: %s", INFO); \ - std::throw_with_nested(std::runtime_error(INFO)); \ -} while(false) - -/* - * This macro used for define scope for isolate which is created at the time initialization. - */ -#define _ISOLATE_CONTEXT_ENTER Isolate *isolate = GetIsolate(); \ - Isolate::Scope isolate_scope(isolate); \ - HandleScope handle_scope(isolate); \ - Local context = Local::New(isolate, m_context); \ - Context::Scope context_scope(context); \ - -static int s_NumberOfIsolates = 0; -static bool s_PlatformInitialized = false; - -#if DEBUG -static void nativeInjectHMRUpdate(const FunctionCallbackInfo &args) { - LOGV("V8Executor::nativeInjectHMRUpdate entry"); - SystraceSection s("V8Executor.nativeInjectHMRUpdate"); - if (args.Length() != 2) { - throw std::invalid_argument("Got wrong number of args"); - } - - Local execJSString = Local::Cast(args[0]); - Local jsURL = Local::Cast(args[1]); - - //executeScript(args.GetIsolate()->GetCurrentContext(), execJSString); - LOGV("V8Executor::nativeInjectHMRUpdate exit"); -} -#endif - -/* - * This function used to get time taken by native module. - */ -inline void nativePerformanceNow(const FunctionCallbackInfo &args) { - LOGV("V8Executor::nativePerformanceNow entry"); - static const int64_t NANOSECONDS_IN_SECOND = 1000000000LL; - static const int64_t NANOSECONDS_IN_MILLISECOND = 1000000LL; - - // This is equivalent to android.os.SystemClock.elapsedRealtime() in native - struct timespec now; - clock_gettime(CLOCK_MONOTONIC_RAW, &now); - int64_t nano = now.tv_sec * NANOSECONDS_IN_SECOND + now.tv_nsec; - args.GetReturnValue().Set((nano / (double) NANOSECONDS_IN_MILLISECOND)); - LOGV("V8Executor::nativePerformanceNow exit"); -} - -// Native JS Function Hooks -template &args)> -void V8Executor::installNativeFunctionHook(Local global, const char *name) { - LOGV("V8Executor::installNativeFunctionHook entry"); - struct funcWrapper { - static void call(const v8::FunctionCallbackInfo &args) { - Isolate *isolate = args.GetIsolate(); - HandleScope handle_scope(isolate); - Local context = isolate->GetCurrentContext(); - auto ptr = context->GetAlignedPointerFromEmbedderData(1); - V8Executor *executor = static_cast(ptr); - if (!executor) { - THROW_RUNTIME_ERROR("Get Empty Context in installNativeHook!"); - } - (executor->*method)(std::move(args)); - } - }; - global->Set(toLocalString(GetIsolate(), name), FunctionTemplate::New(GetIsolate(), funcWrapper::call)); - LOGV("V8Executor::installNativeFunctionHook exit"); -} - -// Native Static JS Function Hooks -template &args)> -void installGlobalFunction(Isolate *isolate, Local global, const char *name) { - LOGV("V8Executor::installGlobalFunction entry"); - global->Set(toLocalString(isolate, name), FunctionTemplate::New(isolate, method)); - LOGV("V8Executor::installGlobalFunction exit"); -} - -template(V8Executor::*method)(Local property, const PropertyCallbackInfo &callback)> -void V8Executor::installNativePropertyHook(Local global, const char *name) { - LOGV("V8Executor::installNativePropertyHook entry"); - - struct funcWrapper { - static void call(Local localProperty, const PropertyCallbackInfo &info) { - printType(localProperty, "installNativePropertyHook.localProperty"); - Local context = info.GetIsolate()->GetCurrentContext(); - auto ptr = context->GetAlignedPointerFromEmbedderData(1); - V8Executor *executor = static_cast(ptr); - if (!executor) { - THROW_RUNTIME_ERROR("Get Empty Context in installNativePropertyHook!"); - } - - Global res = (executor->*method)(Local::Cast(localProperty), std::move(info)); - info.GetReturnValue().Set(res); - } - }; - Isolate* isolate = GetIsolate(); - Local nativeModuleProxyTemplate = ObjectTemplate::New(isolate); - nativeModuleProxyTemplate->SetHandler(NamedPropertyHandlerConfiguration(funcWrapper::call)); - global->Set(toLocalString(isolate, name), nativeModuleProxyTemplate); - LOGV("V8Executor::installNativePropertyHook exit"); -} - -void V8Executor::ClearStartupData(StartupData* data) { - LOGV("V8Executor::ClearStartupData entry"); - data->data = nullptr; - data->raw_size = 0; - LOGV("V8Executor::ClearStartupData exit"); -} - -StartupData* V8Executor::Load(const char* blob_file, void(*setter_fn)(v8::StartupData*)) { - LOGV("V8Executor::Load entry"); - StartupData* startup_data = new StartupData; - - long length = 0; - - CHECK(blob_file); - auto data = File::ReadBinary(blob_file, length); - if (!data) { - LOGW("compiled_script->Run error: %s", blob_file); - return startup_data; - } - startup_data->raw_size = length; - startup_data->data = new char[startup_data->raw_size]; - memcpy((void *) startup_data->data, (const void*) data, startup_data->raw_size); - if (startup_data->raw_size == length) { - (*setter_fn)(startup_data); - } else { - LOGW("Corrupted startup resource '%s'.\n", blob_file); - } - LOGV("V8Executor::Load exit"); - return startup_data; -} - -// PlatformInit function will be called once per process. -// V8 platform is independent of V8 isolate/instance. -void V8Executor::PlatformInit() { - if (!s_PlatformInitialized) { - Platform *platform = platform::CreateDefaultPlatform(); - LOGV("V8Executor::PlatformInit CreateDefaultPlatform"); - - V8::InitializePlatform(platform); - LOGV("V8Executor::PlatformInit InitializePlatform"); - - V8::Initialize(); - LOGV("V8Executor::PlatformInit Initialize"); - - s_PlatformInitialized = true; - } -} - -Isolate *V8Executor::GetIsolate() { - LOGV("V8Executor::GetIsolate entry"); - - if (m_isolate) { - LOGV("V8Executor::GetIsolate not NULL"); - return m_isolate; - } - - PlatformInit(); - - Isolate::CreateParams create_params; - create_params.array_buffer_allocator = v8::ArrayBuffer::Allocator::NewDefaultAllocator(); - // In-case external Snapshot file want to load like RN Js snapshot - //create_params.snapshot_blob = Load(fullPath.c_str(), V8::SetSnapshotDataBlob); - - // Create a new Isolate and make it the current one. - Isolate *isolate = Isolate::New(create_params); - LOGV("V8Executor::GetIsolate Isolate::New"); - - m_isolate = isolate; - LOGV("V8Executor::GetIsolate exit"); - s_NumberOfIsolates++; - return isolate; -} - -/* -* This below function used incase user set the enviorment variable -* to enable cache insted of enable from C++ reacthost instance. -*/ -void V8Executor::TrySetJSEConfigFromEnv(){ - const char* localPath = getenv("V8_JSCACHE_PATH"); - if (localPath != NULL) { - if ( m_jseConfigParams == nullptr ){ - LOGV("V8Executor.setCacheFromEnv V8_JSCACHE_PATH: %s", localPath); - m_jseConfigParams = std::make_unique(); - m_jseConfigParams->cachePath = std::string(localPath); - m_jseConfigParams->cacheType = CachingType::FullCachingWithNoLazy; - m_jseConfigParams->loggingLevel = 50; // deafult logging 10 = Logging::LoggingLevel::ERROR - } - } -} - -bool V8Executor::IsCacheEnabled() { - if (m_jseConfigParams == nullptr || (m_jseConfigParams->cacheType == CachingType::NoCaching) || (m_jseConfigParams->cachePath.empty())) { - return false; - } - - if (!m_jseLocalPath.empty()) { - return true; - } - - m_jseLocalPath = m_jseConfigParams->cachePath; - LOGV("V8Executor::IsCacheEnabled cachePath: %s", m_jseLocalPath.c_str()); - - return true; -} - -bool V8Executor::ShouldSetNoLazyFlag() { - return (m_jseConfigParams != nullptr && - (m_jseConfigParams->cacheType == CachingType::PartialCachingWithNoLazy || m_jseConfigParams->cacheType == CachingType::FullCachingWithNoLazy)); -} - -bool V8Executor::ShouldProduceFullCache() { - return (m_jseConfigParams != nullptr && - (m_jseConfigParams->cacheType == CachingType::FullCaching || m_jseConfigParams->cacheType == CachingType::FullCachingWithNoLazy)); -} - -V8Executor::V8Executor(std::shared_ptr delegate, - std::shared_ptr messageQueueThread, - const folly::dynamic& jscConfig, - std::shared_ptr jseConfigParams) : - m_delegate(delegate), - m_messageQueueThread(messageQueueThread), - m_nativeModules(delegate ? delegate->getModuleRegistry() : nullptr), - m_jscConfig(jscConfig), - m_jseConfigParams(std::move(jseConfigParams)) { - LOGV("V8Executor::V8Executor entry"); - if ( m_jseConfigParams == nullptr ){ - TrySetJSEConfigFromEnv(); - } - m_jseLocalPath = ""; - if (m_jseConfigParams != nullptr) { - Logging::setLevel(Logging::forValue(m_jseConfigParams->loggingLevel)); - } - initOnJSVMThread(); - LOGV("V8Executor::V8Executor exit"); -} - -V8Executor::~V8Executor() { - LOGV("V8Executor::~V8Executor entry"); - CHECK(*m_isDestroyed) << "V8Executor::destroy() must be called before its destructor!"; - LOGV("V8Executor::~V8Executor exit"); -} - -void V8Executor::destroy() { - LOGV("V8Executor::destroy entry"); - *m_isDestroyed = true; - if (m_messageQueueThread.get()) { - m_messageQueueThread->runOnQueueSync([this]() { - terminateOnJSVMThread(); - }); - } else { - terminateOnJSVMThread(); - } - LOGV("V8Executor::destroy exit"); -} - -void V8Executor::setContextName(const std::string& name) { - LOGV("V8Executor::setContextName name: %s", name.c_str()); -} - -/*static bool canUseInspector(JSContextRef context) { -#ifdef WITH_INSPECTOR - LOGV("V8Executor::canUseInspector true"); - return true; // WITH_INSPECTOR && Android -#else - LOGV("V8Executor::canUseInspector false"); - return false; // !WITH_INSPECTOR -#endif -} -*/ -void V8Executor::initOnJSVMThread() { - LOGV("V8Executor::initOnJSVMThread entry"); - //SystraceSection s("V8Executor.initOnJSVMThread"); - // TODO,not support Inspector now! - Isolate *isolate = GetIsolate(); - Isolate::Scope isolate_scope(isolate); - HandleScope handle_scope(isolate); - Local global = ObjectTemplate::New(isolate); - // Bind the global 'print' function to the C++ Print callback. - installNativeFunctionHook<&V8Executor::nativeFlushQueueImmediate>(global, "nativeFlushQueueImmediate"); - installNativeFunctionHook<&V8Executor::nativeCallSyncHook>(global, "nativeCallSyncHook"); - installGlobalFunction<&nativeLog>(isolate, global, "nativeLoggingHook"); - installGlobalFunction<&nativePerformanceNow>(isolate, global, "nativePerformanceNow"); -#if DEBUG - installGlobalFunction<&nativeInjectHMRUpdate>(isolate, global, "nativeInjectHMRUpdate"); -#endif - // TODO, trace and log - // native require - installNativeFunctionHook<&V8Executor::nativeRequire>(global, "nativeRequire"); - { - SystraceSection s("nativeModuleProxy object"); - installNativePropertyHook<&V8Executor::getNativeModule>(global, "nativeModuleProxy"); - } - Local context = Context::New(isolate, NULL, global); - Context::Scope context_scope(context); - // Add a pointer to ourselves so we can retrieve it later in our hooks - context->SetAlignedPointerInEmbedderData(1, this); - m_context.Reset(isolate, context); - - LOGV("V8Executor::initOnJSVMThread exit jsclocalPath = %s", m_jseLocalPath.c_str()); -} - -void V8Executor::terminateOnJSVMThread() { - LOGV("V8Executor::terminateOnJSVMThread entry"); - SystraceSection s("V8Executor::terminateOnJSVMThread"); - m_nativeModules.reset(); - m_invokeCallbackAndReturnFlushedQueueJS.Reset(); - m_callFunctionReturnFlushedQueueJS.Reset(); - m_flushedQueueJS.Reset(); - m_callFunctionReturnResultAndFlushedQueueJS.Reset(); - m_context.Reset(); - m_isolate->TerminateExecution(); - m_isolate->Dispose(); - m_isolate = NULL; - s_NumberOfIsolates--; - if (s_NumberOfIsolates == 0) { - V8::ShutdownPlatform(); - s_PlatformInitialized = false; - } - LOGV("V8Executor::terminateOnJSVMThread exit"); -} - -// basename_r isn't in all android SDKs, so use this simple version instead. -static std::string simpleBasename(const std::string &path) { - LOGV("V8Executor::simpleBasename entry"); - size_t pos = path.rfind("/"); - return (pos != std::string::npos) ? path.substr(pos) : path; - LOGV("V8Executor::simpleBasename exit"); -} - -void V8Executor::loadApplicationScript(std::unique_ptr script, std::string sourceURL) { - - LOGV("V8Executor::loadApplicationScript entry sourceURL = %s", sourceURL.c_str()); - SystraceSection s("V8Executor::loadApplicationScript", "sourceURL", sourceURL); - std::string scriptName = simpleBasename(sourceURL); - ReactMarker::logTaggedMarker(ReactMarker::RUN_JS_BUNDLE_START, scriptName.c_str()); - _ISOLATE_CONTEXT_ENTER; - TryCatch try_catch(isolate); - Local