JDK-8340118 : Improve oopDesc::header_size() related methods
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: runtime
  • Priority: P4
  • Status: New
  • Resolution: Unresolved
  • Submitted: 2024-09-13
  • Updated: 2024-09-13
Related Reports
Blocks :  
Description
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();
  }
Comments
I'll probably do this as part of JDK-8305895 if I get to it without breaking stuff (in which case I would close this issue), otherwise this issue serves as a follow-up.
13-09-2024

This blocks, not is blocked-by right? You want to do this first? Thank you for working on this.
13-09-2024