Integrating core collections with the garbage collector

32 views
Skip to first unread message

Jon Harrop

unread,
Nov 29, 2013, 8:22:09 AM11/29/13
to pragmatic-functional...@googlegroups.com

 

When an object is popped off a mutable stack or dequeued from a mutable queue the implementation removes the reference to that object from its internal array by setting that element to the NULL reference. If the GC understood the semantics of the collection it could not only avoid traversing that object without the user code having to NULL it but it could also avoid scanning all of the other NULL pointers in the array because it would know exactly which elements were reachable from the collection.

 

Similarly, an object that represents a slice of an array could force only that part of the underlying array to be scanned and, therefore, the remainder of the array would not keep unreachable values alive.

 

Has anyone ever written a language/VM with core collections that work with the garbage collector in this way? My HLVM project would be ideal for this because every type has a GC “visit” function associated with it that is responsible for pushing all references from an object onto the GC’s visit stack.

 

Cheers,

Jon.

 

Reply all
Reply to author
Forward
0 new messages