mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-24 02:09:28 +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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user