Mercurial > hg > truffle
annotate agent/src/share/classes/sun/jvm/hotspot/memory/Universe.java @ 3972:4f93f0d00802
7059019: G1: add G1 support to the SA
Summary: Extend the SA to recognize the G1CollectedHeap and implement any code that's needed by our serviceability tools (jmap, jinfo, jstack, etc.) that depend on the SA.
Reviewed-by: never, poonam, johnc
author | tonyp |
---|---|
date | Tue, 20 Sep 2011 09:59:59 -0400 |
parents | c18cbe5936b8 |
children | da91efe96a93 |
rev | line source |
---|---|
0 | 1 /* |
3972 | 2 * Copyright (c) 2000, 2011, 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.*; | |
3972 | 31 import sun.jvm.hotspot.gc_implementation.g1.G1CollectedHeap; |
0 | 32 import sun.jvm.hotspot.gc_implementation.parallelScavenge.*; |
33 import sun.jvm.hotspot.oops.*; | |
34 import sun.jvm.hotspot.types.*; | |
35 import sun.jvm.hotspot.runtime.*; | |
36 | |
37 | |
38 public class Universe { | |
39 private static AddressField collectedHeapField; | |
40 private static VirtualConstructor heapConstructor; | |
41 private static sun.jvm.hotspot.types.OopField mainThreadGroupField; | |
42 private static sun.jvm.hotspot.types.OopField systemThreadGroupField; | |
43 | |
44 // single dimensional primitive array klasses | |
45 private static sun.jvm.hotspot.types.OopField boolArrayKlassObjField; | |
46 private static sun.jvm.hotspot.types.OopField byteArrayKlassObjField; | |
47 private static sun.jvm.hotspot.types.OopField charArrayKlassObjField; | |
48 private static sun.jvm.hotspot.types.OopField intArrayKlassObjField; | |
49 private static sun.jvm.hotspot.types.OopField shortArrayKlassObjField; | |
50 private static sun.jvm.hotspot.types.OopField longArrayKlassObjField; | |
51 private static sun.jvm.hotspot.types.OopField singleArrayKlassObjField; | |
52 private static sun.jvm.hotspot.types.OopField doubleArrayKlassObjField; | |
53 | |
54 // system obj array klass object | |
55 private static sun.jvm.hotspot.types.OopField systemObjArrayKlassObjField; | |
56 | |
642
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
196
diff
changeset
|
57 private static AddressField narrowOopBaseField; |
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
196
diff
changeset
|
58 private static CIntegerField narrowOopShiftField; |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
59 |
0 | 60 static { |
61 VM.registerVMInitializedObserver(new Observer() { | |
62 public void update(Observable o, Object data) { | |
63 initialize(VM.getVM().getTypeDataBase()); | |
64 } | |
65 }); | |
66 } | |
67 | |
68 private static synchronized void initialize(TypeDataBase db) { | |
69 Type type = db.lookupType("Universe"); | |
70 | |
71 collectedHeapField = type.getAddressField("_collectedHeap"); | |
72 | |
73 heapConstructor = new VirtualConstructor(db); | |
74 heapConstructor.addMapping("GenCollectedHeap", GenCollectedHeap.class); | |
75 heapConstructor.addMapping("ParallelScavengeHeap", ParallelScavengeHeap.class); | |
3972 | 76 heapConstructor.addMapping("G1CollectedHeap", G1CollectedHeap.class); |
0 | 77 |
78 mainThreadGroupField = type.getOopField("_main_thread_group"); | |
79 systemThreadGroupField = type.getOopField("_system_thread_group"); | |
80 | |
81 boolArrayKlassObjField = type.getOopField("_boolArrayKlassObj"); | |
82 byteArrayKlassObjField = type.getOopField("_byteArrayKlassObj"); | |
83 charArrayKlassObjField = type.getOopField("_charArrayKlassObj"); | |
84 intArrayKlassObjField = type.getOopField("_intArrayKlassObj"); | |
85 shortArrayKlassObjField = type.getOopField("_shortArrayKlassObj"); | |
86 longArrayKlassObjField = type.getOopField("_longArrayKlassObj"); | |
87 singleArrayKlassObjField = type.getOopField("_singleArrayKlassObj"); | |
88 doubleArrayKlassObjField = type.getOopField("_doubleArrayKlassObj"); | |
89 | |
90 systemObjArrayKlassObjField = type.getOopField("_systemObjArrayKlassObj"); | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
91 |
642
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
196
diff
changeset
|
92 narrowOopBaseField = type.getAddressField("_narrow_oop._base"); |
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
196
diff
changeset
|
93 narrowOopShiftField = type.getCIntegerField("_narrow_oop._shift"); |
0 | 94 } |
95 | |
96 public Universe() { | |
97 } | |
98 | |
99 public CollectedHeap heap() { | |
100 try { | |
101 return (CollectedHeap) heapConstructor.instantiateWrapperFor(collectedHeapField.getValue()); | |
102 } catch (WrongTypeException e) { | |
103 return new CollectedHeap(collectedHeapField.getValue()); | |
104 } | |
105 } | |
106 | |
642
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
196
diff
changeset
|
107 public static long getNarrowOopBase() { |
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
196
diff
changeset
|
108 if (narrowOopBaseField.getValue() == null) { |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
109 return 0; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
110 } else { |
642
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
196
diff
changeset
|
111 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
|
112 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
113 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
114 |
642
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
196
diff
changeset
|
115 public static int getNarrowOopShift() { |
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
196
diff
changeset
|
116 return (int)narrowOopShiftField.getValue(); |
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
196
diff
changeset
|
117 } |
660978a2a31a
6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents:
196
diff
changeset
|
118 |
0 | 119 /** Returns "TRUE" iff "p" points into the allocated area of the heap. */ |
120 public boolean isIn(Address p) { | |
121 return heap().isIn(p); | |
122 } | |
123 | |
124 /** Returns "TRUE" iff "p" points into the reserved area of the heap. */ | |
125 public boolean isInReserved(Address p) { | |
126 return heap().isInReserved(p); | |
127 } | |
128 | |
129 private Oop newOop(OopHandle handle) { | |
130 return VM.getVM().getObjectHeap().newOop(handle); | |
131 } | |
132 | |
133 public Oop mainThreadGroup() { | |
134 return newOop(mainThreadGroupField.getValue()); | |
135 } | |
136 | |
137 public Oop systemThreadGroup() { | |
138 return newOop(systemThreadGroupField.getValue()); | |
139 } | |
140 | |
141 public Oop systemObjArrayKlassObj() { | |
142 return newOop(systemObjArrayKlassObjField.getValue()); | |
143 } | |
144 | |
145 // iterate through the single dimensional primitive array klasses | |
146 // refer to basic_type_classes_do(void f(klassOop)) in universe.cpp | |
147 public void basicTypeClassesDo(SystemDictionary.ClassVisitor visitor) { | |
148 visitor.visit((Klass)newOop(boolArrayKlassObjField.getValue())); | |
149 visitor.visit((Klass)newOop(byteArrayKlassObjField.getValue())); | |
150 visitor.visit((Klass)newOop(charArrayKlassObjField.getValue())); | |
151 visitor.visit((Klass)newOop(intArrayKlassObjField.getValue())); | |
152 visitor.visit((Klass)newOop(shortArrayKlassObjField.getValue())); | |
153 visitor.visit((Klass)newOop(longArrayKlassObjField.getValue())); | |
154 visitor.visit((Klass)newOop(singleArrayKlassObjField.getValue())); | |
155 visitor.visit((Klass)newOop(doubleArrayKlassObjField.getValue())); | |
156 } | |
157 | |
158 public void print() { printOn(System.out); } | |
159 public void printOn(PrintStream tty) { | |
160 heap().printOn(tty); | |
161 } | |
162 | |
163 // Check whether an element of a typeArrayOop with the given type must be | |
164 // aligned 0 mod 8. The typeArrayOop itself must be aligned at least this | |
165 // strongly. | |
166 public static boolean elementTypeShouldBeAligned(BasicType type) { | |
167 return type == BasicType.T_DOUBLE || type == BasicType.T_LONG; | |
168 } | |
169 | |
170 // Check whether an object field (static/non-static) of the given type must be | |
171 // aligned 0 mod 8. | |
172 public static boolean fieldTypeShouldBeAligned(BasicType type) { | |
173 return type == BasicType.T_DOUBLE || type == BasicType.T_LONG; | |
174 } | |
175 } |