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
Notes:
sideshowbarker
2024-07-18 12:22:04 +09:00
Author: https://github.com/IdanHo Commit: https://github.com/SerenityOS/serenity/commit/6913f06b6f8 Pull-request: https://github.com/SerenityOS/serenity/pull/8022 Reviewed-by: https://github.com/linusg
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)
|
||||
vm().pop_call_frame();
|
||||
|
||||
vm().finish_execution_generation();
|
||||
|
||||
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,
|
||||
// in which case this is a no-op.
|
||||
vm.run_queued_promise_jobs();
|
||||
|
||||
vm.finish_execution_generation();
|
||||
}
|
||||
|
||||
GlobalObject& Interpreter::global_object()
|
||||
|
|
|
@ -166,6 +166,9 @@ public:
|
|||
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; }
|
||||
|
||||
u32 execution_generation() const { return m_execution_generation; }
|
||||
void finish_execution_generation() { ++m_execution_generation; }
|
||||
|
||||
void unwind(ScopeType type, FlyString label = {})
|
||||
{
|
||||
m_unwind_until = type;
|
||||
|
@ -279,6 +282,8 @@ private:
|
|||
Shape* m_scope_object_shape { nullptr };
|
||||
|
||||
bool m_underscore_is_last_value { false };
|
||||
|
||||
u32 m_execution_generation { 0 };
|
||||
};
|
||||
|
||||
template<>
|
||||
|
|
|
@ -655,6 +655,8 @@ JS::Interpreter& Document::interpreter()
|
|||
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);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue