mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-30 11:37:16 +02: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:
Notes:
sideshowbarker
2024-07-17 05:58:46 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/6537ed8fff Pull-request: https://github.com/SerenityOS/serenity/pull/19560 Reviewed-by: https://github.com/mattco98
@@ -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