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,365 @@
|
|
|
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
|
+
import os
|
|
7
|
+
from dataclasses import dataclass, field
|
|
8
|
+
from enum import auto, Flag
|
|
9
|
+
from typing import List
|
|
10
|
+
|
|
11
|
+
from .external.parse_test262 import parseTestRecord
|
|
12
|
+
from .typing_defs import OptExpectedFailure, PathT
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class StrictMode(Flag):
|
|
16
|
+
NO_STRICT = auto()
|
|
17
|
+
STRICT = auto()
|
|
18
|
+
ALL = NO_STRICT | STRICT
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@dataclass
|
|
22
|
+
class TestCase:
|
|
23
|
+
"""
|
|
24
|
+
Source code and all metadata provided in a test262 test case.
|
|
25
|
+
For details about these metadata, see
|
|
26
|
+
https://chromium.googlesource.com/external/github.com/tc39/test262/+/HEAD/CONTRIBUTING.md
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
source: str
|
|
30
|
+
"""Preprocessed source code."""
|
|
31
|
+
includes: List[str] = field(default_factory=list)
|
|
32
|
+
"""
|
|
33
|
+
A list of files in the test262/harness/ directory that needs to be
|
|
34
|
+
included to run the test. The content of these included files has been
|
|
35
|
+
prepended to the source field.
|
|
36
|
+
"""
|
|
37
|
+
strict_mode: StrictMode = StrictMode.NO_STRICT
|
|
38
|
+
"""Run the test in strict or/and non-strict mode."""
|
|
39
|
+
flags: List[str] = field(default_factory=list)
|
|
40
|
+
"""
|
|
41
|
+
Flags specified in the test262 frontmatter, possible values are:
|
|
42
|
+
onlyStrict, noStrict, module, raw, async, generated, CanBlockIsFalse,
|
|
43
|
+
CanBlockIsTrue, non-deterministic.
|
|
44
|
+
"""
|
|
45
|
+
expected_failure: OptExpectedFailure = None
|
|
46
|
+
"""
|
|
47
|
+
The "negative" field in the test262 frontmatter. This means the test is
|
|
48
|
+
expected to throw an error of given type. The two fields are (if not None):
|
|
49
|
+
- phase, potential values are:
|
|
50
|
+
- parse, meaning that the test must throw before execution
|
|
51
|
+
- resolution, throw when performing ES2015 module resolution
|
|
52
|
+
- runtime, thrown when executed the bytecode
|
|
53
|
+
- type, the concrete error type
|
|
54
|
+
"""
|
|
55
|
+
features: List[str] = field(default_factory=list)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def generate_test262_source(content: str, suite: PathT, filepath: PathT) -> TestCase:
|
|
59
|
+
"""
|
|
60
|
+
Parse the give test262 test file and perform necessary preprocessing, e.g.,
|
|
61
|
+
inserting code from included files to the test.
|
|
62
|
+
"""
|
|
63
|
+
test = parseTestRecord(content, filepath)
|
|
64
|
+
|
|
65
|
+
flags = test.get("flags", [])
|
|
66
|
+
strict_mode = StrictMode.ALL
|
|
67
|
+
if "onlyStrict" in flags:
|
|
68
|
+
strict_mode = StrictMode.STRICT
|
|
69
|
+
elif "noStrict" in flags or "raw" in flags:
|
|
70
|
+
strict_mode = StrictMode.NO_STRICT
|
|
71
|
+
|
|
72
|
+
negative = test.get("negative", None)
|
|
73
|
+
|
|
74
|
+
includes = ["sta.js", "assert.js"]
|
|
75
|
+
if "async" in flags:
|
|
76
|
+
includes += ["doneprintHandle.js"]
|
|
77
|
+
includes += test.get("includes", [])
|
|
78
|
+
|
|
79
|
+
full_src = ""
|
|
80
|
+
if "raw" not in flags:
|
|
81
|
+
for include in includes:
|
|
82
|
+
include_path = os.path.join(suite, "harness", include)
|
|
83
|
+
with open(include_path, "rb") as f:
|
|
84
|
+
full_src += f.read().decode("utf-8") + "\n"
|
|
85
|
+
full_src += test["src"]
|
|
86
|
+
|
|
87
|
+
return TestCase(
|
|
88
|
+
source=full_src,
|
|
89
|
+
includes=includes,
|
|
90
|
+
strict_mode=strict_mode,
|
|
91
|
+
flags=flags,
|
|
92
|
+
expected_failure=negative,
|
|
93
|
+
features=test.get("features", []),
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def generate_mjsunit_source(content: str, suite: str) -> TestCase:
|
|
98
|
+
"""
|
|
99
|
+
Perform preprocessing on a given mjsunit test file.
|
|
100
|
+
"""
|
|
101
|
+
|
|
102
|
+
# The content of this string is prepended to the test files and is used to
|
|
103
|
+
# provide the basic test built-ins.
|
|
104
|
+
v8_harness = """
|
|
105
|
+
// v8 test harness:
|
|
106
|
+
function internal_arraysEqual(a, b) {
|
|
107
|
+
if (a === b) return true;
|
|
108
|
+
if (a.length != b.length) return false;
|
|
109
|
+
for (var i = 0; i < a.length; ++i) { if (a[i] !== b[i]) return false; }
|
|
110
|
+
return true;
|
|
111
|
+
}
|
|
112
|
+
function builtin_nop(x) { return x; }
|
|
113
|
+
function builtin_false() { return false; }
|
|
114
|
+
function builtin_true() { return true; }
|
|
115
|
+
|
|
116
|
+
var nopSentinel = {};
|
|
117
|
+
|
|
118
|
+
function v8pragma_HaveSameMap(obj1, obj2) {
|
|
119
|
+
// This function doesn't work for all tests, but works for many.
|
|
120
|
+
var keysAreSubset = function(lhs, rhs) {
|
|
121
|
+
for (var property in lhs) {
|
|
122
|
+
if (lhs[property] !== rhs[property]) {
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return true;
|
|
127
|
+
}
|
|
128
|
+
return keysAreSubset(obj1, obj2) && keysAreSubset(obj2, obj1);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function v8pragma_FunctionSetPrototype(f, p) {
|
|
132
|
+
// Set f.prototype.
|
|
133
|
+
f.prototype = p;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function v8pragma_ClassOf(obj) {
|
|
137
|
+
// Turn "[object ClassName]" into just "ClassName".
|
|
138
|
+
return Object.prototype.toString.call(obj).slice(8, -1);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function v8pragma_Call(f, thisVal) {
|
|
142
|
+
return f.apply(thisVal, Array.prototype.slice.call(arguments, 2));
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function v8pragma_StringCharFromCode(i) {
|
|
146
|
+
return String.fromCharCode(i);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function v8pragma_StringCharCodeAt(s, i) {
|
|
150
|
+
return s.charCodeAt(i);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// debug variable sometimes used in mjsunit.
|
|
154
|
+
// Implemented the same way JSC does.
|
|
155
|
+
var debug = function(s) {
|
|
156
|
+
alert('-->', s);
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
function v8pragma_StringMaxLength() {
|
|
160
|
+
return 256 * 1024 * 1024;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function v8pragma_TypeOf(val) {
|
|
164
|
+
return typeof val;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function v8pragma_ConstructConsString(a, b) {
|
|
168
|
+
return a;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// For 64-bit devices, v8 may do extra tests regarding optimization, but we can skip
|
|
172
|
+
function v8pragma_Is64Bit() {
|
|
173
|
+
return false;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function v8pragma_ConstructSlicedString(str, i) {
|
|
177
|
+
return str.slice(i);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function v8pragma_ConstructInternalizedString(a, b) {
|
|
181
|
+
return a + b;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function v8pragma_ToLength(val) {
|
|
185
|
+
return val.length;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function executeCode(code) {
|
|
189
|
+
if (typeof code === 'function') return code();
|
|
190
|
+
if (typeof code === 'string') return eval(code);
|
|
191
|
+
failWithMessage(
|
|
192
|
+
'Given code is neither function nor string, but ' + (typeof code) +
|
|
193
|
+
': <' + prettyPrinted(code) + '>');
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function v8_assertException(e, type_opt, cause_opt) {
|
|
197
|
+
if (type_opt !== undefined) {
|
|
198
|
+
assertEquals('function', typeof type_opt);
|
|
199
|
+
assertInstanceof(e, type_opt);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// Error messages may differ between V8 and Hermes, so ignore the assert on the message.
|
|
204
|
+
function v8_assertThrows(code, type_opt, cause_opt) {
|
|
205
|
+
if (arguments.length > 1 && type_opt === undefined) {
|
|
206
|
+
failWithMessage('invalid use of assertThrows, unknown type_opt given');
|
|
207
|
+
}
|
|
208
|
+
if (type_opt !== undefined && typeof type_opt !== 'function') {
|
|
209
|
+
failWithMessage(
|
|
210
|
+
'invalid use of assertThrows, maybe you want assertThrowsEquals');
|
|
211
|
+
}
|
|
212
|
+
try {
|
|
213
|
+
executeCode(code);
|
|
214
|
+
} catch (e) {
|
|
215
|
+
assertException(e, type_opt, undefined);
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
let msg = 'Did not throw exception';
|
|
219
|
+
if (type_opt !== undefined && type_opt.name !== undefined)
|
|
220
|
+
msg += ', expected ' + type_opt.name;
|
|
221
|
+
failWithMessage(msg);
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
// Note that this is not added in the pragma map to avoid overriding other variants
|
|
225
|
+
// of assertThrows, e.g. assertThrowsEquals
|
|
226
|
+
assertThrows = v8_assertThrows;
|
|
227
|
+
|
|
228
|
+
// The idea here is that some pragmas are meaningless for our JS interpreter,
|
|
229
|
+
// but we don't want to throw out the whole test case. In those cases, just
|
|
230
|
+
// throw out the assertions in those test cases resulting from checking the
|
|
231
|
+
// results of those pragmas.
|
|
232
|
+
function v8pragma_NopSentinel() {
|
|
233
|
+
return nopSentinel;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// Throw error on any unhandled Promise rejections.
|
|
237
|
+
HermesInternal.enablePromiseRejectionTracker({
|
|
238
|
+
allRejections: true,
|
|
239
|
+
onUnhandled: function(_, error) {
|
|
240
|
+
throw error;
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
"""
|
|
245
|
+
|
|
246
|
+
v8_pragmas = {
|
|
247
|
+
"%ClearFunctionTypeFeedback": "builtin_nop",
|
|
248
|
+
"%OptimizeFunctionOnNextCall": "builtin_nop",
|
|
249
|
+
"%DeoptimizeFunction": "builtin_nop",
|
|
250
|
+
"%DeoptimizeNow": "builtin_nop",
|
|
251
|
+
"%_DeoptimizeNow": "builtin_nop",
|
|
252
|
+
"%NeverOptimizeFunction": "builtin_nop",
|
|
253
|
+
"%OptimizeOsr": "builtin_nop",
|
|
254
|
+
"%BaselineFunctionOnNextCall": "builtin_nop",
|
|
255
|
+
"%SetForceInlineFlag": "builtin_nop",
|
|
256
|
+
"%OptimizeObjectForAddingMultipleProperties": "builtin_nop",
|
|
257
|
+
"%ToFastProperties": "builtin_nop",
|
|
258
|
+
"%NormalizeElements": "builtin_nop",
|
|
259
|
+
"%ArrayBufferNeuter": "HermesInternal.detachArrayBuffer",
|
|
260
|
+
# ArrayBufferDetach is the more modern version of ArrayBufferNeuter.
|
|
261
|
+
"%ArrayBufferDetach": "HermesInternal.detachArrayBuffer",
|
|
262
|
+
"%RunMicrotasks": "HermesInternal.drainJobs",
|
|
263
|
+
"%SetAllocationTimeout": "builtin_nop",
|
|
264
|
+
"%UnblockConcurrentRecompilation": "builtin_nop",
|
|
265
|
+
"%DebugPrint": "builtin_nop",
|
|
266
|
+
"%HaveSameMap": "v8pragma_HaveSameMap",
|
|
267
|
+
"%HasFastDoubleElements": "v8pragma_NopSentinel",
|
|
268
|
+
"%HasFastSmiElements": "v8pragma_NopSentinel",
|
|
269
|
+
"%HasFastObjectElements": "v8pragma_NopSentinel",
|
|
270
|
+
"%HasFastHoleyElements": "v8pragma_NopSentinel",
|
|
271
|
+
"%HasFastProperties": "v8pragma_NopSentinel",
|
|
272
|
+
"%IsAsmWasmCode": "v8pragma_NopSentinel",
|
|
273
|
+
"%IsNotAsmWasmCode": "v8pragma_NopSentinel",
|
|
274
|
+
"%NotifyContextDisposed": "v8pragma_NopSentinel",
|
|
275
|
+
"%FunctionSetPrototype": "v8pragma_FunctionSetPrototype",
|
|
276
|
+
"%_ClassOf": "v8pragma_ClassOf",
|
|
277
|
+
"%_Call": "v8pragma_Call",
|
|
278
|
+
"%RunningInSimulator": "builtin_false",
|
|
279
|
+
"%IsConcurrentRecompilationSupported": "builtin_false",
|
|
280
|
+
"%_StringCharFromCode": "v8pragma_StringCharFromCode",
|
|
281
|
+
"%_StringCharCodeAt": "v8pragma_StringCharCodeAt",
|
|
282
|
+
"%AbortJS": "throw new Error",
|
|
283
|
+
"%EnqueueMicrotask": "queueMicrotask",
|
|
284
|
+
"%PerformMicrotaskCheckpoint": "HermesInternal.drainJobs",
|
|
285
|
+
"%PrepareFunctionForOptimization": "builtin_nop",
|
|
286
|
+
"%OptimizeMaglevOnNextCall": "builtin_nop",
|
|
287
|
+
"%IsDictPropertyConstTrackingEnabled": "v8pragma_NopSentinel",
|
|
288
|
+
"%HasSmiElements": "v8pragma_NopSentinel",
|
|
289
|
+
"%GetOptimizationStatus": "v8pragma_NopSentinel",
|
|
290
|
+
"%StringMaxLength": "v8pragma_StringMaxLength",
|
|
291
|
+
"%EnsureFeedbackVectorForFunction": "builtin_nop",
|
|
292
|
+
"%HeapObjectVerify": "builtin_nop",
|
|
293
|
+
"%ClearFunctionFeedback": "builtin_nop",
|
|
294
|
+
"%TurbofanStaticAssert": "builtin_nop",
|
|
295
|
+
"%DisableOptimizationFinalization": "builtin_nop",
|
|
296
|
+
"%FinalizeOptimization": "builtin_nop",
|
|
297
|
+
"%SimulateNewspaceFull": "builtin_nop",
|
|
298
|
+
"%BaselineOsr": "builtin_nop",
|
|
299
|
+
"%ForceFlush": "builtin_nop",
|
|
300
|
+
"%CompleteInobjectSlackTracking": "builtin_nop",
|
|
301
|
+
"%DisassembleFunction": "builtin_nop",
|
|
302
|
+
"%InternalizeString": "builtin_nop",
|
|
303
|
+
"%SetForceSlowPath": "builtin_nop",
|
|
304
|
+
"%RegexpIsUnmodified": "builtin_nop",
|
|
305
|
+
"%NewRegExpWithBacktrackLimit": "builtin_nop",
|
|
306
|
+
"%PretenureAllocationSite": "builtin_nop",
|
|
307
|
+
"%WaitForBackgroundOptimization": "builtin_nop",
|
|
308
|
+
"%Typeof": "v8pragma_TypeOf",
|
|
309
|
+
"%CompileBaseline": "builtin_nop",
|
|
310
|
+
"%ConstructConsString": "v8pragma_ConstructConsString",
|
|
311
|
+
"%Is64Bit": "builtin_false",
|
|
312
|
+
"%ToLength": "v8pragma_ToLength",
|
|
313
|
+
"%IsUndefinedDoubleEnabled": "builtin_false",
|
|
314
|
+
"%Call": "v8pragma_Call",
|
|
315
|
+
"%ConstructThinString": "v8pragma_ConstructConsString",
|
|
316
|
+
"%ConstructSlicedString": "v8pragma_ConstructSlicedString",
|
|
317
|
+
"%SystemBreak": "builtin_nop",
|
|
318
|
+
"%CollectGarbage": "builtin_nop",
|
|
319
|
+
"assertException": "v8_assertException",
|
|
320
|
+
"assertOptimized": "builtin_nop",
|
|
321
|
+
"assertUnoptimized": "builtin_nop",
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
for pragma, replacement in v8_pragmas.items():
|
|
325
|
+
content = content.replace(pragma, replacement)
|
|
326
|
+
|
|
327
|
+
mjsunit_path = os.path.join(suite, "mjsunit.js")
|
|
328
|
+
full_src = ""
|
|
329
|
+
with open(mjsunit_path, "rb") as f:
|
|
330
|
+
full_src += f.read().decode("utf-8") + "\n"
|
|
331
|
+
full_src += v8_harness
|
|
332
|
+
full_src += content
|
|
333
|
+
return TestCase(source=full_src, strict_mode=StrictMode.NO_STRICT)
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
def generate_cves_source(content: str, test_name: str) -> TestCase:
|
|
337
|
+
"""
|
|
338
|
+
Read potential metadata in CVEs tests (currently only negative field).
|
|
339
|
+
"""
|
|
340
|
+
|
|
341
|
+
# Unlike test262, we don't want to print warnings of missing
|
|
342
|
+
# header and frontmatter since most tests under CVEs do not have them.
|
|
343
|
+
test = parseTestRecord(content, test_name, False)
|
|
344
|
+
# A few CVEs tests use the same style metadata as test262
|
|
345
|
+
negative = test.get("negative", None)
|
|
346
|
+
return TestCase(
|
|
347
|
+
source=test["src"], strict_mode=StrictMode.NO_STRICT, expected_failure=negative
|
|
348
|
+
)
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
def generate_source(content: str, suite: str, test_name: str) -> TestCase:
|
|
352
|
+
"""
|
|
353
|
+
Preprocess the test code for different testsuites, return the preprocessed
|
|
354
|
+
source and metadata for it (e.g., strict mode, flags).
|
|
355
|
+
"""
|
|
356
|
+
|
|
357
|
+
if "test262" in suite:
|
|
358
|
+
return generate_test262_source(content, suite, test_name)
|
|
359
|
+
if "mjsunit" in suite:
|
|
360
|
+
return generate_mjsunit_source(content, suite)
|
|
361
|
+
if "CVEs" in suite:
|
|
362
|
+
return generate_cves_source(content, test_name)
|
|
363
|
+
|
|
364
|
+
# For all other suites, return the exact source instead.
|
|
365
|
+
return TestCase(content, strict_mode=StrictMode.NO_STRICT)
|