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.
Files changed (181) hide show
  1. package/hermes/CMakeLists.txt +874 -0
  2. package/hermes/android/HostObjectJniTest.cpp +178 -0
  3. package/hermes/android/build-logic/build.gradle.kts +31 -0
  4. package/hermes/android/build-logic/settings.gradle.kts +17 -0
  5. package/hermes/android/build-logic/src/main/kotlin/com/facebook/hermes/helpers/internal/SerializeHermesCompilerPackageJson.kt +33 -0
  6. package/hermes/android/build-logic/src/main/kotlin/com/facebook/hermes/plugins/internal/TestUtilsPlugin.kt +80 -0
  7. package/hermes/android/build-logic/src/main/kotlin/com/facebook/hermes/tasks/internal/CustomExecTask.kt +46 -0
  8. package/hermes/android/build-logic/src/main/kotlin/publish.gradle.kts +82 -0
  9. package/hermes/android/build.gradle.kts +332 -0
  10. package/hermes/android/cppruntime/build.gradle +72 -0
  11. package/hermes/android/cppruntime/src/main/AndroidManifest.xml +2 -0
  12. package/hermes/android/cppruntime/src/main/cpp/CMakeLists.txt +8 -0
  13. package/hermes/android/cppruntime/src/main/cpp/stub.cpp +12 -0
  14. package/hermes/android/cross-compile/swift-libicu.patch +13 -0
  15. package/hermes/android/cross-compile/toolchain-android-arm-api13-gnustl.cmake +13 -0
  16. package/hermes/android/cross-compile/toolchain-android-arm-api15-gnustl.cmake +14 -0
  17. package/hermes/android/gradle/libs.versions.toml +30 -0
  18. package/hermes/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  19. package/hermes/android/gradle/wrapper/gradle-wrapper.properties +7 -0
  20. package/hermes/android/gradle.properties +3 -0
  21. package/hermes/android/gradlew +248 -0
  22. package/hermes/android/gradlew.bat +93 -0
  23. package/hermes/android/intltest/build.gradle +147 -0
  24. package/hermes/android/intltest/java/com/facebook/hermes/test/CMakeLists.txt +45 -0
  25. package/hermes/android/intltest/java/com/facebook/hermes/test/HermesEpilogue.cpp +68 -0
  26. package/hermes/android/intltest/java/com/facebook/hermes/test/HermesEpilogue.h +44 -0
  27. package/hermes/android/intltest/java/com/facebook/hermes/test/HermesEpilogue.java +45 -0
  28. package/hermes/android/intltest/java/com/facebook/hermes/test/HermesEpilogueTestData.java +32 -0
  29. package/hermes/android/intltest/java/com/facebook/hermes/test/HermesInstrumentationTest.java +150 -0
  30. package/hermes/android/intltest/java/com/facebook/hermes/test/HermesIntlAndroidTest.java +147 -0
  31. package/hermes/android/intltest/java/com/facebook/hermes/test/HermesIntlTest262.java +470 -0
  32. package/hermes/android/intltest/java/com/facebook/hermes/test/HermesRuntimeFactory.cpp +73 -0
  33. package/hermes/android/intltest/java/com/facebook/hermes/test/JSRuntime.cpp +90 -0
  34. package/hermes/android/intltest/java/com/facebook/hermes/test/JSRuntime.h +62 -0
  35. package/hermes/android/intltest/java/com/facebook/hermes/test/JSRuntime.java +155 -0
  36. package/hermes/android/intltest/java/com/facebook/hermes/test/MappedFileBuffer.cpp +48 -0
  37. package/hermes/android/intltest/java/com/facebook/hermes/test/MappedFileBuffer.h +36 -0
  38. package/hermes/android/intltest/java/com/facebook/hermes/test/OnLoad.cpp +13 -0
  39. package/hermes/android/intltest/java/com/facebook/hermes/test/OnLoadEpilogue.cpp +13 -0
  40. package/hermes/android/intltest/src/main/AndroidManifest.xml +2 -0
  41. package/hermes/android/ios-artifacts/build.gradle.kts +65 -0
  42. package/hermes/android/settings.gradle.kts +27 -0
  43. package/hermes/cmake/modules/Hermes.cmake +481 -0
  44. package/hermes/cmake/modules/Lit.cmake +96 -0
  45. package/hermes/doc/Branches.md +38 -0
  46. package/hermes/doc/BuildingAndRunning.md +121 -0
  47. package/hermes/doc/CodingStandards.md +112 -0
  48. package/hermes/doc/CrossCompilation.md +79 -0
  49. package/hermes/doc/Design.md +217 -0
  50. package/hermes/doc/Emscripten.md +156 -0
  51. package/hermes/doc/Features.md +143 -0
  52. package/hermes/doc/GCSafeCoding.md +563 -0
  53. package/hermes/doc/GenGC.md +300 -0
  54. package/hermes/doc/Hades.md +344 -0
  55. package/hermes/doc/HighLevelOptimizations.md +37 -0
  56. package/hermes/doc/IR.md +1306 -0
  57. package/hermes/doc/IntlAPIs.md +196 -0
  58. package/hermes/doc/JIT.md +999 -0
  59. package/hermes/doc/LazyEvalCompilation.md +84 -0
  60. package/hermes/doc/MemoryProfilers.md +316 -0
  61. package/hermes/doc/Modules.md +144 -0
  62. package/hermes/doc/Optimizer.md +83 -0
  63. package/hermes/doc/PerfProfiling.md +29 -0
  64. package/hermes/doc/ProhibitInvoke.md +329 -0
  65. package/hermes/doc/ReactNative.md +40 -0
  66. package/hermes/doc/ReactNativeIntegration.md +94 -0
  67. package/hermes/doc/RegExp.md +24 -0
  68. package/hermes/doc/SpecIncompat.md +85 -0
  69. package/hermes/doc/Strings.md +140 -0
  70. package/hermes/doc/TypedLanguage.md +432 -0
  71. package/hermes/doc/VM.md +174 -0
  72. package/hermes/doc/blog/2024-11-09-octane-benchmark-jit-progress.md +17 -0
  73. package/hermes/doc/blog/2024-12-19-static-hermes-update-dec-2024.md +47 -0
  74. package/hermes/doc/blog/2024-12-23-compiling-javascript-to-wasm.md +267 -0
  75. package/hermes/doc/blog/2025-06-09-jsi-runtime-data-apis.md +23 -0
  76. package/hermes/doc/blog/2025-07-15-static-h-performance-june-2025.md +18 -0
  77. package/hermes/doc/blog/2025-11-02-hermes-compilation-runtime-modes.md +23 -0
  78. package/hermes/doc/blog/2025-11-06-hermes-memory-modes.md +35 -0
  79. package/hermes/doc/blog/2025-11-24-json-parsing-performance.md +17 -0
  80. package/hermes/doc/blog/2025-12-02-iserialization.md +11 -0
  81. package/hermes/doc/blog/2025-12-12-new-way-to-contribute.md +68 -0
  82. package/hermes/doc/blog/2026-06-05-new-hermes-stable-release.md +51 -0
  83. package/hermes/doc/blog/README.md +25 -0
  84. package/hermes/doc/blog/images/2024-11-09-octane-pi3.jpeg +0 -0
  85. package/hermes/doc/blog/images/2024-11-09-octane-pi5.jpeg +0 -0
  86. package/hermes/doc/blog/images/2025-07-15-perf-hv32-interpreter.jpeg +0 -0
  87. package/hermes/doc/blog/images/2025-07-15-perf-hv32-jit.jpeg +0 -0
  88. package/hermes/doc/icu_license.txt +420 -0
  89. package/hermes/doc/img/heap_snapshot_retainers.png +0 -0
  90. package/hermes/doc/img/logo.svg +1 -0
  91. package/hermes/doc/img/object_captured_by_environment.png +0 -0
  92. package/hermes/doc/img/root_categories.png +0 -0
  93. package/hermes/doc/plans/ir-type/flow-type-system.md +324 -0
  94. package/hermes/doc/plans/ir-type/ir-type-system-v2-design.md +652 -0
  95. package/hermes/doc/plans/ir-type/ir-type-system.md +220 -0
  96. package/hermes/doc/plans/ir-type/ir-type-v2-implementation.md +1187 -0
  97. package/hermes/doc/plans/ir-type/memory.md +48 -0
  98. package/hermes/doc/plans/ir-type/phase1-steps.md +512 -0
  99. package/hermes/doc/plans/ir-type/progress.md +239 -0
  100. package/hermes/doc/plans/ir-type/typeinference-primitive-fastpath-design.md +203 -0
  101. package/hermes/doc/plans/ir-type/typeinference-primitive-fastpath-results.md +71 -0
  102. package/hermes/doc/superpowers/plans/2026-07-28-worker-arraybuffer-input.md +597 -0
  103. package/hermes/doc/superpowers/plans/2026-08-18-jitemitter-split.md +1149 -0
  104. package/hermes/doc/superpowers/plans/2026-08-20-jit-type-asserts.md +969 -0
  105. package/hermes/doc/superpowers/plans/2026-08-23-jit-shared-compiler-driver.md +478 -0
  106. package/hermes/doc/superpowers/plans/2026-08-23-x86-64-jit-skeleton.md +797 -0
  107. package/hermes/doc/superpowers/plans/2026-08-24-x86-64-jit-arith.md +444 -0
  108. package/hermes/doc/superpowers/plans/2026-08-24-x86-64-jit-calls.md +261 -0
  109. package/hermes/doc/superpowers/plans/2026-08-24-x86-64-jit-props.md +240 -0
  110. package/hermes/doc/superpowers/plans/2026-10-26-regexp-bytecode-sharing.md +2197 -0
  111. package/hermes/doc/superpowers/plans/2026-10-28-regexp-start-filter-and-exec-fast-paths.md +3981 -0
  112. package/hermes/doc/superpowers/specs/2026-07-28-worker-arraybuffer-input-design.md +206 -0
  113. package/hermes/doc/superpowers/specs/2026-08-18-jitemitter-split-design.md +530 -0
  114. package/hermes/doc/superpowers/specs/2026-08-20-jit-type-asserts-design.md +360 -0
  115. package/hermes/doc/superpowers/specs/2026-08-23-x86-64-jit-design.md +246 -0
  116. package/hermes/doc/superpowers/specs/2026-08-26-icu-free-normalize-design.md +355 -0
  117. package/hermes/doc/superpowers/specs/2026-08-27-icu-free-convert-to-case-design.md +305 -0
  118. package/hermes/doc/superpowers/specs/2026-08-27-icu-free-locale-compare-design.md +429 -0
  119. package/hermes/doc/superpowers/specs/2026-08-29-icu-free-date-format-design.md +297 -0
  120. package/hermes/doc/superpowers/specs/2026-10-26-regexp-bytecode-sharing-design.md +605 -0
  121. package/hermes/doc/superpowers/specs/2026-10-28-regexp-start-filter-and-exec-fast-paths-design.md +551 -0
  122. package/hermes/doc/typescript-stripping.md +90 -0
  123. package/hermes/external/CMakeLists.txt +20 -0
  124. package/hermes/utils/IntlGen/IntlGen.java +531 -0
  125. package/hermes/utils/bench_with_stats.py +827 -0
  126. package/hermes/utils/build-apple-framework.sh +323 -0
  127. package/hermes/utils/chrome_snapshot_parser.py +210 -0
  128. package/hermes/utils/cmake-dev-build.sh +18 -0
  129. package/hermes/utils/commons.sh +55 -0
  130. package/hermes/utils/dump-cpp-funcs.sh +3 -0
  131. package/hermes/utils/es5objects.js +198 -0
  132. package/hermes/utils/format.sh +145 -0
  133. package/hermes/utils/gen-promise-internal-bc.sh +66 -0
  134. package/hermes/utils/genUnicodeTable.py +2503 -0
  135. package/hermes/utils/hermes-lit/CMakeLists.txt +22 -0
  136. package/hermes/utils/hermes-lit/hermes-lit.in +15 -0
  137. package/hermes/utils/jit/README.md +134 -0
  138. package/hermes/utils/jit/jit-diff.sh +160 -0
  139. package/hermes/utils/jit/jit-dump.sh +193 -0
  140. package/hermes/utils/lit-expect-gen/generate.py +217 -0
  141. package/hermes/utils/promise/index.js +15 -0
  142. package/hermes/utils/promise/package.json +13 -0
  143. package/hermes/utils/promise/rollup.config.js +19 -0
  144. package/hermes/utils/promise/yarn.lock +247 -0
  145. package/hermes/utils/scripts/hermes/consts.js +26 -0
  146. package/hermes/utils/scripts/hermes/create-tarball.js +75 -0
  147. package/hermes/utils/scripts/hermes/get-hermes-version.js +57 -0
  148. package/hermes/utils/scripts/hermes/hermes-utils.js +122 -0
  149. package/hermes/utils/scripts/hermes/package.json +6 -0
  150. package/hermes/utils/scripts/hermes/prepare-artifacts.js +113 -0
  151. package/hermes/utils/scripts/hermes/publish-artifacts.js +109 -0
  152. package/hermes/utils/scripts/hermes/publish-npm.js +96 -0
  153. package/hermes/utils/scripts/hermes/scm-utils.js +41 -0
  154. package/hermes/utils/scripts/hermes/set-artifacts-version.js +64 -0
  155. package/hermes/utils/scripts/hermes/version-utils.js +98 -0
  156. package/hermes/utils/scripts/hermes/yarn.lock +240 -0
  157. package/hermes/utils/summarize_sizes.py +184 -0
  158. package/hermes/utils/symbolicate-nativecall-stats.py +112 -0
  159. package/hermes/utils/test_runner.py +13 -0
  160. package/hermes/utils/testsuite/README.facebook +3 -0
  161. package/hermes/utils/testsuite/README.md +69 -0
  162. package/hermes/utils/testsuite/cli.py +547 -0
  163. package/hermes/utils/testsuite/es_ast.py +337 -0
  164. package/hermes/utils/testsuite/external/LICENSE +28 -0
  165. package/hermes/utils/testsuite/external/README.facebook +8 -0
  166. package/hermes/utils/testsuite/external/__init__.py +0 -0
  167. package/hermes/utils/testsuite/external/_monkeyYaml.py +164 -0
  168. package/hermes/utils/testsuite/external/parse_test262.py +141 -0
  169. package/hermes/utils/testsuite/hermes.py +522 -0
  170. package/hermes/utils/testsuite/preprocess.py +365 -0
  171. package/hermes/utils/testsuite/progress.py +377 -0
  172. package/hermes/utils/testsuite/skiplist.json +4356 -0
  173. package/hermes/utils/testsuite/skiplist.py +270 -0
  174. package/hermes/utils/testsuite/test_run_defs.py +435 -0
  175. package/hermes/utils/testsuite/typing_defs.py +52 -0
  176. package/hermes/utils/testsuite/utils.py +214 -0
  177. package/hermes/utils/tidy.sh +22 -0
  178. package/hermes/utils/update-fbcode-hermes.sh +53 -0
  179. package/hermes/utils/updateErrorTest.py +193 -0
  180. package/hermes/utils/wasm-compile.sh +65 -0
  181. package/package.json +1 -1
