What is the reason for the additional indirection in Handle?

Ramón García ramon.garcia.f+java at gmail.com
Sun Sep 7 06:14:17 PDT 2008


The Handle class, and subclasses like KlassHandle have an additional
indirection to the Oop they are pointing to.

Instead of storing the oop inside (which is already a pointer), they
store a pointer to the oop. This causes an additional memory
allocation of an object of size pointer, to contain the actual pointer
to the oop.

Why?

I guess it must have something to do with garbage collection, so that
in case the underlying oop is moved, the pointer is updated. I guess a
pointer in the stack cannot be updated. Or perhaps with scanning: the
stack is not scanned for references, but the malloced heap where the
pointers to references are.



More information about the hotspot-runtime-dev mailing list