Okay, here's a quick draft of the rules I'm thinking of to govern memory 
allocation and tracking so the interpreter can GC and dead-object detect 
properly.

1) The pointer in a PMC structure may point to:

   *) Another PMC
   *) A buffer object
   *) Something non-tracked

Additionally the buffer object may contain array of buffer object pointers, 
or an array of PMC pointers. Flags in the PMC note these occurrences.

2) A buffer object has the structure:

    struct {
       void *memory;
       INTVAL size;
    }

this may be at the head of a larger structure, that's OK. (In fact, this is 
the start of the STRING and BIGNUM structures) The memory pointed to by a 
buffer object may be anything, but it is assumed to be moveable.

For a buffer to be considered 'live' it must be pointed to by a PMC either 
directly or via a single level of indirection. (If the PMC points to a 
buffer object that has an array of buffer pointers in it) For a PMC to be 
considered live it must be reachable via the interpreter's root set.

There will be a mechanism to register PMCs with the interpreter to note 
they're pointed to by something that the interpreter can't reach. (For 
example, a structure in your extension code, or via a pointer stashed in 
the depths of a buffer object, or referenced by another interpreter) This 
"foreign access" registry is considered part of an interpreter's root set.

                                        Dan

--------------------------------------"it's like this"-------------------
Dan Sugalski                          even samurai
[EMAIL PROTECTED]                         have teddy bears and even
                                      teddy bears get drunk

Reply via email to