StanzaOrg / lbstanza-old

L.B. Stanza Programming Language
Other
216 stars 23 forks source link

Break table construction #122

Closed OlegPliss closed 3 years ago

OlegPliss commented 3 years ago

Break table is necessary for relocation of pointers and compaction phases.

"Break" is a conventional name for a maximum sequence of unmarked objects starting at given address. A break can consist of one or more longs. This garbage collector does not mandate 2 longs (or 16 bytes) minimum object size. One long is sufficient.

A break contains a pointer to the first marked object above it and a pointer to the next break. The pointers are aligned. To fit into single long, special encoding is used for the first marked object above. In a single-long break the address of the first marked object above is designated by 1 in the lowest bit of the pointer to the next break.

Break table is represented by an implicit list of breaks and a hashed root to accelerate lookup.

The list of breaks starts at the lowest break. compaction-start conveniently points to this location. Compaction phase moves a segment of reachable object downwards by the sum of break lengths below the segment.

To avoid computing this sum for given object from the list entry, compaction area is divided into equally sized buckets. Break table root consists of entries each of which contains a pointer to the start of the lowest break is the bucket and accumulated sum of breaks below it. To compute a sum of breaks below given object, we locate its bucket, prime the counter with the stored accumulated breaks below the bucket and continue to accumulate breaks below the object starting with the stored break.