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