Mercurial > hg > truffle
comparison agent/src/share/classes/sun/jvm/hotspot/gc_implementation/g1/G1CollectedHeap.java @ 20404:227a9e5e4b4a
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
author | sjohanss |
---|---|
date | Fri, 05 Sep 2014 09:49:19 +0200 |
parents | a8ea2f110d87 |
children |
comparison
equal
deleted
inserted
replaced
20403:8ec8971f511a | 20404:227a9e5e4b4a |
---|---|
34 import sun.jvm.hotspot.memory.SharedHeap; | 34 import sun.jvm.hotspot.memory.SharedHeap; |
35 import sun.jvm.hotspot.memory.SpaceClosure; | 35 import sun.jvm.hotspot.memory.SpaceClosure; |
36 import sun.jvm.hotspot.runtime.VM; | 36 import sun.jvm.hotspot.runtime.VM; |
37 import sun.jvm.hotspot.runtime.VMObjectFactory; | 37 import sun.jvm.hotspot.runtime.VMObjectFactory; |
38 import sun.jvm.hotspot.types.AddressField; | 38 import sun.jvm.hotspot.types.AddressField; |
39 import sun.jvm.hotspot.types.CIntegerField; | |
40 import sun.jvm.hotspot.types.Type; | 39 import sun.jvm.hotspot.types.Type; |
41 import sun.jvm.hotspot.types.TypeDataBase; | 40 import sun.jvm.hotspot.types.TypeDataBase; |
42 | 41 |
43 // Mirror class for G1CollectedHeap. | 42 // Mirror class for G1CollectedHeap. |
44 | 43 |
45 public class G1CollectedHeap extends SharedHeap { | 44 public class G1CollectedHeap extends SharedHeap { |
46 // HeapRegionManager _hrm; | 45 // HeapRegionManager _hrm; |
47 static private long hrmFieldOffset; | 46 static private long hrmFieldOffset; |
48 // MemRegion _g1_reserved; | 47 // MemRegion _g1_reserved; |
49 static private long g1ReservedFieldOffset; | 48 static private long g1ReservedFieldOffset; |
50 // size_t _summary_bytes_used; | 49 // G1Allocator* _allocator |
51 static private CIntegerField summaryBytesUsedField; | 50 static private AddressField g1Allocator; |
52 // G1MonitoringSupport* _g1mm; | 51 // G1MonitoringSupport* _g1mm; |
53 static private AddressField g1mmField; | 52 static private AddressField g1mmField; |
54 // HeapRegionSet _old_set; | 53 // HeapRegionSet _old_set; |
55 static private long oldSetFieldOffset; | 54 static private long oldSetFieldOffset; |
56 // HeapRegionSet _humongous_set; | 55 // HeapRegionSet _humongous_set; |
66 | 65 |
67 static private synchronized void initialize(TypeDataBase db) { | 66 static private synchronized void initialize(TypeDataBase db) { |
68 Type type = db.lookupType("G1CollectedHeap"); | 67 Type type = db.lookupType("G1CollectedHeap"); |
69 | 68 |
70 hrmFieldOffset = type.getField("_hrm").getOffset(); | 69 hrmFieldOffset = type.getField("_hrm").getOffset(); |
71 summaryBytesUsedField = type.getCIntegerField("_summary_bytes_used"); | 70 g1Allocator = type.getAddressField("_allocator"); |
72 g1mmField = type.getAddressField("_g1mm"); | 71 g1mmField = type.getAddressField("_g1mm"); |
73 oldSetFieldOffset = type.getField("_old_set").getOffset(); | 72 oldSetFieldOffset = type.getField("_old_set").getOffset(); |
74 humongousSetFieldOffset = type.getField("_humongous_set").getOffset(); | 73 humongousSetFieldOffset = type.getField("_humongous_set").getOffset(); |
75 } | 74 } |
76 | 75 |
77 public long capacity() { | 76 public long capacity() { |
78 return hrm().capacity(); | 77 return hrm().capacity(); |
79 } | 78 } |
80 | 79 |
81 public long used() { | 80 public long used() { |
82 return summaryBytesUsedField.getValue(addr); | 81 return allocator().getSummaryBytes(); |
83 } | 82 } |
84 | 83 |
85 public long n_regions() { | 84 public long n_regions() { |
86 return hrm().length(); | 85 return hrm().length(); |
87 } | 86 } |
93 } | 92 } |
94 | 93 |
95 public G1MonitoringSupport g1mm() { | 94 public G1MonitoringSupport g1mm() { |
96 Address g1mmAddr = g1mmField.getValue(addr); | 95 Address g1mmAddr = g1mmField.getValue(addr); |
97 return (G1MonitoringSupport) VMObjectFactory.newObject(G1MonitoringSupport.class, g1mmAddr); | 96 return (G1MonitoringSupport) VMObjectFactory.newObject(G1MonitoringSupport.class, g1mmAddr); |
97 } | |
98 | |
99 public G1Allocator allocator() { | |
100 Address g1AllocatorAddr = g1Allocator.getValue(addr); | |
101 return (G1Allocator) VMObjectFactory.newObject(G1Allocator.class, g1AllocatorAddr); | |
98 } | 102 } |
99 | 103 |
100 public HeapRegionSetBase oldSet() { | 104 public HeapRegionSetBase oldSet() { |
101 Address oldSetAddr = addr.addOffsetTo(oldSetFieldOffset); | 105 Address oldSetAddr = addr.addOffsetTo(oldSetFieldOffset); |
102 return (HeapRegionSetBase) VMObjectFactory.newObject(HeapRegionSetBase.class, | 106 return (HeapRegionSetBase) VMObjectFactory.newObject(HeapRegionSetBase.class, |