[rucksack-devel] Another GC patch

Arthur Lemmens alemmens at xs4all.nl
Thu May 18 21:31:36 UTC 2006


Edi wrote:

> Here's another one I'm not sure about: In SWEEP-SOME-HEAP-BLOCKS the
> comments explicitely say that BLOCK-START can be NIL.  However, the
> code after the "Reclaim dead blocks" comment seems to assume that
> BLOCK-START is a positive integer when it calls BLOCK-ALIVE-P.

Yes.  Like I said to Nikodemus, there are some places in the garbage
collector that need to be adapted to the 'new' object layout (the old
one didn't have pointers to previous versions and transaction ids
for each object).  This is probably one such place.

Here's a description of blocks:

** Blocks

The heap contains blocks of different sizes (currently the block sizes
are powers of 2; starting with blocks of 16 bytes).  Each block
starts with an 8-byte header.  If the block is unoccupied, the header
contains a pointer to the next block in the free list; otherwise it
contains the size of the block.

The header is followed by a serialized value which is either NIL,
a positive integer or a negative integer.  If it's NIL, the block
is occupied by an object of which there is exactly one version.
If it's a positive integer, the block is occupied by an object and
the integer is a pointer to (the heap position of) the previously
saved version of the object.  If it's negative, the block belongs
to a free list and is not in use; the integer's absolute value is
the size of the block (the sweep phase of the garbage collector needs
this block size).

[OCCUPIED BLOCK]:
   0- 8: block size
   8-15: pointer to previous version (nil or an integer)
    .. : transaction id
    .. : object id
    .. : nr of slots
    .. : schema id
    ...: serialized slots
    ...: maybe some free space

[FREE BLOCK]:
   0- 8: pointer to next free block
   ..  : the negative of the block size
   ... : free space

> Now, what does it mean if BLOCK-START is NIL?

BLOCK-START points to byte 8 of the block.  So the block is occupied
by the one and only version of an object.

> Does it mean that the block is not dead?

It's not really related to live or dead: that's indicated by the garbage
collector info byte in the object table.  If you have an object id, you
can find that byte.

> In that case my tiny patch might be correct.

It probably isn't (I haven't looked closely).  And even if it is correct,
it's not enough: the function BLOCK-ALIVE-P needs to be adapted too.
It's still based on the old block layout, where BLOCK-START pointed to
an object id.

Arthur





More information about the rucksack-devel mailing list