< prev index next >

src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ObjectHeap.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. --- 1,7 ---- /* ! * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation.
*** 302,392 **** } visitor.epilogue(); } ! private void addLiveRegions(String name, List input, List output) { ! for (Iterator itr = input.iterator(); itr.hasNext();) { ! MemRegion reg = (MemRegion) itr.next(); Address top = reg.end(); Address bottom = reg.start(); if (Assert.ASSERTS_ENABLED) { Assert.that(top != null, "top address in a live region should not be null"); } if (Assert.ASSERTS_ENABLED) { Assert.that(bottom != null, "bottom address in a live region should not be null"); } ! output.add(top); ! output.add(bottom); if (DEBUG) { ! System.err.println("Live region: " + name + ": " + bottom + ", " + top); } } } ! private class LiveRegionsCollector implements SpaceClosure { ! LiveRegionsCollector(List l) { ! liveRegions = l; ! } ! ! public void doSpace(Space s) { ! addLiveRegions(s.toString(), s.getLiveRegions(), liveRegions); ! } ! private List liveRegions; } // Returns a List<Address> where the addresses come in pairs. These // designate the live regions of the heap. ! private List collectLiveRegions() { // We want to iterate through all live portions of the heap, but // do not want to abort the heap traversal prematurely if we find // a problem (like an allocated but uninitialized object at the // top of a generation). To do this we enumerate all generations' // bottom and top regions, and factor in TLABs if necessary. ! // List<Address>. Addresses come in pairs. ! List liveRegions = new ArrayList(); LiveRegionsCollector lrc = new LiveRegionsCollector(liveRegions); CollectedHeap heap = VM.getVM().getUniverse().heap(); ! ! if (heap instanceof GenCollectedHeap) { ! GenCollectedHeap genHeap = (GenCollectedHeap) heap; ! // Run through all generations, obtaining bottom-top pairs. ! for (int i = 0; i < genHeap.nGens(); i++) { ! Generation gen = genHeap.getGen(i); ! gen.spaceIterate(lrc, true); ! } ! } else if (heap instanceof ParallelScavengeHeap) { ! ParallelScavengeHeap psh = (ParallelScavengeHeap) heap; ! PSYoungGen youngGen = psh.youngGen(); ! // Add eden space ! addLiveRegions("eden", youngGen.edenSpace().getLiveRegions(), liveRegions); ! // Add from-space but not to-space ! addLiveRegions("from", youngGen.fromSpace().getLiveRegions(), liveRegions); ! PSOldGen oldGen = psh.oldGen(); ! addLiveRegions("old ", oldGen.objectSpace().getLiveRegions(), liveRegions); ! } else if (heap instanceof G1CollectedHeap) { ! G1CollectedHeap g1h = (G1CollectedHeap) heap; ! g1h.heapRegionIterate(lrc); ! } else if (heap instanceof ShenandoahHeap) { ! // Operation (currently) not supported with Shenandoah GC. Print ! // a warning and leave the list of live regions empty. ! System.err.println("Warning: Operation not supported with Shenandoah GC"); ! } else if (heap instanceof ZCollectedHeap) { ! // Operation (currently) not supported with ZGC. Print ! // a warning and leave the list of live regions empty. ! System.err.println("Warning: Operation not supported with ZGC"); ! } else if (heap instanceof EpsilonHeap) { ! EpsilonHeap eh = (EpsilonHeap) heap; ! liveRegions.add(eh.space().top()); ! liveRegions.add(eh.space().bottom()); ! } else { ! if (Assert.ASSERTS_ENABLED) { ! Assert.that(false, "Unexpected CollectedHeap type: " + heap.getClass().getName()); ! } ! } // If UseTLAB is enabled, snip out regions associated with TLABs' // dead regions. Note that TLABs can be present in any generation. // FIXME: consider adding fewer boundaries to live region list. --- 302,353 ---- } visitor.epilogue(); } ! private static class LiveRegionsCollector implements LiveRegionsClosure { ! LiveRegionsCollector(List<Address> l) { ! liveRegions = l; ! } ! ! @Override ! public void doLiveRegions(LiveRegionsProvider lrp) { ! for (MemRegion reg : lrp.getLiveRegions()) { Address top = reg.end(); Address bottom = reg.start(); if (Assert.ASSERTS_ENABLED) { Assert.that(top != null, "top address in a live region should not be null"); } if (Assert.ASSERTS_ENABLED) { Assert.that(bottom != null, "bottom address in a live region should not be null"); } ! liveRegions.add(top); ! liveRegions.add(bottom); if (DEBUG) { ! System.err.println("Live region: " + lrp + ": " + bottom + ", " + top); } } } ! private List<Address> liveRegions; } // Returns a List<Address> where the addresses come in pairs. These // designate the live regions of the heap. ! private List<Address> collectLiveRegions() { // We want to iterate through all live portions of the heap, but // do not want to abort the heap traversal prematurely if we find // a problem (like an allocated but uninitialized object at the // top of a generation). To do this we enumerate all generations' // bottom and top regions, and factor in TLABs if necessary. ! // Addresses come in pairs. ! List<Address> liveRegions = new ArrayList<>(); LiveRegionsCollector lrc = new LiveRegionsCollector(liveRegions); CollectedHeap heap = VM.getVM().getUniverse().heap(); ! heap.liveRegionsIterate(lrc); // If UseTLAB is enabled, snip out regions associated with TLABs' // dead regions. Note that TLABs can be present in any generation. // FIXME: consider adding fewer boundaries to live region list.
*** 438,452 **** } return liveRegions; } ! private void sortLiveRegions(List liveRegions) { ! Collections.sort(liveRegions, new Comparator() { ! public int compare(Object o1, Object o2) { ! Address a1 = (Address) o1; ! Address a2 = (Address) o2; if (AddressOps.lt(a1, a2)) { return -1; } else if (AddressOps.gt(a1, a2)) { return 1; } --- 399,411 ---- } return liveRegions; } ! private void sortLiveRegions(List<Address> liveRegions) { ! Collections.sort(liveRegions, new Comparator<Address>() { ! public int compare(Address a1, Address a2) { if (AddressOps.lt(a1, a2)) { return -1; } else if (AddressOps.gt(a1, a2)) { return 1; }
< prev index next >