annotate agent/src/share/classes/sun/jvm/hotspot/runtime/InterpretedVFrame.java @ 844:bd02caa94611

6862919: Update copyright year Summary: Update copyright for files that have been modified in 2009, up to 07/09 Reviewed-by: tbell, ohair
author xdono
date Tue, 28 Jul 2009 12:12:40 -0700
parents b109e761e927
children c18cbe5936b8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
844
bd02caa94611 6862919: Update copyright year
xdono
parents: 818
diff changeset
2 * Copyright 2000-2009 Sun Microsystems, Inc. All Rights Reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 package sun.jvm.hotspot.runtime;
a61af66fc99e Initial load
duke
parents:
diff changeset
26
a61af66fc99e Initial load
duke
parents:
diff changeset
27 import java.util.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
28 import sun.jvm.hotspot.debugger.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
29 import sun.jvm.hotspot.interpreter.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
30 import sun.jvm.hotspot.oops.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
31 import sun.jvm.hotspot.utilities.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
32
a61af66fc99e Initial load
duke
parents:
diff changeset
33 public class InterpretedVFrame extends JavaVFrame {
a61af66fc99e Initial load
duke
parents:
diff changeset
34 /** JVM state */
a61af66fc99e Initial load
duke
parents:
diff changeset
35 public Method getMethod() {
a61af66fc99e Initial load
duke
parents:
diff changeset
36 return getFrame().getInterpreterFrameMethod();
a61af66fc99e Initial load
duke
parents:
diff changeset
37 }
a61af66fc99e Initial load
duke
parents:
diff changeset
38
a61af66fc99e Initial load
duke
parents:
diff changeset
39 public StackValueCollection getLocals() {
a61af66fc99e Initial load
duke
parents:
diff changeset
40 Method m = getMethod();
a61af66fc99e Initial load
duke
parents:
diff changeset
41
a61af66fc99e Initial load
duke
parents:
diff changeset
42 int length = (int) m.getMaxLocals();
a61af66fc99e Initial load
duke
parents:
diff changeset
43
a61af66fc99e Initial load
duke
parents:
diff changeset
44 if (m.isNative()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
45 // If the method is native, getMaxLocals is not telling the truth.
a61af66fc99e Initial load
duke
parents:
diff changeset
46 // maxlocals then equals the size of parameters
a61af66fc99e Initial load
duke
parents:
diff changeset
47 length = (int) m.getSizeOfParameters();
a61af66fc99e Initial load
duke
parents:
diff changeset
48 }
a61af66fc99e Initial load
duke
parents:
diff changeset
49
a61af66fc99e Initial load
duke
parents:
diff changeset
50 StackValueCollection result = new StackValueCollection(length);
a61af66fc99e Initial load
duke
parents:
diff changeset
51
a61af66fc99e Initial load
duke
parents:
diff changeset
52 // Get oopmap describing oops and int for current bci
a61af66fc99e Initial load
duke
parents:
diff changeset
53 OopMapCacheEntry oopMask = getMethod().getMaskFor(getBCI());
a61af66fc99e Initial load
duke
parents:
diff changeset
54
a61af66fc99e Initial load
duke
parents:
diff changeset
55 // handle locals
a61af66fc99e Initial load
duke
parents:
diff changeset
56 for(int i = 0; i < length; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
57 // Find stack location
a61af66fc99e Initial load
duke
parents:
diff changeset
58 Address addr = addressOfLocalAt(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
59
a61af66fc99e Initial load
duke
parents:
diff changeset
60 // Depending on oop/int put it in the right package
a61af66fc99e Initial load
duke
parents:
diff changeset
61 StackValue sv;
a61af66fc99e Initial load
duke
parents:
diff changeset
62 if (oopMask.isOop(i)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
63 // oop value
818
b109e761e927 6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents: 0
diff changeset
64 sv = new StackValue(addr.getOopHandleAt(0), 0);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
65 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
66 // integer
a61af66fc99e Initial load
duke
parents:
diff changeset
67 // Fetch a signed integer the size of a stack slot
a61af66fc99e Initial load
duke
parents:
diff changeset
68 sv = new StackValue(addr.getCIntegerAt(0, VM.getVM().getAddressSize(), false));
a61af66fc99e Initial load
duke
parents:
diff changeset
69 }
a61af66fc99e Initial load
duke
parents:
diff changeset
70 result.add(sv);
a61af66fc99e Initial load
duke
parents:
diff changeset
71 }
a61af66fc99e Initial load
duke
parents:
diff changeset
72
a61af66fc99e Initial load
duke
parents:
diff changeset
73 return result;
a61af66fc99e Initial load
duke
parents:
diff changeset
74 }
a61af66fc99e Initial load
duke
parents:
diff changeset
75
a61af66fc99e Initial load
duke
parents:
diff changeset
76 public StackValueCollection getExpressions() {
a61af66fc99e Initial load
duke
parents:
diff changeset
77 int length = getFrame().getInterpreterFrameExpressionStackSize();
a61af66fc99e Initial load
duke
parents:
diff changeset
78
a61af66fc99e Initial load
duke
parents:
diff changeset
79 if (getMethod().isNative()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
80 // If the method is native, there is no expression stack
a61af66fc99e Initial load
duke
parents:
diff changeset
81 length = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
82 }
a61af66fc99e Initial load
duke
parents:
diff changeset
83
a61af66fc99e Initial load
duke
parents:
diff changeset
84 int nofLocals = (int) getMethod().getMaxLocals();
a61af66fc99e Initial load
duke
parents:
diff changeset
85 StackValueCollection result = new StackValueCollection(length);
a61af66fc99e Initial load
duke
parents:
diff changeset
86
a61af66fc99e Initial load
duke
parents:
diff changeset
87 // Get oopmap describing oops and int for current bci
a61af66fc99e Initial load
duke
parents:
diff changeset
88 OopMapCacheEntry oopMask = getMethod().getMaskFor(getBCI());
a61af66fc99e Initial load
duke
parents:
diff changeset
89
a61af66fc99e Initial load
duke
parents:
diff changeset
90 for(int i = 0; i < length; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
91 // Find stack location
a61af66fc99e Initial load
duke
parents:
diff changeset
92 Address addr = addressOfExpressionStackAt(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
93
a61af66fc99e Initial load
duke
parents:
diff changeset
94 // Depending on oop/int put it in the right package
a61af66fc99e Initial load
duke
parents:
diff changeset
95 StackValue sv;
a61af66fc99e Initial load
duke
parents:
diff changeset
96 if (oopMask.isOop(i + nofLocals)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
97 // oop value
818
b109e761e927 6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents: 0
diff changeset
98 sv = new StackValue(addr.getOopHandleAt(0), 0);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
99 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
100 // integer
a61af66fc99e Initial load
duke
parents:
diff changeset
101 // Fetch a signed integer the size of a stack slot
a61af66fc99e Initial load
duke
parents:
diff changeset
102 sv = new StackValue(addr.getCIntegerAt(0, VM.getVM().getAddressSize(), false));
a61af66fc99e Initial load
duke
parents:
diff changeset
103 }
a61af66fc99e Initial load
duke
parents:
diff changeset
104 result.add(sv);
a61af66fc99e Initial load
duke
parents:
diff changeset
105 }
a61af66fc99e Initial load
duke
parents:
diff changeset
106
a61af66fc99e Initial load
duke
parents:
diff changeset
107 return result;
a61af66fc99e Initial load
duke
parents:
diff changeset
108 }
a61af66fc99e Initial load
duke
parents:
diff changeset
109
a61af66fc99e Initial load
duke
parents:
diff changeset
110 /** Returns List<MonitorInfo> */
a61af66fc99e Initial load
duke
parents:
diff changeset
111 public List getMonitors() {
a61af66fc99e Initial load
duke
parents:
diff changeset
112 List result = new ArrayList(5);
a61af66fc99e Initial load
duke
parents:
diff changeset
113 for (BasicObjectLock current = getFrame().interpreterFrameMonitorEnd();
a61af66fc99e Initial load
duke
parents:
diff changeset
114 current.address().lessThan(getFrame().interpreterFrameMonitorBegin().address());
a61af66fc99e Initial load
duke
parents:
diff changeset
115 current = getFrame().nextMonitorInInterpreterFrame(current)) {
818
b109e761e927 6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents: 0
diff changeset
116 result.add(new MonitorInfo(current.obj(), current.lock(), false, false));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
117 }
a61af66fc99e Initial load
duke
parents:
diff changeset
118 return result;
a61af66fc99e Initial load
duke
parents:
diff changeset
119 }
a61af66fc99e Initial load
duke
parents:
diff changeset
120
a61af66fc99e Initial load
duke
parents:
diff changeset
121 /** Test operation */
a61af66fc99e Initial load
duke
parents:
diff changeset
122 public boolean isInterpretedFrame() { return true; }
a61af66fc99e Initial load
duke
parents:
diff changeset
123
a61af66fc99e Initial load
duke
parents:
diff changeset
124 /** Package-internal constructor */
a61af66fc99e Initial load
duke
parents:
diff changeset
125 InterpretedVFrame(Frame fr, RegisterMap regMap, JavaThread thread) {
a61af66fc99e Initial load
duke
parents:
diff changeset
126 super(fr, regMap, thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
127 }
a61af66fc99e Initial load
duke
parents:
diff changeset
128
a61af66fc99e Initial load
duke
parents:
diff changeset
129 /** Accessor for Byte Code Index (NOTE: access to BCP is not allowed
a61af66fc99e Initial load
duke
parents:
diff changeset
130 in this system; see Frame.java) */
a61af66fc99e Initial load
duke
parents:
diff changeset
131 public int getBCI() {
a61af66fc99e Initial load
duke
parents:
diff changeset
132 return getFrame().getInterpreterFrameBCI();
a61af66fc99e Initial load
duke
parents:
diff changeset
133 }
a61af66fc99e Initial load
duke
parents:
diff changeset
134
a61af66fc99e Initial load
duke
parents:
diff changeset
135 /** Setter for Byte Code Index */
a61af66fc99e Initial load
duke
parents:
diff changeset
136 // FIXME: not yet implementable
a61af66fc99e Initial load
duke
parents:
diff changeset
137 // public void setBCI(int bci) {
a61af66fc99e Initial load
duke
parents:
diff changeset
138 // getFrame().setInterpreterFrameBCI(bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
139 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
140
a61af66fc99e Initial load
duke
parents:
diff changeset
141 public void verify() {
a61af66fc99e Initial load
duke
parents:
diff changeset
142 }
a61af66fc99e Initial load
duke
parents:
diff changeset
143
a61af66fc99e Initial load
duke
parents:
diff changeset
144 //--------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
145 // Internals only below this point
a61af66fc99e Initial load
duke
parents:
diff changeset
146 //
a61af66fc99e Initial load
duke
parents:
diff changeset
147
a61af66fc99e Initial load
duke
parents:
diff changeset
148 private Address addressOfLocalAt(int index) {
a61af66fc99e Initial load
duke
parents:
diff changeset
149 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
150 Assert.that(getFrame().isInterpretedFrame(), "frame should be an interpreted frame");
a61af66fc99e Initial load
duke
parents:
diff changeset
151 }
a61af66fc99e Initial load
duke
parents:
diff changeset
152 return fr.addressOfInterpreterFrameLocal(index);
a61af66fc99e Initial load
duke
parents:
diff changeset
153 }
a61af66fc99e Initial load
duke
parents:
diff changeset
154
a61af66fc99e Initial load
duke
parents:
diff changeset
155 private Address addressOfExpressionStackAt(int index) {
a61af66fc99e Initial load
duke
parents:
diff changeset
156 return fr.addressOfInterpreterFrameExpressionStackSlot(index);
a61af66fc99e Initial load
duke
parents:
diff changeset
157 }
a61af66fc99e Initial load
duke
parents:
diff changeset
158 }