mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-29 15:58:47 +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
Notes:
sideshowbarker
2024-07-17 05:58:46 +09:00
Author: https://github.com/awesomekling
Commit: 6537ed8fff
Pull-request: https://github.com/SerenityOS/serenity/pull/19560
Reviewed-by: https://github.com/mattco98
15 changed files with 117 additions and 106 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue