Mercurial > hg > graal-compiler
comparison agent/src/share/classes/sun/jvm/hotspot/oops/ObjectHeap.java @ 6725:da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
Summary: Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
Contributed-by: jmasa <jon.masamitsu@oracle.com>, stefank <stefan.karlsson@oracle.com>, mgerdin <mikael.gerdin@oracle.com>, never <tom.rodriguez@oracle.com>
author | coleenp |
---|---|
date | Sat, 01 Sep 2012 13:25:18 -0400 |
parents | 4f93f0d00802 |
children | ec0c4951286c |
comparison
equal
deleted
inserted
replaced
6724:36d1d483d5d6 | 6725:da91efe96a93 |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 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 | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
46 | 46 |
47 static { | 47 static { |
48 DEBUG = System.getProperty("sun.jvm.hotspot.oops.ObjectHeap.DEBUG") != null; | 48 DEBUG = System.getProperty("sun.jvm.hotspot.oops.ObjectHeap.DEBUG") != null; |
49 } | 49 } |
50 | 50 |
51 private OopHandle methodKlassHandle; | 51 private Address boolArrayKlassHandle; |
52 private OopHandle constMethodKlassHandle; | 52 private Address byteArrayKlassHandle; |
53 private OopHandle methodDataKlassHandle; | 53 private Address charArrayKlassHandle; |
54 private OopHandle constantPoolKlassHandle; | 54 private Address intArrayKlassHandle; |
55 private OopHandle constantPoolCacheKlassHandle; | 55 private Address shortArrayKlassHandle; |
56 private OopHandle klassKlassHandle; | 56 private Address longArrayKlassHandle; |
57 private OopHandle instanceKlassKlassHandle; | 57 private Address singleArrayKlassHandle; |
58 private OopHandle typeArrayKlassKlassHandle; | 58 private Address doubleArrayKlassHandle; |
59 private OopHandle objArrayKlassKlassHandle; | 59 |
60 private OopHandle boolArrayKlassHandle; | |
61 private OopHandle byteArrayKlassHandle; | |
62 private OopHandle charArrayKlassHandle; | |
63 private OopHandle intArrayKlassHandle; | |
64 private OopHandle shortArrayKlassHandle; | |
65 private OopHandle longArrayKlassHandle; | |
66 private OopHandle singleArrayKlassHandle; | |
67 private OopHandle doubleArrayKlassHandle; | |
68 private OopHandle arrayKlassKlassHandle; | |
69 private OopHandle compiledICHolderKlassHandle; | |
70 | |
71 private MethodKlass methodKlassObj; | |
72 private ConstMethodKlass constMethodKlassObj; | |
73 private MethodDataKlass methodDataKlassObj; | |
74 private ConstantPoolKlass constantPoolKlassObj; | |
75 private ConstantPoolCacheKlass constantPoolCacheKlassObj; | |
76 private KlassKlass klassKlassObj; | |
77 private InstanceKlassKlass instanceKlassKlassObj; | |
78 private TypeArrayKlassKlass typeArrayKlassKlassObj; | |
79 private ObjArrayKlassKlass objArrayKlassKlassObj; | |
80 private TypeArrayKlass boolArrayKlassObj; | 60 private TypeArrayKlass boolArrayKlassObj; |
81 private TypeArrayKlass byteArrayKlassObj; | 61 private TypeArrayKlass byteArrayKlassObj; |
82 private TypeArrayKlass charArrayKlassObj; | 62 private TypeArrayKlass charArrayKlassObj; |
83 private TypeArrayKlass intArrayKlassObj; | 63 private TypeArrayKlass intArrayKlassObj; |
84 private TypeArrayKlass shortArrayKlassObj; | 64 private TypeArrayKlass shortArrayKlassObj; |
85 private TypeArrayKlass longArrayKlassObj; | 65 private TypeArrayKlass longArrayKlassObj; |
86 private TypeArrayKlass singleArrayKlassObj; | 66 private TypeArrayKlass singleArrayKlassObj; |
87 private TypeArrayKlass doubleArrayKlassObj; | 67 private TypeArrayKlass doubleArrayKlassObj; |
88 private ArrayKlassKlass arrayKlassKlassObj; | |
89 private CompiledICHolderKlass compiledICHolderKlassObj; | |
90 | 68 |
91 public void initialize(TypeDataBase db) throws WrongTypeException { | 69 public void initialize(TypeDataBase db) throws WrongTypeException { |
92 // Lookup the roots in the object hierarchy. | 70 // Lookup the roots in the object hierarchy. |
93 Type universeType = db.lookupType("Universe"); | 71 Type universeType = db.lookupType("Universe"); |
94 | 72 |
95 methodKlassHandle = universeType.getOopField("_methodKlassObj").getValue(); | 73 boolArrayKlassHandle = universeType.getAddressField("_boolArrayKlassObj").getValue(); |
96 methodKlassObj = new MethodKlass(methodKlassHandle, this); | 74 boolArrayKlassObj = new TypeArrayKlass(boolArrayKlassHandle); |
97 | 75 |
98 constMethodKlassHandle = universeType.getOopField("_constMethodKlassObj").getValue(); | 76 byteArrayKlassHandle = universeType.getAddressField("_byteArrayKlassObj").getValue(); |
99 constMethodKlassObj = new ConstMethodKlass(constMethodKlassHandle, this); | 77 byteArrayKlassObj = new TypeArrayKlass(byteArrayKlassHandle); |
100 | 78 |
101 constantPoolKlassHandle = universeType.getOopField("_constantPoolKlassObj").getValue(); | 79 charArrayKlassHandle = universeType.getAddressField("_charArrayKlassObj").getValue(); |
102 constantPoolKlassObj = new ConstantPoolKlass(constantPoolKlassHandle, this); | 80 charArrayKlassObj = new TypeArrayKlass(charArrayKlassHandle); |
103 | 81 |
104 constantPoolCacheKlassHandle = universeType.getOopField("_constantPoolCacheKlassObj").getValue(); | 82 intArrayKlassHandle = universeType.getAddressField("_intArrayKlassObj").getValue(); |
105 constantPoolCacheKlassObj = new ConstantPoolCacheKlass(constantPoolCacheKlassHandle, this); | 83 intArrayKlassObj = new TypeArrayKlass(intArrayKlassHandle); |
106 | 84 |
107 klassKlassHandle = universeType.getOopField("_klassKlassObj").getValue(); | 85 shortArrayKlassHandle = universeType.getAddressField("_shortArrayKlassObj").getValue(); |
108 klassKlassObj = new KlassKlass(klassKlassHandle, this); | 86 shortArrayKlassObj = new TypeArrayKlass(shortArrayKlassHandle); |
109 | 87 |
110 arrayKlassKlassHandle = universeType.getOopField("_arrayKlassKlassObj").getValue(); | 88 longArrayKlassHandle = universeType.getAddressField("_longArrayKlassObj").getValue(); |
111 arrayKlassKlassObj = new ArrayKlassKlass(arrayKlassKlassHandle, this); | 89 longArrayKlassObj = new TypeArrayKlass(longArrayKlassHandle); |
112 | 90 |
113 instanceKlassKlassHandle = universeType.getOopField("_instanceKlassKlassObj").getValue(); | 91 singleArrayKlassHandle = universeType.getAddressField("_singleArrayKlassObj").getValue(); |
114 instanceKlassKlassObj = new InstanceKlassKlass(instanceKlassKlassHandle, this); | 92 singleArrayKlassObj = new TypeArrayKlass(singleArrayKlassHandle); |
115 | 93 |
116 typeArrayKlassKlassHandle = universeType.getOopField("_typeArrayKlassKlassObj").getValue(); | 94 doubleArrayKlassHandle = universeType.getAddressField("_doubleArrayKlassObj").getValue(); |
117 typeArrayKlassKlassObj = new TypeArrayKlassKlass(typeArrayKlassKlassHandle, this); | 95 doubleArrayKlassObj = new TypeArrayKlass(doubleArrayKlassHandle); |
118 | |
119 objArrayKlassKlassHandle = universeType.getOopField("_objArrayKlassKlassObj").getValue(); | |
120 objArrayKlassKlassObj = new ObjArrayKlassKlass(objArrayKlassKlassHandle, this); | |
121 | |
122 boolArrayKlassHandle = universeType.getOopField("_boolArrayKlassObj").getValue(); | |
123 boolArrayKlassObj = new TypeArrayKlass(boolArrayKlassHandle, this); | |
124 | |
125 byteArrayKlassHandle = universeType.getOopField("_byteArrayKlassObj").getValue(); | |
126 byteArrayKlassObj = new TypeArrayKlass(byteArrayKlassHandle, this); | |
127 | |
128 charArrayKlassHandle = universeType.getOopField("_charArrayKlassObj").getValue(); | |
129 charArrayKlassObj = new TypeArrayKlass(charArrayKlassHandle, this); | |
130 | |
131 intArrayKlassHandle = universeType.getOopField("_intArrayKlassObj").getValue(); | |
132 intArrayKlassObj = new TypeArrayKlass(intArrayKlassHandle, this); | |
133 | |
134 shortArrayKlassHandle = universeType.getOopField("_shortArrayKlassObj").getValue(); | |
135 shortArrayKlassObj = new TypeArrayKlass(shortArrayKlassHandle, this); | |
136 | |
137 longArrayKlassHandle = universeType.getOopField("_longArrayKlassObj").getValue(); | |
138 longArrayKlassObj = new TypeArrayKlass(longArrayKlassHandle, this); | |
139 | |
140 singleArrayKlassHandle = universeType.getOopField("_singleArrayKlassObj").getValue(); | |
141 singleArrayKlassObj = new TypeArrayKlass(singleArrayKlassHandle, this); | |
142 | |
143 doubleArrayKlassHandle = universeType.getOopField("_doubleArrayKlassObj").getValue(); | |
144 doubleArrayKlassObj = new TypeArrayKlass(doubleArrayKlassHandle, this); | |
145 | |
146 if (!VM.getVM().isCore()) { | |
147 methodDataKlassHandle = universeType.getOopField("_methodDataKlassObj").getValue(); | |
148 methodDataKlassObj = new MethodDataKlass(methodDataKlassHandle, this); | |
149 | |
150 compiledICHolderKlassHandle = universeType.getOopField("_compiledICHolderKlassObj").getValue(); | |
151 compiledICHolderKlassObj= new CompiledICHolderKlass(compiledICHolderKlassHandle ,this); | |
152 } | |
153 } | 96 } |
154 | 97 |
155 public ObjectHeap(TypeDataBase db) throws WrongTypeException { | 98 public ObjectHeap(TypeDataBase db) throws WrongTypeException { |
156 // Get commonly used sizes of basic types | 99 // Get commonly used sizes of basic types |
157 oopSize = VM.getVM().getOopSize(); | 100 oopSize = VM.getVM().getOopSize(); |
193 public long getLongSize() { return longSize; } | 136 public long getLongSize() { return longSize; } |
194 public long getFloatSize() { return floatSize; } | 137 public long getFloatSize() { return floatSize; } |
195 public long getDoubleSize() { return doubleSize; } | 138 public long getDoubleSize() { return doubleSize; } |
196 | 139 |
197 // Accessors for well-known system classes (from Universe) | 140 // Accessors for well-known system classes (from Universe) |
198 public MethodKlass getMethodKlassObj() { return methodKlassObj; } | |
199 public ConstMethodKlass getConstMethodKlassObj() { return constMethodKlassObj; } | |
200 public MethodDataKlass getMethodDataKlassObj() { return methodDataKlassObj; } | |
201 public ConstantPoolKlass getConstantPoolKlassObj() { return constantPoolKlassObj; } | |
202 public ConstantPoolCacheKlass getConstantPoolCacheKlassObj() { return constantPoolCacheKlassObj; } | |
203 public KlassKlass getKlassKlassObj() { return klassKlassObj; } | |
204 public ArrayKlassKlass getArrayKlassKlassObj() { return arrayKlassKlassObj; } | |
205 public InstanceKlassKlass getInstanceKlassKlassObj() { return instanceKlassKlassObj; } | |
206 public ObjArrayKlassKlass getObjArrayKlassKlassObj() { return objArrayKlassKlassObj; } | |
207 public TypeArrayKlassKlass getTypeArrayKlassKlassObj() { return typeArrayKlassKlassObj; } | |
208 public TypeArrayKlass getBoolArrayKlassObj() { return boolArrayKlassObj; } | 141 public TypeArrayKlass getBoolArrayKlassObj() { return boolArrayKlassObj; } |
209 public TypeArrayKlass getByteArrayKlassObj() { return byteArrayKlassObj; } | 142 public TypeArrayKlass getByteArrayKlassObj() { return byteArrayKlassObj; } |
210 public TypeArrayKlass getCharArrayKlassObj() { return charArrayKlassObj; } | 143 public TypeArrayKlass getCharArrayKlassObj() { return charArrayKlassObj; } |
211 public TypeArrayKlass getIntArrayKlassObj() { return intArrayKlassObj; } | 144 public TypeArrayKlass getIntArrayKlassObj() { return intArrayKlassObj; } |
212 public TypeArrayKlass getShortArrayKlassObj() { return shortArrayKlassObj; } | 145 public TypeArrayKlass getShortArrayKlassObj() { return shortArrayKlassObj; } |
213 public TypeArrayKlass getLongArrayKlassObj() { return longArrayKlassObj; } | 146 public TypeArrayKlass getLongArrayKlassObj() { return longArrayKlassObj; } |
214 public TypeArrayKlass getSingleArrayKlassObj() { return singleArrayKlassObj; } | 147 public TypeArrayKlass getSingleArrayKlassObj() { return singleArrayKlassObj; } |
215 public TypeArrayKlass getDoubleArrayKlassObj() { return doubleArrayKlassObj; } | 148 public TypeArrayKlass getDoubleArrayKlassObj() { return doubleArrayKlassObj; } |
216 public CompiledICHolderKlass getCompiledICHolderKlassObj() { | |
217 if (Assert.ASSERTS_ENABLED) { | |
218 Assert.that(!VM.getVM().isCore(), "must not be called for core build"); | |
219 } | |
220 return compiledICHolderKlassObj; | |
221 } | |
222 | 149 |
223 /** Takes a BasicType and returns the corresponding primitive array | 150 /** Takes a BasicType and returns the corresponding primitive array |
224 klass */ | 151 klass */ |
225 public Klass typeArrayKlassObj(int t) { | 152 public Klass typeArrayKlassObj(int t) { |
226 if (t == BasicType.getTBoolean()) return getBoolArrayKlassObj(); | 153 if (t == BasicType.getTBoolean()) return getBoolArrayKlassObj(); |
299 } | 226 } |
300 | 227 |
301 visitor.epilogue(); | 228 visitor.epilogue(); |
302 } | 229 } |
303 | 230 |
304 // Iterates through only the perm generation for the purpose of | 231 public boolean isValidMethod(Address handle) { |
305 // finding static fields for liveness analysis | 232 try { |
306 public void iteratePerm(HeapVisitor visitor) { | 233 Method m = (Method)Metadata.instantiateWrapperFor(handle); |
307 CollectedHeap heap = VM.getVM().getUniverse().heap(); | |
308 List liveRegions = new ArrayList(); | |
309 addPermGenLiveRegions(liveRegions, heap); | |
310 sortLiveRegions(liveRegions); | |
311 iterateLiveRegions(liveRegions, visitor, null); | |
312 } | |
313 | |
314 public boolean isValidMethod(OopHandle handle) { | |
315 OopHandle klass = Oop.getKlassForOopHandle(handle); | |
316 if (klass != null && klass.equals(methodKlassHandle)) { | |
317 return true; | 234 return true; |
318 } | 235 } catch (Exception e) { |
319 return false; | 236 return false; |
237 } | |
320 } | 238 } |
321 | 239 |
322 // Creates an instance from the Oop hierarchy based based on the handle | 240 // Creates an instance from the Oop hierarchy based based on the handle |
323 public Oop newOop(OopHandle handle) { | 241 public Oop newOop(OopHandle handle) { |
324 // The only known way to detect the right type of an oop is | 242 // The only known way to detect the right type of an oop is |
327 // the C++ vtbl structure. | 245 // the C++ vtbl structure. |
328 | 246 |
329 // Handle the null reference | 247 // Handle the null reference |
330 if (handle == null) return null; | 248 if (handle == null) return null; |
331 | 249 |
332 // First check if handle is one of the root objects | |
333 if (handle.equals(methodKlassHandle)) return getMethodKlassObj(); | |
334 if (handle.equals(constMethodKlassHandle)) return getConstMethodKlassObj(); | |
335 if (handle.equals(constantPoolKlassHandle)) return getConstantPoolKlassObj(); | |
336 if (handle.equals(constantPoolCacheKlassHandle)) return getConstantPoolCacheKlassObj(); | |
337 if (handle.equals(instanceKlassKlassHandle)) return getInstanceKlassKlassObj(); | |
338 if (handle.equals(objArrayKlassKlassHandle)) return getObjArrayKlassKlassObj(); | |
339 if (handle.equals(klassKlassHandle)) return getKlassKlassObj(); | |
340 if (handle.equals(arrayKlassKlassHandle)) return getArrayKlassKlassObj(); | |
341 if (handle.equals(typeArrayKlassKlassHandle)) return getTypeArrayKlassKlassObj(); | |
342 if (handle.equals(boolArrayKlassHandle)) return getBoolArrayKlassObj(); | |
343 if (handle.equals(byteArrayKlassHandle)) return getByteArrayKlassObj(); | |
344 if (handle.equals(charArrayKlassHandle)) return getCharArrayKlassObj(); | |
345 if (handle.equals(intArrayKlassHandle)) return getIntArrayKlassObj(); | |
346 if (handle.equals(shortArrayKlassHandle)) return getShortArrayKlassObj(); | |
347 if (handle.equals(longArrayKlassHandle)) return getLongArrayKlassObj(); | |
348 if (handle.equals(singleArrayKlassHandle)) return getSingleArrayKlassObj(); | |
349 if (handle.equals(doubleArrayKlassHandle)) return getDoubleArrayKlassObj(); | |
350 if (!VM.getVM().isCore()) { | |
351 if (handle.equals(compiledICHolderKlassHandle)) return getCompiledICHolderKlassObj(); | |
352 if (handle.equals(methodDataKlassHandle)) return getMethodDataKlassObj(); | |
353 } | |
354 | |
355 // Then check if obj.klass() is one of the root objects | 250 // Then check if obj.klass() is one of the root objects |
356 OopHandle klass = Oop.getKlassForOopHandle(handle); | 251 Klass klass = Oop.getKlassForOopHandle(handle); |
357 if (klass != null) { | 252 if (klass != null) { |
358 if (klass.equals(methodKlassHandle)) return new Method(handle, this); | 253 if (klass instanceof TypeArrayKlass) return new TypeArray(handle, this); |
359 if (klass.equals(constMethodKlassHandle)) return new ConstMethod(handle, this); | 254 if (klass instanceof ObjArrayKlass) return new ObjArray(handle, this); |
360 if (klass.equals(constantPoolKlassHandle)) return new ConstantPool(handle, this); | 255 if (klass instanceof InstanceKlass) return new Instance(handle, this); |
361 if (klass.equals(constantPoolCacheKlassHandle)) return new ConstantPoolCache(handle, this); | |
362 if (!VM.getVM().isCore()) { | |
363 if (klass.equals(compiledICHolderKlassHandle)) return new CompiledICHolder(handle, this); | |
364 if (klass.equals(methodDataKlassHandle)) return new MethodData(handle, this); | |
365 } | |
366 if (klass.equals(instanceKlassKlassHandle)) { | |
367 InstanceKlass ik = new InstanceKlass(handle, this); | |
368 if (ik.getName().asString().equals("java/lang/Class")) { | |
369 // We would normally do this using the vtable style | |
370 // lookup but since it's not used for these currently | |
371 // it's simpler to just check for the name. | |
372 return new InstanceMirrorKlass(handle, this); | |
373 } | |
374 return ik; | |
375 } | |
376 if (klass.equals(objArrayKlassKlassHandle)) return new ObjArrayKlass(handle, this); | |
377 if (klass.equals(typeArrayKlassKlassHandle)) return new TypeArrayKlass(handle, this); | |
378 | |
379 // Lastly check if obj.klass().klass() is on of the root objects | |
380 OopHandle klassKlass = Oop.getKlassForOopHandle(klass); | |
381 if (klassKlass != null) { | |
382 if (klassKlass.equals(instanceKlassKlassHandle)) return new Instance(handle, this); | |
383 if (klassKlass.equals(objArrayKlassKlassHandle)) return new ObjArray(handle, this); | |
384 if (klassKlass.equals(typeArrayKlassKlassHandle)) return new TypeArray(handle, this); | |
385 } | |
386 } | 256 } |
387 | 257 |
388 if (DEBUG) { | 258 if (DEBUG) { |
389 System.err.println("Unknown oop at " + handle); | 259 System.err.println("Unknown oop at " + handle); |
390 System.err.println("Oop's klass is " + klass); | 260 System.err.println("Oop's klass is " + klass); |
432 totalSize += top.minus(bottom); | 302 totalSize += top.minus(bottom); |
433 } | 303 } |
434 visitor.prologue(totalSize); | 304 visitor.prologue(totalSize); |
435 | 305 |
436 CompactibleFreeListSpace cmsSpaceOld = null; | 306 CompactibleFreeListSpace cmsSpaceOld = null; |
437 CompactibleFreeListSpace cmsSpacePerm = null; | |
438 CollectedHeap heap = VM.getVM().getUniverse().heap(); | 307 CollectedHeap heap = VM.getVM().getUniverse().heap(); |
439 | 308 |
440 if (heap instanceof GenCollectedHeap) { | 309 if (heap instanceof GenCollectedHeap) { |
441 GenCollectedHeap genHeap = (GenCollectedHeap) heap; | 310 GenCollectedHeap genHeap = (GenCollectedHeap) heap; |
442 Generation genOld = genHeap.getGen(1); | 311 Generation genOld = genHeap.getGen(1); |
443 Generation genPerm = genHeap.permGen(); | |
444 if (genOld instanceof ConcurrentMarkSweepGeneration) { | 312 if (genOld instanceof ConcurrentMarkSweepGeneration) { |
445 ConcurrentMarkSweepGeneration concGen = (ConcurrentMarkSweepGeneration)genOld; | 313 ConcurrentMarkSweepGeneration concGen = (ConcurrentMarkSweepGeneration)genOld; |
446 cmsSpaceOld = concGen.cmsSpace(); | 314 cmsSpaceOld = concGen.cmsSpace(); |
447 } | |
448 if (genPerm instanceof ConcurrentMarkSweepGeneration) { | |
449 ConcurrentMarkSweepGeneration concGen = (ConcurrentMarkSweepGeneration)genPerm; | |
450 cmsSpacePerm = concGen.cmsSpace(); | |
451 } | 315 } |
452 } | 316 } |
453 | 317 |
454 for (int i = 0; i < liveRegions.size(); i += 2) { | 318 for (int i = 0; i < liveRegions.size(); i += 2) { |
455 Address bottom = (Address) liveRegions.get(i); | 319 Address bottom = (Address) liveRegions.get(i); |
474 System.err.println("Finding object size using Printezis bits and skipping over..."); | 338 System.err.println("Finding object size using Printezis bits and skipping over..."); |
475 long size = 0; | 339 long size = 0; |
476 | 340 |
477 if ( (cmsSpaceOld != null) && cmsSpaceOld.contains(handle) ){ | 341 if ( (cmsSpaceOld != null) && cmsSpaceOld.contains(handle) ){ |
478 size = cmsSpaceOld.collector().blockSizeUsingPrintezisBits(handle); | 342 size = cmsSpaceOld.collector().blockSizeUsingPrintezisBits(handle); |
479 } else if ((cmsSpacePerm != null) && cmsSpacePerm.contains(handle) ){ | |
480 size = cmsSpacePerm.collector().blockSizeUsingPrintezisBits(handle); | |
481 } | 343 } |
482 | 344 |
483 if (size <= 0) { | 345 if (size <= 0) { |
484 //Either Printezis bits not set or handle is not in cms space. | 346 //Either Printezis bits not set or handle is not in cms space. |
485 throw new UnknownOopException(); | 347 throw new UnknownOopException(); |
492 if (visitor.doObj(obj)) { | 354 if (visitor.doObj(obj)) { |
493 // doObj() returns true to abort this loop. | 355 // doObj() returns true to abort this loop. |
494 break; | 356 break; |
495 } | 357 } |
496 } | 358 } |
497 if ( (cmsSpaceOld != null) && cmsSpaceOld.contains(handle) || | 359 if ( (cmsSpaceOld != null) && cmsSpaceOld.contains(handle)) { |
498 (cmsSpacePerm != null) && cmsSpacePerm.contains(handle) ) { | |
499 handle = handle.addOffsetToAsOopHandle(CompactibleFreeListSpace.adjustObjectSizeInBytes(obj.getObjectSize()) ); | 360 handle = handle.addOffsetToAsOopHandle(CompactibleFreeListSpace.adjustObjectSizeInBytes(obj.getObjectSize()) ); |
500 } else { | 361 } else { |
501 handle = handle.addOffsetToAsOopHandle(obj.getObjectSize()); | 362 handle = handle.addOffsetToAsOopHandle(obj.getObjectSize()); |
502 } | 363 } |
503 } | 364 } |
509 // This is okay at the top of these regions | 370 // This is okay at the top of these regions |
510 } | 371 } |
511 } | 372 } |
512 | 373 |
513 visitor.epilogue(); | 374 visitor.epilogue(); |
514 } | |
515 | |
516 private void addPermGenLiveRegions(List output, CollectedHeap heap) { | |
517 LiveRegionsCollector lrc = new LiveRegionsCollector(output); | |
518 if (heap instanceof SharedHeap) { | |
519 if (Assert.ASSERTS_ENABLED) { | |
520 Assert.that(heap instanceof GenCollectedHeap || | |
521 heap instanceof G1CollectedHeap, | |
522 "Expecting GenCollectedHeap or G1CollectedHeap, " + | |
523 "but got " + heap.getClass().getName()); | |
524 } | |
525 // Handles both GenCollectedHeap and G1CollectedHeap | |
526 SharedHeap sharedHeap = (SharedHeap) heap; | |
527 Generation gen = sharedHeap.permGen(); | |
528 gen.spaceIterate(lrc, true); | |
529 } else if (heap instanceof ParallelScavengeHeap) { | |
530 ParallelScavengeHeap psh = (ParallelScavengeHeap) heap; | |
531 PSPermGen permGen = psh.permGen(); | |
532 addLiveRegions(permGen.objectSpace().getLiveRegions(), output); | |
533 } else { | |
534 if (Assert.ASSERTS_ENABLED) { | |
535 Assert.that(false, | |
536 "Expecting SharedHeap or ParallelScavengeHeap, " + | |
537 "but got " + heap.getClass().getName()); | |
538 } | |
539 } | |
540 } | 375 } |
541 | 376 |
542 private void addLiveRegions(List input, List output) { | 377 private void addLiveRegions(List input, List output) { |
543 for (Iterator itr = input.iterator(); itr.hasNext();) { | 378 for (Iterator itr = input.iterator(); itr.hasNext();) { |
544 MemRegion reg = (MemRegion) itr.next(); | 379 MemRegion reg = (MemRegion) itr.next(); |
606 "or ParallelScavengeHeap, but got " + | 441 "or ParallelScavengeHeap, but got " + |
607 heap.getClass().getName()); | 442 heap.getClass().getName()); |
608 } | 443 } |
609 } | 444 } |
610 | 445 |
611 // handle perm generation | |
612 addPermGenLiveRegions(liveRegions, heap); | |
613 | |
614 // If UseTLAB is enabled, snip out regions associated with TLABs' | 446 // If UseTLAB is enabled, snip out regions associated with TLABs' |
615 // dead regions. Note that TLABs can be present in any generation. | 447 // dead regions. Note that TLABs can be present in any generation. |
616 | 448 |
617 // FIXME: consider adding fewer boundaries to live region list. | 449 // FIXME: consider adding fewer boundaries to live region list. |
618 // Theoretically only need to stop at TLAB's top and resume at its | 450 // Theoretically only need to stop at TLAB's top and resume at its |