1 /* 2 * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 package sun.jvm.hotspot.gc_implementation.g1; 26 27 import java.util.Observable; 28 import java.util.Observer; 29 30 import sun.jvm.hotspot.debugger.Address; 31 import sun.jvm.hotspot.runtime.VM; 32 import sun.jvm.hotspot.runtime.VMObject; 33 import sun.jvm.hotspot.types.CIntegerField; 34 import sun.jvm.hotspot.types.Type; 35 import sun.jvm.hotspot.types.TypeDataBase; 36 37 // Mirror class for G1MonitoringSupport. 38 39 public class G1MonitoringSupport extends VMObject { 40 // size_t _eden_committed; 41 static private CIntegerField edenCommittedField; 42 // size_t _eden_used; 43 static private CIntegerField edenUsedField; 44 // size_t _survivor_committed; 45 static private CIntegerField survivorCommittedField; 46 // size_t _survivor_used; 47 static private CIntegerField survivorUsedField; 48 // size_t _old_committed; 49 static private CIntegerField oldCommittedField; 50 // size_t _old_used; 51 static private CIntegerField oldUsedField; 52 53 static { 54 VM.registerVMInitializedObserver(new Observer() { 55 public void update(Observable o, Object data) { 56 initialize(VM.getVM().getTypeDataBase()); 57 } 58 }); 59 } 60 61 static private synchronized void initialize(TypeDataBase db) { 62 Type type = db.lookupType("G1MonitoringSupport"); 63 64 edenCommittedField = type.getCIntegerField("_eden_committed"); 65 edenUsedField = type.getCIntegerField("_eden_used"); 66 survivorCommittedField = type.getCIntegerField("_survivor_committed"); 67 survivorUsedField = type.getCIntegerField("_survivor_used"); 68 oldCommittedField = type.getCIntegerField("_old_committed"); 69 oldUsedField = type.getCIntegerField("_old_used"); 70 } 71 72 public long edenCommitted() { 73 return edenCommittedField.getValue(addr); 74 } 75 76 public long edenUsed() { 77 return edenUsedField.getValue(addr); 78 } 79 80 public long edenRegionNum() { 81 return edenUsed() / HeapRegion.grainBytes(); 82 } 83 84 public long survivorCommitted() { 85 return survivorCommittedField.getValue(addr); 86 } 87 88 public long survivorUsed() { 89 return survivorUsedField.getValue(addr); 90 } 91 92 public long survivorRegionNum() { 93 return survivorUsed() / HeapRegion.grainBytes(); 94 } 95 96 public long oldCommitted() { 97 return oldCommittedField.getValue(addr); 98 } 99 100 public long oldUsed() { 101 return oldUsedField.getValue(addr); 102 } 103 104 public G1MonitoringSupport(Address addr) { 105 super(addr); 106 } 107 }