mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 21:37:34 +00:00
LibJS: Store and maintain an "execution generation" counter
This counter is increased each time a synchronous execution sequence completes, and will allow us to emulate the abstract operations AddToKeptObjects & ClearKeptObjects efficiently.
This commit is contained in:
parent
8a739f986a
commit
6913f06b6f
4 changed files with 11 additions and 0 deletions
|
@ -141,6 +141,8 @@ Value Interpreter::run(Executable const& executable, BasicBlock const* entry_poi
|
||||||
if (vm().call_stack().size() == 1)
|
if (vm().call_stack().size() == 1)
|
||||||
vm().pop_call_frame();
|
vm().pop_call_frame();
|
||||||
|
|
||||||
|
vm().finish_execution_generation();
|
||||||
|
|
||||||
return return_value;
|
return return_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,6 +63,8 @@ void Interpreter::run(GlobalObject& global_object, const Program& program)
|
||||||
// At this point we may have already run any queued promise jobs via on_call_stack_emptied,
|
// At this point we may have already run any queued promise jobs via on_call_stack_emptied,
|
||||||
// in which case this is a no-op.
|
// in which case this is a no-op.
|
||||||
vm.run_queued_promise_jobs();
|
vm.run_queued_promise_jobs();
|
||||||
|
|
||||||
|
vm.finish_execution_generation();
|
||||||
}
|
}
|
||||||
|
|
||||||
GlobalObject& Interpreter::global_object()
|
GlobalObject& Interpreter::global_object()
|
||||||
|
|
|
@ -166,6 +166,9 @@ public:
|
||||||
bool underscore_is_last_value() const { return m_underscore_is_last_value; }
|
bool underscore_is_last_value() const { return m_underscore_is_last_value; }
|
||||||
void set_underscore_is_last_value(bool b) { m_underscore_is_last_value = b; }
|
void set_underscore_is_last_value(bool b) { m_underscore_is_last_value = b; }
|
||||||
|
|
||||||
|
u32 execution_generation() const { return m_execution_generation; }
|
||||||
|
void finish_execution_generation() { ++m_execution_generation; }
|
||||||
|
|
||||||
void unwind(ScopeType type, FlyString label = {})
|
void unwind(ScopeType type, FlyString label = {})
|
||||||
{
|
{
|
||||||
m_unwind_until = type;
|
m_unwind_until = type;
|
||||||
|
@ -279,6 +282,8 @@ private:
|
||||||
Shape* m_scope_object_shape { nullptr };
|
Shape* m_scope_object_shape { nullptr };
|
||||||
|
|
||||||
bool m_underscore_is_last_value { false };
|
bool m_underscore_is_last_value { false };
|
||||||
|
|
||||||
|
u32 m_execution_generation { 0 };
|
||||||
};
|
};
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
|
|
|
@ -655,6 +655,8 @@ JS::Interpreter& Document::interpreter()
|
||||||
dbgln(" {} at {}:{}:{}", function_name, source_range.filename, source_range.start.line, source_range.start.column);
|
dbgln(" {} at {}:{}:{}", function_name, source_range.filename, source_range.start.line, source_range.start.column);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vm.finish_execution_generation();
|
||||||
};
|
};
|
||||||
m_interpreter = JS::Interpreter::create<Bindings::WindowObject>(vm, *m_window);
|
m_interpreter = JS::Interpreter::create<Bindings::WindowObject>(vm, *m_window);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue