As noted by Stefan Karlsson in the review for JDK-8305895:
there are many places that calculates almost the same thing (header_size_in_bytes() and related methods), and it might be good to limit the number of places we do similar calculations.
I'm wondering if it wouldn't be better for readability to structure the code as follows:
static int header_size_in_bytes() {
if (UseCompactObjectHeaders) {
return sizeof(markWord);
} else if (UseCompressedClassPointers) {
return sizeof(markWord) + sizeof(narrowKlass);
} else {
return sizeof(markWord) + sizeof(Klass*);
}
}
// Size of object header, aligned to platform wordSize
static int header_size() {
return align_up(header_size_in_bytes(), HeapWordSize) / HeapWordSize;
}
...
static int base_offset_in_bytes() {
return header_size_in_bytes();
}
there are many places that calculates almost the same thing (header_size_in_bytes() and related methods), and it might be good to limit the number of places we do similar calculations.
I'm wondering if it wouldn't be better for readability to structure the code as follows:
static int header_size_in_bytes() {
if (UseCompactObjectHeaders) {
return sizeof(markWord);
} else if (UseCompressedClassPointers) {
return sizeof(markWord) + sizeof(narrowKlass);
} else {
return sizeof(markWord) + sizeof(Klass*);
}
}
// Size of object header, aligned to platform wordSize
static int header_size() {
return align_up(header_size_in_bytes(), HeapWordSize) / HeapWordSize;
}
...
static int base_offset_in_bytes() {
return header_size_in_bytes();
}
- is blocked by
-
JDK-8305895 Implement JEP 450: Compact Object Headers (Experimental)
- Resolved