Mercurial > hg > truffle
annotate agent/src/share/classes/sun/jvm/hotspot/memory/Universe.java @ 1579:e9ff18c4ace7
Merge
author | jrose |
---|---|
date | Wed, 02 Jun 2010 22:45:42 -0700 |
parents | c18cbe5936b8 |
children | 4f93f0d00802 |
rev | line source |
---|---|
0 | 1 /* |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
844
diff
changeset
|
2 * Copyright (c) 2000, 2009, Oracle and/or its affiliates. All rights reserved. |
0 | 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
844
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
844
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
844
diff
changeset
|
21 * questions. |
0 | 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 | |
642
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
196
diff
changeset
|
56 private static AddressField narrowOopBaseField; |
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
196
diff
changeset
|
57 private static CIntegerField narrowOopShiftField; |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
58 |
0 | 59 static { |
60 VM.registerVMInitializedObserver(new Observer() { | |
61 public void update(Observable o, Object data) { | |
62 initialize(VM.getVM().getTypeDataBase()); | |
63 } | |
64 }); | |
65 } | |
66 | |
67 private static synchronized void initialize(TypeDataBase db) { | |
68 Type type = db.lookupType("Universe"); | |
69 | |
70 collectedHeapField = type.getAddressField("_collectedHeap"); | |
71 | |
72 heapConstructor = new VirtualConstructor(db); | |
73 heapConstructor.addMapping("GenCollectedHeap", GenCollectedHeap.class); | |
74 heapConstructor.addMapping("ParallelScavengeHeap", ParallelScavengeHeap.class); | |
75 | |
76 mainThreadGroupField = type.getOopField("_main_thread_group"); | |
77 systemThreadGroupField = type.getOopField("_system_thread_group"); | |
78 | |
79 boolArrayKlassObjField = type.getOopField("_boolArrayKlassObj"); | |
80 byteArrayKlassObjField = type.getOopField("_byteArrayKlassObj"); | |
81 charArrayKlassObjField = type.getOopField("_charArrayKlassObj"); | |
82 intArrayKlassObjField = type.getOopField("_intArrayKlassObj"); | |
83 shortArrayKlassObjField = type.getOopField("_shortArrayKlassObj"); | |
84 longArrayKlassObjField = type.getOopField("_longArrayKlassObj"); | |
85 singleArrayKlassObjField = type.getOopField("_singleArrayKlassObj"); | |
86 doubleArrayKlassObjField = type.getOopField("_doubleArrayKlassObj"); | |
87 | |
88 systemObjArrayKlassObjField = type.getOopField("_systemObjArrayKlassObj"); | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
89 |
642
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
196
diff
changeset
|
90 narrowOopBaseField = type.getAddressField("_narrow_oop._base"); |
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
196
diff
changeset
|
91 narrowOopShiftField = type.getCIntegerField("_narrow_oop._shift"); |
0 | 92 } |
93 | |
94 public Universe() { | |
95 } | |
96 | |
97 public CollectedHeap heap() { | |
98 try { | |
99 return (CollectedHeap) heapConstructor.instantiateWrapperFor(collectedHeapField.getValue()); | |
100 } catch (WrongTypeException e) { | |
101 return new CollectedHeap(collectedHeapField.getValue()); | |
102 } | |
103 } | |
104 | |
642
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
196
diff
changeset
|
105 public static long getNarrowOopBase() { |
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
196
diff
changeset
|
106 if (narrowOopBaseField.getValue() == null) { |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
107 return 0; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
108 } else { |
642
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
196
diff
changeset
|
109 return narrowOopBaseField.getValue().minus(null); |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
110 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
111 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
112 |
642
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
196
diff
changeset
|
113 public static int getNarrowOopShift() { |
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
196
diff
changeset
|
114 return (int)narrowOopShiftField.getValue(); |
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
196
diff
changeset
|
115 } |
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
196
diff
changeset
|
116 |
0 | 117 /** Returns "TRUE" iff "p" points into the allocated area of the heap. */ |
118 public boolean isIn(Address p) { | |
119 return heap().isIn(p); | |
120 } | |
121 | |
122 /** Returns "TRUE" iff "p" points into the reserved area of the heap. */ | |
123 public boolean isInReserved(Address p) { | |
124 return heap().isInReserved(p); | |
125 } | |
126 | |
127 private Oop newOop(OopHandle handle) { | |
128 return VM.getVM().getObjectHeap().newOop(handle); | |
129 } | |
130 | |
131 public Oop mainThreadGroup() { | |
132 return newOop(mainThreadGroupField.getValue()); | |
133 } | |
134 | |
135 public Oop systemThreadGroup() { | |
136 return newOop(systemThreadGroupField.getValue()); | |
137 } | |
138 | |
139 public Oop systemObjArrayKlassObj() { | |
140 return newOop(systemObjArrayKlassObjField.getValue()); | |
141 } | |
142 | |
143 // iterate through the single dimensional primitive array klasses | |
144 // refer to basic_type_classes_do(void f(klassOop)) in universe.cpp | |
145 public void basicTypeClassesDo(SystemDictionary.ClassVisitor visitor) { | |
146 visitor.visit((Klass)newOop(boolArrayKlassObjField.getValue())); | |
147 visitor.visit((Klass)newOop(byteArrayKlassObjField.getValue())); | |
148 visitor.visit((Klass)newOop(charArrayKlassObjField.getValue())); | |
149 visitor.visit((Klass)newOop(intArrayKlassObjField.getValue())); | |
150 visitor.visit((Klass)newOop(shortArrayKlassObjField.getValue())); | |
151 visitor.visit((Klass)newOop(longArrayKlassObjField.getValue())); | |
152 visitor.visit((Klass)newOop(singleArrayKlassObjField.getValue())); | |
153 visitor.visit((Klass)newOop(doubleArrayKlassObjField.getValue())); | |
154 } | |
155 | |
156 public void print() { printOn(System.out); } | |
157 public void printOn(PrintStream tty) { | |
158 heap().printOn(tty); | |
159 } | |
160 | |
161 // Check whether an element of a typeArrayOop with the given type must be | |
162 // aligned 0 mod 8. The typeArrayOop itself must be aligned at least this | |
163 // strongly. | |
164 public static boolean elementTypeShouldBeAligned(BasicType type) { | |
165 return type == BasicType.T_DOUBLE || type == BasicType.T_LONG; | |
166 } | |
167 | |
168 // Check whether an object field (static/non-static) of the given type must be | |
169 // aligned 0 mod 8. | |
170 public static boolean fieldTypeShouldBeAligned(BasicType type) { | |
171 return type == BasicType.T_DOUBLE || type == BasicType.T_LONG; | |
172 } | |
173 } |