18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 package sun.jvm.hotspot.memory;
26
27 import java.io.PrintStream;
28 import sun.jvm.hotspot.utilities.Observable;
29 import sun.jvm.hotspot.utilities.Observer;
30
31 import sun.jvm.hotspot.debugger.Address;
32 import sun.jvm.hotspot.debugger.OopHandle;
33 import sun.jvm.hotspot.gc.epsilon.EpsilonHeap;
34 import sun.jvm.hotspot.gc.g1.G1CollectedHeap;
35 import sun.jvm.hotspot.gc.parallel.ParallelScavengeHeap;
36 import sun.jvm.hotspot.gc.serial.SerialHeap;
37 import sun.jvm.hotspot.gc.shared.CollectedHeap;
38 import sun.jvm.hotspot.gc.shenandoah.ShenandoahHeap;
39 import sun.jvm.hotspot.gc.x.XCollectedHeap;
40 import sun.jvm.hotspot.gc.z.ZCollectedHeap;
41 import sun.jvm.hotspot.oops.Oop;
42 import sun.jvm.hotspot.runtime.BasicType;
43 import sun.jvm.hotspot.runtime.VM;
44 import sun.jvm.hotspot.runtime.VMObject;
45 import sun.jvm.hotspot.runtime.VirtualConstructor;
46 import sun.jvm.hotspot.types.AddressField;
47 import sun.jvm.hotspot.types.CIntegerField;
48 import sun.jvm.hotspot.types.Type;
49 import sun.jvm.hotspot.types.TypeDataBase;
50
51
52 public class Universe {
53 private static AddressField collectedHeapField;
54 private static VirtualConstructor heapConstructor;
55
56 static {
57 VM.registerVMInitializedObserver(new Observer() {
73 private static void addHeapTypeIfInDB(TypeDataBase db, Class<? extends VMObject> heapClass) {
74 String heapName = heapClass.getSimpleName();
75 if (typeExists(db, heapName)) {
76 heapConstructor.addMapping(heapName, heapClass);
77 }
78 }
79
80 private static synchronized void initialize(TypeDataBase db) {
81 Type type = db.lookupType("Universe");
82
83 collectedHeapField = type.getAddressField("_collectedHeap");
84
85 heapConstructor = new VirtualConstructor(db);
86 addHeapTypeIfInDB(db, SerialHeap.class);
87 addHeapTypeIfInDB(db, ParallelScavengeHeap.class);
88 addHeapTypeIfInDB(db, G1CollectedHeap.class);
89 addHeapTypeIfInDB(db, EpsilonHeap.class);
90 addHeapTypeIfInDB(db, XCollectedHeap.class);
91 addHeapTypeIfInDB(db, ZCollectedHeap.class);
92 addHeapTypeIfInDB(db, ShenandoahHeap.class);
93
94 UniverseExt.initialize(heapConstructor);
95 }
96
97 public Universe() {
98 }
99 public CollectedHeap heap() {
100 return (CollectedHeap) heapConstructor.instantiateWrapperFor(collectedHeapField.getValue());
101 }
102
103
104 /** Returns "TRUE" iff "p" points into the allocated area of the heap. */
105 public boolean isIn(Address p) {
106 return heap().isIn(p);
107 }
108
109 /** Returns "TRUE" iff "p" points into the reserved area of the heap. */
110 public boolean isInReserved(Address p) {
111 return heap().isInReserved(p);
112 }
|
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 package sun.jvm.hotspot.memory;
26
27 import java.io.PrintStream;
28 import sun.jvm.hotspot.utilities.Observable;
29 import sun.jvm.hotspot.utilities.Observer;
30
31 import sun.jvm.hotspot.debugger.Address;
32 import sun.jvm.hotspot.debugger.OopHandle;
33 import sun.jvm.hotspot.gc.epsilon.EpsilonHeap;
34 import sun.jvm.hotspot.gc.g1.G1CollectedHeap;
35 import sun.jvm.hotspot.gc.parallel.ParallelScavengeHeap;
36 import sun.jvm.hotspot.gc.serial.SerialHeap;
37 import sun.jvm.hotspot.gc.shared.CollectedHeap;
38 import sun.jvm.hotspot.gc.shenandoah.ShenandoahGenerationalHeap;
39 import sun.jvm.hotspot.gc.shenandoah.ShenandoahHeap;
40 import sun.jvm.hotspot.gc.x.XCollectedHeap;
41 import sun.jvm.hotspot.gc.z.ZCollectedHeap;
42 import sun.jvm.hotspot.oops.Oop;
43 import sun.jvm.hotspot.runtime.BasicType;
44 import sun.jvm.hotspot.runtime.VM;
45 import sun.jvm.hotspot.runtime.VMObject;
46 import sun.jvm.hotspot.runtime.VirtualConstructor;
47 import sun.jvm.hotspot.types.AddressField;
48 import sun.jvm.hotspot.types.CIntegerField;
49 import sun.jvm.hotspot.types.Type;
50 import sun.jvm.hotspot.types.TypeDataBase;
51
52
53 public class Universe {
54 private static AddressField collectedHeapField;
55 private static VirtualConstructor heapConstructor;
56
57 static {
58 VM.registerVMInitializedObserver(new Observer() {
74 private static void addHeapTypeIfInDB(TypeDataBase db, Class<? extends VMObject> heapClass) {
75 String heapName = heapClass.getSimpleName();
76 if (typeExists(db, heapName)) {
77 heapConstructor.addMapping(heapName, heapClass);
78 }
79 }
80
81 private static synchronized void initialize(TypeDataBase db) {
82 Type type = db.lookupType("Universe");
83
84 collectedHeapField = type.getAddressField("_collectedHeap");
85
86 heapConstructor = new VirtualConstructor(db);
87 addHeapTypeIfInDB(db, SerialHeap.class);
88 addHeapTypeIfInDB(db, ParallelScavengeHeap.class);
89 addHeapTypeIfInDB(db, G1CollectedHeap.class);
90 addHeapTypeIfInDB(db, EpsilonHeap.class);
91 addHeapTypeIfInDB(db, XCollectedHeap.class);
92 addHeapTypeIfInDB(db, ZCollectedHeap.class);
93 addHeapTypeIfInDB(db, ShenandoahHeap.class);
94 addHeapTypeIfInDB(db, ShenandoahGenerationalHeap.class);
95
96 UniverseExt.initialize(heapConstructor);
97 }
98
99 public Universe() {
100 }
101 public CollectedHeap heap() {
102 return (CollectedHeap) heapConstructor.instantiateWrapperFor(collectedHeapField.getValue());
103 }
104
105
106 /** Returns "TRUE" iff "p" points into the allocated area of the heap. */
107 public boolean isIn(Address p) {
108 return heap().isIn(p);
109 }
110
111 /** Returns "TRUE" iff "p" points into the reserved area of the heap. */
112 public boolean isInReserved(Address p) {
113 return heap().isInReserved(p);
114 }
|