Skip to content
Commit 7e19a0c7 authored by Philip Chimento's avatar Philip Chimento
Browse files

object: Fully use GjsMaybeOwned wrapper

Previously, when not needing to keep a JS wrapper object alive, we would
unroot it from the GjsMaybeOwned that is part of its private struct, and
instead move it to a JS::Heap wrapper in the GObject's qdata where it was
kept as a weak pointer.

By adding switch_to_rooted() and switch_to_unrooted() API to
GjsMaybeOwned, we can instead use GjsMaybeOwned for both cases. We also
need to add an update_after_gc() method in order to store a weak pointer
in the GjsMaybeOwned, since we will need to update the pointer's location
after every garbage collection in SpiderMonkey 38.

Because we still need to get to the object's private struct given the
GObject, we can use the object's qdata for that purpose instead.

There is one test that must be skipped for the time being: SpiderMonkey
31's garbage collector is not smart enough to collect the object right
after switch_to_unrooted(). This test passes in SpiderMonkey 38.

https://bugzilla.gnome.org/show_bug.cgi?id=776966
parent ea43a1c4
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment