[webkit-dev] The JSC Garbage Collector
Geoffrey Garen
ggaren at apple.com
Wed Oct 5 11:06:52 PDT 2011
Hi Sanjoy.
(+Oliver and Mark, who can help point you in the right direction.)
I don't think the system you described would work. To move an object, you need to update all pointers to it. You also need to resolve other assumptions about pointer identity. For example, you need to rework hash tables of pointers to objects, and references from the (conservatively scanned) C stack.
A simpler task that would be useful to GC would be to add to ClassInfo the size of an object, so the collector can traverse objects without explicit size class information.
Geoff
On Oct 4, 2011, at 10:50 PM, Sanjoy Das wrote:
> Hi!
>
> I recently started looking through the JavaScriptCore codebase, and
> discovered that working on the GC would be a nice way to contribute.
>
> A starting point, I think, would be to implement code that allows
> moving objects around. I was thinking of doing this by adding a third
> field to the MethodTable which takes a hashtable mapping addresses of
> old objects to their new addresses. This function should then modify
> the structure in question accordingly (to modify the fields to point
> to the new memory locations wherever needed).
>
> This way a basic moving and compacting collector (with two spaces)
> could be implemented like:
>
> 1. Figure out the live objects.
> 2. Allocate space for them in the other allocation space. Put the old
> and new address pairs in a map.
> 3. Ask every live (old) object to re-orient itself using the map
> generated in (2).
> 4. Copy the old objects to their designated new locations.
>
> Does this make sense? I'm still pretty new to the JSC codebase so I'm
> not sure about most of what I just said. Another way is, of course,
> to keep references to references, as mentioned in [1]. I found this
> approach better since all the heavy lifting happens at GC time, and
> does not burden the runtime with a double deref.
>
> Thank you for your time!
>
> [1] http://trac.webkit.org/wiki/JS%20Core%20Garbage%20Collector
> --
> Sanjoy Das
> http://playingwithpointers.com
> _______________________________________________
> webkit-dev mailing list
> webkit-dev at lists.webkit.org
> http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
More information about the webkit-dev
mailing list