mirror of
https://github.com/RGBCube/serenity
synced 2025-05-20 14:05:08 +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
13 changed files with 178 additions and 16 deletions
|
@ -28,6 +28,7 @@
|
|||
#include <LibJS/AST.h>
|
||||
#include <LibJS/Interpreter.h>
|
||||
#include <LibJS/Runtime/Function.h>
|
||||
#include <LibJS/Runtime/MarkedValueList.h>
|
||||
#include <LibJS/Runtime/ScriptFunction.h>
|
||||
#include <LibWeb/Bindings/EventWrapper.h>
|
||||
#include <LibWeb/Bindings/NodeWrapper.h>
|
||||
|
@ -142,7 +143,9 @@ void Node::dispatch_event(NonnullRefPtr<Event> event)
|
|||
dbg() << "calling event listener with this=" << this_value;
|
||||
#endif
|
||||
auto* event_wrapper = wrap(function->heap(), *event);
|
||||
document().interpreter().call(function, this_value, { event_wrapper });
|
||||
JS::MarkedValueList arguments(function->heap());
|
||||
arguments.append(event_wrapper);
|
||||
document().interpreter().call(function, this_value, move(arguments));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue