annotate agent/src/share/classes/sun/jvm/hotspot/memory/Universe.java @ 196:d1605aabd0a1 jdk7-b30

6719955: Update copyright year Summary: Update copyright year for files that have been modified in 2008 Reviewed-by: ohair, tbell
author xdono
date Wed, 02 Jul 2008 12:55:16 -0700
parents ba764ed4b6f2
children 660978a2a31a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
196
d1605aabd0a1 6719955: Update copyright year
xdono
parents: 113
diff changeset
2 * Copyright 2000-2008 Sun Microsystems, Inc. All Rights Reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 package sun.jvm.hotspot.memory;
a61af66fc99e Initial load
duke
parents:
diff changeset
26
a61af66fc99e Initial load
duke
parents:
diff changeset
27 import java.io.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
28 import java.util.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
29 import sun.jvm.hotspot.debugger.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
30 import sun.jvm.hotspot.gc_interface.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
31 import sun.jvm.hotspot.gc_implementation.parallelScavenge.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
32 import sun.jvm.hotspot.oops.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
33 import sun.jvm.hotspot.types.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
34 import sun.jvm.hotspot.runtime.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
35
a61af66fc99e Initial load
duke
parents:
diff changeset
36
a61af66fc99e Initial load
duke
parents:
diff changeset
37 public class Universe {
a61af66fc99e Initial load
duke
parents:
diff changeset
38 private static AddressField collectedHeapField;
a61af66fc99e Initial load
duke
parents:
diff changeset
39 private static VirtualConstructor heapConstructor;
a61af66fc99e Initial load
duke
parents:
diff changeset
40 private static sun.jvm.hotspot.types.OopField mainThreadGroupField;
a61af66fc99e Initial load
duke
parents:
diff changeset
41 private static sun.jvm.hotspot.types.OopField systemThreadGroupField;
a61af66fc99e Initial load
duke
parents:
diff changeset
42
a61af66fc99e Initial load
duke
parents:
diff changeset
43 // single dimensional primitive array klasses
a61af66fc99e Initial load
duke
parents:
diff changeset
44 private static sun.jvm.hotspot.types.OopField boolArrayKlassObjField;
a61af66fc99e Initial load
duke
parents:
diff changeset
45 private static sun.jvm.hotspot.types.OopField byteArrayKlassObjField;
a61af66fc99e Initial load
duke
parents:
diff changeset
46 private static sun.jvm.hotspot.types.OopField charArrayKlassObjField;
a61af66fc99e Initial load
duke
parents:
diff changeset
47 private static sun.jvm.hotspot.types.OopField intArrayKlassObjField;
a61af66fc99e Initial load
duke
parents:
diff changeset
48 private static sun.jvm.hotspot.types.OopField shortArrayKlassObjField;
a61af66fc99e Initial load
duke
parents:
diff changeset
49 private static sun.jvm.hotspot.types.OopField longArrayKlassObjField;
a61af66fc99e Initial load
duke
parents:
diff changeset
50 private static sun.jvm.hotspot.types.OopField singleArrayKlassObjField;
a61af66fc99e Initial load
duke
parents:
diff changeset
51 private static sun.jvm.hotspot.types.OopField doubleArrayKlassObjField;
a61af66fc99e Initial load
duke
parents:
diff changeset
52
a61af66fc99e Initial load
duke
parents:
diff changeset
53 // system obj array klass object
a61af66fc99e Initial load
duke
parents:
diff changeset
54 private static sun.jvm.hotspot.types.OopField systemObjArrayKlassObjField;
a61af66fc99e Initial load
duke
parents:
diff changeset
55
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
56 private static AddressField heapBaseField;
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
57
0
a61af66fc99e Initial load
duke
parents:
diff changeset
58 static {
a61af66fc99e Initial load
duke
parents:
diff changeset
59 VM.registerVMInitializedObserver(new Observer() {
a61af66fc99e Initial load
duke
parents:
diff changeset
60 public void update(Observable o, Object data) {
a61af66fc99e Initial load
duke
parents:
diff changeset
61 initialize(VM.getVM().getTypeDataBase());
a61af66fc99e Initial load
duke
parents:
diff changeset
62 }
a61af66fc99e Initial load
duke
parents:
diff changeset
63 });
a61af66fc99e Initial load
duke
parents:
diff changeset
64 }
a61af66fc99e Initial load
duke
parents:
diff changeset
65
a61af66fc99e Initial load
duke
parents:
diff changeset
66 private static synchronized void initialize(TypeDataBase db) {
a61af66fc99e Initial load
duke
parents:
diff changeset
67 Type type = db.lookupType("Universe");
a61af66fc99e Initial load
duke
parents:
diff changeset
68
a61af66fc99e Initial load
duke
parents:
diff changeset
69 collectedHeapField = type.getAddressField("_collectedHeap");
a61af66fc99e Initial load
duke
parents:
diff changeset
70
a61af66fc99e Initial load
duke
parents:
diff changeset
71 heapConstructor = new VirtualConstructor(db);
a61af66fc99e Initial load
duke
parents:
diff changeset
72 heapConstructor.addMapping("GenCollectedHeap", GenCollectedHeap.class);
a61af66fc99e Initial load
duke
parents:
diff changeset
73 heapConstructor.addMapping("ParallelScavengeHeap", ParallelScavengeHeap.class);
a61af66fc99e Initial load
duke
parents:
diff changeset
74
a61af66fc99e Initial load
duke
parents:
diff changeset
75 mainThreadGroupField = type.getOopField("_main_thread_group");
a61af66fc99e Initial load
duke
parents:
diff changeset
76 systemThreadGroupField = type.getOopField("_system_thread_group");
a61af66fc99e Initial load
duke
parents:
diff changeset
77
a61af66fc99e Initial load
duke
parents:
diff changeset
78 boolArrayKlassObjField = type.getOopField("_boolArrayKlassObj");
a61af66fc99e Initial load
duke
parents:
diff changeset
79 byteArrayKlassObjField = type.getOopField("_byteArrayKlassObj");
a61af66fc99e Initial load
duke
parents:
diff changeset
80 charArrayKlassObjField = type.getOopField("_charArrayKlassObj");
a61af66fc99e Initial load
duke
parents:
diff changeset
81 intArrayKlassObjField = type.getOopField("_intArrayKlassObj");
a61af66fc99e Initial load
duke
parents:
diff changeset
82 shortArrayKlassObjField = type.getOopField("_shortArrayKlassObj");
a61af66fc99e Initial load
duke
parents:
diff changeset
83 longArrayKlassObjField = type.getOopField("_longArrayKlassObj");
a61af66fc99e Initial load
duke
parents:
diff changeset
84 singleArrayKlassObjField = type.getOopField("_singleArrayKlassObj");
a61af66fc99e Initial load
duke
parents:
diff changeset
85 doubleArrayKlassObjField = type.getOopField("_doubleArrayKlassObj");
a61af66fc99e Initial load
duke
parents:
diff changeset
86
a61af66fc99e Initial load
duke
parents:
diff changeset
87 systemObjArrayKlassObjField = type.getOopField("_systemObjArrayKlassObj");
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
88
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
89 heapBaseField = type.getAddressField("_heap_base");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
90 }
a61af66fc99e Initial load
duke
parents:
diff changeset
91
a61af66fc99e Initial load
duke
parents:
diff changeset
92 public Universe() {
a61af66fc99e Initial load
duke
parents:
diff changeset
93 }
a61af66fc99e Initial load
duke
parents:
diff changeset
94
a61af66fc99e Initial load
duke
parents:
diff changeset
95 public CollectedHeap heap() {
a61af66fc99e Initial load
duke
parents:
diff changeset
96 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
97 return (CollectedHeap) heapConstructor.instantiateWrapperFor(collectedHeapField.getValue());
a61af66fc99e Initial load
duke
parents:
diff changeset
98 } catch (WrongTypeException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
99 return new CollectedHeap(collectedHeapField.getValue());
a61af66fc99e Initial load
duke
parents:
diff changeset
100 }
a61af66fc99e Initial load
duke
parents:
diff changeset
101 }
a61af66fc99e Initial load
duke
parents:
diff changeset
102
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
103 public static long getHeapBase() {
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
104 if (heapBaseField.getValue() == null) {
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
105 return 0;
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
106 } else {
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
107 return heapBaseField.getValue().minus(null);
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
108 }
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
109 }
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
110
0
a61af66fc99e Initial load
duke
parents:
diff changeset
111 /** Returns "TRUE" iff "p" points into the allocated area of the heap. */
a61af66fc99e Initial load
duke
parents:
diff changeset
112 public boolean isIn(Address p) {
a61af66fc99e Initial load
duke
parents:
diff changeset
113 return heap().isIn(p);
a61af66fc99e Initial load
duke
parents:
diff changeset
114 }
a61af66fc99e Initial load
duke
parents:
diff changeset
115
a61af66fc99e Initial load
duke
parents:
diff changeset
116 /** Returns "TRUE" iff "p" points into the reserved area of the heap. */
a61af66fc99e Initial load
duke
parents:
diff changeset
117 public boolean isInReserved(Address p) {
a61af66fc99e Initial load
duke
parents:
diff changeset
118 return heap().isInReserved(p);
a61af66fc99e Initial load
duke
parents:
diff changeset
119 }
a61af66fc99e Initial load
duke
parents:
diff changeset
120
a61af66fc99e Initial load
duke
parents:
diff changeset
121 private Oop newOop(OopHandle handle) {
a61af66fc99e Initial load
duke
parents:
diff changeset
122 return VM.getVM().getObjectHeap().newOop(handle);
a61af66fc99e Initial load
duke
parents:
diff changeset
123 }
a61af66fc99e Initial load
duke
parents:
diff changeset
124
a61af66fc99e Initial load
duke
parents:
diff changeset
125 public Oop mainThreadGroup() {
a61af66fc99e Initial load
duke
parents:
diff changeset
126 return newOop(mainThreadGroupField.getValue());
a61af66fc99e Initial load
duke
parents:
diff changeset
127 }
a61af66fc99e Initial load
duke
parents:
diff changeset
128
a61af66fc99e Initial load
duke
parents:
diff changeset
129 public Oop systemThreadGroup() {
a61af66fc99e Initial load
duke
parents:
diff changeset
130 return newOop(systemThreadGroupField.getValue());
a61af66fc99e Initial load
duke
parents:
diff changeset
131 }
a61af66fc99e Initial load
duke
parents:
diff changeset
132
a61af66fc99e Initial load
duke
parents:
diff changeset
133 public Oop systemObjArrayKlassObj() {
a61af66fc99e Initial load
duke
parents:
diff changeset
134 return newOop(systemObjArrayKlassObjField.getValue());
a61af66fc99e Initial load
duke
parents:
diff changeset
135 }
a61af66fc99e Initial load
duke
parents:
diff changeset
136
a61af66fc99e Initial load
duke
parents:
diff changeset
137 // iterate through the single dimensional primitive array klasses
a61af66fc99e Initial load
duke
parents:
diff changeset
138 // refer to basic_type_classes_do(void f(klassOop)) in universe.cpp
a61af66fc99e Initial load
duke
parents:
diff changeset
139 public void basicTypeClassesDo(SystemDictionary.ClassVisitor visitor) {
a61af66fc99e Initial load
duke
parents:
diff changeset
140 visitor.visit((Klass)newOop(boolArrayKlassObjField.getValue()));
a61af66fc99e Initial load
duke
parents:
diff changeset
141 visitor.visit((Klass)newOop(byteArrayKlassObjField.getValue()));
a61af66fc99e Initial load
duke
parents:
diff changeset
142 visitor.visit((Klass)newOop(charArrayKlassObjField.getValue()));
a61af66fc99e Initial load
duke
parents:
diff changeset
143 visitor.visit((Klass)newOop(intArrayKlassObjField.getValue()));
a61af66fc99e Initial load
duke
parents:
diff changeset
144 visitor.visit((Klass)newOop(shortArrayKlassObjField.getValue()));
a61af66fc99e Initial load
duke
parents:
diff changeset
145 visitor.visit((Klass)newOop(longArrayKlassObjField.getValue()));
a61af66fc99e Initial load
duke
parents:
diff changeset
146 visitor.visit((Klass)newOop(singleArrayKlassObjField.getValue()));
a61af66fc99e Initial load
duke
parents:
diff changeset
147 visitor.visit((Klass)newOop(doubleArrayKlassObjField.getValue()));
a61af66fc99e Initial load
duke
parents:
diff changeset
148 }
a61af66fc99e Initial load
duke
parents:
diff changeset
149
a61af66fc99e Initial load
duke
parents:
diff changeset
150 public void print() { printOn(System.out); }
a61af66fc99e Initial load
duke
parents:
diff changeset
151 public void printOn(PrintStream tty) {
a61af66fc99e Initial load
duke
parents:
diff changeset
152 heap().printOn(tty);
a61af66fc99e Initial load
duke
parents:
diff changeset
153 }
a61af66fc99e Initial load
duke
parents:
diff changeset
154
a61af66fc99e Initial load
duke
parents:
diff changeset
155 // Check whether an element of a typeArrayOop with the given type must be
a61af66fc99e Initial load
duke
parents:
diff changeset
156 // aligned 0 mod 8. The typeArrayOop itself must be aligned at least this
a61af66fc99e Initial load
duke
parents:
diff changeset
157 // strongly.
a61af66fc99e Initial load
duke
parents:
diff changeset
158 public static boolean elementTypeShouldBeAligned(BasicType type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
159 return type == BasicType.T_DOUBLE || type == BasicType.T_LONG;
a61af66fc99e Initial load
duke
parents:
diff changeset
160 }
a61af66fc99e Initial load
duke
parents:
diff changeset
161
a61af66fc99e Initial load
duke
parents:
diff changeset
162 // Check whether an object field (static/non-static) of the given type must be
a61af66fc99e Initial load
duke
parents:
diff changeset
163 // aligned 0 mod 8.
a61af66fc99e Initial load
duke
parents:
diff changeset
164 public static boolean fieldTypeShouldBeAligned(BasicType type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
165 return type == BasicType.T_DOUBLE || type == BasicType.T_LONG;
a61af66fc99e Initial load
duke
parents:
diff changeset
166 }
a61af66fc99e Initial load
duke
parents:
diff changeset
167 }