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 25package sun.jvm.hotspot.opto; 26 27import java.util.*; 28import java.io.PrintStream; 29import sun.jvm.hotspot.ci.*; 30import sun.jvm.hotspot.debugger.*; 31import sun.jvm.hotspot.runtime.*; 32import sun.jvm.hotspot.oops.*; 33import sun.jvm.hotspot.types.*; 34 35public class Compile extends VMObject { 36 static { 37 VM.registerVMInitializedObserver(new Observer() { 38 public void update(Observable o, Object data) { 39 initialize(VM.getVM().getTypeDataBase()); 40 } 41 }); 42 } 43 44 private static synchronized void initialize(TypeDataBase db) throws WrongTypeException { 45 Type type = db.lookupType("Compile"); 46 rootField = type.getAddressField("_root"); 47 uniqueField = new CIntField(type.getCIntegerField("_unique"), 0); 48 entryBciField = new CIntField(type.getCIntegerField("_entry_bci"), 0); 49 topField = type.getAddressField("_top"); 50 cfgField = type.getAddressField("_cfg"); 51 regallocField = type.getAddressField("_regalloc"); 52 methodField = type.getAddressField("_method"); 53 iltField = type.getAddressField("_ilt"); 54 } 55 56 private static AddressField rootField; 57 private static CIntField uniqueField; 58 private static CIntField entryBciField; 59 private static AddressField topField; 60 private static AddressField cfgField; 61 private static AddressField regallocField; 62 private static AddressField methodField; 63 private static AddressField iltField; 64 65 public Compile(Address addr) { 66 super(addr); 67 } 68 69 public Node root() { 70 return new RootNode(rootField.getValue(this.getAddress())); 71 } 72 73 public int entryBci() { 74 return (int)entryBciField.getValue(getAddress()); 75 } 76 77 public ciMethod method() { 78 return (ciMethod) ciObjectFactory.getMetadata(methodField.getValue(getAddress())); 79 } 80 81 public PhaseCFG cfg() { 82 Address a = cfgField.getValue(this.getAddress()); 83 if (a != null) { 84 return new PhaseCFG(a); 85 } 86 return null; 87 } 88 89 public InlineTree ilt() { 90 Address a = iltField.getValue(this.getAddress()); 91 if (a != null) { 92 return new InlineTree(a); 93 } 94 return null; 95 } 96 97 public void dumpInlineData(PrintStream out) { 98 InlineTree inlTree = ilt(); 99 if (inlTree != null) { 100 out.print(" inline " + inlTree.count()); 101 inlTree.dumpReplayData(out); 102 } 103 } 104 105} 106