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.
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.
- relates to
-
JDK-6523674 Allow different styles of java object fields allocation
- Resolved
-
JDK-8024912 Subclass instance fields are laid out with alignment gaps
- Closed