Runtime Gotchas

Revision as of 19:36, 3 April 2006 by Manus (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Introduction

While working on the runtime I (user:manus) found a few things that need to be watched for when modifying the runtime. Below is a non-exhaustive list of bugs I've encountered that can easily be redone if not flagged anywhere for future references.

Objects

Size of objects

The size of objects must always be a multiple of ALIGNMAX, and the size of containers of objects too. That is to say that either the container is full (no non-used bytes), or if it is not full, there is at least ALIGNMAX bytes available. See the comments on ALIGNMAX to understand why it is important.


B_LAST flag

It is quite dangerous to play with the B_LAST flag as if you set it on an object which is at the beginning of chunk, then the memory allocation will consider the block as free if the object is no B_BUSY, and thus will free it. Usually the B_LAST operations are transparent to the GC writer except in one place: the incremental compaction done in `partial_scavenging'.

Is object alive?

When traversing the memory to find objects that are still alive (e.g. as done in `sweep_from_space') you need to be careful about the flags you are checking. First the object needs to have the B_BUSY flag, if not then it means that this block is part of the free list. Then it needs to be either marked with the B_FWD flag, and if B_BUSY and not B_FWD then it should have the EO_MARK flag.

Not doing this proper check could end up in a bug chasing that last for days....