1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 14:47:44 +00:00

Ladybird+LibJS: Add CLI option to run browser with LibJS bytecode VM

This required quite a bit of plumbing, but now you can run

    ladybird --use-bytecode
This commit is contained in:
Andreas Kling 2023-06-17 13:16:35 +02:00
parent 7ec7015750
commit 9c568282dc
20 changed files with 91 additions and 38 deletions

View file

@ -32,7 +32,6 @@
#endif
static DeprecatedString s_current_test = "";
static bool s_use_bytecode = false;
static bool s_enable_bytecode_optimizations = false;
static bool s_parse_only = false;
static DeprecatedString s_harness_file_directory;
@ -217,11 +216,11 @@ static Result<void, TestError> run_test(StringView source, StringView filepath,
return program_or_error.release_error();
OwnPtr<JS::Bytecode::Interpreter> bytecode_interpreter = nullptr;
if (s_use_bytecode)
if (JS::Bytecode::Interpreter::enabled())
bytecode_interpreter = make<JS::Bytecode::Interpreter>(realm);
auto run_with_interpreter = [&](ScriptOrModuleProgram& program) {
if (s_use_bytecode)
if (JS::Bytecode::Interpreter::enabled())
return run_program(*bytecode_interpreter, program);
return run_program(*ast_interpreter, program);
};
@ -572,11 +571,12 @@ int main(int argc, char** argv)
int timeout = 10;
bool enable_debug_printing = false;
bool disable_core_dumping = false;
bool use_bytecode = false;
Core::ArgsParser args_parser;
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(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");
@ -584,6 +584,8 @@ int main(int argc, char** argv)
args_parser.add_option(disable_core_dumping, "Disable core dumping", "disable-core-dump", 0);
args_parser.parse(arguments);
JS::Bytecode::Interpreter::set_enabled(use_bytecode);
#if !defined(AK_OS_MACOS) && !defined(AK_OS_EMSCRIPTEN)
if (disable_core_dumping && prctl(PR_SET_DUMPABLE, 0, 0) < 0) {
perror("prctl(PR_SET_DUMPABLE)");