@@ -0,0 +1,323 @@
1
+ #!/bin/bash
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
+ # Builds Hermes Apple frameworks for all platforms (iOS, macOS, tvOS, visionOS,
8
+ # Mac Catalyst) and combines them into a single universal xcframework.
9
+ #
10
+ # Usage:
11
+ # ./build-apple-framework.sh # build all platforms + universal xcframework
12
+ # ./build-apple-framework.sh <platform> # build a single platform (e.g. macosx, iphoneos)
13
+ # ./build-apple-framework.sh build_framework # combine already-built slices into xcframework
14
+ # ./build-apple-framework.sh build_hermesc # build host hermesc compiler
15
+ # ./build-apple-framework.sh prepare_dest_root # assemble destroot from pre-built slices
16
+
17
+ if [ "$CI" ]; then
18
+ set -x
19
+ fi
20
+ set -e
21
+
22
+ CURR_SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
23
+
24
+ IMPORT_HERMESC_PATH=${HERMES_OVERRIDE_HERMESC_PATH:-$PWD/build_host_hermesc/ImportHostCompilers.cmake}
25
+ BUILD_TYPE=${BUILD_TYPE:-Debug}
26
+
27
+ HERMES_PATH="$CURR_SCRIPT_DIR/.."
28
+ HERMES_COMPILER_PACKAGE_PATH="$HERMES_PATH/npm/hermes-compiler"
29
+
30
+ NUM_CORES=$(sysctl -n hw.ncpu)
31
+
32
+ PLATFORMS=("macosx" "iphoneos" "iphonesimulator" "catalyst" "xros" "xrsimulator" "appletvos" "appletvsimulator")
33
+
34
+ if [[ -z "$JSI_PATH" ]]; then
35
+ JSI_PATH="$HERMES_PATH/API/jsi"
36
+ fi
37
+
38
+ function use_env_var {
39
+ if [[ -n "$1" ]]; then
40
+ echo "$1"
41
+ else
42
+ echo "error: Missing $2 environment variable"
43
+ exit 1
44
+ fi
45
+ }
46
+
47
+ function get_ios_deployment_target {
48
+ use_env_var "${IOS_DEPLOYMENT_TARGET}" "IOS_DEPLOYMENT_TARGET"
49
+ }
50
+
51
+ function get_visionos_deployment_target {
52
+ use_env_var "${XROS_DEPLOYMENT_TARGET}" "XROS_DEPLOYMENT_TARGET"
53
+ }
54
+
55
+ function get_mac_deployment_target {
56
+ use_env_var "${MAC_DEPLOYMENT_TARGET}" "MAC_DEPLOYMENT_TARGET"
57
+ }
58
+
59
+ function get_release_version {
60
+ local package_json_path="$HERMES_COMPILER_PACKAGE_PATH/package.json"
61
+ if [[ -f "$package_json_path" ]]; then
62
+ local version
63
+ version=$(node -e "console.log(JSON.parse(require('fs').readFileSync('$package_json_path', 'utf8')).version)" 2>/dev/null)
64
+ if [[ -n "$version" ]]; then
65
+ echo "$version"
66
+ return
67
+ else
68
+ echo >&2 "Error: Failed to read version from $package_json_path"
69
+ exit 1
70
+ fi
71
+ else
72
+ echo >&2 "Error: Package file not found at $package_json_path"
73
+ exit 1
74
+ fi
75
+ }
76
+
77
+ # Given a specific target, retrieve the right architecture for it
78
+ # $1 the target you want to build. Allowed values: iphoneos, iphonesimulator, catalyst, macosx, xros, xrsimulator, appletvos, appletvsimulator
79
+ function get_architecture {
80
+ if [[ $1 == "iphoneos" || $1 == "xros" || $1 == "appletvos" ]]; then
81
+ echo "arm64"
82
+ elif [[ $1 == "iphonesimulator" || $1 == "xrsimulator" || $1 == "appletvsimulator" || $1 == "catalyst" || $1 == "macosx" ]]; then
83
+ echo "x86_64;arm64"
84
+ else
85
+ echo "Error: unknown architecture passed $1"
86
+ exit 1
87
+ fi
88
+ }
89
+
90
+ function get_deployment_target {
91
+ if [[ $1 == "xros" || $1 == "xrsimulator" ]]; then
92
+ echo "$(get_visionos_deployment_target)"
93
+ elif [[ $1 == "macosx" ]]; then
94
+ echo "$(get_mac_deployment_target)"
95
+ else # tvOS and iOS use the same deployment target
96
+ echo "$(get_ios_deployment_target)"
97
+ fi
98
+ }
99
+
100
+ # Build host hermes compiler for internal bytecode
101
+ function build_host_hermesc {
102
+ echo "Building hermesc"
103
+ pushd "$HERMES_PATH" > /dev/null || exit 1
104
+ cmake -S . -B build_host_hermesc -DJSI_DIR="$JSI_PATH" -DCMAKE_BUILD_TYPE=Release
105
+ cmake --build ./build_host_hermesc --target hermesc -j "${NUM_CORES}"
106
+ popd > /dev/null || exit 1
107
+ }
108
+
109
+ function build_host_hermesc_if_needed {
110
+ if [[ ! -f "$IMPORT_HERMESC_PATH" ]]; then
111
+ build_host_hermesc
112
+ else
113
+ echo "[HermesC] Skipping! Found an existent hermesc already at: $IMPORT_HERMESC_PATH"
114
+ fi
115
+ }
116
+
117
+ # Utility function to configure an Apple framework
118
+ function configure_apple_framework {
119
+ local enable_debugger cmake_build_type xcode_15_flags xcode_major_version
120
+
121
+ if [[ $BUILD_TYPE == "Debug" ]]; then
122
+ enable_debugger="true"
123
+ else
124
+ enable_debugger="false"
125
+ fi
126
+ if [[ $BUILD_TYPE == "Debug" ]]; then
127
+ # JS developers aren't VM developers.
128
+ # Therefore we're passing as build type Release, to provide a faster build.
129
+ cmake_build_type="Release"
130
+ else
131
+ cmake_build_type="MinSizeRel"
132
+ fi
133
+
134
+ xcode_15_flags=""
135
+ xcode_major_version=$(xcodebuild -version | grep -oE '[0-9]*' | head -n 1)
136
+ if [[ $xcode_major_version -ge 15 ]]; then
137
+ xcode_15_flags="LINKER:-ld_classic"
138
+ fi
139
+
140
+ # For catalyst, we need to set the target triple to use the macabi environment.
141
+ # The architecture in -target is overridden by CMake's -arch flags, so we can use
142
+ # any architecture here (arm64). CMake will add -arch x86_64 and -arch arm64 which
143
+ # correctly override just the architecture portion while preserving ios-macabi.
144
+ boost_context_flag=""
145
+ shared_clang_flags=""
146
+ if [[ $1 == "catalyst" ]]; then
147
+ boost_context_flag="-DHERMES_ALLOW_BOOST_CONTEXT=0"
148
+ shared_clang_flags="-target arm64-apple-ios$3-macabi -isystem ${CMAKE_OSX_SYSROOT}/System/iOSSupport/usr/include"
149
+ fi
150
+
151
+ pushd "$HERMES_PATH" > /dev/null || exit 1
152
+ cmake -S . -B "build_$1" \
153
+ -DHERMES_EXTRA_LINKER_FLAGS="$xcode_15_flags" \
154
+ -DHERMES_APPLE_TARGET_PLATFORM:STRING="$1" \
155
+ -DCMAKE_OSX_ARCHITECTURES:STRING="$2" \
156
+ -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING="$3" \
157
+ -DHERMES_ENABLE_DEBUGGER:BOOLEAN="$enable_debugger" \
158
+ -DHERMES_ENABLE_INTL:BOOLEAN=true \
159
+ -DHERMES_ENABLE_LIBFUZZER:BOOLEAN=false \
160
+ -DHERMES_ENABLE_FUZZILLI:BOOLEAN=false \
161
+ -DHERMES_ENABLE_TEST_SUITE:BOOLEAN=false \
162
+ -DHERMES_ENABLE_BITCODE:BOOLEAN=false \
163
+ -DHERMES_BUILD_APPLE_FRAMEWORK:BOOLEAN=true \
164
+ -DHERMES_BUILD_SHARED_JSI:BOOLEAN=false \
165
+ -DCMAKE_CXX_FLAGS:STRING="-gdwarf $shared_clang_flags" \
166
+ -DCMAKE_C_FLAGS:STRING="-gdwarf $shared_clang_flags" \
167
+ -DIMPORT_HOST_COMPILERS:PATH="$IMPORT_HERMESC_PATH" \
168
+ -DJSI_DIR="$JSI_PATH" \
169
+ -DHERMES_RELEASE_VERSION="$(get_release_version)" \
170
+ -DCMAKE_BUILD_TYPE="$cmake_build_type" \
171
+ $boost_context_flag
172
+ popd > /dev/null || exit 1
173
+ }
174
+
175
+ function generate_dSYM {
176
+ TARGET_PLATFORM="$1"
177
+
178
+ DSYM_PATH="$PWD/build_$TARGET_PLATFORM/lib/hermesvm.framework.dSYM"
179
+ xcrun dsymutil "$PWD/build_$TARGET_PLATFORM/lib/hermesvm.framework/hermesvm" --out "$DSYM_PATH"
180
+ mkdir -p "$PWD/destroot/Library/Frameworks/$TARGET_PLATFORM"
181
+ cp -R "$DSYM_PATH" "$PWD/destroot/Library/Frameworks/$TARGET_PLATFORM"
182
+ }
183
+
184
+ # Utility function to build an Apple framework for a single platform
185
+ # $1: platform, $2: architectures, $3: deployment target
186
+ function build_apple_framework {
187
+ # Only build host HermesC if no file found at $IMPORT_HERMESC_PATH
188
+ build_host_hermesc_if_needed
189
+
190
+ # Confirm ImportHermesc.cmake is now available.
191
+ [ ! -f "$IMPORT_HERMESC_PATH" ] &&
192
+ echo "Host hermesc is required to build apple frameworks!"
193
+
194
+ echo "Building $BUILD_TYPE framework for $1 with architectures: $2"
195
+ configure_apple_framework "$1" "$2" "$3"
196
+
197
+ pushd "$HERMES_PATH" > /dev/null || exit 1
198
+ mkdir -p "destroot/Library/Frameworks/$1"
199
+ cmake --build "./build_$1" --target hermesvm -j "${NUM_CORES}"
200
+ cp -R "./build_$1"/lib/hermesvm.framework* "destroot/Library/Frameworks/$1"
201
+ generate_dSYM "$1"
202
+
203
+ # In a MacOS build, also produce the hermes and hermesc CLI tools.
204
+ if [[ $1 == macosx ]]; then
205
+ cmake --build "./build_$1" --target hermesc hermesvm -j "${NUM_CORES}"
206
+ mkdir -p destroot/bin
207
+ cp "./build_$1/bin"/* "destroot/bin"
208
+ fi
209
+
210
+ # Copy over Hermes and JSI API headers.
211
+ mkdir -p destroot/include/hermes/Public
212
+ cp public/hermes/Public/*.h destroot/include/hermes/Public
213
+
214
+ mkdir -p destroot/include/hermes
215
+ cp API/hermes/*.h destroot/include/hermes
216
+
217
+ mkdir -p destroot/include/hermes/cdp
218
+ cp API/hermes/cdp/*.h destroot/include/hermes/cdp
219
+
220
+ mkdir -p destroot/include/jsi
221
+ cp "$JSI_PATH"/jsi/*.h destroot/include/jsi
222
+ popd > /dev/null || exit 1
223
+ }
224
+
225
+ function prepare_dest_root_for_ci {
226
+ mkdir -p "destroot/bin"
227
+ for platform in "${PLATFORMS[@]}"; do
228
+ mkdir -p "destroot/Library/Frameworks/$platform"
229
+ cp -R "./build_$platform/lib/hermesvm.framework"* "destroot/Library/Frameworks/$platform"
230
+ done
231
+
232
+ cp "./build_macosx/bin/"* "destroot/bin"
233
+
234
+ # Copy over Hermes and JSI API headers.
235
+ mkdir -p destroot/include/hermes/Public
236
+ cp public/hermes/Public/*.h destroot/include/hermes/Public
237
+
238
+ mkdir -p destroot/include/hermes
239
+ cp API/hermes/*.h destroot/include/hermes
240
+
241
+ mkdir -p destroot/include/hermes/cdp
242
+ cp API/hermes/cdp/*.h destroot/include/hermes/cdp
243
+
244
+ mkdir -p destroot/include/jsi
245
+ cp "$JSI_PATH"/jsi/*.h destroot/include/jsi
246
+ }
247
+
248
+ # Accepts an array of frameworks and will place all of
249
+ # the architectures into an universal folder and then remove
250
+ # the merged frameworks from destroot
251
+ function create_universal_framework {
252
+ pushd "$HERMES_PATH/destroot/Library/Frameworks" > /dev/null || exit 1
253
+
254
+ local platforms=("$@")
255
+ local args=""
256
+
257
+ echo "Creating universal framework for platforms: ${platforms[*]}"
258
+
259
+ for i in "${!platforms[@]}"; do
260
+ local platform="${platforms[$i]}"
261
+ local hermes_framework_path="${platform}/hermesvm.framework"
262
+ args+="-framework $hermes_framework_path "
263
+ done
264
+
265
+ mkdir -p universal
266
+ # shellcheck disable=SC2086
267
+ if xcodebuild -create-xcframework $args -output "universal/hermesvm.xcframework"
268
+ then
269
+ # # Remove the thin hermesvm.frameworks that are now part of the universal
270
+ # XCFramework
271
+ for platform in "${platforms[@]}"; do
272
+ rm -r "$platform"
273
+ done
274
+ fi
275
+
276
+ popd > /dev/null || exit 1
277
+ }
278
+
279
+ # Build a single framework for a given platform
280
+ # $1 is the target to build (e.g. iphoneos, macosx, etc.)
281
+ function build_framework {
282
+ if [ ! -d destroot/Library/Frameworks/universal/hermesvm.xcframework ]; then
283
+ deployment_target=$(get_deployment_target "$1")
284
+ architecture=$(get_architecture "$1")
285
+ build_apple_framework "$1" "$architecture" "$deployment_target"
286
+ else
287
+ echo "Skipping; Clean \"destroot\" to rebuild".
288
+ fi
289
+ }
290
+
291
+ # Combine already-built slices into a universal xcframework
292
+ function build_universal_framework {
293
+ if [ ! -d destroot/Library/Frameworks/universal/hermesvm.xcframework ]; then
294
+ create_universal_framework "${PLATFORMS[@]}"
295
+ else
296
+ echo "Skipping; Clean \"destroot\" to rebuild".
297
+ fi
298
+ }
299
+
300
+ # Build all platforms sequentially then combine into a universal xcframework
301
+ function create_framework {
302
+ if [ ! -d destroot/Library/Frameworks/universal/hermesvm.xcframework ]; then
303
+ for platform in "${PLATFORMS[@]}"; do
304
+ build_framework "$platform"
305
+ done
306
+ build_universal_framework
307
+ else
308
+ echo "Skipping; Clean \"destroot\" to rebuild".
309
+ fi
310
+ }
311
+
312
+ # --- Entry point ---
313
+ if [[ -z $1 ]]; then
314
+ create_framework
315
+ elif [[ $1 == "build_framework" ]]; then
316
+ build_universal_framework
317
+ elif [[ $1 == "build_hermesc" ]]; then
318
+ build_host_hermesc_if_needed
319
+ elif [[ $1 == "prepare_dest_root" ]]; then
320
+ prepare_dest_root_for_ci
321
+ else
322
+ build_framework "$1"
323
+ fi
@@ -0,0 +1,210 @@
1
+ #!/usr/bin/env python3
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
+ import argparse
8
+ import json
9
+
10
+
11
+ """
12
+ Takes in a Chrome heap snapshot and makes the output into more explorable JSON
13
+ """
14
+
15
+
16
+ # The order of all these lists must match the order of fields that v8 outputs.
17
+ EDGE_FIELDS = ["type", "name_or_index", "to_node"]
18
+ EDGE_TYPES = [
19
+ "context",
20
+ "element",
21
+ "property",
22
+ "internal",
23
+ "hidden",
24
+ "shortcut",
25
+ "weak",
26
+ ]
27
+ NODE_FIELDS = [
28
+ "type",
29
+ "name",
30
+ "id",
31
+ "self_size",
32
+ "edge_count",
33
+ "trace_node_id",
34
+ "detachedness",
35
+ ]
36
+ NODE_TYPES = [
37
+ "hidden",
38
+ "array",
39
+ "string",
40
+ "object",
41
+ "code",
42
+ "closure",
43
+ "regexp",
44
+ "number",
45
+ "native",
46
+ "synthetic",
47
+ "concatenated string",
48
+ "sliced string",
49
+ "symbol",
50
+ "bigint",
51
+ ]
52
+ LOCATION_FIELDS = ["object_index", "script_id", "line", "column"]
53
+ SAMPLE_FIELDS = ["timestamp_us", "last_assigned_id"]
54
+ TRACE_FUNCTION_INFO_FIELDS = [
55
+ "function_id",
56
+ "name",
57
+ "script_name",
58
+ "script_id",
59
+ "line",
60
+ "column",
61
+ ]
62
+ TRACE_NODE_FIELDS = ["id", "function_info_index", "count", "size", "children"]
63
+
64
+
65
+ def chunk(arr, chunk_size):
66
+ assert len(arr) % chunk_size == 0, "arr must be evenly divisible by the chunk size"
67
+ assert chunk_size >= 1, "chunk_size must be at least 1"
68
+ for i in range(0, len(arr), chunk_size):
69
+ yield arr[i : i + chunk_size]
70
+
71
+
72
+ def main():
73
+ parser = argparse.ArgumentParser()
74
+ parser.add_argument("heapsnapshot")
75
+ parser.add_argument("out")
76
+ args = parser.parse_args()
77
+ with open(args.heapsnapshot, "r") as f:
78
+ root = json.load(f)
79
+
80
+ strings = root["strings"]
81
+ # First parse the trace fields, if present.
82
+ trace_functions = [
83
+ {
84
+ "function_id": function_id,
85
+ "name": strings[name],
86
+ "script_name": strings[script_name],
87
+ "script_id": script_id,
88
+ "line": line,
89
+ "column": column,
90
+ }
91
+ for function_id, name, script_name, script_id, line, column in chunk(
92
+ root.get("trace_function_infos", []), len(TRACE_FUNCTION_INFO_FIELDS)
93
+ )
94
+ ]
95
+ root["trace_function_infos"] = trace_functions
96
+
97
+ # The result of this will be the node, and that node's parent, to ascend
98
+ # the stack.
99
+ trace_id_to_node = {}
100
+ # The root node has trace_node_id 0, to make it easy to break out.
101
+ trace_tree = root.get("trace_tree", [])
102
+ if trace_tree:
103
+ trace_node_stack = [(trace_tree, 0)]
104
+ while trace_node_stack:
105
+ trace_node, parent_id = trace_node_stack.pop()
106
+ if not parent_id:
107
+ # Root node should be the only one at the top level.
108
+ assert len(trace_node) == len(TRACE_NODE_FIELDS), (
109
+ "More than one node at the top of the tree"
110
+ )
111
+ for child in chunk(trace_node, len(TRACE_NODE_FIELDS)):
112
+ # Convert function_info_index into the actual function_info.
113
+ child[1] = trace_functions[child[1]]
114
+ trace_id_to_node[child[0]] = (child, parent_id)
115
+ # Children array is the last element.
116
+ if child[-1]:
117
+ # Add to the stack, to do a depth first traversal of the tree.
118
+ trace_node_stack.append((child[-1], child[0]))
119
+
120
+ nodes = []
121
+ curr_edge = iter(chunk(root["edges"], len(EDGE_FIELDS)))
122
+ for raw_type, name, id, self_size, edge_count, trace_node_id, detachedness in chunk(
123
+ root["nodes"], len(NODE_FIELDS)
124
+ ):
125
+ edges = []
126
+ for _ in range(edge_count):
127
+ raw_edge_type, name_or_index, to_node = next(curr_edge)
128
+ real_type = EDGE_TYPES[raw_edge_type]
129
+ assert to_node % len(NODE_FIELDS) == 0, (
130
+ "to_node in an edge isn't divisible by {}".format(len(NODE_FIELDS))
131
+ )
132
+ edges.append(
133
+ {
134
+ "type": real_type,
135
+ "name_or_index": (
136
+ strings[name_or_index]
137
+ if real_type
138
+ in ("context", "property", "internal", "shortcut", "weak")
139
+ else name_or_index
140
+ ),
141
+ # Instead of printing the index, print the ID of the node
142
+ # pointed to. to_node points to the start of a node chunk,
143
+ # and the ID is the 3rd element in that chunk (zero-based
144
+ # indexing so +2 to get to the third element).
145
+ "to_node": root["nodes"][to_node + 2],
146
+ }
147
+ )
148
+ node = {
149
+ "type": NODE_TYPES[raw_type],
150
+ "name": strings[name],
151
+ "id": id,
152
+ "self_size": self_size,
153
+ "edges": edges,
154
+ "detachedness": detachedness,
155
+ }
156
+ # Make an allocation stack for this object.
157
+ allocation_stack = []
158
+ # The root ID is zero, and so is the default ID if tracing isn't on.
159
+ while trace_node_id:
160
+ trace_node, trace_node_id = trace_id_to_node[trace_node_id]
161
+ function_info = trace_node[1]
162
+ allocation_stack.append(
163
+ "{} at {}:{}:{}".format(
164
+ function_info["name"],
165
+ function_info["script_name"],
166
+ function_info["line"],
167
+ function_info["column"],
168
+ )
169
+ )
170
+ if allocation_stack:
171
+ # Reverse the stack, so that the first element is the topmost entry
172
+ # point.
173
+ node["alloc_stack"] = list(reversed(allocation_stack))
174
+ nodes.append(node)
175
+ try:
176
+ next(curr_edge)
177
+ raise AssertionError("Next edge should be the end of the edges")
178
+ except StopIteration:
179
+ pass
180
+ del root["edges"]
181
+ del root["trace_tree"]
182
+
183
+ # Iterate through locations and add the location resolution to nodes
184
+ for object_index, script_id, line, column in chunk(
185
+ root.get("locations", []), len(LOCATION_FIELDS)
186
+ ):
187
+ nodes[object_index // len(NODE_FIELDS)]["location"] = {
188
+ "script_id": script_id,
189
+ # Line numbers and column numbers are 0-based internally,
190
+ # but 1-based when viewed.
191
+ "line": line + 1,
192
+ "column": column + 1,
193
+ }
194
+ del root["locations"]
195
+
196
+ root["nodes"] = nodes
197
+ root["samples"] = [
198
+ {"timestamp": timestamp_us, "last_assigned_id": last_assigned_id}
199
+ for timestamp_us, last_assigned_id in chunk(
200
+ root.get("samples", []), len(SAMPLE_FIELDS)
201
+ )
202
+ ]
203
+
204
+ del root["strings"]
205
+ with open(args.out, "w") as f:
206
+ json.dump(root, f, indent=2)
207
+
208
+
209
+ if __name__ == "__main__":
210
+ main()
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env bash
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
+ # Thin wrapper script for setting up a CMake build directory which has options
8
+ # to ensure that large portions of code aren't commented out.
9
+ # For example, enables HV32 and the debugger to make sure they can compile
10
+ # while you're developing.
11
+ # Usage: use it just like cmake.
12
+ # cmake-dev-build.sh /path/to/static_h -GNinja any other args here
13
+
14
+ cmake \
15
+ -DHERMES_ENABLE_DEBUGGER=ON \
16
+ -DHERMESVM_HEAP_HV_MODE=HEAP_HV_PREFER32 \
17
+ -DJSI_UNSTABLE=ON \
18
+ "$@"
@@ -0,0 +1,55 @@
1
+ #!/usr/bin/env bash
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
+ if ! (return 0 2>/dev/null); then
8
+ echo "commons.sh must be sourced"
9
+ exit 1
10
+ fi
11
+
12
+ # Run a command repeatedly until it success (exit code is 0), up to X times.
13
+ # For example, "retry 3 make -j2" will run "make -j2" repeatedly until
14
+ # it fails 3 times or succeeds.
15
+ function retry() {
16
+ RETRY=$1
17
+ ATTEMPTS=0
18
+ while (( ATTEMPTS <= RETRY )); do
19
+ "${@:2}" && return 0
20
+ ATTEMPTS=$((ATTEMPTS+1))
21
+ echo "Retry: $ATTEMPTS failures so far"
22
+ done
23
+ echo "Retry depleted for command: ${*:2}"
24
+ return 1
25
+ }
26
+
27
+ # Determine platform so that things like NT
28
+ # don't need to be littered everywhere.
29
+ case "$(uname)" in
30
+ "Linux")
31
+ PLATFORM="linux" ;;
32
+ "Darwin")
33
+ PLATFORM="macosx" ;;
34
+ *"_NT-"*)
35
+ PLATFORM="windows" ;;
36
+ *)
37
+ PLATFORM="unknown" ;;
38
+ esac
39
+
40
+ # Setup Windows specific path conversion
41
+ if [[ "$PLATFORM" == "windows" ]]; then
42
+ platform_path() {
43
+ # Cygwin, MSYS, and MSYS2 all provides cygpath
44
+ cygpath -m -- "$@"
45
+ }
46
+ # Disable MSYS and MSYS2 automatic path conversion. This script needs to run
47
+ # in both Cygwin and MSYS*. Allowing the automatic path conversion,
48
+ # which isn't available in Cygwin, allows bugs to hide.
49
+ export MSYS2_ARG_CONV_EXCL="*"
50
+ export MSYS_NO_PATHCONV=1
51
+ else
52
+ platform_path() {
53
+ echo "$@"
54
+ }
55
+ fi
@@ -0,0 +1,3 @@
1
+ #!/bin/bash
2
+
3
+ ctags -x --c++-kinds=f $1 | sort -k3