Skip to content

Commit 0bb4f5e

Browse files
IdanHolinusg
authored andcommitted
Support running with bytecode optimizations enabled
1 parent 09ed60f commit 0bb4f5e

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

main.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ def run_streaming_script(
7575
libjs_test262_runner: Path,
7676
test262_root: Path,
7777
use_bytecode: bool,
78+
enable_bytecode_optimizations: bool,
7879
extra_runner_options: list[str],
7980
timeout: int,
8081
memory_limit: int,
@@ -88,6 +89,7 @@ def limit_memory():
8889
command = [
8990
str(libjs_test262_runner),
9091
*(["-b"] if use_bytecode else []),
92+
*(["-e"] if enable_bytecode_optimizations else []),
9193
*extra_runner_options,
9294
"--harness-location",
9395
str((test262_root / "harness").resolve()),
@@ -112,6 +114,7 @@ def run_tests(
112114
test262_root: Path,
113115
test_file_paths: list[Path],
114116
use_bytecode: bool,
117+
enable_bytecode_optimizations: bool,
115118
extra_runner_options: list[str],
116119
timeout: int,
117120
memory_limit: int,
@@ -147,6 +150,7 @@ def add_result(
147150
libjs_test262_runner,
148151
test262_root,
149152
use_bytecode,
153+
enable_bytecode_optimizations,
150154
extra_runner_options,
151155
timeout,
152156
memory_limit,
@@ -258,6 +262,7 @@ def __init__(
258262
silent: bool = False,
259263
verbose: bool = False,
260264
use_bytecode: bool = False,
265+
enable_bytecode_optimizations: bool = False,
261266
track_per_file: bool = False,
262267
fail_only: bool = False,
263268
extra_runner_options: list[str] | None = None,
@@ -272,6 +277,7 @@ def __init__(
272277
self.silent = silent
273278
self.verbose = verbose
274279
self.use_bytecode = use_bytecode
280+
self.enable_bytecode_optimizations = enable_bytecode_optimizations
275281
self.track_per_file = track_per_file
276282
self.fail_only = fail_only
277283
self.files: list[Path] = []
@@ -400,6 +406,7 @@ def process_list(self, files: list[Path]) -> list[TestRun]:
400406
self.test262_root,
401407
files,
402408
use_bytecode=self.use_bytecode,
409+
enable_bytecode_optimizations=self.enable_bytecode_optimizations,
403410
extra_runner_options=self.extra_runner_options,
404411
timeout=self.timeout,
405412
memory_limit=self.memory_limit,
@@ -518,6 +525,12 @@ def main() -> None:
518525
action="store_true",
519526
help="Use the bytecode interpreter to run the tests",
520527
)
528+
parser.add_argument(
529+
"-e",
530+
"--enable-bytecode-optimizations",
531+
action="store_true",
532+
help="Enable the bytecode optimization passes",
533+
)
521534
parser.add_argument(
522535
"-t",
523536
"--test262-root",
@@ -619,6 +632,7 @@ def main() -> None:
619632
args.silent,
620633
args.verbose,
621634
args.use_bytecode,
635+
args.enable_bytecode_optimizations,
622636
args.per_file is not None,
623637
args.fail_only,
624638
extra_runner_options,

run_all_and_update_results.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,13 @@ def main() -> None:
8888
metavar="PATH",
8989
help="output the per-file result of the bytecode run to this file",
9090
)
91+
parser.add_argument(
92+
"--per-file-bytecode-optimized-output",
93+
default=None,
94+
type=str,
95+
metavar="PATH",
96+
help="output the per-file result of the optimized bytecode run to this file",
97+
)
9198
args = parser.parse_args()
9299

93100
libjs_test262 = Path(__file__).parent
@@ -177,6 +184,25 @@ def main() -> None:
177184
)
178185
libjs_test262_bc_results = libjs_test262_bc_output["results"]["test"]["results"]
179186

187+
print("Running test262 with the optimized bytecode interpreter...")
188+
libjs_test262_bc_opt_output = json.loads(
189+
# This is not the way either, but I can't be bothered to fix the one above and _then_ copy it. :^)
190+
run_command(
191+
f"python3 {libjs_test262_main_py} "
192+
f"--libjs-test262-runner {libjs_test262_runner} "
193+
f"--test262 {test262} "
194+
"--silent --summary --json --use-bytecode --enable-bytecode-optimizations "
195+
+ (
196+
""
197+
if args.per_file_bytecode_optimized_output is None
198+
else f"--per-file {args.per_file_bytecode_optimized_output} "
199+
)
200+
)
201+
)
202+
libjs_test262_bc_opt_results = libjs_test262_bc_opt_output["results"]["test"][
203+
"results"
204+
]
205+
180206
result = {
181207
"commit_timestamp": commit_timestamp,
182208
"run_timestamp": run_timestamp,
@@ -217,6 +243,23 @@ def main() -> None:
217243
"todo_error": libjs_test262_bc_results["TODO_ERROR"],
218244
},
219245
},
246+
"test262-bytecode-optimized": {
247+
"duration": libjs_test262_bc_opt_output["duration"],
248+
"results": {
249+
"total": libjs_test262_bc_opt_output["results"]["test"]["count"],
250+
"passed": libjs_test262_bc_opt_results["PASSED"],
251+
"failed": libjs_test262_bc_opt_results["FAILED"],
252+
"skipped": libjs_test262_bc_opt_results["SKIPPED"],
253+
"metadata_error": libjs_test262_bc_opt_results["METADATA_ERROR"],
254+
"harness_error": libjs_test262_bc_opt_results["HARNESS_ERROR"],
255+
"timeout_error": libjs_test262_bc_opt_results["TIMEOUT_ERROR"],
256+
"process_error": libjs_test262_bc_opt_results["PROCESS_ERROR"],
257+
"runner_exception": libjs_test262_bc_opt_results[
258+
"RUNNER_EXCEPTION"
259+
],
260+
"todo_error": libjs_test262_bc_opt_results["TODO_ERROR"],
261+
},
262+
},
220263
"test262-parser-tests": {
221264
"duration": test_js_output["duration"],
222265
"results": {

0 commit comments

Comments
 (0)