17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
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_interface.*;
36 import sun.jvm.hotspot.gc_implementation.g1.*;
37 import sun.jvm.hotspot.gc_implementation.parallelScavenge.*;
38 import sun.jvm.hotspot.memory.*;
39 import sun.jvm.hotspot.runtime.*;
40 import sun.jvm.hotspot.types.*;
41 import sun.jvm.hotspot.utilities.*;
42
43 public class ObjectHeap {
44
45 private static final boolean DEBUG;
46
47 static {
48 DEBUG = System.getProperty("sun.jvm.hotspot.oops.ObjectHeap.DEBUG") != null;
49 }
50
51 private Address boolArrayKlassHandle;
52 private Address byteArrayKlassHandle;
53 private Address charArrayKlassHandle;
54 private Address intArrayKlassHandle;
55 private Address shortArrayKlassHandle;
56 private Address longArrayKlassHandle;
420
421 if (heap instanceof GenCollectedHeap) {
422 GenCollectedHeap genHeap = (GenCollectedHeap) heap;
423 // Run through all generations, obtaining bottom-top pairs.
424 for (int i = 0; i < genHeap.nGens(); i++) {
425 Generation gen = genHeap.getGen(i);
426 gen.spaceIterate(lrc, true);
427 }
428 } else if (heap instanceof ParallelScavengeHeap) {
429 ParallelScavengeHeap psh = (ParallelScavengeHeap) heap;
430 PSYoungGen youngGen = psh.youngGen();
431 // Add eden space
432 addLiveRegions("eden", youngGen.edenSpace().getLiveRegions(), liveRegions);
433 // Add from-space but not to-space
434 addLiveRegions("from", youngGen.fromSpace().getLiveRegions(), liveRegions);
435 PSOldGen oldGen = psh.oldGen();
436 addLiveRegions("old ", oldGen.objectSpace().getLiveRegions(), liveRegions);
437 } else if (heap instanceof G1CollectedHeap) {
438 G1CollectedHeap g1h = (G1CollectedHeap) heap;
439 g1h.heapRegionIterate(lrc);
440 } else {
441 if (Assert.ASSERTS_ENABLED) {
442 Assert.that(false, "Expecting GenCollectedHeap, G1CollectedHeap, " +
443 "or ParallelScavengeHeap, but got " +
444 heap.getClass().getName());
445 }
446 }
447
448 // If UseTLAB is enabled, snip out regions associated with TLABs'
449 // dead regions. Note that TLABs can be present in any generation.
450
451 // FIXME: consider adding fewer boundaries to live region list.
452 // Theoretically only need to stop at TLAB's top and resume at its
453 // end.
454
455 if (VM.getVM().getUseTLAB()) {
456 for (JavaThread thread = VM.getVM().getThreads().first(); thread != null; thread = thread.next()) {
457 ThreadLocalAllocBuffer tlab = thread.tlab();
458 if (tlab.start() != null) {
459 if ((tlab.top() == null) || (tlab.end() == null)) {
460 System.err.print("Warning: skipping invalid TLAB for thread ");
461 thread.printThreadIDOn(System.err);
462 System.err.println();
463 } else {
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
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_interface.*;
36 import sun.jvm.hotspot.gc_implementation.g1.*;
37 import sun.jvm.hotspot.gc_implementation.shenandoah.*;
38 import sun.jvm.hotspot.gc_implementation.parallelScavenge.*;
39 import sun.jvm.hotspot.memory.*;
40 import sun.jvm.hotspot.runtime.*;
41 import sun.jvm.hotspot.types.*;
42 import sun.jvm.hotspot.utilities.*;
43
44 public class ObjectHeap {
45
46 private static final boolean DEBUG;
47
48 static {
49 DEBUG = System.getProperty("sun.jvm.hotspot.oops.ObjectHeap.DEBUG") != null;
50 }
51
52 private Address boolArrayKlassHandle;
53 private Address byteArrayKlassHandle;
54 private Address charArrayKlassHandle;
55 private Address intArrayKlassHandle;
56 private Address shortArrayKlassHandle;
57 private Address longArrayKlassHandle;
421
422 if (heap instanceof GenCollectedHeap) {
423 GenCollectedHeap genHeap = (GenCollectedHeap) heap;
424 // Run through all generations, obtaining bottom-top pairs.
425 for (int i = 0; i < genHeap.nGens(); i++) {
426 Generation gen = genHeap.getGen(i);
427 gen.spaceIterate(lrc, true);
428 }
429 } else if (heap instanceof ParallelScavengeHeap) {
430 ParallelScavengeHeap psh = (ParallelScavengeHeap) heap;
431 PSYoungGen youngGen = psh.youngGen();
432 // Add eden space
433 addLiveRegions("eden", youngGen.edenSpace().getLiveRegions(), liveRegions);
434 // Add from-space but not to-space
435 addLiveRegions("from", youngGen.fromSpace().getLiveRegions(), liveRegions);
436 PSOldGen oldGen = psh.oldGen();
437 addLiveRegions("old ", oldGen.objectSpace().getLiveRegions(), liveRegions);
438 } else if (heap instanceof G1CollectedHeap) {
439 G1CollectedHeap g1h = (G1CollectedHeap) heap;
440 g1h.heapRegionIterate(lrc);
441 } else if (heap instanceof ShenandoahHeap) {
442 ShenandoahHeap sh = (ShenandoahHeap) heap;
443 addLiveRegions("heap", sh.getLiveRegions(), liveRegions);
444 } else {
445 if (Assert.ASSERTS_ENABLED) {
446 Assert.that(false, "Expecting GenCollectedHeap, G1CollectedHeap, " +
447 "SheandoahHeap or ParallelScavengeHeap, but got " +
448 heap.getClass().getName());
449 }
450 }
451
452 // If UseTLAB is enabled, snip out regions associated with TLABs'
453 // dead regions. Note that TLABs can be present in any generation.
454
455 // FIXME: consider adding fewer boundaries to live region list.
456 // Theoretically only need to stop at TLAB's top and resume at its
457 // end.
458
459 if (VM.getVM().getUseTLAB()) {
460 for (JavaThread thread = VM.getVM().getThreads().first(); thread != null; thread = thread.next()) {
461 ThreadLocalAllocBuffer tlab = thread.tlab();
462 if (tlab.start() != null) {
463 if ((tlab.top() == null) || (tlab.end() == null)) {
464 System.err.print("Warning: skipping invalid TLAB for thread ");
465 thread.printThreadIDOn(System.err);
466 System.err.println();
467 } else {
|