26
27 import sun.jvm.hotspot.gc.shared.CollectedHeap;
28 import sun.jvm.hotspot.gc.shared.CollectedHeapName;
29 import sun.jvm.hotspot.gc.shared.LiveRegionsClosure;
30 import sun.jvm.hotspot.debugger.Address;
31 import sun.jvm.hotspot.runtime.VM;
32 import sun.jvm.hotspot.runtime.VMObjectFactory;
33 import sun.jvm.hotspot.types.AddressField;
34 import sun.jvm.hotspot.types.Type;
35 import sun.jvm.hotspot.types.TypeDataBase;
36 import sun.jvm.hotspot.memory.MemRegion;
37 import sun.jvm.hotspot.types.CIntegerField;
38 import sun.jvm.hotspot.utilities.BitMapInterface;
39
40 import java.io.PrintStream;
41 import sun.jvm.hotspot.utilities.Observable;
42 import sun.jvm.hotspot.utilities.Observer;
43
44 public class ShenandoahHeap extends CollectedHeap {
45 private static CIntegerField numRegions;
46 private static CIntegerField used;
47 private static CIntegerField committed;
48 private static AddressField regions;
49 private static CIntegerField logMinObjAlignmentInBytes;
50
51 private static long regionPtrFieldSize;
52 static {
53 VM.registerVMInitializedObserver(new Observer() {
54 public void update(Observable o, Object data) {
55 initialize(VM.getVM().getTypeDataBase());
56 }
57 });
58 }
59
60 private static synchronized void initialize(TypeDataBase db) {
61 Type type = db.lookupType("ShenandoahHeap");
62 numRegions = type.getCIntegerField("_num_regions");
63 used = type.getCIntegerField("_used");
64 committed = type.getCIntegerField("_committed");
65 regions = type.getAddressField("_regions");
66 logMinObjAlignmentInBytes = type.getCIntegerField("_log_min_obj_alignment_in_bytes");
67
68 Type regionPtrType = db.lookupType("ShenandoahHeapRegion*");
69 regionPtrFieldSize = regionPtrType.getSize();
70 }
71
72 public ShenandoahHeap(Address addr) {
73 super(addr);
74 }
75
76 @Override
77 public CollectedHeapName kind() {
78 return CollectedHeapName.SHENANDOAH;
79 }
80
81 public long numOfRegions() {
82 return numRegions.getValue(addr);
83 }
84
85 @Override
86 public long capacity() {
87 return numOfRegions() * ShenandoahHeapRegion.regionSizeBytes();
88 }
89
90 @Override
91 public long used() {
92 return used.getValue(addr);
93 }
94
95 public long committed() {
96 return committed.getValue(addr);
97 }
98
99 public int getLogMinObjAlignmentInBytes() {
100 return logMinObjAlignmentInBytes.getJInt(addr);
101 }
102
103 public ShenandoahHeapRegion getRegion(long index) {
104 if (index < numOfRegions()) {
105 Address arrayAddr = regions.getValue(addr);
106 Address regAddr = arrayAddr.getAddressAt(index * regionPtrFieldSize);
107 ShenandoahHeapRegion region = VMObjectFactory.newObject(ShenandoahHeapRegion.class, regAddr);
108 region.setHeap(this);
109 return region;
110 }
111 return null;
112 }
|
26
27 import sun.jvm.hotspot.gc.shared.CollectedHeap;
28 import sun.jvm.hotspot.gc.shared.CollectedHeapName;
29 import sun.jvm.hotspot.gc.shared.LiveRegionsClosure;
30 import sun.jvm.hotspot.debugger.Address;
31 import sun.jvm.hotspot.runtime.VM;
32 import sun.jvm.hotspot.runtime.VMObjectFactory;
33 import sun.jvm.hotspot.types.AddressField;
34 import sun.jvm.hotspot.types.Type;
35 import sun.jvm.hotspot.types.TypeDataBase;
36 import sun.jvm.hotspot.memory.MemRegion;
37 import sun.jvm.hotspot.types.CIntegerField;
38 import sun.jvm.hotspot.utilities.BitMapInterface;
39
40 import java.io.PrintStream;
41 import sun.jvm.hotspot.utilities.Observable;
42 import sun.jvm.hotspot.utilities.Observer;
43
44 public class ShenandoahHeap extends CollectedHeap {
45 private static CIntegerField numRegions;
46 private static AddressField globalGeneration;
47 private static CIntegerField committed;
48 private static AddressField regions;
49 private static CIntegerField logMinObjAlignmentInBytes;
50
51 private static long regionPtrFieldSize;
52 static {
53 VM.registerVMInitializedObserver(new Observer() {
54 public void update(Observable o, Object data) {
55 initialize(VM.getVM().getTypeDataBase());
56 }
57 });
58 }
59
60 private static synchronized void initialize(TypeDataBase db) {
61 Type type = db.lookupType("ShenandoahHeap");
62 numRegions = type.getCIntegerField("_num_regions");
63 globalGeneration = type.getAddressField("_global_generation");
64 committed = type.getCIntegerField("_committed");
65 regions = type.getAddressField("_regions");
66 logMinObjAlignmentInBytes = type.getCIntegerField("_log_min_obj_alignment_in_bytes");
67
68 Type regionPtrType = db.lookupType("ShenandoahHeapRegion*");
69 regionPtrFieldSize = regionPtrType.getSize();
70 }
71
72 public ShenandoahHeap(Address addr) {
73 super(addr);
74 }
75
76 @Override
77 public CollectedHeapName kind() {
78 return CollectedHeapName.SHENANDOAH;
79 }
80
81 public long numOfRegions() {
82 return numRegions.getValue(addr);
83 }
84
85 @Override
86 public long capacity() {
87 return numOfRegions() * ShenandoahHeapRegion.regionSizeBytes();
88 }
89
90 @Override
91 public long used() {
92 Address globalGenerationAddress = globalGeneration.getValue(addr);
93 ShenandoahGeneration global = VMObjectFactory.newObject(ShenandoahGeneration.class, globalGenerationAddress);
94 return global.used();
95 }
96
97 public long committed() {
98 return committed.getValue(addr);
99 }
100
101 public int getLogMinObjAlignmentInBytes() {
102 return logMinObjAlignmentInBytes.getJInt(addr);
103 }
104
105 public ShenandoahHeapRegion getRegion(long index) {
106 if (index < numOfRegions()) {
107 Address arrayAddr = regions.getValue(addr);
108 Address regAddr = arrayAddr.getAddressAt(index * regionPtrFieldSize);
109 ShenandoahHeapRegion region = VMObjectFactory.newObject(ShenandoahHeapRegion.class, regAddr);
110 region.setHeap(this);
111 return region;
112 }
113 return null;
114 }
|