Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8340118

Improve oopDesc::header_size() related methods

XMLWordPrintable

      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();
        }

            rkennke Roman Kennke
            rkennke Roman Kennke
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: