edbrowse-dev - development list for edbrowse
 help / color / mirror / Atom feed
From: Adam Thompson <arthompson1990@gmail.com>
To: Karl Dahlke <eklhad@comcast.net>
Cc: Edbrowse-dev@lists.the-brannons.com
Subject: Re: [Edbrowse-dev] gc
Date: Sun, 5 Jan 2014 19:52:22 +0000	[thread overview]
Message-ID: <20140105195222.GF11201@toaster.adamthompson.me.uk> (raw)
In-Reply-To: <20140105134622.GD11201@toaster.adamthompson.me.uk>

On Sun, Jan 05, 2014 at 01:46:22PM +0000, Adam Thompson wrote:
> On Sun, Jan 05, 2014 at 02:30:44AM -0500, Karl Dahlke wrote:
> > > The problem for us is that we currently don't construct any of these
> > > RootedObject instances, which means that the SpiderMonkey internal GC
> > 
> > Really?
> > My layer calls, for example, JS_ConstructObjectWithArguments()
> > to make a new object,
> > I would suppose you replace that with some kind of js new call,
> > which implicitly or explicitly creates a new object in c++,
> > which calls the constructor you described,
> > and I would figure that's good enough to keep it around,
> > until we remove it, which use to be some kind of js_free,
> > now some kind of js_destroy,
> > and then the gc can clean up the loose ends,
> > and I'm sorry in advance if I'm oversimplifying it,
> > because I haven't looked at any of your code or how it works;
> > I just didn't expect a problem here.
> > Allocate becomes new construct, and all should be well.
> 
> I'm guessing this wasn't an issue before since you had to explicitly call the
> GC so you had time to insert the references into the environment (i.e.
> make jwin the global object), however now it seems to be called as part of most operations.
> 
> To allow this to work they now have the rooting api,
> which as far as I can work out, provides objects which are like the "smart"
> pointers chris was talking about. Instead of just freeing the object however,
> these ones hook into the GC for the javascript environment allowing objects to
> stay around in the environment until all references,
> including those in the host app, are gone.

Ok, on closer inspection it looks like we've been living dangerously for a
while as JS_Add*Root functions are present in smjs 185 as well.
The good news is I discovered this whilst looking for a non-c++ alternative to
the smart pointers approach, and the fact that it still exists and is still
supported (though is only encouraged when absolutely necessary)
means that I can save myself a whole bunch of work.
The bad news is that there's been a set of GC-related bugs there for, well,
however long edbrowse's been using SpiderMonkey I guess.
This supports my suspicions that the GC is probably behind many of the js
related segfaults since we really should've been telling it about most of the
js stuff we do.

The reason this is more of an issue now is because they've improved their GC to
make it much more memory efficient apparently.

Cheers,
Adam.

  reply	other threads:[~2014-01-05 19:52 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-05  7:30 Karl Dahlke
2014-01-05 13:46 ` Adam Thompson
2014-01-05 19:52   ` Adam Thompson [this message]
  -- strict thread matches above, loose matches on Subject: below --
2014-01-04 22:14 Karl Dahlke
2014-01-04 22:42 ` Chris Brannon
2014-01-04 22:52 ` 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=20140105195222.GF11201@toaster.adamthompson.me.uk \
    --to=arthompson1990@gmail.com \
    --cc=Edbrowse-dev@lists.the-brannons.com \
    --cc=eklhad@comcast.net \
    /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).