mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:47:34 +00:00
LibJS/Bytecode: Simplify Bytecode::Interpreter lifetime model
The JS::VM now owns the one Bytecode::Interpreter. We no longer have multiple bytecode interpreters, and there is no concept of a "current" bytecode interpreter. If you ask for VM::bytecode_interpreter_if_exists(), it will return null if we're not running the program in "bytecode enabled" mode. If you ask for VM::bytecode_interpreter(), it will return a bytecode interpreter in all modes. This is used for situations where even the AST interpreter switches to bytecode mode (generators, etc.)
This commit is contained in:
parent
6150960671
commit
6537ed8fff
15 changed files with 117 additions and 106 deletions
|
@ -102,7 +102,6 @@ private:
|
|||
};
|
||||
|
||||
static bool s_dump_ast = false;
|
||||
static bool s_run_bytecode = false;
|
||||
static bool s_as_module = false;
|
||||
static bool s_print_last_result = false;
|
||||
|
||||
|
@ -119,9 +118,8 @@ static ErrorOr<bool> parse_and_run(JS::Interpreter& interpreter, StringView sour
|
|||
if (s_dump_ast)
|
||||
script_or_module->parse_node().dump(0);
|
||||
|
||||
if (s_run_bytecode) {
|
||||
JS::Bytecode::Interpreter bytecode_interpreter(interpreter.realm());
|
||||
result = bytecode_interpreter.run(*script_or_module);
|
||||
if (auto* bytecode_interpreter = g_vm->bytecode_interpreter_if_exists()) {
|
||||
result = bytecode_interpreter->run(*script_or_module);
|
||||
} else {
|
||||
result = interpreter.run(*script_or_module);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue