Path: blob/master/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/InterpretedVFrame.java
41161 views
/*1* Copyright (c) 2000, 2017, 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.runtime;2526import java.util.*;27import sun.jvm.hotspot.debugger.*;28import sun.jvm.hotspot.interpreter.*;29import sun.jvm.hotspot.oops.*;30import sun.jvm.hotspot.utilities.*;3132public class InterpretedVFrame extends JavaVFrame {33/** JVM state */34public Method getMethod() {35return getFrame().getInterpreterFrameMethod();36}3738public StackValueCollection getLocals() {39Method m = getMethod();4041int length = (int) m.getMaxLocals();4243if (m.isNative()) {44// If the method is native, getMaxLocals is not telling the truth.45// maxlocals then equals the size of parameters46length = (int) m.getSizeOfParameters();47}4849StackValueCollection result = new StackValueCollection(length);5051// Get oopmap describing oops and int for current bci52OopMapCacheEntry oopMask = getMethod().getMaskFor(getBCI());5354// handle locals55for(int i = 0; i < length; i++) {56// Find stack location57Address addr = addressOfLocalAt(i);5859// Depending on oop/int put it in the right package60StackValue sv;61if (oopMask.isOop(i)) {62// oop value63sv = new StackValue(addr.getOopHandleAt(0), 0);64} else {65// integer66// Fetch a signed integer the size of a stack slot67sv = new StackValue(addr.getCIntegerAt(0, VM.getVM().getAddressSize(), false));68}69result.add(sv);70}7172return result;73}7475public StackValueCollection getExpressions() {76int length = getFrame().getInterpreterFrameExpressionStackSize();7778if (getMethod().isNative()) {79// If the method is native, there is no expression stack80length = 0;81}8283int nofLocals = (int) getMethod().getMaxLocals();84StackValueCollection result = new StackValueCollection(length);8586// Get oopmap describing oops and int for current bci87OopMapCacheEntry oopMask = getMethod().getMaskFor(getBCI());8889for(int i = 0; i < length; i++) {90// Find stack location91Address addr = addressOfExpressionStackAt(i);9293// Depending on oop/int put it in the right package94StackValue sv;95if (oopMask.isOop(i + nofLocals)) {96// oop value97sv = new StackValue(addr.getOopHandleAt(0), 0);98} else {99// integer100// Fetch a signed integer the size of a stack slot101sv = new StackValue(addr.getCIntegerAt(0, VM.getVM().getAddressSize(), false));102}103result.add(sv);104}105106return result;107}108109/** Returns List<MonitorInfo> */110public List<MonitorInfo> getMonitors() {111List<MonitorInfo> result = new ArrayList<>(5);112for (BasicObjectLock current = getFrame().interpreterFrameMonitorEnd();113current.address().lessThan(getFrame().interpreterFrameMonitorBegin().address());114current = getFrame().nextMonitorInInterpreterFrame(current)) {115result.add(new MonitorInfo(current.obj(), current.lock(), false, false));116}117return result;118}119120/** Test operation */121public boolean isInterpretedFrame() { return true; }122123/** Package-internal constructor */124InterpretedVFrame(Frame fr, RegisterMap regMap, JavaThread thread) {125super(fr, regMap, thread);126}127128/** Accessor for Byte Code Index (NOTE: access to BCP is not allowed129in this system; see Frame.java) */130public int getBCI() {131return getFrame().getInterpreterFrameBCI();132}133134/** Setter for Byte Code Index */135// FIXME: not yet implementable136// public void setBCI(int bci) {137// getFrame().setInterpreterFrameBCI(bci);138// }139140public void verify() {141}142143//--------------------------------------------------------------------------------144// Internals only below this point145//146147private Address addressOfLocalAt(int index) {148if (Assert.ASSERTS_ENABLED) {149Assert.that(getFrame().isInterpretedFrame(), "frame should be an interpreted frame");150}151return fr.addressOfInterpreterFrameLocal(index);152}153154private Address addressOfExpressionStackAt(int index) {155return fr.addressOfInterpreterFrameExpressionStackSlot(index);156}157}158159160