annotate agent/src/share/classes/sun/jvm/hotspot/runtime/CompiledVFrame.java @ 1552:c18cbe5936b8

6941466: Oracle rebranding changes for Hotspot repositories Summary: Change all the Sun copyrights to Oracle copyright Reviewed-by: ohair
author trims
date Thu, 27 May 2010 19:08:38 -0700
parents bd02caa94611
children 7588156f5cf9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 844
diff changeset
2 * Copyright (c) 2000, 2009, Oracle and/or its affiliates. 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 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 844
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 844
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 844
diff changeset
21 * questions.
0
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.code.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
29 import sun.jvm.hotspot.debugger.*;
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 /** FIXME: missing many accessors; all we have right now is the method
a61af66fc99e Initial load
duke
parents:
diff changeset
34 and BCI. NOTE that this has been modified from the VM's version to
a61af66fc99e Initial load
duke
parents:
diff changeset
35 handle NULL ScopeDescs for the debugging case. This simplifies
a61af66fc99e Initial load
duke
parents:
diff changeset
36 using code a great deal. */
a61af66fc99e Initial load
duke
parents:
diff changeset
37
a61af66fc99e Initial load
duke
parents:
diff changeset
38 public class CompiledVFrame extends JavaVFrame {
a61af66fc99e Initial load
duke
parents:
diff changeset
39 private ScopeDesc scope;
a61af66fc99e Initial load
duke
parents:
diff changeset
40 private boolean mayBeImprecise;
a61af66fc99e Initial load
duke
parents:
diff changeset
41
a61af66fc99e Initial load
duke
parents:
diff changeset
42 public CompiledVFrame(Frame fr, RegisterMap regMap, JavaThread thread, ScopeDesc scope, boolean mayBeImprecise) {
a61af66fc99e Initial load
duke
parents:
diff changeset
43 super(fr, regMap, thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
44 this.scope = scope;
a61af66fc99e Initial load
duke
parents:
diff changeset
45 this.mayBeImprecise = mayBeImprecise;
a61af66fc99e Initial load
duke
parents:
diff changeset
46 if (!VM.getVM().isDebugging()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
47 Assert.that(scope != null, "scope must be present");
a61af66fc99e Initial load
duke
parents:
diff changeset
48 }
a61af66fc99e Initial load
duke
parents:
diff changeset
49 }
a61af66fc99e Initial load
duke
parents:
diff changeset
50
a61af66fc99e Initial load
duke
parents:
diff changeset
51 public boolean isTop() {
a61af66fc99e Initial load
duke
parents:
diff changeset
52 if (VM.getVM().isDebugging()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
53 return (getScope() == null || getScope().isTop());
a61af66fc99e Initial load
duke
parents:
diff changeset
54 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
55 return getScope().isTop();
a61af66fc99e Initial load
duke
parents:
diff changeset
56 }
a61af66fc99e Initial load
duke
parents:
diff changeset
57 }
a61af66fc99e Initial load
duke
parents:
diff changeset
58
a61af66fc99e Initial load
duke
parents:
diff changeset
59 public boolean isCompiledFrame() {
a61af66fc99e Initial load
duke
parents:
diff changeset
60 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
61 }
a61af66fc99e Initial load
duke
parents:
diff changeset
62
a61af66fc99e Initial load
duke
parents:
diff changeset
63 public boolean isDeoptimized() {
a61af66fc99e Initial load
duke
parents:
diff changeset
64 return fr.isDeoptimized();
a61af66fc99e Initial load
duke
parents:
diff changeset
65 }
a61af66fc99e Initial load
duke
parents:
diff changeset
66
a61af66fc99e Initial load
duke
parents:
diff changeset
67 public boolean mayBeImpreciseDbg() {
a61af66fc99e Initial load
duke
parents:
diff changeset
68 return mayBeImprecise;
a61af66fc99e Initial load
duke
parents:
diff changeset
69 }
a61af66fc99e Initial load
duke
parents:
diff changeset
70
a61af66fc99e Initial load
duke
parents:
diff changeset
71 /** Returns the active method */
a61af66fc99e Initial load
duke
parents:
diff changeset
72 public NMethod getCode() {
a61af66fc99e Initial load
duke
parents:
diff changeset
73 return VM.getVM().getCodeCache().findNMethod(fr.getPC());
a61af66fc99e Initial load
duke
parents:
diff changeset
74 }
a61af66fc99e Initial load
duke
parents:
diff changeset
75
a61af66fc99e Initial load
duke
parents:
diff changeset
76 /** Returns the active method. Does not perform a guarantee
a61af66fc99e Initial load
duke
parents:
diff changeset
77 regarding unloaded methods -- more suitable for debugging
a61af66fc99e Initial load
duke
parents:
diff changeset
78 system. */
a61af66fc99e Initial load
duke
parents:
diff changeset
79 public NMethod getCodeUnsafe() {
a61af66fc99e Initial load
duke
parents:
diff changeset
80 return VM.getVM().getCodeCache().findNMethodUnsafe(fr.getPC());
a61af66fc99e Initial load
duke
parents:
diff changeset
81 }
a61af66fc99e Initial load
duke
parents:
diff changeset
82
a61af66fc99e Initial load
duke
parents:
diff changeset
83 /** Returns the ScopeDesc */
a61af66fc99e Initial load
duke
parents:
diff changeset
84 public ScopeDesc getScope() {
a61af66fc99e Initial load
duke
parents:
diff changeset
85 return scope;
a61af66fc99e Initial load
duke
parents:
diff changeset
86 }
a61af66fc99e Initial load
duke
parents:
diff changeset
87
a61af66fc99e Initial load
duke
parents:
diff changeset
88 public Method getMethod() {
a61af66fc99e Initial load
duke
parents:
diff changeset
89 if (VM.getVM().isDebugging() && getScope() == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
90 return getCodeUnsafe().getMethod();
a61af66fc99e Initial load
duke
parents:
diff changeset
91 }
a61af66fc99e Initial load
duke
parents:
diff changeset
92 return getScope().getMethod();
a61af66fc99e Initial load
duke
parents:
diff changeset
93 }
a61af66fc99e Initial load
duke
parents:
diff changeset
94
a61af66fc99e Initial load
duke
parents:
diff changeset
95 public StackValueCollection getLocals() {
a61af66fc99e Initial load
duke
parents:
diff changeset
96 List scvList = getScope().getLocals();
a61af66fc99e Initial load
duke
parents:
diff changeset
97 if (scvList == null)
a61af66fc99e Initial load
duke
parents:
diff changeset
98 return new StackValueCollection();
a61af66fc99e Initial load
duke
parents:
diff changeset
99
a61af66fc99e Initial load
duke
parents:
diff changeset
100 // scvList is the list of ScopeValues describing the JVM stack state.
a61af66fc99e Initial load
duke
parents:
diff changeset
101 // There is one scv_list entry for every JVM stack state in use.
a61af66fc99e Initial load
duke
parents:
diff changeset
102 int length = scvList.size();
a61af66fc99e Initial load
duke
parents:
diff changeset
103 StackValueCollection result = new StackValueCollection(length);
a61af66fc99e Initial load
duke
parents:
diff changeset
104 for( int i = 0; i < length; i++ )
a61af66fc99e Initial load
duke
parents:
diff changeset
105 result.add( createStackValue((ScopeValue) scvList.get(i)) );
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 public StackValueCollection getExpressions() {
a61af66fc99e Initial load
duke
parents:
diff changeset
111 List scvList = getScope().getExpressions();
a61af66fc99e Initial load
duke
parents:
diff changeset
112 if (scvList == null)
a61af66fc99e Initial load
duke
parents:
diff changeset
113 return new StackValueCollection();
a61af66fc99e Initial load
duke
parents:
diff changeset
114
a61af66fc99e Initial load
duke
parents:
diff changeset
115 // scvList is the list of ScopeValues describing the JVM stack state.
a61af66fc99e Initial load
duke
parents:
diff changeset
116 // There is one scv_list entry for every JVM stack state in use.
a61af66fc99e Initial load
duke
parents:
diff changeset
117 int length = scvList.size();
a61af66fc99e Initial load
duke
parents:
diff changeset
118 StackValueCollection result = new StackValueCollection(length);
a61af66fc99e Initial load
duke
parents:
diff changeset
119 for( int i = 0; i < length; i++ )
a61af66fc99e Initial load
duke
parents:
diff changeset
120 result.add( createStackValue((ScopeValue) scvList.get(i)) );
a61af66fc99e Initial load
duke
parents:
diff changeset
121
a61af66fc99e Initial load
duke
parents:
diff changeset
122 return result;
a61af66fc99e Initial load
duke
parents:
diff changeset
123 }
a61af66fc99e Initial load
duke
parents:
diff changeset
124
a61af66fc99e Initial load
duke
parents:
diff changeset
125 /** Returns List<MonitorInfo> */
a61af66fc99e Initial load
duke
parents:
diff changeset
126 public List getMonitors() {
a61af66fc99e Initial load
duke
parents:
diff changeset
127 List monitors = getScope().getMonitors();
a61af66fc99e Initial load
duke
parents:
diff changeset
128 if (monitors == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
129 return new ArrayList();
a61af66fc99e Initial load
duke
parents:
diff changeset
130 }
a61af66fc99e Initial load
duke
parents:
diff changeset
131 List result = new ArrayList(monitors.size());
a61af66fc99e Initial load
duke
parents:
diff changeset
132 for (int i = 0; i < monitors.size(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
133 MonitorValue mv = (MonitorValue) monitors.get(i);
818
b109e761e927 6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents: 337
diff changeset
134 ScopeValue ov = mv.owner();
b109e761e927 6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents: 337
diff changeset
135 StackValue ownerSV = createStackValue(ov); // it is an oop
b109e761e927 6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents: 337
diff changeset
136 if (ov.isObject()) { // The owner object was scalar replaced
b109e761e927 6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents: 337
diff changeset
137 Assert.that(mv.eliminated() && ownerSV.objIsScalarReplaced(), "monitor should be eliminated for scalar replaced object");
b109e761e927 6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents: 337
diff changeset
138 // Put klass for scalar replaced object.
b109e761e927 6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents: 337
diff changeset
139 ScopeValue kv = ((ObjectValue)ov).getKlass();
b109e761e927 6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents: 337
diff changeset
140 Assert.that(kv.isConstantOop(), "klass should be oop constant for scalar replaced object");
b109e761e927 6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents: 337
diff changeset
141 OopHandle k = ((ConstantOopReadValue)kv).getValue();
b109e761e927 6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents: 337
diff changeset
142 result.add(new MonitorInfo(k, resolveMonitorLock(mv.basicLock()), mv.eliminated(), true));
b109e761e927 6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents: 337
diff changeset
143 } else {
b109e761e927 6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents: 337
diff changeset
144 result.add(new MonitorInfo(ownerSV.getObject(), resolveMonitorLock(mv.basicLock()), mv.eliminated(), false));
b109e761e927 6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents: 337
diff changeset
145 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
146 }
a61af66fc99e Initial load
duke
parents:
diff changeset
147 return result;
a61af66fc99e Initial load
duke
parents:
diff changeset
148 }
a61af66fc99e Initial load
duke
parents:
diff changeset
149
a61af66fc99e Initial load
duke
parents:
diff changeset
150 public int getBCI() {
a61af66fc99e Initial load
duke
parents:
diff changeset
151 int raw = getRawBCI();
a61af66fc99e Initial load
duke
parents:
diff changeset
152 return ((raw == DebugInformationRecorder.SYNCHRONIZATION_ENTRY_BCI) ? 0 : raw);
a61af66fc99e Initial load
duke
parents:
diff changeset
153 }
a61af66fc99e Initial load
duke
parents:
diff changeset
154
a61af66fc99e Initial load
duke
parents:
diff changeset
155 /** Returns SynchronizationEntryBCI or bci() (used for synchronization) */
a61af66fc99e Initial load
duke
parents:
diff changeset
156 public int getRawBCI() {
a61af66fc99e Initial load
duke
parents:
diff changeset
157 if (VM.getVM().isDebugging() && getScope() == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
158 return 0; // No debugging information!
a61af66fc99e Initial load
duke
parents:
diff changeset
159 }
a61af66fc99e Initial load
duke
parents:
diff changeset
160 return getScope().getBCI();
a61af66fc99e Initial load
duke
parents:
diff changeset
161 }
a61af66fc99e Initial load
duke
parents:
diff changeset
162
a61af66fc99e Initial load
duke
parents:
diff changeset
163 /** Returns the sender vframe */
a61af66fc99e Initial load
duke
parents:
diff changeset
164 public VFrame sender() {
a61af66fc99e Initial load
duke
parents:
diff changeset
165 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
166 Assert.that(isTop(), "just checking");
a61af66fc99e Initial load
duke
parents:
diff changeset
167 }
a61af66fc99e Initial load
duke
parents:
diff changeset
168 return sender(false);
a61af66fc99e Initial load
duke
parents:
diff changeset
169 }
a61af66fc99e Initial load
duke
parents:
diff changeset
170
a61af66fc99e Initial load
duke
parents:
diff changeset
171 public VFrame sender(boolean mayBeImprecise) {
a61af66fc99e Initial load
duke
parents:
diff changeset
172 if (!VM.getVM().isDebugging()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
173 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
174 Assert.that(scope != null, "When new stub generator is in place, then scope can never be NULL");
a61af66fc99e Initial load
duke
parents:
diff changeset
175 }
a61af66fc99e Initial load
duke
parents:
diff changeset
176 }
a61af66fc99e Initial load
duke
parents:
diff changeset
177 Frame f = (Frame) getFrame().clone();
a61af66fc99e Initial load
duke
parents:
diff changeset
178 return (isTop()
a61af66fc99e Initial load
duke
parents:
diff changeset
179 ? super.sender(false)
a61af66fc99e Initial load
duke
parents:
diff changeset
180 : new CompiledVFrame(f, getRegisterMap(), getThread(), getScope().sender(), mayBeImprecise));
a61af66fc99e Initial load
duke
parents:
diff changeset
181 }
a61af66fc99e Initial load
duke
parents:
diff changeset
182
a61af66fc99e Initial load
duke
parents:
diff changeset
183 private StackValue createStackValue(ScopeValue sv) {
a61af66fc99e Initial load
duke
parents:
diff changeset
184 // FIXME: this code appears to be out-of-date with respect to the VM especially in 64-bit mode
a61af66fc99e Initial load
duke
parents:
diff changeset
185 if (sv.isLocation()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
186 // Stack or register value
a61af66fc99e Initial load
duke
parents:
diff changeset
187 Location loc = ((LocationValue) sv).getLocation();
a61af66fc99e Initial load
duke
parents:
diff changeset
188
a61af66fc99e Initial load
duke
parents:
diff changeset
189 if (loc.isIllegal()) return new StackValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
190
a61af66fc99e Initial load
duke
parents:
diff changeset
191 // First find address of value
a61af66fc99e Initial load
duke
parents:
diff changeset
192 Address valueAddr = loc.isRegister()
a61af66fc99e Initial load
duke
parents:
diff changeset
193 // Value was in a callee-save register
a61af66fc99e Initial load
duke
parents:
diff changeset
194 ? getRegisterMap().getLocation(new VMReg(loc.getRegisterNumber()))
a61af66fc99e Initial load
duke
parents:
diff changeset
195 // Else value was directly saved on the stack. The frame's original stack pointer,
a61af66fc99e Initial load
duke
parents:
diff changeset
196 // before any extension by its callee (due to Compiler1 linkage on SPARC), must be used.
a61af66fc99e Initial load
duke
parents:
diff changeset
197 : ((Address)fr.getUnextendedSP()).addOffsetTo(loc.getStackOffset());
a61af66fc99e Initial load
duke
parents:
diff changeset
198
a61af66fc99e Initial load
duke
parents:
diff changeset
199 // Then package it right depending on type
a61af66fc99e Initial load
duke
parents:
diff changeset
200 if (loc.holdsFloat()) { // Holds a float in a double register?
a61af66fc99e Initial load
duke
parents:
diff changeset
201 // The callee has no clue whether the register holds a float,
a61af66fc99e Initial load
duke
parents:
diff changeset
202 // double or is unused. He always saves a double. Here we know
a61af66fc99e Initial load
duke
parents:
diff changeset
203 // a double was saved, but we only want a float back. Narrow the
a61af66fc99e Initial load
duke
parents:
diff changeset
204 // saved double to the float that the JVM wants.
a61af66fc99e Initial load
duke
parents:
diff changeset
205 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
206 Assert.that( loc.isRegister(), "floats always saved to stack in 1 word" );
a61af66fc99e Initial load
duke
parents:
diff changeset
207 }
a61af66fc99e Initial load
duke
parents:
diff changeset
208 float value = (float) valueAddr.getJDoubleAt(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
209 return new StackValue(Float.floatToIntBits(value) & 0xFFFFFFFF); // 64-bit high half is stack junk
a61af66fc99e Initial load
duke
parents:
diff changeset
210 } else if (loc.holdsInt()) { // Holds an int in a long register?
a61af66fc99e Initial load
duke
parents:
diff changeset
211 // The callee has no clue whether the register holds an int,
a61af66fc99e Initial load
duke
parents:
diff changeset
212 // long or is unused. He always saves a long. Here we know
a61af66fc99e Initial load
duke
parents:
diff changeset
213 // a long was saved, but we only want an int back. Narrow the
a61af66fc99e Initial load
duke
parents:
diff changeset
214 // saved long to the int that the JVM wants.
a61af66fc99e Initial load
duke
parents:
diff changeset
215 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
216 Assert.that( loc.isRegister(), "ints always saved to stack in 1 word" );
a61af66fc99e Initial load
duke
parents:
diff changeset
217 }
a61af66fc99e Initial load
duke
parents:
diff changeset
218 return new StackValue(valueAddr.getJLongAt(0) & 0xFFFFFFFF);
331
cecd8eb4e0ca 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 0
diff changeset
219 } else if (loc.holdsNarrowOop()) { // Holds an narrow oop?
cecd8eb4e0ca 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 0
diff changeset
220 if (loc.isRegister() && VM.getVM().isBigEndian()) {
cecd8eb4e0ca 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 0
diff changeset
221 // The callee has no clue whether the register holds an narrow oop,
cecd8eb4e0ca 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 0
diff changeset
222 // long or is unused. He always saves a long. Here we know
cecd8eb4e0ca 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 0
diff changeset
223 // a long was saved, but we only want an narrow oop back. Narrow the
cecd8eb4e0ca 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 0
diff changeset
224 // saved long to the narrow oop that the JVM wants.
818
b109e761e927 6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents: 337
diff changeset
225 return new StackValue(valueAddr.getCompOopHandleAt(VM.getVM().getIntSize()), 0);
331
cecd8eb4e0ca 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 0
diff changeset
226 } else {
818
b109e761e927 6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents: 337
diff changeset
227 return new StackValue(valueAddr.getCompOopHandleAt(0), 0);
331
cecd8eb4e0ca 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 0
diff changeset
228 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
229 } else if( loc.holdsOop() ) { // Holds an oop?
818
b109e761e927 6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents: 337
diff changeset
230 return new StackValue(valueAddr.getOopHandleAt(0), 0);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
231 } else if( loc.holdsDouble() ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
232 // Double value in a single stack slot
a61af66fc99e Initial load
duke
parents:
diff changeset
233 return new StackValue(valueAddr.getJIntAt(0) & 0xFFFFFFFF);
a61af66fc99e Initial load
duke
parents:
diff changeset
234 } else if(loc.holdsAddr()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
235 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
236 Assert.that(!VM.getVM().isServerCompiler(), "No address type for locations with C2 (jsr-s are inlined)");
a61af66fc99e Initial load
duke
parents:
diff changeset
237 }
a61af66fc99e Initial load
duke
parents:
diff changeset
238 // FIXME: not yet implemented (no access to safepoint state yet)
a61af66fc99e Initial load
duke
parents:
diff changeset
239 return new StackValue(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
240 // intptr_t return_addr_tmp = *(intptr_t *)value_addr;
a61af66fc99e Initial load
duke
parents:
diff changeset
241 // int bci = -1;
a61af66fc99e Initial load
duke
parents:
diff changeset
242 // // Get the bci of the jsr that generated this returnAddress value.
a61af66fc99e Initial load
duke
parents:
diff changeset
243 // // If the destination of a jsr is a block that ends with a return or throw, then
a61af66fc99e Initial load
duke
parents:
diff changeset
244 // // the GraphBuilder converts the jsr into a direct goto. This has the side effect that
a61af66fc99e Initial load
duke
parents:
diff changeset
245 // // the return address for the jsr gets emitted as a bci instead of as a real pc
a61af66fc99e Initial load
duke
parents:
diff changeset
246 // if (code()->contains((address)return_addr_tmp)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
247 // ScopeDesc* scope = code()->scope_desc_at((address)(return_addr_tmp - jsr_call_offset), false);
a61af66fc99e Initial load
duke
parents:
diff changeset
248 // bci = scope->bci();
a61af66fc99e Initial load
duke
parents:
diff changeset
249 // } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
250 // bci = (int)return_addr_tmp;
a61af66fc99e Initial load
duke
parents:
diff changeset
251 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
252 // // no need to lock method as this happens at Safepoint
a61af66fc99e Initial load
duke
parents:
diff changeset
253 // assert (SafepointSynchronize::is_at_safepoint(), "must be at safepoint, otherwise lock method()");
a61af66fc99e Initial load
duke
parents:
diff changeset
254 // // make sure bci points to jsr
a61af66fc99e Initial load
duke
parents:
diff changeset
255 // Bytecode* bytecode = Bytecode_at(method()->bcp_from(bci));
a61af66fc99e Initial load
duke
parents:
diff changeset
256 // Bytecodes::Code bc = bytecode->code();
a61af66fc99e Initial load
duke
parents:
diff changeset
257 // assert (bc == Bytecodes::_jsr || bc == Bytecodes::_jsr_w, "must be jsr");
a61af66fc99e Initial load
duke
parents:
diff changeset
258 //
a61af66fc99e Initial load
duke
parents:
diff changeset
259 // // the real returnAddress is the bytecode following the jsr
a61af66fc99e Initial load
duke
parents:
diff changeset
260 // return new StackValue((intptr_t)(bci + Bytecodes::length_for(bc)));
a61af66fc99e Initial load
duke
parents:
diff changeset
261 } else if (VM.getVM().isLP64() && loc.holdsLong()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
262 if ( loc.isRegister() ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
263 // Long value in two registers, high half in the first, low in the second
a61af66fc99e Initial load
duke
parents:
diff changeset
264 return new StackValue(((valueAddr.getJLongAt(0) & 0xFFFFFFFF) << 32) |
a61af66fc99e Initial load
duke
parents:
diff changeset
265 ((valueAddr.getJLongAt(8) & 0xFFFFFFFF)));
a61af66fc99e Initial load
duke
parents:
diff changeset
266 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
267 // Long value in a single stack slot
a61af66fc99e Initial load
duke
parents:
diff changeset
268 return new StackValue(valueAddr.getJLongAt(0));
a61af66fc99e Initial load
duke
parents:
diff changeset
269 }
a61af66fc99e Initial load
duke
parents:
diff changeset
270 } else if( loc.isRegister() ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
271 // At the moment, all non-oop values in registers are 4 bytes,
a61af66fc99e Initial load
duke
parents:
diff changeset
272 // including double and long halves (see Compile::FillLocArray() in
a61af66fc99e Initial load
duke
parents:
diff changeset
273 // opto/output.cpp). Haul them out as such and return a StackValue
a61af66fc99e Initial load
duke
parents:
diff changeset
274 // containing an image of the value as it appears in a stack slot.
a61af66fc99e Initial load
duke
parents:
diff changeset
275 // If this is a double or long half, the interpreter _must_ deal
a61af66fc99e Initial load
duke
parents:
diff changeset
276 // with doubles and longs as entities split across two stack slots.
a61af66fc99e Initial load
duke
parents:
diff changeset
277 // To change this so doubles and/or longs can live in one stack slot,
a61af66fc99e Initial load
duke
parents:
diff changeset
278 // a StackValue will have to understand that it can contain an
a61af66fc99e Initial load
duke
parents:
diff changeset
279 // undivided double or long, implying that a Location (and the debug
a61af66fc99e Initial load
duke
parents:
diff changeset
280 // info mechanism) and FillLocArray() will also have to understand it.
a61af66fc99e Initial load
duke
parents:
diff changeset
281 return new StackValue(valueAddr.getJIntAt(0) & 0xFFFFFFFF);
a61af66fc99e Initial load
duke
parents:
diff changeset
282 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
283 return new StackValue(valueAddr.getJIntAt(0) & 0xFFFFFFFF);
a61af66fc99e Initial load
duke
parents:
diff changeset
284 }
a61af66fc99e Initial load
duke
parents:
diff changeset
285 } else if (sv.isConstantInt()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
286 // Constant int: treat same as register int.
a61af66fc99e Initial load
duke
parents:
diff changeset
287 return new StackValue(((ConstantIntValue) sv).getValue() & 0xFFFFFFFF);
a61af66fc99e Initial load
duke
parents:
diff changeset
288 } else if (sv.isConstantOop()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
289 // constant oop
818
b109e761e927 6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents: 337
diff changeset
290 return new StackValue(((ConstantOopReadValue) sv).getValue(), 0);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
291 } else if (sv.isConstantDouble()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
292 // Constant double in a single stack slot
a61af66fc99e Initial load
duke
parents:
diff changeset
293 double d = ((ConstantDoubleValue) sv).getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
294 return new StackValue(Double.doubleToLongBits(d) & 0xFFFFFFFF);
a61af66fc99e Initial load
duke
parents:
diff changeset
295 } else if (VM.getVM().isLP64() && sv.isConstantLong()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
296 // Constant long in a single stack slot
a61af66fc99e Initial load
duke
parents:
diff changeset
297 return new StackValue(((ConstantLongValue) sv).getValue() & 0xFFFFFFFF);
818
b109e761e927 6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents: 337
diff changeset
298 } else if (sv.isObject()) {
b109e761e927 6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents: 337
diff changeset
299 // Scalar replaced object in compiled frame
b109e761e927 6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents: 337
diff changeset
300 return new StackValue(((ObjectValue)sv).getValue(), 1);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
301 }
a61af66fc99e Initial load
duke
parents:
diff changeset
302
a61af66fc99e Initial load
duke
parents:
diff changeset
303 // Unknown ScopeValue type
a61af66fc99e Initial load
duke
parents:
diff changeset
304 Assert.that(false, "Should not reach here");
a61af66fc99e Initial load
duke
parents:
diff changeset
305 return new StackValue(0); // dummy
a61af66fc99e Initial load
duke
parents:
diff changeset
306 }
a61af66fc99e Initial load
duke
parents:
diff changeset
307
a61af66fc99e Initial load
duke
parents:
diff changeset
308 private BasicLock resolveMonitorLock(Location location) {
a61af66fc99e Initial load
duke
parents:
diff changeset
309 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
310 Assert.that(location.isStack(), "for now we only look at the stack");
a61af66fc99e Initial load
duke
parents:
diff changeset
311 }
a61af66fc99e Initial load
duke
parents:
diff changeset
312 int byteOffset = location.getStackOffset();
a61af66fc99e Initial load
duke
parents:
diff changeset
313 // (stack picture)
a61af66fc99e Initial load
duke
parents:
diff changeset
314 // high: [ ] byte_offset + wordSize
a61af66fc99e Initial load
duke
parents:
diff changeset
315 // low [ ] byte_offset
a61af66fc99e Initial load
duke
parents:
diff changeset
316 //
a61af66fc99e Initial load
duke
parents:
diff changeset
317 // sp-> [ ] 0
a61af66fc99e Initial load
duke
parents:
diff changeset
318 // the byte_offset is the distance from the stack pointer to the lowest address
a61af66fc99e Initial load
duke
parents:
diff changeset
319 // The frame's original stack pointer, before any extension by its callee
a61af66fc99e Initial load
duke
parents:
diff changeset
320 // (due to Compiler1 linkage on SPARC), must be used.
a61af66fc99e Initial load
duke
parents:
diff changeset
321 return new BasicLock(getFrame().getUnextendedSP().addOffsetTo(byteOffset));
a61af66fc99e Initial load
duke
parents:
diff changeset
322 }
a61af66fc99e Initial load
duke
parents:
diff changeset
323 }