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

sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 9
    • Fix Version/s: 9
    • Component/s: hotspot
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b131

      Description

      Here's the code:

        public long getSize() {
          return Oop.alignObjectSize(getHeaderSize() + Oop.alignObjectOffset(getVtableLen()) +
                                     Oop.alignObjectOffset(getItableLen()) + Oop.alignObjectOffset(getNonstaticOopMapSize()));
        }

      Issue #1: getSize() is suppose to return the number of bytes. getVtableLen(), getItableLen(), and getNonstaticOopMapSize() all return the number or words. Their values need to be scaled by the word size, but aren't.

      Issue #2: If the InstanceKlass is an interface or an anonymous class, and extra word of memory needs to be added to the size.

      Issue #3: There is no test for this code.

      Here's how I showed it isn't working properly:

      bash-4.1$ /java/re/jdk/9/promoted/latest/binaries/linux-x64/bin/java -XX:+UnlockDiagnosticVMOptions -version
      java version "9-ea"
      Java(TM) SE Runtime Environment (build 9-ea+96-2015-12-09-185335.javare.4030)
      Java HotSpot(TM) 64-Bit Server VM (build 9-ea+96-2015-12-09-185335.javare.4030, mixed mode)

      bash-4.1$ /java/re/jdk/9/promoted/latest/binaries/linux-x64/bin/java -XX:+UnlockDiagnosticVMOptions -cp /local/export/tests/ HelloWorld -wait &
      [1] 28623
      Hello world.

      # Note for the list of classes in the jcmd output below, I pruned out all but the 3 I later use with CLHSDB
      bash-4.1$ /local/ws/jdk9/hs-rt/build/linux-x86-normal-clientANDserverANDminimal1-slowdebug/jdk/bin/jcmd HelloWorld GC.class_stats VTab,ITab,OopMap,KlassBytes
      28623:
      Index Super KlassBytes VTab ITab OopMap ClassName
         37 -1 496 40 16 0 java.lang.Object
         55 383 1384 472 464 8 java.util.Vector
        517 384 936 248 232 16 sun.util.PreHashedMap
      Index Super KlassBytes VTab ITab OopMap ClassName

      bash-4.1$ /java/re/jdk/9/promoted/latest/binaries/linux-x64/bin/java sun.jvm.hotspot.CLHSDB 28745
      Attaching to process 28745, please wait...
      hsdb> jseval "sapkg.utilities.SystemDictionaryHelper.findInstanceKlass('java.lang.Object').getSize();"
      456 <--- Should be 496
      hsdb> jseval "sapkg.utilities.SystemDictionaryHelper.findInstanceKlass('java.util.Vector').getSize();"
      576 <--- Should be 1384
      hsdb> jseval "sapkg.utilities.SystemDictionaryHelper.findInstanceKlass('sun.util.PreHashedMap').getSize();"
      512 <--- Should be 936

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              jgeorge Jini George (Inactive)
              Reporter:
              cjplummer Chris Plummer
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: