From 1141e2b56a023feb5ddb4f2c961095ac95893141 Mon Sep 17 00:00:00 2001 From: Idan Horowitz Date: Sat, 3 Dec 2022 18:06:54 +0200 Subject: [PATCH] test262-runner: Add option to enable bytecode optimizations --- Tests/LibJS/test262-runner.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Tests/LibJS/test262-runner.cpp b/Tests/LibJS/test262-runner.cpp index 4f96cdad48..1faa4f29ea 100644 --- a/Tests/LibJS/test262-runner.cpp +++ b/Tests/LibJS/test262-runner.cpp @@ -33,6 +33,7 @@ static String s_current_test = ""; static bool s_use_bytecode = false; +static bool s_enable_bytecode_optimizations = false; static bool s_parse_only = false; static String s_harness_file_directory; static bool s_automatic_harness_detection_mode = false; @@ -95,7 +96,8 @@ static Result run_program(InterpreterT& interpreter, ScriptOrMo result = JS::throw_completion(JS::InternalError::create(interpreter.realm(), String::formatted("TODO({})", unit_result.error().to_string()))); } else { auto unit = unit_result.release_value(); - auto& passes = JS::Bytecode::Interpreter::optimization_pipeline(); + auto optimization_level = s_enable_bytecode_optimizations ? JS::Bytecode::Interpreter::OptimizationLevel::Optimize : JS::Bytecode::Interpreter::OptimizationLevel::Default; + auto& passes = JS::Bytecode::Interpreter::optimization_pipeline(optimization_level); passes.perform(*unit); result = interpreter.run(*unit); } @@ -586,6 +588,7 @@ int main(int argc, char** argv) args_parser.set_general_help("LibJS test262 runner for streaming tests"); args_parser.add_option(s_harness_file_directory, "Directory containing the harness files", "harness-location", 'l', "harness-files"); args_parser.add_option(s_use_bytecode, "Use the bytecode interpreter", "use-bytecode", 'b'); + args_parser.add_option(s_enable_bytecode_optimizations, "Enable the bytecode optimization passes", "enable-bytecode-optimizations", 'e'); args_parser.add_option(s_parse_only, "Only parse the files", "parse-only", 'p'); args_parser.add_option(timeout, "Seconds before test should timeout", "timeout", 't', "seconds"); args_parser.add_option(enable_debug_printing, "Enable debug printing", "debug", 'd');