How to detect if the VM is running with compact refs from within the VM (no agent)?

Dawid Weiss dawid.weiss at gmail.com
Wed Mar 14 11:13:19 PDT 2012


Thanks John,

Oh dear, how could I forget to check my beloved Unsafe -- the keyhole
into the world of magic :)

        ARRAY_BOOLEAN_INDEX_SCALE = theUnsafe.arrayIndexScale([Z);
        ARRAY_BYTE_INDEX_SCALE = theUnsafe.arrayIndexScale([B);
        ARRAY_SHORT_INDEX_SCALE = theUnsafe.arrayIndexScale([S);
        ARRAY_CHAR_INDEX_SCALE = theUnsafe.arrayIndexScale([C);
        ARRAY_INT_INDEX_SCALE = theUnsafe.arrayIndexScale([I);
        ARRAY_LONG_INDEX_SCALE = theUnsafe.arrayIndexScale([J);
        ARRAY_FLOAT_INDEX_SCALE = theUnsafe.arrayIndexScale([F);
        ARRAY_DOUBLE_INDEX_SCALE = theUnsafe.arrayIndexScale([D);

I looked and see these too -- do these ever change from the defaults?
This could really make a killer puzzler question: "How many bytes can
a new byte [1] take?"

Dawid

On Wed, Mar 14, 2012 at 6:53 PM, John Rose <john.r.rose at oracle.com> wrote:
> On Mar 14, 2012, at 1:41 AM, Krystal Mok wrote:
>
> I'm not aware of any way to get the exact "reference size" (or "oop size" in
> HotSpot's terms). But it's possible to know whether compressed oops is in
> use or not.
>
>
> For some platforms, you could inspect
> sun.misc.Unsafe.ARRAY_OBJECT_INDEX_SCALE (= oopSize) and ADDRESS_SIZE (=
> wordSize).
>
> — John


More information about the hotspot-compiler-dev mailing list