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.z.ZCollectedHeap;
40 import sun.jvm.hotspot.oops.Oop;
41 import sun.jvm.hotspot.runtime.BasicType;
42 import sun.jvm.hotspot.runtime.VM;
43 import sun.jvm.hotspot.runtime.VMObject;
44 import sun.jvm.hotspot.runtime.VirtualConstructor;
45 import sun.jvm.hotspot.types.AddressField;
46 import sun.jvm.hotspot.types.CIntegerField;
47 import sun.jvm.hotspot.types.Type;
48 import sun.jvm.hotspot.types.TypeDataBase;
49
50
51 public class Universe {
52 private static AddressField collectedHeapField;
53 private static VirtualConstructor heapConstructor;
54
55 static {
56 VM.registerVMInitializedObserver(new Observer() {
57 public void update(Observable o, Object data) {
58 initialize(VM.getVM().getTypeDataBase());
71
72 private static void addHeapTypeIfInDB(TypeDataBase db, Class<? extends VMObject> heapClass) {
73 String heapName = heapClass.getSimpleName();
74 if (typeExists(db, heapName)) {
75 heapConstructor.addMapping(heapName, heapClass);
76 }
77 }
78
79 private static synchronized void initialize(TypeDataBase db) {
80 Type type = db.lookupType("Universe");
81
82 collectedHeapField = type.getAddressField("_collectedHeap");
83
84 heapConstructor = new VirtualConstructor(db);
85 addHeapTypeIfInDB(db, SerialHeap.class);
86 addHeapTypeIfInDB(db, ParallelScavengeHeap.class);
87 addHeapTypeIfInDB(db, G1CollectedHeap.class);
88 addHeapTypeIfInDB(db, EpsilonHeap.class);
89 addHeapTypeIfInDB(db, ZCollectedHeap.class);
90 addHeapTypeIfInDB(db, ShenandoahHeap.class);
91
92 UniverseExt.initialize(heapConstructor);
93 }
94
95 public Universe() {
96 }
97 public CollectedHeap heap() {
98 return (CollectedHeap) heapConstructor.instantiateWrapperFor(collectedHeapField.getValue());
99 }
100
101
102 /** Returns "TRUE" iff "p" points into the allocated area of the heap. */
103 public boolean isIn(Address p) {
104 return heap().isIn(p);
105 }
106
107 /** Returns "TRUE" iff "p" points into the reserved area of the heap. */
108 public boolean isInReserved(Address p) {
109 return heap().isInReserved(p);
110 }
|
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.shenandoah.ShenandoahGenerationalHeap;
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() {
58 public void update(Observable o, Object data) {
59 initialize(VM.getVM().getTypeDataBase());
72
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, ZCollectedHeap.class);
91 addHeapTypeIfInDB(db, ShenandoahHeap.class);
92 addHeapTypeIfInDB(db, ShenandoahGenerationalHeap.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 }
|