mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
7059019: G1: add G1 support to the SA
Extend the SA to recognize the G1CollectedHeap and implement any code that's needed by our serviceability tools (jmap, jinfo, jstack, etc.) that depend on the SA. Reviewed-by: never, poonam, johnc
This commit is contained in:
parent
e3faa527bd
commit
95832db2e5
12 changed files with 427 additions and 35 deletions
|
@ -1,5 +1,5 @@
|
||||||
#
|
#
|
||||||
# Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
|
# Copyright (c) 2000, 2011, 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
|
||||||
|
@ -81,6 +81,7 @@ sun.jvm.hotspot.debugger.windbg.ia64 \
|
||||||
sun.jvm.hotspot.debugger.windbg.x86 \
|
sun.jvm.hotspot.debugger.windbg.x86 \
|
||||||
sun.jvm.hotspot.debugger.x86 \
|
sun.jvm.hotspot.debugger.x86 \
|
||||||
sun.jvm.hotspot.gc_implementation \
|
sun.jvm.hotspot.gc_implementation \
|
||||||
|
sun.jvm.hotspot.gc_implementation.g1 \
|
||||||
sun.jvm.hotspot.gc_implementation.parallelScavenge \
|
sun.jvm.hotspot.gc_implementation.parallelScavenge \
|
||||||
sun.jvm.hotspot.gc_implementation.shared \
|
sun.jvm.hotspot.gc_implementation.shared \
|
||||||
sun.jvm.hotspot.gc_interface \
|
sun.jvm.hotspot.gc_interface \
|
||||||
|
@ -167,6 +168,9 @@ sun/jvm/hotspot/debugger/windbg/*.java \
|
||||||
sun/jvm/hotspot/debugger/windbg/ia64/*.java \
|
sun/jvm/hotspot/debugger/windbg/ia64/*.java \
|
||||||
sun/jvm/hotspot/debugger/windbg/x86/*.java \
|
sun/jvm/hotspot/debugger/windbg/x86/*.java \
|
||||||
sun/jvm/hotspot/debugger/x86/*.java \
|
sun/jvm/hotspot/debugger/x86/*.java \
|
||||||
|
sun/jvm/hotspot/gc_implementation/g1/*.java \
|
||||||
|
sun/jvm/hotspot/gc_implementation/parallelScavenge/*.java \
|
||||||
|
sun/jvm/hotspot/gc_implementation/shared/*.java \
|
||||||
sun/jvm/hotspot/interpreter/*.java \
|
sun/jvm/hotspot/interpreter/*.java \
|
||||||
sun/jvm/hotspot/jdi/*.java \
|
sun/jvm/hotspot/jdi/*.java \
|
||||||
sun/jvm/hotspot/livejvm/*.java \
|
sun/jvm/hotspot/livejvm/*.java \
|
||||||
|
|
|
@ -0,0 +1,107 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2011, 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_implementation.g1;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Observable;
|
||||||
|
import java.util.Observer;
|
||||||
|
|
||||||
|
import sun.jvm.hotspot.debugger.Address;
|
||||||
|
import sun.jvm.hotspot.gc_interface.CollectedHeapName;
|
||||||
|
import sun.jvm.hotspot.memory.MemRegion;
|
||||||
|
import sun.jvm.hotspot.memory.SharedHeap;
|
||||||
|
import sun.jvm.hotspot.memory.SpaceClosure;
|
||||||
|
import sun.jvm.hotspot.runtime.VM;
|
||||||
|
import sun.jvm.hotspot.runtime.VMObjectFactory;
|
||||||
|
import sun.jvm.hotspot.types.CIntegerField;
|
||||||
|
import sun.jvm.hotspot.types.Type;
|
||||||
|
import sun.jvm.hotspot.types.TypeDataBase;
|
||||||
|
|
||||||
|
// Mirror class for G1CollectedHeap.
|
||||||
|
|
||||||
|
public class G1CollectedHeap extends SharedHeap {
|
||||||
|
// HeapRegionSeq _seq;
|
||||||
|
static private long hrsFieldOffset;
|
||||||
|
// MemRegion _g1_committed;
|
||||||
|
static private long g1CommittedFieldOffset;
|
||||||
|
// size_t _summary_bytes_used;
|
||||||
|
static private CIntegerField summaryBytesUsedField;
|
||||||
|
|
||||||
|
static {
|
||||||
|
VM.registerVMInitializedObserver(new Observer() {
|
||||||
|
public void update(Observable o, Object data) {
|
||||||
|
initialize(VM.getVM().getTypeDataBase());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
static private synchronized void initialize(TypeDataBase db) {
|
||||||
|
Type type = db.lookupType("G1CollectedHeap");
|
||||||
|
|
||||||
|
hrsFieldOffset = type.getField("_hrs").getOffset();
|
||||||
|
g1CommittedFieldOffset = type.getField("_g1_committed").getOffset();
|
||||||
|
summaryBytesUsedField = type.getCIntegerField("_summary_bytes_used");
|
||||||
|
}
|
||||||
|
|
||||||
|
public long capacity() {
|
||||||
|
Address g1CommittedAddr = addr.addOffsetTo(g1CommittedFieldOffset);
|
||||||
|
MemRegion g1_committed = new MemRegion(g1CommittedAddr);
|
||||||
|
return g1_committed.byteSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
public long used() {
|
||||||
|
return summaryBytesUsedField.getValue(addr);
|
||||||
|
}
|
||||||
|
|
||||||
|
public long n_regions() {
|
||||||
|
return hrs().length();
|
||||||
|
}
|
||||||
|
|
||||||
|
private HeapRegionSeq hrs() {
|
||||||
|
Address hrsAddr = addr.addOffsetTo(hrsFieldOffset);
|
||||||
|
return (HeapRegionSeq) VMObjectFactory.newObject(HeapRegionSeq.class,
|
||||||
|
hrsAddr);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Iterator<HeapRegion> heapRegionIterator() {
|
||||||
|
return hrs().heapRegionIterator();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void heapRegionIterate(SpaceClosure scl) {
|
||||||
|
Iterator<HeapRegion> iter = heapRegionIterator();
|
||||||
|
while (iter.hasNext()) {
|
||||||
|
HeapRegion hr = iter.next();
|
||||||
|
scl.doSpace(hr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public CollectedHeapName kind() {
|
||||||
|
return CollectedHeapName.G1_COLLECTED_HEAP;
|
||||||
|
}
|
||||||
|
|
||||||
|
public G1CollectedHeap(Address addr) {
|
||||||
|
super(addr);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,66 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2011, 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_implementation.g1;
|
||||||
|
|
||||||
|
import java.util.Observable;
|
||||||
|
import java.util.Observer;
|
||||||
|
|
||||||
|
import sun.jvm.hotspot.debugger.Address;
|
||||||
|
import sun.jvm.hotspot.memory.ContiguousSpace;
|
||||||
|
import sun.jvm.hotspot.runtime.VM;
|
||||||
|
import sun.jvm.hotspot.types.CIntegerField;
|
||||||
|
import sun.jvm.hotspot.types.Type;
|
||||||
|
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 (which we get "for free"
|
||||||
|
// as HeapRegion ultimately inherits from ContiguousSpace).
|
||||||
|
|
||||||
|
public class HeapRegion extends ContiguousSpace {
|
||||||
|
// static int GrainBytes;
|
||||||
|
static private CIntegerField grainBytesField;
|
||||||
|
|
||||||
|
static {
|
||||||
|
VM.registerVMInitializedObserver(new Observer() {
|
||||||
|
public void update(Observable o, Object data) {
|
||||||
|
initialize(VM.getVM().getTypeDataBase());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
static private synchronized void initialize(TypeDataBase db) {
|
||||||
|
Type type = db.lookupType("HeapRegion");
|
||||||
|
|
||||||
|
grainBytesField = type.getCIntegerField("GrainBytes");
|
||||||
|
}
|
||||||
|
|
||||||
|
static public long grainBytes() {
|
||||||
|
return grainBytesField.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
public HeapRegion(Address addr) {
|
||||||
|
super(addr);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,102 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2011, 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_implementation.g1;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Observable;
|
||||||
|
import java.util.Observer;
|
||||||
|
|
||||||
|
import sun.jvm.hotspot.debugger.Address;
|
||||||
|
import sun.jvm.hotspot.runtime.VM;
|
||||||
|
import sun.jvm.hotspot.runtime.VMObject;
|
||||||
|
import sun.jvm.hotspot.runtime.VMObjectFactory;
|
||||||
|
import sun.jvm.hotspot.types.AddressField;
|
||||||
|
import sun.jvm.hotspot.types.CIntegerField;
|
||||||
|
import sun.jvm.hotspot.types.Type;
|
||||||
|
import sun.jvm.hotspot.types.TypeDataBase;
|
||||||
|
|
||||||
|
// Mirror class for HeapRegionSeq. It's essentially an index -> HeapRegion map.
|
||||||
|
|
||||||
|
public class HeapRegionSeq extends VMObject {
|
||||||
|
// HeapRegion** _regions;
|
||||||
|
static private AddressField regionsField;
|
||||||
|
// size_t _length;
|
||||||
|
static private CIntegerField lengthField;
|
||||||
|
|
||||||
|
static {
|
||||||
|
VM.registerVMInitializedObserver(new Observer() {
|
||||||
|
public void update(Observable o, Object data) {
|
||||||
|
initialize(VM.getVM().getTypeDataBase());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
static private synchronized void initialize(TypeDataBase db) {
|
||||||
|
Type type = db.lookupType("HeapRegionSeq");
|
||||||
|
|
||||||
|
regionsField = type.getAddressField("_regions");
|
||||||
|
lengthField = type.getCIntegerField("_length");
|
||||||
|
}
|
||||||
|
|
||||||
|
private HeapRegion at(long index) {
|
||||||
|
Address arrayAddr = regionsField.getValue(addr);
|
||||||
|
// Offset of &_region[index]
|
||||||
|
long offset = index * VM.getVM().getAddressSize();
|
||||||
|
Address regionAddr = arrayAddr.getAddressAt(offset);
|
||||||
|
return (HeapRegion) VMObjectFactory.newObject(HeapRegion.class,
|
||||||
|
regionAddr);
|
||||||
|
}
|
||||||
|
|
||||||
|
public long length() {
|
||||||
|
return lengthField.getValue(addr);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class HeapRegionIterator implements Iterator<HeapRegion> {
|
||||||
|
private long index;
|
||||||
|
private long length;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasNext() { return index < length; }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HeapRegion next() { return at(index++); }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void remove() { /* not supported */ }
|
||||||
|
|
||||||
|
HeapRegionIterator(Address addr) {
|
||||||
|
index = 0;
|
||||||
|
length = length();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Iterator<HeapRegion> heapRegionIterator() {
|
||||||
|
return new HeapRegionIterator(addr);
|
||||||
|
}
|
||||||
|
|
||||||
|
public HeapRegionSeq(Address addr) {
|
||||||
|
super(addr);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2000, 2011, 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
|
||||||
|
@ -34,6 +34,7 @@ public class CollectedHeapName {
|
||||||
public static final CollectedHeapName ABSTRACT = new CollectedHeapName("abstract");
|
public static final CollectedHeapName ABSTRACT = new CollectedHeapName("abstract");
|
||||||
public static final CollectedHeapName SHARED_HEAP = new CollectedHeapName("SharedHeap");
|
public static final CollectedHeapName SHARED_HEAP = new CollectedHeapName("SharedHeap");
|
||||||
public static final CollectedHeapName GEN_COLLECTED_HEAP = new CollectedHeapName("GenCollectedHeap");
|
public static final CollectedHeapName GEN_COLLECTED_HEAP = new CollectedHeapName("GenCollectedHeap");
|
||||||
|
public static final CollectedHeapName G1_COLLECTED_HEAP = new CollectedHeapName("G1CollectedHeap");
|
||||||
public static final CollectedHeapName PARALLEL_SCAVENGE_HEAP = new CollectedHeapName("ParallelScavengeHeap");
|
public static final CollectedHeapName PARALLEL_SCAVENGE_HEAP = new CollectedHeapName("ParallelScavengeHeap");
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2000, 2009, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2000, 2011, 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_interface.*;
|
import sun.jvm.hotspot.gc_interface.*;
|
||||||
|
import sun.jvm.hotspot.gc_implementation.g1.G1CollectedHeap;
|
||||||
import sun.jvm.hotspot.gc_implementation.parallelScavenge.*;
|
import sun.jvm.hotspot.gc_implementation.parallelScavenge.*;
|
||||||
import sun.jvm.hotspot.oops.*;
|
import sun.jvm.hotspot.oops.*;
|
||||||
import sun.jvm.hotspot.types.*;
|
import sun.jvm.hotspot.types.*;
|
||||||
|
@ -72,6 +73,7 @@ public class Universe {
|
||||||
heapConstructor = new VirtualConstructor(db);
|
heapConstructor = new VirtualConstructor(db);
|
||||||
heapConstructor.addMapping("GenCollectedHeap", GenCollectedHeap.class);
|
heapConstructor.addMapping("GenCollectedHeap", GenCollectedHeap.class);
|
||||||
heapConstructor.addMapping("ParallelScavengeHeap", ParallelScavengeHeap.class);
|
heapConstructor.addMapping("ParallelScavengeHeap", ParallelScavengeHeap.class);
|
||||||
|
heapConstructor.addMapping("G1CollectedHeap", G1CollectedHeap.class);
|
||||||
|
|
||||||
mainThreadGroupField = type.getOopField("_main_thread_group");
|
mainThreadGroupField = type.getOopField("_main_thread_group");
|
||||||
systemThreadGroupField = type.getOopField("_system_thread_group");
|
systemThreadGroupField = type.getOopField("_system_thread_group");
|
||||||
|
|
|
@ -33,6 +33,7 @@ import java.util.*;
|
||||||
|
|
||||||
import sun.jvm.hotspot.debugger.*;
|
import sun.jvm.hotspot.debugger.*;
|
||||||
import sun.jvm.hotspot.gc_interface.*;
|
import sun.jvm.hotspot.gc_interface.*;
|
||||||
|
import sun.jvm.hotspot.gc_implementation.g1.*;
|
||||||
import sun.jvm.hotspot.gc_implementation.parallelScavenge.*;
|
import sun.jvm.hotspot.gc_implementation.parallelScavenge.*;
|
||||||
import sun.jvm.hotspot.memory.*;
|
import sun.jvm.hotspot.memory.*;
|
||||||
import sun.jvm.hotspot.runtime.*;
|
import sun.jvm.hotspot.runtime.*;
|
||||||
|
@ -514,9 +515,16 @@ public class ObjectHeap {
|
||||||
|
|
||||||
private void addPermGenLiveRegions(List output, CollectedHeap heap) {
|
private void addPermGenLiveRegions(List output, CollectedHeap heap) {
|
||||||
LiveRegionsCollector lrc = new LiveRegionsCollector(output);
|
LiveRegionsCollector lrc = new LiveRegionsCollector(output);
|
||||||
if (heap instanceof GenCollectedHeap) {
|
if (heap instanceof SharedHeap) {
|
||||||
GenCollectedHeap genHeap = (GenCollectedHeap) heap;
|
if (Assert.ASSERTS_ENABLED) {
|
||||||
Generation gen = genHeap.permGen();
|
Assert.that(heap instanceof GenCollectedHeap ||
|
||||||
|
heap instanceof G1CollectedHeap,
|
||||||
|
"Expecting GenCollectedHeap or G1CollectedHeap, " +
|
||||||
|
"but got " + heap.getClass().getName());
|
||||||
|
}
|
||||||
|
// Handles both GenCollectedHeap and G1CollectedHeap
|
||||||
|
SharedHeap sharedHeap = (SharedHeap) heap;
|
||||||
|
Generation gen = sharedHeap.permGen();
|
||||||
gen.spaceIterate(lrc, true);
|
gen.spaceIterate(lrc, true);
|
||||||
} else if (heap instanceof ParallelScavengeHeap) {
|
} else if (heap instanceof ParallelScavengeHeap) {
|
||||||
ParallelScavengeHeap psh = (ParallelScavengeHeap) heap;
|
ParallelScavengeHeap psh = (ParallelScavengeHeap) heap;
|
||||||
|
@ -524,8 +532,9 @@ public class ObjectHeap {
|
||||||
addLiveRegions(permGen.objectSpace().getLiveRegions(), output);
|
addLiveRegions(permGen.objectSpace().getLiveRegions(), output);
|
||||||
} else {
|
} else {
|
||||||
if (Assert.ASSERTS_ENABLED) {
|
if (Assert.ASSERTS_ENABLED) {
|
||||||
Assert.that(false, "Expecting GenCollectedHeap or ParallelScavengeHeap, but got " +
|
Assert.that(false,
|
||||||
heap.getClass().getName());
|
"Expecting SharedHeap or ParallelScavengeHeap, " +
|
||||||
|
"but got " + heap.getClass().getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -588,10 +597,14 @@ public class ObjectHeap {
|
||||||
addLiveRegions(youngGen.fromSpace().getLiveRegions(), liveRegions);
|
addLiveRegions(youngGen.fromSpace().getLiveRegions(), liveRegions);
|
||||||
PSOldGen oldGen = psh.oldGen();
|
PSOldGen oldGen = psh.oldGen();
|
||||||
addLiveRegions(oldGen.objectSpace().getLiveRegions(), liveRegions);
|
addLiveRegions(oldGen.objectSpace().getLiveRegions(), liveRegions);
|
||||||
|
} else if (heap instanceof G1CollectedHeap) {
|
||||||
|
G1CollectedHeap g1h = (G1CollectedHeap) heap;
|
||||||
|
g1h.heapRegionIterate(lrc);
|
||||||
} else {
|
} else {
|
||||||
if (Assert.ASSERTS_ENABLED) {
|
if (Assert.ASSERTS_ENABLED) {
|
||||||
Assert.that(false, "Expecting GenCollectedHeap or ParallelScavengeHeap, but got " +
|
Assert.that(false, "Expecting GenCollectedHeap, G1CollectedHeap, " +
|
||||||
heap.getClass().getName());
|
"or ParallelScavengeHeap, but got " +
|
||||||
|
heap.getClass().getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2003, 2011, 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
|
||||||
|
@ -26,11 +26,11 @@ package sun.jvm.hotspot.tools;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import sun.jvm.hotspot.gc_interface.*;
|
import sun.jvm.hotspot.gc_interface.*;
|
||||||
|
import sun.jvm.hotspot.gc_implementation.g1.*;
|
||||||
import sun.jvm.hotspot.gc_implementation.parallelScavenge.*;
|
import sun.jvm.hotspot.gc_implementation.parallelScavenge.*;
|
||||||
import sun.jvm.hotspot.gc_implementation.shared.*;
|
import sun.jvm.hotspot.gc_implementation.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.tools.*;
|
|
||||||
|
|
||||||
public class HeapSummary extends Tool {
|
public class HeapSummary extends Tool {
|
||||||
|
|
||||||
|
@ -70,32 +70,50 @@ public class HeapSummary extends Tool {
|
||||||
System.out.println();
|
System.out.println();
|
||||||
System.out.println("Heap Usage:");
|
System.out.println("Heap Usage:");
|
||||||
|
|
||||||
if (heap instanceof GenCollectedHeap) {
|
if (heap instanceof SharedHeap) {
|
||||||
GenCollectedHeap genHeap = (GenCollectedHeap) heap;
|
SharedHeap sharedHeap = (SharedHeap) heap;
|
||||||
for (int n = 0; n < genHeap.nGens(); n++) {
|
if (sharedHeap instanceof GenCollectedHeap) {
|
||||||
Generation gen = genHeap.getGen(n);
|
GenCollectedHeap genHeap = (GenCollectedHeap) sharedHeap;
|
||||||
if (gen instanceof sun.jvm.hotspot.memory.DefNewGeneration) {
|
for (int n = 0; n < genHeap.nGens(); n++) {
|
||||||
System.out.println("New Generation (Eden + 1 Survivor Space):");
|
Generation gen = genHeap.getGen(n);
|
||||||
printGen(gen);
|
if (gen instanceof sun.jvm.hotspot.memory.DefNewGeneration) {
|
||||||
|
System.out.println("New Generation (Eden + 1 Survivor Space):");
|
||||||
|
printGen(gen);
|
||||||
|
|
||||||
ContiguousSpace eden = ((DefNewGeneration)gen).eden();
|
ContiguousSpace eden = ((DefNewGeneration)gen).eden();
|
||||||
System.out.println("Eden Space:");
|
System.out.println("Eden Space:");
|
||||||
printSpace(eden);
|
printSpace(eden);
|
||||||
|
|
||||||
ContiguousSpace from = ((DefNewGeneration)gen).from();
|
ContiguousSpace from = ((DefNewGeneration)gen).from();
|
||||||
System.out.println("From Space:");
|
System.out.println("From Space:");
|
||||||
printSpace(from);
|
printSpace(from);
|
||||||
|
|
||||||
ContiguousSpace to = ((DefNewGeneration)gen).to();
|
ContiguousSpace to = ((DefNewGeneration)gen).to();
|
||||||
System.out.println("To Space:");
|
System.out.println("To Space:");
|
||||||
printSpace(to);
|
printSpace(to);
|
||||||
} else {
|
} else {
|
||||||
System.out.println(gen.name() + ":");
|
System.out.println(gen.name() + ":");
|
||||||
printGen(gen);
|
printGen(gen);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else if (sharedHeap instanceof G1CollectedHeap) {
|
||||||
|
G1CollectedHeap g1h = (G1CollectedHeap) sharedHeap;
|
||||||
|
|
||||||
|
System.out.println("Garbage-First (G1) Heap");
|
||||||
|
long capacityBytes = g1h.capacity();
|
||||||
|
long usedBytes = g1h.used();
|
||||||
|
long freeBytes = capacityBytes - usedBytes;
|
||||||
|
printValMB("region size = ", HeapRegion.grainBytes());
|
||||||
|
printValue("regions = ", g1h.n_regions());
|
||||||
|
printValMB("capacity = ", capacityBytes);
|
||||||
|
printValMB("used = ", usedBytes);
|
||||||
|
printValMB("free = ", freeBytes);
|
||||||
|
System.out.println(alignment + (double) usedBytes * 100.0 / capacityBytes + "% used");
|
||||||
|
} else {
|
||||||
|
throw new RuntimeException("unknown SharedHeap type : " + heap.getClass());
|
||||||
}
|
}
|
||||||
// Perm generation
|
// Perm generation shared by the above
|
||||||
Generation permGen = genHeap.permGen();
|
Generation permGen = sharedHeap.permGen();
|
||||||
System.out.println("Perm Generation:");
|
System.out.println("Perm Generation:");
|
||||||
printGen(permGen);
|
printGen(permGen);
|
||||||
} else if (heap instanceof ParallelScavengeHeap) {
|
} else if (heap instanceof ParallelScavengeHeap) {
|
||||||
|
@ -119,7 +137,7 @@ public class HeapSummary extends Tool {
|
||||||
printValMB("free = ", permFree);
|
printValMB("free = ", permFree);
|
||||||
System.out.println(alignment + (double)permGen.used() * 100.0 / permGen.capacity() + "% used");
|
System.out.println(alignment + (double)permGen.used() * 100.0 / permGen.capacity() + "% used");
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException("unknown heap type : " + heap.getClass());
|
throw new RuntimeException("unknown CollectedHeap type : " + heap.getClass());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,6 +169,14 @@ public class HeapSummary extends Tool {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
l = getFlagValue("UseG1GC", flagMap);
|
||||||
|
if (l == 1L) {
|
||||||
|
System.out.print("Garbage-First (G1) GC ");
|
||||||
|
l = getFlagValue("ParallelGCThreads", flagMap);
|
||||||
|
System.out.println("with " + l + " thread(s)");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
System.out.println("Mark Sweep Compact GC");
|
System.out.println("Mark Sweep Compact GC");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#
|
#
|
||||||
# Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
|
# Copyright (c) 2003, 2011, 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
|
||||||
|
@ -79,6 +79,7 @@ $(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/windbg/amd64/*.java \
|
||||||
$(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/windbg/ia64/*.java \
|
$(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/windbg/ia64/*.java \
|
||||||
$(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/windbg/x86/*.java \
|
$(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/windbg/x86/*.java \
|
||||||
$(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/x86/*.java \
|
$(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/x86/*.java \
|
||||||
|
$(AGENT_SRC_DIR)/sun/jvm/hotspot/gc_implementation/g1/*.java \
|
||||||
$(AGENT_SRC_DIR)/sun/jvm/hotspot/gc_implementation/parallelScavenge/*.java \
|
$(AGENT_SRC_DIR)/sun/jvm/hotspot/gc_implementation/parallelScavenge/*.java \
|
||||||
$(AGENT_SRC_DIR)/sun/jvm/hotspot/gc_implementation/shared/*.java \
|
$(AGENT_SRC_DIR)/sun/jvm/hotspot/gc_implementation/shared/*.java \
|
||||||
$(AGENT_SRC_DIR)/sun/jvm/hotspot/gc_interface/*.java \
|
$(AGENT_SRC_DIR)/sun/jvm/hotspot/gc_interface/*.java \
|
||||||
|
|
|
@ -56,6 +56,7 @@ class FreeRegionList;
|
||||||
// and maintain that: _length <= _allocated_length <= _max_length
|
// and maintain that: _length <= _allocated_length <= _max_length
|
||||||
|
|
||||||
class HeapRegionSeq: public CHeapObj {
|
class HeapRegionSeq: public CHeapObj {
|
||||||
|
friend class VMStructs;
|
||||||
|
|
||||||
// The array that holds the HeapRegions.
|
// The array that holds the HeapRegions.
|
||||||
HeapRegion** _regions;
|
HeapRegion** _regions;
|
||||||
|
|
54
hotspot/src/share/vm/gc_implementation/g1/vmStructs_g1.hpp
Normal file
54
hotspot/src/share/vm/gc_implementation/g1/vmStructs_g1.hpp
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2011, 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.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SHARE_VM_GC_IMPLEMENTATION_G1_VMSTRUCTS_G1_HPP
|
||||||
|
#define SHARE_VM_GC_IMPLEMENTATION_G1_VMSTRUCTS_G1_HPP
|
||||||
|
|
||||||
|
#include "gc_implementation/g1/heapRegion.hpp"
|
||||||
|
#include "gc_implementation/g1/heapRegionSeq.inline.hpp"
|
||||||
|
#include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
|
||||||
|
|
||||||
|
#define VM_STRUCTS_G1(nonstatic_field, static_field) \
|
||||||
|
\
|
||||||
|
static_field(HeapRegion, GrainBytes, int) \
|
||||||
|
\
|
||||||
|
nonstatic_field(HeapRegionSeq, _regions, HeapRegion**) \
|
||||||
|
nonstatic_field(HeapRegionSeq, _length, size_t) \
|
||||||
|
\
|
||||||
|
nonstatic_field(G1CollectedHeap, _hrs, HeapRegionSeq) \
|
||||||
|
nonstatic_field(G1CollectedHeap, _g1_committed, MemRegion) \
|
||||||
|
nonstatic_field(G1CollectedHeap, _summary_bytes_used, size_t) \
|
||||||
|
|
||||||
|
|
||||||
|
#define VM_TYPES_G1(declare_type, declare_toplevel_type) \
|
||||||
|
\
|
||||||
|
declare_type(G1CollectedHeap, SharedHeap) \
|
||||||
|
\
|
||||||
|
declare_type(HeapRegion, ContiguousSpace) \
|
||||||
|
declare_toplevel_type(HeapRegionSeq) \
|
||||||
|
\
|
||||||
|
declare_toplevel_type(G1CollectedHeap*) \
|
||||||
|
declare_toplevel_type(HeapRegion*) \
|
||||||
|
|
||||||
|
#endif // SHARE_VM_GC_IMPLEMENTATION_G1_VMSTRUCTS_G1_HPP
|
|
@ -173,6 +173,7 @@
|
||||||
#include "gc_implementation/parallelScavenge/psVirtualspace.hpp"
|
#include "gc_implementation/parallelScavenge/psVirtualspace.hpp"
|
||||||
#include "gc_implementation/parallelScavenge/psYoungGen.hpp"
|
#include "gc_implementation/parallelScavenge/psYoungGen.hpp"
|
||||||
#include "gc_implementation/parallelScavenge/vmStructs_parallelgc.hpp"
|
#include "gc_implementation/parallelScavenge/vmStructs_parallelgc.hpp"
|
||||||
|
#include "gc_implementation/g1/vmStructs_g1.hpp"
|
||||||
#endif
|
#endif
|
||||||
#ifdef COMPILER2
|
#ifdef COMPILER2
|
||||||
#include "opto/addnode.hpp"
|
#include "opto/addnode.hpp"
|
||||||
|
@ -2855,6 +2856,9 @@ VMStructEntry VMStructs::localHotSpotVMStructs[] = {
|
||||||
VM_STRUCTS_CMS(GENERATE_NONSTATIC_VM_STRUCT_ENTRY, \
|
VM_STRUCTS_CMS(GENERATE_NONSTATIC_VM_STRUCT_ENTRY, \
|
||||||
GENERATE_NONSTATIC_VM_STRUCT_ENTRY, \
|
GENERATE_NONSTATIC_VM_STRUCT_ENTRY, \
|
||||||
GENERATE_STATIC_VM_STRUCT_ENTRY)
|
GENERATE_STATIC_VM_STRUCT_ENTRY)
|
||||||
|
|
||||||
|
VM_STRUCTS_G1(GENERATE_NONSTATIC_VM_STRUCT_ENTRY, \
|
||||||
|
GENERATE_STATIC_VM_STRUCT_ENTRY)
|
||||||
#endif // SERIALGC
|
#endif // SERIALGC
|
||||||
|
|
||||||
VM_STRUCTS_CPU(GENERATE_NONSTATIC_VM_STRUCT_ENTRY, \
|
VM_STRUCTS_CPU(GENERATE_NONSTATIC_VM_STRUCT_ENTRY, \
|
||||||
|
@ -2898,6 +2902,9 @@ VMTypeEntry VMStructs::localHotSpotVMTypes[] = {
|
||||||
GENERATE_TOPLEVEL_VM_TYPE_ENTRY)
|
GENERATE_TOPLEVEL_VM_TYPE_ENTRY)
|
||||||
|
|
||||||
VM_TYPES_PARNEW(GENERATE_VM_TYPE_ENTRY)
|
VM_TYPES_PARNEW(GENERATE_VM_TYPE_ENTRY)
|
||||||
|
|
||||||
|
VM_TYPES_G1(GENERATE_VM_TYPE_ENTRY,
|
||||||
|
GENERATE_TOPLEVEL_VM_TYPE_ENTRY)
|
||||||
#endif // SERIALGC
|
#endif // SERIALGC
|
||||||
|
|
||||||
VM_TYPES_CPU(GENERATE_VM_TYPE_ENTRY,
|
VM_TYPES_CPU(GENERATE_VM_TYPE_ENTRY,
|
||||||
|
@ -2997,6 +3004,9 @@ VMStructs::init() {
|
||||||
VM_STRUCTS_CMS(CHECK_NONSTATIC_VM_STRUCT_ENTRY,
|
VM_STRUCTS_CMS(CHECK_NONSTATIC_VM_STRUCT_ENTRY,
|
||||||
CHECK_VOLATILE_NONSTATIC_VM_STRUCT_ENTRY,
|
CHECK_VOLATILE_NONSTATIC_VM_STRUCT_ENTRY,
|
||||||
CHECK_STATIC_VM_STRUCT_ENTRY);
|
CHECK_STATIC_VM_STRUCT_ENTRY);
|
||||||
|
|
||||||
|
VM_STRUCTS_G1(CHECK_NONSTATIC_VM_STRUCT_ENTRY,
|
||||||
|
CHECK_STATIC_VM_STRUCT_ENTRY);
|
||||||
#endif // SERIALGC
|
#endif // SERIALGC
|
||||||
|
|
||||||
VM_STRUCTS_CPU(CHECK_NONSTATIC_VM_STRUCT_ENTRY,
|
VM_STRUCTS_CPU(CHECK_NONSTATIC_VM_STRUCT_ENTRY,
|
||||||
|
@ -3037,6 +3047,9 @@ VMStructs::init() {
|
||||||
CHECK_SINGLE_ARG_VM_TYPE_NO_OP);
|
CHECK_SINGLE_ARG_VM_TYPE_NO_OP);
|
||||||
|
|
||||||
VM_TYPES_PARNEW(CHECK_VM_TYPE_ENTRY)
|
VM_TYPES_PARNEW(CHECK_VM_TYPE_ENTRY)
|
||||||
|
|
||||||
|
VM_TYPES_G1(CHECK_VM_TYPE_ENTRY,
|
||||||
|
CHECK_SINGLE_ARG_VM_TYPE_NO_OP);
|
||||||
#endif // SERIALGC
|
#endif // SERIALGC
|
||||||
|
|
||||||
VM_TYPES_CPU(CHECK_VM_TYPE_ENTRY,
|
VM_TYPES_CPU(CHECK_VM_TYPE_ENTRY,
|
||||||
|
@ -3102,6 +3115,8 @@ VMStructs::init() {
|
||||||
debug_only(VM_STRUCTS_CMS(ENSURE_FIELD_TYPE_PRESENT, \
|
debug_only(VM_STRUCTS_CMS(ENSURE_FIELD_TYPE_PRESENT, \
|
||||||
ENSURE_FIELD_TYPE_PRESENT, \
|
ENSURE_FIELD_TYPE_PRESENT, \
|
||||||
ENSURE_FIELD_TYPE_PRESENT));
|
ENSURE_FIELD_TYPE_PRESENT));
|
||||||
|
debug_only(VM_STRUCTS_G1(ENSURE_FIELD_TYPE_PRESENT, \
|
||||||
|
ENSURE_FIELD_TYPE_PRESENT));
|
||||||
#endif // SERIALGC
|
#endif // SERIALGC
|
||||||
debug_only(VM_STRUCTS_CPU(ENSURE_FIELD_TYPE_PRESENT, \
|
debug_only(VM_STRUCTS_CPU(ENSURE_FIELD_TYPE_PRESENT, \
|
||||||
ENSURE_FIELD_TYPE_PRESENT, \
|
ENSURE_FIELD_TYPE_PRESENT, \
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue