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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* 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.types.*;
|
||||||
import sun.jvm.hotspot.utilities.*;
|
import sun.jvm.hotspot.utilities.*;
|
||||||
|
|
||||||
public class CompactibleFreeListSpace extends CompactibleSpace {
|
public class CompactibleFreeListSpace extends CompactibleSpace implements LiveRegionsProvider {
|
||||||
private static AddressField collectorField;
|
private static AddressField collectorField;
|
||||||
private static AddressField indexedFreeListField;
|
private static AddressField indexedFreeListField;
|
||||||
private static AddressField dictionaryField;
|
private static AddressField dictionaryField;
|
||||||
@ -93,10 +93,10 @@ public class CompactibleFreeListSpace extends CompactibleSpace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public long used0() {
|
public long used0() {
|
||||||
List regions = getLiveRegions();
|
List<MemRegion> regions = getLiveRegions();
|
||||||
long usedSize = 0L;
|
long usedSize = 0L;
|
||||||
for (Iterator itr = regions.iterator(); itr.hasNext();) {
|
for (Iterator<MemRegion> itr = regions.iterator(); itr.hasNext();) {
|
||||||
MemRegion mr = (MemRegion) itr.next();
|
MemRegion mr = itr.next();
|
||||||
usedSize += mr.byteSize();
|
usedSize += mr.byteSize();
|
||||||
}
|
}
|
||||||
return usedSize;
|
return usedSize;
|
||||||
@ -154,8 +154,9 @@ public class CompactibleFreeListSpace extends CompactibleSpace {
|
|||||||
return addr;
|
return addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List/*<MemRegion>*/ getLiveRegions() {
|
@Override
|
||||||
List res = new ArrayList(); // List<MemRegion>
|
public List<MemRegion> getLiveRegions() {
|
||||||
|
List<MemRegion> res = new ArrayList<>();
|
||||||
VM vm = VM.getVM();
|
VM vm = VM.getVM();
|
||||||
Debugger dbg = vm.getDebugger();
|
Debugger dbg = vm.getDebugger();
|
||||||
ObjectHeap heap = vm.getObjectHeap();
|
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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* 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) {
|
public void spaceIterate(SpaceClosure blk, boolean usedOnly) {
|
||||||
blk.doSpace(cmsSpace());
|
blk.doSpace(cmsSpace());
|
||||||
}
|
}
|
||||||
|
public void liveRegionsIterate(LiveRegionsClosure closure) {
|
||||||
|
closure.doLiveRegions(cmsSpace());
|
||||||
|
}
|
||||||
|
|
||||||
public Generation.Name kind() {
|
public Generation.Name kind() {
|
||||||
return Generation.Name.CONCURRENT_MARK_SWEEP;
|
return Generation.Name.CONCURRENT_MARK_SWEEP;
|
||||||
|
@ -80,6 +80,11 @@ public class EpsilonHeap extends CollectedHeap {
|
|||||||
return space;
|
return space;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void liveRegionsIterate(LiveRegionsClosure closure) {
|
||||||
|
closure.doLiveRegions(space());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void printOn(PrintStream tty) {
|
public void printOn(PrintStream tty) {
|
||||||
MemRegion mr = reservedRegion();
|
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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* 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.debugger.Address;
|
||||||
import sun.jvm.hotspot.gc.shared.CollectedHeap;
|
import sun.jvm.hotspot.gc.shared.CollectedHeap;
|
||||||
import sun.jvm.hotspot.gc.shared.CollectedHeapName;
|
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.PrintRegionClosure;
|
||||||
|
import sun.jvm.hotspot.gc.shared.SpaceClosure;
|
||||||
import sun.jvm.hotspot.memory.MemRegion;
|
import sun.jvm.hotspot.memory.MemRegion;
|
||||||
import sun.jvm.hotspot.runtime.VM;
|
import sun.jvm.hotspot.runtime.VM;
|
||||||
import sun.jvm.hotspot.runtime.VMObjectFactory;
|
import sun.jvm.hotspot.runtime.VMObjectFactory;
|
||||||
@ -137,6 +138,15 @@ public class G1CollectedHeap extends CollectedHeap {
|
|||||||
return CollectedHeapName.G1;
|
return CollectedHeapName.G1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void liveRegionsIterate(LiveRegionsClosure closure) {
|
||||||
|
Iterator<HeapRegion> iter = heapRegionIterator();
|
||||||
|
while (iter.hasNext()) {
|
||||||
|
HeapRegion hr = iter.next();
|
||||||
|
closure.doLiveRegions(hr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void printOn(PrintStream tty) {
|
public void printOn(PrintStream tty) {
|
||||||
MemRegion mr = reservedRegion();
|
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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* 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.Address;
|
||||||
import sun.jvm.hotspot.debugger.OopHandle;
|
import sun.jvm.hotspot.debugger.OopHandle;
|
||||||
import sun.jvm.hotspot.gc.shared.CompactibleSpace;
|
import sun.jvm.hotspot.gc.shared.CompactibleSpace;
|
||||||
|
import sun.jvm.hotspot.gc.shared.LiveRegionsProvider;
|
||||||
import sun.jvm.hotspot.memory.MemRegion;
|
import sun.jvm.hotspot.memory.MemRegion;
|
||||||
import sun.jvm.hotspot.runtime.VM;
|
import sun.jvm.hotspot.runtime.VM;
|
||||||
import sun.jvm.hotspot.runtime.VMObjectFactory;
|
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
|
// Mirror class for HeapRegion. Currently we don't actually include
|
||||||
// any of its fields but only iterate over it.
|
// 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 int GrainBytes;
|
||||||
static private CIntegerField grainBytesField;
|
static private CIntegerField grainBytesField;
|
||||||
static private AddressField topField;
|
static private AddressField topField;
|
||||||
@ -86,8 +87,8 @@ public class HeapRegion extends CompactibleSpace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List getLiveRegions() {
|
public List<MemRegion> getLiveRegions() {
|
||||||
List res = new ArrayList();
|
List<MemRegion> res = new ArrayList<>();
|
||||||
res.add(new MemRegion(bottom(), top()));
|
res.add(new MemRegion(bottom(), top()));
|
||||||
return res;
|
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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* 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 */
|
/** returns all MemRegions where live objects are */
|
||||||
public abstract List/*<MemRegion>*/ getLiveRegions();
|
public abstract List<MemRegion> getLiveRegions();
|
||||||
|
|
||||||
/** Returned value is in bytes */
|
/** Returned value is in bytes */
|
||||||
public long capacity() { return end().minus(bottom()); }
|
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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* 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 */
|
/** returns all MemRegions where live objects are */
|
||||||
public List/*<MemRegion>*/ getLiveRegions() {
|
public List<MemRegion> getLiveRegions() {
|
||||||
List res = new ArrayList();
|
List<MemRegion> res = new ArrayList<>();
|
||||||
res.add(new MemRegion(bottom(), top()));
|
res.add(new MemRegion(bottom(), top()));
|
||||||
return res;
|
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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* 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.debugger.*;
|
||||||
import sun.jvm.hotspot.gc.shared.*;
|
import sun.jvm.hotspot.gc.shared.*;
|
||||||
|
import sun.jvm.hotspot.memory.MemRegion;
|
||||||
import sun.jvm.hotspot.runtime.*;
|
import sun.jvm.hotspot.runtime.*;
|
||||||
import sun.jvm.hotspot.types.*;
|
import sun.jvm.hotspot.types.*;
|
||||||
|
|
||||||
@ -88,6 +89,35 @@ public class ParallelScavengeHeap extends CollectedHeap {
|
|||||||
return CollectedHeapName.PARALLEL;
|
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) {
|
public void printOn(PrintStream tty) {
|
||||||
tty.print("ParallelScavengeHeap [ ");
|
tty.print("ParallelScavengeHeap [ ");
|
||||||
youngGen().printOn(tty);
|
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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* 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) {
|
public void printOn(PrintStream tty) {
|
||||||
tty.print(" eden");
|
tty.print(" eden");
|
||||||
eden().printOn(tty);
|
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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* 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());
|
blk.doSpace(theSpace());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void liveRegionsIterate(LiveRegionsClosure closure) {
|
||||||
|
closure.doLiveRegions(theSpace());
|
||||||
|
}
|
||||||
|
|
||||||
public void printOn(PrintStream tty) {
|
public void printOn(PrintStream tty) {
|
||||||
tty.print(" old ");
|
tty.print(" old ");
|
||||||
theSpace().printOn(tty);
|
theSpace().printOn(tty);
|
||||||
|
@ -28,6 +28,7 @@ import java.io.*;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import sun.jvm.hotspot.debugger.*;
|
import sun.jvm.hotspot.debugger.*;
|
||||||
|
import sun.jvm.hotspot.gc.shared.*;
|
||||||
import sun.jvm.hotspot.memory.*;
|
import sun.jvm.hotspot.memory.*;
|
||||||
import sun.jvm.hotspot.runtime.*;
|
import sun.jvm.hotspot.runtime.*;
|
||||||
import sun.jvm.hotspot.types.*;
|
import sun.jvm.hotspot.types.*;
|
||||||
@ -77,6 +78,8 @@ public abstract class CollectedHeap extends VMObject {
|
|||||||
|
|
||||||
public abstract CollectedHeapName kind();
|
public abstract CollectedHeapName kind();
|
||||||
|
|
||||||
|
public abstract void liveRegionsIterate(LiveRegionsClosure closure);
|
||||||
|
|
||||||
public String oopAddressDescription(OopHandle handle) {
|
public String oopAddressDescription(OopHandle handle) {
|
||||||
return handle.toString();
|
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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* 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.runtime.*;
|
||||||
import sun.jvm.hotspot.types.*;
|
import sun.jvm.hotspot.types.*;
|
||||||
|
|
||||||
public class ContiguousSpace extends CompactibleSpace {
|
public class ContiguousSpace extends CompactibleSpace implements LiveRegionsProvider {
|
||||||
private static AddressField topField;
|
private static AddressField topField;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
@ -79,8 +79,8 @@ public class ContiguousSpace extends CompactibleSpace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Returns regions of Space where live objects live */
|
/** Returns regions of Space where live objects live */
|
||||||
public List/*<MemRegion>*/ getLiveRegions() {
|
public List<MemRegion> getLiveRegions() {
|
||||||
List res = new ArrayList();
|
List<MemRegion> res = new ArrayList<>();
|
||||||
res.add(new MemRegion(bottom(), top()));
|
res.add(new MemRegion(bottom(), top()));
|
||||||
return res;
|
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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -28,6 +28,7 @@ import java.io.*;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import sun.jvm.hotspot.debugger.*;
|
import sun.jvm.hotspot.debugger.*;
|
||||||
|
import sun.jvm.hotspot.gc.shared.*;
|
||||||
import sun.jvm.hotspot.runtime.*;
|
import sun.jvm.hotspot.runtime.*;
|
||||||
import sun.jvm.hotspot.types.*;
|
import sun.jvm.hotspot.types.*;
|
||||||
import sun.jvm.hotspot.utilities.*;
|
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) {
|
public void printOn(PrintStream tty) {
|
||||||
for (int i = 0; i < nGens(); i++) {
|
for (int i = 0; i < nGens(); i++) {
|
||||||
tty.print("Gen " + 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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* 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 */
|
/** Iteration - do not use for time critical operations */
|
||||||
public abstract void spaceIterate(SpaceClosure blk, boolean usedOnly);
|
public abstract void spaceIterate(SpaceClosure blk, boolean usedOnly);
|
||||||
|
public abstract void liveRegionsIterate(LiveRegionsClosure closure);
|
||||||
|
|
||||||
public void print() { printOn(System.out); }
|
public void print() { printOn(System.out); }
|
||||||
public abstract void printOn(PrintStream tty);
|
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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* 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 spaceIterate(SpaceClosure blk, boolean usedOnly) {
|
||||||
}
|
}
|
||||||
|
public void liveRegionsIterate(LiveRegionsClosure closure) {
|
||||||
|
}
|
||||||
public void printOn(java.io.PrintStream tty) {
|
public void printOn(java.io.PrintStream tty) {
|
||||||
tty.println("unknown subtype of Generation @ " + getAddress() + " (" +
|
tty.println("unknown subtype of Generation @ " + getAddress() + " (" +
|
||||||
virtualSpace().low() + "," + virtualSpace().high() + ")");
|
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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* 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);
|
return handle.addOffsetToAsOopHandle(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** returns all MemRegions where live objects are */
|
|
||||||
public abstract List/*<MemRegion>*/ getLiveRegions();
|
|
||||||
|
|
||||||
/** Returned value is in bytes */
|
/** Returned value is in bytes */
|
||||||
public long capacity() { return end().minus(bottom()); }
|
public long capacity() { return end().minus(bottom()); }
|
||||||
/** Returned value is in bytes */
|
/** 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.CollectedHeap;
|
||||||
import sun.jvm.hotspot.gc.shared.CollectedHeapName;
|
import sun.jvm.hotspot.gc.shared.CollectedHeapName;
|
||||||
|
import sun.jvm.hotspot.gc.shared.LiveRegionsClosure;
|
||||||
import sun.jvm.hotspot.debugger.Address;
|
import sun.jvm.hotspot.debugger.Address;
|
||||||
import sun.jvm.hotspot.runtime.VM;
|
import sun.jvm.hotspot.runtime.VM;
|
||||||
import sun.jvm.hotspot.types.Type;
|
import sun.jvm.hotspot.types.Type;
|
||||||
@ -77,6 +78,12 @@ public class ShenandoahHeap extends CollectedHeap {
|
|||||||
return committed.getValue(addr);
|
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
|
@Override
|
||||||
public void printOn(PrintStream tty) {
|
public void printOn(PrintStream tty) {
|
||||||
MemRegion mr = reservedRegion();
|
MemRegion mr = reservedRegion();
|
||||||
|
@ -30,6 +30,7 @@ import sun.jvm.hotspot.debugger.Address;
|
|||||||
import sun.jvm.hotspot.debugger.OopHandle;
|
import sun.jvm.hotspot.debugger.OopHandle;
|
||||||
import sun.jvm.hotspot.gc.shared.CollectedHeap;
|
import sun.jvm.hotspot.gc.shared.CollectedHeap;
|
||||||
import sun.jvm.hotspot.gc.shared.CollectedHeapName;
|
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.VM;
|
||||||
import sun.jvm.hotspot.runtime.VMObjectFactory;
|
import sun.jvm.hotspot.runtime.VMObjectFactory;
|
||||||
import sun.jvm.hotspot.types.Type;
|
import sun.jvm.hotspot.types.Type;
|
||||||
@ -39,7 +40,6 @@ import sun.jvm.hotspot.utilities.BitMapInterface;
|
|||||||
// Mirror class for ZCollectedHeap.
|
// Mirror class for ZCollectedHeap.
|
||||||
|
|
||||||
public class ZCollectedHeap extends CollectedHeap {
|
public class ZCollectedHeap extends CollectedHeap {
|
||||||
|
|
||||||
private static long zHeapFieldOffset;
|
private static long zHeapFieldOffset;
|
||||||
|
|
||||||
static {
|
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
|
@Override
|
||||||
public BitMapInterface createBitMap(long size) {
|
public BitMapInterface createBitMap(long size) {
|
||||||
// Ignores the 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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -304,87 +304,48 @@ public class ObjectHeap {
|
|||||||
visitor.epilogue();
|
visitor.epilogue();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addLiveRegions(String name, List input, List output) {
|
private static class LiveRegionsCollector implements LiveRegionsClosure {
|
||||||
for (Iterator itr = input.iterator(); itr.hasNext();) {
|
LiveRegionsCollector(List<Address> l) {
|
||||||
MemRegion reg = (MemRegion) itr.next();
|
liveRegions = l;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void doLiveRegions(LiveRegionsProvider lrp) {
|
||||||
|
for (MemRegion reg : lrp.getLiveRegions()) {
|
||||||
Address top = reg.end();
|
Address top = reg.end();
|
||||||
Address bottom = reg.start();
|
Address bottom = reg.start();
|
||||||
if (Assert.ASSERTS_ENABLED) {
|
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) {
|
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);
|
liveRegions.add(top);
|
||||||
output.add(bottom);
|
liveRegions.add(bottom);
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
System.err.println("Live region: " + name + ": " + bottom + ", " + top);
|
System.err.println("Live region: " + lrp + ": " + bottom + ", " + top);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class LiveRegionsCollector implements SpaceClosure {
|
private List<Address> liveRegions;
|
||||||
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
|
// Returns a List<Address> where the addresses come in pairs. These
|
||||||
// designate the live regions of the heap.
|
// 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
|
// We want to iterate through all live portions of the heap, but
|
||||||
// do not want to abort the heap traversal prematurely if we find
|
// do not want to abort the heap traversal prematurely if we find
|
||||||
// a problem (like an allocated but uninitialized object at the
|
// a problem (like an allocated but uninitialized object at the
|
||||||
// top of a generation). To do this we enumerate all generations'
|
// top of a generation). To do this we enumerate all generations'
|
||||||
// bottom and top regions, and factor in TLABs if necessary.
|
// bottom and top regions, and factor in TLABs if necessary.
|
||||||
|
|
||||||
// List<Address>. Addresses come in pairs.
|
// Addresses come in pairs.
|
||||||
List liveRegions = new ArrayList();
|
List<Address> liveRegions = new ArrayList<>();
|
||||||
LiveRegionsCollector lrc = new LiveRegionsCollector(liveRegions);
|
LiveRegionsCollector lrc = new LiveRegionsCollector(liveRegions);
|
||||||
|
|
||||||
CollectedHeap heap = VM.getVM().getUniverse().heap();
|
CollectedHeap heap = VM.getVM().getUniverse().heap();
|
||||||
|
heap.liveRegionsIterate(lrc);
|
||||||
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'
|
// If UseTLAB is enabled, snip out regions associated with TLABs'
|
||||||
// dead regions. Note that TLABs can be present in any generation.
|
// dead regions. Note that TLABs can be present in any generation.
|
||||||
@ -440,11 +401,9 @@ public class ObjectHeap {
|
|||||||
return liveRegions;
|
return liveRegions;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sortLiveRegions(List liveRegions) {
|
private void sortLiveRegions(List<Address> liveRegions) {
|
||||||
Collections.sort(liveRegions, new Comparator() {
|
Collections.sort(liveRegions, new Comparator<Address>() {
|
||||||
public int compare(Object o1, Object o2) {
|
public int compare(Address a1, Address a2) {
|
||||||
Address a1 = (Address) o1;
|
|
||||||
Address a2 = (Address) o2;
|
|
||||||
if (AddressOps.lt(a1, a2)) {
|
if (AddressOps.lt(a1, a2)) {
|
||||||
return -1;
|
return -1;
|
||||||
} else if (AddressOps.gt(a1, a2)) {
|
} else if (AddressOps.gt(a1, a2)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user