JOL object header information

Rafael Winterhalter rafael.wth at gmail.com
Mon Dec 15 13:03:51 UTC 2014


Hello everybody,

first of all, thank you for this great tool, it helped me a lot to
understand some cache line issues. Keep up the good work!

After using JOL for looking into field layouts I became curious about
HotSpot's mark word which is referred to in the examples on
http://hg.openjdk.java.net/code-tools/jol/file/tip/jol-samples/src/main/java/org/openjdk/jol/samples/

Unfortunately, I stumbled when trying to interpret the mark word's contents
of which I found a description in the commentary to this class:
http://hg.openjdk.java.net/jdk6/jdk6/hotspot/file/8389681cd7b1/src/share/vm/oops/markOop.hpp

To be certain, I wrote a minor extension to JOL which allows to print more
detailed header information by something like:

ClassLayout layout = ClassLayout.parseClass(Foo.class).withDetailedHeader();

where each header value is then mapped to its content in JOL's tabular
overview instead of just printing "(object header)". My (minor)
modification can found here:
https://gist.github.com/raphw/7345bae62abd424fb040

However, it seems like the layout JOL retrieves diverges from the layout
that is described in markOop.hpp - As one exemplary divergence, I found
that the identity hash code seems to reach one bit further than the
described 31 bit, e.g. when running

ClassLayout layout =
ClassLayout.parseClass(Object.class).withDetailedHeader();
Object foo = new Object();
System.out.println(Integer.toHexValue(foo.hashCode()));
System.out.println(layout.toPrintable(foo));

the hex code often is one bit longer than the 31 bit that are specified in
markOop.hpp - also, I cannot observe that the biased lock flag is set for
the biased lock example.

I understand that this mailing list is not a support forum for a potential
beginner's problem when trying to learn more about HotSpot, I would still
really appreciate an answer. Furthermore, I was wondering you would
consider adding a similar feature for a detailed view of an instance's
header to JOL. I am sure, others would benefit from the extended output
when going through the examples that concern locking and hash code
computation.

Thank you for your time and best regards,
Rafael


More information about the jol-dev mailing list