From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-we0-x231.google.com (mail-we0-x231.google.com [IPv6:2a00:1450:400c:c03::231]) by hurricane.the-brannons.com (Postfix) with ESMTPS id 7438E77AD7 for ; Sat, 4 Jan 2014 14:52:40 -0800 (PST) Received: by mail-we0-f177.google.com with SMTP id u56so14182219wes.8 for ; Sat, 04 Jan 2014 14:52:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=W5I8+EK9wu+7BCWvW3fQ9ouQrlrkv4PU6kKabTqLQLo=; b=hZjnX7Y1ik9N/Gg5mKTwvsUOYt4fZZclSdjxMloRWNeS1p4aJwygv4y8toddNZYSiA XE6dCGZPw6IrY9/hXFJwiELzZ57xgC4zptGQbM5fxbClmroViCL0hHbM2ROv0uh8mTkt 7Hls208nTR5qLXVKyR+4Q5cPJfMtIBhu6004e7tBXWxFQ/4Q3iP4KKBllItP+G3jvZ92 ltUDFcNWDgEg9T6MBqQyuWJnqemMotwy8GaoH0qj2r5Kxx+n4Nbb9XJy98tTM7jlNQlt YFDTiMeWfE/uQe6BerEwQsFvD+1OZOX4dzs2W8IIwX3heWLPuIX7fAVAdoGzarUYEwWK a7Uw== X-Received: by 10.194.57.243 with SMTP id l19mr2433692wjq.54.1388875945957; Sat, 04 Jan 2014 14:52:25 -0800 (PST) Received: from toaster.adamthompson.me.uk (toaster.adamthompson.me.uk. [2001:8b0:1142:9042::2]) by mx.google.com with ESMTPSA id fj8sm9887941wib.1.2014.01.04.14.52.24 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 04 Jan 2014 14:52:25 -0800 (PST) Date: Sat, 4 Jan 2014 22:52:22 +0000 From: Adam Thompson To: Karl Dahlke Message-ID: <20140104225222.GB11201@toaster.adamthompson.me.uk> References: <20140004171414.eklhad@comcast.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20140004171414.eklhad@comcast.net> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: Edbrowse-dev@lists.the-brannons.com Subject: Re: [Edbrowse-dev] gc X-BeenThere: edbrowse-dev@lists.the-brannons.com X-Mailman-Version: 2.1.17 Precedence: list List-Id: Edbrowse Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 04 Jan 2014 22:52:40 -0000 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.