19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
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.*;
35 import sun.jvm.hotspot.gc.cms.*;
36 import sun.jvm.hotspot.gc.shared.*;
37 import sun.jvm.hotspot.gc.epsilon.*;
38 import sun.jvm.hotspot.gc.g1.*;
39 import sun.jvm.hotspot.gc.parallel.*;
40 import sun.jvm.hotspot.gc.z.*;
41 import sun.jvm.hotspot.memory.*;
42 import sun.jvm.hotspot.runtime.*;
43 import sun.jvm.hotspot.types.*;
44 import sun.jvm.hotspot.utilities.*;
45
46 public class ObjectHeap {
47
48 private static final boolean DEBUG;
49
50 static {
51 DEBUG = System.getProperty("sun.jvm.hotspot.oops.ObjectHeap.DEBUG") != null;
52 }
53
54 public ObjectHeap(TypeDataBase db) throws WrongTypeException {
55 // Get commonly used sizes of basic types
56 oopSize = VM.getVM().getOopSize();
57 byteSize = db.getJByteType().getSize();
58 charSize = db.getJCharType().getSize();
350
351 if (heap instanceof GenCollectedHeap) {
352 GenCollectedHeap genHeap = (GenCollectedHeap) heap;
353 // Run through all generations, obtaining bottom-top pairs.
354 for (int i = 0; i < genHeap.nGens(); i++) {
355 Generation gen = genHeap.getGen(i);
356 gen.spaceIterate(lrc, true);
357 }
358 } else if (heap instanceof ParallelScavengeHeap) {
359 ParallelScavengeHeap psh = (ParallelScavengeHeap) heap;
360 PSYoungGen youngGen = psh.youngGen();
361 // Add eden space
362 addLiveRegions("eden", youngGen.edenSpace().getLiveRegions(), liveRegions);
363 // Add from-space but not to-space
364 addLiveRegions("from", youngGen.fromSpace().getLiveRegions(), liveRegions);
365 PSOldGen oldGen = psh.oldGen();
366 addLiveRegions("old ", oldGen.objectSpace().getLiveRegions(), liveRegions);
367 } else if (heap instanceof G1CollectedHeap) {
368 G1CollectedHeap g1h = (G1CollectedHeap) heap;
369 g1h.heapRegionIterate(lrc);
370 } else if (heap instanceof ZCollectedHeap) {
371 // Operation (currently) not supported with ZGC. Print
372 // a warning and leave the list of live regions empty.
373 System.err.println("Warning: Operation not supported with ZGC");
374 } else if (heap instanceof EpsilonHeap) {
375 EpsilonHeap eh = (EpsilonHeap) heap;
376 liveRegions.add(eh.space().top());
377 liveRegions.add(eh.space().bottom());
378 } else {
379 if (Assert.ASSERTS_ENABLED) {
380 Assert.that(false, "Unexpected CollectedHeap type: " + heap.getClass().getName());
381 }
382 }
383
384 // If UseTLAB is enabled, snip out regions associated with TLABs'
385 // dead regions. Note that TLABs can be present in any generation.
386
387 // FIXME: consider adding fewer boundaries to live region list.
388 // Theoretically only need to stop at TLAB's top and resume at its
389 // end.
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
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.*;
35 import sun.jvm.hotspot.gc.cms.*;
36 import sun.jvm.hotspot.gc.shared.*;
37 import sun.jvm.hotspot.gc.epsilon.*;
38 import sun.jvm.hotspot.gc.g1.*;
39 import sun.jvm.hotspot.gc.shenandoah.*;
40 import sun.jvm.hotspot.gc.parallel.*;
41 import sun.jvm.hotspot.gc.z.*;
42 import sun.jvm.hotspot.memory.*;
43 import sun.jvm.hotspot.runtime.*;
44 import sun.jvm.hotspot.types.*;
45 import sun.jvm.hotspot.utilities.*;
46
47 public class ObjectHeap {
48
49 private static final boolean DEBUG;
50
51 static {
52 DEBUG = System.getProperty("sun.jvm.hotspot.oops.ObjectHeap.DEBUG") != null;
53 }
54
55 public ObjectHeap(TypeDataBase db) throws WrongTypeException {
56 // Get commonly used sizes of basic types
57 oopSize = VM.getVM().getOopSize();
58 byteSize = db.getJByteType().getSize();
59 charSize = db.getJCharType().getSize();
351
352 if (heap instanceof GenCollectedHeap) {
353 GenCollectedHeap genHeap = (GenCollectedHeap) heap;
354 // Run through all generations, obtaining bottom-top pairs.
355 for (int i = 0; i < genHeap.nGens(); i++) {
356 Generation gen = genHeap.getGen(i);
357 gen.spaceIterate(lrc, true);
358 }
359 } else if (heap instanceof ParallelScavengeHeap) {
360 ParallelScavengeHeap psh = (ParallelScavengeHeap) heap;
361 PSYoungGen youngGen = psh.youngGen();
362 // Add eden space
363 addLiveRegions("eden", youngGen.edenSpace().getLiveRegions(), liveRegions);
364 // Add from-space but not to-space
365 addLiveRegions("from", youngGen.fromSpace().getLiveRegions(), liveRegions);
366 PSOldGen oldGen = psh.oldGen();
367 addLiveRegions("old ", oldGen.objectSpace().getLiveRegions(), liveRegions);
368 } else if (heap instanceof G1CollectedHeap) {
369 G1CollectedHeap g1h = (G1CollectedHeap) heap;
370 g1h.heapRegionIterate(lrc);
371 } else if (heap instanceof ShenandoahHeap) {
372 // Operation (currently) not supported with Shenandoah GC. Print
373 // a warning and leave the list of live regions empty.
374 System.err.println("Warning: Operation not supported with Shenandoah GC");
375 } else if (heap instanceof ZCollectedHeap) {
376 // Operation (currently) not supported with ZGC. Print
377 // a warning and leave the list of live regions empty.
378 System.err.println("Warning: Operation not supported with ZGC");
379 } else if (heap instanceof EpsilonHeap) {
380 EpsilonHeap eh = (EpsilonHeap) heap;
381 liveRegions.add(eh.space().top());
382 liveRegions.add(eh.space().bottom());
383 } else {
384 if (Assert.ASSERTS_ENABLED) {
385 Assert.that(false, "Unexpected CollectedHeap type: " + heap.getClass().getName());
386 }
387 }
388
389 // If UseTLAB is enabled, snip out regions associated with TLABs'
390 // dead regions. Note that TLABs can be present in any generation.
391
392 // FIXME: consider adding fewer boundaries to live region list.
393 // Theoretically only need to stop at TLAB's top and resume at its
394 // end.
|