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,52 @@
1
+ # Copyright (c) Meta Platforms, Inc. and affiliates.
2
+ #
3
+ # This source code is licensed under the MIT license found in the
4
+ # LICENSE file in the root directory of this source tree.
5
+
6
+ from __future__ import annotations
7
+
8
+ from typing import Dict, List, Optional, TypedDict, Union
9
+
10
+
11
+ # PathT = Union[str, bytes, os.PathLike]
12
+ # Currently, paths passed between functions are mostly str, so use it
13
+ # to aovid unncessary conversions.
14
+ PathT = str
15
+
16
+
17
+ class ExpectedFailure(TypedDict):
18
+ phase: str
19
+ type: str
20
+
21
+
22
+ OptExpectedFailure = Optional[ExpectedFailure]
23
+
24
+
25
+ class PathsWithComment(TypedDict):
26
+ """
27
+ A list of paths (to be skipped), with a comment explaining why we skip them.
28
+ """
29
+
30
+ # TODO(zhaogang): we can make this recursive to have nested comments on
31
+ # paths.
32
+ paths: List[str]
33
+ comment: str
34
+
35
+
36
+ SkippedPathItem = Union[PathsWithComment, str]
37
+
38
+
39
+ class SkippedPathsOrFeaturesDict(TypedDict):
40
+ skip_list: List[SkippedPathItem]
41
+ lazy_skip_list: List[SkippedPathItem]
42
+ permant_skip_list: List[SkippedPathItem]
43
+ handlesan_skip_list: List[SkippedPathItem]
44
+ unsupported_features: List[str]
45
+ permant_unsupported_features: List[str]
46
+ intl_tests: List[SkippedPathItem]
47
+ platform_skip_list: Dict[str, List[SkippedPathItem]]
48
+
49
+
50
+ # Use | with Python 3.10+
51
+ # This is a recursive type, requiring support of type checker.
52
+ JSON = Union[int, float, str, bool, List["JSON"], Dict[str, "JSON"], None]
@@ -0,0 +1,214 @@
1
+ # Copyright (c) Meta Platforms, Inc. and affiliates.
2
+ #
3
+ # This source code is licensed under the MIT license found in the
4
+ # LICENSE file in the root directory of this source tree.
5
+
6
+ from __future__ import annotations
7
+
8
+ import os
9
+ import re
10
+ import sys
11
+ from dataclasses import dataclass
12
+ from enum import auto, Enum, unique
13
+ from functools import cache
14
+ from pathlib import Path
15
+ from typing import List, Set
16
+
17
+ from .typing_defs import PathT
18
+
19
+
20
+ @unique
21
+ class TestResultCode(Enum):
22
+ TEST_PASSED = auto()
23
+ TEST_FAILED = auto()
24
+ """Only use TEST_FAILED for unclassified failure, e.g., JSON error."""
25
+ TEST_SKIPPED = auto()
26
+ TEST_PERMANENTLY_SKIPPED = auto()
27
+ COMPILE_FAILED = auto()
28
+ COMPILE_TIMEOUT = auto()
29
+ EXECUTE_FAILED = auto()
30
+ EXECUTE_TIMEOUT = auto()
31
+
32
+ @property
33
+ def is_failure(self) -> bool:
34
+ """Return whether this code indicates a test failure."""
35
+ return (
36
+ self != TestResultCode.TEST_PASSED
37
+ and self != TestResultCode.TEST_SKIPPED
38
+ and self != TestResultCode.TEST_PERMANENTLY_SKIPPED
39
+ )
40
+
41
+
42
+ @dataclass
43
+ class TestCaseResult(object):
44
+ # Test name
45
+ test_name: str
46
+ code: TestResultCode
47
+ # A short message
48
+ msg: str = ""
49
+ # Output details of this test run
50
+ output: str = ""
51
+ # Subprocess wall-clock duration in seconds
52
+ duration: float = 0.0
53
+
54
+
55
+ # Colors for stdout.
56
+ @unique
57
+ class Color(Enum):
58
+ RESET = auto()
59
+ RED = auto()
60
+ GREEN = auto()
61
+
62
+ def __str__(self):
63
+ if not sys.stdout.isatty():
64
+ return ""
65
+ return {
66
+ Color.RESET.value: "\033[0m",
67
+ Color.RED.value: "\033[31m",
68
+ Color.GREEN.value: "\033[32m",
69
+ }[self.value]
70
+
71
+
72
+ # Ignore non-JS files and fixture files in test262.
73
+ def is_test(f: PathT) -> bool:
74
+ isFixture = "test262" in f and f.endswith("_FIXTURE.js")
75
+ return f.endswith(".js") and not isFixture
76
+
77
+
78
+ def list_all_files(paths: List[PathT]) -> List[PathT]:
79
+ """
80
+ Recursively list all files in the given paths.
81
+ """
82
+
83
+ files = []
84
+ for p in paths:
85
+ if os.path.isdir(p):
86
+ for root, _, filenames in os.walk(p):
87
+ for filename in filenames:
88
+ full_filename = os.path.join(root, filename)
89
+ if is_test(full_filename):
90
+ files.append(full_filename)
91
+ elif os.path.isfile(p):
92
+ if is_test(p):
93
+ files.append(p)
94
+ else:
95
+ print(f"Invalid path: {p}")
96
+ sys.exit(1)
97
+
98
+ return files
99
+
100
+
101
+ def list_entries_non_recursive(dir_path: PathT) -> List[PathT]:
102
+ """
103
+ List all files and directories in the given path (non-recursively).
104
+ """
105
+
106
+ entries = []
107
+ for entry in os.listdir(dir_path):
108
+ path = os.path.join(dir_path, entry)
109
+ if os.path.isdir(path):
110
+ entries.append(path)
111
+ elif os.path.isfile(path):
112
+ if is_test(path):
113
+ entries.append(path)
114
+ else:
115
+ print(f"Invalid path: {path}")
116
+ sys.exit(1)
117
+
118
+ return entries
119
+
120
+
121
+ def list_all_matched_entries(pattern: str) -> List[PathT]:
122
+ """
123
+ List all files/directories matching the given pattern, which could be a
124
+ directory path, or a partial path that is prefix of other file paths.
125
+
126
+ Unlike list_all_files(), when the pattern is a directory path, we only list
127
+ the files/directories directly under it.
128
+ """
129
+
130
+ if os.path.isdir(pattern):
131
+ return list_entries_non_recursive(pattern)
132
+
133
+ # In skiplist config, we have partial path like
134
+ # test262/test/language/statements/for-of/head-let. We first get its
135
+ # parent directory, then list all files that are under it, and return those
136
+ # match the partial path.
137
+ parent = os.fspath(Path(pattern).parent)
138
+ # In case the partial path matches directories, we recursively list all
139
+ # files.
140
+ files = list_all_files([parent])
141
+ return [f for f in files if f.startswith(pattern)]
142
+
143
+
144
+ def check_hermes_exe(
145
+ binary_dir: PathT, shermes: bool, bytecode_compat_check: bool
146
+ ) -> None:
147
+ """Check that needed Hermes executables exist, terminate the execution if not."""
148
+
149
+ import shutil
150
+
151
+ exe = shutil.which(os.path.join(binary_dir, "hermes"))
152
+ if shermes:
153
+ exe = shutil.which(os.path.join(binary_dir, "shermes"))
154
+
155
+ if not exe:
156
+ print(f"Error: {exe} not found.")
157
+ sys.exit(1)
158
+
159
+ if bytecode_compat_check:
160
+ exe = shutil.which(os.path.join(binary_dir, "b_hermes"))
161
+ if not exe:
162
+ print(f"Error: {exe} not found.")
163
+ sys.exit(1)
164
+
165
+
166
+ HERMES_FEATURES_MATCHER = re.compile(
167
+ r"\s*Features:\s*\n(.*\n)", re.MULTILINE | re.DOTALL
168
+ )
169
+ """Match the "Features" output of `hermes --version`."""
170
+
171
+
172
+ CONFIGURABLE_HERMES_FEATURES = {
173
+ "Unicode RegExp Property Escapes": "regexp-unicode-property-escapes",
174
+ }
175
+ """Mapping of Hermes features to test262 features, for use in dynamic feature
176
+ skipping."""
177
+
178
+
179
+ @cache
180
+ def get_hermes_features(binary_dir: PathT) -> List[str]:
181
+ """
182
+ Run `hermes --version` and extract the features from the output.
183
+ """
184
+
185
+ import subprocess
186
+
187
+ exe = os.path.join(binary_dir, "hermes")
188
+ try:
189
+ output = subprocess.check_output([exe, "--version"], stderr=subprocess.STDOUT)
190
+ features = HERMES_FEATURES_MATCHER.search(output.decode("utf-8"))
191
+ if features is not None:
192
+ return [feature.strip() for feature in features.group(1).splitlines()]
193
+ else:
194
+ return []
195
+ except subprocess.CalledProcessError as e:
196
+ print(
197
+ "Failed to run hermes --version: " + e.output.decode("utf-8"),
198
+ file=sys.stderr,
199
+ )
200
+ return []
201
+
202
+
203
+ @cache
204
+ def get_hermes_supported_test262_features(binary_dir: PathT) -> List[str]:
205
+ """
206
+ Get hermes supported test262 feature from the feature list of the built
207
+ hermes binary.
208
+ """
209
+ hermes_features = get_hermes_features(binary_dir)
210
+ return [
211
+ CONFIGURABLE_HERMES_FEATURES[hermes_feature]
212
+ for hermes_feature in hermes_features
213
+ if hermes_feature in CONFIGURABLE_HERMES_FEATURES
214
+ ]
@@ -0,0 +1,22 @@
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 [ $(which clang-tidy) ]; then
8
+ FILES=`find lib include tools unittests -name \*.h -print -o -name \*.cpp -print`
9
+
10
+ FARRAY=( $FILES ) # count the number of files to process
11
+ echo Inspecting ${#FARRAY[@]} files
12
+
13
+ for F in $FILES; do
14
+ clang-tidy $F -p ../build/ $1
15
+ echo -n .
16
+ done
17
+ echo
18
+ echo "Done"
19
+ exit
20
+ fi
21
+
22
+ echo "ERROR: can't find clang-tidy in your path."
@@ -0,0 +1,53 @@
1
+ #!/bin/sh
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
+ # README:
8
+ # To update the fbcode copy of Hermes, follow these steps:
9
+ # 1) cd to fbsource/xplat/hermes/utils
10
+ # 2) Run the current script: ./update-fbcode-hermes.sh
11
+ # This should leave you with files copied over, and new files as hg adds.
12
+ # 3) Until we update the xplat hermes to the newer LLVM used in fbcode,
13
+ # if any of the files we had to modify for the LLVM version (only
14
+ # 4, I believe) changed, we have to re-apply those changes.
15
+ # Those changes are in D10353003. So attempt to build, in fbsource/fbcode:
16
+ # buick build xplat/hermes/...
17
+ # For any errors, check whether the file is one of those modified
18
+ # in the given diff, and reapply the changes.
19
+ # You may also get errors if BUCK files changed; if so, you need to
20
+ # make equivalent changes in the corresponding TARGETS file.
21
+ #
22
+ # Not completely automatic, but not too bad.
23
+
24
+ case $(pwd) in
25
+ *fbsource/xplat/hermes/utils) ;;
26
+ *) echo Must run from fbsource/xplat/hermes/utils; exit 1;;
27
+ esac
28
+
29
+ # Move to fbsource
30
+ cd ../../.. || exit
31
+
32
+ # copy hermes to fbcode
33
+ echo Copying hermes.
34
+ /bin/cp -r xplat/hermes fbcode/xplat
35
+ # Now remove some directories with large files we don't need in fbcode.
36
+ echo Removing unnecessary hermes subdirs.
37
+ /bin/rm -rf fbcode/xplat/hermes/facebook/js_bundles
38
+ /bin/rm -rf fbcode/xplat/hermes/facebook/sandcastle
39
+
40
+ # copy jsi to fbcode
41
+ echo Copying jsi.
42
+ /bin/cp -r xplat/jsi fbcode/xplat
43
+
44
+ # Now do hg adds for any new files:
45
+
46
+ echo Doing hg adds.
47
+ hg status > /tmp/hg-status.out
48
+ grep "^\\? " /tmp/hg-status.out > /tmp/hg-status2.out
49
+ sed -e "s/^\\?/hg add/" /tmp/hg-status2.out > /tmp/hg-status3.out
50
+ # This executes the shell commands in /tmp/hg-status3.out. Like "source".
51
+ . /tmp/hg-status3.out
52
+
53
+ /bin/rm /tmp/hg-status.out /tmp/hg-status2.out /tmp/hg-status3.out
@@ -0,0 +1,193 @@
1
+ #!/usr/bin/env python
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
+ from __future__ import print_function
8
+
9
+ import os
10
+ import re
11
+ import sys
12
+
13
+
14
+ def eprint(*args, **kwargs):
15
+ print(*args, file=sys.stderr, **kwargs)
16
+
17
+
18
+ baseName = ""
19
+ headingLines = []
20
+ sourceLines = {}
21
+ lastSourceLine = 0
22
+ errors = []
23
+
24
+
25
+ def parseErrorLine(line):
26
+ m = re.match(r".*:(\d+):(\d+): (.*)", line)
27
+ if not m:
28
+ return None
29
+ return (int(m.group(1)), int(m.group(2)), m.group(3))
30
+
31
+
32
+ def parseSource(lines):
33
+ global lastSourceLine
34
+ i = 0
35
+ # Collect the commented out lines at the beginning.
36
+ while i < len(lines):
37
+ if not re.match(r"^\s*//|^$|^\/\*|^ \*", lines[i]):
38
+ break
39
+ headingLines.append(lines[i])
40
+ i += 1
41
+ # Collect the source, exlcuding // CHECK: and similar lines.
42
+ while i < len(lines):
43
+ if not re.match(r"^\s*//\s*(\S+):", lines[i]):
44
+ if lines[i].strip():
45
+ sourceLines[i + 1] = lines[i]
46
+ lastSourceLine = i + 1
47
+ i += 1
48
+
49
+
50
+ def parseErrors(lines):
51
+ i = 0
52
+ lastError = None
53
+ while i < len(lines):
54
+ errDesc = parseErrorLine(lines[i])
55
+ if errDesc:
56
+ if lastError:
57
+ errors.append(lastError)
58
+ lastError = (errDesc, [])
59
+ else:
60
+ if lastError:
61
+ lastError[1].append(lines[i])
62
+ else:
63
+ eprint("ignored error line", lines[i])
64
+ i += 1
65
+ if lastError:
66
+ errors.append(lastError)
67
+ list.sort(errors, key=lambda error: error[0][0])
68
+
69
+
70
+ def generateOutput(f):
71
+ lineNo = 0
72
+ for hl in headingLines:
73
+ print(hl, file=f)
74
+ lineNo += 1
75
+
76
+ prevErrorLine = lineNo
77
+
78
+ errorIndex = 0
79
+ while errorIndex < len(errors):
80
+ origErrorLine = errors[errorIndex][0][0]
81
+
82
+ # Detect all errors on the same line
83
+ nextErrorIndex = errorIndex + 1
84
+ while (
85
+ nextErrorIndex < len(errors)
86
+ and errors[nextErrorIndex][0][0] == origErrorLine
87
+ ):
88
+ nextErrorIndex += 1
89
+
90
+ # Output all source up to and including the line of the error, but skip empty lines
91
+ # in the beginning and end.
92
+
93
+ # Skip empty lines in the beginning.
94
+ fromLine = prevErrorLine + 1
95
+ prevErrorLine = origErrorLine
96
+ while fromLine < origErrorLine and not sourceLines.get(fromLine, ""):
97
+ fromLine += 1
98
+ # Skip empty lines at the end.
99
+ toLine = origErrorLine
100
+ while toLine > fromLine and not sourceLines.get(toLine, ""):
101
+ toLine -= 1
102
+
103
+ # Output a separator line, but not the first time.
104
+ if errorIndex:
105
+ print("", file=f)
106
+ lineNo += 1
107
+
108
+ # Output the source lines.
109
+ for i in range(fromLine, toLine + 1):
110
+ print(sourceLines.get(i, ""), file=f)
111
+ lineNo += 1
112
+ newErrorLine = lineNo
113
+
114
+ while errorIndex < nextErrorIndex:
115
+ error = errors[errorIndex]
116
+ errorIndex += 1
117
+ print(
118
+ "//CHECK: {{.*}}%s:%d:%d: %s"
119
+ % (baseName, newErrorLine, error[0][1], error[0][2]),
120
+ file=f,
121
+ )
122
+ lineNo += 1
123
+ for eline in error[1]:
124
+ print("//CHECK-NEXT:", eline, file=f)
125
+ lineNo += 1
126
+
127
+ # Output the rest of the source.
128
+ fromLine = prevErrorLine + 1
129
+ while fromLine < lastSourceLine and not sourceLines.get(fromLine, ""):
130
+ fromLine += 1
131
+ if fromLine <= lastSourceLine:
132
+ print("", file=f)
133
+ lineNo += 1
134
+ for i in range(fromLine, lastSourceLine + 1):
135
+ print(sourceLines.get(i, ""), file=f)
136
+ lineNo += 1
137
+
138
+
139
+ def printHelp():
140
+ print("syntax: updateErrorTest.py [options] input-file")
141
+ print(" -h help")
142
+ print(" -i replace the input file inplace")
143
+
144
+
145
+ def main(argv):
146
+ argI = 1
147
+
148
+ inputName = ""
149
+ inplace = False
150
+ while argI < len(argv):
151
+ if argv[argI] == "-h":
152
+ printHelp()
153
+ sys.exit()
154
+ elif argv[argI] == "-i":
155
+ inplace = True
156
+ elif argv[argI].startswith("-"):
157
+ eprint("Invalid option '%s'. -h for help." % argv[argI])
158
+ sys.exit(1)
159
+ else:
160
+ if inputName:
161
+ eprint("More than one input-file specified")
162
+ sys.exit(1)
163
+ inputName = argv[argI]
164
+ argI += 1
165
+
166
+ if not inputName:
167
+ eprint("Input-file not specified. -h for help.")
168
+ sys.exit(1)
169
+
170
+ global baseName
171
+ baseName = os.path.basename(inputName)
172
+
173
+ # Read the source file
174
+ with open(inputName, "r") as f:
175
+ source = [x.strip("\n") for x in f.readlines()]
176
+
177
+ # Read the error output
178
+ errorOutput = [x.strip("\n") for x in sys.stdin.readlines()]
179
+
180
+ parseSource(source)
181
+ parseErrors(errorOutput)
182
+
183
+ eprint("Scanned %d source lines and %d errors" % (len(sourceLines), len(errors)))
184
+
185
+ if inplace:
186
+ with open(inputName, "w") as f:
187
+ generateOutput(f)
188
+ else:
189
+ generateOutput(sys.stdout)
190
+
191
+
192
+ if __name__ == "__main__":
193
+ main(sys.argv)
@@ -0,0 +1,65 @@
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
+ set -e # Exit immediately if a command exits with a non-zero status
8
+ set -u # Treat unset variables as an error and exit immediately
9
+
10
+ # Check if exactly one argument is provided
11
+ if [[ $# -ne 3 ]]; then
12
+ echo "Usage: $0 <path-to-host-build> <path-to-wasm-build> <file>"
13
+ exit 1
14
+ fi
15
+
16
+ # Check if HermesSourcePath is set
17
+ if [[ -z "${HermesSourcePath+x}" ]]; then
18
+ echo "Error: HermesSourcePath is not set."
19
+ exit 1
20
+ fi
21
+
22
+ # Check if the host build directory is valid
23
+ if [[ ! -x $1/bin/shermes ]]; then
24
+ echo "Error: '$1' does not contain a bin/shermes executable."
25
+ exit 1
26
+ fi
27
+ shermes="$1/bin/shermes"
28
+
29
+ # Check if the wasm build directory is valid
30
+ if [[ ! -f $2/bin/hermes.js ]]; then
31
+ echo "Error: '$2' does not contain bin/hermes.js"
32
+ exit 1
33
+ fi
34
+ wasm_build="$2"
35
+
36
+ # Check if the file exists
37
+ if [[ ! -f $3 ]]; then
38
+ echo "Error: File '$3' does not exist."
39
+ exit 1
40
+ fi
41
+ # Extract the filename without path and extension
42
+ input="$3"
43
+ file_name=$(basename "$input") # Remove path
44
+ file_name="${file_name%.*}" # Remove extension
45
+
46
+ echo "Using shermes to compile $input... to ${file_name}.c"
47
+ "$shermes" -Xenable-tdz -emit-c "$input"
48
+
49
+ echo "Using emcc to compile ${file_name}.c to ${file_name}.o"
50
+ emcc "${file_name}.c" -c \
51
+ -O3 \
52
+ -DNDEBUG \
53
+ -fno-strict-aliasing -fno-strict-overflow \
54
+ -I${wasm_build}/lib/config \
55
+ -I${HermesSourcePath}/include
56
+
57
+ echo "Using emcc to link ${file_name}.o to ${file_name}-wasm.js/.wasm"
58
+ emcc -O3 ${file_name}.o -o ${file_name}-wasm.js \
59
+ -L${wasm_build}/lib \
60
+ -L${wasm_build}/jsi \
61
+ -L${wasm_build}/tools/shermes \
62
+ -lshermes_console_a -lhermesvm_a -ljsi \
63
+ -sALLOW_MEMORY_GROWTH=1 -sSTACK_SIZE=256KB
64
+
65
+ ls -lh ${file_name}-wasm.*
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-nitro-hermes",
3
- "version": "0.0.1-alpha.8",
3
+ "version": "0.0.1-alpha.9",
4
4
  "publishConfig": {
5
5
  "tag": "latest",
6
6
  "access": "public"