1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 07:27:45 +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

@ -39,11 +39,14 @@ public:
};
static ErrorOr<NonnullRefPtr<VM>> create(OwnPtr<CustomData> = {});
~VM() = default;
~VM();
Heap& heap() { return m_heap; }
Heap const& heap() const { return m_heap; }
Bytecode::Interpreter& bytecode_interpreter();
Bytecode::Interpreter* bytecode_interpreter_if_exists();
Interpreter& interpreter();
Interpreter* interpreter_if_exists();
@ -332,6 +335,8 @@ private:
u32 m_execution_generation { 0 };
OwnPtr<CustomData> m_custom_data;
OwnPtr<Bytecode::Interpreter> m_bytecode_interpreter;
};
ALWAYS_INLINE Heap& Cell::heap() const