GC API: Difference between revisions

95 bytes added ,  1 April 2008
steal bsmedberg's description of layout
m (→‎Allocation: onions)
(steal bsmedberg's description of layout)
Line 26: Line 26:


== Heap setup/teardown ==
== Heap setup/teardown ==
Requirement: Support multiple heaps.  Each heap is a disjoint universe of objects.  We don't need to trace pointers across heaps.
We support multiple heaps; each heap is a disjoint universe of objects and can be collected separatelyImplementations are expected not to trace pointers across heaps.
 
typedef ... '''GCHeap''';
GCHeap '''gc_heap_create'''();
void '''gc_destroy_heap'''(GCHeap heap);


==Allocation==
==Allocation==
Line 75: Line 81:
== Layout ==
== Layout ==


'''TODO'''
typedef ... '''GCLayout''';
GCLayout gc_create_layout(GCHeap heap, size_t size,
                          unsigned char *bitmap);
 
Create a layout object which represents the layout of pointers within an object type.
 
''bitmap'' is an array of bytes. Each byte represents one word of the target object (there must be <code>''size''/sizeof(void *)</code> entries)
 
:0 - the word is not a pointer
:1 - the word is a pointer, perhaps an interior pointer, and perhaps a pointer to an rcobject
:2 - the word is a jsval
:3 - the word is the possibly-pointer-containing half of a ttbox
 
3 only makes sense on 32-bit platforms for now.
 
'''Open issue:''' GCLayout lifetime - gc'd? or lifetime of heap?
 


== Write barrier ==
== Write barrier ==
Line 113: Line 136:


This is a description of the API that the allocator needs to provide to the GC engine which runs atop it:
This is a description of the API that the allocator needs to provide to the GC engine which runs atop it:
/* GC Heap API */
typedef struct gcheap gcheap;
gcheap * gc_create_heap();
void gc_destroy_heap(gcheap *heap);
/* Layout API */
typedef struct gclayout gclayout;
/* Create a layout object which represents the layout of pointers within
    an object type.
    @param bitmap An array of bytes. Each byte represents one word of the
                  target object (there must be size / 4 entries)
          0 - the word is not a pointer
          1 - the word is a pointer, perhaps an interior pointer, and
              perhaps a pointer to an rcobject
          2 - the word is a jsval
          3 - the word is a ttbox
*/
gclayout * gc_create_layout(gcheap *heap, size_t size,
                            char *bitmap);
   
   
  /* Allocation API */
  /* Allocation API */
638

edits