Path: blob/master/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/interpreter/InterpreterCodelet.java
41161 views
/*1* Copyright (c) 2000, 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.interpreter;2526import java.io.*;27import java.util.*;2829import sun.jvm.hotspot.code.*;30import sun.jvm.hotspot.debugger.*;31import sun.jvm.hotspot.runtime.*;32import sun.jvm.hotspot.types.*;33import sun.jvm.hotspot.utilities.*;34import sun.jvm.hotspot.utilities.Observable;35import sun.jvm.hotspot.utilities.Observer;3637/** An InterpreterCodelet is a piece of interpreter code. All38interpreter code is generated into little codelets which contain39extra information for debugging and printing purposes. */4041public class InterpreterCodelet extends Stub {42private static long instanceSize;43private static CIntegerField sizeField; // the size in bytes44private static AddressField descriptionField; // a description of the codelet, for debugging & printing45private static CIntegerField bytecodeField; // associated bytecode if any4647static {48VM.registerVMInitializedObserver(new Observer() {49public void update(Observable o, Object data) {50initialize(VM.getVM().getTypeDataBase());51}52});53}5455private static synchronized void initialize(TypeDataBase db) {56Type type = db.lookupType("InterpreterCodelet");5758sizeField = type.getCIntegerField("_size");59descriptionField = type.getAddressField("_description");60bytecodeField = type.getCIntegerField("_bytecode");6162instanceSize = type.getSize();63}6465public InterpreterCodelet(Address addr) {66super(addr);67}6869public long getSize() {70return sizeField.getValue(addr);71}7273public Address codeBegin() {74return addr.addOffsetTo(instanceSize);75}7677public Address codeEnd() {78return addr.addOffsetTo(getSize());79}8081public long codeSize() {82return codeEnd().minus(codeBegin());83}8485public String getDescription() {86return CStringUtilities.getString(descriptionField.getValue(addr));87}8889public void verify() {90}9192public void printOn(PrintStream tty) {93String desc = getDescription();94if (desc != null) {95tty.print(desc);96}97// FIXME: add printing of bytecode98tty.println(" [" + codeBegin() + ", " + codeEnd() + ") " +99codeSize() + " bytes ");100// FIXME: add disassembly101}102}103104105