edbrowse-dev - development list for edbrowse
 help / color / mirror / Atom feed
From: Adam Thompson <arthompson1990@gmail.com>
To: Chris Brannon <chris@the-brannons.com>
Cc: Edbrowse-dev@lists.the-brannons.com
Subject: Re: [Edbrowse-dev] window root
Date: Mon, 6 Jan 2014 09:46:15 +0000	[thread overview]
Message-ID: <20140106094615.GH11201@toaster.adamthompson.me.uk> (raw)
In-Reply-To: <87fvp1297n.fsf@mushroom.PK5001Z>

On Sun, Jan 05, 2014 at 05:24:44PM -0800, Chris Brannon wrote:
> Karl Dahlke <eklhad@comcast.net> 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

  reply	other threads:[~2014-01-06  9:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-06  0:55 Karl Dahlke
2014-01-06  1:24 ` Chris Brannon
2014-01-06  9:46   ` Adam Thompson [this message]
2014-01-06 10:19 Karl Dahlke
2014-01-06 13:05 ` Adam Thompson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140106094615.GH11201@toaster.adamthompson.me.uk \
    --to=arthompson1990@gmail.com \
    --cc=Edbrowse-dev@lists.the-brannons.com \
    --cc=chris@the-brannons.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).