react-nitro-hermes 0.0.1-alpha.8 → 0.0.1-alpha.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/hermes/CMakeLists.txt +874 -0
- package/hermes/android/HostObjectJniTest.cpp +178 -0
- package/hermes/android/build-logic/build.gradle.kts +31 -0
- package/hermes/android/build-logic/settings.gradle.kts +17 -0
- package/hermes/android/build-logic/src/main/kotlin/com/facebook/hermes/helpers/internal/SerializeHermesCompilerPackageJson.kt +33 -0
- package/hermes/android/build-logic/src/main/kotlin/com/facebook/hermes/plugins/internal/TestUtilsPlugin.kt +80 -0
- package/hermes/android/build-logic/src/main/kotlin/com/facebook/hermes/tasks/internal/CustomExecTask.kt +46 -0
- package/hermes/android/build-logic/src/main/kotlin/publish.gradle.kts +82 -0
- package/hermes/android/build.gradle.kts +332 -0
- package/hermes/android/cppruntime/build.gradle +72 -0
- package/hermes/android/cppruntime/src/main/AndroidManifest.xml +2 -0
- package/hermes/android/cppruntime/src/main/cpp/CMakeLists.txt +8 -0
- package/hermes/android/cppruntime/src/main/cpp/stub.cpp +12 -0
- package/hermes/android/cross-compile/swift-libicu.patch +13 -0
- package/hermes/android/cross-compile/toolchain-android-arm-api13-gnustl.cmake +13 -0
- package/hermes/android/cross-compile/toolchain-android-arm-api15-gnustl.cmake +14 -0
- package/hermes/android/gradle/libs.versions.toml +30 -0
- package/hermes/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/hermes/android/gradle/wrapper/gradle-wrapper.properties +7 -0
- package/hermes/android/gradle.properties +3 -0
- package/hermes/android/gradlew +248 -0
- package/hermes/android/gradlew.bat +93 -0
- package/hermes/android/intltest/build.gradle +147 -0
- package/hermes/android/intltest/java/com/facebook/hermes/test/CMakeLists.txt +45 -0
- package/hermes/android/intltest/java/com/facebook/hermes/test/HermesEpilogue.cpp +68 -0
- package/hermes/android/intltest/java/com/facebook/hermes/test/HermesEpilogue.h +44 -0
- package/hermes/android/intltest/java/com/facebook/hermes/test/HermesEpilogue.java +45 -0
- package/hermes/android/intltest/java/com/facebook/hermes/test/HermesEpilogueTestData.java +32 -0
- package/hermes/android/intltest/java/com/facebook/hermes/test/HermesInstrumentationTest.java +150 -0
- package/hermes/android/intltest/java/com/facebook/hermes/test/HermesIntlAndroidTest.java +147 -0
- package/hermes/android/intltest/java/com/facebook/hermes/test/HermesIntlTest262.java +470 -0
- package/hermes/android/intltest/java/com/facebook/hermes/test/HermesRuntimeFactory.cpp +73 -0
- package/hermes/android/intltest/java/com/facebook/hermes/test/JSRuntime.cpp +90 -0
- package/hermes/android/intltest/java/com/facebook/hermes/test/JSRuntime.h +62 -0
- package/hermes/android/intltest/java/com/facebook/hermes/test/JSRuntime.java +155 -0
- package/hermes/android/intltest/java/com/facebook/hermes/test/MappedFileBuffer.cpp +48 -0
- package/hermes/android/intltest/java/com/facebook/hermes/test/MappedFileBuffer.h +36 -0
- package/hermes/android/intltest/java/com/facebook/hermes/test/OnLoad.cpp +13 -0
- package/hermes/android/intltest/java/com/facebook/hermes/test/OnLoadEpilogue.cpp +13 -0
- package/hermes/android/intltest/src/main/AndroidManifest.xml +2 -0
- package/hermes/android/ios-artifacts/build.gradle.kts +65 -0
- package/hermes/android/settings.gradle.kts +27 -0
- package/hermes/cmake/modules/Hermes.cmake +481 -0
- package/hermes/cmake/modules/Lit.cmake +96 -0
- package/hermes/doc/Branches.md +38 -0
- package/hermes/doc/BuildingAndRunning.md +121 -0
- package/hermes/doc/CodingStandards.md +112 -0
- package/hermes/doc/CrossCompilation.md +79 -0
- package/hermes/doc/Design.md +217 -0
- package/hermes/doc/Emscripten.md +156 -0
- package/hermes/doc/Features.md +143 -0
- package/hermes/doc/GCSafeCoding.md +563 -0
- package/hermes/doc/GenGC.md +300 -0
- package/hermes/doc/Hades.md +344 -0
- package/hermes/doc/HighLevelOptimizations.md +37 -0
- package/hermes/doc/IR.md +1306 -0
- package/hermes/doc/IntlAPIs.md +196 -0
- package/hermes/doc/JIT.md +999 -0
- package/hermes/doc/LazyEvalCompilation.md +84 -0
- package/hermes/doc/MemoryProfilers.md +316 -0
- package/hermes/doc/Modules.md +144 -0
- package/hermes/doc/Optimizer.md +83 -0
- package/hermes/doc/PerfProfiling.md +29 -0
- package/hermes/doc/ProhibitInvoke.md +329 -0
- package/hermes/doc/ReactNative.md +40 -0
- package/hermes/doc/ReactNativeIntegration.md +94 -0
- package/hermes/doc/RegExp.md +24 -0
- package/hermes/doc/SpecIncompat.md +85 -0
- package/hermes/doc/Strings.md +140 -0
- package/hermes/doc/TypedLanguage.md +432 -0
- package/hermes/doc/VM.md +174 -0
- package/hermes/doc/blog/2024-11-09-octane-benchmark-jit-progress.md +17 -0
- package/hermes/doc/blog/2024-12-19-static-hermes-update-dec-2024.md +47 -0
- package/hermes/doc/blog/2024-12-23-compiling-javascript-to-wasm.md +267 -0
- package/hermes/doc/blog/2025-06-09-jsi-runtime-data-apis.md +23 -0
- package/hermes/doc/blog/2025-07-15-static-h-performance-june-2025.md +18 -0
- package/hermes/doc/blog/2025-11-02-hermes-compilation-runtime-modes.md +23 -0
- package/hermes/doc/blog/2025-11-06-hermes-memory-modes.md +35 -0
- package/hermes/doc/blog/2025-11-24-json-parsing-performance.md +17 -0
- package/hermes/doc/blog/2025-12-02-iserialization.md +11 -0
- package/hermes/doc/blog/2025-12-12-new-way-to-contribute.md +68 -0
- package/hermes/doc/blog/2026-06-05-new-hermes-stable-release.md +51 -0
- package/hermes/doc/blog/README.md +25 -0
- package/hermes/doc/blog/images/2024-11-09-octane-pi3.jpeg +0 -0
- package/hermes/doc/blog/images/2024-11-09-octane-pi5.jpeg +0 -0
- package/hermes/doc/blog/images/2025-07-15-perf-hv32-interpreter.jpeg +0 -0
- package/hermes/doc/blog/images/2025-07-15-perf-hv32-jit.jpeg +0 -0
- package/hermes/doc/icu_license.txt +420 -0
- package/hermes/doc/img/heap_snapshot_retainers.png +0 -0
- package/hermes/doc/img/logo.svg +1 -0
- package/hermes/doc/img/object_captured_by_environment.png +0 -0
- package/hermes/doc/img/root_categories.png +0 -0
- package/hermes/doc/plans/ir-type/flow-type-system.md +324 -0
- package/hermes/doc/plans/ir-type/ir-type-system-v2-design.md +652 -0
- package/hermes/doc/plans/ir-type/ir-type-system.md +220 -0
- package/hermes/doc/plans/ir-type/ir-type-v2-implementation.md +1187 -0
- package/hermes/doc/plans/ir-type/memory.md +48 -0
- package/hermes/doc/plans/ir-type/phase1-steps.md +512 -0
- package/hermes/doc/plans/ir-type/progress.md +239 -0
- package/hermes/doc/plans/ir-type/typeinference-primitive-fastpath-design.md +203 -0
- package/hermes/doc/plans/ir-type/typeinference-primitive-fastpath-results.md +71 -0
- package/hermes/doc/superpowers/plans/2026-07-28-worker-arraybuffer-input.md +597 -0
- package/hermes/doc/superpowers/plans/2026-08-18-jitemitter-split.md +1149 -0
- package/hermes/doc/superpowers/plans/2026-08-20-jit-type-asserts.md +969 -0
- package/hermes/doc/superpowers/plans/2026-08-23-jit-shared-compiler-driver.md +478 -0
- package/hermes/doc/superpowers/plans/2026-08-23-x86-64-jit-skeleton.md +797 -0
- package/hermes/doc/superpowers/plans/2026-08-24-x86-64-jit-arith.md +444 -0
- package/hermes/doc/superpowers/plans/2026-08-24-x86-64-jit-calls.md +261 -0
- package/hermes/doc/superpowers/plans/2026-08-24-x86-64-jit-props.md +240 -0
- package/hermes/doc/superpowers/plans/2026-10-26-regexp-bytecode-sharing.md +2197 -0
- package/hermes/doc/superpowers/plans/2026-10-28-regexp-start-filter-and-exec-fast-paths.md +3981 -0
- package/hermes/doc/superpowers/specs/2026-07-28-worker-arraybuffer-input-design.md +206 -0
- package/hermes/doc/superpowers/specs/2026-08-18-jitemitter-split-design.md +530 -0
- package/hermes/doc/superpowers/specs/2026-08-20-jit-type-asserts-design.md +360 -0
- package/hermes/doc/superpowers/specs/2026-08-23-x86-64-jit-design.md +246 -0
- package/hermes/doc/superpowers/specs/2026-08-26-icu-free-normalize-design.md +355 -0
- package/hermes/doc/superpowers/specs/2026-08-27-icu-free-convert-to-case-design.md +305 -0
- package/hermes/doc/superpowers/specs/2026-08-27-icu-free-locale-compare-design.md +429 -0
- package/hermes/doc/superpowers/specs/2026-08-29-icu-free-date-format-design.md +297 -0
- package/hermes/doc/superpowers/specs/2026-10-26-regexp-bytecode-sharing-design.md +605 -0
- package/hermes/doc/superpowers/specs/2026-10-28-regexp-start-filter-and-exec-fast-paths-design.md +551 -0
- package/hermes/doc/typescript-stripping.md +90 -0
- package/hermes/external/CMakeLists.txt +20 -0
- package/hermes/utils/IntlGen/IntlGen.java +531 -0
- package/hermes/utils/bench_with_stats.py +827 -0
- package/hermes/utils/build-apple-framework.sh +323 -0
- package/hermes/utils/chrome_snapshot_parser.py +210 -0
- package/hermes/utils/cmake-dev-build.sh +18 -0
- package/hermes/utils/commons.sh +55 -0
- package/hermes/utils/dump-cpp-funcs.sh +3 -0
- package/hermes/utils/es5objects.js +198 -0
- package/hermes/utils/format.sh +145 -0
- package/hermes/utils/gen-promise-internal-bc.sh +66 -0
- package/hermes/utils/genUnicodeTable.py +2503 -0
- package/hermes/utils/hermes-lit/CMakeLists.txt +22 -0
- package/hermes/utils/hermes-lit/hermes-lit.in +15 -0
- package/hermes/utils/jit/README.md +134 -0
- package/hermes/utils/jit/jit-diff.sh +160 -0
- package/hermes/utils/jit/jit-dump.sh +193 -0
- package/hermes/utils/lit-expect-gen/generate.py +217 -0
- package/hermes/utils/promise/index.js +15 -0
- package/hermes/utils/promise/package.json +13 -0
- package/hermes/utils/promise/rollup.config.js +19 -0
- package/hermes/utils/promise/yarn.lock +247 -0
- package/hermes/utils/scripts/hermes/consts.js +26 -0
- package/hermes/utils/scripts/hermes/create-tarball.js +75 -0
- package/hermes/utils/scripts/hermes/get-hermes-version.js +57 -0
- package/hermes/utils/scripts/hermes/hermes-utils.js +122 -0
- package/hermes/utils/scripts/hermes/package.json +6 -0
- package/hermes/utils/scripts/hermes/prepare-artifacts.js +113 -0
- package/hermes/utils/scripts/hermes/publish-artifacts.js +109 -0
- package/hermes/utils/scripts/hermes/publish-npm.js +96 -0
- package/hermes/utils/scripts/hermes/scm-utils.js +41 -0
- package/hermes/utils/scripts/hermes/set-artifacts-version.js +64 -0
- package/hermes/utils/scripts/hermes/version-utils.js +98 -0
- package/hermes/utils/scripts/hermes/yarn.lock +240 -0
- package/hermes/utils/summarize_sizes.py +184 -0
- package/hermes/utils/symbolicate-nativecall-stats.py +112 -0
- package/hermes/utils/test_runner.py +13 -0
- package/hermes/utils/testsuite/README.facebook +3 -0
- package/hermes/utils/testsuite/README.md +69 -0
- package/hermes/utils/testsuite/cli.py +547 -0
- package/hermes/utils/testsuite/es_ast.py +337 -0
- package/hermes/utils/testsuite/external/LICENSE +28 -0
- package/hermes/utils/testsuite/external/README.facebook +8 -0
- package/hermes/utils/testsuite/external/__init__.py +0 -0
- package/hermes/utils/testsuite/external/_monkeyYaml.py +164 -0
- package/hermes/utils/testsuite/external/parse_test262.py +141 -0
- package/hermes/utils/testsuite/hermes.py +522 -0
- package/hermes/utils/testsuite/preprocess.py +365 -0
- package/hermes/utils/testsuite/progress.py +377 -0
- package/hermes/utils/testsuite/skiplist.json +4356 -0
- package/hermes/utils/testsuite/skiplist.py +270 -0
- package/hermes/utils/testsuite/test_run_defs.py +435 -0
- package/hermes/utils/testsuite/typing_defs.py +52 -0
- package/hermes/utils/testsuite/utils.py +214 -0
- package/hermes/utils/tidy.sh +22 -0
- package/hermes/utils/update-fbcode-hermes.sh +53 -0
- package/hermes/utils/updateErrorTest.py +193 -0
- package/hermes/utils/wasm-compile.sh +65 -0
- package/package.json +1 -1
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
#ifndef JSRUNTIME_H
|
|
9
|
+
#define JSRUNTIME_H
|
|
10
|
+
|
|
11
|
+
#include <fbjni/fbjni.h>
|
|
12
|
+
#include <jsi/jsi.h>
|
|
13
|
+
|
|
14
|
+
namespace facebook {
|
|
15
|
+
namespace jsi {
|
|
16
|
+
namespace jni {
|
|
17
|
+
|
|
18
|
+
namespace jni = ::facebook::jni;
|
|
19
|
+
|
|
20
|
+
class JSRuntime : public jni::HybridClass<JSRuntime> {
|
|
21
|
+
public:
|
|
22
|
+
constexpr static auto kJavaDescriptor =
|
|
23
|
+
"Lcom/facebook/hermes/test/JSRuntime;";
|
|
24
|
+
|
|
25
|
+
static jni::local_ref<jhybridobject> makeHermesRuntime(
|
|
26
|
+
jni::alias_ref<jclass>,
|
|
27
|
+
bool shouldRecordGCStats);
|
|
28
|
+
static jni::local_ref<jhybridobject> makeHermesRuntimeWithHeapSpec(
|
|
29
|
+
jni::alias_ref<jclass>,
|
|
30
|
+
jlong initHeapSize,
|
|
31
|
+
jlong maxHeapSize,
|
|
32
|
+
bool shouldRecordGCStats);
|
|
33
|
+
|
|
34
|
+
static jni::local_ref<jbyteArray> compileJavaScript(
|
|
35
|
+
jni::alias_ref<jclass>,
|
|
36
|
+
jni::alias_ref<jbyteArray> bytes);
|
|
37
|
+
|
|
38
|
+
static void registerNatives();
|
|
39
|
+
|
|
40
|
+
void evaluateJavaScript(jni::alias_ref<jbyteArray> bytes);
|
|
41
|
+
void evaluateJavaScriptFile(std::string fileName);
|
|
42
|
+
|
|
43
|
+
jint getGlobalNumberProperty(std::string propName);
|
|
44
|
+
std::string getGlobalStringProperty(std::string propName);
|
|
45
|
+
void setGlobalNumberProperty(std::string propName, jint val);
|
|
46
|
+
void setGlobalStringProperty(std::string propName, std::string val);
|
|
47
|
+
void callFunction(std::string functionName);
|
|
48
|
+
|
|
49
|
+
std::string getRecordedGCStats();
|
|
50
|
+
|
|
51
|
+
private:
|
|
52
|
+
friend HybridBase;
|
|
53
|
+
JSRuntime(std::unique_ptr<jsi::Runtime> rt);
|
|
54
|
+
|
|
55
|
+
std::unique_ptr<jsi::Runtime> runtime_;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
} // namespace jni
|
|
59
|
+
} // namespace jsi
|
|
60
|
+
} // namespace facebook
|
|
61
|
+
|
|
62
|
+
#endif // JSRUNTIME_H
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
package com.facebook.hermes.test;
|
|
9
|
+
|
|
10
|
+
import android.annotation.SuppressLint;
|
|
11
|
+
import android.annotation.TargetApi;
|
|
12
|
+
import androidx.test.InstrumentationRegistry;
|
|
13
|
+
import com.facebook.jni.HybridData;
|
|
14
|
+
import com.facebook.proguard.annotations.DoNotStrip;
|
|
15
|
+
import com.facebook.soloader.SoLoader;
|
|
16
|
+
import java.nio.charset.Charset;
|
|
17
|
+
|
|
18
|
+
// This class is only used by tests. If they fail on older APIs, I
|
|
19
|
+
// don't care.
|
|
20
|
+
@TargetApi(19)
|
|
21
|
+
public class JSRuntime implements AutoCloseable {
|
|
22
|
+
static {
|
|
23
|
+
SoLoader.init(InstrumentationRegistry.getContext(), false);
|
|
24
|
+
try {
|
|
25
|
+
// The OSS build produces two .so files, so both need
|
|
26
|
+
// to be loaded to initialize JNI context.
|
|
27
|
+
SoLoader.loadLibrary("hermes");
|
|
28
|
+
} catch (UnsatisfiedLinkError e) {
|
|
29
|
+
// FB Internal build doesn't produce a separate libhermes,
|
|
30
|
+
// so just ignore this failure.
|
|
31
|
+
}
|
|
32
|
+
SoLoader.loadLibrary("jsijni");
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@DoNotStrip
|
|
36
|
+
@SuppressLint("NotAccessedPrivateField")
|
|
37
|
+
private final HybridData mHybridData;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Create a {@link JSRuntime} that evaluates JS using Hermes.
|
|
41
|
+
*
|
|
42
|
+
* @param shouldRecordGCStats indicates whether or not the runtime should collect GC statistics
|
|
43
|
+
* which can be accessed through calls to {@link getRecordedGCStats}. This parameter is
|
|
44
|
+
* optional, and defaults to {@code false}.
|
|
45
|
+
*/
|
|
46
|
+
public static native JSRuntime makeHermesRuntime(boolean shouldRecordGCStats);
|
|
47
|
+
|
|
48
|
+
public static JSRuntime makeHermesRuntime() {
|
|
49
|
+
return makeHermesRuntime(/* shouldRecordGCStats */ false);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Create a {@link JSRuntime} that evaluates JS using Hermes, with the given initial and maximum
|
|
54
|
+
* heap sizes.
|
|
55
|
+
*
|
|
56
|
+
* @param shouldRecordGCStats indicates whether or not the runtime should collect GC statistics
|
|
57
|
+
* which can be accessed through calls to {@link getRecordedGCStats}. This parameter is
|
|
58
|
+
* optional, and defaults to {@code false}.
|
|
59
|
+
*/
|
|
60
|
+
public static native JSRuntime makeHermesRuntimeWithHeapSpec(
|
|
61
|
+
long initHeapSize, long maxHeapSize, boolean shouldRecordGCStats);
|
|
62
|
+
|
|
63
|
+
public static JSRuntime makeHermesRuntimeWithHeapSpec(long initHeapSize, long maxHeapSize) {
|
|
64
|
+
return makeHermesRuntimeWithHeapSpec(
|
|
65
|
+
initHeapSize, maxHeapSize, /* shouldRecordGCStats */ false);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** Compile JS source to bytecode. NOTE: This only creates hermes bytecode. */
|
|
69
|
+
public static native byte[] compileJavaScript(byte[] code);
|
|
70
|
+
|
|
71
|
+
public static byte[] compileJavaScript(String code) {
|
|
72
|
+
return compileJavaScript(code.getBytes(Charset.forName("UTF-8")));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
private JSRuntime(HybridData hybridData) {
|
|
76
|
+
mHybridData = hybridData;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Evaluate JS in the runtime managed by this object.
|
|
81
|
+
*
|
|
82
|
+
* @param code the JS source code to evaluate.
|
|
83
|
+
*/
|
|
84
|
+
public native void evaluateJavaScript(byte[] code);
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Evaluate JS in the runtime managed by this object.
|
|
88
|
+
*
|
|
89
|
+
* @param code the JS source code to evaluate, as a String.
|
|
90
|
+
*/
|
|
91
|
+
public void evaluateJavaScript(String code) {
|
|
92
|
+
evaluateJavaScript(code.getBytes(Charset.forName("UTF-8")));
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Evaluate JS in the runtime managed by this object.
|
|
97
|
+
*
|
|
98
|
+
* @param codeFile the path to the file containing JS source or bytecode.
|
|
99
|
+
*/
|
|
100
|
+
public native void evaluateJavaScriptFile(String codeFile);
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* It is assumed that the property is an int.
|
|
104
|
+
*
|
|
105
|
+
* @param propertyName name of the property on the global object
|
|
106
|
+
*/
|
|
107
|
+
public native int getGlobalNumberProperty(String propertyName);
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Set a int type property.
|
|
111
|
+
*
|
|
112
|
+
* @param propertyName name of the property on the global object
|
|
113
|
+
* @param val value of the property
|
|
114
|
+
*/
|
|
115
|
+
public native void setGlobalNumberProperty(String propertyName, int val);
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Set a String type property.
|
|
119
|
+
*
|
|
120
|
+
* @param propertyName name of the property on the global object
|
|
121
|
+
* @param val value of the property
|
|
122
|
+
*/
|
|
123
|
+
public native void setGlobalStringProperty(String propertyName, String val);
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Call a Java Script function by name
|
|
127
|
+
*
|
|
128
|
+
* @param functionName the name of the function
|
|
129
|
+
*/
|
|
130
|
+
public native void callFunction(String functionName);
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* It is assumed that the property is a String.
|
|
134
|
+
*
|
|
135
|
+
* @param propertyName name of the property on the global object
|
|
136
|
+
*/
|
|
137
|
+
public native String getGlobalStringProperty(String propertyName);
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* (Hermes-only API)
|
|
141
|
+
*
|
|
142
|
+
* @return the GC statistics that have been collected so far, as a JSON-encoded string, if there
|
|
143
|
+
* are any.
|
|
144
|
+
*/
|
|
145
|
+
public native String getRecordedGCStats();
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Explicitly deallocate the Runtime. After a particular instance of the Hermes Runtime has been
|
|
149
|
+
* closed, any other calls to it will result in a {@link NullPointerException}.
|
|
150
|
+
*/
|
|
151
|
+
@Override
|
|
152
|
+
public void close() {
|
|
153
|
+
mHybridData.resetNative();
|
|
154
|
+
}
|
|
155
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
#include <MappedFileBuffer.h>
|
|
9
|
+
|
|
10
|
+
#include <fcntl.h>
|
|
11
|
+
#include <sys/mman.h>
|
|
12
|
+
#include <sys/stat.h>
|
|
13
|
+
#include <unistd.h>
|
|
14
|
+
#include <memory>
|
|
15
|
+
#include <system_error>
|
|
16
|
+
|
|
17
|
+
namespace facebook {
|
|
18
|
+
namespace jsi {
|
|
19
|
+
namespace jni {
|
|
20
|
+
|
|
21
|
+
MappedFileBuffer::MappedFileBuffer(const std::string &fileName) {
|
|
22
|
+
fd_ = open(fileName.c_str(), O_RDONLY);
|
|
23
|
+
if (fd_ < 0) {
|
|
24
|
+
throw std::system_error(errno, std::system_category(), "open failed");
|
|
25
|
+
}
|
|
26
|
+
struct stat statbuf;
|
|
27
|
+
if (fstat(fd_, &statbuf) < 0) {
|
|
28
|
+
throw std::system_error(errno, std::system_category(), "fstat failed");
|
|
29
|
+
}
|
|
30
|
+
size_ = statbuf.st_size;
|
|
31
|
+
void *bytecodeFileMap = mmap(
|
|
32
|
+
/*address*/ nullptr, size_, PROT_READ, MAP_PRIVATE, fd_, /*offset*/ 0);
|
|
33
|
+
assert(bytecodeFileMap != MAP_FAILED && "mmap failed.");
|
|
34
|
+
data_ = reinterpret_cast<uint8_t *>(bytecodeFileMap);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
MappedFileBuffer::~MappedFileBuffer() {
|
|
38
|
+
if (munmap(data_, size_) < 0) {
|
|
39
|
+
assert(false && "Failed to munmap MappedFileBuffer");
|
|
40
|
+
}
|
|
41
|
+
if (close(fd_) < 0) {
|
|
42
|
+
assert(false && "Failed to close MappedFileBuffer");
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
} // namespace jni
|
|
47
|
+
} // namespace jsi
|
|
48
|
+
} // namespace facebook
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
#include <jsi/jsi.h>
|
|
9
|
+
|
|
10
|
+
namespace facebook {
|
|
11
|
+
namespace jsi {
|
|
12
|
+
namespace jni {
|
|
13
|
+
|
|
14
|
+
class MappedFileBuffer : public jsi::Buffer {
|
|
15
|
+
public:
|
|
16
|
+
explicit MappedFileBuffer(const std::string &fileName);
|
|
17
|
+
|
|
18
|
+
size_t size() const override {
|
|
19
|
+
return size_;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const uint8_t *data() const override {
|
|
23
|
+
return data_;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
~MappedFileBuffer() override;
|
|
27
|
+
|
|
28
|
+
private:
|
|
29
|
+
int fd_;
|
|
30
|
+
uint8_t *data_;
|
|
31
|
+
size_t size_;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
} // namespace jni
|
|
35
|
+
} // namespace jsi
|
|
36
|
+
} // namespace facebook
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
#include "JSRuntime.h"
|
|
9
|
+
|
|
10
|
+
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
|
|
11
|
+
return facebook::jni::initialize(
|
|
12
|
+
vm, [] { facebook::jsi::jni::JSRuntime::registerNatives(); });
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
#include "HermesEpilogue.h"
|
|
9
|
+
|
|
10
|
+
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
|
|
11
|
+
return facebook::jni::initialize(
|
|
12
|
+
vm, [] { facebook::jsi::jni::HermesEpilogue::registerNatives(); });
|
|
13
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
plugins {
|
|
9
|
+
id("maven-publish")
|
|
10
|
+
id("publish")
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
group = "com.facebook.hermes"
|
|
14
|
+
|
|
15
|
+
version = project.findProperty("VERSION_NAME")?.toString()!!
|
|
16
|
+
|
|
17
|
+
configurations.maybeCreate("iosArtifacts")
|
|
18
|
+
|
|
19
|
+
// Those artifacts should be placed inside the `artifacts/hermes-ios-*.tar.gz` location.
|
|
20
|
+
val hermesiOSDebugArtifactFile: RegularFile =
|
|
21
|
+
layout.projectDirectory.file("artifacts/hermes-ios-debug.tar.gz")
|
|
22
|
+
val hermesiOSDebugArtifact: PublishArtifact =
|
|
23
|
+
artifacts.add("iosArtifacts", hermesiOSDebugArtifactFile) {
|
|
24
|
+
type = "tgz"
|
|
25
|
+
extension = "tar.gz"
|
|
26
|
+
classifier = "hermes-ios-debug"
|
|
27
|
+
}
|
|
28
|
+
val hermesiOSReleaseArtifactFile: RegularFile =
|
|
29
|
+
layout.projectDirectory.file("artifacts/hermes-ios-release.tar.gz")
|
|
30
|
+
val hermesiOSReleaseArtifact: PublishArtifact =
|
|
31
|
+
artifacts.add("iosArtifacts", hermesiOSReleaseArtifactFile) {
|
|
32
|
+
type = "tgz"
|
|
33
|
+
extension = "tar.gz"
|
|
34
|
+
classifier = "hermes-ios-release"
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Those artifacts should be placed inside the `artifacts/hermes-*.framework.dSYM` location
|
|
38
|
+
val hermesDSYMDebugArtifactFile: RegularFile =
|
|
39
|
+
layout.projectDirectory.file("artifacts/hermes-framework-dSYM-debug.tar.gz")
|
|
40
|
+
val hermesDSYMDebugArtifact: PublishArtifact =
|
|
41
|
+
artifacts.add("iosArtifacts", hermesDSYMDebugArtifactFile) {
|
|
42
|
+
type = "tgz"
|
|
43
|
+
extension = "tar.gz"
|
|
44
|
+
classifier = "hermes-framework-dSYM-debug"
|
|
45
|
+
}
|
|
46
|
+
val hermesDSYMReleaseArtifactFile: RegularFile =
|
|
47
|
+
layout.projectDirectory.file("artifacts/hermes-framework-dSYM-release.tar.gz")
|
|
48
|
+
val hermesDSYMReleaseArtifact: PublishArtifact =
|
|
49
|
+
artifacts.add("iosArtifacts", hermesDSYMReleaseArtifactFile) {
|
|
50
|
+
type = "tgz"
|
|
51
|
+
extension = "tar.gz"
|
|
52
|
+
classifier = "hermes-framework-dSYM-release"
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
publishing {
|
|
56
|
+
publications {
|
|
57
|
+
getByName("release", MavenPublication::class) {
|
|
58
|
+
artifactId = "hermes-ios"
|
|
59
|
+
artifact(hermesiOSDebugArtifact)
|
|
60
|
+
artifact(hermesiOSReleaseArtifact)
|
|
61
|
+
artifact(hermesDSYMDebugArtifact)
|
|
62
|
+
artifact(hermesDSYMReleaseArtifact)
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
pluginManagement {
|
|
9
|
+
includeBuild("build-logic")
|
|
10
|
+
|
|
11
|
+
repositories {
|
|
12
|
+
mavenCentral()
|
|
13
|
+
google()
|
|
14
|
+
gradlePluginPortal()
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
dependencyResolutionManagement {
|
|
19
|
+
repositories {
|
|
20
|
+
google()
|
|
21
|
+
mavenCentral()
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
rootProject.name = "hermes-engine"
|
|
26
|
+
|
|
27
|
+
include(":ios-artifacts", ":cppruntime", ":intltest")
|