mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-26 22:38:51 +00:00
LibJS: Add MarkedValueList and use it for argument passing
A MarkedValueList is basically a Vector<JS::Value> that registers with the Heap and makes sure that the stored values don't get GC'd. Before this change, we were unsafely keeping Vector<JS::Value> in some places, which is out-of-reach for the live reference finding logic since Vector puts its elements on the heap by default. We now pass all the JavaScript tests even when running with "js -g", which does a GC on every heap allocation.
This commit is contained in:
parent
cb3cf589ed
commit
f7a1696087
Notes:
sideshowbarker
2024-07-19 07:27:57 +09:00
Author: https://github.com/awesomekling
Commit: f7a1696087
13 changed files with 178 additions and 16 deletions
|
@ -83,8 +83,9 @@ void XMLHttpRequest::dispatch_event(NonnullRefPtr<Event> event)
|
|||
if (listener.event_name == event->name()) {
|
||||
auto* function = const_cast<EventListener&>(*listener.listener).function();
|
||||
auto* this_value = wrap(function->heap(), *this);
|
||||
auto* event_wrapper = wrap(function->heap(), *event);
|
||||
function->interpreter().call(function, this_value, { event_wrapper });
|
||||
JS::MarkedValueList arguments(function->heap());
|
||||
arguments.append(wrap(function->heap(), *event));
|
||||
function->interpreter().call(function, this_value, move(arguments));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue