On Sun, Jan 05, 2014 at 05:24:44PM -0800, Chris Brannon wrote:
> Karl Dahlke <[email protected]> writes:
> 
> > Every object is created under another, linking all the way back to jswin.
> > And so I still don't understand why there should be an issue.
> 
> If I understand correctly, rooting is only necessary if you need an
> unreferenced object to persist for some reason.  That's what I'm getting
> from their documentation, at least.

According to the latest docs I've been reading,
one shouldn't store unrooted pointers on the stack.
I think this has something to do with the way that the js pointers returned
from the various JS_* functions are managed in the smjs memory pool.
For example the JS_ValueToString function explicitly says (at the botom of the
page) that you should protect its return value with a GC root or the string is
at risk of garbage collection at any stage.

I think this is because the SpiderMonkey environment uses a managed memory pool
from whihch it allocates values, strings, objects etc.
Theoretically most of our objects should be protected from GC because they have
references linked to the window, however objects created by converting a jsval
to a JSObject pointer don't and thus can be garbage collected according to the 
docs.
I think this is slightly different to the way it used to work,
where lots more implicit rooting was performed.

Admittedly some of this rooting may be paranoia, but the GC rooting guide [1] 
is very explicit about the risks of not rooting c orrectly.

Cheers,
Adam.
[1] https://developer.mozilla.org/en-US/docs/SpiderMonkey/GC_Rooting_Guide
_______________________________________________
Edbrowse-dev mailing list
[email protected]
http://lists.the-brannons.com/mailman/listinfo/edbrowse-dev

Reply via email to