agent/src/share/classes/sun/jvm/hotspot/gc_implementation/g1/G1CollectedHeap.java

Tue, 26 Aug 2014 09:36:53 +0200

author
tschatzl
date
Tue, 26 Aug 2014 09:36:53 +0200
changeset 7091
a8ea2f110d87
parent 7050
6701abbc4441
child 7118
227a9e5e4b4a
permissions
-rw-r--r--

8054819: Rename HeapRegionSeq to HeapRegionManager
Reviewed-by: jwilhelm, jmasa

tonyp@3168 1 /*
tonyp@3457 2 * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
tonyp@3168 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
tonyp@3168 4 *
tonyp@3168 5 * This code is free software; you can redistribute it and/or modify it
tonyp@3168 6 * under the terms of the GNU General Public License version 2 only, as
tonyp@3168 7 * published by the Free Software Foundation.
tonyp@3168 8 *
tonyp@3168 9 * This code is distributed in the hope that it will be useful, but WITHOUT
tonyp@3168 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
tonyp@3168 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
tonyp@3168 12 * version 2 for more details (a copy is included in the LICENSE file that
tonyp@3168 13 * accompanied this code).
tonyp@3168 14 *
tonyp@3168 15 * You should have received a copy of the GNU General Public License version
tonyp@3168 16 * 2 along with this work; if not, write to the Free Software Foundation,
tonyp@3168 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
tonyp@3168 18 *
tonyp@3168 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
tonyp@3168 20 * or visit www.oracle.com if you need additional information or have any
tonyp@3168 21 * questions.
tonyp@3168 22 *
tonyp@3168 23 */
tonyp@3168 24
tonyp@3168 25 package sun.jvm.hotspot.gc_implementation.g1;
tonyp@3168 26
tonyp@3168 27 import java.util.Iterator;
tonyp@3168 28 import java.util.Observable;
tonyp@3168 29 import java.util.Observer;
tonyp@3168 30
tonyp@3168 31 import sun.jvm.hotspot.debugger.Address;
tonyp@3168 32 import sun.jvm.hotspot.gc_interface.CollectedHeapName;
tonyp@3168 33 import sun.jvm.hotspot.memory.MemRegion;
tonyp@3168 34 import sun.jvm.hotspot.memory.SharedHeap;
tonyp@3168 35 import sun.jvm.hotspot.memory.SpaceClosure;
tonyp@3168 36 import sun.jvm.hotspot.runtime.VM;
tonyp@3168 37 import sun.jvm.hotspot.runtime.VMObjectFactory;
tonyp@3180 38 import sun.jvm.hotspot.types.AddressField;
tonyp@3168 39 import sun.jvm.hotspot.types.CIntegerField;
tonyp@3168 40 import sun.jvm.hotspot.types.Type;
tonyp@3168 41 import sun.jvm.hotspot.types.TypeDataBase;
tonyp@3168 42
tonyp@3168 43 // Mirror class for G1CollectedHeap.
tonyp@3168 44
tonyp@3168 45 public class G1CollectedHeap extends SharedHeap {
tschatzl@7091 46 // HeapRegionManager _hrm;
tschatzl@7091 47 static private long hrmFieldOffset;
tschatzl@7050 48 // MemRegion _g1_reserved;
tschatzl@7050 49 static private long g1ReservedFieldOffset;
tonyp@3168 50 // size_t _summary_bytes_used;
tonyp@3168 51 static private CIntegerField summaryBytesUsedField;
tonyp@3457 52 // G1MonitoringSupport* _g1mm;
tonyp@3180 53 static private AddressField g1mmField;
brutisso@6385 54 // HeapRegionSet _old_set;
tonyp@3457 55 static private long oldSetFieldOffset;
brutisso@6385 56 // HeapRegionSet _humongous_set;
tonyp@3457 57 static private long humongousSetFieldOffset;
tonyp@3168 58
tonyp@3168 59 static {
tonyp@3168 60 VM.registerVMInitializedObserver(new Observer() {
tonyp@3168 61 public void update(Observable o, Object data) {
tonyp@3168 62 initialize(VM.getVM().getTypeDataBase());
tonyp@3168 63 }
tonyp@3168 64 });
tonyp@3168 65 }
tonyp@3168 66
tonyp@3168 67 static private synchronized void initialize(TypeDataBase db) {
tonyp@3168 68 Type type = db.lookupType("G1CollectedHeap");
tonyp@3168 69
tschatzl@7091 70 hrmFieldOffset = type.getField("_hrm").getOffset();
tonyp@3168 71 summaryBytesUsedField = type.getCIntegerField("_summary_bytes_used");
tonyp@3180 72 g1mmField = type.getAddressField("_g1mm");
tonyp@3457 73 oldSetFieldOffset = type.getField("_old_set").getOffset();
tonyp@3457 74 humongousSetFieldOffset = type.getField("_humongous_set").getOffset();
tonyp@3168 75 }
tonyp@3168 76
tonyp@3168 77 public long capacity() {
tschatzl@7091 78 return hrm().capacity();
tonyp@3168 79 }
tonyp@3168 80
tonyp@3168 81 public long used() {
tonyp@3168 82 return summaryBytesUsedField.getValue(addr);
tonyp@3168 83 }
tonyp@3168 84
tonyp@3168 85 public long n_regions() {
tschatzl@7091 86 return hrm().length();
tonyp@3168 87 }
tonyp@3168 88
tschatzl@7091 89 private HeapRegionManager hrm() {
tschatzl@7091 90 Address hrmAddr = addr.addOffsetTo(hrmFieldOffset);
tschatzl@7091 91 return (HeapRegionManager) VMObjectFactory.newObject(HeapRegionManager.class,
tschatzl@7091 92 hrmAddr);
tonyp@3168 93 }
tonyp@3168 94
tonyp@3180 95 public G1MonitoringSupport g1mm() {
tonyp@3180 96 Address g1mmAddr = g1mmField.getValue(addr);
tonyp@3180 97 return (G1MonitoringSupport) VMObjectFactory.newObject(G1MonitoringSupport.class, g1mmAddr);
tonyp@3180 98 }
tonyp@3180 99
tonyp@3457 100 public HeapRegionSetBase oldSet() {
tonyp@3457 101 Address oldSetAddr = addr.addOffsetTo(oldSetFieldOffset);
tonyp@3457 102 return (HeapRegionSetBase) VMObjectFactory.newObject(HeapRegionSetBase.class,
tonyp@3457 103 oldSetAddr);
tonyp@3457 104 }
tonyp@3457 105
tonyp@3457 106 public HeapRegionSetBase humongousSet() {
tonyp@3457 107 Address humongousSetAddr = addr.addOffsetTo(humongousSetFieldOffset);
tonyp@3457 108 return (HeapRegionSetBase) VMObjectFactory.newObject(HeapRegionSetBase.class,
tonyp@3457 109 humongousSetAddr);
tonyp@3457 110 }
tonyp@3457 111
tonyp@3168 112 private Iterator<HeapRegion> heapRegionIterator() {
tschatzl@7091 113 return hrm().heapRegionIterator();
tonyp@3168 114 }
tonyp@3168 115
tonyp@3168 116 public void heapRegionIterate(SpaceClosure scl) {
tonyp@3168 117 Iterator<HeapRegion> iter = heapRegionIterator();
tonyp@3168 118 while (iter.hasNext()) {
tonyp@3168 119 HeapRegion hr = iter.next();
tonyp@3168 120 scl.doSpace(hr);
tonyp@3168 121 }
tonyp@3168 122 }
tonyp@3168 123
tonyp@3168 124 public CollectedHeapName kind() {
tonyp@3168 125 return CollectedHeapName.G1_COLLECTED_HEAP;
tonyp@3168 126 }
tonyp@3168 127
tonyp@3168 128 public G1CollectedHeap(Address addr) {
tonyp@3168 129 super(addr);
tonyp@3168 130 }
tonyp@3168 131 }

mercurial