mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-22 17:31:58 -05:00
test262-runner+js: Respect the bytecode optimizations enabled flag
This commit is contained in:
parent
aa0ed4ab4e
commit
e012565898
4 changed files with 15 additions and 14 deletions
|
@ -32,7 +32,6 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static DeprecatedString s_current_test = "";
|
static DeprecatedString s_current_test = "";
|
||||||
static bool s_enable_bytecode_optimizations = false;
|
|
||||||
static bool s_parse_only = false;
|
static bool s_parse_only = false;
|
||||||
static DeprecatedString s_harness_file_directory;
|
static DeprecatedString s_harness_file_directory;
|
||||||
static bool s_automatic_harness_detection_mode = false;
|
static bool s_automatic_harness_detection_mode = false;
|
||||||
|
@ -565,12 +564,13 @@ int main(int argc, char** argv)
|
||||||
bool enable_debug_printing = false;
|
bool enable_debug_printing = false;
|
||||||
bool disable_core_dumping = false;
|
bool disable_core_dumping = false;
|
||||||
bool use_bytecode = false;
|
bool use_bytecode = false;
|
||||||
|
bool enable_bytecode_optimizations = false;
|
||||||
|
|
||||||
Core::ArgsParser args_parser;
|
Core::ArgsParser args_parser;
|
||||||
args_parser.set_general_help("LibJS test262 runner for streaming tests");
|
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_harness_file_directory, "Directory containing the harness files", "harness-location", 'l', "harness-files");
|
||||||
args_parser.add_option(use_bytecode, "Use the bytecode interpreter", "use-bytecode", 'b');
|
args_parser.add_option(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(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(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(timeout, "Seconds before test should timeout", "timeout", 't', "seconds");
|
||||||
args_parser.add_option(enable_debug_printing, "Enable debug printing", "debug", 'd');
|
args_parser.add_option(enable_debug_printing, "Enable debug printing", "debug", 'd');
|
||||||
|
@ -578,6 +578,7 @@ int main(int argc, char** argv)
|
||||||
args_parser.parse(arguments);
|
args_parser.parse(arguments);
|
||||||
|
|
||||||
JS::Bytecode::Interpreter::set_enabled(use_bytecode);
|
JS::Bytecode::Interpreter::set_enabled(use_bytecode);
|
||||||
|
JS::Bytecode::Interpreter::set_optimizations_enabled(enable_bytecode_optimizations);
|
||||||
|
|
||||||
#if !defined(AK_OS_MACOS) && !defined(AK_OS_EMSCRIPTEN)
|
#if !defined(AK_OS_MACOS) && !defined(AK_OS_EMSCRIPTEN)
|
||||||
if (disable_core_dumping && prctl(PR_SET_DUMPABLE, 0, 0) < 0) {
|
if (disable_core_dumping && prctl(PR_SET_DUMPABLE, 0, 0) < 0) {
|
||||||
|
|
|
@ -32,6 +32,13 @@ void Interpreter::set_enabled(bool enabled)
|
||||||
s_bytecode_interpreter_enabled = enabled;
|
s_bytecode_interpreter_enabled = enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool s_optimizations_enabled = false;
|
||||||
|
|
||||||
|
void Interpreter::set_optimizations_enabled(bool enabled)
|
||||||
|
{
|
||||||
|
s_optimizations_enabled = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
bool g_dump_bytecode = false;
|
bool g_dump_bytecode = false;
|
||||||
|
|
||||||
Interpreter::Interpreter(VM& vm)
|
Interpreter::Interpreter(VM& vm)
|
||||||
|
@ -104,7 +111,7 @@ ThrowCompletionOr<Value> Interpreter::run(Script& script_record, JS::GCPtr<Envir
|
||||||
} else {
|
} else {
|
||||||
auto executable = executable_result.release_value();
|
auto executable = executable_result.release_value();
|
||||||
|
|
||||||
if (m_optimizations_enabled) {
|
if (s_optimizations_enabled) {
|
||||||
auto& passes = optimization_pipeline();
|
auto& passes = optimization_pipeline();
|
||||||
passes.perform(*executable);
|
passes.perform(*executable);
|
||||||
}
|
}
|
||||||
|
@ -173,11 +180,6 @@ ThrowCompletionOr<Value> Interpreter::run(SourceTextModule& module)
|
||||||
return js_undefined();
|
return js_undefined();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Interpreter::set_optimizations_enabled(bool enabled)
|
|
||||||
{
|
|
||||||
m_optimizations_enabled = enabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
Interpreter::ValueAndFrame Interpreter::run_and_return_frame(Realm& realm, Executable const& executable, BasicBlock const* entry_point, RegisterWindow* in_frame)
|
Interpreter::ValueAndFrame Interpreter::run_and_return_frame(Realm& realm, Executable const& executable, BasicBlock const* entry_point, RegisterWindow* in_frame)
|
||||||
{
|
{
|
||||||
dbgln_if(JS_BYTECODE_DEBUG, "Bytecode::Interpreter will run unit {:p}", &executable);
|
dbgln_if(JS_BYTECODE_DEBUG, "Bytecode::Interpreter will run unit {:p}", &executable);
|
||||||
|
|
|
@ -31,6 +31,7 @@ class Interpreter {
|
||||||
public:
|
public:
|
||||||
[[nodiscard]] static bool enabled();
|
[[nodiscard]] static bool enabled();
|
||||||
static void set_enabled(bool);
|
static void set_enabled(bool);
|
||||||
|
static void set_optimizations_enabled(bool);
|
||||||
|
|
||||||
explicit Interpreter(VM&);
|
explicit Interpreter(VM&);
|
||||||
~Interpreter();
|
~Interpreter();
|
||||||
|
@ -38,8 +39,6 @@ public:
|
||||||
Realm& realm();
|
Realm& realm();
|
||||||
VM& vm() { return m_vm; }
|
VM& vm() { return m_vm; }
|
||||||
|
|
||||||
void set_optimizations_enabled(bool);
|
|
||||||
|
|
||||||
ThrowCompletionOr<Value> run(Script&, JS::GCPtr<Environment> lexical_environment_override = nullptr);
|
ThrowCompletionOr<Value> run(Script&, JS::GCPtr<Environment> lexical_environment_override = nullptr);
|
||||||
ThrowCompletionOr<Value> run(SourceTextModule&);
|
ThrowCompletionOr<Value> run(SourceTextModule&);
|
||||||
|
|
||||||
|
@ -123,7 +122,6 @@ private:
|
||||||
OwnPtr<JS::Interpreter> m_ast_interpreter;
|
OwnPtr<JS::Interpreter> m_ast_interpreter;
|
||||||
BasicBlock const* m_current_block { nullptr };
|
BasicBlock const* m_current_block { nullptr };
|
||||||
InstructionStreamIterator* m_pc { nullptr };
|
InstructionStreamIterator* m_pc { nullptr };
|
||||||
bool m_optimizations_enabled { false };
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern bool g_dump_bytecode;
|
extern bool g_dump_bytecode;
|
||||||
|
|
|
@ -71,7 +71,6 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
static bool s_dump_ast = false;
|
static bool s_dump_ast = false;
|
||||||
static bool s_opt_bytecode = false;
|
|
||||||
static bool s_as_module = false;
|
static bool s_as_module = false;
|
||||||
static bool s_print_last_result = false;
|
static bool s_print_last_result = false;
|
||||||
static bool s_strip_ansi = false;
|
static bool s_strip_ansi = false;
|
||||||
|
@ -212,7 +211,6 @@ static ErrorOr<bool> parse_and_run(JS::Interpreter& interpreter, StringView sour
|
||||||
script_or_module->parse_node().dump(0);
|
script_or_module->parse_node().dump(0);
|
||||||
|
|
||||||
if (auto* bytecode_interpreter = g_vm->bytecode_interpreter_if_exists()) {
|
if (auto* bytecode_interpreter = g_vm->bytecode_interpreter_if_exists()) {
|
||||||
bytecode_interpreter->set_optimizations_enabled(s_opt_bytecode);
|
|
||||||
result = bytecode_interpreter->run(*script_or_module);
|
result = bytecode_interpreter->run(*script_or_module);
|
||||||
} else {
|
} else {
|
||||||
result = interpreter.run(*script_or_module);
|
result = interpreter.run(*script_or_module);
|
||||||
|
@ -578,13 +576,14 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
StringView evaluate_script;
|
StringView evaluate_script;
|
||||||
Vector<StringView> script_paths;
|
Vector<StringView> script_paths;
|
||||||
bool use_bytecode = false;
|
bool use_bytecode = false;
|
||||||
|
bool optimize_bytecode = false;
|
||||||
|
|
||||||
Core::ArgsParser args_parser;
|
Core::ArgsParser args_parser;
|
||||||
args_parser.set_general_help("This is a JavaScript interpreter.");
|
args_parser.set_general_help("This is a JavaScript interpreter.");
|
||||||
args_parser.add_option(s_dump_ast, "Dump the AST", "dump-ast", 'A');
|
args_parser.add_option(s_dump_ast, "Dump the AST", "dump-ast", 'A');
|
||||||
args_parser.add_option(JS::Bytecode::g_dump_bytecode, "Dump the bytecode", "dump-bytecode", 'd');
|
args_parser.add_option(JS::Bytecode::g_dump_bytecode, "Dump the bytecode", "dump-bytecode", 'd');
|
||||||
args_parser.add_option(use_bytecode, "Run the bytecode", "run-bytecode", 'b');
|
args_parser.add_option(use_bytecode, "Run the bytecode", "run-bytecode", 'b');
|
||||||
args_parser.add_option(s_opt_bytecode, "Optimize the bytecode", "optimize-bytecode", 'p');
|
args_parser.add_option(optimize_bytecode, "Optimize the bytecode", "optimize-bytecode", 'p');
|
||||||
args_parser.add_option(s_as_module, "Treat as module", "as-module", 'm');
|
args_parser.add_option(s_as_module, "Treat as module", "as-module", 'm');
|
||||||
args_parser.add_option(s_print_last_result, "Print last result", "print-last-result", 'l');
|
args_parser.add_option(s_print_last_result, "Print last result", "print-last-result", 'l');
|
||||||
args_parser.add_option(s_strip_ansi, "Disable ANSI colors", "disable-ansi-colors", 'i');
|
args_parser.add_option(s_strip_ansi, "Disable ANSI colors", "disable-ansi-colors", 'i');
|
||||||
|
@ -598,6 +597,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
args_parser.parse(arguments);
|
args_parser.parse(arguments);
|
||||||
|
|
||||||
JS::Bytecode::Interpreter::set_enabled(use_bytecode);
|
JS::Bytecode::Interpreter::set_enabled(use_bytecode);
|
||||||
|
JS::Bytecode::Interpreter::set_optimizations_enabled(optimize_bytecode);
|
||||||
|
|
||||||
bool syntax_highlight = !disable_syntax_highlight;
|
bool syntax_highlight = !disable_syntax_highlight;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue