diff --git a/agent/src/share/classes/sun/jvm/hotspot/oops/ObjectHeap.java b/agent/src/share/classes/sun/jvm/hotspot/oops/ObjectHeap.java index 59923078d3dd2748f2967f2059cf22b2e094ee44..f944188f4d16800752f3e783c724a1e12fca2988 100644 --- a/agent/src/share/classes/sun/jvm/hotspot/oops/ObjectHeap.java +++ b/agent/src/share/classes/sun/jvm/hotspot/oops/ObjectHeap.java @@ -467,7 +467,7 @@ public class ObjectHeap { liveRegions.add(tlab.start()); liveRegions.add(tlab.start()); liveRegions.add(tlab.top()); - liveRegions.add(tlab.end()); + liveRegions.add(tlab.hardEnd()); } } } diff --git a/agent/src/share/classes/sun/jvm/hotspot/runtime/ThreadLocalAllocBuffer.java b/agent/src/share/classes/sun/jvm/hotspot/runtime/ThreadLocalAllocBuffer.java index 381b53dededea7ee9300430c9fe75f28f2b76825..738dc94fa9179f1689f0cfe6be57b48878385399 100644 --- a/agent/src/share/classes/sun/jvm/hotspot/runtime/ThreadLocalAllocBuffer.java +++ b/agent/src/share/classes/sun/jvm/hotspot/runtime/ThreadLocalAllocBuffer.java @@ -27,6 +27,7 @@ package sun.jvm.hotspot.runtime; import java.io.*; import java.util.*; import sun.jvm.hotspot.debugger.*; +import sun.jvm.hotspot.oops.*; import sun.jvm.hotspot.types.*; /**
ThreadLocalAllocBuffer: a descriptor for thread-local storage
@@ -62,9 +63,22 @@ public class ThreadLocalAllocBuffer extends VMObject {
super(addr);
}
- public Address start() { return startField.getValue(addr); }
- public Address end() { return endField.getValue(addr); }
- public Address top() { return topField.getValue(addr); }
+ public Address start() { return startField.getValue(addr); }
+ public Address end() { return endField.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
interact with GC in reflective system, but necessary for the
diff --git a/agent/src/share/classes/sun/jvm/hotspot/runtime/VM.java b/agent/src/share/classes/sun/jvm/hotspot/runtime/VM.java
index 5531980b1f8dffa17a03622ca1759284f2210517..80464a10bb0677506e4a61459e44859daa18928d 100644
--- a/agent/src/share/classes/sun/jvm/hotspot/runtime/VM.java
+++ b/agent/src/share/classes/sun/jvm/hotspot/runtime/VM.java
@@ -114,6 +114,7 @@ public class VM {
private int invalidOSREntryBCI;
private ReversePtrs revPtrs;
private VMRegImpl vmregImpl;
+ private int reserveForAllocationPrefetch;
// System.getProperties from debuggee VM
private Properties sysProps;
@@ -293,6 +294,10 @@ public class VM {
vmRelease = CStringUtilities.getString(releaseAddr);
Address vmInternalInfoAddr = vmVersion.getAddressField("_s_internal_vm_info_string").getValue();
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) {
throw new RuntimeException("can't determine target's VM version : " + exp.getMessage());
}
@@ -778,6 +783,10 @@ public class VM {
return vmInternalInfo;
}
+ public int getReserveForAllocationPrefetch() {
+ return reserveForAllocationPrefetch;
+ }
+
public boolean isSharingEnabled() {
if (sharingEnabled == null) {
Flag flag = getCommandLineFlag("UseSharedSpaces");
diff --git a/src/share/vm/runtime/vmStructs.cpp b/src/share/vm/runtime/vmStructs.cpp
index 70e5d2b92818d73cfcb4024378700d5db00f5cf5..1a30f7554e71d2173ad7da65290e8bb1f40a6578 100644
--- a/src/share/vm/runtime/vmStructs.cpp
+++ b/src/share/vm/runtime/vmStructs.cpp
@@ -1161,6 +1161,7 @@ typedef BinaryTreeDictionary