Path: blob/master/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ci/ciEnv.java
41161 views
/*1* Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324package sun.jvm.hotspot.ci;2526import java.io.PrintStream;27import java.util.*;28import sun.jvm.hotspot.debugger.*;29import sun.jvm.hotspot.runtime.*;30import sun.jvm.hotspot.oops.*;31import sun.jvm.hotspot.opto.*;32import sun.jvm.hotspot.compiler.CompileTask;33import sun.jvm.hotspot.prims.JvmtiExport;34import sun.jvm.hotspot.types.*;35import sun.jvm.hotspot.utilities.GrowableArray;36import sun.jvm.hotspot.utilities.Observable;37import sun.jvm.hotspot.utilities.Observer;3839public class ciEnv extends VMObject {40static {41VM.registerVMInitializedObserver(new Observer() {42public void update(Observable o, Object data) {43initialize(VM.getVM().getTypeDataBase());44}45});46}4748private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {49Type type = db.lookupType("ciEnv");50dependenciesField = type.getAddressField("_dependencies");51factoryField = type.getAddressField("_factory");52compilerDataField = type.getAddressField("_compiler_data");53taskField = type.getAddressField("_task");54}5556private static AddressField dependenciesField;57private static AddressField factoryField;58private static AddressField compilerDataField;59private static AddressField taskField;6061public ciEnv(Address addr) {62super(addr);63}6465public Compile compilerData() {66Address addr = compilerDataField.getValue(this.getAddress());67if (addr == null) {68return null;69}70return new Compile(addr);71}7273public ciObjectFactory factory() {74return new ciObjectFactory(factoryField.getValue(this.getAddress()));75}7677public CompileTask task() {78return new CompileTask(taskField.getValue(this.getAddress()));79}8081public void dumpReplayData(PrintStream out) {82out.println("JvmtiExport can_access_local_variables " +83(JvmtiExport.canAccessLocalVariables() ? '1' : '0'));84out.println("JvmtiExport can_hotswap_or_post_breakpoint " +85(JvmtiExport.canHotswapOrPostBreakpoint() ? '1' : '0'));86out.println("JvmtiExport can_post_on_exceptions " +87(JvmtiExport.canPostOnExceptions() ? '1' : '0'));8889GrowableArray<ciMetadata> objects = factory().objects();90out.println("# " + objects.length() + " ciObject found");91for (int i = 0; i < objects.length(); i++) {92ciMetadata o = objects.at(i);93out.println("# ciMetadata" + i + " @ " + o);94o.dumpReplayData(out);95}96CompileTask task = task();97Method method = task.method();98int entryBci = task.osrBci();99int compLevel = task.compLevel();100out.print("compile " + method.nameAsAscii() + " " +101entryBci + " " + compLevel);102Compile compiler = compilerData();103if (compiler != null) {104// Dump inlining data.105compiler.dumpInlineData(out);106}107out.println();108}109}110111112