Skip to content
  • Philip Chimento's avatar
    closure: Prevent collection of invalidated closure · ee3c9c2b
    Philip Chimento authored
    It's not possible to stop tracing an object in the middle of GC. However,
    by using JS::ExposeObjectToActiveJS(), it is possible to mark an object
    as reachable for the duration of one GC. This is exactly what we need for
    closures, to keep the closure's callable object from disappearing while
    GC is going on.
    
    This requires adding a method, prevent_collection(), to GjsMaybeOwned.
    This method is only valid in non-rooted mode. It also requires a bit of
    GC API magic to avoid running afoul of some debug-mode assertions.
    SpiderMonkey master at least has an official API for one of these bits of
    magic, which we can switch to in SpiderMonkey 59.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=786668
    ee3c9c2b