GC API: Difference between revisions

144 bytes added ,  1 April 2008
m
(prefer bsmedberg's names)
m (→‎Allocation: onions)
Line 52: Line 52:


Allocate ''rawSize'' + ''ptrsSize'' bytes of memory.  Both sizes must be pointer-size-aligned.  The first ''rawSize'' bytes are not necessarily zeroed.  They GC will assume that they never contain pointers.  The next ''ptrsSize'' bytes are treated as an array of "possible pointers" (<code>jsval</code>, really; see below).
Allocate ''rawSize'' + ''ptrsSize'' bytes of memory.  Both sizes must be pointer-size-aligned.  The first ''rawSize'' bytes are not necessarily zeroed.  They GC will assume that they never contain pointers.  The next ''ptrsSize'' bytes are treated as an array of "possible pointers" (<code>jsval</code>, really; see below).
Returns a pointer to the first byte of the pointers region, so the non-pointer-containing words are at negative offsets and the pointer-containing words are at positive offsets.


  void * '''gc_alloc_with_layout'''(GCHeap heap, GCLayout layout);
  void * '''gc_alloc_with_layout'''(GCHeap heap, GCLayout layout);
Line 64: Line 66:


Allocate and zero out memory for an array.  The layout of the array consists of an optional header described by ''headerLayout'', followed by ''count'' array elements, each described by ''elementLayout''.  Returns a pointer to the beginning of the allocation (the header).
Allocate and zero out memory for an array.  The layout of the array consists of an optional header described by ''headerLayout'', followed by ''count'' array elements, each described by ''elementLayout''.  Returns a pointer to the beginning of the allocation (the header).
'''Open issue:''' API for onions.


'''Open issue:''' Reference counting (or DRC) and/or other nasty tricks to keep memory usage down.
'''Open issue:''' Reference counting (or DRC) and/or other nasty tricks to keep memory usage down.
638

edits