author | coleenp |
Tue, 28 Aug 2018 18:17:01 -0400 | |
changeset 51554 | 5b0d86499960 |
parent 50523 | 7b7c75d87f9b |
child 51741 | ed9b1200dd81 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
51554
5b0d86499960
8209958: Clean up duplicate basic array type statics in Universe
coleenp
parents:
50523
diff
changeset
|
2 |
* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
781
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
781
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
781
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
25 |
// |
|
26 |
// The ObjectHeap is an abstraction over all generations in the VM |
|
27 |
// It gives access to all present objects and classes. |
|
28 |
// |
|
29 |
||
30 |
package sun.jvm.hotspot.oops; |
|
31 |
||
32 |
import java.util.*; |
|
33 |
||
34 |
import sun.jvm.hotspot.debugger.*; |
|
30769 | 35 |
import sun.jvm.hotspot.gc.cms.*; |
30764 | 36 |
import sun.jvm.hotspot.gc.shared.*; |
50523
7b7c75d87f9b
8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
47216
diff
changeset
|
37 |
import sun.jvm.hotspot.gc.epsilon.*; |
30764 | 38 |
import sun.jvm.hotspot.gc.g1.*; |
39 |
import sun.jvm.hotspot.gc.parallel.*; |
|
1 | 40 |
import sun.jvm.hotspot.memory.*; |
41 |
import sun.jvm.hotspot.runtime.*; |
|
42 |
import sun.jvm.hotspot.types.*; |
|
43 |
import sun.jvm.hotspot.utilities.*; |
|
44 |
||
45 |
public class ObjectHeap { |
|
46 |
||
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
47 |
private static final boolean DEBUG; |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
48 |
|
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
49 |
static { |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
50 |
DEBUG = System.getProperty("sun.jvm.hotspot.oops.ObjectHeap.DEBUG") != null; |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
51 |
} |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
52 |
|
1 | 53 |
public ObjectHeap(TypeDataBase db) throws WrongTypeException { |
54 |
// Get commonly used sizes of basic types |
|
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
55 |
oopSize = VM.getVM().getOopSize(); |
1 | 56 |
byteSize = db.getJByteType().getSize(); |
57 |
charSize = db.getJCharType().getSize(); |
|
58 |
booleanSize = db.getJBooleanType().getSize(); |
|
59 |
intSize = db.getJIntType().getSize(); |
|
60 |
shortSize = db.getJShortType().getSize(); |
|
61 |
longSize = db.getJLongType().getSize(); |
|
62 |
floatSize = db.getJFloatType().getSize(); |
|
63 |
doubleSize = db.getJDoubleType().getSize(); |
|
64 |
} |
|
65 |
||
66 |
/** Comparison operation for oops, either or both of which may be null */ |
|
67 |
public boolean equal(Oop o1, Oop o2) { |
|
68 |
if (o1 != null) return o1.equals(o2); |
|
69 |
return (o2 == null); |
|
70 |
} |
|
71 |
||
72 |
// Cached sizes of basic types |
|
73 |
private long oopSize; |
|
74 |
private long byteSize; |
|
75 |
private long charSize; |
|
76 |
private long booleanSize; |
|
77 |
private long intSize; |
|
78 |
private long shortSize; |
|
79 |
private long longSize; |
|
80 |
private long floatSize; |
|
81 |
private long doubleSize; |
|
82 |
||
83 |
public long getOopSize() { return oopSize; } |
|
84 |
public long getByteSize() { return byteSize; } |
|
85 |
public long getCharSize() { return charSize; } |
|
86 |
public long getBooleanSize() { return booleanSize; } |
|
87 |
public long getIntSize() { return intSize; } |
|
88 |
public long getShortSize() { return shortSize; } |
|
89 |
public long getLongSize() { return longSize; } |
|
90 |
public long getFloatSize() { return floatSize; } |
|
91 |
public long getDoubleSize() { return doubleSize; } |
|
92 |
||
93 |
/** an interface to filter objects while walking heap */ |
|
94 |
public static interface ObjectFilter { |
|
95 |
public boolean canInclude(Oop obj); |
|
96 |
} |
|
97 |
||
98 |
/** The base heap iteration mechanism */ |
|
99 |
public void iterate(HeapVisitor visitor) { |
|
100 |
iterateLiveRegions(collectLiveRegions(), visitor, null); |
|
101 |
} |
|
102 |
||
103 |
/** iterate objects satisfying a specified ObjectFilter */ |
|
104 |
public void iterate(HeapVisitor visitor, ObjectFilter of) { |
|
105 |
iterateLiveRegions(collectLiveRegions(), visitor, of); |
|
106 |
} |
|
107 |
||
108 |
/** iterate objects of given Klass. param 'includeSubtypes' tells whether to |
|
109 |
* include objects of subtypes or not */ |
|
110 |
public void iterateObjectsOfKlass(HeapVisitor visitor, final Klass k, boolean includeSubtypes) { |
|
111 |
if (includeSubtypes) { |
|
112 |
if (k.isFinal()) { |
|
113 |
// do the simpler "exact" klass loop |
|
114 |
iterateExact(visitor, k); |
|
115 |
} else { |
|
116 |
iterateSubtypes(visitor, k); |
|
117 |
} |
|
118 |
} else { |
|
119 |
// there can no object of abstract classes and interfaces |
|
120 |
if (!k.isAbstract() && !k.isInterface()) { |
|
121 |
iterateExact(visitor, k); |
|
122 |
} |
|
123 |
} |
|
124 |
} |
|
125 |
||
126 |
/** iterate objects of given Klass (objects of subtypes included) */ |
|
127 |
public void iterateObjectsOfKlass(HeapVisitor visitor, final Klass k) { |
|
128 |
iterateObjectsOfKlass(visitor, k, true); |
|
129 |
} |
|
130 |
||
131 |
/** This routine can be used to iterate through the heap at an |
|
132 |
extremely low level (stepping word-by-word) to provide the |
|
133 |
ability to do very low-level debugging */ |
|
134 |
public void iterateRaw(RawHeapVisitor visitor) { |
|
135 |
List liveRegions = collectLiveRegions(); |
|
136 |
||
137 |
// Summarize size |
|
138 |
long totalSize = 0; |
|
139 |
for (int i = 0; i < liveRegions.size(); i += 2) { |
|
140 |
Address bottom = (Address) liveRegions.get(i); |
|
141 |
Address top = (Address) liveRegions.get(i+1); |
|
142 |
totalSize += top.minus(bottom); |
|
143 |
} |
|
144 |
visitor.prologue(totalSize); |
|
145 |
||
146 |
for (int i = 0; i < liveRegions.size(); i += 2) { |
|
147 |
Address bottom = (Address) liveRegions.get(i); |
|
148 |
Address top = (Address) liveRegions.get(i+1); |
|
149 |
||
150 |
// Traverses the space from bottom to top |
|
151 |
while (bottom.lessThan(top)) { |
|
152 |
visitor.visitAddress(bottom); |
|
153 |
bottom = bottom.addOffsetTo(VM.getVM().getAddressSize()); |
|
154 |
} |
|
155 |
} |
|
156 |
||
157 |
visitor.epilogue(); |
|
158 |
} |
|
159 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10663
diff
changeset
|
160 |
public boolean isValidMethod(Address handle) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10663
diff
changeset
|
161 |
try { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10663
diff
changeset
|
162 |
Method m = (Method)Metadata.instantiateWrapperFor(handle); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10663
diff
changeset
|
163 |
return true; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10663
diff
changeset
|
164 |
} catch (Exception e) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10663
diff
changeset
|
165 |
return false; |
1 | 166 |
} |
764
67578bc37423
6620329: jstack prints double native methods on Solaris/sparc
swamyv
parents:
360
diff
changeset
|
167 |
} |
67578bc37423
6620329: jstack prints double native methods on Solaris/sparc
swamyv
parents:
360
diff
changeset
|
168 |
|
1 | 169 |
// Creates an instance from the Oop hierarchy based based on the handle |
170 |
public Oop newOop(OopHandle handle) { |
|
171 |
// The only known way to detect the right type of an oop is |
|
172 |
// traversing the class chain until a well-known klass is recognized. |
|
173 |
// A more direct solution would require the klasses to expose |
|
174 |
// the C++ vtbl structure. |
|
175 |
||
176 |
// Handle the null reference |
|
177 |
if (handle == null) return null; |
|
178 |
||
179 |
// Then check if obj.klass() is one of the root objects |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10663
diff
changeset
|
180 |
Klass klass = Oop.getKlassForOopHandle(handle); |
1 | 181 |
if (klass != null) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10663
diff
changeset
|
182 |
if (klass instanceof TypeArrayKlass) return new TypeArray(handle, this); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10663
diff
changeset
|
183 |
if (klass instanceof ObjArrayKlass) return new ObjArray(handle, this); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10663
diff
changeset
|
184 |
if (klass instanceof InstanceKlass) return new Instance(handle, this); |
1 | 185 |
} |
186 |
||
764
67578bc37423
6620329: jstack prints double native methods on Solaris/sparc
swamyv
parents:
360
diff
changeset
|
187 |
if (DEBUG) { |
67578bc37423
6620329: jstack prints double native methods on Solaris/sparc
swamyv
parents:
360
diff
changeset
|
188 |
System.err.println("Unknown oop at " + handle); |
67578bc37423
6620329: jstack prints double native methods on Solaris/sparc
swamyv
parents:
360
diff
changeset
|
189 |
System.err.println("Oop's klass is " + klass); |
67578bc37423
6620329: jstack prints double native methods on Solaris/sparc
swamyv
parents:
360
diff
changeset
|
190 |
} |
1 | 191 |
|
192 |
throw new UnknownOopException(); |
|
193 |
} |
|
194 |
||
195 |
// Print all objects in the object heap |
|
196 |
public void print() { |
|
197 |
HeapPrinter printer = new HeapPrinter(System.out); |
|
198 |
iterate(printer); |
|
199 |
} |
|
200 |
||
201 |
//--------------------------------------------------------------------------- |
|
202 |
// Internals only below this point |
|
203 |
// |
|
204 |
||
205 |
private void iterateExact(HeapVisitor visitor, final Klass k) { |
|
206 |
iterateLiveRegions(collectLiveRegions(), visitor, new ObjectFilter() { |
|
207 |
public boolean canInclude(Oop obj) { |
|
208 |
Klass tk = obj.getKlass(); |
|
209 |
// null Klass is seen sometimes! |
|
210 |
return (tk != null && tk.equals(k)); |
|
211 |
} |
|
212 |
}); |
|
213 |
} |
|
214 |
||
215 |
private void iterateSubtypes(HeapVisitor visitor, final Klass k) { |
|
216 |
iterateLiveRegions(collectLiveRegions(), visitor, new ObjectFilter() { |
|
217 |
public boolean canInclude(Oop obj) { |
|
218 |
Klass tk = obj.getKlass(); |
|
219 |
// null Klass is seen sometimes! |
|
220 |
return (tk != null && tk.isSubtypeOf(k)); |
|
221 |
} |
|
222 |
}); |
|
223 |
} |
|
224 |
||
225 |
private void iterateLiveRegions(List liveRegions, HeapVisitor visitor, ObjectFilter of) { |
|
226 |
// Summarize size |
|
227 |
long totalSize = 0; |
|
228 |
for (int i = 0; i < liveRegions.size(); i += 2) { |
|
229 |
Address bottom = (Address) liveRegions.get(i); |
|
230 |
Address top = (Address) liveRegions.get(i+1); |
|
231 |
totalSize += top.minus(bottom); |
|
232 |
} |
|
233 |
visitor.prologue(totalSize); |
|
234 |
||
235 |
CompactibleFreeListSpace cmsSpaceOld = null; |
|
236 |
CollectedHeap heap = VM.getVM().getUniverse().heap(); |
|
237 |
||
238 |
if (heap instanceof GenCollectedHeap) { |
|
239 |
GenCollectedHeap genHeap = (GenCollectedHeap) heap; |
|
240 |
Generation genOld = genHeap.getGen(1); |
|
241 |
if (genOld instanceof ConcurrentMarkSweepGeneration) { |
|
242 |
ConcurrentMarkSweepGeneration concGen = (ConcurrentMarkSweepGeneration)genOld; |
|
243 |
cmsSpaceOld = concGen.cmsSpace(); |
|
244 |
} |
|
245 |
} |
|
246 |
||
247 |
for (int i = 0; i < liveRegions.size(); i += 2) { |
|
248 |
Address bottom = (Address) liveRegions.get(i); |
|
249 |
Address top = (Address) liveRegions.get(i+1); |
|
250 |
||
251 |
try { |
|
252 |
// Traverses the space from bottom to top |
|
253 |
OopHandle handle = bottom.addOffsetToAsOopHandle(0); |
|
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
254 |
|
1 | 255 |
while (handle.lessThan(top)) { |
256 |
Oop obj = null; |
|
257 |
||
258 |
try { |
|
259 |
obj = newOop(handle); |
|
260 |
} catch (UnknownOopException exp) { |
|
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
261 |
if (DEBUG) { |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
262 |
throw new RuntimeException(" UnknownOopException " + exp); |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
263 |
} |
1 | 264 |
} |
265 |
if (obj == null) { |
|
266 |
//Find the object size using Printezis bits and skip over |
|
267 |
long size = 0; |
|
268 |
||
269 |
if ( (cmsSpaceOld != null) && cmsSpaceOld.contains(handle) ){ |
|
270 |
size = cmsSpaceOld.collector().blockSizeUsingPrintezisBits(handle); |
|
271 |
} |
|
272 |
||
273 |
if (size <= 0) { |
|
274 |
//Either Printezis bits not set or handle is not in cms space. |
|
275 |
throw new UnknownOopException(); |
|
276 |
} |
|
277 |
||
278 |
handle = handle.addOffsetToAsOopHandle(CompactibleFreeListSpace.adjustObjectSizeInBytes(size)); |
|
279 |
continue; |
|
280 |
} |
|
281 |
if (of == null || of.canInclude(obj)) { |
|
282 |
if (visitor.doObj(obj)) { |
|
283 |
// doObj() returns true to abort this loop. |
|
284 |
break; |
|
285 |
} |
|
286 |
} |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10663
diff
changeset
|
287 |
if ( (cmsSpaceOld != null) && cmsSpaceOld.contains(handle)) { |
1 | 288 |
handle = handle.addOffsetToAsOopHandle(CompactibleFreeListSpace.adjustObjectSizeInBytes(obj.getObjectSize()) ); |
289 |
} else { |
|
290 |
handle = handle.addOffsetToAsOopHandle(obj.getObjectSize()); |
|
291 |
} |
|
292 |
} |
|
293 |
} |
|
294 |
catch (AddressException e) { |
|
295 |
// This is okay at the top of these regions |
|
22216 | 296 |
} |
1 | 297 |
catch (UnknownOopException e) { |
298 |
// This is okay at the top of these regions |
|
299 |
} |
|
300 |
} |
|
301 |
||
302 |
visitor.epilogue(); |
|
303 |
} |
|
304 |
||
22216 | 305 |
private void addLiveRegions(String name, List input, List output) { |
1 | 306 |
for (Iterator itr = input.iterator(); itr.hasNext();) { |
307 |
MemRegion reg = (MemRegion) itr.next(); |
|
308 |
Address top = reg.end(); |
|
309 |
Address bottom = reg.start(); |
|
310 |
if (Assert.ASSERTS_ENABLED) { |
|
311 |
Assert.that(top != null, "top address in a live region should not be null"); |
|
312 |
} |
|
313 |
if (Assert.ASSERTS_ENABLED) { |
|
314 |
Assert.that(bottom != null, "bottom address in a live region should not be null"); |
|
315 |
} |
|
316 |
output.add(top); |
|
317 |
output.add(bottom); |
|
22216 | 318 |
if (DEBUG) { |
319 |
System.err.println("Live region: " + name + ": " + bottom + ", " + top); |
|
320 |
} |
|
1 | 321 |
} |
322 |
} |
|
323 |
||
324 |
private class LiveRegionsCollector implements SpaceClosure { |
|
325 |
LiveRegionsCollector(List l) { |
|
326 |
liveRegions = l; |
|
327 |
} |
|
328 |
||
329 |
public void doSpace(Space s) { |
|
22216 | 330 |
addLiveRegions(s.toString(), s.getLiveRegions(), liveRegions); |
1 | 331 |
} |
332 |
private List liveRegions; |
|
333 |
} |
|
334 |
||
335 |
// Returns a List<Address> where the addresses come in pairs. These |
|
336 |
// designate the live regions of the heap. |
|
337 |
private List collectLiveRegions() { |
|
338 |
// We want to iterate through all live portions of the heap, but |
|
339 |
// do not want to abort the heap traversal prematurely if we find |
|
340 |
// a problem (like an allocated but uninitialized object at the |
|
341 |
// top of a generation). To do this we enumerate all generations' |
|
342 |
// bottom and top regions, and factor in TLABs if necessary. |
|
343 |
||
344 |
// List<Address>. Addresses come in pairs. |
|
345 |
List liveRegions = new ArrayList(); |
|
346 |
LiveRegionsCollector lrc = new LiveRegionsCollector(liveRegions); |
|
347 |
||
348 |
CollectedHeap heap = VM.getVM().getUniverse().heap(); |
|
349 |
||
350 |
if (heap instanceof GenCollectedHeap) { |
|
351 |
GenCollectedHeap genHeap = (GenCollectedHeap) heap; |
|
352 |
// Run through all generations, obtaining bottom-top pairs. |
|
353 |
for (int i = 0; i < genHeap.nGens(); i++) { |
|
354 |
Generation gen = genHeap.getGen(i); |
|
355 |
gen.spaceIterate(lrc, true); |
|
356 |
} |
|
357 |
} else if (heap instanceof ParallelScavengeHeap) { |
|
358 |
ParallelScavengeHeap psh = (ParallelScavengeHeap) heap; |
|
359 |
PSYoungGen youngGen = psh.youngGen(); |
|
360 |
// Add eden space |
|
22216 | 361 |
addLiveRegions("eden", youngGen.edenSpace().getLiveRegions(), liveRegions); |
1 | 362 |
// Add from-space but not to-space |
22216 | 363 |
addLiveRegions("from", youngGen.fromSpace().getLiveRegions(), liveRegions); |
1 | 364 |
PSOldGen oldGen = psh.oldGen(); |
22216 | 365 |
addLiveRegions("old ", oldGen.objectSpace().getLiveRegions(), liveRegions); |
10663 | 366 |
} else if (heap instanceof G1CollectedHeap) { |
367 |
G1CollectedHeap g1h = (G1CollectedHeap) heap; |
|
368 |
g1h.heapRegionIterate(lrc); |
|
50523
7b7c75d87f9b
8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
47216
diff
changeset
|
369 |
} else if (heap instanceof EpsilonHeap) { |
7b7c75d87f9b
8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
47216
diff
changeset
|
370 |
EpsilonHeap eh = (EpsilonHeap) heap; |
7b7c75d87f9b
8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
47216
diff
changeset
|
371 |
liveRegions.add(eh.space().top()); |
7b7c75d87f9b
8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
47216
diff
changeset
|
372 |
liveRegions.add(eh.space().bottom()); |
1 | 373 |
} else { |
374 |
if (Assert.ASSERTS_ENABLED) { |
|
50523
7b7c75d87f9b
8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
47216
diff
changeset
|
375 |
Assert.that(false, "Unexpected CollectedHeap type: " + heap.getClass().getName()); |
1 | 376 |
} |
377 |
} |
|
378 |
||
379 |
// If UseTLAB is enabled, snip out regions associated with TLABs' |
|
380 |
// dead regions. Note that TLABs can be present in any generation. |
|
381 |
||
382 |
// FIXME: consider adding fewer boundaries to live region list. |
|
383 |
// Theoretically only need to stop at TLAB's top and resume at its |
|
384 |
// end. |
|
385 |
||
386 |
if (VM.getVM().getUseTLAB()) { |
|
387 |
for (JavaThread thread = VM.getVM().getThreads().first(); thread != null; thread = thread.next()) { |
|
22216 | 388 |
ThreadLocalAllocBuffer tlab = thread.tlab(); |
389 |
if (tlab.start() != null) { |
|
390 |
if ((tlab.top() == null) || (tlab.end() == null)) { |
|
391 |
System.err.print("Warning: skipping invalid TLAB for thread "); |
|
392 |
thread.printThreadIDOn(System.err); |
|
393 |
System.err.println(); |
|
394 |
} else { |
|
395 |
if (DEBUG) { |
|
396 |
System.err.print("TLAB for " + thread.getThreadName() + ", #"); |
|
1 | 397 |
thread.printThreadIDOn(System.err); |
22216 | 398 |
System.err.print(": "); |
399 |
tlab.printOn(System.err); |
|
1 | 400 |
} |
22216 | 401 |
// Go from: |
402 |
// - below start() to start() |
|
403 |
// - start() to top() |
|
404 |
// - end() and above |
|
405 |
liveRegions.add(tlab.start()); |
|
406 |
liveRegions.add(tlab.start()); |
|
407 |
liveRegions.add(tlab.top()); |
|
408 |
liveRegions.add(tlab.hardEnd()); |
|
1 | 409 |
} |
410 |
} |
|
411 |
} |
|
412 |
} |
|
413 |
||
414 |
// Now sort live regions |
|
415 |
sortLiveRegions(liveRegions); |
|
416 |
||
417 |
if (Assert.ASSERTS_ENABLED) { |
|
418 |
Assert.that(liveRegions.size() % 2 == 0, "Must have even number of region boundaries"); |
|
419 |
} |
|
420 |
||
22216 | 421 |
if (DEBUG) { |
422 |
System.err.println("liveRegions:"); |
|
423 |
for (int i = 0; i < liveRegions.size(); i += 2) { |
|
424 |
Address bottom = (Address) liveRegions.get(i); |
|
425 |
Address top = (Address) liveRegions.get(i+1); |
|
426 |
System.err.println(" " + bottom + " - " + top); |
|
427 |
} |
|
428 |
} |
|
429 |
||
1 | 430 |
return liveRegions; |
431 |
} |
|
432 |
||
433 |
private void sortLiveRegions(List liveRegions) { |
|
434 |
Collections.sort(liveRegions, new Comparator() { |
|
435 |
public int compare(Object o1, Object o2) { |
|
436 |
Address a1 = (Address) o1; |
|
437 |
Address a2 = (Address) o2; |
|
438 |
if (AddressOps.lt(a1, a2)) { |
|
439 |
return -1; |
|
440 |
} else if (AddressOps.gt(a1, a2)) { |
|
441 |
return 1; |
|
442 |
} |
|
443 |
return 0; |
|
444 |
} |
|
445 |
}); |
|
446 |
} |
|
447 |
} |