JDK-7007564 : Align non-static fields size on byte instead of wordSize
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 7
  • Priority: P4
  • Status: Closed
  • Resolution: Won't Fix
  • OS: solaris_10
  • CPU: sparc
  • Submitted: 2010-12-17
  • Updated: 2016-12-15
  • Resolved: 2013-05-22
Related Reports
Relates :  
Relates :  
Description
Currently we round non-static fields size to word and subclass non-static fields start from this aligned offset. As result it could increase total instance size:

Tom Rodriguez wrote:

If I have this hierarchy:

class MDecimal {
  Object _impl;
  bool _dirty;
}

class MByte extends MDecimal {
  byte _value;
}

This is the layout I'm getting:

 - ---- non-static fields (3 words):
 - protected transient '_impl' 'Ljava/lang/Object;' @8
 - protected transient '_dirty' 'Z' @12
 - private '_value' 'B' @16

which bumps the object size up by a double word.

Note: final changes for 6523674 allowed to compact small fields into gaps at the same subclass only.

Comments
Memory saving is too small/
22-05-2013

Thanks, Vladimir. Will do.
22-05-2013

I modified ClassFileParser::layout_fields() to detect any gaps caused by alignment between the first non-static field in child class and the last non-static field in superclass. When loading all classes from rt.jar (about 19000 classes), the total waste of memory due to gaps are only 366bytes. So the saving would be very small if gaps are eliminated.
22-05-2013

Thank you for collecting this data. May be we should closed this RFE since benefit is very small but it will require not small changes in sources.
22-05-2013

I'll look into this. Thanks for forwarding this to me, Vlad.
03-05-2013

Jiangli, could you look on this? I am definitely will not have time for this. Feel free to pass it to other person or close this. May be runtime group has similar RFE.
03-05-2013