on non-static field layout
Dmytro Sheyko
dmytro.sheyko at gmail.com
Thu Feb 19 07:58:59 UTC 2015
On Tue, Feb 17, 2015 at 2:39 AM, John Rose <john.r.rose at oracle.com> wrote:
>> a stupid question but how do you scan the heap from start to end if you have an unknown number of references in front of the header of an object ?
>
> Either prefix the sequence of oops with a pre-header word, or else make sure any object header is always a distinct bit pattern from any oop. (This is mostly true in the non-compressed-oop VM, since mark words often have a low-tag bit of 1.)
You are right. It appears I reinvented _bidirectional object layout_.
https://www.usenix.org/legacy/event/jvm01/gagnon/gagnon_html/node12.html
This approach is also mentioned briefly in The Garbage Collection
Handbook (http://gchandbook.org/).
In order to distinguish reference field from header, they use the fact
that object pointers are aligned (i.e. the last bit is always 0). Thus
the last bit in header word is to be always set to 1. It can also be
applicable to compressed oops as well - just use 2-bit shift instead
of 3-bit shift in case of 8-bytes object alignment, but then max heap
size will be twice shorter.
Dmytro
More information about the hotspot-runtime-dev
mailing list