8004710: NPG: jmap could throw sun.jvm.hotspot.types.WrongTypeException after PermGen removal

When calculating live object regions, make sure that the alignment reserve, at the end of a TLAB, is excluded.

Reviewed-by: jmasa, brutisso
This commit is contained in:
Stefan Karlsson 2013-01-29 10:51:33 +01:00
parent 6f5991fa38
commit e8860a177b
4 changed files with 28 additions and 4 deletions

View file

@ -467,7 +467,7 @@ public class ObjectHeap {
liveRegions.add(tlab.start()); liveRegions.add(tlab.start());
liveRegions.add(tlab.start()); liveRegions.add(tlab.start());
liveRegions.add(tlab.top()); liveRegions.add(tlab.top());
liveRegions.add(tlab.end()); liveRegions.add(tlab.hardEnd());
} }
} }
} }

View file

@ -27,6 +27,7 @@ package sun.jvm.hotspot.runtime;
import java.io.*; import java.io.*;
import java.util.*; import java.util.*;
import sun.jvm.hotspot.debugger.*; import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.oops.*;
import sun.jvm.hotspot.types.*; import sun.jvm.hotspot.types.*;
/** <P> ThreadLocalAllocBuffer: a descriptor for thread-local storage /** <P> ThreadLocalAllocBuffer: a descriptor for thread-local storage
@ -65,6 +66,19 @@ public class ThreadLocalAllocBuffer extends VMObject {
public Address start() { return startField.getValue(addr); } public Address start() { return startField.getValue(addr); }
public Address end() { return endField.getValue(addr); } public Address end() { return endField.getValue(addr); }
public Address top() { return topField.getValue(addr); } public Address top() { return topField.getValue(addr); }
public Address hardEnd() { return end().addOffsetTo(alignmentReserve()); }
private long alignmentReserve() {
return Oop.alignObjectSize(endReserve());
}
private long endReserve() {
long minFillerArraySize = Array.baseOffsetInBytes(BasicType.T_INT);
long reserveForAllocationPrefetch = VM.getVM().getReserveForAllocationPrefetch();
long heapWordSize = VM.getVM().getHeapWordSize();
return Math.max(minFillerArraySize, reserveForAllocationPrefetch * heapWordSize);
}
/** Support for iteration over heap -- not sure how this will /** Support for iteration over heap -- not sure how this will
interact with GC in reflective system, but necessary for the interact with GC in reflective system, but necessary for the

View file

@ -114,6 +114,7 @@ public class VM {
private int invalidOSREntryBCI; private int invalidOSREntryBCI;
private ReversePtrs revPtrs; private ReversePtrs revPtrs;
private VMRegImpl vmregImpl; private VMRegImpl vmregImpl;
private int reserveForAllocationPrefetch;
// System.getProperties from debuggee VM // System.getProperties from debuggee VM
private Properties sysProps; private Properties sysProps;
@ -293,6 +294,10 @@ public class VM {
vmRelease = CStringUtilities.getString(releaseAddr); vmRelease = CStringUtilities.getString(releaseAddr);
Address vmInternalInfoAddr = vmVersion.getAddressField("_s_internal_vm_info_string").getValue(); Address vmInternalInfoAddr = vmVersion.getAddressField("_s_internal_vm_info_string").getValue();
vmInternalInfo = CStringUtilities.getString(vmInternalInfoAddr); vmInternalInfo = CStringUtilities.getString(vmInternalInfoAddr);
CIntegerType intType = (CIntegerType) db.lookupType("int");
CIntegerField reserveForAllocationPrefetchField = vmVersion.getCIntegerField("_reserve_for_allocation_prefetch");
reserveForAllocationPrefetch = (int)reserveForAllocationPrefetchField.getCInteger(intType);
} catch (Exception exp) { } catch (Exception exp) {
throw new RuntimeException("can't determine target's VM version : " + exp.getMessage()); throw new RuntimeException("can't determine target's VM version : " + exp.getMessage());
} }
@ -778,6 +783,10 @@ public class VM {
return vmInternalInfo; return vmInternalInfo;
} }
public int getReserveForAllocationPrefetch() {
return reserveForAllocationPrefetch;
}
public boolean isSharingEnabled() { public boolean isSharingEnabled() {
if (sharingEnabled == null) { if (sharingEnabled == null) {
Flag flag = getCommandLineFlag("UseSharedSpaces"); Flag flag = getCommandLineFlag("UseSharedSpaces");

View file

@ -1161,6 +1161,7 @@ typedef BinaryTreeDictionary<Metablock, FreeList> MetablockTreeDictionary;
static_field(Abstract_VM_Version, _vm_major_version, int) \ static_field(Abstract_VM_Version, _vm_major_version, int) \
static_field(Abstract_VM_Version, _vm_minor_version, int) \ static_field(Abstract_VM_Version, _vm_minor_version, int) \
static_field(Abstract_VM_Version, _vm_build_number, int) \ static_field(Abstract_VM_Version, _vm_build_number, int) \
static_field(Abstract_VM_Version, _reserve_for_allocation_prefetch, int) \
\ \
static_field(JDK_Version, _current, JDK_Version) \ static_field(JDK_Version, _current, JDK_Version) \
nonstatic_field(JDK_Version, _partially_initialized, bool) \ nonstatic_field(JDK_Version, _partially_initialized, bool) \