Tue, 29 Jan 2013 10:51:33 +0100
8004710: NPG: jmap could throw sun.jvm.hotspot.types.WrongTypeException after PermGen removal
Summary: When calculating live object regions, make sure that the alignment reserve, at the end of a TLAB, is excluded.
Reviewed-by: jmasa, brutisso
1.1 --- a/agent/src/share/classes/sun/jvm/hotspot/oops/ObjectHeap.java Thu Jan 03 15:03:27 2013 -0800 1.2 +++ b/agent/src/share/classes/sun/jvm/hotspot/oops/ObjectHeap.java Tue Jan 29 10:51:33 2013 +0100 1.3 @@ -467,7 +467,7 @@ 1.4 liveRegions.add(tlab.start()); 1.5 liveRegions.add(tlab.start()); 1.6 liveRegions.add(tlab.top()); 1.7 - liveRegions.add(tlab.end()); 1.8 + liveRegions.add(tlab.hardEnd()); 1.9 } 1.10 } 1.11 }
2.1 --- a/agent/src/share/classes/sun/jvm/hotspot/runtime/ThreadLocalAllocBuffer.java Thu Jan 03 15:03:27 2013 -0800 2.2 +++ b/agent/src/share/classes/sun/jvm/hotspot/runtime/ThreadLocalAllocBuffer.java Tue Jan 29 10:51:33 2013 +0100 2.3 @@ -27,6 +27,7 @@ 2.4 import java.io.*; 2.5 import java.util.*; 2.6 import sun.jvm.hotspot.debugger.*; 2.7 +import sun.jvm.hotspot.oops.*; 2.8 import sun.jvm.hotspot.types.*; 2.9 2.10 /** <P> ThreadLocalAllocBuffer: a descriptor for thread-local storage 2.11 @@ -62,9 +63,22 @@ 2.12 super(addr); 2.13 } 2.14 2.15 - public Address start() { return startField.getValue(addr); } 2.16 - public Address end() { return endField.getValue(addr); } 2.17 - public Address top() { return topField.getValue(addr); } 2.18 + public Address start() { return startField.getValue(addr); } 2.19 + public Address end() { return endField.getValue(addr); } 2.20 + public Address top() { return topField.getValue(addr); } 2.21 + public Address hardEnd() { return end().addOffsetTo(alignmentReserve()); } 2.22 + 2.23 + private long alignmentReserve() { 2.24 + return Oop.alignObjectSize(endReserve()); 2.25 + } 2.26 + 2.27 + private long endReserve() { 2.28 + long minFillerArraySize = Array.baseOffsetInBytes(BasicType.T_INT); 2.29 + long reserveForAllocationPrefetch = VM.getVM().getReserveForAllocationPrefetch(); 2.30 + long heapWordSize = VM.getVM().getHeapWordSize(); 2.31 + 2.32 + return Math.max(minFillerArraySize, reserveForAllocationPrefetch * heapWordSize); 2.33 + } 2.34 2.35 /** Support for iteration over heap -- not sure how this will 2.36 interact with GC in reflective system, but necessary for the
3.1 --- a/agent/src/share/classes/sun/jvm/hotspot/runtime/VM.java Thu Jan 03 15:03:27 2013 -0800 3.2 +++ b/agent/src/share/classes/sun/jvm/hotspot/runtime/VM.java Tue Jan 29 10:51:33 2013 +0100 3.3 @@ -114,6 +114,7 @@ 3.4 private int invalidOSREntryBCI; 3.5 private ReversePtrs revPtrs; 3.6 private VMRegImpl vmregImpl; 3.7 + private int reserveForAllocationPrefetch; 3.8 3.9 // System.getProperties from debuggee VM 3.10 private Properties sysProps; 3.11 @@ -293,6 +294,10 @@ 3.12 vmRelease = CStringUtilities.getString(releaseAddr); 3.13 Address vmInternalInfoAddr = vmVersion.getAddressField("_s_internal_vm_info_string").getValue(); 3.14 vmInternalInfo = CStringUtilities.getString(vmInternalInfoAddr); 3.15 + 3.16 + CIntegerType intType = (CIntegerType) db.lookupType("int"); 3.17 + CIntegerField reserveForAllocationPrefetchField = vmVersion.getCIntegerField("_reserve_for_allocation_prefetch"); 3.18 + reserveForAllocationPrefetch = (int)reserveForAllocationPrefetchField.getCInteger(intType); 3.19 } catch (Exception exp) { 3.20 throw new RuntimeException("can't determine target's VM version : " + exp.getMessage()); 3.21 } 3.22 @@ -778,6 +783,10 @@ 3.23 return vmInternalInfo; 3.24 } 3.25 3.26 + public int getReserveForAllocationPrefetch() { 3.27 + return reserveForAllocationPrefetch; 3.28 + } 3.29 + 3.30 public boolean isSharingEnabled() { 3.31 if (sharingEnabled == null) { 3.32 Flag flag = getCommandLineFlag("UseSharedSpaces");
4.1 --- a/src/share/vm/runtime/vmStructs.cpp Thu Jan 03 15:03:27 2013 -0800 4.2 +++ b/src/share/vm/runtime/vmStructs.cpp Tue Jan 29 10:51:33 2013 +0100 4.3 @@ -1161,6 +1161,7 @@ 4.4 static_field(Abstract_VM_Version, _vm_major_version, int) \ 4.5 static_field(Abstract_VM_Version, _vm_minor_version, int) \ 4.6 static_field(Abstract_VM_Version, _vm_build_number, int) \ 4.7 + static_field(Abstract_VM_Version, _reserve_for_allocation_prefetch, int) \ 4.8 \ 4.9 static_field(JDK_Version, _current, JDK_Version) \ 4.10 nonstatic_field(JDK_Version, _partially_initialized, bool) \