I also have an idea how to fix the scopes not being collected right now, in `InterpretedFunction_gc_traverse`, which can then simplify it to a couple of lines. But it needs some changes to the scope_chain_t so that it is wrapped in a dummy jsdisp, so I'll keep that for another MR. I will add tests for that too, of course. Anyway just wanted to mention that the `FIXME` there is temporary!
A dummy jsdisp sounds worrying and handling things like scopes is an important part of GC, so I'd rather wait and see the whole thing. I'd expect that abstracting "GC thing" instead of binding it so tight to jsdisp_t would be better, especially with Gecko CC integration on the horizon. See how `note_cc_edge()` works, for example.
I'm also not sure if you need to modify object refs in GC and restoring them later is needed. You could, for example, store count of noted references to the object in GC and later compare object's ref count to noted ref count. If it's equal, you know you may unlink it. This would avoid modifying objects until we know if we want to unlink them or not.