Review request (M): 7118863: Move sizeof(klassOopDesc) into the *Klass::*_offset_in_bytes() functions

Stefan Karlsson stefan.karlsson at
Wed Dec 7 04:52:22 PST 2011

Please review this REF.

The main motivation for this patch is to make it easier to merge with 
the permgen project. But, IMHO, they also help the code by not having 
different ways to go from a klass field offset to an offset against the 

Two things to note about this patch.
1) There's one place in the code where we don't add 
sizeof(klassOopDesc). I maintain this oddity and will leave the correct 
fix for a later change.

2) I have no way to verify the shark changes.

 From the RFE:
The *Klass::*_offset_in_bytes() functions are used to get the offset to 
a field in a Klass. All places where they are used, we add something 
like sizeof(klassOopDesc) to make the offset against the klassOopDesc 

For example in opto/memnode.cpp:
  if (tkls->offset() == Klass::access_flags_offset_in_bytes() + 
(int)sizeof(oopDesc)) {

There's a couple of variants to this:
  instanceKlass::init_thread_offset_in_bytes() + sizeof(klassOopDesc)
  Klass::access_flags_offset_in_bytes() + (int)sizeof(oopDesc)
  Klass::secondary_supers_offset_in_bytes() + 
klassOopDesc::header_size() * HeapWordSize

The proposal is to move all these size adjustments into the 
*Klass:*_offset_in_bytes() functions.

More information about the hotspot-dev mailing list