Re: How do I trace objects on the heap with JS 59

Boris Zbarsky <[email protected]> Tue, 14 Aug 2018 14:14:48 -0400
Newsgroups gmane.comp.mozilla.devel.jseng
Message-ID <[email protected]>
On 8/9/18 11:44 PM, James Stortz wrote:
> What if I have JSObjects that are already rooted? (Either as global
> variables, or properties of rooted objects) And I have references to those
> JSObject* pointers in my backend?

You must not store JSObject* directly, because that doesn't play nice 
with the GC moving objects.

If you're storing JSObject** pointing into a rooted thing, that might be 
OK as long as you don't write to it, I think.  So a "JSObject* const*", 
basically.

> Do I need to change those JSObject* pointers to JS::Heap<JSObject*> in that
> case? I always assumed that would be the case, but does it affect those
> rooted JSObjects? Are they still the same object? If so, how do I convert
> Heap<T> back to Rooted<T>?

I'm not quite sure what you're asking here... :(

-Boris