-
Notifications
You must be signed in to change notification settings - Fork 24.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: Pull Request resolved: #38007 Enable JSC for Bridgeless and wire it up with RNTester Android Changelog: [Internal] Reviewed By: fkgozali Differential Revision: D46527692 fbshipit-source-id: 68f36a6db5573a70156864904bb428a4f789d4f5
- Loading branch information
1 parent
85666e4
commit 016e77a
Showing
8 changed files
with
129 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
...es/react-native/ReactAndroid/src/main/java/com/facebook/react/bridgeless/JSCInstance.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
package com.facebook.react.bridgeless; | ||
|
||
import com.facebook.infer.annotation.Nullsafe; | ||
import com.facebook.jni.HybridData; | ||
import com.facebook.jni.annotations.DoNotStrip; | ||
import com.facebook.soloader.SoLoader; | ||
|
||
@Nullsafe(Nullsafe.Mode.LOCAL) | ||
public class JSCInstance extends JSEngineInstance { | ||
static { | ||
SoLoader.loadLibrary("jscinstance"); | ||
} | ||
|
||
@DoNotStrip | ||
protected static native HybridData initHybrid(); | ||
|
||
public JSCInstance() { | ||
super(initHybrid()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
packages/react-native/ReactAndroid/src/main/jni/react/bridgeless/jsc/jni/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Copyright (c) Meta Platforms, Inc. and affiliates. | ||
# | ||
# This source code is licensed under the MIT license found in the | ||
# LICENSE file in the root directory of this source tree. | ||
|
||
cmake_minimum_required(VERSION 3.13) | ||
set(CMAKE_VERBOSE_MAKEFILE on) | ||
|
||
add_compile_options(-fvisibility=hidden -fexceptions -frtti) | ||
|
||
file(GLOB jscinstance_SRC CONFIGURE_DEPENDS "*.cpp") | ||
add_library(jscinstance SHARED ${jscinstance_SRC}) | ||
|
||
target_include_directories(jscinstance PUBLIC .) | ||
|
||
target_link_libraries( | ||
jscinstance | ||
bridgeless | ||
jscruntime | ||
fbjni | ||
reactnativejni | ||
) |
46 changes: 46 additions & 0 deletions
46
packages/react-native/ReactAndroid/src/main/jni/react/bridgeless/jsc/jni/OnLoad.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#include <fbjni/fbjni.h> | ||
#include <jsc/JSCRuntime.h> | ||
#include <jsi/jsi.h> | ||
#include <react/bridgeless/JSEngineInstance.h> | ||
#include <react/bridgeless/jni/JJSEngineInstance.h> | ||
#include <react/jni/ReadableNativeMap.h> | ||
|
||
namespace facebook::react { | ||
|
||
class JSCInstance : public jni::HybridClass<JSCInstance, JJSEngineInstance> { | ||
public: | ||
static constexpr auto kJavaDescriptor = | ||
"Lcom/facebook/react/bridgeless/JSCInstance;"; | ||
|
||
static jni::local_ref<jhybriddata> initHybrid(jni::alias_ref<jhybridobject>) { | ||
return makeCxxInstance(); | ||
} | ||
|
||
static void registerNatives() { | ||
registerHybrid({ | ||
makeNativeMethod("initHybrid", JSCInstance::initHybrid), | ||
}); | ||
} | ||
|
||
std::unique_ptr<jsi::Runtime> createJSRuntime() noexcept { | ||
return jsc::makeJSCRuntime(); | ||
} | ||
|
||
private: | ||
friend HybridBase; | ||
using HybridBase::HybridBase; | ||
}; | ||
|
||
} // namespace facebook::react | ||
|
||
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) { | ||
return facebook::jni::initialize( | ||
vm, [] { facebook::react::JSCInstance::registerNatives(); }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters