annotate agent/src/share/classes/sun/jvm/hotspot/oops/ObjectHeap.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 63997f575155
children da91efe96a93
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
2411
63997f575155 7031614: jmap -permstat fails with java.lang.InternalError in sun.jvm.hotspot.oops.OopField.getValue
never
parents: 2177
diff changeset
2 * Copyright (c) 2000, 2011, Oracle and/or its affiliates. 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 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 235
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 235
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: 235
diff changeset
21 * questions.
0
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 //
a61af66fc99e Initial load
duke
parents:
diff changeset
26 // The ObjectHeap is an abstraction over all generations in the VM
a61af66fc99e Initial load
duke
parents:
diff changeset
27 // It gives access to all present objects and classes.
a61af66fc99e Initial load
duke
parents:
diff changeset
28 //
a61af66fc99e Initial load
duke
parents:
diff changeset
29
a61af66fc99e Initial load
duke
parents:
diff changeset
30 package sun.jvm.hotspot.oops;
a61af66fc99e Initial load
duke
parents:
diff changeset
31
a61af66fc99e Initial load
duke
parents:
diff changeset
32 import java.util.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
33
a61af66fc99e Initial load
duke
parents:
diff changeset
34 import sun.jvm.hotspot.debugger.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
35 import sun.jvm.hotspot.gc_interface.*;
3972
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 2411
diff changeset
36 import sun.jvm.hotspot.gc_implementation.g1.*;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
37 import sun.jvm.hotspot.gc_implementation.parallelScavenge.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
38 import sun.jvm.hotspot.memory.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
39 import sun.jvm.hotspot.runtime.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
40 import sun.jvm.hotspot.types.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
41 import sun.jvm.hotspot.utilities.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
42
a61af66fc99e Initial load
duke
parents:
diff changeset
43 public class ObjectHeap {
a61af66fc99e Initial load
duke
parents:
diff changeset
44
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
45 private static final boolean DEBUG;
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
46
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
47 static {
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
48 DEBUG = System.getProperty("sun.jvm.hotspot.oops.ObjectHeap.DEBUG") != null;
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
49 }
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
50
0
a61af66fc99e Initial load
duke
parents:
diff changeset
51 private OopHandle methodKlassHandle;
a61af66fc99e Initial load
duke
parents:
diff changeset
52 private OopHandle constMethodKlassHandle;
a61af66fc99e Initial load
duke
parents:
diff changeset
53 private OopHandle methodDataKlassHandle;
a61af66fc99e Initial load
duke
parents:
diff changeset
54 private OopHandle constantPoolKlassHandle;
a61af66fc99e Initial load
duke
parents:
diff changeset
55 private OopHandle constantPoolCacheKlassHandle;
a61af66fc99e Initial load
duke
parents:
diff changeset
56 private OopHandle klassKlassHandle;
a61af66fc99e Initial load
duke
parents:
diff changeset
57 private OopHandle instanceKlassKlassHandle;
a61af66fc99e Initial load
duke
parents:
diff changeset
58 private OopHandle typeArrayKlassKlassHandle;
a61af66fc99e Initial load
duke
parents:
diff changeset
59 private OopHandle objArrayKlassKlassHandle;
a61af66fc99e Initial load
duke
parents:
diff changeset
60 private OopHandle boolArrayKlassHandle;
a61af66fc99e Initial load
duke
parents:
diff changeset
61 private OopHandle byteArrayKlassHandle;
a61af66fc99e Initial load
duke
parents:
diff changeset
62 private OopHandle charArrayKlassHandle;
a61af66fc99e Initial load
duke
parents:
diff changeset
63 private OopHandle intArrayKlassHandle;
a61af66fc99e Initial load
duke
parents:
diff changeset
64 private OopHandle shortArrayKlassHandle;
a61af66fc99e Initial load
duke
parents:
diff changeset
65 private OopHandle longArrayKlassHandle;
a61af66fc99e Initial load
duke
parents:
diff changeset
66 private OopHandle singleArrayKlassHandle;
a61af66fc99e Initial load
duke
parents:
diff changeset
67 private OopHandle doubleArrayKlassHandle;
a61af66fc99e Initial load
duke
parents:
diff changeset
68 private OopHandle arrayKlassKlassHandle;
a61af66fc99e Initial load
duke
parents:
diff changeset
69 private OopHandle compiledICHolderKlassHandle;
a61af66fc99e Initial load
duke
parents:
diff changeset
70
a61af66fc99e Initial load
duke
parents:
diff changeset
71 private MethodKlass methodKlassObj;
a61af66fc99e Initial load
duke
parents:
diff changeset
72 private ConstMethodKlass constMethodKlassObj;
a61af66fc99e Initial load
duke
parents:
diff changeset
73 private MethodDataKlass methodDataKlassObj;
a61af66fc99e Initial load
duke
parents:
diff changeset
74 private ConstantPoolKlass constantPoolKlassObj;
a61af66fc99e Initial load
duke
parents:
diff changeset
75 private ConstantPoolCacheKlass constantPoolCacheKlassObj;
a61af66fc99e Initial load
duke
parents:
diff changeset
76 private KlassKlass klassKlassObj;
a61af66fc99e Initial load
duke
parents:
diff changeset
77 private InstanceKlassKlass instanceKlassKlassObj;
a61af66fc99e Initial load
duke
parents:
diff changeset
78 private TypeArrayKlassKlass typeArrayKlassKlassObj;
a61af66fc99e Initial load
duke
parents:
diff changeset
79 private ObjArrayKlassKlass objArrayKlassKlassObj;
a61af66fc99e Initial load
duke
parents:
diff changeset
80 private TypeArrayKlass boolArrayKlassObj;
a61af66fc99e Initial load
duke
parents:
diff changeset
81 private TypeArrayKlass byteArrayKlassObj;
a61af66fc99e Initial load
duke
parents:
diff changeset
82 private TypeArrayKlass charArrayKlassObj;
a61af66fc99e Initial load
duke
parents:
diff changeset
83 private TypeArrayKlass intArrayKlassObj;
a61af66fc99e Initial load
duke
parents:
diff changeset
84 private TypeArrayKlass shortArrayKlassObj;
a61af66fc99e Initial load
duke
parents:
diff changeset
85 private TypeArrayKlass longArrayKlassObj;
a61af66fc99e Initial load
duke
parents:
diff changeset
86 private TypeArrayKlass singleArrayKlassObj;
a61af66fc99e Initial load
duke
parents:
diff changeset
87 private TypeArrayKlass doubleArrayKlassObj;
a61af66fc99e Initial load
duke
parents:
diff changeset
88 private ArrayKlassKlass arrayKlassKlassObj;
a61af66fc99e Initial load
duke
parents:
diff changeset
89 private CompiledICHolderKlass compiledICHolderKlassObj;
a61af66fc99e Initial load
duke
parents:
diff changeset
90
a61af66fc99e Initial load
duke
parents:
diff changeset
91 public void initialize(TypeDataBase db) throws WrongTypeException {
a61af66fc99e Initial load
duke
parents:
diff changeset
92 // Lookup the roots in the object hierarchy.
a61af66fc99e Initial load
duke
parents:
diff changeset
93 Type universeType = db.lookupType("Universe");
a61af66fc99e Initial load
duke
parents:
diff changeset
94
a61af66fc99e Initial load
duke
parents:
diff changeset
95 methodKlassHandle = universeType.getOopField("_methodKlassObj").getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
96 methodKlassObj = new MethodKlass(methodKlassHandle, this);
a61af66fc99e Initial load
duke
parents:
diff changeset
97
a61af66fc99e Initial load
duke
parents:
diff changeset
98 constMethodKlassHandle = universeType.getOopField("_constMethodKlassObj").getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
99 constMethodKlassObj = new ConstMethodKlass(constMethodKlassHandle, this);
a61af66fc99e Initial load
duke
parents:
diff changeset
100
a61af66fc99e Initial load
duke
parents:
diff changeset
101 constantPoolKlassHandle = universeType.getOopField("_constantPoolKlassObj").getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
102 constantPoolKlassObj = new ConstantPoolKlass(constantPoolKlassHandle, this);
a61af66fc99e Initial load
duke
parents:
diff changeset
103
a61af66fc99e Initial load
duke
parents:
diff changeset
104 constantPoolCacheKlassHandle = universeType.getOopField("_constantPoolCacheKlassObj").getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
105 constantPoolCacheKlassObj = new ConstantPoolCacheKlass(constantPoolCacheKlassHandle, this);
a61af66fc99e Initial load
duke
parents:
diff changeset
106
a61af66fc99e Initial load
duke
parents:
diff changeset
107 klassKlassHandle = universeType.getOopField("_klassKlassObj").getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
108 klassKlassObj = new KlassKlass(klassKlassHandle, this);
a61af66fc99e Initial load
duke
parents:
diff changeset
109
a61af66fc99e Initial load
duke
parents:
diff changeset
110 arrayKlassKlassHandle = universeType.getOopField("_arrayKlassKlassObj").getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
111 arrayKlassKlassObj = new ArrayKlassKlass(arrayKlassKlassHandle, this);
a61af66fc99e Initial load
duke
parents:
diff changeset
112
a61af66fc99e Initial load
duke
parents:
diff changeset
113 instanceKlassKlassHandle = universeType.getOopField("_instanceKlassKlassObj").getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
114 instanceKlassKlassObj = new InstanceKlassKlass(instanceKlassKlassHandle, this);
a61af66fc99e Initial load
duke
parents:
diff changeset
115
a61af66fc99e Initial load
duke
parents:
diff changeset
116 typeArrayKlassKlassHandle = universeType.getOopField("_typeArrayKlassKlassObj").getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
117 typeArrayKlassKlassObj = new TypeArrayKlassKlass(typeArrayKlassKlassHandle, this);
a61af66fc99e Initial load
duke
parents:
diff changeset
118
a61af66fc99e Initial load
duke
parents:
diff changeset
119 objArrayKlassKlassHandle = universeType.getOopField("_objArrayKlassKlassObj").getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
120 objArrayKlassKlassObj = new ObjArrayKlassKlass(objArrayKlassKlassHandle, this);
a61af66fc99e Initial load
duke
parents:
diff changeset
121
a61af66fc99e Initial load
duke
parents:
diff changeset
122 boolArrayKlassHandle = universeType.getOopField("_boolArrayKlassObj").getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
123 boolArrayKlassObj = new TypeArrayKlass(boolArrayKlassHandle, this);
a61af66fc99e Initial load
duke
parents:
diff changeset
124
a61af66fc99e Initial load
duke
parents:
diff changeset
125 byteArrayKlassHandle = universeType.getOopField("_byteArrayKlassObj").getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
126 byteArrayKlassObj = new TypeArrayKlass(byteArrayKlassHandle, this);
a61af66fc99e Initial load
duke
parents:
diff changeset
127
a61af66fc99e Initial load
duke
parents:
diff changeset
128 charArrayKlassHandle = universeType.getOopField("_charArrayKlassObj").getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
129 charArrayKlassObj = new TypeArrayKlass(charArrayKlassHandle, this);
a61af66fc99e Initial load
duke
parents:
diff changeset
130
a61af66fc99e Initial load
duke
parents:
diff changeset
131 intArrayKlassHandle = universeType.getOopField("_intArrayKlassObj").getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
132 intArrayKlassObj = new TypeArrayKlass(intArrayKlassHandle, this);
a61af66fc99e Initial load
duke
parents:
diff changeset
133
a61af66fc99e Initial load
duke
parents:
diff changeset
134 shortArrayKlassHandle = universeType.getOopField("_shortArrayKlassObj").getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
135 shortArrayKlassObj = new TypeArrayKlass(shortArrayKlassHandle, this);
a61af66fc99e Initial load
duke
parents:
diff changeset
136
a61af66fc99e Initial load
duke
parents:
diff changeset
137 longArrayKlassHandle = universeType.getOopField("_longArrayKlassObj").getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
138 longArrayKlassObj = new TypeArrayKlass(longArrayKlassHandle, this);
a61af66fc99e Initial load
duke
parents:
diff changeset
139
a61af66fc99e Initial load
duke
parents:
diff changeset
140 singleArrayKlassHandle = universeType.getOopField("_singleArrayKlassObj").getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
141 singleArrayKlassObj = new TypeArrayKlass(singleArrayKlassHandle, this);
a61af66fc99e Initial load
duke
parents:
diff changeset
142
a61af66fc99e Initial load
duke
parents:
diff changeset
143 doubleArrayKlassHandle = universeType.getOopField("_doubleArrayKlassObj").getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
144 doubleArrayKlassObj = new TypeArrayKlass(doubleArrayKlassHandle, this);
a61af66fc99e Initial load
duke
parents:
diff changeset
145
a61af66fc99e Initial load
duke
parents:
diff changeset
146 if (!VM.getVM().isCore()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
147 methodDataKlassHandle = universeType.getOopField("_methodDataKlassObj").getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
148 methodDataKlassObj = new MethodDataKlass(methodDataKlassHandle, this);
a61af66fc99e Initial load
duke
parents:
diff changeset
149
a61af66fc99e Initial load
duke
parents:
diff changeset
150 compiledICHolderKlassHandle = universeType.getOopField("_compiledICHolderKlassObj").getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
151 compiledICHolderKlassObj= new CompiledICHolderKlass(compiledICHolderKlassHandle ,this);
a61af66fc99e Initial load
duke
parents:
diff changeset
152 }
a61af66fc99e Initial load
duke
parents:
diff changeset
153 }
a61af66fc99e Initial load
duke
parents:
diff changeset
154
a61af66fc99e Initial load
duke
parents:
diff changeset
155 public ObjectHeap(TypeDataBase db) throws WrongTypeException {
a61af66fc99e Initial load
duke
parents:
diff changeset
156 // Get commonly used sizes of basic types
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
157 oopSize = VM.getVM().getOopSize();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
158 byteSize = db.getJByteType().getSize();
a61af66fc99e Initial load
duke
parents:
diff changeset
159 charSize = db.getJCharType().getSize();
a61af66fc99e Initial load
duke
parents:
diff changeset
160 booleanSize = db.getJBooleanType().getSize();
a61af66fc99e Initial load
duke
parents:
diff changeset
161 intSize = db.getJIntType().getSize();
a61af66fc99e Initial load
duke
parents:
diff changeset
162 shortSize = db.getJShortType().getSize();
a61af66fc99e Initial load
duke
parents:
diff changeset
163 longSize = db.getJLongType().getSize();
a61af66fc99e Initial load
duke
parents:
diff changeset
164 floatSize = db.getJFloatType().getSize();
a61af66fc99e Initial load
duke
parents:
diff changeset
165 doubleSize = db.getJDoubleType().getSize();
a61af66fc99e Initial load
duke
parents:
diff changeset
166
a61af66fc99e Initial load
duke
parents:
diff changeset
167 initialize(db);
a61af66fc99e Initial load
duke
parents:
diff changeset
168 }
a61af66fc99e Initial load
duke
parents:
diff changeset
169
a61af66fc99e Initial load
duke
parents:
diff changeset
170 /** Comparison operation for oops, either or both of which may be null */
a61af66fc99e Initial load
duke
parents:
diff changeset
171 public boolean equal(Oop o1, Oop o2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
172 if (o1 != null) return o1.equals(o2);
a61af66fc99e Initial load
duke
parents:
diff changeset
173 return (o2 == null);
a61af66fc99e Initial load
duke
parents:
diff changeset
174 }
a61af66fc99e Initial load
duke
parents:
diff changeset
175
a61af66fc99e Initial load
duke
parents:
diff changeset
176 // Cached sizes of basic types
a61af66fc99e Initial load
duke
parents:
diff changeset
177 private long oopSize;
a61af66fc99e Initial load
duke
parents:
diff changeset
178 private long byteSize;
a61af66fc99e Initial load
duke
parents:
diff changeset
179 private long charSize;
a61af66fc99e Initial load
duke
parents:
diff changeset
180 private long booleanSize;
a61af66fc99e Initial load
duke
parents:
diff changeset
181 private long intSize;
a61af66fc99e Initial load
duke
parents:
diff changeset
182 private long shortSize;
a61af66fc99e Initial load
duke
parents:
diff changeset
183 private long longSize;
a61af66fc99e Initial load
duke
parents:
diff changeset
184 private long floatSize;
a61af66fc99e Initial load
duke
parents:
diff changeset
185 private long doubleSize;
a61af66fc99e Initial load
duke
parents:
diff changeset
186
a61af66fc99e Initial load
duke
parents:
diff changeset
187 public long getOopSize() { return oopSize; }
a61af66fc99e Initial load
duke
parents:
diff changeset
188 public long getByteSize() { return byteSize; }
a61af66fc99e Initial load
duke
parents:
diff changeset
189 public long getCharSize() { return charSize; }
a61af66fc99e Initial load
duke
parents:
diff changeset
190 public long getBooleanSize() { return booleanSize; }
a61af66fc99e Initial load
duke
parents:
diff changeset
191 public long getIntSize() { return intSize; }
a61af66fc99e Initial load
duke
parents:
diff changeset
192 public long getShortSize() { return shortSize; }
a61af66fc99e Initial load
duke
parents:
diff changeset
193 public long getLongSize() { return longSize; }
a61af66fc99e Initial load
duke
parents:
diff changeset
194 public long getFloatSize() { return floatSize; }
a61af66fc99e Initial load
duke
parents:
diff changeset
195 public long getDoubleSize() { return doubleSize; }
a61af66fc99e Initial load
duke
parents:
diff changeset
196
a61af66fc99e Initial load
duke
parents:
diff changeset
197 // Accessors for well-known system classes (from Universe)
a61af66fc99e Initial load
duke
parents:
diff changeset
198 public MethodKlass getMethodKlassObj() { return methodKlassObj; }
a61af66fc99e Initial load
duke
parents:
diff changeset
199 public ConstMethodKlass getConstMethodKlassObj() { return constMethodKlassObj; }
a61af66fc99e Initial load
duke
parents:
diff changeset
200 public MethodDataKlass getMethodDataKlassObj() { return methodDataKlassObj; }
a61af66fc99e Initial load
duke
parents:
diff changeset
201 public ConstantPoolKlass getConstantPoolKlassObj() { return constantPoolKlassObj; }
a61af66fc99e Initial load
duke
parents:
diff changeset
202 public ConstantPoolCacheKlass getConstantPoolCacheKlassObj() { return constantPoolCacheKlassObj; }
a61af66fc99e Initial load
duke
parents:
diff changeset
203 public KlassKlass getKlassKlassObj() { return klassKlassObj; }
a61af66fc99e Initial load
duke
parents:
diff changeset
204 public ArrayKlassKlass getArrayKlassKlassObj() { return arrayKlassKlassObj; }
a61af66fc99e Initial load
duke
parents:
diff changeset
205 public InstanceKlassKlass getInstanceKlassKlassObj() { return instanceKlassKlassObj; }
a61af66fc99e Initial load
duke
parents:
diff changeset
206 public ObjArrayKlassKlass getObjArrayKlassKlassObj() { return objArrayKlassKlassObj; }
a61af66fc99e Initial load
duke
parents:
diff changeset
207 public TypeArrayKlassKlass getTypeArrayKlassKlassObj() { return typeArrayKlassKlassObj; }
a61af66fc99e Initial load
duke
parents:
diff changeset
208 public TypeArrayKlass getBoolArrayKlassObj() { return boolArrayKlassObj; }
a61af66fc99e Initial load
duke
parents:
diff changeset
209 public TypeArrayKlass getByteArrayKlassObj() { return byteArrayKlassObj; }
a61af66fc99e Initial load
duke
parents:
diff changeset
210 public TypeArrayKlass getCharArrayKlassObj() { return charArrayKlassObj; }
a61af66fc99e Initial load
duke
parents:
diff changeset
211 public TypeArrayKlass getIntArrayKlassObj() { return intArrayKlassObj; }
a61af66fc99e Initial load
duke
parents:
diff changeset
212 public TypeArrayKlass getShortArrayKlassObj() { return shortArrayKlassObj; }
a61af66fc99e Initial load
duke
parents:
diff changeset
213 public TypeArrayKlass getLongArrayKlassObj() { return longArrayKlassObj; }
a61af66fc99e Initial load
duke
parents:
diff changeset
214 public TypeArrayKlass getSingleArrayKlassObj() { return singleArrayKlassObj; }
a61af66fc99e Initial load
duke
parents:
diff changeset
215 public TypeArrayKlass getDoubleArrayKlassObj() { return doubleArrayKlassObj; }
a61af66fc99e Initial load
duke
parents:
diff changeset
216 public CompiledICHolderKlass getCompiledICHolderKlassObj() {
a61af66fc99e Initial load
duke
parents:
diff changeset
217 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
218 Assert.that(!VM.getVM().isCore(), "must not be called for core build");
a61af66fc99e Initial load
duke
parents:
diff changeset
219 }
a61af66fc99e Initial load
duke
parents:
diff changeset
220 return compiledICHolderKlassObj;
a61af66fc99e Initial load
duke
parents:
diff changeset
221 }
a61af66fc99e Initial load
duke
parents:
diff changeset
222
a61af66fc99e Initial load
duke
parents:
diff changeset
223 /** Takes a BasicType and returns the corresponding primitive array
a61af66fc99e Initial load
duke
parents:
diff changeset
224 klass */
a61af66fc99e Initial load
duke
parents:
diff changeset
225 public Klass typeArrayKlassObj(int t) {
a61af66fc99e Initial load
duke
parents:
diff changeset
226 if (t == BasicType.getTBoolean()) return getBoolArrayKlassObj();
a61af66fc99e Initial load
duke
parents:
diff changeset
227 if (t == BasicType.getTChar()) return getCharArrayKlassObj();
a61af66fc99e Initial load
duke
parents:
diff changeset
228 if (t == BasicType.getTFloat()) return getSingleArrayKlassObj();
a61af66fc99e Initial load
duke
parents:
diff changeset
229 if (t == BasicType.getTDouble()) return getDoubleArrayKlassObj();
a61af66fc99e Initial load
duke
parents:
diff changeset
230 if (t == BasicType.getTByte()) return getByteArrayKlassObj();
a61af66fc99e Initial load
duke
parents:
diff changeset
231 if (t == BasicType.getTShort()) return getShortArrayKlassObj();
a61af66fc99e Initial load
duke
parents:
diff changeset
232 if (t == BasicType.getTInt()) return getIntArrayKlassObj();
a61af66fc99e Initial load
duke
parents:
diff changeset
233 if (t == BasicType.getTLong()) return getLongArrayKlassObj();
a61af66fc99e Initial load
duke
parents:
diff changeset
234 throw new RuntimeException("Illegal basic type " + t);
a61af66fc99e Initial load
duke
parents:
diff changeset
235 }
a61af66fc99e Initial load
duke
parents:
diff changeset
236
a61af66fc99e Initial load
duke
parents:
diff changeset
237 /** an interface to filter objects while walking heap */
a61af66fc99e Initial load
duke
parents:
diff changeset
238 public static interface ObjectFilter {
a61af66fc99e Initial load
duke
parents:
diff changeset
239 public boolean canInclude(Oop obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
240 }
a61af66fc99e Initial load
duke
parents:
diff changeset
241
a61af66fc99e Initial load
duke
parents:
diff changeset
242 /** The base heap iteration mechanism */
a61af66fc99e Initial load
duke
parents:
diff changeset
243 public void iterate(HeapVisitor visitor) {
a61af66fc99e Initial load
duke
parents:
diff changeset
244 iterateLiveRegions(collectLiveRegions(), visitor, null);
a61af66fc99e Initial load
duke
parents:
diff changeset
245 }
a61af66fc99e Initial load
duke
parents:
diff changeset
246
a61af66fc99e Initial load
duke
parents:
diff changeset
247 /** iterate objects satisfying a specified ObjectFilter */
a61af66fc99e Initial load
duke
parents:
diff changeset
248 public void iterate(HeapVisitor visitor, ObjectFilter of) {
a61af66fc99e Initial load
duke
parents:
diff changeset
249 iterateLiveRegions(collectLiveRegions(), visitor, of);
a61af66fc99e Initial load
duke
parents:
diff changeset
250 }
a61af66fc99e Initial load
duke
parents:
diff changeset
251
a61af66fc99e Initial load
duke
parents:
diff changeset
252 /** iterate objects of given Klass. param 'includeSubtypes' tells whether to
a61af66fc99e Initial load
duke
parents:
diff changeset
253 * include objects of subtypes or not */
a61af66fc99e Initial load
duke
parents:
diff changeset
254 public void iterateObjectsOfKlass(HeapVisitor visitor, final Klass k, boolean includeSubtypes) {
a61af66fc99e Initial load
duke
parents:
diff changeset
255 if (includeSubtypes) {
a61af66fc99e Initial load
duke
parents:
diff changeset
256 if (k.isFinal()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
257 // do the simpler "exact" klass loop
a61af66fc99e Initial load
duke
parents:
diff changeset
258 iterateExact(visitor, k);
a61af66fc99e Initial load
duke
parents:
diff changeset
259 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
260 iterateSubtypes(visitor, k);
a61af66fc99e Initial load
duke
parents:
diff changeset
261 }
a61af66fc99e Initial load
duke
parents:
diff changeset
262 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
263 // there can no object of abstract classes and interfaces
a61af66fc99e Initial load
duke
parents:
diff changeset
264 if (!k.isAbstract() && !k.isInterface()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
265 iterateExact(visitor, k);
a61af66fc99e Initial load
duke
parents:
diff changeset
266 }
a61af66fc99e Initial load
duke
parents:
diff changeset
267 }
a61af66fc99e Initial load
duke
parents:
diff changeset
268 }
a61af66fc99e Initial load
duke
parents:
diff changeset
269
a61af66fc99e Initial load
duke
parents:
diff changeset
270 /** iterate objects of given Klass (objects of subtypes included) */
a61af66fc99e Initial load
duke
parents:
diff changeset
271 public void iterateObjectsOfKlass(HeapVisitor visitor, final Klass k) {
a61af66fc99e Initial load
duke
parents:
diff changeset
272 iterateObjectsOfKlass(visitor, k, true);
a61af66fc99e Initial load
duke
parents:
diff changeset
273 }
a61af66fc99e Initial load
duke
parents:
diff changeset
274
a61af66fc99e Initial load
duke
parents:
diff changeset
275 /** This routine can be used to iterate through the heap at an
a61af66fc99e Initial load
duke
parents:
diff changeset
276 extremely low level (stepping word-by-word) to provide the
a61af66fc99e Initial load
duke
parents:
diff changeset
277 ability to do very low-level debugging */
a61af66fc99e Initial load
duke
parents:
diff changeset
278 public void iterateRaw(RawHeapVisitor visitor) {
a61af66fc99e Initial load
duke
parents:
diff changeset
279 List liveRegions = collectLiveRegions();
a61af66fc99e Initial load
duke
parents:
diff changeset
280
a61af66fc99e Initial load
duke
parents:
diff changeset
281 // Summarize size
a61af66fc99e Initial load
duke
parents:
diff changeset
282 long totalSize = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
283 for (int i = 0; i < liveRegions.size(); i += 2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
284 Address bottom = (Address) liveRegions.get(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
285 Address top = (Address) liveRegions.get(i+1);
a61af66fc99e Initial load
duke
parents:
diff changeset
286 totalSize += top.minus(bottom);
a61af66fc99e Initial load
duke
parents:
diff changeset
287 }
a61af66fc99e Initial load
duke
parents:
diff changeset
288 visitor.prologue(totalSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
289
a61af66fc99e Initial load
duke
parents:
diff changeset
290 for (int i = 0; i < liveRegions.size(); i += 2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
291 Address bottom = (Address) liveRegions.get(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
292 Address top = (Address) liveRegions.get(i+1);
a61af66fc99e Initial load
duke
parents:
diff changeset
293
a61af66fc99e Initial load
duke
parents:
diff changeset
294 // Traverses the space from bottom to top
a61af66fc99e Initial load
duke
parents:
diff changeset
295 while (bottom.lessThan(top)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
296 visitor.visitAddress(bottom);
a61af66fc99e Initial load
duke
parents:
diff changeset
297 bottom = bottom.addOffsetTo(VM.getVM().getAddressSize());
a61af66fc99e Initial load
duke
parents:
diff changeset
298 }
a61af66fc99e Initial load
duke
parents:
diff changeset
299 }
a61af66fc99e Initial load
duke
parents:
diff changeset
300
a61af66fc99e Initial load
duke
parents:
diff changeset
301 visitor.epilogue();
a61af66fc99e Initial load
duke
parents:
diff changeset
302 }
a61af66fc99e Initial load
duke
parents:
diff changeset
303
a61af66fc99e Initial load
duke
parents:
diff changeset
304 // Iterates through only the perm generation for the purpose of
a61af66fc99e Initial load
duke
parents:
diff changeset
305 // finding static fields for liveness analysis
a61af66fc99e Initial load
duke
parents:
diff changeset
306 public void iteratePerm(HeapVisitor visitor) {
a61af66fc99e Initial load
duke
parents:
diff changeset
307 CollectedHeap heap = VM.getVM().getUniverse().heap();
a61af66fc99e Initial load
duke
parents:
diff changeset
308 List liveRegions = new ArrayList();
a61af66fc99e Initial load
duke
parents:
diff changeset
309 addPermGenLiveRegions(liveRegions, heap);
a61af66fc99e Initial load
duke
parents:
diff changeset
310 sortLiveRegions(liveRegions);
a61af66fc99e Initial load
duke
parents:
diff changeset
311 iterateLiveRegions(liveRegions, visitor, null);
a61af66fc99e Initial load
duke
parents:
diff changeset
312 }
a61af66fc99e Initial load
duke
parents:
diff changeset
313
218
a5838065ab24 6620329: jstack prints double native methods on Solaris/sparc
swamyv
parents: 113
diff changeset
314 public boolean isValidMethod(OopHandle handle) {
a5838065ab24 6620329: jstack prints double native methods on Solaris/sparc
swamyv
parents: 113
diff changeset
315 OopHandle klass = Oop.getKlassForOopHandle(handle);
a5838065ab24 6620329: jstack prints double native methods on Solaris/sparc
swamyv
parents: 113
diff changeset
316 if (klass != null && klass.equals(methodKlassHandle)) {
a5838065ab24 6620329: jstack prints double native methods on Solaris/sparc
swamyv
parents: 113
diff changeset
317 return true;
a5838065ab24 6620329: jstack prints double native methods on Solaris/sparc
swamyv
parents: 113
diff changeset
318 }
a5838065ab24 6620329: jstack prints double native methods on Solaris/sparc
swamyv
parents: 113
diff changeset
319 return false;
a5838065ab24 6620329: jstack prints double native methods on Solaris/sparc
swamyv
parents: 113
diff changeset
320 }
a5838065ab24 6620329: jstack prints double native methods on Solaris/sparc
swamyv
parents: 113
diff changeset
321
0
a61af66fc99e Initial load
duke
parents:
diff changeset
322 // Creates an instance from the Oop hierarchy based based on the handle
a61af66fc99e Initial load
duke
parents:
diff changeset
323 public Oop newOop(OopHandle handle) {
a61af66fc99e Initial load
duke
parents:
diff changeset
324 // The only known way to detect the right type of an oop is
a61af66fc99e Initial load
duke
parents:
diff changeset
325 // traversing the class chain until a well-known klass is recognized.
a61af66fc99e Initial load
duke
parents:
diff changeset
326 // A more direct solution would require the klasses to expose
a61af66fc99e Initial load
duke
parents:
diff changeset
327 // the C++ vtbl structure.
a61af66fc99e Initial load
duke
parents:
diff changeset
328
a61af66fc99e Initial load
duke
parents:
diff changeset
329 // Handle the null reference
a61af66fc99e Initial load
duke
parents:
diff changeset
330 if (handle == null) return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
331
a61af66fc99e Initial load
duke
parents:
diff changeset
332 // First check if handle is one of the root objects
a61af66fc99e Initial load
duke
parents:
diff changeset
333 if (handle.equals(methodKlassHandle)) return getMethodKlassObj();
a61af66fc99e Initial load
duke
parents:
diff changeset
334 if (handle.equals(constMethodKlassHandle)) return getConstMethodKlassObj();
a61af66fc99e Initial load
duke
parents:
diff changeset
335 if (handle.equals(constantPoolKlassHandle)) return getConstantPoolKlassObj();
a61af66fc99e Initial load
duke
parents:
diff changeset
336 if (handle.equals(constantPoolCacheKlassHandle)) return getConstantPoolCacheKlassObj();
a61af66fc99e Initial load
duke
parents:
diff changeset
337 if (handle.equals(instanceKlassKlassHandle)) return getInstanceKlassKlassObj();
a61af66fc99e Initial load
duke
parents:
diff changeset
338 if (handle.equals(objArrayKlassKlassHandle)) return getObjArrayKlassKlassObj();
a61af66fc99e Initial load
duke
parents:
diff changeset
339 if (handle.equals(klassKlassHandle)) return getKlassKlassObj();
a61af66fc99e Initial load
duke
parents:
diff changeset
340 if (handle.equals(arrayKlassKlassHandle)) return getArrayKlassKlassObj();
a61af66fc99e Initial load
duke
parents:
diff changeset
341 if (handle.equals(typeArrayKlassKlassHandle)) return getTypeArrayKlassKlassObj();
a61af66fc99e Initial load
duke
parents:
diff changeset
342 if (handle.equals(boolArrayKlassHandle)) return getBoolArrayKlassObj();
a61af66fc99e Initial load
duke
parents:
diff changeset
343 if (handle.equals(byteArrayKlassHandle)) return getByteArrayKlassObj();
a61af66fc99e Initial load
duke
parents:
diff changeset
344 if (handle.equals(charArrayKlassHandle)) return getCharArrayKlassObj();
a61af66fc99e Initial load
duke
parents:
diff changeset
345 if (handle.equals(intArrayKlassHandle)) return getIntArrayKlassObj();
a61af66fc99e Initial load
duke
parents:
diff changeset
346 if (handle.equals(shortArrayKlassHandle)) return getShortArrayKlassObj();
a61af66fc99e Initial load
duke
parents:
diff changeset
347 if (handle.equals(longArrayKlassHandle)) return getLongArrayKlassObj();
a61af66fc99e Initial load
duke
parents:
diff changeset
348 if (handle.equals(singleArrayKlassHandle)) return getSingleArrayKlassObj();
a61af66fc99e Initial load
duke
parents:
diff changeset
349 if (handle.equals(doubleArrayKlassHandle)) return getDoubleArrayKlassObj();
a61af66fc99e Initial load
duke
parents:
diff changeset
350 if (!VM.getVM().isCore()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
351 if (handle.equals(compiledICHolderKlassHandle)) return getCompiledICHolderKlassObj();
a61af66fc99e Initial load
duke
parents:
diff changeset
352 if (handle.equals(methodDataKlassHandle)) return getMethodDataKlassObj();
a61af66fc99e Initial load
duke
parents:
diff changeset
353 }
a61af66fc99e Initial load
duke
parents:
diff changeset
354
a61af66fc99e Initial load
duke
parents:
diff changeset
355 // Then check if obj.klass() is one of the root objects
a61af66fc99e Initial load
duke
parents:
diff changeset
356 OopHandle klass = Oop.getKlassForOopHandle(handle);
a61af66fc99e Initial load
duke
parents:
diff changeset
357 if (klass != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
358 if (klass.equals(methodKlassHandle)) return new Method(handle, this);
a61af66fc99e Initial load
duke
parents:
diff changeset
359 if (klass.equals(constMethodKlassHandle)) return new ConstMethod(handle, this);
a61af66fc99e Initial load
duke
parents:
diff changeset
360 if (klass.equals(constantPoolKlassHandle)) return new ConstantPool(handle, this);
a61af66fc99e Initial load
duke
parents:
diff changeset
361 if (klass.equals(constantPoolCacheKlassHandle)) return new ConstantPoolCache(handle, this);
a61af66fc99e Initial load
duke
parents:
diff changeset
362 if (!VM.getVM().isCore()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
363 if (klass.equals(compiledICHolderKlassHandle)) return new CompiledICHolder(handle, this);
a61af66fc99e Initial load
duke
parents:
diff changeset
364 if (klass.equals(methodDataKlassHandle)) return new MethodData(handle, this);
a61af66fc99e Initial load
duke
parents:
diff changeset
365 }
2411
63997f575155 7031614: jmap -permstat fails with java.lang.InternalError in sun.jvm.hotspot.oops.OopField.getValue
never
parents: 2177
diff changeset
366 if (klass.equals(instanceKlassKlassHandle)) {
63997f575155 7031614: jmap -permstat fails with java.lang.InternalError in sun.jvm.hotspot.oops.OopField.getValue
never
parents: 2177
diff changeset
367 InstanceKlass ik = new InstanceKlass(handle, this);
63997f575155 7031614: jmap -permstat fails with java.lang.InternalError in sun.jvm.hotspot.oops.OopField.getValue
never
parents: 2177
diff changeset
368 if (ik.getName().asString().equals("java/lang/Class")) {
63997f575155 7031614: jmap -permstat fails with java.lang.InternalError in sun.jvm.hotspot.oops.OopField.getValue
never
parents: 2177
diff changeset
369 // We would normally do this using the vtable style
63997f575155 7031614: jmap -permstat fails with java.lang.InternalError in sun.jvm.hotspot.oops.OopField.getValue
never
parents: 2177
diff changeset
370 // lookup but since it's not used for these currently
63997f575155 7031614: jmap -permstat fails with java.lang.InternalError in sun.jvm.hotspot.oops.OopField.getValue
never
parents: 2177
diff changeset
371 // it's simpler to just check for the name.
63997f575155 7031614: jmap -permstat fails with java.lang.InternalError in sun.jvm.hotspot.oops.OopField.getValue
never
parents: 2177
diff changeset
372 return new InstanceMirrorKlass(handle, this);
63997f575155 7031614: jmap -permstat fails with java.lang.InternalError in sun.jvm.hotspot.oops.OopField.getValue
never
parents: 2177
diff changeset
373 }
63997f575155 7031614: jmap -permstat fails with java.lang.InternalError in sun.jvm.hotspot.oops.OopField.getValue
never
parents: 2177
diff changeset
374 return ik;
63997f575155 7031614: jmap -permstat fails with java.lang.InternalError in sun.jvm.hotspot.oops.OopField.getValue
never
parents: 2177
diff changeset
375 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
376 if (klass.equals(objArrayKlassKlassHandle)) return new ObjArrayKlass(handle, this);
a61af66fc99e Initial load
duke
parents:
diff changeset
377 if (klass.equals(typeArrayKlassKlassHandle)) return new TypeArrayKlass(handle, this);
a61af66fc99e Initial load
duke
parents:
diff changeset
378
a61af66fc99e Initial load
duke
parents:
diff changeset
379 // Lastly check if obj.klass().klass() is on of the root objects
a61af66fc99e Initial load
duke
parents:
diff changeset
380 OopHandle klassKlass = Oop.getKlassForOopHandle(klass);
a61af66fc99e Initial load
duke
parents:
diff changeset
381 if (klassKlass != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
382 if (klassKlass.equals(instanceKlassKlassHandle)) return new Instance(handle, this);
a61af66fc99e Initial load
duke
parents:
diff changeset
383 if (klassKlass.equals(objArrayKlassKlassHandle)) return new ObjArray(handle, this);
a61af66fc99e Initial load
duke
parents:
diff changeset
384 if (klassKlass.equals(typeArrayKlassKlassHandle)) return new TypeArray(handle, this);
a61af66fc99e Initial load
duke
parents:
diff changeset
385 }
a61af66fc99e Initial load
duke
parents:
diff changeset
386 }
a61af66fc99e Initial load
duke
parents:
diff changeset
387
218
a5838065ab24 6620329: jstack prints double native methods on Solaris/sparc
swamyv
parents: 113
diff changeset
388 if (DEBUG) {
a5838065ab24 6620329: jstack prints double native methods on Solaris/sparc
swamyv
parents: 113
diff changeset
389 System.err.println("Unknown oop at " + handle);
a5838065ab24 6620329: jstack prints double native methods on Solaris/sparc
swamyv
parents: 113
diff changeset
390 System.err.println("Oop's klass is " + klass);
a5838065ab24 6620329: jstack prints double native methods on Solaris/sparc
swamyv
parents: 113
diff changeset
391 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
392
a61af66fc99e Initial load
duke
parents:
diff changeset
393 throw new UnknownOopException();
a61af66fc99e Initial load
duke
parents:
diff changeset
394 }
a61af66fc99e Initial load
duke
parents:
diff changeset
395
a61af66fc99e Initial load
duke
parents:
diff changeset
396 // Print all objects in the object heap
a61af66fc99e Initial load
duke
parents:
diff changeset
397 public void print() {
a61af66fc99e Initial load
duke
parents:
diff changeset
398 HeapPrinter printer = new HeapPrinter(System.out);
a61af66fc99e Initial load
duke
parents:
diff changeset
399 iterate(printer);
a61af66fc99e Initial load
duke
parents:
diff changeset
400 }
a61af66fc99e Initial load
duke
parents:
diff changeset
401
a61af66fc99e Initial load
duke
parents:
diff changeset
402 //---------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
403 // Internals only below this point
a61af66fc99e Initial load
duke
parents:
diff changeset
404 //
a61af66fc99e Initial load
duke
parents:
diff changeset
405
a61af66fc99e Initial load
duke
parents:
diff changeset
406 private void iterateExact(HeapVisitor visitor, final Klass k) {
a61af66fc99e Initial load
duke
parents:
diff changeset
407 iterateLiveRegions(collectLiveRegions(), visitor, new ObjectFilter() {
a61af66fc99e Initial load
duke
parents:
diff changeset
408 public boolean canInclude(Oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
409 Klass tk = obj.getKlass();
a61af66fc99e Initial load
duke
parents:
diff changeset
410 // null Klass is seen sometimes!
a61af66fc99e Initial load
duke
parents:
diff changeset
411 return (tk != null && tk.equals(k));
a61af66fc99e Initial load
duke
parents:
diff changeset
412 }
a61af66fc99e Initial load
duke
parents:
diff changeset
413 });
a61af66fc99e Initial load
duke
parents:
diff changeset
414 }
a61af66fc99e Initial load
duke
parents:
diff changeset
415
a61af66fc99e Initial load
duke
parents:
diff changeset
416 private void iterateSubtypes(HeapVisitor visitor, final Klass k) {
a61af66fc99e Initial load
duke
parents:
diff changeset
417 iterateLiveRegions(collectLiveRegions(), visitor, new ObjectFilter() {
a61af66fc99e Initial load
duke
parents:
diff changeset
418 public boolean canInclude(Oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
419 Klass tk = obj.getKlass();
a61af66fc99e Initial load
duke
parents:
diff changeset
420 // null Klass is seen sometimes!
a61af66fc99e Initial load
duke
parents:
diff changeset
421 return (tk != null && tk.isSubtypeOf(k));
a61af66fc99e Initial load
duke
parents:
diff changeset
422 }
a61af66fc99e Initial load
duke
parents:
diff changeset
423 });
a61af66fc99e Initial load
duke
parents:
diff changeset
424 }
a61af66fc99e Initial load
duke
parents:
diff changeset
425
a61af66fc99e Initial load
duke
parents:
diff changeset
426 private void iterateLiveRegions(List liveRegions, HeapVisitor visitor, ObjectFilter of) {
a61af66fc99e Initial load
duke
parents:
diff changeset
427 // Summarize size
a61af66fc99e Initial load
duke
parents:
diff changeset
428 long totalSize = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
429 for (int i = 0; i < liveRegions.size(); i += 2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
430 Address bottom = (Address) liveRegions.get(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
431 Address top = (Address) liveRegions.get(i+1);
a61af66fc99e Initial load
duke
parents:
diff changeset
432 totalSize += top.minus(bottom);
a61af66fc99e Initial load
duke
parents:
diff changeset
433 }
a61af66fc99e Initial load
duke
parents:
diff changeset
434 visitor.prologue(totalSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
435
a61af66fc99e Initial load
duke
parents:
diff changeset
436 CompactibleFreeListSpace cmsSpaceOld = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
437 CompactibleFreeListSpace cmsSpacePerm = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
438 CollectedHeap heap = VM.getVM().getUniverse().heap();
a61af66fc99e Initial load
duke
parents:
diff changeset
439
a61af66fc99e Initial load
duke
parents:
diff changeset
440 if (heap instanceof GenCollectedHeap) {
a61af66fc99e Initial load
duke
parents:
diff changeset
441 GenCollectedHeap genHeap = (GenCollectedHeap) heap;
a61af66fc99e Initial load
duke
parents:
diff changeset
442 Generation genOld = genHeap.getGen(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
443 Generation genPerm = genHeap.permGen();
a61af66fc99e Initial load
duke
parents:
diff changeset
444 if (genOld instanceof ConcurrentMarkSweepGeneration) {
a61af66fc99e Initial load
duke
parents:
diff changeset
445 ConcurrentMarkSweepGeneration concGen = (ConcurrentMarkSweepGeneration)genOld;
a61af66fc99e Initial load
duke
parents:
diff changeset
446 cmsSpaceOld = concGen.cmsSpace();
a61af66fc99e Initial load
duke
parents:
diff changeset
447 }
a61af66fc99e Initial load
duke
parents:
diff changeset
448 if (genPerm instanceof ConcurrentMarkSweepGeneration) {
a61af66fc99e Initial load
duke
parents:
diff changeset
449 ConcurrentMarkSweepGeneration concGen = (ConcurrentMarkSweepGeneration)genPerm;
a61af66fc99e Initial load
duke
parents:
diff changeset
450 cmsSpacePerm = concGen.cmsSpace();
a61af66fc99e Initial load
duke
parents:
diff changeset
451 }
a61af66fc99e Initial load
duke
parents:
diff changeset
452 }
a61af66fc99e Initial load
duke
parents:
diff changeset
453
a61af66fc99e Initial load
duke
parents:
diff changeset
454 for (int i = 0; i < liveRegions.size(); i += 2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
455 Address bottom = (Address) liveRegions.get(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
456 Address top = (Address) liveRegions.get(i+1);
a61af66fc99e Initial load
duke
parents:
diff changeset
457
a61af66fc99e Initial load
duke
parents:
diff changeset
458 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
459 // Traverses the space from bottom to top
a61af66fc99e Initial load
duke
parents:
diff changeset
460 OopHandle handle = bottom.addOffsetToAsOopHandle(0);
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
461
0
a61af66fc99e Initial load
duke
parents:
diff changeset
462 while (handle.lessThan(top)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
463 Oop obj = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
464
a61af66fc99e Initial load
duke
parents:
diff changeset
465 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
466 obj = newOop(handle);
a61af66fc99e Initial load
duke
parents:
diff changeset
467 } catch (UnknownOopException exp) {
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
468 if (DEBUG) {
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
469 throw new RuntimeException(" UnknownOopException " + exp);
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
470 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
471 }
a61af66fc99e Initial load
duke
parents:
diff changeset
472 if (obj == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
473 //Find the object size using Printezis bits and skip over
a61af66fc99e Initial load
duke
parents:
diff changeset
474 System.err.println("Finding object size using Printezis bits and skipping over...");
a61af66fc99e Initial load
duke
parents:
diff changeset
475 long size = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
476
a61af66fc99e Initial load
duke
parents:
diff changeset
477 if ( (cmsSpaceOld != null) && cmsSpaceOld.contains(handle) ){
a61af66fc99e Initial load
duke
parents:
diff changeset
478 size = cmsSpaceOld.collector().blockSizeUsingPrintezisBits(handle);
a61af66fc99e Initial load
duke
parents:
diff changeset
479 } else if ((cmsSpacePerm != null) && cmsSpacePerm.contains(handle) ){
a61af66fc99e Initial load
duke
parents:
diff changeset
480 size = cmsSpacePerm.collector().blockSizeUsingPrintezisBits(handle);
a61af66fc99e Initial load
duke
parents:
diff changeset
481 }
a61af66fc99e Initial load
duke
parents:
diff changeset
482
a61af66fc99e Initial load
duke
parents:
diff changeset
483 if (size <= 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
484 //Either Printezis bits not set or handle is not in cms space.
a61af66fc99e Initial load
duke
parents:
diff changeset
485 throw new UnknownOopException();
a61af66fc99e Initial load
duke
parents:
diff changeset
486 }
a61af66fc99e Initial load
duke
parents:
diff changeset
487
a61af66fc99e Initial load
duke
parents:
diff changeset
488 handle = handle.addOffsetToAsOopHandle(CompactibleFreeListSpace.adjustObjectSizeInBytes(size));
a61af66fc99e Initial load
duke
parents:
diff changeset
489 continue;
a61af66fc99e Initial load
duke
parents:
diff changeset
490 }
a61af66fc99e Initial load
duke
parents:
diff changeset
491 if (of == null || of.canInclude(obj)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
492 if (visitor.doObj(obj)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
493 // doObj() returns true to abort this loop.
a61af66fc99e Initial load
duke
parents:
diff changeset
494 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
495 }
a61af66fc99e Initial load
duke
parents:
diff changeset
496 }
a61af66fc99e Initial load
duke
parents:
diff changeset
497 if ( (cmsSpaceOld != null) && cmsSpaceOld.contains(handle) ||
a61af66fc99e Initial load
duke
parents:
diff changeset
498 (cmsSpacePerm != null) && cmsSpacePerm.contains(handle) ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
499 handle = handle.addOffsetToAsOopHandle(CompactibleFreeListSpace.adjustObjectSizeInBytes(obj.getObjectSize()) );
a61af66fc99e Initial load
duke
parents:
diff changeset
500 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
501 handle = handle.addOffsetToAsOopHandle(obj.getObjectSize());
a61af66fc99e Initial load
duke
parents:
diff changeset
502 }
a61af66fc99e Initial load
duke
parents:
diff changeset
503 }
a61af66fc99e Initial load
duke
parents:
diff changeset
504 }
a61af66fc99e Initial load
duke
parents:
diff changeset
505 catch (AddressException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
506 // This is okay at the top of these regions
a61af66fc99e Initial load
duke
parents:
diff changeset
507 }
a61af66fc99e Initial load
duke
parents:
diff changeset
508 catch (UnknownOopException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
509 // This is okay at the top of these regions
a61af66fc99e Initial load
duke
parents:
diff changeset
510 }
a61af66fc99e Initial load
duke
parents:
diff changeset
511 }
a61af66fc99e Initial load
duke
parents:
diff changeset
512
a61af66fc99e Initial load
duke
parents:
diff changeset
513 visitor.epilogue();
a61af66fc99e Initial load
duke
parents:
diff changeset
514 }
a61af66fc99e Initial load
duke
parents:
diff changeset
515
a61af66fc99e Initial load
duke
parents:
diff changeset
516 private void addPermGenLiveRegions(List output, CollectedHeap heap) {
a61af66fc99e Initial load
duke
parents:
diff changeset
517 LiveRegionsCollector lrc = new LiveRegionsCollector(output);
3972
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 2411
diff changeset
518 if (heap instanceof SharedHeap) {
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 2411
diff changeset
519 if (Assert.ASSERTS_ENABLED) {
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 2411
diff changeset
520 Assert.that(heap instanceof GenCollectedHeap ||
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 2411
diff changeset
521 heap instanceof G1CollectedHeap,
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 2411
diff changeset
522 "Expecting GenCollectedHeap or G1CollectedHeap, " +
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 2411
diff changeset
523 "but got " + heap.getClass().getName());
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 2411
diff changeset
524 }
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 2411
diff changeset
525 // Handles both GenCollectedHeap and G1CollectedHeap
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 2411
diff changeset
526 SharedHeap sharedHeap = (SharedHeap) heap;
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 2411
diff changeset
527 Generation gen = sharedHeap.permGen();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
528 gen.spaceIterate(lrc, true);
a61af66fc99e Initial load
duke
parents:
diff changeset
529 } else if (heap instanceof ParallelScavengeHeap) {
a61af66fc99e Initial load
duke
parents:
diff changeset
530 ParallelScavengeHeap psh = (ParallelScavengeHeap) heap;
a61af66fc99e Initial load
duke
parents:
diff changeset
531 PSPermGen permGen = psh.permGen();
a61af66fc99e Initial load
duke
parents:
diff changeset
532 addLiveRegions(permGen.objectSpace().getLiveRegions(), output);
a61af66fc99e Initial load
duke
parents:
diff changeset
533 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
534 if (Assert.ASSERTS_ENABLED) {
3972
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 2411
diff changeset
535 Assert.that(false,
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 2411
diff changeset
536 "Expecting SharedHeap or ParallelScavengeHeap, " +
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 2411
diff changeset
537 "but got " + heap.getClass().getName());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
538 }
a61af66fc99e Initial load
duke
parents:
diff changeset
539 }
a61af66fc99e Initial load
duke
parents:
diff changeset
540 }
a61af66fc99e Initial load
duke
parents:
diff changeset
541
a61af66fc99e Initial load
duke
parents:
diff changeset
542 private void addLiveRegions(List input, List output) {
a61af66fc99e Initial load
duke
parents:
diff changeset
543 for (Iterator itr = input.iterator(); itr.hasNext();) {
a61af66fc99e Initial load
duke
parents:
diff changeset
544 MemRegion reg = (MemRegion) itr.next();
a61af66fc99e Initial load
duke
parents:
diff changeset
545 Address top = reg.end();
a61af66fc99e Initial load
duke
parents:
diff changeset
546 Address bottom = reg.start();
a61af66fc99e Initial load
duke
parents:
diff changeset
547 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
548 Assert.that(top != null, "top address in a live region should not be null");
a61af66fc99e Initial load
duke
parents:
diff changeset
549 }
a61af66fc99e Initial load
duke
parents:
diff changeset
550 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
551 Assert.that(bottom != null, "bottom address in a live region should not be null");
a61af66fc99e Initial load
duke
parents:
diff changeset
552 }
a61af66fc99e Initial load
duke
parents:
diff changeset
553 output.add(top);
a61af66fc99e Initial load
duke
parents:
diff changeset
554 output.add(bottom);
a61af66fc99e Initial load
duke
parents:
diff changeset
555 }
a61af66fc99e Initial load
duke
parents:
diff changeset
556 }
a61af66fc99e Initial load
duke
parents:
diff changeset
557
a61af66fc99e Initial load
duke
parents:
diff changeset
558 private class LiveRegionsCollector implements SpaceClosure {
a61af66fc99e Initial load
duke
parents:
diff changeset
559 LiveRegionsCollector(List l) {
a61af66fc99e Initial load
duke
parents:
diff changeset
560 liveRegions = l;
a61af66fc99e Initial load
duke
parents:
diff changeset
561 }
a61af66fc99e Initial load
duke
parents:
diff changeset
562
a61af66fc99e Initial load
duke
parents:
diff changeset
563 public void doSpace(Space s) {
a61af66fc99e Initial load
duke
parents:
diff changeset
564 addLiveRegions(s.getLiveRegions(), liveRegions);
a61af66fc99e Initial load
duke
parents:
diff changeset
565 }
a61af66fc99e Initial load
duke
parents:
diff changeset
566 private List liveRegions;
a61af66fc99e Initial load
duke
parents:
diff changeset
567 }
a61af66fc99e Initial load
duke
parents:
diff changeset
568
a61af66fc99e Initial load
duke
parents:
diff changeset
569 // Returns a List<Address> where the addresses come in pairs. These
a61af66fc99e Initial load
duke
parents:
diff changeset
570 // designate the live regions of the heap.
a61af66fc99e Initial load
duke
parents:
diff changeset
571 private List collectLiveRegions() {
a61af66fc99e Initial load
duke
parents:
diff changeset
572 // We want to iterate through all live portions of the heap, but
a61af66fc99e Initial load
duke
parents:
diff changeset
573 // do not want to abort the heap traversal prematurely if we find
a61af66fc99e Initial load
duke
parents:
diff changeset
574 // a problem (like an allocated but uninitialized object at the
a61af66fc99e Initial load
duke
parents:
diff changeset
575 // top of a generation). To do this we enumerate all generations'
a61af66fc99e Initial load
duke
parents:
diff changeset
576 // bottom and top regions, and factor in TLABs if necessary.
a61af66fc99e Initial load
duke
parents:
diff changeset
577
a61af66fc99e Initial load
duke
parents:
diff changeset
578 // List<Address>. Addresses come in pairs.
a61af66fc99e Initial load
duke
parents:
diff changeset
579 List liveRegions = new ArrayList();
a61af66fc99e Initial load
duke
parents:
diff changeset
580 LiveRegionsCollector lrc = new LiveRegionsCollector(liveRegions);
a61af66fc99e Initial load
duke
parents:
diff changeset
581
a61af66fc99e Initial load
duke
parents:
diff changeset
582 CollectedHeap heap = VM.getVM().getUniverse().heap();
a61af66fc99e Initial load
duke
parents:
diff changeset
583
a61af66fc99e Initial load
duke
parents:
diff changeset
584 if (heap instanceof GenCollectedHeap) {
a61af66fc99e Initial load
duke
parents:
diff changeset
585 GenCollectedHeap genHeap = (GenCollectedHeap) heap;
a61af66fc99e Initial load
duke
parents:
diff changeset
586 // Run through all generations, obtaining bottom-top pairs.
a61af66fc99e Initial load
duke
parents:
diff changeset
587 for (int i = 0; i < genHeap.nGens(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
588 Generation gen = genHeap.getGen(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
589 gen.spaceIterate(lrc, true);
a61af66fc99e Initial load
duke
parents:
diff changeset
590 }
a61af66fc99e Initial load
duke
parents:
diff changeset
591 } else if (heap instanceof ParallelScavengeHeap) {
a61af66fc99e Initial load
duke
parents:
diff changeset
592 ParallelScavengeHeap psh = (ParallelScavengeHeap) heap;
a61af66fc99e Initial load
duke
parents:
diff changeset
593 PSYoungGen youngGen = psh.youngGen();
a61af66fc99e Initial load
duke
parents:
diff changeset
594 // Add eden space
a61af66fc99e Initial load
duke
parents:
diff changeset
595 addLiveRegions(youngGen.edenSpace().getLiveRegions(), liveRegions);
a61af66fc99e Initial load
duke
parents:
diff changeset
596 // Add from-space but not to-space
a61af66fc99e Initial load
duke
parents:
diff changeset
597 addLiveRegions(youngGen.fromSpace().getLiveRegions(), liveRegions);
a61af66fc99e Initial load
duke
parents:
diff changeset
598 PSOldGen oldGen = psh.oldGen();
a61af66fc99e Initial load
duke
parents:
diff changeset
599 addLiveRegions(oldGen.objectSpace().getLiveRegions(), liveRegions);
3972
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 2411
diff changeset
600 } else if (heap instanceof G1CollectedHeap) {
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 2411
diff changeset
601 G1CollectedHeap g1h = (G1CollectedHeap) heap;
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 2411
diff changeset
602 g1h.heapRegionIterate(lrc);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
603 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
604 if (Assert.ASSERTS_ENABLED) {
3972
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 2411
diff changeset
605 Assert.that(false, "Expecting GenCollectedHeap, G1CollectedHeap, " +
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 2411
diff changeset
606 "or ParallelScavengeHeap, but got " +
4f93f0d00802 7059019: G1: add G1 support to the SA
tonyp
parents: 2411
diff changeset
607 heap.getClass().getName());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
608 }
a61af66fc99e Initial load
duke
parents:
diff changeset
609 }
a61af66fc99e Initial load
duke
parents:
diff changeset
610
a61af66fc99e Initial load
duke
parents:
diff changeset
611 // handle perm generation
a61af66fc99e Initial load
duke
parents:
diff changeset
612 addPermGenLiveRegions(liveRegions, heap);
a61af66fc99e Initial load
duke
parents:
diff changeset
613
a61af66fc99e Initial load
duke
parents:
diff changeset
614 // If UseTLAB is enabled, snip out regions associated with TLABs'
a61af66fc99e Initial load
duke
parents:
diff changeset
615 // dead regions. Note that TLABs can be present in any generation.
a61af66fc99e Initial load
duke
parents:
diff changeset
616
a61af66fc99e Initial load
duke
parents:
diff changeset
617 // FIXME: consider adding fewer boundaries to live region list.
a61af66fc99e Initial load
duke
parents:
diff changeset
618 // Theoretically only need to stop at TLAB's top and resume at its
a61af66fc99e Initial load
duke
parents:
diff changeset
619 // end.
a61af66fc99e Initial load
duke
parents:
diff changeset
620
a61af66fc99e Initial load
duke
parents:
diff changeset
621 if (VM.getVM().getUseTLAB()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
622 for (JavaThread thread = VM.getVM().getThreads().first(); thread != null; thread = thread.next()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
623 if (thread.isJavaThread()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
624 ThreadLocalAllocBuffer tlab = thread.tlab();
a61af66fc99e Initial load
duke
parents:
diff changeset
625 if (tlab.start() != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
626 if ((tlab.top() == null) || (tlab.end() == null)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
627 System.err.print("Warning: skipping invalid TLAB for thread ");
a61af66fc99e Initial load
duke
parents:
diff changeset
628 thread.printThreadIDOn(System.err);
a61af66fc99e Initial load
duke
parents:
diff changeset
629 System.err.println();
a61af66fc99e Initial load
duke
parents:
diff changeset
630 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
631 // Go from:
a61af66fc99e Initial load
duke
parents:
diff changeset
632 // - below start() to start()
a61af66fc99e Initial load
duke
parents:
diff changeset
633 // - start() to top()
a61af66fc99e Initial load
duke
parents:
diff changeset
634 // - end() and above
a61af66fc99e Initial load
duke
parents:
diff changeset
635 liveRegions.add(tlab.start());
a61af66fc99e Initial load
duke
parents:
diff changeset
636 liveRegions.add(tlab.start());
a61af66fc99e Initial load
duke
parents:
diff changeset
637 liveRegions.add(tlab.top());
a61af66fc99e Initial load
duke
parents:
diff changeset
638 liveRegions.add(tlab.end());
a61af66fc99e Initial load
duke
parents:
diff changeset
639 }
a61af66fc99e Initial load
duke
parents:
diff changeset
640 }
a61af66fc99e Initial load
duke
parents:
diff changeset
641 }
a61af66fc99e Initial load
duke
parents:
diff changeset
642 }
a61af66fc99e Initial load
duke
parents:
diff changeset
643 }
a61af66fc99e Initial load
duke
parents:
diff changeset
644
a61af66fc99e Initial load
duke
parents:
diff changeset
645 // Now sort live regions
a61af66fc99e Initial load
duke
parents:
diff changeset
646 sortLiveRegions(liveRegions);
a61af66fc99e Initial load
duke
parents:
diff changeset
647
a61af66fc99e Initial load
duke
parents:
diff changeset
648 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
649 Assert.that(liveRegions.size() % 2 == 0, "Must have even number of region boundaries");
a61af66fc99e Initial load
duke
parents:
diff changeset
650 }
a61af66fc99e Initial load
duke
parents:
diff changeset
651
a61af66fc99e Initial load
duke
parents:
diff changeset
652 return liveRegions;
a61af66fc99e Initial load
duke
parents:
diff changeset
653 }
a61af66fc99e Initial load
duke
parents:
diff changeset
654
a61af66fc99e Initial load
duke
parents:
diff changeset
655 private void sortLiveRegions(List liveRegions) {
a61af66fc99e Initial load
duke
parents:
diff changeset
656 Collections.sort(liveRegions, new Comparator() {
a61af66fc99e Initial load
duke
parents:
diff changeset
657 public int compare(Object o1, Object o2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
658 Address a1 = (Address) o1;
a61af66fc99e Initial load
duke
parents:
diff changeset
659 Address a2 = (Address) o2;
a61af66fc99e Initial load
duke
parents:
diff changeset
660 if (AddressOps.lt(a1, a2)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
661 return -1;
a61af66fc99e Initial load
duke
parents:
diff changeset
662 } else if (AddressOps.gt(a1, a2)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
663 return 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
664 }
a61af66fc99e Initial load
duke
parents:
diff changeset
665 return 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
666 }
a61af66fc99e Initial load
duke
parents:
diff changeset
667 });
a61af66fc99e Initial load
duke
parents:
diff changeset
668 }
a61af66fc99e Initial load
duke
parents:
diff changeset
669 }