RFR: Report fwdptr size in JNI GetObjectSize

Aleksey Shipilev shade at redhat.com
Mon Dec 11 17:12:41 UTC 2017


http://cr.openjdk.java.net/~shade/shenandoah/objsize-fwdptr/webrev.01/

To make cross-GC comparisons more convenient, it makes sense to let Shenandoah report JNI
GetObjectSize added up with forwarding pointer. This seems innocuous, because it is specified to
return implementation-specific value ("This size is an implementation-specific approximation of the
amount of storage consumed by this object"), and it does not touch "actual" oopDesc::size() which is
used everywhere else in critical VM code.

Testing: hotspot_gc_shenandoah, eyeballing JOL output for different GCs

# -XX:+UseParallelGC

java.lang.String object internals:
 OFFSET  SIZE     TYPE DESCRIPTION                               VALUE
      0     4          (object header)                           05 00 00 00
      4     4          (object header)                           00 00 00 00
      8     4          (object header)                           18 16 00 00
     12     4   byte[] String.value                              []
     16     4      int String.hash                               0
     20     1     byte String.coder                              0
     21     3          (loss due to the next object alignment)
Instance size: 24 bytes
Space losses: 0 bytes internal + 3 bytes external = 3 bytes total

# -XX:+UseShenandoahGC

java.lang.String object internals:
 OFFSET  SIZE     TYPE DESCRIPTION                               VALUE
      0     4          (object header)                           05 00 00 00
      4     4          (object header)                           00 00 00 00
      8     4          (object header)                           18 16 00 00
     12     4   byte[] String.value                              []
     16     4      int String.hash                               0
     20     1     byte String.coder                              0
     21    11          (loss due to the next object alignment)
Instance size: 32 bytes
Space losses: 0 bytes internal + 11 bytes external = 11 bytes total


Thanks,
-Aleksey



More information about the shenandoah-dev mailing list