1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 17:57:35 +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:
Andreas Kling 2023-06-22 15:59:18 +02:00
parent 6150960671
commit 6537ed8fff
15 changed files with 117 additions and 106 deletions

View file

@ -215,12 +215,10 @@ static Result<void, TestError> run_test(StringView source, StringView filepath,
if (program_or_error.is_error())
return program_or_error.release_error();
OwnPtr<JS::Bytecode::Interpreter> bytecode_interpreter = nullptr;
if (JS::Bytecode::Interpreter::enabled())
bytecode_interpreter = make<JS::Bytecode::Interpreter>(realm);
auto* bytecode_interpreter = vm->bytecode_interpreter_if_exists();
auto run_with_interpreter = [&](ScriptOrModuleProgram& program) {
if (JS::Bytecode::Interpreter::enabled())
if (bytecode_interpreter)
return run_program(*bytecode_interpreter, program);
return run_program(*ast_interpreter, program);
};