31 |
31 |
32 import java.util.*; |
32 import java.util.*; |
33 |
33 |
34 import sun.jvm.hotspot.debugger.*; |
34 import sun.jvm.hotspot.debugger.*; |
35 import sun.jvm.hotspot.gc_interface.*; |
35 import sun.jvm.hotspot.gc_interface.*; |
|
36 import sun.jvm.hotspot.gc_implementation.g1.*; |
36 import sun.jvm.hotspot.gc_implementation.parallelScavenge.*; |
37 import sun.jvm.hotspot.gc_implementation.parallelScavenge.*; |
37 import sun.jvm.hotspot.memory.*; |
38 import sun.jvm.hotspot.memory.*; |
38 import sun.jvm.hotspot.runtime.*; |
39 import sun.jvm.hotspot.runtime.*; |
39 import sun.jvm.hotspot.types.*; |
40 import sun.jvm.hotspot.types.*; |
40 import sun.jvm.hotspot.utilities.*; |
41 import sun.jvm.hotspot.utilities.*; |
512 visitor.epilogue(); |
513 visitor.epilogue(); |
513 } |
514 } |
514 |
515 |
515 private void addPermGenLiveRegions(List output, CollectedHeap heap) { |
516 private void addPermGenLiveRegions(List output, CollectedHeap heap) { |
516 LiveRegionsCollector lrc = new LiveRegionsCollector(output); |
517 LiveRegionsCollector lrc = new LiveRegionsCollector(output); |
517 if (heap instanceof GenCollectedHeap) { |
518 if (heap instanceof SharedHeap) { |
518 GenCollectedHeap genHeap = (GenCollectedHeap) heap; |
519 if (Assert.ASSERTS_ENABLED) { |
519 Generation gen = genHeap.permGen(); |
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(); |
520 gen.spaceIterate(lrc, true); |
528 gen.spaceIterate(lrc, true); |
521 } else if (heap instanceof ParallelScavengeHeap) { |
529 } else if (heap instanceof ParallelScavengeHeap) { |
522 ParallelScavengeHeap psh = (ParallelScavengeHeap) heap; |
530 ParallelScavengeHeap psh = (ParallelScavengeHeap) heap; |
523 PSPermGen permGen = psh.permGen(); |
531 PSPermGen permGen = psh.permGen(); |
524 addLiveRegions(permGen.objectSpace().getLiveRegions(), output); |
532 addLiveRegions(permGen.objectSpace().getLiveRegions(), output); |
525 } else { |
533 } else { |
526 if (Assert.ASSERTS_ENABLED) { |
534 if (Assert.ASSERTS_ENABLED) { |
527 Assert.that(false, "Expecting GenCollectedHeap or ParallelScavengeHeap, but got " + |
535 Assert.that(false, |
528 heap.getClass().getName()); |
536 "Expecting SharedHeap or ParallelScavengeHeap, " + |
|
537 "but got " + heap.getClass().getName()); |
529 } |
538 } |
530 } |
539 } |
531 } |
540 } |
532 |
541 |
533 private void addLiveRegions(List input, List output) { |
542 private void addLiveRegions(List input, List output) { |
586 addLiveRegions(youngGen.edenSpace().getLiveRegions(), liveRegions); |
595 addLiveRegions(youngGen.edenSpace().getLiveRegions(), liveRegions); |
587 // Add from-space but not to-space |
596 // Add from-space but not to-space |
588 addLiveRegions(youngGen.fromSpace().getLiveRegions(), liveRegions); |
597 addLiveRegions(youngGen.fromSpace().getLiveRegions(), liveRegions); |
589 PSOldGen oldGen = psh.oldGen(); |
598 PSOldGen oldGen = psh.oldGen(); |
590 addLiveRegions(oldGen.objectSpace().getLiveRegions(), liveRegions); |
599 addLiveRegions(oldGen.objectSpace().getLiveRegions(), liveRegions); |
|
600 } else if (heap instanceof G1CollectedHeap) { |
|
601 G1CollectedHeap g1h = (G1CollectedHeap) heap; |
|
602 g1h.heapRegionIterate(lrc); |
591 } else { |
603 } else { |
592 if (Assert.ASSERTS_ENABLED) { |
604 if (Assert.ASSERTS_ENABLED) { |
593 Assert.that(false, "Expecting GenCollectedHeap or ParallelScavengeHeap, but got " + |
605 Assert.that(false, "Expecting GenCollectedHeap, G1CollectedHeap, " + |
594 heap.getClass().getName()); |
606 "or ParallelScavengeHeap, but got " + |
|
607 heap.getClass().getName()); |
595 } |
608 } |
596 } |
609 } |
597 |
610 |
598 // handle perm generation |
611 // handle perm generation |
599 addPermGenLiveRegions(liveRegions, heap); |
612 addPermGenLiveRegions(liveRegions, heap); |