aboutsummaryrefslogtreecommitdiff
path: root/agent
diff options
context:
space:
mode:
authorsjohanss <none@none>2014-09-05 09:49:19 +0200
committersjohanss <none@none>2014-09-05 09:49:19 +0200
commit182bb17f33a0dc55195ff487216b1e828fac5b52 (patch)
tree10240e00c61cccf0c49cbcfeecffde7325a967fd /agent
parented7fb99c1c988043a032f37734fda89c7ece86db (diff)
downloadjdk8u_hotspot-182bb17f33a0dc55195ff487216b1e828fac5b52.tar.gz
8057536: Refactor G1 to allow context specific allocations
Summary: Splitting out a g1 allocator class to simply specialized allocators which can associate each allocation with a given context. Reviewed-by: mgerdin, brutisso
Diffstat (limited to 'agent')
-rw-r--r--agent/src/share/classes/sun/jvm/hotspot/gc_implementation/g1/G1Allocator.java40
-rw-r--r--agent/src/share/classes/sun/jvm/hotspot/gc_implementation/g1/G1CollectedHeap.java14
2 files changed, 49 insertions, 5 deletions
diff --git a/agent/src/share/classes/sun/jvm/hotspot/gc_implementation/g1/G1Allocator.java b/agent/src/share/classes/sun/jvm/hotspot/gc_implementation/g1/G1Allocator.java
new file mode 100644
index 000000000..1195eed06
--- /dev/null
+++ b/agent/src/share/classes/sun/jvm/hotspot/gc_implementation/g1/G1Allocator.java
@@ -0,0 +1,40 @@
+package sun.jvm.hotspot.gc_implementation.g1;
+
+import java.util.Observable;
+import java.util.Observer;
+
+import sun.jvm.hotspot.debugger.Address;
+import sun.jvm.hotspot.runtime.VM;
+import sun.jvm.hotspot.runtime.VMObject;
+import sun.jvm.hotspot.types.CIntegerField;
+import sun.jvm.hotspot.types.Type;
+import sun.jvm.hotspot.types.TypeDataBase;
+
+public class G1Allocator extends VMObject {
+
+ //size_t _summary_bytes_used;
+ static private CIntegerField summaryBytesUsedField;
+
+ static {
+ VM.registerVMInitializedObserver(new Observer() {
+ public void update(Observable o, Object data) {
+ initialize(VM.getVM().getTypeDataBase());
+ }
+ });
+ }
+
+ static private synchronized void initialize(TypeDataBase db) {
+ Type type = db.lookupType("G1Allocator");
+
+ summaryBytesUsedField = type.getCIntegerField("_summary_bytes_used");
+ }
+
+ public long getSummaryBytes() {
+ return summaryBytesUsedField.getValue(addr);
+ }
+
+ public G1Allocator(Address addr) {
+ super(addr);
+
+ }
+}
diff --git a/agent/src/share/classes/sun/jvm/hotspot/gc_implementation/g1/G1CollectedHeap.java b/agent/src/share/classes/sun/jvm/hotspot/gc_implementation/g1/G1CollectedHeap.java
index e177468e5..b0b6d8462 100644
--- a/agent/src/share/classes/sun/jvm/hotspot/gc_implementation/g1/G1CollectedHeap.java
+++ b/agent/src/share/classes/sun/jvm/hotspot/gc_implementation/g1/G1CollectedHeap.java
@@ -36,7 +36,6 @@ import sun.jvm.hotspot.memory.SpaceClosure;
import sun.jvm.hotspot.runtime.VM;
import sun.jvm.hotspot.runtime.VMObjectFactory;
import sun.jvm.hotspot.types.AddressField;
-import sun.jvm.hotspot.types.CIntegerField;
import sun.jvm.hotspot.types.Type;
import sun.jvm.hotspot.types.TypeDataBase;
@@ -47,8 +46,8 @@ public class G1CollectedHeap extends SharedHeap {
static private long hrmFieldOffset;
// MemRegion _g1_reserved;
static private long g1ReservedFieldOffset;
- // size_t _summary_bytes_used;
- static private CIntegerField summaryBytesUsedField;
+ // G1Allocator* _allocator
+ static private AddressField g1Allocator;
// G1MonitoringSupport* _g1mm;
static private AddressField g1mmField;
// HeapRegionSet _old_set;
@@ -68,7 +67,7 @@ public class G1CollectedHeap extends SharedHeap {
Type type = db.lookupType("G1CollectedHeap");
hrmFieldOffset = type.getField("_hrm").getOffset();
- summaryBytesUsedField = type.getCIntegerField("_summary_bytes_used");
+ g1Allocator = type.getAddressField("_allocator");
g1mmField = type.getAddressField("_g1mm");
oldSetFieldOffset = type.getField("_old_set").getOffset();
humongousSetFieldOffset = type.getField("_humongous_set").getOffset();
@@ -79,7 +78,7 @@ public class G1CollectedHeap extends SharedHeap {
}
public long used() {
- return summaryBytesUsedField.getValue(addr);
+ return allocator().getSummaryBytes();
}
public long n_regions() {
@@ -97,6 +96,11 @@ public class G1CollectedHeap extends SharedHeap {
return (G1MonitoringSupport) VMObjectFactory.newObject(G1MonitoringSupport.class, g1mmAddr);
}
+ public G1Allocator allocator() {
+ Address g1AllocatorAddr = g1Allocator.getValue(addr);
+ return (G1Allocator) VMObjectFactory.newObject(G1Allocator.class, g1AllocatorAddr);
+ }
+
public HeapRegionSetBase oldSet() {
Address oldSetAddr = addr.addOffsetTo(oldSetFieldOffset);
return (HeapRegionSetBase) VMObjectFactory.newObject(HeapRegionSetBase.class,