mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:07:35 +00:00
LibJS: Always keep the global object in bytecode VM register $1
This commit is contained in:
parent
b3e6a6c1cd
commit
22c803d8e5
3 changed files with 9 additions and 1 deletions
|
@ -99,7 +99,7 @@ private:
|
|||
NonnullOwnPtrVector<BasicBlock> m_root_basic_blocks;
|
||||
NonnullOwnPtr<StringTable> m_string_table;
|
||||
|
||||
u32 m_next_register { 1 };
|
||||
u32 m_next_register { 2 };
|
||||
u32 m_next_block { 1 };
|
||||
Vector<Label> m_continuable_scopes;
|
||||
Vector<Label> m_breakable_scopes;
|
||||
|
|
|
@ -59,6 +59,7 @@ Value Interpreter::run(Executable const& executable)
|
|||
auto block = &executable.basic_blocks.first();
|
||||
m_register_windows.append(make<RegisterWindow>());
|
||||
registers().resize(executable.number_of_registers);
|
||||
registers()[Register::global_object_index] = Value(&global_object());
|
||||
|
||||
for (;;) {
|
||||
Bytecode::InstructionStreamIterator pc(block->instruction_stream());
|
||||
|
|
|
@ -13,6 +13,7 @@ namespace JS::Bytecode {
|
|||
class Register {
|
||||
public:
|
||||
constexpr static u32 accumulator_index = 0;
|
||||
constexpr static u32 global_object_index = 1;
|
||||
|
||||
static Register accumulator()
|
||||
{
|
||||
|
@ -20,6 +21,12 @@ public:
|
|||
return accumulator;
|
||||
}
|
||||
|
||||
static Register global_object()
|
||||
{
|
||||
static Register global_object(global_object_index);
|
||||
return global_object;
|
||||
}
|
||||
|
||||
explicit Register(u32 index)
|
||||
: m_index(index)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue