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
Notes: sideshowbarker 2024-07-17 05:58:46 +09:00
15 changed files with 117 additions and 106 deletions

View file

@ -95,9 +95,8 @@ JS::Completion ClassicScript::run(RethrowErrors rethrow_errors, JS::GCPtr<JS::En
auto timer = Core::ElapsedTimer::start_new();
// 6. Otherwise, set evaluationStatus to ScriptEvaluation(script's record).
if (JS::Bytecode::Interpreter::enabled()) {
auto interpreter = JS::Bytecode::Interpreter(m_script_record->realm());
evaluation_status = interpreter.run(*m_script_record, lexical_environment_override);
if (auto* bytecode_interpreter = vm().bytecode_interpreter_if_exists()) {
evaluation_status = bytecode_interpreter->run(*m_script_record, lexical_environment_override);
} else {
auto interpreter = JS::Interpreter::create_with_existing_realm(m_script_record->realm());
evaluation_status = interpreter->run(*m_script_record, lexical_environment_override);