How much space do the various fields of an object header need?
| Field |
Currently uses |
Minimum |
Realistic goal |
| class |
1 word (pointer) |
Depends on how many classes ~24 bits |
1 word less 8 bits for alignment (it shouldn't be that hard to align class objects to 256 bytes, or to steal a few top bits for a few years before hardware needs all 64). |
| Reference count |
1 word |
Half word or less using saturating reference counting |
1 word less 3+n bits. Where 1/2**n is the fraction of memory that can be allocated to objects |
| GC data |
2 words |
~5 bits, plus external data for younger generations |
~5 bits (can go in class word) + temporary ref count in top half of ref count |
| weakref |
1 word |
1 bit if no weakrefs |
1 bit + external table when needed |
| Total |
5 words |
1 word |
2 words |
A 1 word header is going to be tricky and may well be so convoluted that it makes performance worse.
However I think the two word header is feasible.
The bits required for GC and finalization are:
- Generation: 2 bits
- Scratch bits: 2 bits (for internal GC state)
- Needs finalizing: 1 bit
- Has weakref: 1 bit
Of course, aiming for a two word header doesn't mean we can't improve things incrementally.
A three word header would still be a significant improvement and would be significantly simpler to implement.
How much space do the various fields of an object header need?
1/2**nis the fraction of memory that can be allocated to objectsA 1 word header is going to be tricky and may well be so convoluted that it makes performance worse.
However I think the two word header is feasible.
The bits required for GC and finalization are:
Of course, aiming for a two word header doesn't mean we can't improve things incrementally.
A three word header would still be a significant improvement and would be significantly simpler to implement.