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: Sat, 4 Jan 2014 22:52:22 +0000	[thread overview]
Message-ID: <20140104225222.GB11201@toaster.adamthompson.me.uk> (raw)
In-Reply-To: <20140004171414.eklhad@comcast.net>

On Sat, Jan 04, 2014 at 05:14:14PM -0500, Karl Dahlke wrote:
> I have always wondered about gc in c++.
> It cannot be easy and straightforward like it is in java.
> (One reason I was always afraid of c++)
> So possibly void * won't work, like you have to tell the compiler
> that it's a pointer to a certain object of a certain class,
> for c++ to keep it around.

No, c++ doesn't have its own GC, but it does have the concept of object
constructors and destructors. If I understand the mozilla api correctly,
they basicly use these to hook into their javascript GC system such that when a
RootedObject (I think I've got the type name correct)
is constructed it tells the javascript GC not to collect the object pointed to
by the RootedObject instance, and when the afore mentioned instance goes out of
scope or is destroyed, its destructor tells the javascript GC that the
RootedObject instance is no longer alive and thus,
if all references to the javascript object are destroyed,
the javascript object should be collected.

The problem for us is that we currently don't construct any of these
RootedObject instances, which means that the SpiderMonkey internal GC doesn't
know we want to keep anything we create.
This basicly means (I think) that our objects are collected very soon after they're created, causing the segfault problem.
Another important note is this also applies to javascript values (strings etc) and a copule of other things.

As I see it, either we start keeping pointers to these GC constructs (in void *
should be fine) or we add a further layer of abstraction to basicly make a
more c-like api. Something like an explicit registration and unregistration
setup, with *all* the javascript stuff being in a single void * (runtime,
context list etc).
I think the first option may be the easier short term fix, though it's going to lead to much typecasting.

Cheers,
Adam.

  parent reply	other threads:[~2014-01-04 22:52 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-04 22:14 Karl Dahlke
2014-01-04 22:42 ` Chris Brannon
2014-01-04 22:52 ` Adam Thompson [this message]
2014-01-05  7:30 Karl Dahlke
2014-01-05 13:46 ` Adam Thompson
2014-01-05 19: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=20140104225222.GB11201@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).