author | coleenp |
Sun, 13 Apr 2008 17:43:42 -0400 | |
changeset 360 | 21d113ecbf6a |
parent 1 | 489c9b5090e2 |
child 670 | ddf3e9583f2f |
permissions | -rw-r--r-- |
1 | 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 |
* |
|
23 |
*/ |
|
24 |
||
25 |
package sun.jvm.hotspot.memory; |
|
26 |
||
27 |
import java.io.*; |
|
28 |
import java.util.*; |
|
29 |
import sun.jvm.hotspot.debugger.*; |
|
30 |
import sun.jvm.hotspot.gc_interface.*; |
|
31 |
import sun.jvm.hotspot.gc_implementation.parallelScavenge.*; |
|
32 |
import sun.jvm.hotspot.oops.*; |
|
33 |
import sun.jvm.hotspot.types.*; |
|
34 |
import sun.jvm.hotspot.runtime.*; |
|
35 |
||
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 |
||
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
56 |
private static AddressField heapBaseField; |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
57 |
|
1 | 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"); |
|
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
88 |
|
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
89 |
heapBaseField = type.getAddressField("_heap_base"); |
1 | 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 |
||
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
103 |
public static long getHeapBase() { |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
104 |
if (heapBaseField.getValue() == null) { |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
105 |
return 0; |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
106 |
} else { |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
107 |
return heapBaseField.getValue().minus(null); |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
108 |
} |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
109 |
} |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
110 |
|
1 | 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()); |
|
131 |
} |
|
132 |
||
133 |
public Oop systemObjArrayKlassObj() { |
|
134 |
return newOop(systemObjArrayKlassObjField.getValue()); |
|
135 |
} |
|
136 |
||
137 |
// iterate through the single dimensional primitive array klasses |
|
138 |
// refer to basic_type_classes_do(void f(klassOop)) in universe.cpp |
|
139 |
public void basicTypeClassesDo(SystemDictionary.ClassVisitor visitor) { |
|
140 |
visitor.visit((Klass)newOop(boolArrayKlassObjField.getValue())); |
|
141 |
visitor.visit((Klass)newOop(byteArrayKlassObjField.getValue())); |
|
142 |
visitor.visit((Klass)newOop(charArrayKlassObjField.getValue())); |
|
143 |
visitor.visit((Klass)newOop(intArrayKlassObjField.getValue())); |
|
144 |
visitor.visit((Klass)newOop(shortArrayKlassObjField.getValue())); |
|
145 |
visitor.visit((Klass)newOop(longArrayKlassObjField.getValue())); |
|
146 |
visitor.visit((Klass)newOop(singleArrayKlassObjField.getValue())); |
|
147 |
visitor.visit((Klass)newOop(doubleArrayKlassObjField.getValue())); |
|
148 |
} |
|
149 |
||
150 |
public void print() { printOn(System.out); } |
|
151 |
public void printOn(PrintStream tty) { |
|
152 |
heap().printOn(tty); |
|
153 |
} |
|
154 |
||
155 |
// Check whether an element of a typeArrayOop with the given type must be |
|
156 |
// aligned 0 mod 8. The typeArrayOop itself must be aligned at least this |
|
157 |
// strongly. |
|
158 |
public static boolean elementTypeShouldBeAligned(BasicType type) { |
|
159 |
return type == BasicType.T_DOUBLE || type == BasicType.T_LONG; |
|
160 |
} |
|
161 |
||
162 |
// Check whether an object field (static/non-static) of the given type must be |
|
163 |
// aligned 0 mod 8. |
|
164 |
public static boolean fieldTypeShouldBeAligned(BasicType type) { |
|
165 |
return type == BasicType.T_DOUBLE || type == BasicType.T_LONG; |
|
166 |
} |
|
167 |
} |