8219003: SA: Refactor live regions iteration in preparation for JDK-8218922
Reviewed-by: eosterlund, ysuenaga
This commit is contained in:
parent
a5ec26c681
commit
f9dfc701c8
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 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
|
||||
@ -35,7 +35,7 @@ import sun.jvm.hotspot.runtime.*;
|
||||
import sun.jvm.hotspot.types.*;
|
||||
import sun.jvm.hotspot.utilities.*;
|
||||
|
||||
public class CompactibleFreeListSpace extends CompactibleSpace {
|
||||
public class CompactibleFreeListSpace extends CompactibleSpace implements LiveRegionsProvider {
|
||||
private static AddressField collectorField;
|
||||
private static AddressField indexedFreeListField;
|
||||
private static AddressField dictionaryField;
|
||||
@ -93,10 +93,10 @@ public class CompactibleFreeListSpace extends CompactibleSpace {
|
||||
}
|
||||
|
||||
public long used0() {
|
||||
List regions = getLiveRegions();
|
||||
List<MemRegion> regions = getLiveRegions();
|
||||
long usedSize = 0L;
|
||||
for (Iterator itr = regions.iterator(); itr.hasNext();) {
|
||||
MemRegion mr = (MemRegion) itr.next();
|
||||
for (Iterator<MemRegion> itr = regions.iterator(); itr.hasNext();) {
|
||||
MemRegion mr = itr.next();
|
||||
usedSize += mr.byteSize();
|
||||
}
|
||||
return usedSize;
|
||||
@ -154,8 +154,9 @@ public class CompactibleFreeListSpace extends CompactibleSpace {
|
||||
return addr;
|
||||
}
|
||||
|
||||
public List/*<MemRegion>*/ getLiveRegions() {
|
||||
List res = new ArrayList(); // List<MemRegion>
|
||||
@Override
|
||||
public List<MemRegion> getLiveRegions() {
|
||||
List<MemRegion> res = new ArrayList<>();
|
||||
VM vm = VM.getVM();
|
||||
Debugger dbg = vm.getDebugger();
|
||||
ObjectHeap heap = vm.getObjectHeap();
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 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
|
||||
@ -66,6 +66,9 @@ public class ConcurrentMarkSweepGeneration extends CardGeneration {
|
||||
public void spaceIterate(SpaceClosure blk, boolean usedOnly) {
|
||||
blk.doSpace(cmsSpace());
|
||||
}
|
||||
public void liveRegionsIterate(LiveRegionsClosure closure) {
|
||||
closure.doLiveRegions(cmsSpace());
|
||||
}
|
||||
|
||||
public Generation.Name kind() {
|
||||
return Generation.Name.CONCURRENT_MARK_SWEEP;
|
||||
|
@ -80,6 +80,11 @@ public class EpsilonHeap extends CollectedHeap {
|
||||
return space;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void liveRegionsIterate(LiveRegionsClosure closure) {
|
||||
closure.doLiveRegions(space());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printOn(PrintStream tty) {
|
||||
MemRegion mr = reservedRegion();
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 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
|
||||
@ -32,8 +32,9 @@ import java.util.Observer;
|
||||
import sun.jvm.hotspot.debugger.Address;
|
||||
import sun.jvm.hotspot.gc.shared.CollectedHeap;
|
||||
import sun.jvm.hotspot.gc.shared.CollectedHeapName;
|
||||
import sun.jvm.hotspot.gc.shared.SpaceClosure;
|
||||
import sun.jvm.hotspot.gc.shared.LiveRegionsClosure;
|
||||
import sun.jvm.hotspot.gc.shared.PrintRegionClosure;
|
||||
import sun.jvm.hotspot.gc.shared.SpaceClosure;
|
||||
import sun.jvm.hotspot.memory.MemRegion;
|
||||
import sun.jvm.hotspot.runtime.VM;
|
||||
import sun.jvm.hotspot.runtime.VMObjectFactory;
|
||||
@ -137,6 +138,15 @@ public class G1CollectedHeap extends CollectedHeap {
|
||||
return CollectedHeapName.G1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void liveRegionsIterate(LiveRegionsClosure closure) {
|
||||
Iterator<HeapRegion> iter = heapRegionIterator();
|
||||
while (iter.hasNext()) {
|
||||
HeapRegion hr = iter.next();
|
||||
closure.doLiveRegions(hr);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printOn(PrintStream tty) {
|
||||
MemRegion mr = reservedRegion();
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 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
|
||||
@ -32,6 +32,7 @@ import java.util.Observer;
|
||||
import sun.jvm.hotspot.debugger.Address;
|
||||
import sun.jvm.hotspot.debugger.OopHandle;
|
||||
import sun.jvm.hotspot.gc.shared.CompactibleSpace;
|
||||
import sun.jvm.hotspot.gc.shared.LiveRegionsProvider;
|
||||
import sun.jvm.hotspot.memory.MemRegion;
|
||||
import sun.jvm.hotspot.runtime.VM;
|
||||
import sun.jvm.hotspot.runtime.VMObjectFactory;
|
||||
@ -43,7 +44,7 @@ import sun.jvm.hotspot.types.TypeDataBase;
|
||||
// Mirror class for HeapRegion. Currently we don't actually include
|
||||
// any of its fields but only iterate over it.
|
||||
|
||||
public class HeapRegion extends CompactibleSpace {
|
||||
public class HeapRegion extends CompactibleSpace implements LiveRegionsProvider {
|
||||
// static int GrainBytes;
|
||||
static private CIntegerField grainBytesField;
|
||||
static private AddressField topField;
|
||||
@ -86,8 +87,8 @@ public class HeapRegion extends CompactibleSpace {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List getLiveRegions() {
|
||||
List res = new ArrayList();
|
||||
public List<MemRegion> getLiveRegions() {
|
||||
List<MemRegion> res = new ArrayList<>();
|
||||
res.add(new MemRegion(bottom(), top()));
|
||||
return res;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 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
|
||||
@ -73,7 +73,7 @@ public abstract class ImmutableSpace extends VMObject {
|
||||
}
|
||||
|
||||
/** returns all MemRegions where live objects are */
|
||||
public abstract List/*<MemRegion>*/ getLiveRegions();
|
||||
public abstract List<MemRegion> getLiveRegions();
|
||||
|
||||
/** Returned value is in bytes */
|
||||
public long capacity() { return end().minus(bottom()); }
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 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
|
||||
@ -62,8 +62,8 @@ public class MutableSpace extends ImmutableSpace {
|
||||
}
|
||||
|
||||
/** returns all MemRegions where live objects are */
|
||||
public List/*<MemRegion>*/ getLiveRegions() {
|
||||
List res = new ArrayList();
|
||||
public List<MemRegion> getLiveRegions() {
|
||||
List<MemRegion> res = new ArrayList<>();
|
||||
res.add(new MemRegion(bottom(), top()));
|
||||
return res;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 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
|
||||
@ -29,6 +29,7 @@ import java.util.*;
|
||||
|
||||
import sun.jvm.hotspot.debugger.*;
|
||||
import sun.jvm.hotspot.gc.shared.*;
|
||||
import sun.jvm.hotspot.memory.MemRegion;
|
||||
import sun.jvm.hotspot.runtime.*;
|
||||
import sun.jvm.hotspot.types.*;
|
||||
|
||||
@ -88,6 +89,35 @@ public class ParallelScavengeHeap extends CollectedHeap {
|
||||
return CollectedHeapName.PARALLEL;
|
||||
}
|
||||
|
||||
// Simple wrapper to provide toString() usable for debugging.
|
||||
private class LiveRegionProviderImpl implements LiveRegionsProvider {
|
||||
private String name;
|
||||
private MutableSpace space;
|
||||
|
||||
public LiveRegionProviderImpl(String name, MutableSpace space) {
|
||||
this.name = name;
|
||||
this.space = space;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MemRegion> getLiveRegions() {
|
||||
return space.getLiveRegions();
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
public void liveRegionsIterate(LiveRegionsClosure closure) {
|
||||
// Add eden space
|
||||
closure.doLiveRegions(new LiveRegionProviderImpl("eden", youngGen().edenSpace()));
|
||||
// Add from-space but not to-space
|
||||
closure.doLiveRegions(new LiveRegionProviderImpl("from", youngGen().fromSpace()));
|
||||
|
||||
closure.doLiveRegions(new LiveRegionProviderImpl("old ", oldGen().objectSpace()));
|
||||
}
|
||||
|
||||
public void printOn(PrintStream tty) {
|
||||
tty.print("ParallelScavengeHeap [ ");
|
||||
youngGen().printOn(tty);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* 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
|
||||
@ -94,6 +94,11 @@ public class DefNewGeneration extends Generation {
|
||||
}
|
||||
}
|
||||
|
||||
public void liveRegionsIterate(LiveRegionsClosure closure) {
|
||||
closure.doLiveRegions(eden());
|
||||
closure.doLiveRegions(from());
|
||||
}
|
||||
|
||||
public void printOn(PrintStream tty) {
|
||||
tty.print(" eden");
|
||||
eden().printOn(tty);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* 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
|
||||
@ -76,6 +76,10 @@ public class TenuredGeneration extends CardGeneration {
|
||||
blk.doSpace(theSpace());
|
||||
}
|
||||
|
||||
public void liveRegionsIterate(LiveRegionsClosure closure) {
|
||||
closure.doLiveRegions(theSpace());
|
||||
}
|
||||
|
||||
public void printOn(PrintStream tty) {
|
||||
tty.print(" old ");
|
||||
theSpace().printOn(tty);
|
||||
|
@ -28,6 +28,7 @@ import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
import sun.jvm.hotspot.debugger.*;
|
||||
import sun.jvm.hotspot.gc.shared.*;
|
||||
import sun.jvm.hotspot.memory.*;
|
||||
import sun.jvm.hotspot.runtime.*;
|
||||
import sun.jvm.hotspot.types.*;
|
||||
@ -77,6 +78,8 @@ public abstract class CollectedHeap extends VMObject {
|
||||
|
||||
public abstract CollectedHeapName kind();
|
||||
|
||||
public abstract void liveRegionsIterate(LiveRegionsClosure closure);
|
||||
|
||||
public String oopAddressDescription(OopHandle handle) {
|
||||
return handle.toString();
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* 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
|
||||
@ -32,7 +32,7 @@ import sun.jvm.hotspot.memory.*;
|
||||
import sun.jvm.hotspot.runtime.*;
|
||||
import sun.jvm.hotspot.types.*;
|
||||
|
||||
public class ContiguousSpace extends CompactibleSpace {
|
||||
public class ContiguousSpace extends CompactibleSpace implements LiveRegionsProvider {
|
||||
private static AddressField topField;
|
||||
|
||||
static {
|
||||
@ -79,8 +79,8 @@ public class ContiguousSpace extends CompactibleSpace {
|
||||
}
|
||||
|
||||
/** Returns regions of Space where live objects live */
|
||||
public List/*<MemRegion>*/ getLiveRegions() {
|
||||
List res = new ArrayList();
|
||||
public List<MemRegion> getLiveRegions() {
|
||||
List<MemRegion> res = new ArrayList<>();
|
||||
res.add(new MemRegion(bottom(), top()));
|
||||
return res;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* 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
|
||||
@ -28,6 +28,7 @@ import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
import sun.jvm.hotspot.debugger.*;
|
||||
import sun.jvm.hotspot.gc.shared.*;
|
||||
import sun.jvm.hotspot.runtime.*;
|
||||
import sun.jvm.hotspot.types.*;
|
||||
import sun.jvm.hotspot.utilities.*;
|
||||
@ -134,6 +135,14 @@ abstract public class GenCollectedHeap extends CollectedHeap {
|
||||
}
|
||||
}
|
||||
|
||||
public void liveRegionsIterate(LiveRegionsClosure closure) {
|
||||
// Run through all generations, obtaining bottom-top pairs.
|
||||
for (int i = 0; i < nGens(); i++) {
|
||||
Generation gen = getGen(i);
|
||||
gen.liveRegionsIterate(closure);
|
||||
}
|
||||
}
|
||||
|
||||
public void printOn(PrintStream tty) {
|
||||
for (int i = 0; i < nGens(); i++) {
|
||||
tty.print("Gen " + i + ": ");
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* 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
|
||||
@ -184,6 +184,7 @@ public abstract class Generation extends VMObject {
|
||||
|
||||
/** Iteration - do not use for time critical operations */
|
||||
public abstract void spaceIterate(SpaceClosure blk, boolean usedOnly);
|
||||
public abstract void liveRegionsIterate(LiveRegionsClosure closure);
|
||||
|
||||
public void print() { printOn(System.out); }
|
||||
public abstract void printOn(PrintStream tty);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* 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
|
||||
@ -65,6 +65,8 @@ public class GenerationFactory {
|
||||
}
|
||||
public void spaceIterate(SpaceClosure blk, boolean usedOnly) {
|
||||
}
|
||||
public void liveRegionsIterate(LiveRegionsClosure closure) {
|
||||
}
|
||||
public void printOn(java.io.PrintStream tty) {
|
||||
tty.println("unknown subtype of Generation @ " + getAddress() + " (" +
|
||||
virtualSpace().low() + "," + virtualSpace().high() + ")");
|
||||
|
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.gc.shared;
|
||||
|
||||
public interface LiveRegionsClosure {
|
||||
public void doLiveRegions(LiveRegionsProvider lrp);
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.gc.shared;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import sun.jvm.hotspot.memory.MemRegion;
|
||||
|
||||
public interface LiveRegionsProvider {
|
||||
public List<MemRegion> getLiveRegions();
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* 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
|
||||
@ -89,9 +89,6 @@ public abstract class Space extends VMObject {
|
||||
return handle.addOffsetToAsOopHandle(size);
|
||||
}
|
||||
|
||||
/** returns all MemRegions where live objects are */
|
||||
public abstract List/*<MemRegion>*/ getLiveRegions();
|
||||
|
||||
/** Returned value is in bytes */
|
||||
public long capacity() { return end().minus(bottom()); }
|
||||
/** Returned value is in bytes */
|
||||
|
@ -25,6 +25,7 @@ package sun.jvm.hotspot.gc.shenandoah;
|
||||
|
||||
import sun.jvm.hotspot.gc.shared.CollectedHeap;
|
||||
import sun.jvm.hotspot.gc.shared.CollectedHeapName;
|
||||
import sun.jvm.hotspot.gc.shared.LiveRegionsClosure;
|
||||
import sun.jvm.hotspot.debugger.Address;
|
||||
import sun.jvm.hotspot.runtime.VM;
|
||||
import sun.jvm.hotspot.types.Type;
|
||||
@ -77,6 +78,12 @@ public class ShenandoahHeap extends CollectedHeap {
|
||||
return committed.getValue(addr);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void liveRegionsIterate(LiveRegionsClosure closure) {
|
||||
// Operation (currently) not supported with Shenandoah GC.
|
||||
System.err.println("Warning: Operation not supported with Shenandoah GC");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printOn(PrintStream tty) {
|
||||
MemRegion mr = reservedRegion();
|
||||
|
@ -30,6 +30,7 @@ import sun.jvm.hotspot.debugger.Address;
|
||||
import sun.jvm.hotspot.debugger.OopHandle;
|
||||
import sun.jvm.hotspot.gc.shared.CollectedHeap;
|
||||
import sun.jvm.hotspot.gc.shared.CollectedHeapName;
|
||||
import sun.jvm.hotspot.gc.shared.LiveRegionsClosure;
|
||||
import sun.jvm.hotspot.runtime.VM;
|
||||
import sun.jvm.hotspot.runtime.VMObjectFactory;
|
||||
import sun.jvm.hotspot.types.Type;
|
||||
@ -39,7 +40,6 @@ import sun.jvm.hotspot.utilities.BitMapInterface;
|
||||
// Mirror class for ZCollectedHeap.
|
||||
|
||||
public class ZCollectedHeap extends CollectedHeap {
|
||||
|
||||
private static long zHeapFieldOffset;
|
||||
|
||||
static {
|
||||
@ -119,6 +119,13 @@ public class ZCollectedHeap extends CollectedHeap {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void liveRegionsIterate(LiveRegionsClosure closure) {
|
||||
// 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");
|
||||
}
|
||||
|
||||
@Override
|
||||
public BitMapInterface createBitMap(long size) {
|
||||
// Ignores the size
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* 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
|
||||
@ -304,87 +304,48 @@ public class ObjectHeap {
|
||||
visitor.epilogue();
|
||||
}
|
||||
|
||||
private void addLiveRegions(String name, List input, List output) {
|
||||
for (Iterator itr = input.iterator(); itr.hasNext();) {
|
||||
MemRegion reg = (MemRegion) itr.next();
|
||||
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");
|
||||
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");
|
||||
Assert.that(bottom != null, "bottom address in a live region should not be null");
|
||||
}
|
||||
output.add(top);
|
||||
output.add(bottom);
|
||||
liveRegions.add(top);
|
||||
liveRegions.add(bottom);
|
||||
if (DEBUG) {
|
||||
System.err.println("Live region: " + name + ": " + bottom + ", " + top);
|
||||
}
|
||||
}
|
||||
System.err.println("Live region: " + lrp + ": " + 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;
|
||||
private List<Address> liveRegions;
|
||||
}
|
||||
|
||||
// Returns a List<Address> where the addresses come in pairs. These
|
||||
// designate the live regions of the heap.
|
||||
private List collectLiveRegions() {
|
||||
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.
|
||||
|
||||
// List<Address>. Addresses come in pairs.
|
||||
List liveRegions = new ArrayList();
|
||||
// Addresses come in pairs.
|
||||
List<Address> 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());
|
||||
}
|
||||
}
|
||||
heap.liveRegionsIterate(lrc);
|
||||
|
||||
// If UseTLAB is enabled, snip out regions associated with TLABs'
|
||||
// dead regions. Note that TLABs can be present in any generation.
|
||||
@ -440,11 +401,9 @@ public class ObjectHeap {
|
||||
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;
|
||||
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)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user