7059019: G1: add G1 support to the SA

Tue, 20 Sep 2011 09:59:59 -0400

author
tonyp
date
Tue, 20 Sep 2011 09:59:59 -0400
changeset 3168
4f93f0d00802
parent 3149
77e1a9153757
child 3169
663cb89032b1

7059019: G1: add G1 support to the SA
Summary: 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

agent/make/Makefile file | annotate | diff | comparison | revisions
agent/src/share/classes/sun/jvm/hotspot/gc_implementation/g1/G1CollectedHeap.java file | annotate | diff | comparison | revisions
agent/src/share/classes/sun/jvm/hotspot/gc_implementation/g1/HeapRegion.java file | annotate | diff | comparison | revisions
agent/src/share/classes/sun/jvm/hotspot/gc_implementation/g1/HeapRegionSeq.java file | annotate | diff | comparison | revisions
agent/src/share/classes/sun/jvm/hotspot/gc_interface/CollectedHeapName.java file | annotate | diff | comparison | revisions
agent/src/share/classes/sun/jvm/hotspot/memory/Universe.java file | annotate | diff | comparison | revisions
agent/src/share/classes/sun/jvm/hotspot/oops/ObjectHeap.java file | annotate | diff | comparison | revisions
agent/src/share/classes/sun/jvm/hotspot/tools/HeapSummary.java file | annotate | diff | comparison | revisions
make/sa.files file | annotate | diff | comparison | revisions
src/share/vm/gc_implementation/g1/heapRegionSeq.hpp file | annotate | diff | comparison | revisions
src/share/vm/gc_implementation/g1/vmStructs_g1.hpp file | annotate | diff | comparison | revisions
src/share/vm/runtime/vmStructs.cpp file | annotate | diff | comparison | revisions
     1.1 --- a/agent/make/Makefile	Fri Sep 16 21:35:06 2011 -0700
     1.2 +++ b/agent/make/Makefile	Tue Sep 20 09:59:59 2011 -0400
     1.3 @@ -1,5 +1,5 @@
     1.4  #
     1.5 -# Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
     1.6 +# Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
     1.7  # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8  #
     1.9  # This code is free software; you can redistribute it and/or modify it
    1.10 @@ -81,6 +81,7 @@
    1.11  sun.jvm.hotspot.debugger.windbg.x86 \
    1.12  sun.jvm.hotspot.debugger.x86 \
    1.13  sun.jvm.hotspot.gc_implementation \
    1.14 +sun.jvm.hotspot.gc_implementation.g1 \
    1.15  sun.jvm.hotspot.gc_implementation.parallelScavenge \
    1.16  sun.jvm.hotspot.gc_implementation.shared \
    1.17  sun.jvm.hotspot.gc_interface \
    1.18 @@ -167,6 +168,9 @@
    1.19  sun/jvm/hotspot/debugger/windbg/ia64/*.java \
    1.20  sun/jvm/hotspot/debugger/windbg/x86/*.java \
    1.21  sun/jvm/hotspot/debugger/x86/*.java \
    1.22 +sun/jvm/hotspot/gc_implementation/g1/*.java \
    1.23 +sun/jvm/hotspot/gc_implementation/parallelScavenge/*.java \
    1.24 +sun/jvm/hotspot/gc_implementation/shared/*.java \
    1.25  sun/jvm/hotspot/interpreter/*.java \
    1.26  sun/jvm/hotspot/jdi/*.java \
    1.27  sun/jvm/hotspot/livejvm/*.java \
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/agent/src/share/classes/sun/jvm/hotspot/gc_implementation/g1/G1CollectedHeap.java	Tue Sep 20 09:59:59 2011 -0400
     2.3 @@ -0,0 +1,107 @@
     2.4 +/*
     2.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
     2.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     2.7 + *
     2.8 + * This code is free software; you can redistribute it and/or modify it
     2.9 + * under the terms of the GNU General Public License version 2 only, as
    2.10 + * published by the Free Software Foundation.
    2.11 + *
    2.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    2.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    2.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    2.15 + * version 2 for more details (a copy is included in the LICENSE file that
    2.16 + * accompanied this code).
    2.17 + *
    2.18 + * You should have received a copy of the GNU General Public License version
    2.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    2.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    2.21 + *
    2.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    2.23 + * or visit www.oracle.com if you need additional information or have any
    2.24 + * questions.
    2.25 + *
    2.26 + */
    2.27 +
    2.28 +package sun.jvm.hotspot.gc_implementation.g1;
    2.29 +
    2.30 +import java.util.Iterator;
    2.31 +import java.util.Observable;
    2.32 +import java.util.Observer;
    2.33 +
    2.34 +import sun.jvm.hotspot.debugger.Address;
    2.35 +import sun.jvm.hotspot.gc_interface.CollectedHeapName;
    2.36 +import sun.jvm.hotspot.memory.MemRegion;
    2.37 +import sun.jvm.hotspot.memory.SharedHeap;
    2.38 +import sun.jvm.hotspot.memory.SpaceClosure;
    2.39 +import sun.jvm.hotspot.runtime.VM;
    2.40 +import sun.jvm.hotspot.runtime.VMObjectFactory;
    2.41 +import sun.jvm.hotspot.types.CIntegerField;
    2.42 +import sun.jvm.hotspot.types.Type;
    2.43 +import sun.jvm.hotspot.types.TypeDataBase;
    2.44 +
    2.45 +// Mirror class for G1CollectedHeap.
    2.46 +
    2.47 +public class G1CollectedHeap extends SharedHeap {
    2.48 +    // HeapRegionSeq _seq;
    2.49 +    static private long hrsFieldOffset;
    2.50 +    // MemRegion _g1_committed;
    2.51 +    static private long g1CommittedFieldOffset;
    2.52 +    // size_t _summary_bytes_used;
    2.53 +    static private CIntegerField summaryBytesUsedField;
    2.54 +
    2.55 +    static {
    2.56 +        VM.registerVMInitializedObserver(new Observer() {
    2.57 +                public void update(Observable o, Object data) {
    2.58 +                    initialize(VM.getVM().getTypeDataBase());
    2.59 +                }
    2.60 +            });
    2.61 +    }
    2.62 +
    2.63 +    static private synchronized void initialize(TypeDataBase db) {
    2.64 +        Type type = db.lookupType("G1CollectedHeap");
    2.65 +
    2.66 +        hrsFieldOffset = type.getField("_hrs").getOffset();
    2.67 +        g1CommittedFieldOffset = type.getField("_g1_committed").getOffset();
    2.68 +        summaryBytesUsedField = type.getCIntegerField("_summary_bytes_used");
    2.69 +    }
    2.70 +
    2.71 +    public long capacity() {
    2.72 +        Address g1CommittedAddr = addr.addOffsetTo(g1CommittedFieldOffset);
    2.73 +        MemRegion g1_committed = new MemRegion(g1CommittedAddr);
    2.74 +        return g1_committed.byteSize();
    2.75 +    }
    2.76 +
    2.77 +    public long used() {
    2.78 +        return summaryBytesUsedField.getValue(addr);
    2.79 +    }
    2.80 +
    2.81 +    public long n_regions() {
    2.82 +        return hrs().length();
    2.83 +    }
    2.84 +
    2.85 +    private HeapRegionSeq hrs() {
    2.86 +        Address hrsAddr = addr.addOffsetTo(hrsFieldOffset);
    2.87 +        return (HeapRegionSeq) VMObjectFactory.newObject(HeapRegionSeq.class,
    2.88 +                                                         hrsAddr);
    2.89 +    }
    2.90 +
    2.91 +    private Iterator<HeapRegion> heapRegionIterator() {
    2.92 +        return hrs().heapRegionIterator();
    2.93 +    }
    2.94 +
    2.95 +    public void heapRegionIterate(SpaceClosure scl) {
    2.96 +        Iterator<HeapRegion> iter = heapRegionIterator();
    2.97 +        while (iter.hasNext()) {
    2.98 +            HeapRegion hr = iter.next();
    2.99 +            scl.doSpace(hr);
   2.100 +        }
   2.101 +    }
   2.102 +
   2.103 +    public CollectedHeapName kind() {
   2.104 +        return CollectedHeapName.G1_COLLECTED_HEAP;
   2.105 +    }
   2.106 +
   2.107 +    public G1CollectedHeap(Address addr) {
   2.108 +        super(addr);
   2.109 +    }
   2.110 +}
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/agent/src/share/classes/sun/jvm/hotspot/gc_implementation/g1/HeapRegion.java	Tue Sep 20 09:59:59 2011 -0400
     3.3 @@ -0,0 +1,66 @@
     3.4 +/*
     3.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
     3.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3.7 + *
     3.8 + * This code is free software; you can redistribute it and/or modify it
     3.9 + * under the terms of the GNU General Public License version 2 only, as
    3.10 + * published by the Free Software Foundation.
    3.11 + *
    3.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    3.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    3.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    3.15 + * version 2 for more details (a copy is included in the LICENSE file that
    3.16 + * accompanied this code).
    3.17 + *
    3.18 + * You should have received a copy of the GNU General Public License version
    3.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    3.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    3.21 + *
    3.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    3.23 + * or visit www.oracle.com if you need additional information or have any
    3.24 + * questions.
    3.25 + *
    3.26 + */
    3.27 +
    3.28 +package sun.jvm.hotspot.gc_implementation.g1;
    3.29 +
    3.30 +import java.util.Observable;
    3.31 +import java.util.Observer;
    3.32 +
    3.33 +import sun.jvm.hotspot.debugger.Address;
    3.34 +import sun.jvm.hotspot.memory.ContiguousSpace;
    3.35 +import sun.jvm.hotspot.runtime.VM;
    3.36 +import sun.jvm.hotspot.types.CIntegerField;
    3.37 +import sun.jvm.hotspot.types.Type;
    3.38 +import sun.jvm.hotspot.types.TypeDataBase;
    3.39 +
    3.40 +// Mirror class for HeapRegion. Currently we don't actually include
    3.41 +// any of its fields but only iterate over it (which we get "for free"
    3.42 +// as HeapRegion ultimately inherits from ContiguousSpace).
    3.43 +
    3.44 +public class HeapRegion extends ContiguousSpace {
    3.45 +    // static int GrainBytes;
    3.46 +    static private CIntegerField grainBytesField;
    3.47 +
    3.48 +    static {
    3.49 +        VM.registerVMInitializedObserver(new Observer() {
    3.50 +                public void update(Observable o, Object data) {
    3.51 +                    initialize(VM.getVM().getTypeDataBase());
    3.52 +                }
    3.53 +            });
    3.54 +    }
    3.55 +
    3.56 +    static private synchronized void initialize(TypeDataBase db) {
    3.57 +        Type type = db.lookupType("HeapRegion");
    3.58 +
    3.59 +        grainBytesField = type.getCIntegerField("GrainBytes");
    3.60 +    }
    3.61 +
    3.62 +    static public long grainBytes() {
    3.63 +        return grainBytesField.getValue();
    3.64 +    }
    3.65 +
    3.66 +    public HeapRegion(Address addr) {
    3.67 +        super(addr);
    3.68 +    }
    3.69 +}
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/agent/src/share/classes/sun/jvm/hotspot/gc_implementation/g1/HeapRegionSeq.java	Tue Sep 20 09:59:59 2011 -0400
     4.3 @@ -0,0 +1,102 @@
     4.4 +/*
     4.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
     4.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4.7 + *
     4.8 + * This code is free software; you can redistribute it and/or modify it
     4.9 + * under the terms of the GNU General Public License version 2 only, as
    4.10 + * published by the Free Software Foundation.
    4.11 + *
    4.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    4.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    4.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    4.15 + * version 2 for more details (a copy is included in the LICENSE file that
    4.16 + * accompanied this code).
    4.17 + *
    4.18 + * You should have received a copy of the GNU General Public License version
    4.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    4.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    4.21 + *
    4.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    4.23 + * or visit www.oracle.com if you need additional information or have any
    4.24 + * questions.
    4.25 + *
    4.26 + */
    4.27 +
    4.28 +package sun.jvm.hotspot.gc_implementation.g1;
    4.29 +
    4.30 +import java.util.Iterator;
    4.31 +import java.util.Observable;
    4.32 +import java.util.Observer;
    4.33 +
    4.34 +import sun.jvm.hotspot.debugger.Address;
    4.35 +import sun.jvm.hotspot.runtime.VM;
    4.36 +import sun.jvm.hotspot.runtime.VMObject;
    4.37 +import sun.jvm.hotspot.runtime.VMObjectFactory;
    4.38 +import sun.jvm.hotspot.types.AddressField;
    4.39 +import sun.jvm.hotspot.types.CIntegerField;
    4.40 +import sun.jvm.hotspot.types.Type;
    4.41 +import sun.jvm.hotspot.types.TypeDataBase;
    4.42 +
    4.43 +// Mirror class for HeapRegionSeq. It's essentially an index -> HeapRegion map.
    4.44 +
    4.45 +public class HeapRegionSeq extends VMObject {
    4.46 +    // HeapRegion** _regions;
    4.47 +    static private AddressField regionsField;
    4.48 +    // size_t _length;
    4.49 +    static private CIntegerField lengthField;
    4.50 +
    4.51 +    static {
    4.52 +        VM.registerVMInitializedObserver(new Observer() {
    4.53 +                public void update(Observable o, Object data) {
    4.54 +                    initialize(VM.getVM().getTypeDataBase());
    4.55 +                }
    4.56 +            });
    4.57 +    }
    4.58 +
    4.59 +    static private synchronized void initialize(TypeDataBase db) {
    4.60 +        Type type = db.lookupType("HeapRegionSeq");
    4.61 +
    4.62 +        regionsField = type.getAddressField("_regions");
    4.63 +        lengthField = type.getCIntegerField("_length");
    4.64 +    }
    4.65 +
    4.66 +    private HeapRegion at(long index) {
    4.67 +        Address arrayAddr = regionsField.getValue(addr);
    4.68 +        // Offset of &_region[index]
    4.69 +        long offset = index * VM.getVM().getAddressSize();
    4.70 +        Address regionAddr = arrayAddr.getAddressAt(offset);
    4.71 +        return (HeapRegion) VMObjectFactory.newObject(HeapRegion.class,
    4.72 +                                                      regionAddr);
    4.73 +    }
    4.74 +
    4.75 +    public long length() {
    4.76 +        return lengthField.getValue(addr);
    4.77 +    }
    4.78 +
    4.79 +    private class HeapRegionIterator implements Iterator<HeapRegion> {
    4.80 +        private long index;
    4.81 +        private long length;
    4.82 +
    4.83 +        @Override
    4.84 +        public boolean hasNext() { return index < length; }
    4.85 +
    4.86 +        @Override
    4.87 +        public HeapRegion next() { return at(index++);    }
    4.88 +
    4.89 +        @Override
    4.90 +        public void remove()     { /* not supported */    }
    4.91 +
    4.92 +        HeapRegionIterator(Address addr) {
    4.93 +            index = 0;
    4.94 +            length = length();
    4.95 +        }
    4.96 +    }
    4.97 +
    4.98 +    public Iterator<HeapRegion> heapRegionIterator() {
    4.99 +        return new HeapRegionIterator(addr);
   4.100 +    }
   4.101 +
   4.102 +    public HeapRegionSeq(Address addr) {
   4.103 +        super(addr);
   4.104 +    }
   4.105 +}
     5.1 --- a/agent/src/share/classes/sun/jvm/hotspot/gc_interface/CollectedHeapName.java	Fri Sep 16 21:35:06 2011 -0700
     5.2 +++ b/agent/src/share/classes/sun/jvm/hotspot/gc_interface/CollectedHeapName.java	Tue Sep 20 09:59:59 2011 -0400
     5.3 @@ -1,5 +1,5 @@
     5.4  /*
     5.5 - * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
     5.6 + * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
     5.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     5.8   *
     5.9   * This code is free software; you can redistribute it and/or modify it
    5.10 @@ -34,6 +34,7 @@
    5.11    public static final CollectedHeapName ABSTRACT = new CollectedHeapName("abstract");
    5.12    public static final CollectedHeapName SHARED_HEAP = new CollectedHeapName("SharedHeap");
    5.13    public static final CollectedHeapName GEN_COLLECTED_HEAP = new CollectedHeapName("GenCollectedHeap");
    5.14 +  public static final CollectedHeapName G1_COLLECTED_HEAP = new CollectedHeapName("G1CollectedHeap");
    5.15    public static final CollectedHeapName PARALLEL_SCAVENGE_HEAP = new CollectedHeapName("ParallelScavengeHeap");
    5.16  
    5.17    public String toString() {
     6.1 --- a/agent/src/share/classes/sun/jvm/hotspot/memory/Universe.java	Fri Sep 16 21:35:06 2011 -0700
     6.2 +++ b/agent/src/share/classes/sun/jvm/hotspot/memory/Universe.java	Tue Sep 20 09:59:59 2011 -0400
     6.3 @@ -1,5 +1,5 @@
     6.4  /*
     6.5 - * Copyright (c) 2000, 2009, Oracle and/or its affiliates. All rights reserved.
     6.6 + * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
     6.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     6.8   *
     6.9   * This code is free software; you can redistribute it and/or modify it
    6.10 @@ -28,6 +28,7 @@
    6.11  import java.util.*;
    6.12  import sun.jvm.hotspot.debugger.*;
    6.13  import sun.jvm.hotspot.gc_interface.*;
    6.14 +import sun.jvm.hotspot.gc_implementation.g1.G1CollectedHeap;
    6.15  import sun.jvm.hotspot.gc_implementation.parallelScavenge.*;
    6.16  import sun.jvm.hotspot.oops.*;
    6.17  import sun.jvm.hotspot.types.*;
    6.18 @@ -72,6 +73,7 @@
    6.19      heapConstructor = new VirtualConstructor(db);
    6.20      heapConstructor.addMapping("GenCollectedHeap", GenCollectedHeap.class);
    6.21      heapConstructor.addMapping("ParallelScavengeHeap", ParallelScavengeHeap.class);
    6.22 +    heapConstructor.addMapping("G1CollectedHeap", G1CollectedHeap.class);
    6.23  
    6.24      mainThreadGroupField   = type.getOopField("_main_thread_group");
    6.25      systemThreadGroupField = type.getOopField("_system_thread_group");
     7.1 --- a/agent/src/share/classes/sun/jvm/hotspot/oops/ObjectHeap.java	Fri Sep 16 21:35:06 2011 -0700
     7.2 +++ b/agent/src/share/classes/sun/jvm/hotspot/oops/ObjectHeap.java	Tue Sep 20 09:59:59 2011 -0400
     7.3 @@ -33,6 +33,7 @@
     7.4  
     7.5  import sun.jvm.hotspot.debugger.*;
     7.6  import sun.jvm.hotspot.gc_interface.*;
     7.7 +import sun.jvm.hotspot.gc_implementation.g1.*;
     7.8  import sun.jvm.hotspot.gc_implementation.parallelScavenge.*;
     7.9  import sun.jvm.hotspot.memory.*;
    7.10  import sun.jvm.hotspot.runtime.*;
    7.11 @@ -514,9 +515,16 @@
    7.12  
    7.13    private void addPermGenLiveRegions(List output, CollectedHeap heap) {
    7.14      LiveRegionsCollector lrc = new LiveRegionsCollector(output);
    7.15 -    if (heap instanceof GenCollectedHeap) {
    7.16 -       GenCollectedHeap genHeap = (GenCollectedHeap) heap;
    7.17 -       Generation gen = genHeap.permGen();
    7.18 +    if (heap instanceof SharedHeap) {
    7.19 +       if (Assert.ASSERTS_ENABLED) {
    7.20 +          Assert.that(heap instanceof GenCollectedHeap ||
    7.21 +                      heap instanceof G1CollectedHeap,
    7.22 +                      "Expecting GenCollectedHeap or G1CollectedHeap, " +
    7.23 +                      "but got " + heap.getClass().getName());
    7.24 +       }
    7.25 +       // Handles both GenCollectedHeap and G1CollectedHeap
    7.26 +       SharedHeap sharedHeap = (SharedHeap) heap;
    7.27 +       Generation gen = sharedHeap.permGen();
    7.28         gen.spaceIterate(lrc, true);
    7.29      } else if (heap instanceof ParallelScavengeHeap) {
    7.30         ParallelScavengeHeap psh = (ParallelScavengeHeap) heap;
    7.31 @@ -524,8 +532,9 @@
    7.32         addLiveRegions(permGen.objectSpace().getLiveRegions(), output);
    7.33      } else {
    7.34         if (Assert.ASSERTS_ENABLED) {
    7.35 -          Assert.that(false, "Expecting GenCollectedHeap or ParallelScavengeHeap, but got " +
    7.36 -                             heap.getClass().getName());
    7.37 +          Assert.that(false,
    7.38 +                      "Expecting SharedHeap or ParallelScavengeHeap, " +
    7.39 +                      "but got " + heap.getClass().getName());
    7.40         }
    7.41      }
    7.42    }
    7.43 @@ -588,10 +597,14 @@
    7.44         addLiveRegions(youngGen.fromSpace().getLiveRegions(), liveRegions);
    7.45         PSOldGen oldGen = psh.oldGen();
    7.46         addLiveRegions(oldGen.objectSpace().getLiveRegions(), liveRegions);
    7.47 +    } else if (heap instanceof G1CollectedHeap) {
    7.48 +        G1CollectedHeap g1h = (G1CollectedHeap) heap;
    7.49 +        g1h.heapRegionIterate(lrc);
    7.50      } else {
    7.51         if (Assert.ASSERTS_ENABLED) {
    7.52 -          Assert.that(false, "Expecting GenCollectedHeap or ParallelScavengeHeap, but got " +
    7.53 -                              heap.getClass().getName());
    7.54 +          Assert.that(false, "Expecting GenCollectedHeap, G1CollectedHeap, " +
    7.55 +                      "or ParallelScavengeHeap, but got " +
    7.56 +                      heap.getClass().getName());
    7.57         }
    7.58      }
    7.59  
     8.1 --- a/agent/src/share/classes/sun/jvm/hotspot/tools/HeapSummary.java	Fri Sep 16 21:35:06 2011 -0700
     8.2 +++ b/agent/src/share/classes/sun/jvm/hotspot/tools/HeapSummary.java	Tue Sep 20 09:59:59 2011 -0400
     8.3 @@ -1,5 +1,5 @@
     8.4  /*
     8.5 - * Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
     8.6 + * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
     8.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     8.8   *
     8.9   * This code is free software; you can redistribute it and/or modify it
    8.10 @@ -26,11 +26,11 @@
    8.11  
    8.12  import java.util.*;
    8.13  import sun.jvm.hotspot.gc_interface.*;
    8.14 +import sun.jvm.hotspot.gc_implementation.g1.*;
    8.15  import sun.jvm.hotspot.gc_implementation.parallelScavenge.*;
    8.16  import sun.jvm.hotspot.gc_implementation.shared.*;
    8.17  import sun.jvm.hotspot.memory.*;
    8.18  import sun.jvm.hotspot.runtime.*;
    8.19 -import sun.jvm.hotspot.tools.*;
    8.20  
    8.21  public class HeapSummary extends Tool {
    8.22  
    8.23 @@ -70,32 +70,50 @@
    8.24        System.out.println();
    8.25        System.out.println("Heap Usage:");
    8.26  
    8.27 -      if (heap instanceof GenCollectedHeap) {
    8.28 -         GenCollectedHeap genHeap = (GenCollectedHeap) heap;
    8.29 -         for (int n = 0; n < genHeap.nGens(); n++) {
    8.30 -            Generation gen = genHeap.getGen(n);
    8.31 -            if (gen instanceof sun.jvm.hotspot.memory.DefNewGeneration) {
    8.32 -               System.out.println("New Generation (Eden + 1 Survivor Space):");
    8.33 -               printGen(gen);
    8.34 +      if (heap instanceof SharedHeap) {
    8.35 +         SharedHeap sharedHeap = (SharedHeap) heap;
    8.36 +         if (sharedHeap instanceof GenCollectedHeap) {
    8.37 +            GenCollectedHeap genHeap = (GenCollectedHeap) sharedHeap;
    8.38 +            for (int n = 0; n < genHeap.nGens(); n++) {
    8.39 +               Generation gen = genHeap.getGen(n);
    8.40 +               if (gen instanceof sun.jvm.hotspot.memory.DefNewGeneration) {
    8.41 +                  System.out.println("New Generation (Eden + 1 Survivor Space):");
    8.42 +                  printGen(gen);
    8.43  
    8.44 -               ContiguousSpace eden = ((DefNewGeneration)gen).eden();
    8.45 -               System.out.println("Eden Space:");
    8.46 -               printSpace(eden);
    8.47 +                  ContiguousSpace eden = ((DefNewGeneration)gen).eden();
    8.48 +                  System.out.println("Eden Space:");
    8.49 +                  printSpace(eden);
    8.50  
    8.51 -               ContiguousSpace from = ((DefNewGeneration)gen).from();
    8.52 -               System.out.println("From Space:");
    8.53 -               printSpace(from);
    8.54 +                  ContiguousSpace from = ((DefNewGeneration)gen).from();
    8.55 +                  System.out.println("From Space:");
    8.56 +                  printSpace(from);
    8.57  
    8.58 -               ContiguousSpace to = ((DefNewGeneration)gen).to();
    8.59 -               System.out.println("To Space:");
    8.60 -               printSpace(to);
    8.61 -            } else {
    8.62 -               System.out.println(gen.name() + ":");
    8.63 -               printGen(gen);
    8.64 +                  ContiguousSpace to = ((DefNewGeneration)gen).to();
    8.65 +                  System.out.println("To Space:");
    8.66 +                  printSpace(to);
    8.67 +               } else {
    8.68 +                  System.out.println(gen.name() + ":");
    8.69 +                  printGen(gen);
    8.70 +               }
    8.71              }
    8.72 +         } else if (sharedHeap instanceof G1CollectedHeap) {
    8.73 +             G1CollectedHeap g1h = (G1CollectedHeap) sharedHeap;
    8.74 +
    8.75 +             System.out.println("Garbage-First (G1) Heap");
    8.76 +             long capacityBytes = g1h.capacity();
    8.77 +             long usedBytes = g1h.used();
    8.78 +             long freeBytes = capacityBytes - usedBytes;
    8.79 +             printValMB("region size = ", HeapRegion.grainBytes());
    8.80 +             printValue("regions     = ", g1h.n_regions());
    8.81 +             printValMB("capacity    = ", capacityBytes);
    8.82 +             printValMB("used        = ", usedBytes);
    8.83 +             printValMB("free        = ", freeBytes);
    8.84 +             System.out.println(alignment + (double) usedBytes * 100.0 / capacityBytes + "% used");
    8.85 +         } else {
    8.86 +             throw new RuntimeException("unknown SharedHeap type : " + heap.getClass());
    8.87           }
    8.88 -         // Perm generation
    8.89 -         Generation permGen = genHeap.permGen();
    8.90 +         // Perm generation shared by the above
    8.91 +         Generation permGen = sharedHeap.permGen();
    8.92           System.out.println("Perm Generation:");
    8.93           printGen(permGen);
    8.94        } else if (heap instanceof ParallelScavengeHeap) {
    8.95 @@ -119,7 +137,7 @@
    8.96           printValMB("free     = ", permFree);
    8.97           System.out.println(alignment + (double)permGen.used() * 100.0 / permGen.capacity() + "% used");
    8.98        } else {
    8.99 -         throw new RuntimeException("unknown heap type : " + heap.getClass());
   8.100 +         throw new RuntimeException("unknown CollectedHeap type : " + heap.getClass());
   8.101        }
   8.102     }
   8.103  
   8.104 @@ -151,6 +169,14 @@
   8.105            return;
   8.106         }
   8.107  
   8.108 +       l = getFlagValue("UseG1GC", flagMap);
   8.109 +       if (l == 1L) {
   8.110 +           System.out.print("Garbage-First (G1) GC ");
   8.111 +           l = getFlagValue("ParallelGCThreads", flagMap);
   8.112 +           System.out.println("with " + l + " thread(s)");
   8.113 +           return;
   8.114 +       }
   8.115 +
   8.116         System.out.println("Mark Sweep Compact GC");
   8.117     }
   8.118  
     9.1 --- a/make/sa.files	Fri Sep 16 21:35:06 2011 -0700
     9.2 +++ b/make/sa.files	Tue Sep 20 09:59:59 2011 -0400
     9.3 @@ -1,5 +1,5 @@
     9.4  #
     9.5 -# Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
     9.6 +# Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
     9.7  # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     9.8  #
     9.9  # This code is free software; you can redistribute it and/or modify it
    9.10 @@ -79,6 +79,7 @@
    9.11  $(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/windbg/ia64/*.java \
    9.12  $(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/windbg/x86/*.java \
    9.13  $(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/x86/*.java \
    9.14 +$(AGENT_SRC_DIR)/sun/jvm/hotspot/gc_implementation/g1/*.java \
    9.15  $(AGENT_SRC_DIR)/sun/jvm/hotspot/gc_implementation/parallelScavenge/*.java \
    9.16  $(AGENT_SRC_DIR)/sun/jvm/hotspot/gc_implementation/shared/*.java \
    9.17  $(AGENT_SRC_DIR)/sun/jvm/hotspot/gc_interface/*.java \
    10.1 --- a/src/share/vm/gc_implementation/g1/heapRegionSeq.hpp	Fri Sep 16 21:35:06 2011 -0700
    10.2 +++ b/src/share/vm/gc_implementation/g1/heapRegionSeq.hpp	Tue Sep 20 09:59:59 2011 -0400
    10.3 @@ -56,6 +56,7 @@
    10.4  // and maintain that: _length <= _allocated_length <= _max_length
    10.5  
    10.6  class HeapRegionSeq: public CHeapObj {
    10.7 +  friend class VMStructs;
    10.8  
    10.9    // The array that holds the HeapRegions.
   10.10    HeapRegion** _regions;
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/src/share/vm/gc_implementation/g1/vmStructs_g1.hpp	Tue Sep 20 09:59:59 2011 -0400
    11.3 @@ -0,0 +1,54 @@
    11.4 +/*
    11.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
    11.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    11.7 + *
    11.8 + * This code is free software; you can redistribute it and/or modify it
    11.9 + * under the terms of the GNU General Public License version 2 only, as
   11.10 + * published by the Free Software Foundation.
   11.11 + *
   11.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   11.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   11.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   11.15 + * version 2 for more details (a copy is included in the LICENSE file that
   11.16 + * accompanied this code).
   11.17 + *
   11.18 + * You should have received a copy of the GNU General Public License version
   11.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   11.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   11.21 + *
   11.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   11.23 + * or visit www.oracle.com if you need additional information or have any
   11.24 + * questions.
   11.25 + *
   11.26 + */
   11.27 +
   11.28 +#ifndef SHARE_VM_GC_IMPLEMENTATION_G1_VMSTRUCTS_G1_HPP
   11.29 +#define SHARE_VM_GC_IMPLEMENTATION_G1_VMSTRUCTS_G1_HPP
   11.30 +
   11.31 +#include "gc_implementation/g1/heapRegion.hpp"
   11.32 +#include "gc_implementation/g1/heapRegionSeq.inline.hpp"
   11.33 +#include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
   11.34 +
   11.35 +#define VM_STRUCTS_G1(nonstatic_field, static_field)                          \
   11.36 +                                                                              \
   11.37 +  static_field(HeapRegion, GrainBytes, int)                                   \
   11.38 +                                                                              \
   11.39 +  nonstatic_field(HeapRegionSeq,   _regions, HeapRegion**)                    \
   11.40 +  nonstatic_field(HeapRegionSeq,   _length,  size_t)                          \
   11.41 +                                                                              \
   11.42 +  nonstatic_field(G1CollectedHeap, _hrs,                HeapRegionSeq)        \
   11.43 +  nonstatic_field(G1CollectedHeap, _g1_committed,       MemRegion)            \
   11.44 +  nonstatic_field(G1CollectedHeap, _summary_bytes_used, size_t)               \
   11.45 +
   11.46 +
   11.47 +#define VM_TYPES_G1(declare_type, declare_toplevel_type)                      \
   11.48 +                                                                              \
   11.49 +  declare_type(G1CollectedHeap, SharedHeap)                                   \
   11.50 +                                                                              \
   11.51 +  declare_type(HeapRegion, ContiguousSpace)                                   \
   11.52 +  declare_toplevel_type(HeapRegionSeq)                                        \
   11.53 +                                                                              \
   11.54 +  declare_toplevel_type(G1CollectedHeap*)                                     \
   11.55 +  declare_toplevel_type(HeapRegion*)                                          \
   11.56 +
   11.57 +#endif // SHARE_VM_GC_IMPLEMENTATION_G1_VMSTRUCTS_G1_HPP
    12.1 --- a/src/share/vm/runtime/vmStructs.cpp	Fri Sep 16 21:35:06 2011 -0700
    12.2 +++ b/src/share/vm/runtime/vmStructs.cpp	Tue Sep 20 09:59:59 2011 -0400
    12.3 @@ -173,6 +173,7 @@
    12.4  #include "gc_implementation/parallelScavenge/psVirtualspace.hpp"
    12.5  #include "gc_implementation/parallelScavenge/psYoungGen.hpp"
    12.6  #include "gc_implementation/parallelScavenge/vmStructs_parallelgc.hpp"
    12.7 +#include "gc_implementation/g1/vmStructs_g1.hpp"
    12.8  #endif
    12.9  #ifdef COMPILER2
   12.10  #include "opto/addnode.hpp"
   12.11 @@ -2855,6 +2856,9 @@
   12.12    VM_STRUCTS_CMS(GENERATE_NONSTATIC_VM_STRUCT_ENTRY, \
   12.13                   GENERATE_NONSTATIC_VM_STRUCT_ENTRY, \
   12.14                   GENERATE_STATIC_VM_STRUCT_ENTRY)
   12.15 +
   12.16 +  VM_STRUCTS_G1(GENERATE_NONSTATIC_VM_STRUCT_ENTRY, \
   12.17 +                GENERATE_STATIC_VM_STRUCT_ENTRY)
   12.18  #endif // SERIALGC
   12.19  
   12.20    VM_STRUCTS_CPU(GENERATE_NONSTATIC_VM_STRUCT_ENTRY, \
   12.21 @@ -2898,6 +2902,9 @@
   12.22                 GENERATE_TOPLEVEL_VM_TYPE_ENTRY)
   12.23  
   12.24    VM_TYPES_PARNEW(GENERATE_VM_TYPE_ENTRY)
   12.25 +
   12.26 +  VM_TYPES_G1(GENERATE_VM_TYPE_ENTRY,
   12.27 +              GENERATE_TOPLEVEL_VM_TYPE_ENTRY)
   12.28  #endif // SERIALGC
   12.29  
   12.30    VM_TYPES_CPU(GENERATE_VM_TYPE_ENTRY,
   12.31 @@ -2997,6 +3004,9 @@
   12.32    VM_STRUCTS_CMS(CHECK_NONSTATIC_VM_STRUCT_ENTRY,
   12.33               CHECK_VOLATILE_NONSTATIC_VM_STRUCT_ENTRY,
   12.34               CHECK_STATIC_VM_STRUCT_ENTRY);
   12.35 +
   12.36 +  VM_STRUCTS_G1(CHECK_NONSTATIC_VM_STRUCT_ENTRY,
   12.37 +                CHECK_STATIC_VM_STRUCT_ENTRY);
   12.38  #endif // SERIALGC
   12.39  
   12.40    VM_STRUCTS_CPU(CHECK_NONSTATIC_VM_STRUCT_ENTRY,
   12.41 @@ -3037,6 +3047,9 @@
   12.42                 CHECK_SINGLE_ARG_VM_TYPE_NO_OP);
   12.43  
   12.44    VM_TYPES_PARNEW(CHECK_VM_TYPE_ENTRY)
   12.45 +
   12.46 +  VM_TYPES_G1(CHECK_VM_TYPE_ENTRY,
   12.47 +              CHECK_SINGLE_ARG_VM_TYPE_NO_OP);
   12.48  #endif // SERIALGC
   12.49  
   12.50    VM_TYPES_CPU(CHECK_VM_TYPE_ENTRY,
   12.51 @@ -3102,6 +3115,8 @@
   12.52    debug_only(VM_STRUCTS_CMS(ENSURE_FIELD_TYPE_PRESENT, \
   12.53                              ENSURE_FIELD_TYPE_PRESENT, \
   12.54                              ENSURE_FIELD_TYPE_PRESENT));
   12.55 +  debug_only(VM_STRUCTS_G1(ENSURE_FIELD_TYPE_PRESENT, \
   12.56 +                           ENSURE_FIELD_TYPE_PRESENT));
   12.57  #endif // SERIALGC
   12.58    debug_only(VM_STRUCTS_CPU(ENSURE_FIELD_TYPE_PRESENT, \
   12.59                              ENSURE_FIELD_TYPE_PRESENT, \

mercurial