1 /*
2 * Copyright 2000-2006 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 * have any questions.
22 *
36
37 public class Universe {
38 private static AddressField collectedHeapField;
39 private static VirtualConstructor heapConstructor;
40 private static sun.jvm.hotspot.types.OopField mainThreadGroupField;
41 private static sun.jvm.hotspot.types.OopField systemThreadGroupField;
42
43 // single dimensional primitive array klasses
44 private static sun.jvm.hotspot.types.OopField boolArrayKlassObjField;
45 private static sun.jvm.hotspot.types.OopField byteArrayKlassObjField;
46 private static sun.jvm.hotspot.types.OopField charArrayKlassObjField;
47 private static sun.jvm.hotspot.types.OopField intArrayKlassObjField;
48 private static sun.jvm.hotspot.types.OopField shortArrayKlassObjField;
49 private static sun.jvm.hotspot.types.OopField longArrayKlassObjField;
50 private static sun.jvm.hotspot.types.OopField singleArrayKlassObjField;
51 private static sun.jvm.hotspot.types.OopField doubleArrayKlassObjField;
52
53 // system obj array klass object
54 private static sun.jvm.hotspot.types.OopField systemObjArrayKlassObjField;
55
56 static {
57 VM.registerVMInitializedObserver(new Observer() {
58 public void update(Observable o, Object data) {
59 initialize(VM.getVM().getTypeDataBase());
60 }
61 });
62 }
63
64 private static synchronized void initialize(TypeDataBase db) {
65 Type type = db.lookupType("Universe");
66
67 collectedHeapField = type.getAddressField("_collectedHeap");
68
69 heapConstructor = new VirtualConstructor(db);
70 heapConstructor.addMapping("GenCollectedHeap", GenCollectedHeap.class);
71 heapConstructor.addMapping("ParallelScavengeHeap", ParallelScavengeHeap.class);
72
73 mainThreadGroupField = type.getOopField("_main_thread_group");
74 systemThreadGroupField = type.getOopField("_system_thread_group");
75
76 boolArrayKlassObjField = type.getOopField("_boolArrayKlassObj");
77 byteArrayKlassObjField = type.getOopField("_byteArrayKlassObj");
78 charArrayKlassObjField = type.getOopField("_charArrayKlassObj");
79 intArrayKlassObjField = type.getOopField("_intArrayKlassObj");
80 shortArrayKlassObjField = type.getOopField("_shortArrayKlassObj");
81 longArrayKlassObjField = type.getOopField("_longArrayKlassObj");
82 singleArrayKlassObjField = type.getOopField("_singleArrayKlassObj");
83 doubleArrayKlassObjField = type.getOopField("_doubleArrayKlassObj");
84
85 systemObjArrayKlassObjField = type.getOopField("_systemObjArrayKlassObj");
86 }
87
88 public Universe() {
89 }
90
91 public CollectedHeap heap() {
92 try {
93 return (CollectedHeap) heapConstructor.instantiateWrapperFor(collectedHeapField.getValue());
94 } catch (WrongTypeException e) {
95 return new CollectedHeap(collectedHeapField.getValue());
96 }
97 }
98
99 /** Returns "TRUE" iff "p" points into the allocated area of the heap. */
100 public boolean isIn(Address p) {
101 return heap().isIn(p);
102 }
103
104 /** Returns "TRUE" iff "p" points into the reserved area of the heap. */
105 public boolean isInReserved(Address p) {
106 return heap().isInReserved(p);
107 }
108
109 private Oop newOop(OopHandle handle) {
110 return VM.getVM().getObjectHeap().newOop(handle);
111 }
112
113 public Oop mainThreadGroup() {
114 return newOop(mainThreadGroupField.getValue());
115 }
116
117 public Oop systemThreadGroup() {
118 return newOop(systemThreadGroupField.getValue());
|
1 /*
2 * Copyright 2000-2008 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 * have any questions.
22 *
36
37 public class Universe {
38 private static AddressField collectedHeapField;
39 private static VirtualConstructor heapConstructor;
40 private static sun.jvm.hotspot.types.OopField mainThreadGroupField;
41 private static sun.jvm.hotspot.types.OopField systemThreadGroupField;
42
43 // single dimensional primitive array klasses
44 private static sun.jvm.hotspot.types.OopField boolArrayKlassObjField;
45 private static sun.jvm.hotspot.types.OopField byteArrayKlassObjField;
46 private static sun.jvm.hotspot.types.OopField charArrayKlassObjField;
47 private static sun.jvm.hotspot.types.OopField intArrayKlassObjField;
48 private static sun.jvm.hotspot.types.OopField shortArrayKlassObjField;
49 private static sun.jvm.hotspot.types.OopField longArrayKlassObjField;
50 private static sun.jvm.hotspot.types.OopField singleArrayKlassObjField;
51 private static sun.jvm.hotspot.types.OopField doubleArrayKlassObjField;
52
53 // system obj array klass object
54 private static sun.jvm.hotspot.types.OopField systemObjArrayKlassObjField;
55
56 private static AddressField heapBaseField;
57
58 static {
59 VM.registerVMInitializedObserver(new Observer() {
60 public void update(Observable o, Object data) {
61 initialize(VM.getVM().getTypeDataBase());
62 }
63 });
64 }
65
66 private static synchronized void initialize(TypeDataBase db) {
67 Type type = db.lookupType("Universe");
68
69 collectedHeapField = type.getAddressField("_collectedHeap");
70
71 heapConstructor = new VirtualConstructor(db);
72 heapConstructor.addMapping("GenCollectedHeap", GenCollectedHeap.class);
73 heapConstructor.addMapping("ParallelScavengeHeap", ParallelScavengeHeap.class);
74
75 mainThreadGroupField = type.getOopField("_main_thread_group");
76 systemThreadGroupField = type.getOopField("_system_thread_group");
77
78 boolArrayKlassObjField = type.getOopField("_boolArrayKlassObj");
79 byteArrayKlassObjField = type.getOopField("_byteArrayKlassObj");
80 charArrayKlassObjField = type.getOopField("_charArrayKlassObj");
81 intArrayKlassObjField = type.getOopField("_intArrayKlassObj");
82 shortArrayKlassObjField = type.getOopField("_shortArrayKlassObj");
83 longArrayKlassObjField = type.getOopField("_longArrayKlassObj");
84 singleArrayKlassObjField = type.getOopField("_singleArrayKlassObj");
85 doubleArrayKlassObjField = type.getOopField("_doubleArrayKlassObj");
86
87 systemObjArrayKlassObjField = type.getOopField("_systemObjArrayKlassObj");
88
89 heapBaseField = type.getAddressField("_heap_base");
90 }
91
92 public Universe() {
93 }
94
95 public CollectedHeap heap() {
96 try {
97 return (CollectedHeap) heapConstructor.instantiateWrapperFor(collectedHeapField.getValue());
98 } catch (WrongTypeException e) {
99 return new CollectedHeap(collectedHeapField.getValue());
100 }
101 }
102
103 public static long getHeapBase() {
104 if (heapBaseField.getValue() == null) {
105 return 0;
106 } else {
107 return heapBaseField.getValue().minus(null);
108 }
109 }
110
111 /** Returns "TRUE" iff "p" points into the allocated area of the heap. */
112 public boolean isIn(Address p) {
113 return heap().isIn(p);
114 }
115
116 /** Returns "TRUE" iff "p" points into the reserved area of the heap. */
117 public boolean isInReserved(Address p) {
118 return heap().isInReserved(p);
119 }
120
121 private Oop newOop(OopHandle handle) {
122 return VM.getVM().getObjectHeap().newOop(handle);
123 }
124
125 public Oop mainThreadGroup() {
126 return newOop(mainThreadGroupField.getValue());
127 }
128
129 public Oop systemThreadGroup() {
130 return newOop(systemThreadGroupField.getValue());
|