annotate src/share/vm/interpreter/bytecodeInterpreter.cpp @ 1078:8e7adf982378

6896043: first round of zero fixes Reviewed-by: kvn Contributed-by: Gary Benson <gbenson@redhat.com>
author twisti
date Fri, 27 Nov 2009 07:56:58 -0800
parents 354d3184f6b2
children f61d795ce6de
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
579
0fbdb4381b99 6814575: Update copyright year
xdono
parents: 520
diff changeset
2 * Copyright 2002-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
a61af66fc99e Initial load
duke
parents:
diff changeset
26 // no precompiled headers
a61af66fc99e Initial load
duke
parents:
diff changeset
27 #include "incls/_bytecodeInterpreter.cpp.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
28
a61af66fc99e Initial load
duke
parents:
diff changeset
29 #ifdef CC_INTERP
a61af66fc99e Initial load
duke
parents:
diff changeset
30
a61af66fc99e Initial load
duke
parents:
diff changeset
31 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
32 * USELABELS - If using GCC, then use labels for the opcode dispatching
a61af66fc99e Initial load
duke
parents:
diff changeset
33 * rather -then a switch statement. This improves performance because it
a61af66fc99e Initial load
duke
parents:
diff changeset
34 * gives us the oportunity to have the instructions that calculate the
a61af66fc99e Initial load
duke
parents:
diff changeset
35 * next opcode to jump to be intermixed with the rest of the instructions
a61af66fc99e Initial load
duke
parents:
diff changeset
36 * that implement the opcode (see UPDATE_PC_AND_TOS_AND_CONTINUE macro).
a61af66fc99e Initial load
duke
parents:
diff changeset
37 */
a61af66fc99e Initial load
duke
parents:
diff changeset
38 #undef USELABELS
a61af66fc99e Initial load
duke
parents:
diff changeset
39 #ifdef __GNUC__
a61af66fc99e Initial load
duke
parents:
diff changeset
40 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
41 ASSERT signifies debugging. It is much easier to step thru bytecodes if we
a61af66fc99e Initial load
duke
parents:
diff changeset
42 don't use the computed goto approach.
a61af66fc99e Initial load
duke
parents:
diff changeset
43 */
a61af66fc99e Initial load
duke
parents:
diff changeset
44 #ifndef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
45 #define USELABELS
a61af66fc99e Initial load
duke
parents:
diff changeset
46 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
47 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
48
a61af66fc99e Initial load
duke
parents:
diff changeset
49 #undef CASE
a61af66fc99e Initial load
duke
parents:
diff changeset
50 #ifdef USELABELS
a61af66fc99e Initial load
duke
parents:
diff changeset
51 #define CASE(opcode) opc ## opcode
a61af66fc99e Initial load
duke
parents:
diff changeset
52 #define DEFAULT opc_default
a61af66fc99e Initial load
duke
parents:
diff changeset
53 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
54 #define CASE(opcode) case Bytecodes:: opcode
a61af66fc99e Initial load
duke
parents:
diff changeset
55 #define DEFAULT default
a61af66fc99e Initial load
duke
parents:
diff changeset
56 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
57
a61af66fc99e Initial load
duke
parents:
diff changeset
58 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
59 * PREFETCH_OPCCODE - Some compilers do better if you prefetch the next
a61af66fc99e Initial load
duke
parents:
diff changeset
60 * opcode before going back to the top of the while loop, rather then having
a61af66fc99e Initial load
duke
parents:
diff changeset
61 * the top of the while loop handle it. This provides a better opportunity
a61af66fc99e Initial load
duke
parents:
diff changeset
62 * for instruction scheduling. Some compilers just do this prefetch
a61af66fc99e Initial load
duke
parents:
diff changeset
63 * automatically. Some actually end up with worse performance if you
a61af66fc99e Initial load
duke
parents:
diff changeset
64 * force the prefetch. Solaris gcc seems to do better, but cc does worse.
a61af66fc99e Initial load
duke
parents:
diff changeset
65 */
a61af66fc99e Initial load
duke
parents:
diff changeset
66 #undef PREFETCH_OPCCODE
a61af66fc99e Initial load
duke
parents:
diff changeset
67 #define PREFETCH_OPCCODE
a61af66fc99e Initial load
duke
parents:
diff changeset
68
a61af66fc99e Initial load
duke
parents:
diff changeset
69 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
70 Interpreter safepoint: it is expected that the interpreter will have no live
a61af66fc99e Initial load
duke
parents:
diff changeset
71 handles of its own creation live at an interpreter safepoint. Therefore we
a61af66fc99e Initial load
duke
parents:
diff changeset
72 run a HandleMarkCleaner and trash all handles allocated in the call chain
a61af66fc99e Initial load
duke
parents:
diff changeset
73 since the JavaCalls::call_helper invocation that initiated the chain.
a61af66fc99e Initial load
duke
parents:
diff changeset
74 There really shouldn't be any handles remaining to trash but this is cheap
a61af66fc99e Initial load
duke
parents:
diff changeset
75 in relation to a safepoint.
a61af66fc99e Initial load
duke
parents:
diff changeset
76 */
a61af66fc99e Initial load
duke
parents:
diff changeset
77 #define SAFEPOINT \
a61af66fc99e Initial load
duke
parents:
diff changeset
78 if ( SafepointSynchronize::is_synchronizing()) { \
a61af66fc99e Initial load
duke
parents:
diff changeset
79 { \
a61af66fc99e Initial load
duke
parents:
diff changeset
80 /* zap freed handles rather than GC'ing them */ \
a61af66fc99e Initial load
duke
parents:
diff changeset
81 HandleMarkCleaner __hmc(THREAD); \
a61af66fc99e Initial load
duke
parents:
diff changeset
82 } \
a61af66fc99e Initial load
duke
parents:
diff changeset
83 CALL_VM(SafepointSynchronize::block(THREAD), handle_exception); \
a61af66fc99e Initial load
duke
parents:
diff changeset
84 }
a61af66fc99e Initial load
duke
parents:
diff changeset
85
a61af66fc99e Initial load
duke
parents:
diff changeset
86 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
87 * VM_JAVA_ERROR - Macro for throwing a java exception from
a61af66fc99e Initial load
duke
parents:
diff changeset
88 * the interpreter loop. Should really be a CALL_VM but there
a61af66fc99e Initial load
duke
parents:
diff changeset
89 * is no entry point to do the transition to vm so we just
a61af66fc99e Initial load
duke
parents:
diff changeset
90 * do it by hand here.
a61af66fc99e Initial load
duke
parents:
diff changeset
91 */
a61af66fc99e Initial load
duke
parents:
diff changeset
92 #define VM_JAVA_ERROR_NO_JUMP(name, msg) \
a61af66fc99e Initial load
duke
parents:
diff changeset
93 DECACHE_STATE(); \
a61af66fc99e Initial load
duke
parents:
diff changeset
94 SET_LAST_JAVA_FRAME(); \
a61af66fc99e Initial load
duke
parents:
diff changeset
95 { \
a61af66fc99e Initial load
duke
parents:
diff changeset
96 ThreadInVMfromJava trans(THREAD); \
a61af66fc99e Initial load
duke
parents:
diff changeset
97 Exceptions::_throw_msg(THREAD, __FILE__, __LINE__, name, msg); \
a61af66fc99e Initial load
duke
parents:
diff changeset
98 } \
a61af66fc99e Initial load
duke
parents:
diff changeset
99 RESET_LAST_JAVA_FRAME(); \
a61af66fc99e Initial load
duke
parents:
diff changeset
100 CACHE_STATE();
a61af66fc99e Initial load
duke
parents:
diff changeset
101
a61af66fc99e Initial load
duke
parents:
diff changeset
102 // Normal throw of a java error
a61af66fc99e Initial load
duke
parents:
diff changeset
103 #define VM_JAVA_ERROR(name, msg) \
a61af66fc99e Initial load
duke
parents:
diff changeset
104 VM_JAVA_ERROR_NO_JUMP(name, msg) \
a61af66fc99e Initial load
duke
parents:
diff changeset
105 goto handle_exception;
a61af66fc99e Initial load
duke
parents:
diff changeset
106
a61af66fc99e Initial load
duke
parents:
diff changeset
107 #ifdef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
108 #define DO_UPDATE_INSTRUCTION_COUNT(opcode)
a61af66fc99e Initial load
duke
parents:
diff changeset
109 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
110 #define DO_UPDATE_INSTRUCTION_COUNT(opcode) \
a61af66fc99e Initial load
duke
parents:
diff changeset
111 { \
a61af66fc99e Initial load
duke
parents:
diff changeset
112 BytecodeCounter::_counter_value++; \
a61af66fc99e Initial load
duke
parents:
diff changeset
113 BytecodeHistogram::_counters[(Bytecodes::Code)opcode]++; \
a61af66fc99e Initial load
duke
parents:
diff changeset
114 if (StopInterpreterAt && StopInterpreterAt == BytecodeCounter::_counter_value) os::breakpoint(); \
a61af66fc99e Initial load
duke
parents:
diff changeset
115 if (TraceBytecodes) { \
a61af66fc99e Initial load
duke
parents:
diff changeset
116 CALL_VM((void)SharedRuntime::trace_bytecode(THREAD, 0, \
a61af66fc99e Initial load
duke
parents:
diff changeset
117 topOfStack[Interpreter::expr_index_at(1)], \
a61af66fc99e Initial load
duke
parents:
diff changeset
118 topOfStack[Interpreter::expr_index_at(2)]), \
a61af66fc99e Initial load
duke
parents:
diff changeset
119 handle_exception); \
a61af66fc99e Initial load
duke
parents:
diff changeset
120 } \
a61af66fc99e Initial load
duke
parents:
diff changeset
121 }
a61af66fc99e Initial load
duke
parents:
diff changeset
122 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
123
a61af66fc99e Initial load
duke
parents:
diff changeset
124 #undef DEBUGGER_SINGLE_STEP_NOTIFY
a61af66fc99e Initial load
duke
parents:
diff changeset
125 #ifdef VM_JVMTI
a61af66fc99e Initial load
duke
parents:
diff changeset
126 /* NOTE: (kbr) This macro must be called AFTER the PC has been
a61af66fc99e Initial load
duke
parents:
diff changeset
127 incremented. JvmtiExport::at_single_stepping_point() may cause a
a61af66fc99e Initial load
duke
parents:
diff changeset
128 breakpoint opcode to get inserted at the current PC to allow the
a61af66fc99e Initial load
duke
parents:
diff changeset
129 debugger to coalesce single-step events.
a61af66fc99e Initial load
duke
parents:
diff changeset
130
a61af66fc99e Initial load
duke
parents:
diff changeset
131 As a result if we call at_single_stepping_point() we refetch opcode
a61af66fc99e Initial load
duke
parents:
diff changeset
132 to get the current opcode. This will override any other prefetching
a61af66fc99e Initial load
duke
parents:
diff changeset
133 that might have occurred.
a61af66fc99e Initial load
duke
parents:
diff changeset
134 */
a61af66fc99e Initial load
duke
parents:
diff changeset
135 #define DEBUGGER_SINGLE_STEP_NOTIFY() \
a61af66fc99e Initial load
duke
parents:
diff changeset
136 { \
a61af66fc99e Initial load
duke
parents:
diff changeset
137 if (_jvmti_interp_events) { \
a61af66fc99e Initial load
duke
parents:
diff changeset
138 if (JvmtiExport::should_post_single_step()) { \
a61af66fc99e Initial load
duke
parents:
diff changeset
139 DECACHE_STATE(); \
a61af66fc99e Initial load
duke
parents:
diff changeset
140 SET_LAST_JAVA_FRAME(); \
a61af66fc99e Initial load
duke
parents:
diff changeset
141 ThreadInVMfromJava trans(THREAD); \
a61af66fc99e Initial load
duke
parents:
diff changeset
142 JvmtiExport::at_single_stepping_point(THREAD, \
a61af66fc99e Initial load
duke
parents:
diff changeset
143 istate->method(), \
a61af66fc99e Initial load
duke
parents:
diff changeset
144 pc); \
a61af66fc99e Initial load
duke
parents:
diff changeset
145 RESET_LAST_JAVA_FRAME(); \
a61af66fc99e Initial load
duke
parents:
diff changeset
146 CACHE_STATE(); \
a61af66fc99e Initial load
duke
parents:
diff changeset
147 if (THREAD->pop_frame_pending() && \
a61af66fc99e Initial load
duke
parents:
diff changeset
148 !THREAD->pop_frame_in_process()) { \
a61af66fc99e Initial load
duke
parents:
diff changeset
149 goto handle_Pop_Frame; \
a61af66fc99e Initial load
duke
parents:
diff changeset
150 } \
a61af66fc99e Initial load
duke
parents:
diff changeset
151 opcode = *pc; \
a61af66fc99e Initial load
duke
parents:
diff changeset
152 } \
a61af66fc99e Initial load
duke
parents:
diff changeset
153 } \
a61af66fc99e Initial load
duke
parents:
diff changeset
154 }
a61af66fc99e Initial load
duke
parents:
diff changeset
155 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
156 #define DEBUGGER_SINGLE_STEP_NOTIFY()
a61af66fc99e Initial load
duke
parents:
diff changeset
157 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
158
a61af66fc99e Initial load
duke
parents:
diff changeset
159 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
160 * CONTINUE - Macro for executing the next opcode.
a61af66fc99e Initial load
duke
parents:
diff changeset
161 */
a61af66fc99e Initial load
duke
parents:
diff changeset
162 #undef CONTINUE
a61af66fc99e Initial load
duke
parents:
diff changeset
163 #ifdef USELABELS
a61af66fc99e Initial load
duke
parents:
diff changeset
164 // Have to do this dispatch this way in C++ because otherwise gcc complains about crossing an
a61af66fc99e Initial load
duke
parents:
diff changeset
165 // initialization (which is is the initialization of the table pointer...)
520
52a431267315 6791168: Fix invalid code in bytecodeInterpreter that can cause gcc ICE
coleenp
parents: 196
diff changeset
166 #define DISPATCH(opcode) goto *(void*)dispatch_table[opcode]
0
a61af66fc99e Initial load
duke
parents:
diff changeset
167 #define CONTINUE { \
a61af66fc99e Initial load
duke
parents:
diff changeset
168 opcode = *pc; \
a61af66fc99e Initial load
duke
parents:
diff changeset
169 DO_UPDATE_INSTRUCTION_COUNT(opcode); \
a61af66fc99e Initial load
duke
parents:
diff changeset
170 DEBUGGER_SINGLE_STEP_NOTIFY(); \
a61af66fc99e Initial load
duke
parents:
diff changeset
171 DISPATCH(opcode); \
a61af66fc99e Initial load
duke
parents:
diff changeset
172 }
a61af66fc99e Initial load
duke
parents:
diff changeset
173 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
174 #ifdef PREFETCH_OPCCODE
a61af66fc99e Initial load
duke
parents:
diff changeset
175 #define CONTINUE { \
a61af66fc99e Initial load
duke
parents:
diff changeset
176 opcode = *pc; \
a61af66fc99e Initial load
duke
parents:
diff changeset
177 DO_UPDATE_INSTRUCTION_COUNT(opcode); \
a61af66fc99e Initial load
duke
parents:
diff changeset
178 DEBUGGER_SINGLE_STEP_NOTIFY(); \
a61af66fc99e Initial load
duke
parents:
diff changeset
179 continue; \
a61af66fc99e Initial load
duke
parents:
diff changeset
180 }
a61af66fc99e Initial load
duke
parents:
diff changeset
181 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
182 #define CONTINUE { \
a61af66fc99e Initial load
duke
parents:
diff changeset
183 DO_UPDATE_INSTRUCTION_COUNT(opcode); \
a61af66fc99e Initial load
duke
parents:
diff changeset
184 DEBUGGER_SINGLE_STEP_NOTIFY(); \
a61af66fc99e Initial load
duke
parents:
diff changeset
185 continue; \
a61af66fc99e Initial load
duke
parents:
diff changeset
186 }
a61af66fc99e Initial load
duke
parents:
diff changeset
187 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
188 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
189
a61af66fc99e Initial load
duke
parents:
diff changeset
190 // JavaStack Implementation
a61af66fc99e Initial load
duke
parents:
diff changeset
191 #define MORE_STACK(count) \
a61af66fc99e Initial load
duke
parents:
diff changeset
192 (topOfStack -= ((count) * Interpreter::stackElementWords()))
a61af66fc99e Initial load
duke
parents:
diff changeset
193
a61af66fc99e Initial load
duke
parents:
diff changeset
194
a61af66fc99e Initial load
duke
parents:
diff changeset
195 #define UPDATE_PC(opsize) {pc += opsize; }
a61af66fc99e Initial load
duke
parents:
diff changeset
196 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
197 * UPDATE_PC_AND_TOS - Macro for updating the pc and topOfStack.
a61af66fc99e Initial load
duke
parents:
diff changeset
198 */
a61af66fc99e Initial load
duke
parents:
diff changeset
199 #undef UPDATE_PC_AND_TOS
a61af66fc99e Initial load
duke
parents:
diff changeset
200 #define UPDATE_PC_AND_TOS(opsize, stack) \
a61af66fc99e Initial load
duke
parents:
diff changeset
201 {pc += opsize; MORE_STACK(stack); }
a61af66fc99e Initial load
duke
parents:
diff changeset
202
a61af66fc99e Initial load
duke
parents:
diff changeset
203 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
204 * UPDATE_PC_AND_TOS_AND_CONTINUE - Macro for updating the pc and topOfStack,
a61af66fc99e Initial load
duke
parents:
diff changeset
205 * and executing the next opcode. It's somewhat similar to the combination
a61af66fc99e Initial load
duke
parents:
diff changeset
206 * of UPDATE_PC_AND_TOS and CONTINUE, but with some minor optimizations.
a61af66fc99e Initial load
duke
parents:
diff changeset
207 */
a61af66fc99e Initial load
duke
parents:
diff changeset
208 #undef UPDATE_PC_AND_TOS_AND_CONTINUE
a61af66fc99e Initial load
duke
parents:
diff changeset
209 #ifdef USELABELS
a61af66fc99e Initial load
duke
parents:
diff changeset
210 #define UPDATE_PC_AND_TOS_AND_CONTINUE(opsize, stack) { \
a61af66fc99e Initial load
duke
parents:
diff changeset
211 pc += opsize; opcode = *pc; MORE_STACK(stack); \
a61af66fc99e Initial load
duke
parents:
diff changeset
212 DO_UPDATE_INSTRUCTION_COUNT(opcode); \
a61af66fc99e Initial load
duke
parents:
diff changeset
213 DEBUGGER_SINGLE_STEP_NOTIFY(); \
a61af66fc99e Initial load
duke
parents:
diff changeset
214 DISPATCH(opcode); \
a61af66fc99e Initial load
duke
parents:
diff changeset
215 }
a61af66fc99e Initial load
duke
parents:
diff changeset
216
a61af66fc99e Initial load
duke
parents:
diff changeset
217 #define UPDATE_PC_AND_CONTINUE(opsize) { \
a61af66fc99e Initial load
duke
parents:
diff changeset
218 pc += opsize; opcode = *pc; \
a61af66fc99e Initial load
duke
parents:
diff changeset
219 DO_UPDATE_INSTRUCTION_COUNT(opcode); \
a61af66fc99e Initial load
duke
parents:
diff changeset
220 DEBUGGER_SINGLE_STEP_NOTIFY(); \
a61af66fc99e Initial load
duke
parents:
diff changeset
221 DISPATCH(opcode); \
a61af66fc99e Initial load
duke
parents:
diff changeset
222 }
a61af66fc99e Initial load
duke
parents:
diff changeset
223 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
224 #ifdef PREFETCH_OPCCODE
a61af66fc99e Initial load
duke
parents:
diff changeset
225 #define UPDATE_PC_AND_TOS_AND_CONTINUE(opsize, stack) { \
a61af66fc99e Initial load
duke
parents:
diff changeset
226 pc += opsize; opcode = *pc; MORE_STACK(stack); \
a61af66fc99e Initial load
duke
parents:
diff changeset
227 DO_UPDATE_INSTRUCTION_COUNT(opcode); \
a61af66fc99e Initial load
duke
parents:
diff changeset
228 DEBUGGER_SINGLE_STEP_NOTIFY(); \
a61af66fc99e Initial load
duke
parents:
diff changeset
229 goto do_continue; \
a61af66fc99e Initial load
duke
parents:
diff changeset
230 }
a61af66fc99e Initial load
duke
parents:
diff changeset
231
a61af66fc99e Initial load
duke
parents:
diff changeset
232 #define UPDATE_PC_AND_CONTINUE(opsize) { \
a61af66fc99e Initial load
duke
parents:
diff changeset
233 pc += opsize; opcode = *pc; \
a61af66fc99e Initial load
duke
parents:
diff changeset
234 DO_UPDATE_INSTRUCTION_COUNT(opcode); \
a61af66fc99e Initial load
duke
parents:
diff changeset
235 DEBUGGER_SINGLE_STEP_NOTIFY(); \
a61af66fc99e Initial load
duke
parents:
diff changeset
236 goto do_continue; \
a61af66fc99e Initial load
duke
parents:
diff changeset
237 }
a61af66fc99e Initial load
duke
parents:
diff changeset
238 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
239 #define UPDATE_PC_AND_TOS_AND_CONTINUE(opsize, stack) { \
a61af66fc99e Initial load
duke
parents:
diff changeset
240 pc += opsize; MORE_STACK(stack); \
a61af66fc99e Initial load
duke
parents:
diff changeset
241 DO_UPDATE_INSTRUCTION_COUNT(opcode); \
a61af66fc99e Initial load
duke
parents:
diff changeset
242 DEBUGGER_SINGLE_STEP_NOTIFY(); \
a61af66fc99e Initial load
duke
parents:
diff changeset
243 goto do_continue; \
a61af66fc99e Initial load
duke
parents:
diff changeset
244 }
a61af66fc99e Initial load
duke
parents:
diff changeset
245
a61af66fc99e Initial load
duke
parents:
diff changeset
246 #define UPDATE_PC_AND_CONTINUE(opsize) { \
a61af66fc99e Initial load
duke
parents:
diff changeset
247 pc += opsize; \
a61af66fc99e Initial load
duke
parents:
diff changeset
248 DO_UPDATE_INSTRUCTION_COUNT(opcode); \
a61af66fc99e Initial load
duke
parents:
diff changeset
249 DEBUGGER_SINGLE_STEP_NOTIFY(); \
a61af66fc99e Initial load
duke
parents:
diff changeset
250 goto do_continue; \
a61af66fc99e Initial load
duke
parents:
diff changeset
251 }
a61af66fc99e Initial load
duke
parents:
diff changeset
252 #endif /* PREFETCH_OPCCODE */
a61af66fc99e Initial load
duke
parents:
diff changeset
253 #endif /* USELABELS */
a61af66fc99e Initial load
duke
parents:
diff changeset
254
a61af66fc99e Initial load
duke
parents:
diff changeset
255 // About to call a new method, update the save the adjusted pc and return to frame manager
a61af66fc99e Initial load
duke
parents:
diff changeset
256 #define UPDATE_PC_AND_RETURN(opsize) \
a61af66fc99e Initial load
duke
parents:
diff changeset
257 DECACHE_TOS(); \
a61af66fc99e Initial load
duke
parents:
diff changeset
258 istate->set_bcp(pc+opsize); \
a61af66fc99e Initial load
duke
parents:
diff changeset
259 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
260
a61af66fc99e Initial load
duke
parents:
diff changeset
261
a61af66fc99e Initial load
duke
parents:
diff changeset
262 #define METHOD istate->method()
a61af66fc99e Initial load
duke
parents:
diff changeset
263 #define INVOCATION_COUNT METHOD->invocation_counter()
a61af66fc99e Initial load
duke
parents:
diff changeset
264 #define BACKEDGE_COUNT METHOD->backedge_counter()
a61af66fc99e Initial load
duke
parents:
diff changeset
265
a61af66fc99e Initial load
duke
parents:
diff changeset
266
a61af66fc99e Initial load
duke
parents:
diff changeset
267 #define INCR_INVOCATION_COUNT INVOCATION_COUNT->increment()
a61af66fc99e Initial load
duke
parents:
diff changeset
268 #define OSR_REQUEST(res, branch_pc) \
a61af66fc99e Initial load
duke
parents:
diff changeset
269 CALL_VM(res=InterpreterRuntime::frequency_counter_overflow(THREAD, branch_pc), handle_exception);
a61af66fc99e Initial load
duke
parents:
diff changeset
270 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
271 * For those opcodes that need to have a GC point on a backwards branch
a61af66fc99e Initial load
duke
parents:
diff changeset
272 */
a61af66fc99e Initial load
duke
parents:
diff changeset
273
a61af66fc99e Initial load
duke
parents:
diff changeset
274 // Backedge counting is kind of strange. The asm interpreter will increment
a61af66fc99e Initial load
duke
parents:
diff changeset
275 // the backedge counter as a separate counter but it does it's comparisons
a61af66fc99e Initial load
duke
parents:
diff changeset
276 // to the sum (scaled) of invocation counter and backedge count to make
a61af66fc99e Initial load
duke
parents:
diff changeset
277 // a decision. Seems kind of odd to sum them together like that
a61af66fc99e Initial load
duke
parents:
diff changeset
278
a61af66fc99e Initial load
duke
parents:
diff changeset
279 // skip is delta from current bcp/bci for target, branch_pc is pre-branch bcp
a61af66fc99e Initial load
duke
parents:
diff changeset
280
a61af66fc99e Initial load
duke
parents:
diff changeset
281
a61af66fc99e Initial load
duke
parents:
diff changeset
282 #define DO_BACKEDGE_CHECKS(skip, branch_pc) \
a61af66fc99e Initial load
duke
parents:
diff changeset
283 if ((skip) <= 0) { \
1078
8e7adf982378 6896043: first round of zero fixes
twisti
parents: 1010
diff changeset
284 if (UseLoopCounter) { \
0
a61af66fc99e Initial load
duke
parents:
diff changeset
285 bool do_OSR = UseOnStackReplacement; \
a61af66fc99e Initial load
duke
parents:
diff changeset
286 BACKEDGE_COUNT->increment(); \
a61af66fc99e Initial load
duke
parents:
diff changeset
287 if (do_OSR) do_OSR = BACKEDGE_COUNT->reached_InvocationLimit(); \
a61af66fc99e Initial load
duke
parents:
diff changeset
288 if (do_OSR) { \
a61af66fc99e Initial load
duke
parents:
diff changeset
289 nmethod* osr_nmethod; \
a61af66fc99e Initial load
duke
parents:
diff changeset
290 OSR_REQUEST(osr_nmethod, branch_pc); \
a61af66fc99e Initial load
duke
parents:
diff changeset
291 if (osr_nmethod != NULL && osr_nmethod->osr_entry_bci() != InvalidOSREntryBci) { \
1078
8e7adf982378 6896043: first round of zero fixes
twisti
parents: 1010
diff changeset
292 intptr_t* buf = SharedRuntime::OSR_migration_begin(THREAD); \
0
a61af66fc99e Initial load
duke
parents:
diff changeset
293 istate->set_msg(do_osr); \
a61af66fc99e Initial load
duke
parents:
diff changeset
294 istate->set_osr_buf((address)buf); \
a61af66fc99e Initial load
duke
parents:
diff changeset
295 istate->set_osr_entry(osr_nmethod->osr_entry()); \
a61af66fc99e Initial load
duke
parents:
diff changeset
296 return; \
a61af66fc99e Initial load
duke
parents:
diff changeset
297 } \
a61af66fc99e Initial load
duke
parents:
diff changeset
298 } \
a61af66fc99e Initial load
duke
parents:
diff changeset
299 } /* UseCompiler ... */ \
a61af66fc99e Initial load
duke
parents:
diff changeset
300 INCR_INVOCATION_COUNT; \
a61af66fc99e Initial load
duke
parents:
diff changeset
301 SAFEPOINT; \
a61af66fc99e Initial load
duke
parents:
diff changeset
302 }
a61af66fc99e Initial load
duke
parents:
diff changeset
303
a61af66fc99e Initial load
duke
parents:
diff changeset
304 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
305 * For those opcodes that need to have a GC point on a backwards branch
a61af66fc99e Initial load
duke
parents:
diff changeset
306 */
a61af66fc99e Initial load
duke
parents:
diff changeset
307
a61af66fc99e Initial load
duke
parents:
diff changeset
308 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
309 * Macros for caching and flushing the interpreter state. Some local
a61af66fc99e Initial load
duke
parents:
diff changeset
310 * variables need to be flushed out to the frame before we do certain
a61af66fc99e Initial load
duke
parents:
diff changeset
311 * things (like pushing frames or becomming gc safe) and some need to
a61af66fc99e Initial load
duke
parents:
diff changeset
312 * be recached later (like after popping a frame). We could use one
a61af66fc99e Initial load
duke
parents:
diff changeset
313 * macro to cache or decache everything, but this would be less then
a61af66fc99e Initial load
duke
parents:
diff changeset
314 * optimal because we don't always need to cache or decache everything
a61af66fc99e Initial load
duke
parents:
diff changeset
315 * because some things we know are already cached or decached.
a61af66fc99e Initial load
duke
parents:
diff changeset
316 */
a61af66fc99e Initial load
duke
parents:
diff changeset
317 #undef DECACHE_TOS
a61af66fc99e Initial load
duke
parents:
diff changeset
318 #undef CACHE_TOS
a61af66fc99e Initial load
duke
parents:
diff changeset
319 #undef CACHE_PREV_TOS
a61af66fc99e Initial load
duke
parents:
diff changeset
320 #define DECACHE_TOS() istate->set_stack(topOfStack);
a61af66fc99e Initial load
duke
parents:
diff changeset
321
a61af66fc99e Initial load
duke
parents:
diff changeset
322 #define CACHE_TOS() topOfStack = (intptr_t *)istate->stack();
a61af66fc99e Initial load
duke
parents:
diff changeset
323
a61af66fc99e Initial load
duke
parents:
diff changeset
324 #undef DECACHE_PC
a61af66fc99e Initial load
duke
parents:
diff changeset
325 #undef CACHE_PC
a61af66fc99e Initial load
duke
parents:
diff changeset
326 #define DECACHE_PC() istate->set_bcp(pc);
a61af66fc99e Initial load
duke
parents:
diff changeset
327 #define CACHE_PC() pc = istate->bcp();
a61af66fc99e Initial load
duke
parents:
diff changeset
328 #define CACHE_CP() cp = istate->constants();
a61af66fc99e Initial load
duke
parents:
diff changeset
329 #define CACHE_LOCALS() locals = istate->locals();
a61af66fc99e Initial load
duke
parents:
diff changeset
330 #undef CACHE_FRAME
a61af66fc99e Initial load
duke
parents:
diff changeset
331 #define CACHE_FRAME()
a61af66fc99e Initial load
duke
parents:
diff changeset
332
a61af66fc99e Initial load
duke
parents:
diff changeset
333 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
334 * CHECK_NULL - Macro for throwing a NullPointerException if the object
a61af66fc99e Initial load
duke
parents:
diff changeset
335 * passed is a null ref.
a61af66fc99e Initial load
duke
parents:
diff changeset
336 * On some architectures/platforms it should be possible to do this implicitly
a61af66fc99e Initial load
duke
parents:
diff changeset
337 */
a61af66fc99e Initial load
duke
parents:
diff changeset
338 #undef CHECK_NULL
a61af66fc99e Initial load
duke
parents:
diff changeset
339 #define CHECK_NULL(obj_) \
520
52a431267315 6791168: Fix invalid code in bytecodeInterpreter that can cause gcc ICE
coleenp
parents: 196
diff changeset
340 if ((obj_) == NULL) { \
0
a61af66fc99e Initial load
duke
parents:
diff changeset
341 VM_JAVA_ERROR(vmSymbols::java_lang_NullPointerException(), ""); \
a61af66fc99e Initial load
duke
parents:
diff changeset
342 }
a61af66fc99e Initial load
duke
parents:
diff changeset
343
a61af66fc99e Initial load
duke
parents:
diff changeset
344 #define VMdoubleConstZero() 0.0
a61af66fc99e Initial load
duke
parents:
diff changeset
345 #define VMdoubleConstOne() 1.0
a61af66fc99e Initial load
duke
parents:
diff changeset
346 #define VMlongConstZero() (max_jlong-max_jlong)
a61af66fc99e Initial load
duke
parents:
diff changeset
347 #define VMlongConstOne() ((max_jlong-max_jlong)+1)
a61af66fc99e Initial load
duke
parents:
diff changeset
348
a61af66fc99e Initial load
duke
parents:
diff changeset
349 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
350 * Alignment
a61af66fc99e Initial load
duke
parents:
diff changeset
351 */
a61af66fc99e Initial load
duke
parents:
diff changeset
352 #define VMalignWordUp(val) (((uintptr_t)(val) + 3) & ~3)
a61af66fc99e Initial load
duke
parents:
diff changeset
353
a61af66fc99e Initial load
duke
parents:
diff changeset
354 // Decache the interpreter state that interpreter modifies directly (i.e. GC is indirect mod)
a61af66fc99e Initial load
duke
parents:
diff changeset
355 #define DECACHE_STATE() DECACHE_PC(); DECACHE_TOS();
a61af66fc99e Initial load
duke
parents:
diff changeset
356
a61af66fc99e Initial load
duke
parents:
diff changeset
357 // Reload interpreter state after calling the VM or a possible GC
a61af66fc99e Initial load
duke
parents:
diff changeset
358 #define CACHE_STATE() \
a61af66fc99e Initial load
duke
parents:
diff changeset
359 CACHE_TOS(); \
a61af66fc99e Initial load
duke
parents:
diff changeset
360 CACHE_PC(); \
a61af66fc99e Initial load
duke
parents:
diff changeset
361 CACHE_CP(); \
a61af66fc99e Initial load
duke
parents:
diff changeset
362 CACHE_LOCALS();
a61af66fc99e Initial load
duke
parents:
diff changeset
363
a61af66fc99e Initial load
duke
parents:
diff changeset
364 // Call the VM don't check for pending exceptions
a61af66fc99e Initial load
duke
parents:
diff changeset
365 #define CALL_VM_NOCHECK(func) \
a61af66fc99e Initial load
duke
parents:
diff changeset
366 DECACHE_STATE(); \
a61af66fc99e Initial load
duke
parents:
diff changeset
367 SET_LAST_JAVA_FRAME(); \
a61af66fc99e Initial load
duke
parents:
diff changeset
368 func; \
a61af66fc99e Initial load
duke
parents:
diff changeset
369 RESET_LAST_JAVA_FRAME(); \
a61af66fc99e Initial load
duke
parents:
diff changeset
370 CACHE_STATE(); \
a61af66fc99e Initial load
duke
parents:
diff changeset
371 if (THREAD->pop_frame_pending() && \
a61af66fc99e Initial load
duke
parents:
diff changeset
372 !THREAD->pop_frame_in_process()) { \
a61af66fc99e Initial load
duke
parents:
diff changeset
373 goto handle_Pop_Frame; \
a61af66fc99e Initial load
duke
parents:
diff changeset
374 }
a61af66fc99e Initial load
duke
parents:
diff changeset
375
a61af66fc99e Initial load
duke
parents:
diff changeset
376 // Call the VM and check for pending exceptions
a61af66fc99e Initial load
duke
parents:
diff changeset
377 #define CALL_VM(func, label) { \
a61af66fc99e Initial load
duke
parents:
diff changeset
378 CALL_VM_NOCHECK(func); \
a61af66fc99e Initial load
duke
parents:
diff changeset
379 if (THREAD->has_pending_exception()) goto label; \
a61af66fc99e Initial load
duke
parents:
diff changeset
380 }
a61af66fc99e Initial load
duke
parents:
diff changeset
381
a61af66fc99e Initial load
duke
parents:
diff changeset
382 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
383 * BytecodeInterpreter::run(interpreterState istate)
a61af66fc99e Initial load
duke
parents:
diff changeset
384 * BytecodeInterpreter::runWithChecks(interpreterState istate)
a61af66fc99e Initial load
duke
parents:
diff changeset
385 *
a61af66fc99e Initial load
duke
parents:
diff changeset
386 * The real deal. This is where byte codes actually get interpreted.
a61af66fc99e Initial load
duke
parents:
diff changeset
387 * Basically it's a big while loop that iterates until we return from
a61af66fc99e Initial load
duke
parents:
diff changeset
388 * the method passed in.
a61af66fc99e Initial load
duke
parents:
diff changeset
389 *
a61af66fc99e Initial load
duke
parents:
diff changeset
390 * The runWithChecks is used if JVMTI is enabled.
a61af66fc99e Initial load
duke
parents:
diff changeset
391 *
a61af66fc99e Initial load
duke
parents:
diff changeset
392 */
a61af66fc99e Initial load
duke
parents:
diff changeset
393 #if defined(VM_JVMTI)
a61af66fc99e Initial load
duke
parents:
diff changeset
394 void
a61af66fc99e Initial load
duke
parents:
diff changeset
395 BytecodeInterpreter::runWithChecks(interpreterState istate) {
a61af66fc99e Initial load
duke
parents:
diff changeset
396 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
397 void
a61af66fc99e Initial load
duke
parents:
diff changeset
398 BytecodeInterpreter::run(interpreterState istate) {
a61af66fc99e Initial load
duke
parents:
diff changeset
399 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
400
a61af66fc99e Initial load
duke
parents:
diff changeset
401 // In order to simplify some tests based on switches set at runtime
a61af66fc99e Initial load
duke
parents:
diff changeset
402 // we invoke the interpreter a single time after switches are enabled
a61af66fc99e Initial load
duke
parents:
diff changeset
403 // and set simpler to to test variables rather than method calls or complex
a61af66fc99e Initial load
duke
parents:
diff changeset
404 // boolean expressions.
a61af66fc99e Initial load
duke
parents:
diff changeset
405
a61af66fc99e Initial load
duke
parents:
diff changeset
406 static int initialized = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
407 static int checkit = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
408 static intptr_t* c_addr = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
409 static intptr_t c_value;
a61af66fc99e Initial load
duke
parents:
diff changeset
410
a61af66fc99e Initial load
duke
parents:
diff changeset
411 if (checkit && *c_addr != c_value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
412 os::breakpoint();
a61af66fc99e Initial load
duke
parents:
diff changeset
413 }
a61af66fc99e Initial load
duke
parents:
diff changeset
414 #ifdef VM_JVMTI
a61af66fc99e Initial load
duke
parents:
diff changeset
415 static bool _jvmti_interp_events = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
416 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
417
a61af66fc99e Initial load
duke
parents:
diff changeset
418 static int _compiling; // (UseCompiler || CountCompiledCalls)
a61af66fc99e Initial load
duke
parents:
diff changeset
419
a61af66fc99e Initial load
duke
parents:
diff changeset
420 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
421 if (istate->_msg != initialize) {
a61af66fc99e Initial load
duke
parents:
diff changeset
422 assert(abs(istate->_stack_base - istate->_stack_limit) == (istate->_method->max_stack() + 1), "bad stack limit");
a61af66fc99e Initial load
duke
parents:
diff changeset
423 IA32_ONLY(assert(istate->_stack_limit == istate->_thread->last_Java_sp() + 1, "wrong"));
a61af66fc99e Initial load
duke
parents:
diff changeset
424 }
a61af66fc99e Initial load
duke
parents:
diff changeset
425 // Verify linkages.
a61af66fc99e Initial load
duke
parents:
diff changeset
426 interpreterState l = istate;
a61af66fc99e Initial load
duke
parents:
diff changeset
427 do {
a61af66fc99e Initial load
duke
parents:
diff changeset
428 assert(l == l->_self_link, "bad link");
a61af66fc99e Initial load
duke
parents:
diff changeset
429 l = l->_prev_link;
a61af66fc99e Initial load
duke
parents:
diff changeset
430 } while (l != NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
431 // Screwups with stack management usually cause us to overwrite istate
a61af66fc99e Initial load
duke
parents:
diff changeset
432 // save a copy so we can verify it.
a61af66fc99e Initial load
duke
parents:
diff changeset
433 interpreterState orig = istate;
a61af66fc99e Initial load
duke
parents:
diff changeset
434 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
435
a61af66fc99e Initial load
duke
parents:
diff changeset
436 static volatile jbyte* _byte_map_base; // adjusted card table base for oop store barrier
a61af66fc99e Initial load
duke
parents:
diff changeset
437
a61af66fc99e Initial load
duke
parents:
diff changeset
438 register intptr_t* topOfStack = (intptr_t *)istate->stack(); /* access with STACK macros */
a61af66fc99e Initial load
duke
parents:
diff changeset
439 register address pc = istate->bcp();
a61af66fc99e Initial load
duke
parents:
diff changeset
440 register jubyte opcode;
a61af66fc99e Initial load
duke
parents:
diff changeset
441 register intptr_t* locals = istate->locals();
a61af66fc99e Initial load
duke
parents:
diff changeset
442 register constantPoolCacheOop cp = istate->constants(); // method()->constants()->cache()
a61af66fc99e Initial load
duke
parents:
diff changeset
443 #ifdef LOTS_OF_REGS
a61af66fc99e Initial load
duke
parents:
diff changeset
444 register JavaThread* THREAD = istate->thread();
a61af66fc99e Initial load
duke
parents:
diff changeset
445 register volatile jbyte* BYTE_MAP_BASE = _byte_map_base;
a61af66fc99e Initial load
duke
parents:
diff changeset
446 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
447 #undef THREAD
a61af66fc99e Initial load
duke
parents:
diff changeset
448 #define THREAD istate->thread()
a61af66fc99e Initial load
duke
parents:
diff changeset
449 #undef BYTE_MAP_BASE
a61af66fc99e Initial load
duke
parents:
diff changeset
450 #define BYTE_MAP_BASE _byte_map_base
a61af66fc99e Initial load
duke
parents:
diff changeset
451 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
452
a61af66fc99e Initial load
duke
parents:
diff changeset
453 #ifdef USELABELS
a61af66fc99e Initial load
duke
parents:
diff changeset
454 const static void* const opclabels_data[256] = {
a61af66fc99e Initial load
duke
parents:
diff changeset
455 /* 0x00 */ &&opc_nop, &&opc_aconst_null,&&opc_iconst_m1,&&opc_iconst_0,
a61af66fc99e Initial load
duke
parents:
diff changeset
456 /* 0x04 */ &&opc_iconst_1,&&opc_iconst_2, &&opc_iconst_3, &&opc_iconst_4,
a61af66fc99e Initial load
duke
parents:
diff changeset
457 /* 0x08 */ &&opc_iconst_5,&&opc_lconst_0, &&opc_lconst_1, &&opc_fconst_0,
a61af66fc99e Initial load
duke
parents:
diff changeset
458 /* 0x0C */ &&opc_fconst_1,&&opc_fconst_2, &&opc_dconst_0, &&opc_dconst_1,
a61af66fc99e Initial load
duke
parents:
diff changeset
459
a61af66fc99e Initial load
duke
parents:
diff changeset
460 /* 0x10 */ &&opc_bipush, &&opc_sipush, &&opc_ldc, &&opc_ldc_w,
a61af66fc99e Initial load
duke
parents:
diff changeset
461 /* 0x14 */ &&opc_ldc2_w, &&opc_iload, &&opc_lload, &&opc_fload,
a61af66fc99e Initial load
duke
parents:
diff changeset
462 /* 0x18 */ &&opc_dload, &&opc_aload, &&opc_iload_0,&&opc_iload_1,
a61af66fc99e Initial load
duke
parents:
diff changeset
463 /* 0x1C */ &&opc_iload_2,&&opc_iload_3,&&opc_lload_0,&&opc_lload_1,
a61af66fc99e Initial load
duke
parents:
diff changeset
464
a61af66fc99e Initial load
duke
parents:
diff changeset
465 /* 0x20 */ &&opc_lload_2,&&opc_lload_3,&&opc_fload_0,&&opc_fload_1,
a61af66fc99e Initial load
duke
parents:
diff changeset
466 /* 0x24 */ &&opc_fload_2,&&opc_fload_3,&&opc_dload_0,&&opc_dload_1,
a61af66fc99e Initial load
duke
parents:
diff changeset
467 /* 0x28 */ &&opc_dload_2,&&opc_dload_3,&&opc_aload_0,&&opc_aload_1,
a61af66fc99e Initial load
duke
parents:
diff changeset
468 /* 0x2C */ &&opc_aload_2,&&opc_aload_3,&&opc_iaload, &&opc_laload,
a61af66fc99e Initial load
duke
parents:
diff changeset
469
a61af66fc99e Initial load
duke
parents:
diff changeset
470 /* 0x30 */ &&opc_faload, &&opc_daload, &&opc_aaload, &&opc_baload,
a61af66fc99e Initial load
duke
parents:
diff changeset
471 /* 0x34 */ &&opc_caload, &&opc_saload, &&opc_istore, &&opc_lstore,
a61af66fc99e Initial load
duke
parents:
diff changeset
472 /* 0x38 */ &&opc_fstore, &&opc_dstore, &&opc_astore, &&opc_istore_0,
a61af66fc99e Initial load
duke
parents:
diff changeset
473 /* 0x3C */ &&opc_istore_1,&&opc_istore_2,&&opc_istore_3,&&opc_lstore_0,
a61af66fc99e Initial load
duke
parents:
diff changeset
474
a61af66fc99e Initial load
duke
parents:
diff changeset
475 /* 0x40 */ &&opc_lstore_1,&&opc_lstore_2,&&opc_lstore_3,&&opc_fstore_0,
a61af66fc99e Initial load
duke
parents:
diff changeset
476 /* 0x44 */ &&opc_fstore_1,&&opc_fstore_2,&&opc_fstore_3,&&opc_dstore_0,
a61af66fc99e Initial load
duke
parents:
diff changeset
477 /* 0x48 */ &&opc_dstore_1,&&opc_dstore_2,&&opc_dstore_3,&&opc_astore_0,
a61af66fc99e Initial load
duke
parents:
diff changeset
478 /* 0x4C */ &&opc_astore_1,&&opc_astore_2,&&opc_astore_3,&&opc_iastore,
a61af66fc99e Initial load
duke
parents:
diff changeset
479
a61af66fc99e Initial load
duke
parents:
diff changeset
480 /* 0x50 */ &&opc_lastore,&&opc_fastore,&&opc_dastore,&&opc_aastore,
a61af66fc99e Initial load
duke
parents:
diff changeset
481 /* 0x54 */ &&opc_bastore,&&opc_castore,&&opc_sastore,&&opc_pop,
a61af66fc99e Initial load
duke
parents:
diff changeset
482 /* 0x58 */ &&opc_pop2, &&opc_dup, &&opc_dup_x1, &&opc_dup_x2,
a61af66fc99e Initial load
duke
parents:
diff changeset
483 /* 0x5C */ &&opc_dup2, &&opc_dup2_x1,&&opc_dup2_x2,&&opc_swap,
a61af66fc99e Initial load
duke
parents:
diff changeset
484
a61af66fc99e Initial load
duke
parents:
diff changeset
485 /* 0x60 */ &&opc_iadd,&&opc_ladd,&&opc_fadd,&&opc_dadd,
a61af66fc99e Initial load
duke
parents:
diff changeset
486 /* 0x64 */ &&opc_isub,&&opc_lsub,&&opc_fsub,&&opc_dsub,
a61af66fc99e Initial load
duke
parents:
diff changeset
487 /* 0x68 */ &&opc_imul,&&opc_lmul,&&opc_fmul,&&opc_dmul,
a61af66fc99e Initial load
duke
parents:
diff changeset
488 /* 0x6C */ &&opc_idiv,&&opc_ldiv,&&opc_fdiv,&&opc_ddiv,
a61af66fc99e Initial load
duke
parents:
diff changeset
489
a61af66fc99e Initial load
duke
parents:
diff changeset
490 /* 0x70 */ &&opc_irem, &&opc_lrem, &&opc_frem,&&opc_drem,
a61af66fc99e Initial load
duke
parents:
diff changeset
491 /* 0x74 */ &&opc_ineg, &&opc_lneg, &&opc_fneg,&&opc_dneg,
a61af66fc99e Initial load
duke
parents:
diff changeset
492 /* 0x78 */ &&opc_ishl, &&opc_lshl, &&opc_ishr,&&opc_lshr,
a61af66fc99e Initial load
duke
parents:
diff changeset
493 /* 0x7C */ &&opc_iushr,&&opc_lushr,&&opc_iand,&&opc_land,
a61af66fc99e Initial load
duke
parents:
diff changeset
494
a61af66fc99e Initial load
duke
parents:
diff changeset
495 /* 0x80 */ &&opc_ior, &&opc_lor,&&opc_ixor,&&opc_lxor,
a61af66fc99e Initial load
duke
parents:
diff changeset
496 /* 0x84 */ &&opc_iinc,&&opc_i2l,&&opc_i2f, &&opc_i2d,
a61af66fc99e Initial load
duke
parents:
diff changeset
497 /* 0x88 */ &&opc_l2i, &&opc_l2f,&&opc_l2d, &&opc_f2i,
a61af66fc99e Initial load
duke
parents:
diff changeset
498 /* 0x8C */ &&opc_f2l, &&opc_f2d,&&opc_d2i, &&opc_d2l,
a61af66fc99e Initial load
duke
parents:
diff changeset
499
a61af66fc99e Initial load
duke
parents:
diff changeset
500 /* 0x90 */ &&opc_d2f, &&opc_i2b, &&opc_i2c, &&opc_i2s,
a61af66fc99e Initial load
duke
parents:
diff changeset
501 /* 0x94 */ &&opc_lcmp, &&opc_fcmpl,&&opc_fcmpg,&&opc_dcmpl,
a61af66fc99e Initial load
duke
parents:
diff changeset
502 /* 0x98 */ &&opc_dcmpg,&&opc_ifeq, &&opc_ifne, &&opc_iflt,
a61af66fc99e Initial load
duke
parents:
diff changeset
503 /* 0x9C */ &&opc_ifge, &&opc_ifgt, &&opc_ifle, &&opc_if_icmpeq,
a61af66fc99e Initial load
duke
parents:
diff changeset
504
a61af66fc99e Initial load
duke
parents:
diff changeset
505 /* 0xA0 */ &&opc_if_icmpne,&&opc_if_icmplt,&&opc_if_icmpge, &&opc_if_icmpgt,
a61af66fc99e Initial load
duke
parents:
diff changeset
506 /* 0xA4 */ &&opc_if_icmple,&&opc_if_acmpeq,&&opc_if_acmpne, &&opc_goto,
a61af66fc99e Initial load
duke
parents:
diff changeset
507 /* 0xA8 */ &&opc_jsr, &&opc_ret, &&opc_tableswitch,&&opc_lookupswitch,
a61af66fc99e Initial load
duke
parents:
diff changeset
508 /* 0xAC */ &&opc_ireturn, &&opc_lreturn, &&opc_freturn, &&opc_dreturn,
a61af66fc99e Initial load
duke
parents:
diff changeset
509
a61af66fc99e Initial load
duke
parents:
diff changeset
510 /* 0xB0 */ &&opc_areturn, &&opc_return, &&opc_getstatic, &&opc_putstatic,
a61af66fc99e Initial load
duke
parents:
diff changeset
511 /* 0xB4 */ &&opc_getfield, &&opc_putfield, &&opc_invokevirtual,&&opc_invokespecial,
a61af66fc99e Initial load
duke
parents:
diff changeset
512 /* 0xB8 */ &&opc_invokestatic,&&opc_invokeinterface,NULL, &&opc_new,
a61af66fc99e Initial load
duke
parents:
diff changeset
513 /* 0xBC */ &&opc_newarray, &&opc_anewarray, &&opc_arraylength, &&opc_athrow,
a61af66fc99e Initial load
duke
parents:
diff changeset
514
a61af66fc99e Initial load
duke
parents:
diff changeset
515 /* 0xC0 */ &&opc_checkcast, &&opc_instanceof, &&opc_monitorenter, &&opc_monitorexit,
a61af66fc99e Initial load
duke
parents:
diff changeset
516 /* 0xC4 */ &&opc_wide, &&opc_multianewarray, &&opc_ifnull, &&opc_ifnonnull,
123
9e5a7340635e 6688137: c++ interpreter fails on 64bit sparc
sgoldman
parents: 0
diff changeset
517 /* 0xC8 */ &&opc_goto_w, &&opc_jsr_w, &&opc_breakpoint, &&opc_default,
9e5a7340635e 6688137: c++ interpreter fails on 64bit sparc
sgoldman
parents: 0
diff changeset
518 /* 0xCC */ &&opc_default, &&opc_default, &&opc_default, &&opc_default,
9e5a7340635e 6688137: c++ interpreter fails on 64bit sparc
sgoldman
parents: 0
diff changeset
519
9e5a7340635e 6688137: c++ interpreter fails on 64bit sparc
sgoldman
parents: 0
diff changeset
520 /* 0xD0 */ &&opc_default, &&opc_default, &&opc_default, &&opc_default,
0
a61af66fc99e Initial load
duke
parents:
diff changeset
521 /* 0xD4 */ &&opc_default, &&opc_default, &&opc_default, &&opc_default,
a61af66fc99e Initial load
duke
parents:
diff changeset
522 /* 0xD8 */ &&opc_default, &&opc_default, &&opc_default, &&opc_default,
a61af66fc99e Initial load
duke
parents:
diff changeset
523 /* 0xDC */ &&opc_default, &&opc_default, &&opc_default, &&opc_default,
a61af66fc99e Initial load
duke
parents:
diff changeset
524
a61af66fc99e Initial load
duke
parents:
diff changeset
525 /* 0xE0 */ &&opc_default, &&opc_default, &&opc_default, &&opc_default,
123
9e5a7340635e 6688137: c++ interpreter fails on 64bit sparc
sgoldman
parents: 0
diff changeset
526 /* 0xE4 */ &&opc_default, &&opc_return_register_finalizer, &&opc_default, &&opc_default,
0
a61af66fc99e Initial load
duke
parents:
diff changeset
527 /* 0xE8 */ &&opc_default, &&opc_default, &&opc_default, &&opc_default,
a61af66fc99e Initial load
duke
parents:
diff changeset
528 /* 0xEC */ &&opc_default, &&opc_default, &&opc_default, &&opc_default,
a61af66fc99e Initial load
duke
parents:
diff changeset
529
a61af66fc99e Initial load
duke
parents:
diff changeset
530 /* 0xF0 */ &&opc_default, &&opc_default, &&opc_default, &&opc_default,
a61af66fc99e Initial load
duke
parents:
diff changeset
531 /* 0xF4 */ &&opc_default, &&opc_default, &&opc_default, &&opc_default,
a61af66fc99e Initial load
duke
parents:
diff changeset
532 /* 0xF8 */ &&opc_default, &&opc_default, &&opc_default, &&opc_default,
a61af66fc99e Initial load
duke
parents:
diff changeset
533 /* 0xFC */ &&opc_default, &&opc_default, &&opc_default, &&opc_default
a61af66fc99e Initial load
duke
parents:
diff changeset
534 };
a61af66fc99e Initial load
duke
parents:
diff changeset
535 register uintptr_t *dispatch_table = (uintptr_t*)&opclabels_data[0];
a61af66fc99e Initial load
duke
parents:
diff changeset
536 #endif /* USELABELS */
a61af66fc99e Initial load
duke
parents:
diff changeset
537
a61af66fc99e Initial load
duke
parents:
diff changeset
538 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
539 // this will trigger a VERIFY_OOP on entry
a61af66fc99e Initial load
duke
parents:
diff changeset
540 if (istate->msg() != initialize && ! METHOD->is_static()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
541 oop rcvr = LOCALS_OBJECT(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
542 }
a61af66fc99e Initial load
duke
parents:
diff changeset
543 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
544 // #define HACK
a61af66fc99e Initial load
duke
parents:
diff changeset
545 #ifdef HACK
a61af66fc99e Initial load
duke
parents:
diff changeset
546 bool interesting = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
547 #endif // HACK
a61af66fc99e Initial load
duke
parents:
diff changeset
548
a61af66fc99e Initial load
duke
parents:
diff changeset
549 /* QQQ this should be a stack method so we don't know actual direction */
a61af66fc99e Initial load
duke
parents:
diff changeset
550 assert(istate->msg() == initialize ||
a61af66fc99e Initial load
duke
parents:
diff changeset
551 topOfStack >= istate->stack_limit() &&
a61af66fc99e Initial load
duke
parents:
diff changeset
552 topOfStack < istate->stack_base(),
a61af66fc99e Initial load
duke
parents:
diff changeset
553 "Stack top out of range");
a61af66fc99e Initial load
duke
parents:
diff changeset
554
a61af66fc99e Initial load
duke
parents:
diff changeset
555 switch (istate->msg()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
556 case initialize: {
a61af66fc99e Initial load
duke
parents:
diff changeset
557 if (initialized++) ShouldNotReachHere(); // Only one initialize call
a61af66fc99e Initial load
duke
parents:
diff changeset
558 _compiling = (UseCompiler || CountCompiledCalls);
a61af66fc99e Initial load
duke
parents:
diff changeset
559 #ifdef VM_JVMTI
a61af66fc99e Initial load
duke
parents:
diff changeset
560 _jvmti_interp_events = JvmtiExport::can_post_interpreter_events();
a61af66fc99e Initial load
duke
parents:
diff changeset
561 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
562 BarrierSet* bs = Universe::heap()->barrier_set();
a61af66fc99e Initial load
duke
parents:
diff changeset
563 assert(bs->kind() == BarrierSet::CardTableModRef, "Wrong barrier set kind");
a61af66fc99e Initial load
duke
parents:
diff changeset
564 _byte_map_base = (volatile jbyte*)(((CardTableModRefBS*)bs)->byte_map_base);
a61af66fc99e Initial load
duke
parents:
diff changeset
565 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
566 }
a61af66fc99e Initial load
duke
parents:
diff changeset
567 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
568 case method_entry: {
a61af66fc99e Initial load
duke
parents:
diff changeset
569 THREAD->set_do_not_unlock();
a61af66fc99e Initial load
duke
parents:
diff changeset
570 // count invocations
a61af66fc99e Initial load
duke
parents:
diff changeset
571 assert(initialized, "Interpreter not initialized");
a61af66fc99e Initial load
duke
parents:
diff changeset
572 if (_compiling) {
a61af66fc99e Initial load
duke
parents:
diff changeset
573 if (ProfileInterpreter) {
a61af66fc99e Initial load
duke
parents:
diff changeset
574 METHOD->increment_interpreter_invocation_count();
a61af66fc99e Initial load
duke
parents:
diff changeset
575 }
a61af66fc99e Initial load
duke
parents:
diff changeset
576 INCR_INVOCATION_COUNT;
a61af66fc99e Initial load
duke
parents:
diff changeset
577 if (INVOCATION_COUNT->reached_InvocationLimit()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
578 CALL_VM((void)InterpreterRuntime::frequency_counter_overflow(THREAD, NULL), handle_exception);
a61af66fc99e Initial load
duke
parents:
diff changeset
579
a61af66fc99e Initial load
duke
parents:
diff changeset
580 // We no longer retry on a counter overflow
a61af66fc99e Initial load
duke
parents:
diff changeset
581
a61af66fc99e Initial load
duke
parents:
diff changeset
582 // istate->set_msg(retry_method);
a61af66fc99e Initial load
duke
parents:
diff changeset
583 // THREAD->clr_do_not_unlock();
a61af66fc99e Initial load
duke
parents:
diff changeset
584 // return;
a61af66fc99e Initial load
duke
parents:
diff changeset
585 }
a61af66fc99e Initial load
duke
parents:
diff changeset
586 SAFEPOINT;
a61af66fc99e Initial load
duke
parents:
diff changeset
587 }
a61af66fc99e Initial load
duke
parents:
diff changeset
588
a61af66fc99e Initial load
duke
parents:
diff changeset
589 if ((istate->_stack_base - istate->_stack_limit) != istate->method()->max_stack() + 1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
590 // initialize
a61af66fc99e Initial load
duke
parents:
diff changeset
591 os::breakpoint();
a61af66fc99e Initial load
duke
parents:
diff changeset
592 }
a61af66fc99e Initial load
duke
parents:
diff changeset
593
a61af66fc99e Initial load
duke
parents:
diff changeset
594 #ifdef HACK
a61af66fc99e Initial load
duke
parents:
diff changeset
595 {
a61af66fc99e Initial load
duke
parents:
diff changeset
596 ResourceMark rm;
a61af66fc99e Initial load
duke
parents:
diff changeset
597 char *method_name = istate->method()->name_and_sig_as_C_string();
a61af66fc99e Initial load
duke
parents:
diff changeset
598 if (strstr(method_name, "runThese$TestRunner.run()V") != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
599 tty->print_cr("entering: depth %d bci: %d",
a61af66fc99e Initial load
duke
parents:
diff changeset
600 (istate->_stack_base - istate->_stack),
a61af66fc99e Initial load
duke
parents:
diff changeset
601 istate->_bcp - istate->_method->code_base());
a61af66fc99e Initial load
duke
parents:
diff changeset
602 interesting = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
603 }
a61af66fc99e Initial load
duke
parents:
diff changeset
604 }
a61af66fc99e Initial load
duke
parents:
diff changeset
605 #endif // HACK
a61af66fc99e Initial load
duke
parents:
diff changeset
606
a61af66fc99e Initial load
duke
parents:
diff changeset
607
a61af66fc99e Initial load
duke
parents:
diff changeset
608 // lock method if synchronized
a61af66fc99e Initial load
duke
parents:
diff changeset
609 if (METHOD->is_synchronized()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
610 // oop rcvr = locals[0].j.r;
a61af66fc99e Initial load
duke
parents:
diff changeset
611 oop rcvr;
a61af66fc99e Initial load
duke
parents:
diff changeset
612 if (METHOD->is_static()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
613 rcvr = METHOD->constants()->pool_holder()->klass_part()->java_mirror();
a61af66fc99e Initial load
duke
parents:
diff changeset
614 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
615 rcvr = LOCALS_OBJECT(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
616 }
a61af66fc99e Initial load
duke
parents:
diff changeset
617 // The initial monitor is ours for the taking
a61af66fc99e Initial load
duke
parents:
diff changeset
618 BasicObjectLock* mon = &istate->monitor_base()[-1];
a61af66fc99e Initial load
duke
parents:
diff changeset
619 oop monobj = mon->obj();
a61af66fc99e Initial load
duke
parents:
diff changeset
620 assert(mon->obj() == rcvr, "method monitor mis-initialized");
a61af66fc99e Initial load
duke
parents:
diff changeset
621
a61af66fc99e Initial load
duke
parents:
diff changeset
622 bool success = UseBiasedLocking;
a61af66fc99e Initial load
duke
parents:
diff changeset
623 if (UseBiasedLocking) {
a61af66fc99e Initial load
duke
parents:
diff changeset
624 markOop mark = rcvr->mark();
a61af66fc99e Initial load
duke
parents:
diff changeset
625 if (mark->has_bias_pattern()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
626 // The bias pattern is present in the object's header. Need to check
a61af66fc99e Initial load
duke
parents:
diff changeset
627 // whether the bias owner and the epoch are both still current.
a61af66fc99e Initial load
duke
parents:
diff changeset
628 intptr_t xx = ((intptr_t) THREAD) ^ (intptr_t) mark;
a61af66fc99e Initial load
duke
parents:
diff changeset
629 xx = (intptr_t) rcvr->klass()->klass_part()->prototype_header() ^ xx;
a61af66fc99e Initial load
duke
parents:
diff changeset
630 intptr_t yy = (xx & ~((int) markOopDesc::age_mask_in_place));
a61af66fc99e Initial load
duke
parents:
diff changeset
631 if (yy != 0 ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
632 // At this point we know that the header has the bias pattern and
a61af66fc99e Initial load
duke
parents:
diff changeset
633 // that we are not the bias owner in the current epoch. We need to
a61af66fc99e Initial load
duke
parents:
diff changeset
634 // figure out more details about the state of the header in order to
a61af66fc99e Initial load
duke
parents:
diff changeset
635 // know what operations can be legally performed on the object's
a61af66fc99e Initial load
duke
parents:
diff changeset
636 // header.
a61af66fc99e Initial load
duke
parents:
diff changeset
637
a61af66fc99e Initial load
duke
parents:
diff changeset
638 // If the low three bits in the xor result aren't clear, that means
a61af66fc99e Initial load
duke
parents:
diff changeset
639 // the prototype header is no longer biased and we have to revoke
a61af66fc99e Initial load
duke
parents:
diff changeset
640 // the bias on this object.
a61af66fc99e Initial load
duke
parents:
diff changeset
641
a61af66fc99e Initial load
duke
parents:
diff changeset
642 if (yy & markOopDesc::biased_lock_mask_in_place == 0 ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
643 // Biasing is still enabled for this data type. See whether the
a61af66fc99e Initial load
duke
parents:
diff changeset
644 // epoch of the current bias is still valid, meaning that the epoch
a61af66fc99e Initial load
duke
parents:
diff changeset
645 // bits of the mark word are equal to the epoch bits of the
a61af66fc99e Initial load
duke
parents:
diff changeset
646 // prototype header. (Note that the prototype header's epoch bits
a61af66fc99e Initial load
duke
parents:
diff changeset
647 // only change at a safepoint.) If not, attempt to rebias the object
a61af66fc99e Initial load
duke
parents:
diff changeset
648 // toward the current thread. Note that we must be absolutely sure
a61af66fc99e Initial load
duke
parents:
diff changeset
649 // that the current epoch is invalid in order to do this because
a61af66fc99e Initial load
duke
parents:
diff changeset
650 // otherwise the manipulations it performs on the mark word are
a61af66fc99e Initial load
duke
parents:
diff changeset
651 // illegal.
a61af66fc99e Initial load
duke
parents:
diff changeset
652 if (yy & markOopDesc::epoch_mask_in_place == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
653 // The epoch of the current bias is still valid but we know nothing
a61af66fc99e Initial load
duke
parents:
diff changeset
654 // about the owner; it might be set or it might be clear. Try to
a61af66fc99e Initial load
duke
parents:
diff changeset
655 // acquire the bias of the object using an atomic operation. If this
a61af66fc99e Initial load
duke
parents:
diff changeset
656 // fails we will go in to the runtime to revoke the object's bias.
a61af66fc99e Initial load
duke
parents:
diff changeset
657 // Note that we first construct the presumed unbiased header so we
a61af66fc99e Initial load
duke
parents:
diff changeset
658 // don't accidentally blow away another thread's valid bias.
a61af66fc99e Initial load
duke
parents:
diff changeset
659 intptr_t unbiased = (intptr_t) mark & (markOopDesc::biased_lock_mask_in_place |
a61af66fc99e Initial load
duke
parents:
diff changeset
660 markOopDesc::age_mask_in_place |
a61af66fc99e Initial load
duke
parents:
diff changeset
661 markOopDesc::epoch_mask_in_place);
a61af66fc99e Initial load
duke
parents:
diff changeset
662 if (Atomic::cmpxchg_ptr((intptr_t)THREAD | unbiased, (intptr_t*) rcvr->mark_addr(), unbiased) != unbiased) {
a61af66fc99e Initial load
duke
parents:
diff changeset
663 CALL_VM(InterpreterRuntime::monitorenter(THREAD, mon), handle_exception);
a61af66fc99e Initial load
duke
parents:
diff changeset
664 }
a61af66fc99e Initial load
duke
parents:
diff changeset
665 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
666 try_rebias:
a61af66fc99e Initial load
duke
parents:
diff changeset
667 // At this point we know the epoch has expired, meaning that the
a61af66fc99e Initial load
duke
parents:
diff changeset
668 // current "bias owner", if any, is actually invalid. Under these
a61af66fc99e Initial load
duke
parents:
diff changeset
669 // circumstances _only_, we are allowed to use the current header's
a61af66fc99e Initial load
duke
parents:
diff changeset
670 // value as the comparison value when doing the cas to acquire the
a61af66fc99e Initial load
duke
parents:
diff changeset
671 // bias in the current epoch. In other words, we allow transfer of
a61af66fc99e Initial load
duke
parents:
diff changeset
672 // the bias from one thread to another directly in this situation.
a61af66fc99e Initial load
duke
parents:
diff changeset
673 xx = (intptr_t) rcvr->klass()->klass_part()->prototype_header() | (intptr_t) THREAD;
a61af66fc99e Initial load
duke
parents:
diff changeset
674 if (Atomic::cmpxchg_ptr((intptr_t)THREAD | (intptr_t) rcvr->klass()->klass_part()->prototype_header(),
a61af66fc99e Initial load
duke
parents:
diff changeset
675 (intptr_t*) rcvr->mark_addr(),
a61af66fc99e Initial load
duke
parents:
diff changeset
676 (intptr_t) mark) != (intptr_t) mark) {
a61af66fc99e Initial load
duke
parents:
diff changeset
677 CALL_VM(InterpreterRuntime::monitorenter(THREAD, mon), handle_exception);
a61af66fc99e Initial load
duke
parents:
diff changeset
678 }
a61af66fc99e Initial load
duke
parents:
diff changeset
679 }
a61af66fc99e Initial load
duke
parents:
diff changeset
680 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
681 try_revoke_bias:
a61af66fc99e Initial load
duke
parents:
diff changeset
682 // The prototype mark in the klass doesn't have the bias bit set any
a61af66fc99e Initial load
duke
parents:
diff changeset
683 // more, indicating that objects of this data type are not supposed
a61af66fc99e Initial load
duke
parents:
diff changeset
684 // to be biased any more. We are going to try to reset the mark of
a61af66fc99e Initial load
duke
parents:
diff changeset
685 // this object to the prototype value and fall through to the
a61af66fc99e Initial load
duke
parents:
diff changeset
686 // CAS-based locking scheme. Note that if our CAS fails, it means
a61af66fc99e Initial load
duke
parents:
diff changeset
687 // that another thread raced us for the privilege of revoking the
a61af66fc99e Initial load
duke
parents:
diff changeset
688 // bias of this particular object, so it's okay to continue in the
a61af66fc99e Initial load
duke
parents:
diff changeset
689 // normal locking code.
a61af66fc99e Initial load
duke
parents:
diff changeset
690 //
a61af66fc99e Initial load
duke
parents:
diff changeset
691 xx = (intptr_t) rcvr->klass()->klass_part()->prototype_header() | (intptr_t) THREAD;
a61af66fc99e Initial load
duke
parents:
diff changeset
692 if (Atomic::cmpxchg_ptr(rcvr->klass()->klass_part()->prototype_header(),
a61af66fc99e Initial load
duke
parents:
diff changeset
693 (intptr_t*) rcvr->mark_addr(),
a61af66fc99e Initial load
duke
parents:
diff changeset
694 mark) == mark) {
a61af66fc99e Initial load
duke
parents:
diff changeset
695 // (*counters->revoked_lock_entry_count_addr())++;
a61af66fc99e Initial load
duke
parents:
diff changeset
696 success = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
697 }
a61af66fc99e Initial load
duke
parents:
diff changeset
698 }
a61af66fc99e Initial load
duke
parents:
diff changeset
699 }
a61af66fc99e Initial load
duke
parents:
diff changeset
700 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
701 cas_label:
a61af66fc99e Initial load
duke
parents:
diff changeset
702 success = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
703 }
a61af66fc99e Initial load
duke
parents:
diff changeset
704 }
a61af66fc99e Initial load
duke
parents:
diff changeset
705 if (!success) {
a61af66fc99e Initial load
duke
parents:
diff changeset
706 markOop displaced = rcvr->mark()->set_unlocked();
a61af66fc99e Initial load
duke
parents:
diff changeset
707 mon->lock()->set_displaced_header(displaced);
a61af66fc99e Initial load
duke
parents:
diff changeset
708 if (Atomic::cmpxchg_ptr(mon, rcvr->mark_addr(), displaced) != displaced) {
a61af66fc99e Initial load
duke
parents:
diff changeset
709 // Is it simple recursive case?
a61af66fc99e Initial load
duke
parents:
diff changeset
710 if (THREAD->is_lock_owned((address) displaced->clear_lock_bits())) {
a61af66fc99e Initial load
duke
parents:
diff changeset
711 mon->lock()->set_displaced_header(NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
712 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
713 CALL_VM(InterpreterRuntime::monitorenter(THREAD, mon), handle_exception);
a61af66fc99e Initial load
duke
parents:
diff changeset
714 }
a61af66fc99e Initial load
duke
parents:
diff changeset
715 }
a61af66fc99e Initial load
duke
parents:
diff changeset
716 }
a61af66fc99e Initial load
duke
parents:
diff changeset
717 }
a61af66fc99e Initial load
duke
parents:
diff changeset
718 THREAD->clr_do_not_unlock();
a61af66fc99e Initial load
duke
parents:
diff changeset
719
a61af66fc99e Initial load
duke
parents:
diff changeset
720 // Notify jvmti
a61af66fc99e Initial load
duke
parents:
diff changeset
721 #ifdef VM_JVMTI
a61af66fc99e Initial load
duke
parents:
diff changeset
722 if (_jvmti_interp_events) {
a61af66fc99e Initial load
duke
parents:
diff changeset
723 // Whenever JVMTI puts a thread in interp_only_mode, method
a61af66fc99e Initial load
duke
parents:
diff changeset
724 // entry/exit events are sent for that thread to track stack depth.
a61af66fc99e Initial load
duke
parents:
diff changeset
725 if (THREAD->is_interp_only_mode()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
726 CALL_VM(InterpreterRuntime::post_method_entry(THREAD),
a61af66fc99e Initial load
duke
parents:
diff changeset
727 handle_exception);
a61af66fc99e Initial load
duke
parents:
diff changeset
728 }
a61af66fc99e Initial load
duke
parents:
diff changeset
729 }
a61af66fc99e Initial load
duke
parents:
diff changeset
730 #endif /* VM_JVMTI */
a61af66fc99e Initial load
duke
parents:
diff changeset
731
a61af66fc99e Initial load
duke
parents:
diff changeset
732 goto run;
a61af66fc99e Initial load
duke
parents:
diff changeset
733 }
a61af66fc99e Initial load
duke
parents:
diff changeset
734
a61af66fc99e Initial load
duke
parents:
diff changeset
735 case popping_frame: {
a61af66fc99e Initial load
duke
parents:
diff changeset
736 // returned from a java call to pop the frame, restart the call
a61af66fc99e Initial load
duke
parents:
diff changeset
737 // clear the message so we don't confuse ourselves later
a61af66fc99e Initial load
duke
parents:
diff changeset
738 assert(THREAD->pop_frame_in_process(), "wrong frame pop state");
a61af66fc99e Initial load
duke
parents:
diff changeset
739 istate->set_msg(no_request);
a61af66fc99e Initial load
duke
parents:
diff changeset
740 THREAD->clr_pop_frame_in_process();
a61af66fc99e Initial load
duke
parents:
diff changeset
741 goto run;
a61af66fc99e Initial load
duke
parents:
diff changeset
742 }
a61af66fc99e Initial load
duke
parents:
diff changeset
743
a61af66fc99e Initial load
duke
parents:
diff changeset
744 case method_resume: {
a61af66fc99e Initial load
duke
parents:
diff changeset
745 if ((istate->_stack_base - istate->_stack_limit) != istate->method()->max_stack() + 1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
746 // resume
a61af66fc99e Initial load
duke
parents:
diff changeset
747 os::breakpoint();
a61af66fc99e Initial load
duke
parents:
diff changeset
748 }
a61af66fc99e Initial load
duke
parents:
diff changeset
749 #ifdef HACK
a61af66fc99e Initial load
duke
parents:
diff changeset
750 {
a61af66fc99e Initial load
duke
parents:
diff changeset
751 ResourceMark rm;
a61af66fc99e Initial load
duke
parents:
diff changeset
752 char *method_name = istate->method()->name_and_sig_as_C_string();
a61af66fc99e Initial load
duke
parents:
diff changeset
753 if (strstr(method_name, "runThese$TestRunner.run()V") != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
754 tty->print_cr("resume: depth %d bci: %d",
a61af66fc99e Initial load
duke
parents:
diff changeset
755 (istate->_stack_base - istate->_stack) ,
a61af66fc99e Initial load
duke
parents:
diff changeset
756 istate->_bcp - istate->_method->code_base());
a61af66fc99e Initial load
duke
parents:
diff changeset
757 interesting = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
758 }
a61af66fc99e Initial load
duke
parents:
diff changeset
759 }
a61af66fc99e Initial load
duke
parents:
diff changeset
760 #endif // HACK
a61af66fc99e Initial load
duke
parents:
diff changeset
761 // returned from a java call, continue executing.
a61af66fc99e Initial load
duke
parents:
diff changeset
762 if (THREAD->pop_frame_pending() && !THREAD->pop_frame_in_process()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
763 goto handle_Pop_Frame;
a61af66fc99e Initial load
duke
parents:
diff changeset
764 }
a61af66fc99e Initial load
duke
parents:
diff changeset
765
a61af66fc99e Initial load
duke
parents:
diff changeset
766 if (THREAD->has_pending_exception()) goto handle_exception;
a61af66fc99e Initial load
duke
parents:
diff changeset
767 // Update the pc by the saved amount of the invoke bytecode size
a61af66fc99e Initial load
duke
parents:
diff changeset
768 UPDATE_PC(istate->bcp_advance());
a61af66fc99e Initial load
duke
parents:
diff changeset
769 goto run;
a61af66fc99e Initial load
duke
parents:
diff changeset
770 }
a61af66fc99e Initial load
duke
parents:
diff changeset
771
a61af66fc99e Initial load
duke
parents:
diff changeset
772 case deopt_resume2: {
a61af66fc99e Initial load
duke
parents:
diff changeset
773 // Returned from an opcode that will reexecute. Deopt was
a61af66fc99e Initial load
duke
parents:
diff changeset
774 // a result of a PopFrame request.
a61af66fc99e Initial load
duke
parents:
diff changeset
775 //
a61af66fc99e Initial load
duke
parents:
diff changeset
776 goto run;
a61af66fc99e Initial load
duke
parents:
diff changeset
777 }
a61af66fc99e Initial load
duke
parents:
diff changeset
778
a61af66fc99e Initial load
duke
parents:
diff changeset
779 case deopt_resume: {
a61af66fc99e Initial load
duke
parents:
diff changeset
780 // Returned from an opcode that has completed. The stack has
a61af66fc99e Initial load
duke
parents:
diff changeset
781 // the result all we need to do is skip across the bytecode
a61af66fc99e Initial load
duke
parents:
diff changeset
782 // and continue (assuming there is no exception pending)
a61af66fc99e Initial load
duke
parents:
diff changeset
783 //
a61af66fc99e Initial load
duke
parents:
diff changeset
784 // compute continuation length
a61af66fc99e Initial load
duke
parents:
diff changeset
785 //
a61af66fc99e Initial load
duke
parents:
diff changeset
786 // Note: it is possible to deopt at a return_register_finalizer opcode
a61af66fc99e Initial load
duke
parents:
diff changeset
787 // because this requires entering the vm to do the registering. While the
a61af66fc99e Initial load
duke
parents:
diff changeset
788 // opcode is complete we can't advance because there are no more opcodes
a61af66fc99e Initial load
duke
parents:
diff changeset
789 // much like trying to deopt at a poll return. In that has we simply
a61af66fc99e Initial load
duke
parents:
diff changeset
790 // get out of here
a61af66fc99e Initial load
duke
parents:
diff changeset
791 //
a61af66fc99e Initial load
duke
parents:
diff changeset
792 if ( Bytecodes::code_at(pc, METHOD) == Bytecodes::_return_register_finalizer) {
a61af66fc99e Initial load
duke
parents:
diff changeset
793 // this will do the right thing even if an exception is pending.
a61af66fc99e Initial load
duke
parents:
diff changeset
794 goto handle_return;
a61af66fc99e Initial load
duke
parents:
diff changeset
795 }
a61af66fc99e Initial load
duke
parents:
diff changeset
796 UPDATE_PC(Bytecodes::length_at(pc));
a61af66fc99e Initial load
duke
parents:
diff changeset
797 if (THREAD->has_pending_exception()) goto handle_exception;
a61af66fc99e Initial load
duke
parents:
diff changeset
798 goto run;
a61af66fc99e Initial load
duke
parents:
diff changeset
799 }
a61af66fc99e Initial load
duke
parents:
diff changeset
800 case got_monitors: {
a61af66fc99e Initial load
duke
parents:
diff changeset
801 // continue locking now that we have a monitor to use
a61af66fc99e Initial load
duke
parents:
diff changeset
802 // we expect to find newly allocated monitor at the "top" of the monitor stack.
a61af66fc99e Initial load
duke
parents:
diff changeset
803 oop lockee = STACK_OBJECT(-1);
a61af66fc99e Initial load
duke
parents:
diff changeset
804 // derefing's lockee ought to provoke implicit null check
a61af66fc99e Initial load
duke
parents:
diff changeset
805 // find a free monitor
a61af66fc99e Initial load
duke
parents:
diff changeset
806 BasicObjectLock* entry = (BasicObjectLock*) istate->stack_base();
a61af66fc99e Initial load
duke
parents:
diff changeset
807 assert(entry->obj() == NULL, "Frame manager didn't allocate the monitor");
a61af66fc99e Initial load
duke
parents:
diff changeset
808 entry->set_obj(lockee);
a61af66fc99e Initial load
duke
parents:
diff changeset
809
a61af66fc99e Initial load
duke
parents:
diff changeset
810 markOop displaced = lockee->mark()->set_unlocked();
a61af66fc99e Initial load
duke
parents:
diff changeset
811 entry->lock()->set_displaced_header(displaced);
a61af66fc99e Initial load
duke
parents:
diff changeset
812 if (Atomic::cmpxchg_ptr(entry, lockee->mark_addr(), displaced) != displaced) {
a61af66fc99e Initial load
duke
parents:
diff changeset
813 // Is it simple recursive case?
a61af66fc99e Initial load
duke
parents:
diff changeset
814 if (THREAD->is_lock_owned((address) displaced->clear_lock_bits())) {
a61af66fc99e Initial load
duke
parents:
diff changeset
815 entry->lock()->set_displaced_header(NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
816 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
817 CALL_VM(InterpreterRuntime::monitorenter(THREAD, entry), handle_exception);
a61af66fc99e Initial load
duke
parents:
diff changeset
818 }
a61af66fc99e Initial load
duke
parents:
diff changeset
819 }
a61af66fc99e Initial load
duke
parents:
diff changeset
820 UPDATE_PC_AND_TOS(1, -1);
a61af66fc99e Initial load
duke
parents:
diff changeset
821 goto run;
a61af66fc99e Initial load
duke
parents:
diff changeset
822 }
a61af66fc99e Initial load
duke
parents:
diff changeset
823 default: {
a61af66fc99e Initial load
duke
parents:
diff changeset
824 fatal("Unexpected message from frame manager");
a61af66fc99e Initial load
duke
parents:
diff changeset
825 }
a61af66fc99e Initial load
duke
parents:
diff changeset
826 }
a61af66fc99e Initial load
duke
parents:
diff changeset
827
a61af66fc99e Initial load
duke
parents:
diff changeset
828 run:
a61af66fc99e Initial load
duke
parents:
diff changeset
829
a61af66fc99e Initial load
duke
parents:
diff changeset
830 DO_UPDATE_INSTRUCTION_COUNT(*pc)
a61af66fc99e Initial load
duke
parents:
diff changeset
831 DEBUGGER_SINGLE_STEP_NOTIFY();
a61af66fc99e Initial load
duke
parents:
diff changeset
832 #ifdef PREFETCH_OPCCODE
a61af66fc99e Initial load
duke
parents:
diff changeset
833 opcode = *pc; /* prefetch first opcode */
a61af66fc99e Initial load
duke
parents:
diff changeset
834 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
835
a61af66fc99e Initial load
duke
parents:
diff changeset
836 #ifndef USELABELS
a61af66fc99e Initial load
duke
parents:
diff changeset
837 while (1)
a61af66fc99e Initial load
duke
parents:
diff changeset
838 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
839 {
a61af66fc99e Initial load
duke
parents:
diff changeset
840 #ifndef PREFETCH_OPCCODE
a61af66fc99e Initial load
duke
parents:
diff changeset
841 opcode = *pc;
a61af66fc99e Initial load
duke
parents:
diff changeset
842 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
843 // Seems like this happens twice per opcode. At worst this is only
a61af66fc99e Initial load
duke
parents:
diff changeset
844 // need at entry to the loop.
a61af66fc99e Initial load
duke
parents:
diff changeset
845 // DEBUGGER_SINGLE_STEP_NOTIFY();
a61af66fc99e Initial load
duke
parents:
diff changeset
846 /* Using this labels avoids double breakpoints when quickening and
a61af66fc99e Initial load
duke
parents:
diff changeset
847 * when returing from transition frames.
a61af66fc99e Initial load
duke
parents:
diff changeset
848 */
a61af66fc99e Initial load
duke
parents:
diff changeset
849 opcode_switch:
a61af66fc99e Initial load
duke
parents:
diff changeset
850 assert(istate == orig, "Corrupted istate");
a61af66fc99e Initial load
duke
parents:
diff changeset
851 /* QQQ Hmm this has knowledge of direction, ought to be a stack method */
a61af66fc99e Initial load
duke
parents:
diff changeset
852 assert(topOfStack >= istate->stack_limit(), "Stack overrun");
a61af66fc99e Initial load
duke
parents:
diff changeset
853 assert(topOfStack < istate->stack_base(), "Stack underrun");
a61af66fc99e Initial load
duke
parents:
diff changeset
854
a61af66fc99e Initial load
duke
parents:
diff changeset
855 #ifdef USELABELS
a61af66fc99e Initial load
duke
parents:
diff changeset
856 DISPATCH(opcode);
a61af66fc99e Initial load
duke
parents:
diff changeset
857 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
858 switch (opcode)
a61af66fc99e Initial load
duke
parents:
diff changeset
859 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
860 {
a61af66fc99e Initial load
duke
parents:
diff changeset
861 CASE(_nop):
a61af66fc99e Initial load
duke
parents:
diff changeset
862 UPDATE_PC_AND_CONTINUE(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
863
a61af66fc99e Initial load
duke
parents:
diff changeset
864 /* Push miscellaneous constants onto the stack. */
a61af66fc99e Initial load
duke
parents:
diff changeset
865
a61af66fc99e Initial load
duke
parents:
diff changeset
866 CASE(_aconst_null):
a61af66fc99e Initial load
duke
parents:
diff changeset
867 SET_STACK_OBJECT(NULL, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
868 UPDATE_PC_AND_TOS_AND_CONTINUE(1, 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
869
a61af66fc99e Initial load
duke
parents:
diff changeset
870 #undef OPC_CONST_n
a61af66fc99e Initial load
duke
parents:
diff changeset
871 #define OPC_CONST_n(opcode, const_type, value) \
a61af66fc99e Initial load
duke
parents:
diff changeset
872 CASE(opcode): \
a61af66fc99e Initial load
duke
parents:
diff changeset
873 SET_STACK_ ## const_type(value, 0); \
a61af66fc99e Initial load
duke
parents:
diff changeset
874 UPDATE_PC_AND_TOS_AND_CONTINUE(1, 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
875
a61af66fc99e Initial load
duke
parents:
diff changeset
876 OPC_CONST_n(_iconst_m1, INT, -1);
a61af66fc99e Initial load
duke
parents:
diff changeset
877 OPC_CONST_n(_iconst_0, INT, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
878 OPC_CONST_n(_iconst_1, INT, 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
879 OPC_CONST_n(_iconst_2, INT, 2);
a61af66fc99e Initial load
duke
parents:
diff changeset
880 OPC_CONST_n(_iconst_3, INT, 3);
a61af66fc99e Initial load
duke
parents:
diff changeset
881 OPC_CONST_n(_iconst_4, INT, 4);
a61af66fc99e Initial load
duke
parents:
diff changeset
882 OPC_CONST_n(_iconst_5, INT, 5);
a61af66fc99e Initial load
duke
parents:
diff changeset
883 OPC_CONST_n(_fconst_0, FLOAT, 0.0);
a61af66fc99e Initial load
duke
parents:
diff changeset
884 OPC_CONST_n(_fconst_1, FLOAT, 1.0);
a61af66fc99e Initial load
duke
parents:
diff changeset
885 OPC_CONST_n(_fconst_2, FLOAT, 2.0);
a61af66fc99e Initial load
duke
parents:
diff changeset
886
a61af66fc99e Initial load
duke
parents:
diff changeset
887 #undef OPC_CONST2_n
a61af66fc99e Initial load
duke
parents:
diff changeset
888 #define OPC_CONST2_n(opcname, value, key, kind) \
a61af66fc99e Initial load
duke
parents:
diff changeset
889 CASE(_##opcname): \
a61af66fc99e Initial load
duke
parents:
diff changeset
890 { \
a61af66fc99e Initial load
duke
parents:
diff changeset
891 SET_STACK_ ## kind(VM##key##Const##value(), 1); \
a61af66fc99e Initial load
duke
parents:
diff changeset
892 UPDATE_PC_AND_TOS_AND_CONTINUE(1, 2); \
a61af66fc99e Initial load
duke
parents:
diff changeset
893 }
a61af66fc99e Initial load
duke
parents:
diff changeset
894 OPC_CONST2_n(dconst_0, Zero, double, DOUBLE);
a61af66fc99e Initial load
duke
parents:
diff changeset
895 OPC_CONST2_n(dconst_1, One, double, DOUBLE);
a61af66fc99e Initial load
duke
parents:
diff changeset
896 OPC_CONST2_n(lconst_0, Zero, long, LONG);
a61af66fc99e Initial load
duke
parents:
diff changeset
897 OPC_CONST2_n(lconst_1, One, long, LONG);
a61af66fc99e Initial load
duke
parents:
diff changeset
898
a61af66fc99e Initial load
duke
parents:
diff changeset
899 /* Load constant from constant pool: */
a61af66fc99e Initial load
duke
parents:
diff changeset
900
a61af66fc99e Initial load
duke
parents:
diff changeset
901 /* Push a 1-byte signed integer value onto the stack. */
a61af66fc99e Initial load
duke
parents:
diff changeset
902 CASE(_bipush):
a61af66fc99e Initial load
duke
parents:
diff changeset
903 SET_STACK_INT((jbyte)(pc[1]), 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
904 UPDATE_PC_AND_TOS_AND_CONTINUE(2, 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
905
a61af66fc99e Initial load
duke
parents:
diff changeset
906 /* Push a 2-byte signed integer constant onto the stack. */
a61af66fc99e Initial load
duke
parents:
diff changeset
907 CASE(_sipush):
a61af66fc99e Initial load
duke
parents:
diff changeset
908 SET_STACK_INT((int16_t)Bytes::get_Java_u2(pc + 1), 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
909 UPDATE_PC_AND_TOS_AND_CONTINUE(3, 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
910
a61af66fc99e Initial load
duke
parents:
diff changeset
911 /* load from local variable */
a61af66fc99e Initial load
duke
parents:
diff changeset
912
a61af66fc99e Initial load
duke
parents:
diff changeset
913 CASE(_aload):
a61af66fc99e Initial load
duke
parents:
diff changeset
914 SET_STACK_OBJECT(LOCALS_OBJECT(pc[1]), 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
915 UPDATE_PC_AND_TOS_AND_CONTINUE(2, 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
916
a61af66fc99e Initial load
duke
parents:
diff changeset
917 CASE(_iload):
a61af66fc99e Initial load
duke
parents:
diff changeset
918 CASE(_fload):
a61af66fc99e Initial load
duke
parents:
diff changeset
919 SET_STACK_SLOT(LOCALS_SLOT(pc[1]), 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
920 UPDATE_PC_AND_TOS_AND_CONTINUE(2, 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
921
a61af66fc99e Initial load
duke
parents:
diff changeset
922 CASE(_lload):
a61af66fc99e Initial load
duke
parents:
diff changeset
923 SET_STACK_LONG_FROM_ADDR(LOCALS_LONG_AT(pc[1]), 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
924 UPDATE_PC_AND_TOS_AND_CONTINUE(2, 2);
a61af66fc99e Initial load
duke
parents:
diff changeset
925
a61af66fc99e Initial load
duke
parents:
diff changeset
926 CASE(_dload):
a61af66fc99e Initial load
duke
parents:
diff changeset
927 SET_STACK_DOUBLE_FROM_ADDR(LOCALS_DOUBLE_AT(pc[1]), 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
928 UPDATE_PC_AND_TOS_AND_CONTINUE(2, 2);
a61af66fc99e Initial load
duke
parents:
diff changeset
929
a61af66fc99e Initial load
duke
parents:
diff changeset
930 #undef OPC_LOAD_n
a61af66fc99e Initial load
duke
parents:
diff changeset
931 #define OPC_LOAD_n(num) \
a61af66fc99e Initial load
duke
parents:
diff changeset
932 CASE(_aload_##num): \
a61af66fc99e Initial load
duke
parents:
diff changeset
933 SET_STACK_OBJECT(LOCALS_OBJECT(num), 0); \
a61af66fc99e Initial load
duke
parents:
diff changeset
934 UPDATE_PC_AND_TOS_AND_CONTINUE(1, 1); \
a61af66fc99e Initial load
duke
parents:
diff changeset
935 \
a61af66fc99e Initial load
duke
parents:
diff changeset
936 CASE(_iload_##num): \
a61af66fc99e Initial load
duke
parents:
diff changeset
937 CASE(_fload_##num): \
a61af66fc99e Initial load
duke
parents:
diff changeset
938 SET_STACK_SLOT(LOCALS_SLOT(num), 0); \
a61af66fc99e Initial load
duke
parents:
diff changeset
939 UPDATE_PC_AND_TOS_AND_CONTINUE(1, 1); \
a61af66fc99e Initial load
duke
parents:
diff changeset
940 \
a61af66fc99e Initial load
duke
parents:
diff changeset
941 CASE(_lload_##num): \
a61af66fc99e Initial load
duke
parents:
diff changeset
942 SET_STACK_LONG_FROM_ADDR(LOCALS_LONG_AT(num), 1); \
a61af66fc99e Initial load
duke
parents:
diff changeset
943 UPDATE_PC_AND_TOS_AND_CONTINUE(1, 2); \
a61af66fc99e Initial load
duke
parents:
diff changeset
944 CASE(_dload_##num): \
a61af66fc99e Initial load
duke
parents:
diff changeset
945 SET_STACK_DOUBLE_FROM_ADDR(LOCALS_DOUBLE_AT(num), 1); \
a61af66fc99e Initial load
duke
parents:
diff changeset
946 UPDATE_PC_AND_TOS_AND_CONTINUE(1, 2);
a61af66fc99e Initial load
duke
parents:
diff changeset
947
a61af66fc99e Initial load
duke
parents:
diff changeset
948 OPC_LOAD_n(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
949 OPC_LOAD_n(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
950 OPC_LOAD_n(2);
a61af66fc99e Initial load
duke
parents:
diff changeset
951 OPC_LOAD_n(3);
a61af66fc99e Initial load
duke
parents:
diff changeset
952
a61af66fc99e Initial load
duke
parents:
diff changeset
953 /* store to a local variable */
a61af66fc99e Initial load
duke
parents:
diff changeset
954
a61af66fc99e Initial load
duke
parents:
diff changeset
955 CASE(_astore):
a61af66fc99e Initial load
duke
parents:
diff changeset
956 astore(topOfStack, -1, locals, pc[1]);
a61af66fc99e Initial load
duke
parents:
diff changeset
957 UPDATE_PC_AND_TOS_AND_CONTINUE(2, -1);
a61af66fc99e Initial load
duke
parents:
diff changeset
958
a61af66fc99e Initial load
duke
parents:
diff changeset
959 CASE(_istore):
a61af66fc99e Initial load
duke
parents:
diff changeset
960 CASE(_fstore):
a61af66fc99e Initial load
duke
parents:
diff changeset
961 SET_LOCALS_SLOT(STACK_SLOT(-1), pc[1]);
a61af66fc99e Initial load
duke
parents:
diff changeset
962 UPDATE_PC_AND_TOS_AND_CONTINUE(2, -1);
a61af66fc99e Initial load
duke
parents:
diff changeset
963
a61af66fc99e Initial load
duke
parents:
diff changeset
964 CASE(_lstore):
a61af66fc99e Initial load
duke
parents:
diff changeset
965 SET_LOCALS_LONG(STACK_LONG(-1), pc[1]);
a61af66fc99e Initial load
duke
parents:
diff changeset
966 UPDATE_PC_AND_TOS_AND_CONTINUE(2, -2);
a61af66fc99e Initial load
duke
parents:
diff changeset
967
a61af66fc99e Initial load
duke
parents:
diff changeset
968 CASE(_dstore):
a61af66fc99e Initial load
duke
parents:
diff changeset
969 SET_LOCALS_DOUBLE(STACK_DOUBLE(-1), pc[1]);
a61af66fc99e Initial load
duke
parents:
diff changeset
970 UPDATE_PC_AND_TOS_AND_CONTINUE(2, -2);
a61af66fc99e Initial load
duke
parents:
diff changeset
971
a61af66fc99e Initial load
duke
parents:
diff changeset
972 CASE(_wide): {
a61af66fc99e Initial load
duke
parents:
diff changeset
973 uint16_t reg = Bytes::get_Java_u2(pc + 2);
a61af66fc99e Initial load
duke
parents:
diff changeset
974
a61af66fc99e Initial load
duke
parents:
diff changeset
975 opcode = pc[1];
a61af66fc99e Initial load
duke
parents:
diff changeset
976 switch(opcode) {
a61af66fc99e Initial load
duke
parents:
diff changeset
977 case Bytecodes::_aload:
a61af66fc99e Initial load
duke
parents:
diff changeset
978 SET_STACK_OBJECT(LOCALS_OBJECT(reg), 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
979 UPDATE_PC_AND_TOS_AND_CONTINUE(4, 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
980
a61af66fc99e Initial load
duke
parents:
diff changeset
981 case Bytecodes::_iload:
a61af66fc99e Initial load
duke
parents:
diff changeset
982 case Bytecodes::_fload:
a61af66fc99e Initial load
duke
parents:
diff changeset
983 SET_STACK_SLOT(LOCALS_SLOT(reg), 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
984 UPDATE_PC_AND_TOS_AND_CONTINUE(4, 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
985
a61af66fc99e Initial load
duke
parents:
diff changeset
986 case Bytecodes::_lload:
a61af66fc99e Initial load
duke
parents:
diff changeset
987 SET_STACK_LONG_FROM_ADDR(LOCALS_LONG_AT(reg), 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
988 UPDATE_PC_AND_TOS_AND_CONTINUE(4, 2);
a61af66fc99e Initial load
duke
parents:
diff changeset
989
a61af66fc99e Initial load
duke
parents:
diff changeset
990 case Bytecodes::_dload:
a61af66fc99e Initial load
duke
parents:
diff changeset
991 SET_STACK_DOUBLE_FROM_ADDR(LOCALS_LONG_AT(reg), 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
992 UPDATE_PC_AND_TOS_AND_CONTINUE(4, 2);
a61af66fc99e Initial load
duke
parents:
diff changeset
993
a61af66fc99e Initial load
duke
parents:
diff changeset
994 case Bytecodes::_astore:
a61af66fc99e Initial load
duke
parents:
diff changeset
995 astore(topOfStack, -1, locals, reg);
a61af66fc99e Initial load
duke
parents:
diff changeset
996 UPDATE_PC_AND_TOS_AND_CONTINUE(4, -1);
a61af66fc99e Initial load
duke
parents:
diff changeset
997
a61af66fc99e Initial load
duke
parents:
diff changeset
998 case Bytecodes::_istore:
a61af66fc99e Initial load
duke
parents:
diff changeset
999 case Bytecodes::_fstore:
a61af66fc99e Initial load
duke
parents:
diff changeset
1000 SET_LOCALS_SLOT(STACK_SLOT(-1), reg);
a61af66fc99e Initial load
duke
parents:
diff changeset
1001 UPDATE_PC_AND_TOS_AND_CONTINUE(4, -1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1002
a61af66fc99e Initial load
duke
parents:
diff changeset
1003 case Bytecodes::_lstore:
a61af66fc99e Initial load
duke
parents:
diff changeset
1004 SET_LOCALS_LONG(STACK_LONG(-1), reg);
a61af66fc99e Initial load
duke
parents:
diff changeset
1005 UPDATE_PC_AND_TOS_AND_CONTINUE(4, -2);
a61af66fc99e Initial load
duke
parents:
diff changeset
1006
a61af66fc99e Initial load
duke
parents:
diff changeset
1007 case Bytecodes::_dstore:
a61af66fc99e Initial load
duke
parents:
diff changeset
1008 SET_LOCALS_DOUBLE(STACK_DOUBLE(-1), reg);
a61af66fc99e Initial load
duke
parents:
diff changeset
1009 UPDATE_PC_AND_TOS_AND_CONTINUE(4, -2);
a61af66fc99e Initial load
duke
parents:
diff changeset
1010
a61af66fc99e Initial load
duke
parents:
diff changeset
1011 case Bytecodes::_iinc: {
a61af66fc99e Initial load
duke
parents:
diff changeset
1012 int16_t offset = (int16_t)Bytes::get_Java_u2(pc+4);
a61af66fc99e Initial load
duke
parents:
diff changeset
1013 // Be nice to see what this generates.... QQQ
a61af66fc99e Initial load
duke
parents:
diff changeset
1014 SET_LOCALS_INT(LOCALS_INT(reg) + offset, reg);
a61af66fc99e Initial load
duke
parents:
diff changeset
1015 UPDATE_PC_AND_CONTINUE(6);
a61af66fc99e Initial load
duke
parents:
diff changeset
1016 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1017 case Bytecodes::_ret:
a61af66fc99e Initial load
duke
parents:
diff changeset
1018 pc = istate->method()->code_base() + (intptr_t)(LOCALS_ADDR(reg));
a61af66fc99e Initial load
duke
parents:
diff changeset
1019 UPDATE_PC_AND_CONTINUE(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1020 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
1021 VM_JAVA_ERROR(vmSymbols::java_lang_InternalError(), "undefined opcode");
a61af66fc99e Initial load
duke
parents:
diff changeset
1022 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1023 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1024
a61af66fc99e Initial load
duke
parents:
diff changeset
1025
a61af66fc99e Initial load
duke
parents:
diff changeset
1026 #undef OPC_STORE_n
a61af66fc99e Initial load
duke
parents:
diff changeset
1027 #define OPC_STORE_n(num) \
a61af66fc99e Initial load
duke
parents:
diff changeset
1028 CASE(_astore_##num): \
a61af66fc99e Initial load
duke
parents:
diff changeset
1029 astore(topOfStack, -1, locals, num); \
a61af66fc99e Initial load
duke
parents:
diff changeset
1030 UPDATE_PC_AND_TOS_AND_CONTINUE(1, -1); \
a61af66fc99e Initial load
duke
parents:
diff changeset
1031 CASE(_istore_##num): \
a61af66fc99e Initial load
duke
parents:
diff changeset
1032 CASE(_fstore_##num): \
a61af66fc99e Initial load
duke
parents:
diff changeset
1033 SET_LOCALS_SLOT(STACK_SLOT(-1), num); \
a61af66fc99e Initial load
duke
parents:
diff changeset
1034 UPDATE_PC_AND_TOS_AND_CONTINUE(1, -1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1035
a61af66fc99e Initial load
duke
parents:
diff changeset
1036 OPC_STORE_n(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1037 OPC_STORE_n(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1038 OPC_STORE_n(2);
a61af66fc99e Initial load
duke
parents:
diff changeset
1039 OPC_STORE_n(3);
a61af66fc99e Initial load
duke
parents:
diff changeset
1040
a61af66fc99e Initial load
duke
parents:
diff changeset
1041 #undef OPC_DSTORE_n
a61af66fc99e Initial load
duke
parents:
diff changeset
1042 #define OPC_DSTORE_n(num) \
a61af66fc99e Initial load
duke
parents:
diff changeset
1043 CASE(_dstore_##num): \
a61af66fc99e Initial load
duke
parents:
diff changeset
1044 SET_LOCALS_DOUBLE(STACK_DOUBLE(-1), num); \
a61af66fc99e Initial load
duke
parents:
diff changeset
1045 UPDATE_PC_AND_TOS_AND_CONTINUE(1, -2); \
a61af66fc99e Initial load
duke
parents:
diff changeset
1046 CASE(_lstore_##num): \
a61af66fc99e Initial load
duke
parents:
diff changeset
1047 SET_LOCALS_LONG(STACK_LONG(-1), num); \
a61af66fc99e Initial load
duke
parents:
diff changeset
1048 UPDATE_PC_AND_TOS_AND_CONTINUE(1, -2);
a61af66fc99e Initial load
duke
parents:
diff changeset
1049
a61af66fc99e Initial load
duke
parents:
diff changeset
1050 OPC_DSTORE_n(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1051 OPC_DSTORE_n(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1052 OPC_DSTORE_n(2);
a61af66fc99e Initial load
duke
parents:
diff changeset
1053 OPC_DSTORE_n(3);
a61af66fc99e Initial load
duke
parents:
diff changeset
1054
a61af66fc99e Initial load
duke
parents:
diff changeset
1055 /* stack pop, dup, and insert opcodes */
a61af66fc99e Initial load
duke
parents:
diff changeset
1056
a61af66fc99e Initial load
duke
parents:
diff changeset
1057
a61af66fc99e Initial load
duke
parents:
diff changeset
1058 CASE(_pop): /* Discard the top item on the stack */
a61af66fc99e Initial load
duke
parents:
diff changeset
1059 UPDATE_PC_AND_TOS_AND_CONTINUE(1, -1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1060
a61af66fc99e Initial load
duke
parents:
diff changeset
1061
a61af66fc99e Initial load
duke
parents:
diff changeset
1062 CASE(_pop2): /* Discard the top 2 items on the stack */
a61af66fc99e Initial load
duke
parents:
diff changeset
1063 UPDATE_PC_AND_TOS_AND_CONTINUE(1, -2);
a61af66fc99e Initial load
duke
parents:
diff changeset
1064
a61af66fc99e Initial load
duke
parents:
diff changeset
1065
a61af66fc99e Initial load
duke
parents:
diff changeset
1066 CASE(_dup): /* Duplicate the top item on the stack */
a61af66fc99e Initial load
duke
parents:
diff changeset
1067 dup(topOfStack);
a61af66fc99e Initial load
duke
parents:
diff changeset
1068 UPDATE_PC_AND_TOS_AND_CONTINUE(1, 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1069
a61af66fc99e Initial load
duke
parents:
diff changeset
1070 CASE(_dup2): /* Duplicate the top 2 items on the stack */
a61af66fc99e Initial load
duke
parents:
diff changeset
1071 dup2(topOfStack);
a61af66fc99e Initial load
duke
parents:
diff changeset
1072 UPDATE_PC_AND_TOS_AND_CONTINUE(1, 2);
a61af66fc99e Initial load
duke
parents:
diff changeset
1073
a61af66fc99e Initial load
duke
parents:
diff changeset
1074 CASE(_dup_x1): /* insert top word two down */
a61af66fc99e Initial load
duke
parents:
diff changeset
1075 dup_x1(topOfStack);
a61af66fc99e Initial load
duke
parents:
diff changeset
1076 UPDATE_PC_AND_TOS_AND_CONTINUE(1, 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1077
a61af66fc99e Initial load
duke
parents:
diff changeset
1078 CASE(_dup_x2): /* insert top word three down */
a61af66fc99e Initial load
duke
parents:
diff changeset
1079 dup_x2(topOfStack);
a61af66fc99e Initial load
duke
parents:
diff changeset
1080 UPDATE_PC_AND_TOS_AND_CONTINUE(1, 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1081
a61af66fc99e Initial load
duke
parents:
diff changeset
1082 CASE(_dup2_x1): /* insert top 2 slots three down */
a61af66fc99e Initial load
duke
parents:
diff changeset
1083 dup2_x1(topOfStack);
a61af66fc99e Initial load
duke
parents:
diff changeset
1084 UPDATE_PC_AND_TOS_AND_CONTINUE(1, 2);
a61af66fc99e Initial load
duke
parents:
diff changeset
1085
a61af66fc99e Initial load
duke
parents:
diff changeset
1086 CASE(_dup2_x2): /* insert top 2 slots four down */
a61af66fc99e Initial load
duke
parents:
diff changeset
1087 dup2_x2(topOfStack);
a61af66fc99e Initial load
duke
parents:
diff changeset
1088 UPDATE_PC_AND_TOS_AND_CONTINUE(1, 2);
a61af66fc99e Initial load
duke
parents:
diff changeset
1089
a61af66fc99e Initial load
duke
parents:
diff changeset
1090 CASE(_swap): { /* swap top two elements on the stack */
a61af66fc99e Initial load
duke
parents:
diff changeset
1091 swap(topOfStack);
a61af66fc99e Initial load
duke
parents:
diff changeset
1092 UPDATE_PC_AND_CONTINUE(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1093 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1094
a61af66fc99e Initial load
duke
parents:
diff changeset
1095 /* Perform various binary integer operations */
a61af66fc99e Initial load
duke
parents:
diff changeset
1096
a61af66fc99e Initial load
duke
parents:
diff changeset
1097 #undef OPC_INT_BINARY
a61af66fc99e Initial load
duke
parents:
diff changeset
1098 #define OPC_INT_BINARY(opcname, opname, test) \
a61af66fc99e Initial load
duke
parents:
diff changeset
1099 CASE(_i##opcname): \
a61af66fc99e Initial load
duke
parents:
diff changeset
1100 if (test && (STACK_INT(-1) == 0)) { \
a61af66fc99e Initial load
duke
parents:
diff changeset
1101 VM_JAVA_ERROR(vmSymbols::java_lang_ArithmeticException(), \
a61af66fc99e Initial load
duke
parents:
diff changeset
1102 "/ by int zero"); \
a61af66fc99e Initial load
duke
parents:
diff changeset
1103 } \
a61af66fc99e Initial load
duke
parents:
diff changeset
1104 SET_STACK_INT(VMint##opname(STACK_INT(-2), \
a61af66fc99e Initial load
duke
parents:
diff changeset
1105 STACK_INT(-1)), \
a61af66fc99e Initial load
duke
parents:
diff changeset
1106 -2); \
a61af66fc99e Initial load
duke
parents:
diff changeset
1107 UPDATE_PC_AND_TOS_AND_CONTINUE(1, -1); \
a61af66fc99e Initial load
duke
parents:
diff changeset
1108 CASE(_l##opcname): \
a61af66fc99e Initial load
duke
parents:
diff changeset
1109 { \
a61af66fc99e Initial load
duke
parents:
diff changeset
1110 if (test) { \
a61af66fc99e Initial load
duke
parents:
diff changeset
1111 jlong l1 = STACK_LONG(-1); \
a61af66fc99e Initial load
duke
parents:
diff changeset
1112 if (VMlongEqz(l1)) { \
a61af66fc99e Initial load
duke
parents:
diff changeset
1113 VM_JAVA_ERROR(vmSymbols::java_lang_ArithmeticException(), \
a61af66fc99e Initial load
duke
parents:
diff changeset
1114 "/ by long zero"); \
a61af66fc99e Initial load
duke
parents:
diff changeset
1115 } \
a61af66fc99e Initial load
duke
parents:
diff changeset
1116 } \
a61af66fc99e Initial load
duke
parents:
diff changeset
1117 /* First long at (-1,-2) next long at (-3,-4) */ \
a61af66fc99e Initial load
duke
parents:
diff changeset
1118 SET_STACK_LONG(VMlong##opname(STACK_LONG(-3), \
a61af66fc99e Initial load
duke
parents:
diff changeset
1119 STACK_LONG(-1)), \
a61af66fc99e Initial load
duke
parents:
diff changeset
1120 -3); \
a61af66fc99e Initial load
duke
parents:
diff changeset
1121 UPDATE_PC_AND_TOS_AND_CONTINUE(1, -2); \
a61af66fc99e Initial load
duke
parents:
diff changeset
1122 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1123
a61af66fc99e Initial load
duke
parents:
diff changeset
1124 OPC_INT_BINARY(add, Add, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1125 OPC_INT_BINARY(sub, Sub, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1126 OPC_INT_BINARY(mul, Mul, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1127 OPC_INT_BINARY(and, And, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1128 OPC_INT_BINARY(or, Or, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1129 OPC_INT_BINARY(xor, Xor, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1130 OPC_INT_BINARY(div, Div, 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1131 OPC_INT_BINARY(rem, Rem, 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1132
a61af66fc99e Initial load
duke
parents:
diff changeset
1133
a61af66fc99e Initial load
duke
parents:
diff changeset
1134 /* Perform various binary floating number operations */
a61af66fc99e Initial load
duke
parents:
diff changeset
1135 /* On some machine/platforms/compilers div zero check can be implicit */
a61af66fc99e Initial load
duke
parents:
diff changeset
1136
a61af66fc99e Initial load
duke
parents:
diff changeset
1137 #undef OPC_FLOAT_BINARY
a61af66fc99e Initial load
duke
parents:
diff changeset
1138 #define OPC_FLOAT_BINARY(opcname, opname) \
a61af66fc99e Initial load
duke
parents:
diff changeset
1139 CASE(_d##opcname): { \
a61af66fc99e Initial load
duke
parents:
diff changeset
1140 SET_STACK_DOUBLE(VMdouble##opname(STACK_DOUBLE(-3), \
a61af66fc99e Initial load
duke
parents:
diff changeset
1141 STACK_DOUBLE(-1)), \
a61af66fc99e Initial load
duke
parents:
diff changeset
1142 -3); \
a61af66fc99e Initial load
duke
parents:
diff changeset
1143 UPDATE_PC_AND_TOS_AND_CONTINUE(1, -2); \
a61af66fc99e Initial load
duke
parents:
diff changeset
1144 } \
a61af66fc99e Initial load
duke
parents:
diff changeset
1145 CASE(_f##opcname): \
a61af66fc99e Initial load
duke
parents:
diff changeset
1146 SET_STACK_FLOAT(VMfloat##opname(STACK_FLOAT(-2), \
a61af66fc99e Initial load
duke
parents:
diff changeset
1147 STACK_FLOAT(-1)), \
a61af66fc99e Initial load
duke
parents:
diff changeset
1148 -2); \
a61af66fc99e Initial load
duke
parents:
diff changeset
1149 UPDATE_PC_AND_TOS_AND_CONTINUE(1, -1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1150
a61af66fc99e Initial load
duke
parents:
diff changeset
1151
a61af66fc99e Initial load
duke
parents:
diff changeset
1152 OPC_FLOAT_BINARY(add, Add);
a61af66fc99e Initial load
duke
parents:
diff changeset
1153 OPC_FLOAT_BINARY(sub, Sub);
a61af66fc99e Initial load
duke
parents:
diff changeset
1154 OPC_FLOAT_BINARY(mul, Mul);
a61af66fc99e Initial load
duke
parents:
diff changeset
1155 OPC_FLOAT_BINARY(div, Div);
a61af66fc99e Initial load
duke
parents:
diff changeset
1156 OPC_FLOAT_BINARY(rem, Rem);
a61af66fc99e Initial load
duke
parents:
diff changeset
1157
a61af66fc99e Initial load
duke
parents:
diff changeset
1158 /* Shift operations
a61af66fc99e Initial load
duke
parents:
diff changeset
1159 * Shift left int and long: ishl, lshl
a61af66fc99e Initial load
duke
parents:
diff changeset
1160 * Logical shift right int and long w/zero extension: iushr, lushr
a61af66fc99e Initial load
duke
parents:
diff changeset
1161 * Arithmetic shift right int and long w/sign extension: ishr, lshr
a61af66fc99e Initial load
duke
parents:
diff changeset
1162 */
a61af66fc99e Initial load
duke
parents:
diff changeset
1163
a61af66fc99e Initial load
duke
parents:
diff changeset
1164 #undef OPC_SHIFT_BINARY
a61af66fc99e Initial load
duke
parents:
diff changeset
1165 #define OPC_SHIFT_BINARY(opcname, opname) \
a61af66fc99e Initial load
duke
parents:
diff changeset
1166 CASE(_i##opcname): \
a61af66fc99e Initial load
duke
parents:
diff changeset
1167 SET_STACK_INT(VMint##opname(STACK_INT(-2), \
a61af66fc99e Initial load
duke
parents:
diff changeset
1168 STACK_INT(-1)), \
a61af66fc99e Initial load
duke
parents:
diff changeset
1169 -2); \
a61af66fc99e Initial load
duke
parents:
diff changeset
1170 UPDATE_PC_AND_TOS_AND_CONTINUE(1, -1); \
a61af66fc99e Initial load
duke
parents:
diff changeset
1171 CASE(_l##opcname): \
a61af66fc99e Initial load
duke
parents:
diff changeset
1172 { \
a61af66fc99e Initial load
duke
parents:
diff changeset
1173 SET_STACK_LONG(VMlong##opname(STACK_LONG(-2), \
a61af66fc99e Initial load
duke
parents:
diff changeset
1174 STACK_INT(-1)), \
a61af66fc99e Initial load
duke
parents:
diff changeset
1175 -2); \
a61af66fc99e Initial load
duke
parents:
diff changeset
1176 UPDATE_PC_AND_TOS_AND_CONTINUE(1, -1); \
a61af66fc99e Initial load
duke
parents:
diff changeset
1177 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1178
a61af66fc99e Initial load
duke
parents:
diff changeset
1179 OPC_SHIFT_BINARY(shl, Shl);
a61af66fc99e Initial load
duke
parents:
diff changeset
1180 OPC_SHIFT_BINARY(shr, Shr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1181 OPC_SHIFT_BINARY(ushr, Ushr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1182
a61af66fc99e Initial load
duke
parents:
diff changeset
1183 /* Increment local variable by constant */
a61af66fc99e Initial load
duke
parents:
diff changeset
1184 CASE(_iinc):
a61af66fc99e Initial load
duke
parents:
diff changeset
1185 {
a61af66fc99e Initial load
duke
parents:
diff changeset
1186 // locals[pc[1]].j.i += (jbyte)(pc[2]);
a61af66fc99e Initial load
duke
parents:
diff changeset
1187 SET_LOCALS_INT(LOCALS_INT(pc[1]) + (jbyte)(pc[2]), pc[1]);
a61af66fc99e Initial load
duke
parents:
diff changeset
1188 UPDATE_PC_AND_CONTINUE(3);
a61af66fc99e Initial load
duke
parents:
diff changeset
1189 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1190
a61af66fc99e Initial load
duke
parents:
diff changeset
1191 /* negate the value on the top of the stack */
a61af66fc99e Initial load
duke
parents:
diff changeset
1192
a61af66fc99e Initial load
duke
parents:
diff changeset
1193 CASE(_ineg):
a61af66fc99e Initial load
duke
parents:
diff changeset
1194 SET_STACK_INT(VMintNeg(STACK_INT(-1)), -1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1195 UPDATE_PC_AND_CONTINUE(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1196
a61af66fc99e Initial load
duke
parents:
diff changeset
1197 CASE(_fneg):
a61af66fc99e Initial load
duke
parents:
diff changeset
1198 SET_STACK_FLOAT(VMfloatNeg(STACK_FLOAT(-1)), -1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1199 UPDATE_PC_AND_CONTINUE(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1200
a61af66fc99e Initial load
duke
parents:
diff changeset
1201 CASE(_lneg):
a61af66fc99e Initial load
duke
parents:
diff changeset
1202 {
a61af66fc99e Initial load
duke
parents:
diff changeset
1203 SET_STACK_LONG(VMlongNeg(STACK_LONG(-1)), -1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1204 UPDATE_PC_AND_CONTINUE(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1205 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1206
a61af66fc99e Initial load
duke
parents:
diff changeset
1207 CASE(_dneg):
a61af66fc99e Initial load
duke
parents:
diff changeset
1208 {
a61af66fc99e Initial load
duke
parents:
diff changeset
1209 SET_STACK_DOUBLE(VMdoubleNeg(STACK_DOUBLE(-1)), -1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1210 UPDATE_PC_AND_CONTINUE(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1211 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1212
a61af66fc99e Initial load
duke
parents:
diff changeset
1213 /* Conversion operations */
a61af66fc99e Initial load
duke
parents:
diff changeset
1214
a61af66fc99e Initial load
duke
parents:
diff changeset
1215 CASE(_i2f): /* convert top of stack int to float */
a61af66fc99e Initial load
duke
parents:
diff changeset
1216 SET_STACK_FLOAT(VMint2Float(STACK_INT(-1)), -1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1217 UPDATE_PC_AND_CONTINUE(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1218
a61af66fc99e Initial load
duke
parents:
diff changeset
1219 CASE(_i2l): /* convert top of stack int to long */
a61af66fc99e Initial load
duke
parents:
diff changeset
1220 {
a61af66fc99e Initial load
duke
parents:
diff changeset
1221 // this is ugly QQQ
a61af66fc99e Initial load
duke
parents:
diff changeset
1222 jlong r = VMint2Long(STACK_INT(-1));
a61af66fc99e Initial load
duke
parents:
diff changeset
1223 MORE_STACK(-1); // Pop
a61af66fc99e Initial load
duke
parents:
diff changeset
1224 SET_STACK_LONG(r, 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1225
a61af66fc99e Initial load
duke
parents:
diff changeset
1226 UPDATE_PC_AND_TOS_AND_CONTINUE(1, 2);
a61af66fc99e Initial load
duke
parents:
diff changeset
1227 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1228
a61af66fc99e Initial load
duke
parents:
diff changeset
1229 CASE(_i2d): /* convert top of stack int to double */
a61af66fc99e Initial load
duke
parents:
diff changeset
1230 {
a61af66fc99e Initial load
duke
parents:
diff changeset
1231 // this is ugly QQQ (why cast to jlong?? )
a61af66fc99e Initial load
duke
parents:
diff changeset
1232 jdouble r = (jlong)STACK_INT(-1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1233 MORE_STACK(-1); // Pop
a61af66fc99e Initial load
duke
parents:
diff changeset
1234 SET_STACK_DOUBLE(r, 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1235
a61af66fc99e Initial load
duke
parents:
diff changeset
1236 UPDATE_PC_AND_TOS_AND_CONTINUE(1, 2);
a61af66fc99e Initial load
duke
parents:
diff changeset
1237 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1238
a61af66fc99e Initial load
duke
parents:
diff changeset
1239 CASE(_l2i): /* convert top of stack long to int */
a61af66fc99e Initial load
duke
parents:
diff changeset
1240 {
a61af66fc99e Initial load
duke
parents:
diff changeset
1241 jint r = VMlong2Int(STACK_LONG(-1));
a61af66fc99e Initial load
duke
parents:
diff changeset
1242 MORE_STACK(-2); // Pop
a61af66fc99e Initial load
duke
parents:
diff changeset
1243 SET_STACK_INT(r, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1244 UPDATE_PC_AND_TOS_AND_CONTINUE(1, 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1245 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1246
a61af66fc99e Initial load
duke
parents:
diff changeset
1247 CASE(_l2f): /* convert top of stack long to float */
a61af66fc99e Initial load
duke
parents:
diff changeset
1248 {
a61af66fc99e Initial load
duke
parents:
diff changeset
1249 jlong r = STACK_LONG(-1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1250 MORE_STACK(-2); // Pop
a61af66fc99e Initial load
duke
parents:
diff changeset
1251 SET_STACK_FLOAT(VMlong2Float(r), 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1252 UPDATE_PC_AND_TOS_AND_CONTINUE(1, 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1253 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1254
a61af66fc99e Initial load
duke
parents:
diff changeset
1255 CASE(_l2d): /* convert top of stack long to double */
a61af66fc99e Initial load
duke
parents:
diff changeset
1256 {
a61af66fc99e Initial load
duke
parents:
diff changeset
1257 jlong r = STACK_LONG(-1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1258 MORE_STACK(-2); // Pop
a61af66fc99e Initial load
duke
parents:
diff changeset
1259 SET_STACK_DOUBLE(VMlong2Double(r), 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1260 UPDATE_PC_AND_TOS_AND_CONTINUE(1, 2);
a61af66fc99e Initial load
duke
parents:
diff changeset
1261 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1262
a61af66fc99e Initial load
duke
parents:
diff changeset
1263 CASE(_f2i): /* Convert top of stack float to int */
a61af66fc99e Initial load
duke
parents:
diff changeset
1264 SET_STACK_INT(SharedRuntime::f2i(STACK_FLOAT(-1)), -1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1265 UPDATE_PC_AND_CONTINUE(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1266
a61af66fc99e Initial load
duke
parents:
diff changeset
1267 CASE(_f2l): /* convert top of stack float to long */
a61af66fc99e Initial load
duke
parents:
diff changeset
1268 {
a61af66fc99e Initial load
duke
parents:
diff changeset
1269 jlong r = SharedRuntime::f2l(STACK_FLOAT(-1));
a61af66fc99e Initial load
duke
parents:
diff changeset
1270 MORE_STACK(-1); // POP
a61af66fc99e Initial load
duke
parents:
diff changeset
1271 SET_STACK_LONG(r, 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1272 UPDATE_PC_AND_TOS_AND_CONTINUE(1, 2);
a61af66fc99e Initial load
duke
parents:
diff changeset
1273 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1274
a61af66fc99e Initial load
duke
parents:
diff changeset
1275 CASE(_f2d): /* convert top of stack float to double */
a61af66fc99e Initial load
duke
parents:
diff changeset
1276 {
a61af66fc99e Initial load
duke
parents:
diff changeset
1277 jfloat f;
a61af66fc99e Initial load
duke
parents:
diff changeset
1278 jdouble r;
a61af66fc99e Initial load
duke
parents:
diff changeset
1279 f = STACK_FLOAT(-1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1280 r = (jdouble) f;
a61af66fc99e Initial load
duke
parents:
diff changeset
1281 MORE_STACK(-1); // POP
a61af66fc99e Initial load
duke
parents:
diff changeset
1282 SET_STACK_DOUBLE(r, 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1283 UPDATE_PC_AND_TOS_AND_CONTINUE(1, 2);
a61af66fc99e Initial load
duke
parents:
diff changeset
1284 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1285
a61af66fc99e Initial load
duke
parents:
diff changeset
1286 CASE(_d2i): /* convert top of stack double to int */
a61af66fc99e Initial load
duke
parents:
diff changeset
1287 {
a61af66fc99e Initial load
duke
parents:
diff changeset
1288 jint r1 = SharedRuntime::d2i(STACK_DOUBLE(-1));
a61af66fc99e Initial load
duke
parents:
diff changeset
1289 MORE_STACK(-2);
a61af66fc99e Initial load
duke
parents:
diff changeset
1290 SET_STACK_INT(r1, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1291 UPDATE_PC_AND_TOS_AND_CONTINUE(1, 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1292 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1293
a61af66fc99e Initial load
duke
parents:
diff changeset
1294 CASE(_d2f): /* convert top of stack double to float */
a61af66fc99e Initial load
duke
parents:
diff changeset
1295 {
a61af66fc99e Initial load
duke
parents:
diff changeset
1296 jfloat r1 = VMdouble2Float(STACK_DOUBLE(-1));
a61af66fc99e Initial load
duke
parents:
diff changeset
1297 MORE_STACK(-2);
a61af66fc99e Initial load
duke
parents:
diff changeset
1298 SET_STACK_FLOAT(r1, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1299 UPDATE_PC_AND_TOS_AND_CONTINUE(1, 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1300 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1301
a61af66fc99e Initial load
duke
parents:
diff changeset
1302 CASE(_d2l): /* convert top of stack double to long */
a61af66fc99e Initial load
duke
parents:
diff changeset
1303 {
a61af66fc99e Initial load
duke
parents:
diff changeset
1304 jlong r1 = SharedRuntime::d2l(STACK_DOUBLE(-1));
a61af66fc99e Initial load
duke
parents:
diff changeset
1305 MORE_STACK(-2);
a61af66fc99e Initial load
duke
parents:
diff changeset
1306 SET_STACK_LONG(r1, 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1307 UPDATE_PC_AND_TOS_AND_CONTINUE(1, 2);
a61af66fc99e Initial load
duke
parents:
diff changeset
1308 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1309
a61af66fc99e Initial load
duke
parents:
diff changeset
1310 CASE(_i2b):
a61af66fc99e Initial load
duke
parents:
diff changeset
1311 SET_STACK_INT(VMint2Byte(STACK_INT(-1)), -1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1312 UPDATE_PC_AND_CONTINUE(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1313
a61af66fc99e Initial load
duke
parents:
diff changeset
1314 CASE(_i2c):
a61af66fc99e Initial load
duke
parents:
diff changeset
1315 SET_STACK_INT(VMint2Char(STACK_INT(-1)), -1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1316 UPDATE_PC_AND_CONTINUE(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1317
a61af66fc99e Initial load
duke
parents:
diff changeset
1318 CASE(_i2s):
a61af66fc99e Initial load
duke
parents:
diff changeset
1319 SET_STACK_INT(VMint2Short(STACK_INT(-1)), -1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1320 UPDATE_PC_AND_CONTINUE(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1321
a61af66fc99e Initial load
duke
parents:
diff changeset
1322 /* comparison operators */
a61af66fc99e Initial load
duke
parents:
diff changeset
1323
a61af66fc99e Initial load
duke
parents:
diff changeset
1324
a61af66fc99e Initial load
duke
parents:
diff changeset
1325 #define COMPARISON_OP(name, comparison) \
a61af66fc99e Initial load
duke
parents:
diff changeset
1326 CASE(_if_icmp##name): { \
a61af66fc99e Initial load
duke
parents:
diff changeset
1327 int skip = (STACK_INT(-2) comparison STACK_INT(-1)) \
a61af66fc99e Initial load
duke
parents:
diff changeset
1328 ? (int16_t)Bytes::get_Java_u2(pc + 1) : 3; \
a61af66fc99e Initial load
duke
parents:
diff changeset
1329 address branch_pc = pc; \
a61af66fc99e Initial load
duke
parents:
diff changeset
1330 UPDATE_PC_AND_TOS(skip, -2); \
a61af66fc99e Initial load
duke
parents:
diff changeset
1331 DO_BACKEDGE_CHECKS(skip, branch_pc); \
a61af66fc99e Initial load
duke
parents:
diff changeset
1332 CONTINUE; \
a61af66fc99e Initial load
duke
parents:
diff changeset
1333 } \
a61af66fc99e Initial load
duke
parents:
diff changeset
1334 CASE(_if##name): { \
a61af66fc99e Initial load
duke
parents:
diff changeset
1335 int skip = (STACK_INT(-1) comparison 0) \
a61af66fc99e Initial load
duke
parents:
diff changeset
1336 ? (int16_t)Bytes::get_Java_u2(pc + 1) : 3; \
a61af66fc99e Initial load
duke
parents:
diff changeset
1337 address branch_pc = pc; \
a61af66fc99e Initial load
duke
parents:
diff changeset
1338 UPDATE_PC_AND_TOS(skip, -1); \
a61af66fc99e Initial load
duke
parents:
diff changeset
1339 DO_BACKEDGE_CHECKS(skip, branch_pc); \
a61af66fc99e Initial load
duke
parents:
diff changeset
1340 CONTINUE; \
a61af66fc99e Initial load
duke
parents:
diff changeset
1341 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1342
a61af66fc99e Initial load
duke
parents:
diff changeset
1343 #define COMPARISON_OP2(name, comparison) \
a61af66fc99e Initial load
duke
parents:
diff changeset
1344 COMPARISON_OP(name, comparison) \
a61af66fc99e Initial load
duke
parents:
diff changeset
1345 CASE(_if_acmp##name): { \
a61af66fc99e Initial load
duke
parents:
diff changeset
1346 int skip = (STACK_OBJECT(-2) comparison STACK_OBJECT(-1)) \
a61af66fc99e Initial load
duke
parents:
diff changeset
1347 ? (int16_t)Bytes::get_Java_u2(pc + 1) : 3; \
a61af66fc99e Initial load
duke
parents:
diff changeset
1348 address branch_pc = pc; \
a61af66fc99e Initial load
duke
parents:
diff changeset
1349 UPDATE_PC_AND_TOS(skip, -2); \
a61af66fc99e Initial load
duke
parents:
diff changeset
1350 DO_BACKEDGE_CHECKS(skip, branch_pc); \
a61af66fc99e Initial load
duke
parents:
diff changeset
1351 CONTINUE; \
a61af66fc99e Initial load
duke
parents:
diff changeset
1352 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1353
a61af66fc99e Initial load
duke
parents:
diff changeset
1354 #define NULL_COMPARISON_NOT_OP(name) \
a61af66fc99e Initial load
duke
parents:
diff changeset
1355 CASE(_if##name): { \
520
52a431267315 6791168: Fix invalid code in bytecodeInterpreter that can cause gcc ICE
coleenp
parents: 196
diff changeset
1356 int skip = (!(STACK_OBJECT(-1) == NULL)) \
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1357 ? (int16_t)Bytes::get_Java_u2(pc + 1) : 3; \
a61af66fc99e Initial load
duke
parents:
diff changeset
1358 address branch_pc = pc; \
a61af66fc99e Initial load
duke
parents:
diff changeset
1359 UPDATE_PC_AND_TOS(skip, -1); \
a61af66fc99e Initial load
duke
parents:
diff changeset
1360 DO_BACKEDGE_CHECKS(skip, branch_pc); \
a61af66fc99e Initial load
duke
parents:
diff changeset
1361 CONTINUE; \
a61af66fc99e Initial load
duke
parents:
diff changeset
1362 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1363
a61af66fc99e Initial load
duke
parents:
diff changeset
1364 #define NULL_COMPARISON_OP(name) \
a61af66fc99e Initial load
duke
parents:
diff changeset
1365 CASE(_if##name): { \
520
52a431267315 6791168: Fix invalid code in bytecodeInterpreter that can cause gcc ICE
coleenp
parents: 196
diff changeset
1366 int skip = ((STACK_OBJECT(-1) == NULL)) \
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1367 ? (int16_t)Bytes::get_Java_u2(pc + 1) : 3; \
a61af66fc99e Initial load
duke
parents:
diff changeset
1368 address branch_pc = pc; \
a61af66fc99e Initial load
duke
parents:
diff changeset
1369 UPDATE_PC_AND_TOS(skip, -1); \
a61af66fc99e Initial load
duke
parents:
diff changeset
1370 DO_BACKEDGE_CHECKS(skip, branch_pc); \
a61af66fc99e Initial load
duke
parents:
diff changeset
1371 CONTINUE; \
a61af66fc99e Initial load
duke
parents:
diff changeset
1372 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1373 COMPARISON_OP(lt, <);
a61af66fc99e Initial load
duke
parents:
diff changeset
1374 COMPARISON_OP(gt, >);
a61af66fc99e Initial load
duke
parents:
diff changeset
1375 COMPARISON_OP(le, <=);
a61af66fc99e Initial load
duke
parents:
diff changeset
1376 COMPARISON_OP(ge, >=);
a61af66fc99e Initial load
duke
parents:
diff changeset
1377 COMPARISON_OP2(eq, ==); /* include ref comparison */
a61af66fc99e Initial load
duke
parents:
diff changeset
1378 COMPARISON_OP2(ne, !=); /* include ref comparison */
a61af66fc99e Initial load
duke
parents:
diff changeset
1379 NULL_COMPARISON_OP(null);
a61af66fc99e Initial load
duke
parents:
diff changeset
1380 NULL_COMPARISON_NOT_OP(nonnull);
a61af66fc99e Initial load
duke
parents:
diff changeset
1381
a61af66fc99e Initial load
duke
parents:
diff changeset
1382 /* Goto pc at specified offset in switch table. */
a61af66fc99e Initial load
duke
parents:
diff changeset
1383
a61af66fc99e Initial load
duke
parents:
diff changeset
1384 CASE(_tableswitch): {
a61af66fc99e Initial load
duke
parents:
diff changeset
1385 jint* lpc = (jint*)VMalignWordUp(pc+1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1386 int32_t key = STACK_INT(-1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1387 int32_t low = Bytes::get_Java_u4((address)&lpc[1]);
a61af66fc99e Initial load
duke
parents:
diff changeset
1388 int32_t high = Bytes::get_Java_u4((address)&lpc[2]);
a61af66fc99e Initial load
duke
parents:
diff changeset
1389 int32_t skip;
a61af66fc99e Initial load
duke
parents:
diff changeset
1390 key -= low;
a61af66fc99e Initial load
duke
parents:
diff changeset
1391 skip = ((uint32_t) key > (uint32_t)(high - low))
a61af66fc99e Initial load
duke
parents:
diff changeset
1392 ? Bytes::get_Java_u4((address)&lpc[0])
a61af66fc99e Initial load
duke
parents:
diff changeset
1393 : Bytes::get_Java_u4((address)&lpc[key + 3]);
a61af66fc99e Initial load
duke
parents:
diff changeset
1394 // Does this really need a full backedge check (osr?)
a61af66fc99e Initial load
duke
parents:
diff changeset
1395 address branch_pc = pc;
a61af66fc99e Initial load
duke
parents:
diff changeset
1396 UPDATE_PC_AND_TOS(skip, -1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1397 DO_BACKEDGE_CHECKS(skip, branch_pc);
a61af66fc99e Initial load
duke
parents:
diff changeset
1398 CONTINUE;
a61af66fc99e Initial load
duke
parents:
diff changeset
1399 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1400
a61af66fc99e Initial load
duke
parents:
diff changeset
1401 /* Goto pc whose table entry matches specified key */
a61af66fc99e Initial load
duke
parents:
diff changeset
1402
a61af66fc99e Initial load
duke
parents:
diff changeset
1403 CASE(_lookupswitch): {
a61af66fc99e Initial load
duke
parents:
diff changeset
1404 jint* lpc = (jint*)VMalignWordUp(pc+1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1405 int32_t key = STACK_INT(-1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1406 int32_t skip = Bytes::get_Java_u4((address) lpc); /* default amount */
a61af66fc99e Initial load
duke
parents:
diff changeset
1407 int32_t npairs = Bytes::get_Java_u4((address) &lpc[1]);
a61af66fc99e Initial load
duke
parents:
diff changeset
1408 while (--npairs >= 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1409 lpc += 2;
a61af66fc99e Initial load
duke
parents:
diff changeset
1410 if (key == (int32_t)Bytes::get_Java_u4((address)lpc)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1411 skip = Bytes::get_Java_u4((address)&lpc[1]);
a61af66fc99e Initial load
duke
parents:
diff changeset
1412 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1413 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1414 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1415 address branch_pc = pc;
a61af66fc99e Initial load
duke
parents:
diff changeset
1416 UPDATE_PC_AND_TOS(skip, -1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1417 DO_BACKEDGE_CHECKS(skip, branch_pc);
a61af66fc99e Initial load
duke
parents:
diff changeset
1418 CONTINUE;
a61af66fc99e Initial load
duke
parents:
diff changeset
1419 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1420
a61af66fc99e Initial load
duke
parents:
diff changeset
1421 CASE(_fcmpl):
a61af66fc99e Initial load
duke
parents:
diff changeset
1422 CASE(_fcmpg):
a61af66fc99e Initial load
duke
parents:
diff changeset
1423 {
a61af66fc99e Initial load
duke
parents:
diff changeset
1424 SET_STACK_INT(VMfloatCompare(STACK_FLOAT(-2),
a61af66fc99e Initial load
duke
parents:
diff changeset
1425 STACK_FLOAT(-1),
a61af66fc99e Initial load
duke
parents:
diff changeset
1426 (opcode == Bytecodes::_fcmpl ? -1 : 1)),
a61af66fc99e Initial load
duke
parents:
diff changeset
1427 -2);
a61af66fc99e Initial load
duke
parents:
diff changeset
1428 UPDATE_PC_AND_TOS_AND_CONTINUE(1, -1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1429 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1430
a61af66fc99e Initial load
duke
parents:
diff changeset
1431 CASE(_dcmpl):
a61af66fc99e Initial load
duke
parents:
diff changeset
1432 CASE(_dcmpg):
a61af66fc99e Initial load
duke
parents:
diff changeset
1433 {
a61af66fc99e Initial load
duke
parents:
diff changeset
1434 int r = VMdoubleCompare(STACK_DOUBLE(-3),
a61af66fc99e Initial load
duke
parents:
diff changeset
1435 STACK_DOUBLE(-1),
a61af66fc99e Initial load
duke
parents:
diff changeset
1436 (opcode == Bytecodes::_dcmpl ? -1 : 1));
a61af66fc99e Initial load
duke
parents:
diff changeset
1437 MORE_STACK(-4); // Pop
a61af66fc99e Initial load
duke
parents:
diff changeset
1438 SET_STACK_INT(r, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1439 UPDATE_PC_AND_TOS_AND_CONTINUE(1, 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1440 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1441
a61af66fc99e Initial load
duke
parents:
diff changeset
1442 CASE(_lcmp):
a61af66fc99e Initial load
duke
parents:
diff changeset
1443 {
a61af66fc99e Initial load
duke
parents:
diff changeset
1444 int r = VMlongCompare(STACK_LONG(-3), STACK_LONG(-1));
a61af66fc99e Initial load
duke
parents:
diff changeset
1445 MORE_STACK(-4);
a61af66fc99e Initial load
duke
parents:
diff changeset
1446 SET_STACK_INT(r, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1447 UPDATE_PC_AND_TOS_AND_CONTINUE(1, 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1448 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1449
a61af66fc99e Initial load
duke
parents:
diff changeset
1450
a61af66fc99e Initial load
duke
parents:
diff changeset
1451 /* Return from a method */
a61af66fc99e Initial load
duke
parents:
diff changeset
1452
a61af66fc99e Initial load
duke
parents:
diff changeset
1453 CASE(_areturn):
a61af66fc99e Initial load
duke
parents:
diff changeset
1454 CASE(_ireturn):
a61af66fc99e Initial load
duke
parents:
diff changeset
1455 CASE(_freturn):
a61af66fc99e Initial load
duke
parents:
diff changeset
1456 {
a61af66fc99e Initial load
duke
parents:
diff changeset
1457 // Allow a safepoint before returning to frame manager.
a61af66fc99e Initial load
duke
parents:
diff changeset
1458 SAFEPOINT;
a61af66fc99e Initial load
duke
parents:
diff changeset
1459
a61af66fc99e Initial load
duke
parents:
diff changeset
1460 goto handle_return;
a61af66fc99e Initial load
duke
parents:
diff changeset
1461 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1462
a61af66fc99e Initial load
duke
parents:
diff changeset
1463 CASE(_lreturn):
a61af66fc99e Initial load
duke
parents:
diff changeset
1464 CASE(_dreturn):
a61af66fc99e Initial load
duke
parents:
diff changeset
1465 {
a61af66fc99e Initial load
duke
parents:
diff changeset
1466 // Allow a safepoint before returning to frame manager.
a61af66fc99e Initial load
duke
parents:
diff changeset
1467 SAFEPOINT;
a61af66fc99e Initial load
duke
parents:
diff changeset
1468 goto handle_return;
a61af66fc99e Initial load
duke
parents:
diff changeset
1469 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1470
a61af66fc99e Initial load
duke
parents:
diff changeset
1471 CASE(_return_register_finalizer): {
a61af66fc99e Initial load
duke
parents:
diff changeset
1472
a61af66fc99e Initial load
duke
parents:
diff changeset
1473 oop rcvr = LOCALS_OBJECT(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1474 if (rcvr->klass()->klass_part()->has_finalizer()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1475 CALL_VM(InterpreterRuntime::register_finalizer(THREAD, rcvr), handle_exception);
a61af66fc99e Initial load
duke
parents:
diff changeset
1476 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1477 goto handle_return;
a61af66fc99e Initial load
duke
parents:
diff changeset
1478 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1479 CASE(_return): {
a61af66fc99e Initial load
duke
parents:
diff changeset
1480
a61af66fc99e Initial load
duke
parents:
diff changeset
1481 // Allow a safepoint before returning to frame manager.
a61af66fc99e Initial load
duke
parents:
diff changeset
1482 SAFEPOINT;
a61af66fc99e Initial load
duke
parents:
diff changeset
1483 goto handle_return;
a61af66fc99e Initial load
duke
parents:
diff changeset
1484 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1485
a61af66fc99e Initial load
duke
parents:
diff changeset
1486 /* Array access byte-codes */
a61af66fc99e Initial load
duke
parents:
diff changeset
1487
a61af66fc99e Initial load
duke
parents:
diff changeset
1488 /* Every array access byte-code starts out like this */
a61af66fc99e Initial load
duke
parents:
diff changeset
1489 // arrayOopDesc* arrObj = (arrayOopDesc*)STACK_OBJECT(arrayOff);
a61af66fc99e Initial load
duke
parents:
diff changeset
1490 #define ARRAY_INTRO(arrayOff) \
a61af66fc99e Initial load
duke
parents:
diff changeset
1491 arrayOop arrObj = (arrayOop)STACK_OBJECT(arrayOff); \
a61af66fc99e Initial load
duke
parents:
diff changeset
1492 jint index = STACK_INT(arrayOff + 1); \
a61af66fc99e Initial load
duke
parents:
diff changeset
1493 char message[jintAsStringSize]; \
a61af66fc99e Initial load
duke
parents:
diff changeset
1494 CHECK_NULL(arrObj); \
a61af66fc99e Initial load
duke
parents:
diff changeset
1495 if ((uint32_t)index >= (uint32_t)arrObj->length()) { \
a61af66fc99e Initial load
duke
parents:
diff changeset
1496 sprintf(message, "%d", index); \
a61af66fc99e Initial load
duke
parents:
diff changeset
1497 VM_JAVA_ERROR(vmSymbols::java_lang_ArrayIndexOutOfBoundsException(), \
a61af66fc99e Initial load
duke
parents:
diff changeset
1498 message); \
a61af66fc99e Initial load
duke
parents:
diff changeset
1499 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1500
a61af66fc99e Initial load
duke
parents:
diff changeset
1501 /* 32-bit loads. These handle conversion from < 32-bit types */
a61af66fc99e Initial load
duke
parents:
diff changeset
1502 #define ARRAY_LOADTO32(T, T2, format, stackRes, extra) \
a61af66fc99e Initial load
duke
parents:
diff changeset
1503 { \
a61af66fc99e Initial load
duke
parents:
diff changeset
1504 ARRAY_INTRO(-2); \
a61af66fc99e Initial load
duke
parents:
diff changeset
1505 extra; \
a61af66fc99e Initial load
duke
parents:
diff changeset
1506 SET_ ## stackRes(*(T2 *)(((address) arrObj->base(T)) + index * sizeof(T2)), \
a61af66fc99e Initial load
duke
parents:
diff changeset
1507 -2); \
a61af66fc99e Initial load
duke
parents:
diff changeset
1508 UPDATE_PC_AND_TOS_AND_CONTINUE(1, -1); \
a61af66fc99e Initial load
duke
parents:
diff changeset
1509 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1510
a61af66fc99e Initial load
duke
parents:
diff changeset
1511 /* 64-bit loads */
a61af66fc99e Initial load
duke
parents:
diff changeset
1512 #define ARRAY_LOADTO64(T,T2, stackRes, extra) \
a61af66fc99e Initial load
duke
parents:
diff changeset
1513 { \
a61af66fc99e Initial load
duke
parents:
diff changeset
1514 ARRAY_INTRO(-2); \
a61af66fc99e Initial load
duke
parents:
diff changeset
1515 SET_ ## stackRes(*(T2 *)(((address) arrObj->base(T)) + index * sizeof(T2)), -1); \
a61af66fc99e Initial load
duke
parents:
diff changeset
1516 extra; \
a61af66fc99e Initial load
duke
parents:
diff changeset
1517 UPDATE_PC_AND_CONTINUE(1); \
a61af66fc99e Initial load
duke
parents:
diff changeset
1518 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1519
a61af66fc99e Initial load
duke
parents:
diff changeset
1520 CASE(_iaload):
a61af66fc99e Initial load
duke
parents:
diff changeset
1521 ARRAY_LOADTO32(T_INT, jint, "%d", STACK_INT, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1522 CASE(_faload):
a61af66fc99e Initial load
duke
parents:
diff changeset
1523 ARRAY_LOADTO32(T_FLOAT, jfloat, "%f", STACK_FLOAT, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1524 CASE(_aaload):
a61af66fc99e Initial load
duke
parents:
diff changeset
1525 ARRAY_LOADTO32(T_OBJECT, oop, INTPTR_FORMAT, STACK_OBJECT, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1526 CASE(_baload):
a61af66fc99e Initial load
duke
parents:
diff changeset
1527 ARRAY_LOADTO32(T_BYTE, jbyte, "%d", STACK_INT, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1528 CASE(_caload):
a61af66fc99e Initial load
duke
parents:
diff changeset
1529 ARRAY_LOADTO32(T_CHAR, jchar, "%d", STACK_INT, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1530 CASE(_saload):
a61af66fc99e Initial load
duke
parents:
diff changeset
1531 ARRAY_LOADTO32(T_SHORT, jshort, "%d", STACK_INT, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1532 CASE(_laload):
a61af66fc99e Initial load
duke
parents:
diff changeset
1533 ARRAY_LOADTO64(T_LONG, jlong, STACK_LONG, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1534 CASE(_daload):
a61af66fc99e Initial load
duke
parents:
diff changeset
1535 ARRAY_LOADTO64(T_DOUBLE, jdouble, STACK_DOUBLE, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1536
a61af66fc99e Initial load
duke
parents:
diff changeset
1537 /* 32-bit stores. These handle conversion to < 32-bit types */
a61af66fc99e Initial load
duke
parents:
diff changeset
1538 #define ARRAY_STOREFROM32(T, T2, format, stackSrc, extra) \
a61af66fc99e Initial load
duke
parents:
diff changeset
1539 { \
a61af66fc99e Initial load
duke
parents:
diff changeset
1540 ARRAY_INTRO(-3); \
a61af66fc99e Initial load
duke
parents:
diff changeset
1541 extra; \
a61af66fc99e Initial load
duke
parents:
diff changeset
1542 *(T2 *)(((address) arrObj->base(T)) + index * sizeof(T2)) = stackSrc( -1); \
a61af66fc99e Initial load
duke
parents:
diff changeset
1543 UPDATE_PC_AND_TOS_AND_CONTINUE(1, -3); \
a61af66fc99e Initial load
duke
parents:
diff changeset
1544 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1545
a61af66fc99e Initial load
duke
parents:
diff changeset
1546 /* 64-bit stores */
a61af66fc99e Initial load
duke
parents:
diff changeset
1547 #define ARRAY_STOREFROM64(T, T2, stackSrc, extra) \
a61af66fc99e Initial load
duke
parents:
diff changeset
1548 { \
a61af66fc99e Initial load
duke
parents:
diff changeset
1549 ARRAY_INTRO(-4); \
a61af66fc99e Initial load
duke
parents:
diff changeset
1550 extra; \
a61af66fc99e Initial load
duke
parents:
diff changeset
1551 *(T2 *)(((address) arrObj->base(T)) + index * sizeof(T2)) = stackSrc( -1); \
a61af66fc99e Initial load
duke
parents:
diff changeset
1552 UPDATE_PC_AND_TOS_AND_CONTINUE(1, -4); \
a61af66fc99e Initial load
duke
parents:
diff changeset
1553 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1554
a61af66fc99e Initial load
duke
parents:
diff changeset
1555 CASE(_iastore):
a61af66fc99e Initial load
duke
parents:
diff changeset
1556 ARRAY_STOREFROM32(T_INT, jint, "%d", STACK_INT, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1557 CASE(_fastore):
a61af66fc99e Initial load
duke
parents:
diff changeset
1558 ARRAY_STOREFROM32(T_FLOAT, jfloat, "%f", STACK_FLOAT, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1559 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
1560 * This one looks different because of the assignability check
a61af66fc99e Initial load
duke
parents:
diff changeset
1561 */
a61af66fc99e Initial load
duke
parents:
diff changeset
1562 CASE(_aastore): {
a61af66fc99e Initial load
duke
parents:
diff changeset
1563 oop rhsObject = STACK_OBJECT(-1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1564 ARRAY_INTRO( -3);
a61af66fc99e Initial load
duke
parents:
diff changeset
1565 // arrObj, index are set
a61af66fc99e Initial load
duke
parents:
diff changeset
1566 if (rhsObject != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1567 /* Check assignability of rhsObject into arrObj */
a61af66fc99e Initial load
duke
parents:
diff changeset
1568 klassOop rhsKlassOop = rhsObject->klass(); // EBX (subclass)
a61af66fc99e Initial load
duke
parents:
diff changeset
1569 assert(arrObj->klass()->klass()->klass_part()->oop_is_objArrayKlass(), "Ack not an objArrayKlass");
a61af66fc99e Initial load
duke
parents:
diff changeset
1570 klassOop elemKlassOop = ((objArrayKlass*) arrObj->klass()->klass_part())->element_klass(); // superklass EAX
a61af66fc99e Initial load
duke
parents:
diff changeset
1571 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1572 // Check for compatibilty. This check must not GC!!
a61af66fc99e Initial load
duke
parents:
diff changeset
1573 // Seems way more expensive now that we must dispatch
a61af66fc99e Initial load
duke
parents:
diff changeset
1574 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1575 if (rhsKlassOop != elemKlassOop && !rhsKlassOop->klass_part()->is_subtype_of(elemKlassOop)) { // ebx->is...
a61af66fc99e Initial load
duke
parents:
diff changeset
1576 VM_JAVA_ERROR(vmSymbols::java_lang_ArrayStoreException(), "");
a61af66fc99e Initial load
duke
parents:
diff changeset
1577 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1578 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1579 oop* elem_loc = (oop*)(((address) arrObj->base(T_OBJECT)) + index * sizeof(oop));
a61af66fc99e Initial load
duke
parents:
diff changeset
1580 // *(oop*)(((address) arrObj->base(T_OBJECT)) + index * sizeof(oop)) = rhsObject;
a61af66fc99e Initial load
duke
parents:
diff changeset
1581 *elem_loc = rhsObject;
a61af66fc99e Initial load
duke
parents:
diff changeset
1582 // Mark the card
a61af66fc99e Initial load
duke
parents:
diff changeset
1583 OrderAccess::release_store(&BYTE_MAP_BASE[(uintptr_t)elem_loc >> CardTableModRefBS::card_shift], 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1584 UPDATE_PC_AND_TOS_AND_CONTINUE(1, -3);
a61af66fc99e Initial load
duke
parents:
diff changeset
1585 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1586 CASE(_bastore):
a61af66fc99e Initial load
duke
parents:
diff changeset
1587 ARRAY_STOREFROM32(T_BYTE, jbyte, "%d", STACK_INT, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1588 CASE(_castore):
a61af66fc99e Initial load
duke
parents:
diff changeset
1589 ARRAY_STOREFROM32(T_CHAR, jchar, "%d", STACK_INT, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1590 CASE(_sastore):
a61af66fc99e Initial load
duke
parents:
diff changeset
1591 ARRAY_STOREFROM32(T_SHORT, jshort, "%d", STACK_INT, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1592 CASE(_lastore):
a61af66fc99e Initial load
duke
parents:
diff changeset
1593 ARRAY_STOREFROM64(T_LONG, jlong, STACK_LONG, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1594 CASE(_dastore):
a61af66fc99e Initial load
duke
parents:
diff changeset
1595 ARRAY_STOREFROM64(T_DOUBLE, jdouble, STACK_DOUBLE, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1596
a61af66fc99e Initial load
duke
parents:
diff changeset
1597 CASE(_arraylength):
a61af66fc99e Initial load
duke
parents:
diff changeset
1598 {
a61af66fc99e Initial load
duke
parents:
diff changeset
1599 arrayOop ary = (arrayOop) STACK_OBJECT(-1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1600 CHECK_NULL(ary);
a61af66fc99e Initial load
duke
parents:
diff changeset
1601 SET_STACK_INT(ary->length(), -1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1602 UPDATE_PC_AND_CONTINUE(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1603 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1604
a61af66fc99e Initial load
duke
parents:
diff changeset
1605 /* monitorenter and monitorexit for locking/unlocking an object */
a61af66fc99e Initial load
duke
parents:
diff changeset
1606
a61af66fc99e Initial load
duke
parents:
diff changeset
1607 CASE(_monitorenter): {
a61af66fc99e Initial load
duke
parents:
diff changeset
1608 oop lockee = STACK_OBJECT(-1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1609 // derefing's lockee ought to provoke implicit null check
a61af66fc99e Initial load
duke
parents:
diff changeset
1610 CHECK_NULL(lockee);
a61af66fc99e Initial load
duke
parents:
diff changeset
1611 // find a free monitor or one already allocated for this object
a61af66fc99e Initial load
duke
parents:
diff changeset
1612 // if we find a matching object then we need a new monitor
a61af66fc99e Initial load
duke
parents:
diff changeset
1613 // since this is recursive enter
a61af66fc99e Initial load
duke
parents:
diff changeset
1614 BasicObjectLock* limit = istate->monitor_base();
a61af66fc99e Initial load
duke
parents:
diff changeset
1615 BasicObjectLock* most_recent = (BasicObjectLock*) istate->stack_base();
a61af66fc99e Initial load
duke
parents:
diff changeset
1616 BasicObjectLock* entry = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
1617 while (most_recent != limit ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1618 if (most_recent->obj() == NULL) entry = most_recent;
a61af66fc99e Initial load
duke
parents:
diff changeset
1619 else if (most_recent->obj() == lockee) break;
a61af66fc99e Initial load
duke
parents:
diff changeset
1620 most_recent++;
a61af66fc99e Initial load
duke
parents:
diff changeset
1621 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1622 if (entry != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1623 entry->set_obj(lockee);
a61af66fc99e Initial load
duke
parents:
diff changeset
1624 markOop displaced = lockee->mark()->set_unlocked();
a61af66fc99e Initial load
duke
parents:
diff changeset
1625 entry->lock()->set_displaced_header(displaced);
a61af66fc99e Initial load
duke
parents:
diff changeset
1626 if (Atomic::cmpxchg_ptr(entry, lockee->mark_addr(), displaced) != displaced) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1627 // Is it simple recursive case?
a61af66fc99e Initial load
duke
parents:
diff changeset
1628 if (THREAD->is_lock_owned((address) displaced->clear_lock_bits())) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1629 entry->lock()->set_displaced_header(NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
1630 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1631 CALL_VM(InterpreterRuntime::monitorenter(THREAD, entry), handle_exception);
a61af66fc99e Initial load
duke
parents:
diff changeset
1632 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1633 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1634 UPDATE_PC_AND_TOS_AND_CONTINUE(1, -1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1635 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1636 istate->set_msg(more_monitors);
a61af66fc99e Initial load
duke
parents:
diff changeset
1637 UPDATE_PC_AND_RETURN(0); // Re-execute
a61af66fc99e Initial load
duke
parents:
diff changeset
1638 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1639 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1640
a61af66fc99e Initial load
duke
parents:
diff changeset
1641 CASE(_monitorexit): {
a61af66fc99e Initial load
duke
parents:
diff changeset
1642 oop lockee = STACK_OBJECT(-1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1643 CHECK_NULL(lockee);
a61af66fc99e Initial load
duke
parents:
diff changeset
1644 // derefing's lockee ought to provoke implicit null check
a61af66fc99e Initial load
duke
parents:
diff changeset
1645 // find our monitor slot
a61af66fc99e Initial load
duke
parents:
diff changeset
1646 BasicObjectLock* limit = istate->monitor_base();
a61af66fc99e Initial load
duke
parents:
diff changeset
1647 BasicObjectLock* most_recent = (BasicObjectLock*) istate->stack_base();
a61af66fc99e Initial load
duke
parents:
diff changeset
1648 while (most_recent != limit ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1649 if ((most_recent)->obj() == lockee) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1650 BasicLock* lock = most_recent->lock();
a61af66fc99e Initial load
duke
parents:
diff changeset
1651 markOop header = lock->displaced_header();
a61af66fc99e Initial load
duke
parents:
diff changeset
1652 most_recent->set_obj(NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
1653 // If it isn't recursive we either must swap old header or call the runtime
a61af66fc99e Initial load
duke
parents:
diff changeset
1654 if (header != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1655 if (Atomic::cmpxchg_ptr(header, lockee->mark_addr(), lock) != lock) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1656 // restore object for the slow case
a61af66fc99e Initial load
duke
parents:
diff changeset
1657 most_recent->set_obj(lockee);
a61af66fc99e Initial load
duke
parents:
diff changeset
1658 CALL_VM(InterpreterRuntime::monitorexit(THREAD, most_recent), handle_exception);
a61af66fc99e Initial load
duke
parents:
diff changeset
1659 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1660 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1661 UPDATE_PC_AND_TOS_AND_CONTINUE(1, -1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1662 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1663 most_recent++;
a61af66fc99e Initial load
duke
parents:
diff changeset
1664 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1665 // Need to throw illegal monitor state exception
a61af66fc99e Initial load
duke
parents:
diff changeset
1666 CALL_VM(InterpreterRuntime::throw_illegal_monitor_state_exception(THREAD), handle_exception);
a61af66fc99e Initial load
duke
parents:
diff changeset
1667 // Should never reach here...
a61af66fc99e Initial load
duke
parents:
diff changeset
1668 assert(false, "Should have thrown illegal monitor exception");
a61af66fc99e Initial load
duke
parents:
diff changeset
1669 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1670
a61af66fc99e Initial load
duke
parents:
diff changeset
1671 /* All of the non-quick opcodes. */
a61af66fc99e Initial load
duke
parents:
diff changeset
1672
a61af66fc99e Initial load
duke
parents:
diff changeset
1673 /* -Set clobbersCpIndex true if the quickened opcode clobbers the
a61af66fc99e Initial load
duke
parents:
diff changeset
1674 * constant pool index in the instruction.
a61af66fc99e Initial load
duke
parents:
diff changeset
1675 */
a61af66fc99e Initial load
duke
parents:
diff changeset
1676 CASE(_getfield):
a61af66fc99e Initial load
duke
parents:
diff changeset
1677 CASE(_getstatic):
a61af66fc99e Initial load
duke
parents:
diff changeset
1678 {
a61af66fc99e Initial load
duke
parents:
diff changeset
1679 u2 index;
a61af66fc99e Initial load
duke
parents:
diff changeset
1680 ConstantPoolCacheEntry* cache;
a61af66fc99e Initial load
duke
parents:
diff changeset
1681 index = Bytes::get_native_u2(pc+1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1682
a61af66fc99e Initial load
duke
parents:
diff changeset
1683 // QQQ Need to make this as inlined as possible. Probably need to
a61af66fc99e Initial load
duke
parents:
diff changeset
1684 // split all the bytecode cases out so c++ compiler has a chance
a61af66fc99e Initial load
duke
parents:
diff changeset
1685 // for constant prop to fold everything possible away.
a61af66fc99e Initial load
duke
parents:
diff changeset
1686
a61af66fc99e Initial load
duke
parents:
diff changeset
1687 cache = cp->entry_at(index);
a61af66fc99e Initial load
duke
parents:
diff changeset
1688 if (!cache->is_resolved((Bytecodes::Code)opcode)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1689 CALL_VM(InterpreterRuntime::resolve_get_put(THREAD, (Bytecodes::Code)opcode),
a61af66fc99e Initial load
duke
parents:
diff changeset
1690 handle_exception);
a61af66fc99e Initial load
duke
parents:
diff changeset
1691 cache = cp->entry_at(index);
a61af66fc99e Initial load
duke
parents:
diff changeset
1692 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1693
a61af66fc99e Initial load
duke
parents:
diff changeset
1694 #ifdef VM_JVMTI
a61af66fc99e Initial load
duke
parents:
diff changeset
1695 if (_jvmti_interp_events) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1696 int *count_addr;
a61af66fc99e Initial load
duke
parents:
diff changeset
1697 oop obj;
a61af66fc99e Initial load
duke
parents:
diff changeset
1698 // Check to see if a field modification watch has been set
a61af66fc99e Initial load
duke
parents:
diff changeset
1699 // before we take the time to call into the VM.
a61af66fc99e Initial load
duke
parents:
diff changeset
1700 count_addr = (int *)JvmtiExport::get_field_access_count_addr();
a61af66fc99e Initial load
duke
parents:
diff changeset
1701 if ( *count_addr > 0 ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1702 if ((Bytecodes::Code)opcode == Bytecodes::_getstatic) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1703 obj = (oop)NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
1704 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1705 obj = (oop) STACK_OBJECT(-1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1706 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1707 CALL_VM(InterpreterRuntime::post_field_access(THREAD,
a61af66fc99e Initial load
duke
parents:
diff changeset
1708 obj,
a61af66fc99e Initial load
duke
parents:
diff changeset
1709 cache),
a61af66fc99e Initial load
duke
parents:
diff changeset
1710 handle_exception);
a61af66fc99e Initial load
duke
parents:
diff changeset
1711 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1712 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1713 #endif /* VM_JVMTI */
a61af66fc99e Initial load
duke
parents:
diff changeset
1714
a61af66fc99e Initial load
duke
parents:
diff changeset
1715 oop obj;
a61af66fc99e Initial load
duke
parents:
diff changeset
1716 if ((Bytecodes::Code)opcode == Bytecodes::_getstatic) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1717 obj = (oop) cache->f1();
a61af66fc99e Initial load
duke
parents:
diff changeset
1718 MORE_STACK(1); // Assume single slot push
a61af66fc99e Initial load
duke
parents:
diff changeset
1719 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1720 obj = (oop) STACK_OBJECT(-1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1721 CHECK_NULL(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
1722 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1723
a61af66fc99e Initial load
duke
parents:
diff changeset
1724 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1725 // Now store the result on the stack
a61af66fc99e Initial load
duke
parents:
diff changeset
1726 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1727 TosState tos_type = cache->flag_state();
a61af66fc99e Initial load
duke
parents:
diff changeset
1728 int field_offset = cache->f2();
a61af66fc99e Initial load
duke
parents:
diff changeset
1729 if (cache->is_volatile()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1730 if (tos_type == atos) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1731 SET_STACK_OBJECT(obj->obj_field_acquire(field_offset), -1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1732 } else if (tos_type == itos) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1733 SET_STACK_INT(obj->int_field_acquire(field_offset), -1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1734 } else if (tos_type == ltos) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1735 SET_STACK_LONG(obj->long_field_acquire(field_offset), 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1736 MORE_STACK(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1737 } else if (tos_type == btos) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1738 SET_STACK_INT(obj->byte_field_acquire(field_offset), -1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1739 } else if (tos_type == ctos) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1740 SET_STACK_INT(obj->char_field_acquire(field_offset), -1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1741 } else if (tos_type == stos) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1742 SET_STACK_INT(obj->short_field_acquire(field_offset), -1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1743 } else if (tos_type == ftos) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1744 SET_STACK_FLOAT(obj->float_field_acquire(field_offset), -1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1745 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1746 SET_STACK_DOUBLE(obj->double_field_acquire(field_offset), 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1747 MORE_STACK(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1748 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1749 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1750 if (tos_type == atos) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1751 SET_STACK_OBJECT(obj->obj_field(field_offset), -1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1752 } else if (tos_type == itos) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1753 SET_STACK_INT(obj->int_field(field_offset), -1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1754 } else if (tos_type == ltos) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1755 SET_STACK_LONG(obj->long_field(field_offset), 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1756 MORE_STACK(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1757 } else if (tos_type == btos) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1758 SET_STACK_INT(obj->byte_field(field_offset), -1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1759 } else if (tos_type == ctos) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1760 SET_STACK_INT(obj->char_field(field_offset), -1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1761 } else if (tos_type == stos) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1762 SET_STACK_INT(obj->short_field(field_offset), -1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1763 } else if (tos_type == ftos) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1764 SET_STACK_FLOAT(obj->float_field(field_offset), -1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1765 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1766 SET_STACK_DOUBLE(obj->double_field(field_offset), 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1767 MORE_STACK(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1768 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1769 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1770
a61af66fc99e Initial load
duke
parents:
diff changeset
1771 UPDATE_PC_AND_CONTINUE(3);
a61af66fc99e Initial load
duke
parents:
diff changeset
1772 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1773
a61af66fc99e Initial load
duke
parents:
diff changeset
1774 CASE(_putfield):
a61af66fc99e Initial load
duke
parents:
diff changeset
1775 CASE(_putstatic):
a61af66fc99e Initial load
duke
parents:
diff changeset
1776 {
a61af66fc99e Initial load
duke
parents:
diff changeset
1777 u2 index = Bytes::get_native_u2(pc+1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1778 ConstantPoolCacheEntry* cache = cp->entry_at(index);
a61af66fc99e Initial load
duke
parents:
diff changeset
1779 if (!cache->is_resolved((Bytecodes::Code)opcode)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1780 CALL_VM(InterpreterRuntime::resolve_get_put(THREAD, (Bytecodes::Code)opcode),
a61af66fc99e Initial load
duke
parents:
diff changeset
1781 handle_exception);
a61af66fc99e Initial load
duke
parents:
diff changeset
1782 cache = cp->entry_at(index);
a61af66fc99e Initial load
duke
parents:
diff changeset
1783 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1784
a61af66fc99e Initial load
duke
parents:
diff changeset
1785 #ifdef VM_JVMTI
a61af66fc99e Initial load
duke
parents:
diff changeset
1786 if (_jvmti_interp_events) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1787 int *count_addr;
a61af66fc99e Initial load
duke
parents:
diff changeset
1788 oop obj;
a61af66fc99e Initial load
duke
parents:
diff changeset
1789 // Check to see if a field modification watch has been set
a61af66fc99e Initial load
duke
parents:
diff changeset
1790 // before we take the time to call into the VM.
a61af66fc99e Initial load
duke
parents:
diff changeset
1791 count_addr = (int *)JvmtiExport::get_field_modification_count_addr();
a61af66fc99e Initial load
duke
parents:
diff changeset
1792 if ( *count_addr > 0 ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1793 if ((Bytecodes::Code)opcode == Bytecodes::_putstatic) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1794 obj = (oop)NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
1795 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1796 else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1797 if (cache->is_long() || cache->is_double()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1798 obj = (oop) STACK_OBJECT(-3);
a61af66fc99e Initial load
duke
parents:
diff changeset
1799 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1800 obj = (oop) STACK_OBJECT(-2);
a61af66fc99e Initial load
duke
parents:
diff changeset
1801 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1802 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1803
a61af66fc99e Initial load
duke
parents:
diff changeset
1804 CALL_VM(InterpreterRuntime::post_field_modification(THREAD,
a61af66fc99e Initial load
duke
parents:
diff changeset
1805 obj,
a61af66fc99e Initial load
duke
parents:
diff changeset
1806 cache,
a61af66fc99e Initial load
duke
parents:
diff changeset
1807 (jvalue *)STACK_SLOT(-1)),
a61af66fc99e Initial load
duke
parents:
diff changeset
1808 handle_exception);
a61af66fc99e Initial load
duke
parents:
diff changeset
1809 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1810 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1811 #endif /* VM_JVMTI */
a61af66fc99e Initial load
duke
parents:
diff changeset
1812
a61af66fc99e Initial load
duke
parents:
diff changeset
1813 // QQQ Need to make this as inlined as possible. Probably need to split all the bytecode cases
a61af66fc99e Initial load
duke
parents:
diff changeset
1814 // out so c++ compiler has a chance for constant prop to fold everything possible away.
a61af66fc99e Initial load
duke
parents:
diff changeset
1815
a61af66fc99e Initial load
duke
parents:
diff changeset
1816 oop obj;
a61af66fc99e Initial load
duke
parents:
diff changeset
1817 int count;
a61af66fc99e Initial load
duke
parents:
diff changeset
1818 TosState tos_type = cache->flag_state();
a61af66fc99e Initial load
duke
parents:
diff changeset
1819
a61af66fc99e Initial load
duke
parents:
diff changeset
1820 count = -1;
a61af66fc99e Initial load
duke
parents:
diff changeset
1821 if (tos_type == ltos || tos_type == dtos) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1822 --count;
a61af66fc99e Initial load
duke
parents:
diff changeset
1823 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1824 if ((Bytecodes::Code)opcode == Bytecodes::_putstatic) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1825 obj = (oop) cache->f1();
a61af66fc99e Initial load
duke
parents:
diff changeset
1826 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1827 --count;
a61af66fc99e Initial load
duke
parents:
diff changeset
1828 obj = (oop) STACK_OBJECT(count);
a61af66fc99e Initial load
duke
parents:
diff changeset
1829 CHECK_NULL(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
1830 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1831
a61af66fc99e Initial load
duke
parents:
diff changeset
1832 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1833 // Now store the result
a61af66fc99e Initial load
duke
parents:
diff changeset
1834 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1835 int field_offset = cache->f2();
a61af66fc99e Initial load
duke
parents:
diff changeset
1836 if (cache->is_volatile()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1837 if (tos_type == itos) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1838 obj->release_int_field_put(field_offset, STACK_INT(-1));
a61af66fc99e Initial load
duke
parents:
diff changeset
1839 } else if (tos_type == atos) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1840 obj->release_obj_field_put(field_offset, STACK_OBJECT(-1));
a61af66fc99e Initial load
duke
parents:
diff changeset
1841 OrderAccess::release_store(&BYTE_MAP_BASE[(uintptr_t)obj >> CardTableModRefBS::card_shift], 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1842 } else if (tos_type == btos) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1843 obj->release_byte_field_put(field_offset, STACK_INT(-1));
a61af66fc99e Initial load
duke
parents:
diff changeset
1844 } else if (tos_type == ltos) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1845 obj->release_long_field_put(field_offset, STACK_LONG(-1));
a61af66fc99e Initial load
duke
parents:
diff changeset
1846 } else if (tos_type == ctos) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1847 obj->release_char_field_put(field_offset, STACK_INT(-1));
a61af66fc99e Initial load
duke
parents:
diff changeset
1848 } else if (tos_type == stos) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1849 obj->release_short_field_put(field_offset, STACK_INT(-1));
a61af66fc99e Initial load
duke
parents:
diff changeset
1850 } else if (tos_type == ftos) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1851 obj->release_float_field_put(field_offset, STACK_FLOAT(-1));
a61af66fc99e Initial load
duke
parents:
diff changeset
1852 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1853 obj->release_double_field_put(field_offset, STACK_DOUBLE(-1));
a61af66fc99e Initial load
duke
parents:
diff changeset
1854 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1855 OrderAccess::storeload();
a61af66fc99e Initial load
duke
parents:
diff changeset
1856 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1857 if (tos_type == itos) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1858 obj->int_field_put(field_offset, STACK_INT(-1));
a61af66fc99e Initial load
duke
parents:
diff changeset
1859 } else if (tos_type == atos) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1860 obj->obj_field_put(field_offset, STACK_OBJECT(-1));
a61af66fc99e Initial load
duke
parents:
diff changeset
1861 OrderAccess::release_store(&BYTE_MAP_BASE[(uintptr_t)obj >> CardTableModRefBS::card_shift], 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1862 } else if (tos_type == btos) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1863 obj->byte_field_put(field_offset, STACK_INT(-1));
a61af66fc99e Initial load
duke
parents:
diff changeset
1864 } else if (tos_type == ltos) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1865 obj->long_field_put(field_offset, STACK_LONG(-1));
a61af66fc99e Initial load
duke
parents:
diff changeset
1866 } else if (tos_type == ctos) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1867 obj->char_field_put(field_offset, STACK_INT(-1));
a61af66fc99e Initial load
duke
parents:
diff changeset
1868 } else if (tos_type == stos) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1869 obj->short_field_put(field_offset, STACK_INT(-1));
a61af66fc99e Initial load
duke
parents:
diff changeset
1870 } else if (tos_type == ftos) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1871 obj->float_field_put(field_offset, STACK_FLOAT(-1));
a61af66fc99e Initial load
duke
parents:
diff changeset
1872 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1873 obj->double_field_put(field_offset, STACK_DOUBLE(-1));
a61af66fc99e Initial load
duke
parents:
diff changeset
1874 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1875 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1876
a61af66fc99e Initial load
duke
parents:
diff changeset
1877 UPDATE_PC_AND_TOS_AND_CONTINUE(3, count);
a61af66fc99e Initial load
duke
parents:
diff changeset
1878 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1879
a61af66fc99e Initial load
duke
parents:
diff changeset
1880 CASE(_new): {
a61af66fc99e Initial load
duke
parents:
diff changeset
1881 u2 index = Bytes::get_Java_u2(pc+1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1882 constantPoolOop constants = istate->method()->constants();
a61af66fc99e Initial load
duke
parents:
diff changeset
1883 if (!constants->tag_at(index).is_unresolved_klass()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1884 // Make sure klass is initialized and doesn't have a finalizer
a61af66fc99e Initial load
duke
parents:
diff changeset
1885 oop entry = (klassOop) *constants->obj_at_addr(index);
a61af66fc99e Initial load
duke
parents:
diff changeset
1886 assert(entry->is_klass(), "Should be resolved klass");
a61af66fc99e Initial load
duke
parents:
diff changeset
1887 klassOop k_entry = (klassOop) entry;
a61af66fc99e Initial load
duke
parents:
diff changeset
1888 assert(k_entry->klass_part()->oop_is_instance(), "Should be instanceKlass");
a61af66fc99e Initial load
duke
parents:
diff changeset
1889 instanceKlass* ik = (instanceKlass*) k_entry->klass_part();
a61af66fc99e Initial load
duke
parents:
diff changeset
1890 if ( ik->is_initialized() && ik->can_be_fastpath_allocated() ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1891 size_t obj_size = ik->size_helper();
a61af66fc99e Initial load
duke
parents:
diff changeset
1892 oop result = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
1893 // If the TLAB isn't pre-zeroed then we'll have to do it
a61af66fc99e Initial load
duke
parents:
diff changeset
1894 bool need_zero = !ZeroTLAB;
a61af66fc99e Initial load
duke
parents:
diff changeset
1895 if (UseTLAB) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1896 result = (oop) THREAD->tlab().allocate(obj_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
1897 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1898 if (result == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1899 need_zero = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
1900 // Try allocate in shared eden
a61af66fc99e Initial load
duke
parents:
diff changeset
1901 retry:
a61af66fc99e Initial load
duke
parents:
diff changeset
1902 HeapWord* compare_to = *Universe::heap()->top_addr();
a61af66fc99e Initial load
duke
parents:
diff changeset
1903 HeapWord* new_top = compare_to + obj_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
1904 if (new_top <= *Universe::heap()->end_addr()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1905 if (Atomic::cmpxchg_ptr(new_top, Universe::heap()->top_addr(), compare_to) != compare_to) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1906 goto retry;
a61af66fc99e Initial load
duke
parents:
diff changeset
1907 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1908 result = (oop) compare_to;
a61af66fc99e Initial load
duke
parents:
diff changeset
1909 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1910 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1911 if (result != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1912 // Initialize object (if nonzero size and need) and then the header
a61af66fc99e Initial load
duke
parents:
diff changeset
1913 if (need_zero ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1914 HeapWord* to_zero = (HeapWord*) result + sizeof(oopDesc) / oopSize;
a61af66fc99e Initial load
duke
parents:
diff changeset
1915 obj_size -= sizeof(oopDesc) / oopSize;
a61af66fc99e Initial load
duke
parents:
diff changeset
1916 if (obj_size > 0 ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1917 memset(to_zero, 0, obj_size * HeapWordSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
1918 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1919 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1920 if (UseBiasedLocking) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1921 result->set_mark(ik->prototype_header());
a61af66fc99e Initial load
duke
parents:
diff changeset
1922 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1923 result->set_mark(markOopDesc::prototype());
a61af66fc99e Initial load
duke
parents:
diff changeset
1924 }
167
feeb96a45707 6696264: assert("narrow oop can never be zero") for GCBasher & ParNewGC
coleenp
parents: 123
diff changeset
1925 result->set_klass_gap(0);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1926 result->set_klass(k_entry);
a61af66fc99e Initial load
duke
parents:
diff changeset
1927 SET_STACK_OBJECT(result, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1928 UPDATE_PC_AND_TOS_AND_CONTINUE(3, 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1929 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1930 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1931 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1932 // Slow case allocation
a61af66fc99e Initial load
duke
parents:
diff changeset
1933 CALL_VM(InterpreterRuntime::_new(THREAD, METHOD->constants(), index),
a61af66fc99e Initial load
duke
parents:
diff changeset
1934 handle_exception);
a61af66fc99e Initial load
duke
parents:
diff changeset
1935 SET_STACK_OBJECT(THREAD->vm_result(), 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1936 THREAD->set_vm_result(NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
1937 UPDATE_PC_AND_TOS_AND_CONTINUE(3, 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1938 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1939 CASE(_anewarray): {
a61af66fc99e Initial load
duke
parents:
diff changeset
1940 u2 index = Bytes::get_Java_u2(pc+1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1941 jint size = STACK_INT(-1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1942 CALL_VM(InterpreterRuntime::anewarray(THREAD, METHOD->constants(), index, size),
a61af66fc99e Initial load
duke
parents:
diff changeset
1943 handle_exception);
a61af66fc99e Initial load
duke
parents:
diff changeset
1944 SET_STACK_OBJECT(THREAD->vm_result(), -1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1945 THREAD->set_vm_result(NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
1946 UPDATE_PC_AND_CONTINUE(3);
a61af66fc99e Initial load
duke
parents:
diff changeset
1947 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1948 CASE(_multianewarray): {
a61af66fc99e Initial load
duke
parents:
diff changeset
1949 jint dims = *(pc+3);
a61af66fc99e Initial load
duke
parents:
diff changeset
1950 jint size = STACK_INT(-1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1951 // stack grows down, dimensions are up!
a61af66fc99e Initial load
duke
parents:
diff changeset
1952 jint *dimarray =
a61af66fc99e Initial load
duke
parents:
diff changeset
1953 (jint*)&topOfStack[dims * Interpreter::stackElementWords()+
a61af66fc99e Initial load
duke
parents:
diff changeset
1954 Interpreter::stackElementWords()-1];
a61af66fc99e Initial load
duke
parents:
diff changeset
1955 //adjust pointer to start of stack element
a61af66fc99e Initial load
duke
parents:
diff changeset
1956 CALL_VM(InterpreterRuntime::multianewarray(THREAD, dimarray),
a61af66fc99e Initial load
duke
parents:
diff changeset
1957 handle_exception);
a61af66fc99e Initial load
duke
parents:
diff changeset
1958 SET_STACK_OBJECT(THREAD->vm_result(), -dims);
a61af66fc99e Initial load
duke
parents:
diff changeset
1959 THREAD->set_vm_result(NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
1960 UPDATE_PC_AND_TOS_AND_CONTINUE(4, -(dims-1));
a61af66fc99e Initial load
duke
parents:
diff changeset
1961 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1962 CASE(_checkcast):
a61af66fc99e Initial load
duke
parents:
diff changeset
1963 if (STACK_OBJECT(-1) != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1964 u2 index = Bytes::get_Java_u2(pc+1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1965 if (ProfileInterpreter) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1966 // needs Profile_checkcast QQQ
a61af66fc99e Initial load
duke
parents:
diff changeset
1967 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1968 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1969 // Constant pool may have actual klass or unresolved klass. If it is
a61af66fc99e Initial load
duke
parents:
diff changeset
1970 // unresolved we must resolve it
a61af66fc99e Initial load
duke
parents:
diff changeset
1971 if (METHOD->constants()->tag_at(index).is_unresolved_klass()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1972 CALL_VM(InterpreterRuntime::quicken_io_cc(THREAD), handle_exception);
a61af66fc99e Initial load
duke
parents:
diff changeset
1973 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1974 klassOop klassOf = (klassOop) *(METHOD->constants()->obj_at_addr(index));
a61af66fc99e Initial load
duke
parents:
diff changeset
1975 klassOop objKlassOop = STACK_OBJECT(-1)->klass(); //ebx
a61af66fc99e Initial load
duke
parents:
diff changeset
1976 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1977 // Check for compatibilty. This check must not GC!!
a61af66fc99e Initial load
duke
parents:
diff changeset
1978 // Seems way more expensive now that we must dispatch
a61af66fc99e Initial load
duke
parents:
diff changeset
1979 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1980 if (objKlassOop != klassOf &&
a61af66fc99e Initial load
duke
parents:
diff changeset
1981 !objKlassOop->klass_part()->is_subtype_of(klassOf)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1982 ResourceMark rm(THREAD);
a61af66fc99e Initial load
duke
parents:
diff changeset
1983 const char* objName = Klass::cast(objKlassOop)->external_name();
a61af66fc99e Initial load
duke
parents:
diff changeset
1984 const char* klassName = Klass::cast(klassOf)->external_name();
a61af66fc99e Initial load
duke
parents:
diff changeset
1985 char* message = SharedRuntime::generate_class_cast_message(
a61af66fc99e Initial load
duke
parents:
diff changeset
1986 objName, klassName);
a61af66fc99e Initial load
duke
parents:
diff changeset
1987 VM_JAVA_ERROR(vmSymbols::java_lang_ClassCastException(), message);
a61af66fc99e Initial load
duke
parents:
diff changeset
1988 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1989 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1990 if (UncommonNullCast) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1991 // istate->method()->set_null_cast_seen();
a61af66fc99e Initial load
duke
parents:
diff changeset
1992 // [RGV] Not sure what to do here!
a61af66fc99e Initial load
duke
parents:
diff changeset
1993
a61af66fc99e Initial load
duke
parents:
diff changeset
1994 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1995 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1996 UPDATE_PC_AND_CONTINUE(3);
a61af66fc99e Initial load
duke
parents:
diff changeset
1997
a61af66fc99e Initial load
duke
parents:
diff changeset
1998 CASE(_instanceof):
a61af66fc99e Initial load
duke
parents:
diff changeset
1999 if (STACK_OBJECT(-1) == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2000 SET_STACK_INT(0, -1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2001 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2002 u2 index = Bytes::get_Java_u2(pc+1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2003 // Constant pool may have actual klass or unresolved klass. If it is
a61af66fc99e Initial load
duke
parents:
diff changeset
2004 // unresolved we must resolve it
a61af66fc99e Initial load
duke
parents:
diff changeset
2005 if (METHOD->constants()->tag_at(index).is_unresolved_klass()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2006 CALL_VM(InterpreterRuntime::quicken_io_cc(THREAD), handle_exception);
a61af66fc99e Initial load
duke
parents:
diff changeset
2007 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2008 klassOop klassOf = (klassOop) *(METHOD->constants()->obj_at_addr(index));
a61af66fc99e Initial load
duke
parents:
diff changeset
2009 klassOop objKlassOop = STACK_OBJECT(-1)->klass();
a61af66fc99e Initial load
duke
parents:
diff changeset
2010 //
a61af66fc99e Initial load
duke
parents:
diff changeset
2011 // Check for compatibilty. This check must not GC!!
a61af66fc99e Initial load
duke
parents:
diff changeset
2012 // Seems way more expensive now that we must dispatch
a61af66fc99e Initial load
duke
parents:
diff changeset
2013 //
a61af66fc99e Initial load
duke
parents:
diff changeset
2014 if ( objKlassOop == klassOf || objKlassOop->klass_part()->is_subtype_of(klassOf)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2015 SET_STACK_INT(1, -1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2016 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2017 SET_STACK_INT(0, -1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2018 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2019 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2020 UPDATE_PC_AND_CONTINUE(3);
a61af66fc99e Initial load
duke
parents:
diff changeset
2021
a61af66fc99e Initial load
duke
parents:
diff changeset
2022 CASE(_ldc_w):
a61af66fc99e Initial load
duke
parents:
diff changeset
2023 CASE(_ldc):
a61af66fc99e Initial load
duke
parents:
diff changeset
2024 {
a61af66fc99e Initial load
duke
parents:
diff changeset
2025 u2 index;
a61af66fc99e Initial load
duke
parents:
diff changeset
2026 bool wide = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
2027 int incr = 2; // frequent case
a61af66fc99e Initial load
duke
parents:
diff changeset
2028 if (opcode == Bytecodes::_ldc) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2029 index = pc[1];
a61af66fc99e Initial load
duke
parents:
diff changeset
2030 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2031 index = Bytes::get_Java_u2(pc+1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2032 incr = 3;
a61af66fc99e Initial load
duke
parents:
diff changeset
2033 wide = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
2034 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2035
a61af66fc99e Initial load
duke
parents:
diff changeset
2036 constantPoolOop constants = METHOD->constants();
a61af66fc99e Initial load
duke
parents:
diff changeset
2037 switch (constants->tag_at(index).value()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2038 case JVM_CONSTANT_Integer:
a61af66fc99e Initial load
duke
parents:
diff changeset
2039 SET_STACK_INT(constants->int_at(index), 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
2040 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2041
a61af66fc99e Initial load
duke
parents:
diff changeset
2042 case JVM_CONSTANT_Float:
a61af66fc99e Initial load
duke
parents:
diff changeset
2043 SET_STACK_FLOAT(constants->float_at(index), 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
2044 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2045
a61af66fc99e Initial load
duke
parents:
diff changeset
2046 case JVM_CONSTANT_String:
a61af66fc99e Initial load
duke
parents:
diff changeset
2047 SET_STACK_OBJECT(constants->resolved_string_at(index), 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
2048 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2049
a61af66fc99e Initial load
duke
parents:
diff changeset
2050 case JVM_CONSTANT_Class:
a61af66fc99e Initial load
duke
parents:
diff changeset
2051 SET_STACK_OBJECT(constants->resolved_klass_at(index)->klass_part()->java_mirror(), 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
2052 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2053
a61af66fc99e Initial load
duke
parents:
diff changeset
2054 case JVM_CONSTANT_UnresolvedString:
a61af66fc99e Initial load
duke
parents:
diff changeset
2055 case JVM_CONSTANT_UnresolvedClass:
a61af66fc99e Initial load
duke
parents:
diff changeset
2056 case JVM_CONSTANT_UnresolvedClassInError:
a61af66fc99e Initial load
duke
parents:
diff changeset
2057 CALL_VM(InterpreterRuntime::ldc(THREAD, wide), handle_exception);
a61af66fc99e Initial load
duke
parents:
diff changeset
2058 SET_STACK_OBJECT(THREAD->vm_result(), 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
2059 THREAD->set_vm_result(NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
2060 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2061
a61af66fc99e Initial load
duke
parents:
diff changeset
2062 #if 0
a61af66fc99e Initial load
duke
parents:
diff changeset
2063 CASE(_fast_igetfield):
a61af66fc99e Initial load
duke
parents:
diff changeset
2064 CASE(_fastagetfield):
a61af66fc99e Initial load
duke
parents:
diff changeset
2065 CASE(_fast_aload_0):
a61af66fc99e Initial load
duke
parents:
diff changeset
2066 CASE(_fast_iaccess_0):
a61af66fc99e Initial load
duke
parents:
diff changeset
2067 CASE(__fast_aaccess_0):
a61af66fc99e Initial load
duke
parents:
diff changeset
2068 CASE(_fast_linearswitch):
a61af66fc99e Initial load
duke
parents:
diff changeset
2069 CASE(_fast_binaryswitch):
a61af66fc99e Initial load
duke
parents:
diff changeset
2070 fatal("unsupported fast bytecode");
a61af66fc99e Initial load
duke
parents:
diff changeset
2071 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
2072
a61af66fc99e Initial load
duke
parents:
diff changeset
2073 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2074 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2075 UPDATE_PC_AND_TOS_AND_CONTINUE(incr, 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2076 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2077
a61af66fc99e Initial load
duke
parents:
diff changeset
2078 CASE(_ldc2_w):
a61af66fc99e Initial load
duke
parents:
diff changeset
2079 {
a61af66fc99e Initial load
duke
parents:
diff changeset
2080 u2 index = Bytes::get_Java_u2(pc+1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2081
a61af66fc99e Initial load
duke
parents:
diff changeset
2082 constantPoolOop constants = METHOD->constants();
a61af66fc99e Initial load
duke
parents:
diff changeset
2083 switch (constants->tag_at(index).value()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2084
a61af66fc99e Initial load
duke
parents:
diff changeset
2085 case JVM_CONSTANT_Long:
a61af66fc99e Initial load
duke
parents:
diff changeset
2086 SET_STACK_LONG(constants->long_at(index), 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2087 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2088
a61af66fc99e Initial load
duke
parents:
diff changeset
2089 case JVM_CONSTANT_Double:
a61af66fc99e Initial load
duke
parents:
diff changeset
2090 SET_STACK_DOUBLE(constants->double_at(index), 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2091 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2092 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2093 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2094 UPDATE_PC_AND_TOS_AND_CONTINUE(3, 2);
a61af66fc99e Initial load
duke
parents:
diff changeset
2095 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2096
a61af66fc99e Initial load
duke
parents:
diff changeset
2097 CASE(_invokeinterface): {
a61af66fc99e Initial load
duke
parents:
diff changeset
2098 u2 index = Bytes::get_native_u2(pc+1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2099
a61af66fc99e Initial load
duke
parents:
diff changeset
2100 // QQQ Need to make this as inlined as possible. Probably need to split all the bytecode cases
a61af66fc99e Initial load
duke
parents:
diff changeset
2101 // out so c++ compiler has a chance for constant prop to fold everything possible away.
a61af66fc99e Initial load
duke
parents:
diff changeset
2102
a61af66fc99e Initial load
duke
parents:
diff changeset
2103 ConstantPoolCacheEntry* cache = cp->entry_at(index);
a61af66fc99e Initial load
duke
parents:
diff changeset
2104 if (!cache->is_resolved((Bytecodes::Code)opcode)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2105 CALL_VM(InterpreterRuntime::resolve_invoke(THREAD, (Bytecodes::Code)opcode),
a61af66fc99e Initial load
duke
parents:
diff changeset
2106 handle_exception);
a61af66fc99e Initial load
duke
parents:
diff changeset
2107 cache = cp->entry_at(index);
a61af66fc99e Initial load
duke
parents:
diff changeset
2108 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2109
a61af66fc99e Initial load
duke
parents:
diff changeset
2110 istate->set_msg(call_method);
a61af66fc99e Initial load
duke
parents:
diff changeset
2111
a61af66fc99e Initial load
duke
parents:
diff changeset
2112 // Special case of invokeinterface called for virtual method of
a61af66fc99e Initial load
duke
parents:
diff changeset
2113 // java.lang.Object. See cpCacheOop.cpp for details.
a61af66fc99e Initial load
duke
parents:
diff changeset
2114 // This code isn't produced by javac, but could be produced by
a61af66fc99e Initial load
duke
parents:
diff changeset
2115 // another compliant java compiler.
a61af66fc99e Initial load
duke
parents:
diff changeset
2116 if (cache->is_methodInterface()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2117 methodOop callee;
a61af66fc99e Initial load
duke
parents:
diff changeset
2118 CHECK_NULL(STACK_OBJECT(-(cache->parameter_size())));
a61af66fc99e Initial load
duke
parents:
diff changeset
2119 if (cache->is_vfinal()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2120 callee = (methodOop) cache->f2();
a61af66fc99e Initial load
duke
parents:
diff changeset
2121 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2122 // get receiver
a61af66fc99e Initial load
duke
parents:
diff changeset
2123 int parms = cache->parameter_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
2124 // Same comments as invokevirtual apply here
a61af66fc99e Initial load
duke
parents:
diff changeset
2125 instanceKlass* rcvrKlass = (instanceKlass*)
a61af66fc99e Initial load
duke
parents:
diff changeset
2126 STACK_OBJECT(-parms)->klass()->klass_part();
a61af66fc99e Initial load
duke
parents:
diff changeset
2127 callee = (methodOop) rcvrKlass->start_of_vtable()[ cache->f2()];
a61af66fc99e Initial load
duke
parents:
diff changeset
2128 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2129 istate->set_callee(callee);
a61af66fc99e Initial load
duke
parents:
diff changeset
2130 istate->set_callee_entry_point(callee->from_interpreted_entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
2131 #ifdef VM_JVMTI
a61af66fc99e Initial load
duke
parents:
diff changeset
2132 if (JvmtiExport::can_post_interpreter_events() && THREAD->is_interp_only_mode()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2133 istate->set_callee_entry_point(callee->interpreter_entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
2134 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2135 #endif /* VM_JVMTI */
a61af66fc99e Initial load
duke
parents:
diff changeset
2136 istate->set_bcp_advance(5);
a61af66fc99e Initial load
duke
parents:
diff changeset
2137 UPDATE_PC_AND_RETURN(0); // I'll be back...
a61af66fc99e Initial load
duke
parents:
diff changeset
2138 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2139
a61af66fc99e Initial load
duke
parents:
diff changeset
2140 // this could definitely be cleaned up QQQ
a61af66fc99e Initial load
duke
parents:
diff changeset
2141 methodOop callee;
a61af66fc99e Initial load
duke
parents:
diff changeset
2142 klassOop iclass = (klassOop)cache->f1();
a61af66fc99e Initial load
duke
parents:
diff changeset
2143 // instanceKlass* interface = (instanceKlass*) iclass->klass_part();
a61af66fc99e Initial load
duke
parents:
diff changeset
2144 // get receiver
a61af66fc99e Initial load
duke
parents:
diff changeset
2145 int parms = cache->parameter_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
2146 oop rcvr = STACK_OBJECT(-parms);
a61af66fc99e Initial load
duke
parents:
diff changeset
2147 CHECK_NULL(rcvr);
a61af66fc99e Initial load
duke
parents:
diff changeset
2148 instanceKlass* int2 = (instanceKlass*) rcvr->klass()->klass_part();
a61af66fc99e Initial load
duke
parents:
diff changeset
2149 itableOffsetEntry* ki = (itableOffsetEntry*) int2->start_of_itable();
a61af66fc99e Initial load
duke
parents:
diff changeset
2150 int i;
a61af66fc99e Initial load
duke
parents:
diff changeset
2151 for ( i = 0 ; i < int2->itable_length() ; i++, ki++ ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2152 if (ki->interface_klass() == iclass) break;
a61af66fc99e Initial load
duke
parents:
diff changeset
2153 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2154 // If the interface isn't found, this class doesn't implement this
a61af66fc99e Initial load
duke
parents:
diff changeset
2155 // interface. The link resolver checks this but only for the first
a61af66fc99e Initial load
duke
parents:
diff changeset
2156 // time this interface is called.
a61af66fc99e Initial load
duke
parents:
diff changeset
2157 if (i == int2->itable_length()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2158 VM_JAVA_ERROR(vmSymbols::java_lang_IncompatibleClassChangeError(), "");
a61af66fc99e Initial load
duke
parents:
diff changeset
2159 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2160 int mindex = cache->f2();
a61af66fc99e Initial load
duke
parents:
diff changeset
2161 itableMethodEntry* im = ki->first_method_entry(rcvr->klass());
a61af66fc99e Initial load
duke
parents:
diff changeset
2162 callee = im[mindex].method();
a61af66fc99e Initial load
duke
parents:
diff changeset
2163 if (callee == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2164 VM_JAVA_ERROR(vmSymbols::java_lang_AbstractMethodError(), "");
a61af66fc99e Initial load
duke
parents:
diff changeset
2165 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2166
a61af66fc99e Initial load
duke
parents:
diff changeset
2167 istate->set_callee(callee);
a61af66fc99e Initial load
duke
parents:
diff changeset
2168 istate->set_callee_entry_point(callee->from_interpreted_entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
2169 #ifdef VM_JVMTI
a61af66fc99e Initial load
duke
parents:
diff changeset
2170 if (JvmtiExport::can_post_interpreter_events() && THREAD->is_interp_only_mode()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2171 istate->set_callee_entry_point(callee->interpreter_entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
2172 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2173 #endif /* VM_JVMTI */
a61af66fc99e Initial load
duke
parents:
diff changeset
2174 istate->set_bcp_advance(5);
a61af66fc99e Initial load
duke
parents:
diff changeset
2175 UPDATE_PC_AND_RETURN(0); // I'll be back...
a61af66fc99e Initial load
duke
parents:
diff changeset
2176 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2177
a61af66fc99e Initial load
duke
parents:
diff changeset
2178 CASE(_invokevirtual):
a61af66fc99e Initial load
duke
parents:
diff changeset
2179 CASE(_invokespecial):
a61af66fc99e Initial load
duke
parents:
diff changeset
2180 CASE(_invokestatic): {
a61af66fc99e Initial load
duke
parents:
diff changeset
2181 u2 index = Bytes::get_native_u2(pc+1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2182
a61af66fc99e Initial load
duke
parents:
diff changeset
2183 ConstantPoolCacheEntry* cache = cp->entry_at(index);
a61af66fc99e Initial load
duke
parents:
diff changeset
2184 // QQQ Need to make this as inlined as possible. Probably need to split all the bytecode cases
a61af66fc99e Initial load
duke
parents:
diff changeset
2185 // out so c++ compiler has a chance for constant prop to fold everything possible away.
a61af66fc99e Initial load
duke
parents:
diff changeset
2186
a61af66fc99e Initial load
duke
parents:
diff changeset
2187 if (!cache->is_resolved((Bytecodes::Code)opcode)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2188 CALL_VM(InterpreterRuntime::resolve_invoke(THREAD, (Bytecodes::Code)opcode),
a61af66fc99e Initial load
duke
parents:
diff changeset
2189 handle_exception);
a61af66fc99e Initial load
duke
parents:
diff changeset
2190 cache = cp->entry_at(index);
a61af66fc99e Initial load
duke
parents:
diff changeset
2191 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2192
a61af66fc99e Initial load
duke
parents:
diff changeset
2193 istate->set_msg(call_method);
a61af66fc99e Initial load
duke
parents:
diff changeset
2194 {
a61af66fc99e Initial load
duke
parents:
diff changeset
2195 methodOop callee;
a61af66fc99e Initial load
duke
parents:
diff changeset
2196 if ((Bytecodes::Code)opcode == Bytecodes::_invokevirtual) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2197 CHECK_NULL(STACK_OBJECT(-(cache->parameter_size())));
a61af66fc99e Initial load
duke
parents:
diff changeset
2198 if (cache->is_vfinal()) callee = (methodOop) cache->f2();
a61af66fc99e Initial load
duke
parents:
diff changeset
2199 else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2200 // get receiver
a61af66fc99e Initial load
duke
parents:
diff changeset
2201 int parms = cache->parameter_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
2202 // this works but needs a resourcemark and seems to create a vtable on every call:
a61af66fc99e Initial load
duke
parents:
diff changeset
2203 // methodOop callee = rcvr->klass()->klass_part()->vtable()->method_at(cache->f2());
a61af66fc99e Initial load
duke
parents:
diff changeset
2204 //
a61af66fc99e Initial load
duke
parents:
diff changeset
2205 // this fails with an assert
a61af66fc99e Initial load
duke
parents:
diff changeset
2206 // instanceKlass* rcvrKlass = instanceKlass::cast(STACK_OBJECT(-parms)->klass());
a61af66fc99e Initial load
duke
parents:
diff changeset
2207 // but this works
a61af66fc99e Initial load
duke
parents:
diff changeset
2208 instanceKlass* rcvrKlass = (instanceKlass*) STACK_OBJECT(-parms)->klass()->klass_part();
a61af66fc99e Initial load
duke
parents:
diff changeset
2209 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
2210 Executing this code in java.lang.String:
a61af66fc99e Initial load
duke
parents:
diff changeset
2211 public String(char value[]) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2212 this.count = value.length;
a61af66fc99e Initial load
duke
parents:
diff changeset
2213 this.value = (char[])value.clone();
a61af66fc99e Initial load
duke
parents:
diff changeset
2214 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2215
a61af66fc99e Initial load
duke
parents:
diff changeset
2216 a find on rcvr->klass()->klass_part() reports:
a61af66fc99e Initial load
duke
parents:
diff changeset
2217 {type array char}{type array class}
a61af66fc99e Initial load
duke
parents:
diff changeset
2218 - klass: {other class}
a61af66fc99e Initial load
duke
parents:
diff changeset
2219
a61af66fc99e Initial load
duke
parents:
diff changeset
2220 but using instanceKlass::cast(STACK_OBJECT(-parms)->klass()) causes in assertion failure
a61af66fc99e Initial load
duke
parents:
diff changeset
2221 because rcvr->klass()->klass_part()->oop_is_instance() == 0
a61af66fc99e Initial load
duke
parents:
diff changeset
2222 However it seems to have a vtable in the right location. Huh?
a61af66fc99e Initial load
duke
parents:
diff changeset
2223
a61af66fc99e Initial load
duke
parents:
diff changeset
2224 */
a61af66fc99e Initial load
duke
parents:
diff changeset
2225 callee = (methodOop) rcvrKlass->start_of_vtable()[ cache->f2()];
a61af66fc99e Initial load
duke
parents:
diff changeset
2226 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2227 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2228 if ((Bytecodes::Code)opcode == Bytecodes::_invokespecial) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2229 CHECK_NULL(STACK_OBJECT(-(cache->parameter_size())));
a61af66fc99e Initial load
duke
parents:
diff changeset
2230 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2231 callee = (methodOop) cache->f1();
a61af66fc99e Initial load
duke
parents:
diff changeset
2232 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2233
a61af66fc99e Initial load
duke
parents:
diff changeset
2234 istate->set_callee(callee);
a61af66fc99e Initial load
duke
parents:
diff changeset
2235 istate->set_callee_entry_point(callee->from_interpreted_entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
2236 #ifdef VM_JVMTI
a61af66fc99e Initial load
duke
parents:
diff changeset
2237 if (JvmtiExport::can_post_interpreter_events() && THREAD->is_interp_only_mode()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2238 istate->set_callee_entry_point(callee->interpreter_entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
2239 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2240 #endif /* VM_JVMTI */
a61af66fc99e Initial load
duke
parents:
diff changeset
2241 istate->set_bcp_advance(3);
a61af66fc99e Initial load
duke
parents:
diff changeset
2242 UPDATE_PC_AND_RETURN(0); // I'll be back...
a61af66fc99e Initial load
duke
parents:
diff changeset
2243 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2244 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2245
a61af66fc99e Initial load
duke
parents:
diff changeset
2246 /* Allocate memory for a new java object. */
a61af66fc99e Initial load
duke
parents:
diff changeset
2247
a61af66fc99e Initial load
duke
parents:
diff changeset
2248 CASE(_newarray): {
a61af66fc99e Initial load
duke
parents:
diff changeset
2249 BasicType atype = (BasicType) *(pc+1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2250 jint size = STACK_INT(-1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2251 CALL_VM(InterpreterRuntime::newarray(THREAD, atype, size),
a61af66fc99e Initial load
duke
parents:
diff changeset
2252 handle_exception);
a61af66fc99e Initial load
duke
parents:
diff changeset
2253 SET_STACK_OBJECT(THREAD->vm_result(), -1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2254 THREAD->set_vm_result(NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
2255
a61af66fc99e Initial load
duke
parents:
diff changeset
2256 UPDATE_PC_AND_CONTINUE(2);
a61af66fc99e Initial load
duke
parents:
diff changeset
2257 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2258
a61af66fc99e Initial load
duke
parents:
diff changeset
2259 /* Throw an exception. */
a61af66fc99e Initial load
duke
parents:
diff changeset
2260
a61af66fc99e Initial load
duke
parents:
diff changeset
2261 CASE(_athrow): {
a61af66fc99e Initial load
duke
parents:
diff changeset
2262 oop except_oop = STACK_OBJECT(-1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2263 CHECK_NULL(except_oop);
a61af66fc99e Initial load
duke
parents:
diff changeset
2264 // set pending_exception so we use common code
a61af66fc99e Initial load
duke
parents:
diff changeset
2265 THREAD->set_pending_exception(except_oop, NULL, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
2266 goto handle_exception;
a61af66fc99e Initial load
duke
parents:
diff changeset
2267 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2268
a61af66fc99e Initial load
duke
parents:
diff changeset
2269 /* goto and jsr. They are exactly the same except jsr pushes
a61af66fc99e Initial load
duke
parents:
diff changeset
2270 * the address of the next instruction first.
a61af66fc99e Initial load
duke
parents:
diff changeset
2271 */
a61af66fc99e Initial load
duke
parents:
diff changeset
2272
a61af66fc99e Initial load
duke
parents:
diff changeset
2273 CASE(_jsr): {
a61af66fc99e Initial load
duke
parents:
diff changeset
2274 /* push bytecode index on stack */
a61af66fc99e Initial load
duke
parents:
diff changeset
2275 SET_STACK_ADDR(((address)pc - (intptr_t)(istate->method()->code_base()) + 3), 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
2276 MORE_STACK(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2277 /* FALL THROUGH */
a61af66fc99e Initial load
duke
parents:
diff changeset
2278 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2279
a61af66fc99e Initial load
duke
parents:
diff changeset
2280 CASE(_goto):
a61af66fc99e Initial load
duke
parents:
diff changeset
2281 {
a61af66fc99e Initial load
duke
parents:
diff changeset
2282 int16_t offset = (int16_t)Bytes::get_Java_u2(pc + 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2283 address branch_pc = pc;
a61af66fc99e Initial load
duke
parents:
diff changeset
2284 UPDATE_PC(offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
2285 DO_BACKEDGE_CHECKS(offset, branch_pc);
a61af66fc99e Initial load
duke
parents:
diff changeset
2286 CONTINUE;
a61af66fc99e Initial load
duke
parents:
diff changeset
2287 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2288
a61af66fc99e Initial load
duke
parents:
diff changeset
2289 CASE(_jsr_w): {
a61af66fc99e Initial load
duke
parents:
diff changeset
2290 /* push return address on the stack */
a61af66fc99e Initial load
duke
parents:
diff changeset
2291 SET_STACK_ADDR(((address)pc - (intptr_t)(istate->method()->code_base()) + 5), 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
2292 MORE_STACK(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2293 /* FALL THROUGH */
a61af66fc99e Initial load
duke
parents:
diff changeset
2294 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2295
a61af66fc99e Initial load
duke
parents:
diff changeset
2296 CASE(_goto_w):
a61af66fc99e Initial load
duke
parents:
diff changeset
2297 {
a61af66fc99e Initial load
duke
parents:
diff changeset
2298 int32_t offset = Bytes::get_Java_u4(pc + 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2299 address branch_pc = pc;
a61af66fc99e Initial load
duke
parents:
diff changeset
2300 UPDATE_PC(offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
2301 DO_BACKEDGE_CHECKS(offset, branch_pc);
a61af66fc99e Initial load
duke
parents:
diff changeset
2302 CONTINUE;
a61af66fc99e Initial load
duke
parents:
diff changeset
2303 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2304
a61af66fc99e Initial load
duke
parents:
diff changeset
2305 /* return from a jsr or jsr_w */
a61af66fc99e Initial load
duke
parents:
diff changeset
2306
a61af66fc99e Initial load
duke
parents:
diff changeset
2307 CASE(_ret): {
a61af66fc99e Initial load
duke
parents:
diff changeset
2308 pc = istate->method()->code_base() + (intptr_t)(LOCALS_ADDR(pc[1]));
a61af66fc99e Initial load
duke
parents:
diff changeset
2309 UPDATE_PC_AND_CONTINUE(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
2310 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2311
a61af66fc99e Initial load
duke
parents:
diff changeset
2312 /* debugger breakpoint */
a61af66fc99e Initial load
duke
parents:
diff changeset
2313
a61af66fc99e Initial load
duke
parents:
diff changeset
2314 CASE(_breakpoint): {
a61af66fc99e Initial load
duke
parents:
diff changeset
2315 Bytecodes::Code original_bytecode;
a61af66fc99e Initial load
duke
parents:
diff changeset
2316 DECACHE_STATE();
a61af66fc99e Initial load
duke
parents:
diff changeset
2317 SET_LAST_JAVA_FRAME();
a61af66fc99e Initial load
duke
parents:
diff changeset
2318 original_bytecode = InterpreterRuntime::get_original_bytecode_at(THREAD,
a61af66fc99e Initial load
duke
parents:
diff changeset
2319 METHOD, pc);
a61af66fc99e Initial load
duke
parents:
diff changeset
2320 RESET_LAST_JAVA_FRAME();
a61af66fc99e Initial load
duke
parents:
diff changeset
2321 CACHE_STATE();
a61af66fc99e Initial load
duke
parents:
diff changeset
2322 if (THREAD->has_pending_exception()) goto handle_exception;
a61af66fc99e Initial load
duke
parents:
diff changeset
2323 CALL_VM(InterpreterRuntime::_breakpoint(THREAD, METHOD, pc),
a61af66fc99e Initial load
duke
parents:
diff changeset
2324 handle_exception);
a61af66fc99e Initial load
duke
parents:
diff changeset
2325
a61af66fc99e Initial load
duke
parents:
diff changeset
2326 opcode = (jubyte)original_bytecode;
a61af66fc99e Initial load
duke
parents:
diff changeset
2327 goto opcode_switch;
a61af66fc99e Initial load
duke
parents:
diff changeset
2328 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2329
a61af66fc99e Initial load
duke
parents:
diff changeset
2330 DEFAULT:
a61af66fc99e Initial load
duke
parents:
diff changeset
2331 fatal2("\t*** Unimplemented opcode: %d = %s\n",
a61af66fc99e Initial load
duke
parents:
diff changeset
2332 opcode, Bytecodes::name((Bytecodes::Code)opcode));
a61af66fc99e Initial load
duke
parents:
diff changeset
2333 goto finish;
a61af66fc99e Initial load
duke
parents:
diff changeset
2334
a61af66fc99e Initial load
duke
parents:
diff changeset
2335 } /* switch(opc) */
a61af66fc99e Initial load
duke
parents:
diff changeset
2336
a61af66fc99e Initial load
duke
parents:
diff changeset
2337
a61af66fc99e Initial load
duke
parents:
diff changeset
2338 #ifdef USELABELS
a61af66fc99e Initial load
duke
parents:
diff changeset
2339 check_for_exception:
a61af66fc99e Initial load
duke
parents:
diff changeset
2340 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
2341 {
a61af66fc99e Initial load
duke
parents:
diff changeset
2342 if (!THREAD->has_pending_exception()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2343 CONTINUE;
a61af66fc99e Initial load
duke
parents:
diff changeset
2344 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2345 /* We will be gcsafe soon, so flush our state. */
a61af66fc99e Initial load
duke
parents:
diff changeset
2346 DECACHE_PC();
a61af66fc99e Initial load
duke
parents:
diff changeset
2347 goto handle_exception;
a61af66fc99e Initial load
duke
parents:
diff changeset
2348 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2349 do_continue: ;
a61af66fc99e Initial load
duke
parents:
diff changeset
2350
a61af66fc99e Initial load
duke
parents:
diff changeset
2351 } /* while (1) interpreter loop */
a61af66fc99e Initial load
duke
parents:
diff changeset
2352
a61af66fc99e Initial load
duke
parents:
diff changeset
2353
a61af66fc99e Initial load
duke
parents:
diff changeset
2354 // An exception exists in the thread state see whether this activation can handle it
a61af66fc99e Initial load
duke
parents:
diff changeset
2355 handle_exception: {
a61af66fc99e Initial load
duke
parents:
diff changeset
2356
a61af66fc99e Initial load
duke
parents:
diff changeset
2357 HandleMarkCleaner __hmc(THREAD);
a61af66fc99e Initial load
duke
parents:
diff changeset
2358 Handle except_oop(THREAD, THREAD->pending_exception());
a61af66fc99e Initial load
duke
parents:
diff changeset
2359 // Prevent any subsequent HandleMarkCleaner in the VM
a61af66fc99e Initial load
duke
parents:
diff changeset
2360 // from freeing the except_oop handle.
a61af66fc99e Initial load
duke
parents:
diff changeset
2361 HandleMark __hm(THREAD);
a61af66fc99e Initial load
duke
parents:
diff changeset
2362
a61af66fc99e Initial load
duke
parents:
diff changeset
2363 THREAD->clear_pending_exception();
a61af66fc99e Initial load
duke
parents:
diff changeset
2364 assert(except_oop(), "No exception to process");
a61af66fc99e Initial load
duke
parents:
diff changeset
2365 intptr_t continuation_bci;
a61af66fc99e Initial load
duke
parents:
diff changeset
2366 // expression stack is emptied
a61af66fc99e Initial load
duke
parents:
diff changeset
2367 topOfStack = istate->stack_base() - Interpreter::stackElementWords();
a61af66fc99e Initial load
duke
parents:
diff changeset
2368 CALL_VM(continuation_bci = (intptr_t)InterpreterRuntime::exception_handler_for_exception(THREAD, except_oop()),
a61af66fc99e Initial load
duke
parents:
diff changeset
2369 handle_exception);
a61af66fc99e Initial load
duke
parents:
diff changeset
2370
a61af66fc99e Initial load
duke
parents:
diff changeset
2371 except_oop = (oop) THREAD->vm_result();
a61af66fc99e Initial load
duke
parents:
diff changeset
2372 THREAD->set_vm_result(NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
2373 if (continuation_bci >= 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2374 // Place exception on top of stack
a61af66fc99e Initial load
duke
parents:
diff changeset
2375 SET_STACK_OBJECT(except_oop(), 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
2376 MORE_STACK(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2377 pc = METHOD->code_base() + continuation_bci;
a61af66fc99e Initial load
duke
parents:
diff changeset
2378 if (TraceExceptions) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2379 ttyLocker ttyl;
a61af66fc99e Initial load
duke
parents:
diff changeset
2380 ResourceMark rm;
a61af66fc99e Initial load
duke
parents:
diff changeset
2381 tty->print_cr("Exception <%s> (" INTPTR_FORMAT ")", except_oop->print_value_string(), except_oop());
a61af66fc99e Initial load
duke
parents:
diff changeset
2382 tty->print_cr(" thrown in interpreter method <%s>", METHOD->print_value_string());
a61af66fc99e Initial load
duke
parents:
diff changeset
2383 tty->print_cr(" at bci %d, continuing at %d for thread " INTPTR_FORMAT,
a61af66fc99e Initial load
duke
parents:
diff changeset
2384 pc - (intptr_t)METHOD->code_base(),
a61af66fc99e Initial load
duke
parents:
diff changeset
2385 continuation_bci, THREAD);
a61af66fc99e Initial load
duke
parents:
diff changeset
2386 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2387 // for AbortVMOnException flag
a61af66fc99e Initial load
duke
parents:
diff changeset
2388 NOT_PRODUCT(Exceptions::debug_check_abort(except_oop));
a61af66fc99e Initial load
duke
parents:
diff changeset
2389 goto run;
a61af66fc99e Initial load
duke
parents:
diff changeset
2390 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2391 if (TraceExceptions) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2392 ttyLocker ttyl;
a61af66fc99e Initial load
duke
parents:
diff changeset
2393 ResourceMark rm;
a61af66fc99e Initial load
duke
parents:
diff changeset
2394 tty->print_cr("Exception <%s> (" INTPTR_FORMAT ")", except_oop->print_value_string(), except_oop());
a61af66fc99e Initial load
duke
parents:
diff changeset
2395 tty->print_cr(" thrown in interpreter method <%s>", METHOD->print_value_string());
a61af66fc99e Initial load
duke
parents:
diff changeset
2396 tty->print_cr(" at bci %d, unwinding for thread " INTPTR_FORMAT,
a61af66fc99e Initial load
duke
parents:
diff changeset
2397 pc - (intptr_t) METHOD->code_base(),
a61af66fc99e Initial load
duke
parents:
diff changeset
2398 THREAD);
a61af66fc99e Initial load
duke
parents:
diff changeset
2399 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2400 // for AbortVMOnException flag
a61af66fc99e Initial load
duke
parents:
diff changeset
2401 NOT_PRODUCT(Exceptions::debug_check_abort(except_oop));
a61af66fc99e Initial load
duke
parents:
diff changeset
2402 // No handler in this activation, unwind and try again
a61af66fc99e Initial load
duke
parents:
diff changeset
2403 THREAD->set_pending_exception(except_oop(), NULL, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
2404 goto handle_return;
a61af66fc99e Initial load
duke
parents:
diff changeset
2405 } /* handle_exception: */
a61af66fc99e Initial load
duke
parents:
diff changeset
2406
a61af66fc99e Initial load
duke
parents:
diff changeset
2407
a61af66fc99e Initial load
duke
parents:
diff changeset
2408
a61af66fc99e Initial load
duke
parents:
diff changeset
2409 // Return from an interpreter invocation with the result of the interpretation
a61af66fc99e Initial load
duke
parents:
diff changeset
2410 // on the top of the Java Stack (or a pending exception)
a61af66fc99e Initial load
duke
parents:
diff changeset
2411
a61af66fc99e Initial load
duke
parents:
diff changeset
2412 handle_Pop_Frame:
a61af66fc99e Initial load
duke
parents:
diff changeset
2413
a61af66fc99e Initial load
duke
parents:
diff changeset
2414 // We don't really do anything special here except we must be aware
a61af66fc99e Initial load
duke
parents:
diff changeset
2415 // that we can get here without ever locking the method (if sync).
a61af66fc99e Initial load
duke
parents:
diff changeset
2416 // Also we skip the notification of the exit.
a61af66fc99e Initial load
duke
parents:
diff changeset
2417
a61af66fc99e Initial load
duke
parents:
diff changeset
2418 istate->set_msg(popping_frame);
a61af66fc99e Initial load
duke
parents:
diff changeset
2419 // Clear pending so while the pop is in process
a61af66fc99e Initial load
duke
parents:
diff changeset
2420 // we don't start another one if a call_vm is done.
a61af66fc99e Initial load
duke
parents:
diff changeset
2421 THREAD->clr_pop_frame_pending();
a61af66fc99e Initial load
duke
parents:
diff changeset
2422 // Let interpreter (only) see the we're in the process of popping a frame
a61af66fc99e Initial load
duke
parents:
diff changeset
2423 THREAD->set_pop_frame_in_process();
a61af66fc99e Initial load
duke
parents:
diff changeset
2424
a61af66fc99e Initial load
duke
parents:
diff changeset
2425 handle_return:
a61af66fc99e Initial load
duke
parents:
diff changeset
2426 {
a61af66fc99e Initial load
duke
parents:
diff changeset
2427 DECACHE_STATE();
a61af66fc99e Initial load
duke
parents:
diff changeset
2428
a61af66fc99e Initial load
duke
parents:
diff changeset
2429 bool suppress_error = istate->msg() == popping_frame;
a61af66fc99e Initial load
duke
parents:
diff changeset
2430 bool suppress_exit_event = THREAD->has_pending_exception() || suppress_error;
a61af66fc99e Initial load
duke
parents:
diff changeset
2431 Handle original_exception(THREAD, THREAD->pending_exception());
a61af66fc99e Initial load
duke
parents:
diff changeset
2432 Handle illegal_state_oop(THREAD, NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
2433
a61af66fc99e Initial load
duke
parents:
diff changeset
2434 // We'd like a HandleMark here to prevent any subsequent HandleMarkCleaner
a61af66fc99e Initial load
duke
parents:
diff changeset
2435 // in any following VM entries from freeing our live handles, but illegal_state_oop
a61af66fc99e Initial load
duke
parents:
diff changeset
2436 // isn't really allocated yet and so doesn't become live until later and
a61af66fc99e Initial load
duke
parents:
diff changeset
2437 // in unpredicatable places. Instead we must protect the places where we enter the
a61af66fc99e Initial load
duke
parents:
diff changeset
2438 // VM. It would be much simpler (and safer) if we could allocate a real handle with
a61af66fc99e Initial load
duke
parents:
diff changeset
2439 // a NULL oop in it and then overwrite the oop later as needed. This isn't
a61af66fc99e Initial load
duke
parents:
diff changeset
2440 // unfortunately isn't possible.
a61af66fc99e Initial load
duke
parents:
diff changeset
2441
a61af66fc99e Initial load
duke
parents:
diff changeset
2442 THREAD->clear_pending_exception();
a61af66fc99e Initial load
duke
parents:
diff changeset
2443
a61af66fc99e Initial load
duke
parents:
diff changeset
2444 //
a61af66fc99e Initial load
duke
parents:
diff changeset
2445 // As far as we are concerned we have returned. If we have a pending exception
a61af66fc99e Initial load
duke
parents:
diff changeset
2446 // that will be returned as this invocation's result. However if we get any
a61af66fc99e Initial load
duke
parents:
diff changeset
2447 // exception(s) while checking monitor state one of those IllegalMonitorStateExceptions
a61af66fc99e Initial load
duke
parents:
diff changeset
2448 // will be our final result (i.e. monitor exception trumps a pending exception).
a61af66fc99e Initial load
duke
parents:
diff changeset
2449 //
a61af66fc99e Initial load
duke
parents:
diff changeset
2450
a61af66fc99e Initial load
duke
parents:
diff changeset
2451 // If we never locked the method (or really passed the point where we would have),
a61af66fc99e Initial load
duke
parents:
diff changeset
2452 // there is no need to unlock it (or look for other monitors), since that
a61af66fc99e Initial load
duke
parents:
diff changeset
2453 // could not have happened.
a61af66fc99e Initial load
duke
parents:
diff changeset
2454
a61af66fc99e Initial load
duke
parents:
diff changeset
2455 if (THREAD->do_not_unlock()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2456
a61af66fc99e Initial load
duke
parents:
diff changeset
2457 // Never locked, reset the flag now because obviously any caller must
a61af66fc99e Initial load
duke
parents:
diff changeset
2458 // have passed their point of locking for us to have gotten here.
a61af66fc99e Initial load
duke
parents:
diff changeset
2459
a61af66fc99e Initial load
duke
parents:
diff changeset
2460 THREAD->clr_do_not_unlock();
a61af66fc99e Initial load
duke
parents:
diff changeset
2461 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2462 // At this point we consider that we have returned. We now check that the
a61af66fc99e Initial load
duke
parents:
diff changeset
2463 // locks were properly block structured. If we find that they were not
a61af66fc99e Initial load
duke
parents:
diff changeset
2464 // used properly we will return with an illegal monitor exception.
a61af66fc99e Initial load
duke
parents:
diff changeset
2465 // The exception is checked by the caller not the callee since this
a61af66fc99e Initial load
duke
parents:
diff changeset
2466 // checking is considered to be part of the invocation and therefore
a61af66fc99e Initial load
duke
parents:
diff changeset
2467 // in the callers scope (JVM spec 8.13).
a61af66fc99e Initial load
duke
parents:
diff changeset
2468 //
a61af66fc99e Initial load
duke
parents:
diff changeset
2469 // Another weird thing to watch for is if the method was locked
a61af66fc99e Initial load
duke
parents:
diff changeset
2470 // recursively and then not exited properly. This means we must
a61af66fc99e Initial load
duke
parents:
diff changeset
2471 // examine all the entries in reverse time(and stack) order and
a61af66fc99e Initial load
duke
parents:
diff changeset
2472 // unlock as we find them. If we find the method monitor before
a61af66fc99e Initial load
duke
parents:
diff changeset
2473 // we are at the initial entry then we should throw an exception.
a61af66fc99e Initial load
duke
parents:
diff changeset
2474 // It is not clear the template based interpreter does this
a61af66fc99e Initial load
duke
parents:
diff changeset
2475 // correctly
a61af66fc99e Initial load
duke
parents:
diff changeset
2476
a61af66fc99e Initial load
duke
parents:
diff changeset
2477 BasicObjectLock* base = istate->monitor_base();
a61af66fc99e Initial load
duke
parents:
diff changeset
2478 BasicObjectLock* end = (BasicObjectLock*) istate->stack_base();
a61af66fc99e Initial load
duke
parents:
diff changeset
2479 bool method_unlock_needed = METHOD->is_synchronized();
a61af66fc99e Initial load
duke
parents:
diff changeset
2480 // We know the initial monitor was used for the method don't check that
a61af66fc99e Initial load
duke
parents:
diff changeset
2481 // slot in the loop
a61af66fc99e Initial load
duke
parents:
diff changeset
2482 if (method_unlock_needed) base--;
a61af66fc99e Initial load
duke
parents:
diff changeset
2483
a61af66fc99e Initial load
duke
parents:
diff changeset
2484 // Check all the monitors to see they are unlocked. Install exception if found to be locked.
a61af66fc99e Initial load
duke
parents:
diff changeset
2485 while (end < base) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2486 oop lockee = end->obj();
a61af66fc99e Initial load
duke
parents:
diff changeset
2487 if (lockee != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2488 BasicLock* lock = end->lock();
a61af66fc99e Initial load
duke
parents:
diff changeset
2489 markOop header = lock->displaced_header();
a61af66fc99e Initial load
duke
parents:
diff changeset
2490 end->set_obj(NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
2491 // If it isn't recursive we either must swap old header or call the runtime
a61af66fc99e Initial load
duke
parents:
diff changeset
2492 if (header != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2493 if (Atomic::cmpxchg_ptr(header, lockee->mark_addr(), lock) != lock) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2494 // restore object for the slow case
a61af66fc99e Initial load
duke
parents:
diff changeset
2495 end->set_obj(lockee);
a61af66fc99e Initial load
duke
parents:
diff changeset
2496 {
a61af66fc99e Initial load
duke
parents:
diff changeset
2497 // Prevent any HandleMarkCleaner from freeing our live handles
a61af66fc99e Initial load
duke
parents:
diff changeset
2498 HandleMark __hm(THREAD);
a61af66fc99e Initial load
duke
parents:
diff changeset
2499 CALL_VM_NOCHECK(InterpreterRuntime::monitorexit(THREAD, end));
a61af66fc99e Initial load
duke
parents:
diff changeset
2500 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2501 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2502 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2503 // One error is plenty
a61af66fc99e Initial load
duke
parents:
diff changeset
2504 if (illegal_state_oop() == NULL && !suppress_error) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2505 {
a61af66fc99e Initial load
duke
parents:
diff changeset
2506 // Prevent any HandleMarkCleaner from freeing our live handles
a61af66fc99e Initial load
duke
parents:
diff changeset
2507 HandleMark __hm(THREAD);
a61af66fc99e Initial load
duke
parents:
diff changeset
2508 CALL_VM_NOCHECK(InterpreterRuntime::throw_illegal_monitor_state_exception(THREAD));
a61af66fc99e Initial load
duke
parents:
diff changeset
2509 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2510 assert(THREAD->has_pending_exception(), "Lost our exception!");
a61af66fc99e Initial load
duke
parents:
diff changeset
2511 illegal_state_oop = THREAD->pending_exception();
a61af66fc99e Initial load
duke
parents:
diff changeset
2512 THREAD->clear_pending_exception();
a61af66fc99e Initial load
duke
parents:
diff changeset
2513 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2514 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2515 end++;
a61af66fc99e Initial load
duke
parents:
diff changeset
2516 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2517 // Unlock the method if needed
a61af66fc99e Initial load
duke
parents:
diff changeset
2518 if (method_unlock_needed) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2519 if (base->obj() == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2520 // The method is already unlocked this is not good.
a61af66fc99e Initial load
duke
parents:
diff changeset
2521 if (illegal_state_oop() == NULL && !suppress_error) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2522 {
a61af66fc99e Initial load
duke
parents:
diff changeset
2523 // Prevent any HandleMarkCleaner from freeing our live handles
a61af66fc99e Initial load
duke
parents:
diff changeset
2524 HandleMark __hm(THREAD);
a61af66fc99e Initial load
duke
parents:
diff changeset
2525 CALL_VM_NOCHECK(InterpreterRuntime::throw_illegal_monitor_state_exception(THREAD));
a61af66fc99e Initial load
duke
parents:
diff changeset
2526 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2527 assert(THREAD->has_pending_exception(), "Lost our exception!");
a61af66fc99e Initial load
duke
parents:
diff changeset
2528 illegal_state_oop = THREAD->pending_exception();
a61af66fc99e Initial load
duke
parents:
diff changeset
2529 THREAD->clear_pending_exception();
a61af66fc99e Initial load
duke
parents:
diff changeset
2530 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2531 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2532 //
a61af66fc99e Initial load
duke
parents:
diff changeset
2533 // The initial monitor is always used for the method
a61af66fc99e Initial load
duke
parents:
diff changeset
2534 // However if that slot is no longer the oop for the method it was unlocked
a61af66fc99e Initial load
duke
parents:
diff changeset
2535 // and reused by something that wasn't unlocked!
a61af66fc99e Initial load
duke
parents:
diff changeset
2536 //
a61af66fc99e Initial load
duke
parents:
diff changeset
2537 // deopt can come in with rcvr dead because c2 knows
a61af66fc99e Initial load
duke
parents:
diff changeset
2538 // its value is preserved in the monitor. So we can't use locals[0] at all
a61af66fc99e Initial load
duke
parents:
diff changeset
2539 // and must use first monitor slot.
a61af66fc99e Initial load
duke
parents:
diff changeset
2540 //
a61af66fc99e Initial load
duke
parents:
diff changeset
2541 oop rcvr = base->obj();
a61af66fc99e Initial load
duke
parents:
diff changeset
2542 if (rcvr == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2543 if (!suppress_error) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2544 VM_JAVA_ERROR_NO_JUMP(vmSymbols::java_lang_NullPointerException(), "");
a61af66fc99e Initial load
duke
parents:
diff changeset
2545 illegal_state_oop = THREAD->pending_exception();
a61af66fc99e Initial load
duke
parents:
diff changeset
2546 THREAD->clear_pending_exception();
a61af66fc99e Initial load
duke
parents:
diff changeset
2547 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2548 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2549 BasicLock* lock = base->lock();
a61af66fc99e Initial load
duke
parents:
diff changeset
2550 markOop header = lock->displaced_header();
a61af66fc99e Initial load
duke
parents:
diff changeset
2551 base->set_obj(NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
2552 // If it isn't recursive we either must swap old header or call the runtime
a61af66fc99e Initial load
duke
parents:
diff changeset
2553 if (header != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2554 if (Atomic::cmpxchg_ptr(header, rcvr->mark_addr(), lock) != lock) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2555 // restore object for the slow case
a61af66fc99e Initial load
duke
parents:
diff changeset
2556 base->set_obj(rcvr);
a61af66fc99e Initial load
duke
parents:
diff changeset
2557 {
a61af66fc99e Initial load
duke
parents:
diff changeset
2558 // Prevent any HandleMarkCleaner from freeing our live handles
a61af66fc99e Initial load
duke
parents:
diff changeset
2559 HandleMark __hm(THREAD);
a61af66fc99e Initial load
duke
parents:
diff changeset
2560 CALL_VM_NOCHECK(InterpreterRuntime::monitorexit(THREAD, base));
a61af66fc99e Initial load
duke
parents:
diff changeset
2561 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2562 if (THREAD->has_pending_exception()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2563 if (!suppress_error) illegal_state_oop = THREAD->pending_exception();
a61af66fc99e Initial load
duke
parents:
diff changeset
2564 THREAD->clear_pending_exception();
a61af66fc99e Initial load
duke
parents:
diff changeset
2565 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2566 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2567 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2568 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2569 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2570 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2571 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2572
a61af66fc99e Initial load
duke
parents:
diff changeset
2573 //
a61af66fc99e Initial load
duke
parents:
diff changeset
2574 // Notify jvmti/jvmdi
a61af66fc99e Initial load
duke
parents:
diff changeset
2575 //
a61af66fc99e Initial load
duke
parents:
diff changeset
2576 // NOTE: we do not notify a method_exit if we have a pending exception,
a61af66fc99e Initial load
duke
parents:
diff changeset
2577 // including an exception we generate for unlocking checks. In the former
a61af66fc99e Initial load
duke
parents:
diff changeset
2578 // case, JVMDI has already been notified by our call for the exception handler
a61af66fc99e Initial load
duke
parents:
diff changeset
2579 // and in both cases as far as JVMDI is concerned we have already returned.
a61af66fc99e Initial load
duke
parents:
diff changeset
2580 // If we notify it again JVMDI will be all confused about how many frames
a61af66fc99e Initial load
duke
parents:
diff changeset
2581 // are still on the stack (4340444).
a61af66fc99e Initial load
duke
parents:
diff changeset
2582 //
a61af66fc99e Initial load
duke
parents:
diff changeset
2583 // NOTE Further! It turns out the the JVMTI spec in fact expects to see
a61af66fc99e Initial load
duke
parents:
diff changeset
2584 // method_exit events whenever we leave an activation unless it was done
a61af66fc99e Initial load
duke
parents:
diff changeset
2585 // for popframe. This is nothing like jvmdi. However we are passing the
a61af66fc99e Initial load
duke
parents:
diff changeset
2586 // tests at the moment (apparently because they are jvmdi based) so rather
a61af66fc99e Initial load
duke
parents:
diff changeset
2587 // than change this code and possibly fail tests we will leave it alone
a61af66fc99e Initial load
duke
parents:
diff changeset
2588 // (with this note) in anticipation of changing the vm and the tests
a61af66fc99e Initial load
duke
parents:
diff changeset
2589 // simultaneously.
a61af66fc99e Initial load
duke
parents:
diff changeset
2590
a61af66fc99e Initial load
duke
parents:
diff changeset
2591
a61af66fc99e Initial load
duke
parents:
diff changeset
2592 //
a61af66fc99e Initial load
duke
parents:
diff changeset
2593 suppress_exit_event = suppress_exit_event || illegal_state_oop() != NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
2594
a61af66fc99e Initial load
duke
parents:
diff changeset
2595
a61af66fc99e Initial load
duke
parents:
diff changeset
2596
a61af66fc99e Initial load
duke
parents:
diff changeset
2597 #ifdef VM_JVMTI
a61af66fc99e Initial load
duke
parents:
diff changeset
2598 if (_jvmti_interp_events) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2599 // Whenever JVMTI puts a thread in interp_only_mode, method
a61af66fc99e Initial load
duke
parents:
diff changeset
2600 // entry/exit events are sent for that thread to track stack depth.
a61af66fc99e Initial load
duke
parents:
diff changeset
2601 if ( !suppress_exit_event && THREAD->is_interp_only_mode() ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2602 {
a61af66fc99e Initial load
duke
parents:
diff changeset
2603 // Prevent any HandleMarkCleaner from freeing our live handles
a61af66fc99e Initial load
duke
parents:
diff changeset
2604 HandleMark __hm(THREAD);
a61af66fc99e Initial load
duke
parents:
diff changeset
2605 CALL_VM_NOCHECK(InterpreterRuntime::post_method_exit(THREAD));
a61af66fc99e Initial load
duke
parents:
diff changeset
2606 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2607 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2608 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2609 #endif /* VM_JVMTI */
a61af66fc99e Initial load
duke
parents:
diff changeset
2610
a61af66fc99e Initial load
duke
parents:
diff changeset
2611 //
a61af66fc99e Initial load
duke
parents:
diff changeset
2612 // See if we are returning any exception
a61af66fc99e Initial load
duke
parents:
diff changeset
2613 // A pending exception that was pending prior to a possible popping frame
a61af66fc99e Initial load
duke
parents:
diff changeset
2614 // overrides the popping frame.
a61af66fc99e Initial load
duke
parents:
diff changeset
2615 //
a61af66fc99e Initial load
duke
parents:
diff changeset
2616 assert(!suppress_error || suppress_error && illegal_state_oop() == NULL, "Error was not suppressed");
a61af66fc99e Initial load
duke
parents:
diff changeset
2617 if (illegal_state_oop() != NULL || original_exception() != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2618 // inform the frame manager we have no result
a61af66fc99e Initial load
duke
parents:
diff changeset
2619 istate->set_msg(throwing_exception);
a61af66fc99e Initial load
duke
parents:
diff changeset
2620 if (illegal_state_oop() != NULL)
a61af66fc99e Initial load
duke
parents:
diff changeset
2621 THREAD->set_pending_exception(illegal_state_oop(), NULL, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
2622 else
a61af66fc99e Initial load
duke
parents:
diff changeset
2623 THREAD->set_pending_exception(original_exception(), NULL, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
2624 istate->set_return_kind((Bytecodes::Code)opcode);
a61af66fc99e Initial load
duke
parents:
diff changeset
2625 UPDATE_PC_AND_RETURN(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
2626 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2627
a61af66fc99e Initial load
duke
parents:
diff changeset
2628 if (istate->msg() == popping_frame) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2629 // Make it simpler on the assembly code and set the message for the frame pop.
a61af66fc99e Initial load
duke
parents:
diff changeset
2630 // returns
a61af66fc99e Initial load
duke
parents:
diff changeset
2631 if (istate->prev() == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2632 // We must be returning to a deoptimized frame (because popframe only happens between
a61af66fc99e Initial load
duke
parents:
diff changeset
2633 // two interpreted frames). We need to save the current arguments in C heap so that
a61af66fc99e Initial load
duke
parents:
diff changeset
2634 // the deoptimized frame when it restarts can copy the arguments to its expression
a61af66fc99e Initial load
duke
parents:
diff changeset
2635 // stack and re-execute the call. We also have to notify deoptimization that this
605
98cb887364d3 6810672: Comment typos
twisti
parents: 520
diff changeset
2636 // has occurred and to pick the preserved args copy them to the deoptimized frame's
0
a61af66fc99e Initial load
duke
parents:
diff changeset
2637 // java expression stack. Yuck.
a61af66fc99e Initial load
duke
parents:
diff changeset
2638 //
a61af66fc99e Initial load
duke
parents:
diff changeset
2639 THREAD->popframe_preserve_args(in_ByteSize(METHOD->size_of_parameters() * wordSize),
a61af66fc99e Initial load
duke
parents:
diff changeset
2640 LOCALS_SLOT(METHOD->size_of_parameters() - 1));
a61af66fc99e Initial load
duke
parents:
diff changeset
2641 THREAD->set_popframe_condition_bit(JavaThread::popframe_force_deopt_reexecution_bit);
a61af66fc99e Initial load
duke
parents:
diff changeset
2642 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2643 UPDATE_PC_AND_RETURN(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2644 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2645 // Normal return
a61af66fc99e Initial load
duke
parents:
diff changeset
2646 // Advance the pc and return to frame manager
a61af66fc99e Initial load
duke
parents:
diff changeset
2647 istate->set_msg(return_from_method);
a61af66fc99e Initial load
duke
parents:
diff changeset
2648 istate->set_return_kind((Bytecodes::Code)opcode);
a61af66fc99e Initial load
duke
parents:
diff changeset
2649 UPDATE_PC_AND_RETURN(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2650 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2651 } /* handle_return: */
a61af66fc99e Initial load
duke
parents:
diff changeset
2652
a61af66fc99e Initial load
duke
parents:
diff changeset
2653 // This is really a fatal error return
a61af66fc99e Initial load
duke
parents:
diff changeset
2654
a61af66fc99e Initial load
duke
parents:
diff changeset
2655 finish:
a61af66fc99e Initial load
duke
parents:
diff changeset
2656 DECACHE_TOS();
a61af66fc99e Initial load
duke
parents:
diff changeset
2657 DECACHE_PC();
a61af66fc99e Initial load
duke
parents:
diff changeset
2658
a61af66fc99e Initial load
duke
parents:
diff changeset
2659 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
2660 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2661
a61af66fc99e Initial load
duke
parents:
diff changeset
2662 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
2663 * All the code following this point is only produced once and is not present
a61af66fc99e Initial load
duke
parents:
diff changeset
2664 * in the JVMTI version of the interpreter
a61af66fc99e Initial load
duke
parents:
diff changeset
2665 */
a61af66fc99e Initial load
duke
parents:
diff changeset
2666
a61af66fc99e Initial load
duke
parents:
diff changeset
2667 #ifndef VM_JVMTI
a61af66fc99e Initial load
duke
parents:
diff changeset
2668
a61af66fc99e Initial load
duke
parents:
diff changeset
2669 // This constructor should only be used to contruct the object to signal
a61af66fc99e Initial load
duke
parents:
diff changeset
2670 // interpreter initialization. All other instances should be created by
a61af66fc99e Initial load
duke
parents:
diff changeset
2671 // the frame manager.
a61af66fc99e Initial load
duke
parents:
diff changeset
2672 BytecodeInterpreter::BytecodeInterpreter(messages msg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2673 if (msg != initialize) ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
2674 _msg = msg;
a61af66fc99e Initial load
duke
parents:
diff changeset
2675 _self_link = this;
a61af66fc99e Initial load
duke
parents:
diff changeset
2676 _prev_link = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
2677 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2678
a61af66fc99e Initial load
duke
parents:
diff changeset
2679 // Inline static functions for Java Stack and Local manipulation
a61af66fc99e Initial load
duke
parents:
diff changeset
2680
a61af66fc99e Initial load
duke
parents:
diff changeset
2681 // The implementations are platform dependent. We have to worry about alignment
a61af66fc99e Initial load
duke
parents:
diff changeset
2682 // issues on some machines which can change on the same platform depending on
a61af66fc99e Initial load
duke
parents:
diff changeset
2683 // whether it is an LP64 machine also.
a61af66fc99e Initial load
duke
parents:
diff changeset
2684 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
2685 void BytecodeInterpreter::verify_stack_tag(intptr_t *tos, frame::Tag tag, int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2686 if (TaggedStackInterpreter) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2687 frame::Tag t = (frame::Tag)tos[Interpreter::expr_tag_index_at(-offset)];
a61af66fc99e Initial load
duke
parents:
diff changeset
2688 assert(t == tag, "stack tag mismatch");
a61af66fc99e Initial load
duke
parents:
diff changeset
2689 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2690 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2691 #endif // ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
2692
a61af66fc99e Initial load
duke
parents:
diff changeset
2693 address BytecodeInterpreter::stack_slot(intptr_t *tos, int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2694 debug_only(verify_stack_tag(tos, frame::TagValue, offset));
a61af66fc99e Initial load
duke
parents:
diff changeset
2695 return (address) tos[Interpreter::expr_index_at(-offset)];
a61af66fc99e Initial load
duke
parents:
diff changeset
2696 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2697
a61af66fc99e Initial load
duke
parents:
diff changeset
2698 jint BytecodeInterpreter::stack_int(intptr_t *tos, int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2699 debug_only(verify_stack_tag(tos, frame::TagValue, offset));
a61af66fc99e Initial load
duke
parents:
diff changeset
2700 return *((jint*) &tos[Interpreter::expr_index_at(-offset)]);
a61af66fc99e Initial load
duke
parents:
diff changeset
2701 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2702
a61af66fc99e Initial load
duke
parents:
diff changeset
2703 jfloat BytecodeInterpreter::stack_float(intptr_t *tos, int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2704 debug_only(verify_stack_tag(tos, frame::TagValue, offset));
a61af66fc99e Initial load
duke
parents:
diff changeset
2705 return *((jfloat *) &tos[Interpreter::expr_index_at(-offset)]);
a61af66fc99e Initial load
duke
parents:
diff changeset
2706 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2707
a61af66fc99e Initial load
duke
parents:
diff changeset
2708 oop BytecodeInterpreter::stack_object(intptr_t *tos, int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2709 debug_only(verify_stack_tag(tos, frame::TagReference, offset));
a61af66fc99e Initial load
duke
parents:
diff changeset
2710 return (oop)tos [Interpreter::expr_index_at(-offset)];
a61af66fc99e Initial load
duke
parents:
diff changeset
2711 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2712
a61af66fc99e Initial load
duke
parents:
diff changeset
2713 jdouble BytecodeInterpreter::stack_double(intptr_t *tos, int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2714 debug_only(verify_stack_tag(tos, frame::TagValue, offset));
a61af66fc99e Initial load
duke
parents:
diff changeset
2715 debug_only(verify_stack_tag(tos, frame::TagValue, offset-1));
a61af66fc99e Initial load
duke
parents:
diff changeset
2716 return ((VMJavaVal64*) &tos[Interpreter::expr_index_at(-offset)])->d;
a61af66fc99e Initial load
duke
parents:
diff changeset
2717 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2718
a61af66fc99e Initial load
duke
parents:
diff changeset
2719 jlong BytecodeInterpreter::stack_long(intptr_t *tos, int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2720 debug_only(verify_stack_tag(tos, frame::TagValue, offset));
a61af66fc99e Initial load
duke
parents:
diff changeset
2721 debug_only(verify_stack_tag(tos, frame::TagValue, offset-1));
a61af66fc99e Initial load
duke
parents:
diff changeset
2722 return ((VMJavaVal64 *) &tos[Interpreter::expr_index_at(-offset)])->l;
a61af66fc99e Initial load
duke
parents:
diff changeset
2723 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2724
a61af66fc99e Initial load
duke
parents:
diff changeset
2725 void BytecodeInterpreter::tag_stack(intptr_t *tos, frame::Tag tag, int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2726 if (TaggedStackInterpreter)
a61af66fc99e Initial load
duke
parents:
diff changeset
2727 tos[Interpreter::expr_tag_index_at(-offset)] = (intptr_t)tag;
a61af66fc99e Initial load
duke
parents:
diff changeset
2728 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2729
a61af66fc99e Initial load
duke
parents:
diff changeset
2730 // only used for value types
a61af66fc99e Initial load
duke
parents:
diff changeset
2731 void BytecodeInterpreter::set_stack_slot(intptr_t *tos, address value,
a61af66fc99e Initial load
duke
parents:
diff changeset
2732 int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2733 tag_stack(tos, frame::TagValue, offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
2734 *((address *)&tos[Interpreter::expr_index_at(-offset)]) = value;
a61af66fc99e Initial load
duke
parents:
diff changeset
2735 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2736
a61af66fc99e Initial load
duke
parents:
diff changeset
2737 void BytecodeInterpreter::set_stack_int(intptr_t *tos, int value,
a61af66fc99e Initial load
duke
parents:
diff changeset
2738 int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2739 tag_stack(tos, frame::TagValue, offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
2740 *((jint *)&tos[Interpreter::expr_index_at(-offset)]) = value;
a61af66fc99e Initial load
duke
parents:
diff changeset
2741 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2742
a61af66fc99e Initial load
duke
parents:
diff changeset
2743 void BytecodeInterpreter::set_stack_float(intptr_t *tos, jfloat value,
a61af66fc99e Initial load
duke
parents:
diff changeset
2744 int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2745 tag_stack(tos, frame::TagValue, offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
2746 *((jfloat *)&tos[Interpreter::expr_index_at(-offset)]) = value;
a61af66fc99e Initial load
duke
parents:
diff changeset
2747 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2748
a61af66fc99e Initial load
duke
parents:
diff changeset
2749 void BytecodeInterpreter::set_stack_object(intptr_t *tos, oop value,
a61af66fc99e Initial load
duke
parents:
diff changeset
2750 int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2751 tag_stack(tos, frame::TagReference, offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
2752 *((oop *)&tos[Interpreter::expr_index_at(-offset)]) = value;
a61af66fc99e Initial load
duke
parents:
diff changeset
2753 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2754
a61af66fc99e Initial load
duke
parents:
diff changeset
2755 // needs to be platform dep for the 32 bit platforms.
a61af66fc99e Initial load
duke
parents:
diff changeset
2756 void BytecodeInterpreter::set_stack_double(intptr_t *tos, jdouble value,
a61af66fc99e Initial load
duke
parents:
diff changeset
2757 int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2758 tag_stack(tos, frame::TagValue, offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
2759 tag_stack(tos, frame::TagValue, offset-1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2760 ((VMJavaVal64*)&tos[Interpreter::expr_index_at(-offset)])->d = value;
a61af66fc99e Initial load
duke
parents:
diff changeset
2761 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2762
a61af66fc99e Initial load
duke
parents:
diff changeset
2763 void BytecodeInterpreter::set_stack_double_from_addr(intptr_t *tos,
a61af66fc99e Initial load
duke
parents:
diff changeset
2764 address addr, int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2765 tag_stack(tos, frame::TagValue, offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
2766 tag_stack(tos, frame::TagValue, offset-1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2767 (((VMJavaVal64*)&tos[Interpreter::expr_index_at(-offset)])->d =
a61af66fc99e Initial load
duke
parents:
diff changeset
2768 ((VMJavaVal64*)addr)->d);
a61af66fc99e Initial load
duke
parents:
diff changeset
2769 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2770
a61af66fc99e Initial load
duke
parents:
diff changeset
2771 void BytecodeInterpreter::set_stack_long(intptr_t *tos, jlong value,
a61af66fc99e Initial load
duke
parents:
diff changeset
2772 int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2773 tag_stack(tos, frame::TagValue, offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
2774 ((VMJavaVal64*)&tos[Interpreter::expr_index_at(-offset+1)])->l = 0xdeedbeeb;
a61af66fc99e Initial load
duke
parents:
diff changeset
2775 tag_stack(tos, frame::TagValue, offset-1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2776 ((VMJavaVal64*)&tos[Interpreter::expr_index_at(-offset)])->l = value;
a61af66fc99e Initial load
duke
parents:
diff changeset
2777 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2778
a61af66fc99e Initial load
duke
parents:
diff changeset
2779 void BytecodeInterpreter::set_stack_long_from_addr(intptr_t *tos,
a61af66fc99e Initial load
duke
parents:
diff changeset
2780 address addr, int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2781 tag_stack(tos, frame::TagValue, offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
2782 ((VMJavaVal64*)&tos[Interpreter::expr_index_at(-offset+1)])->l = 0xdeedbeeb;
a61af66fc99e Initial load
duke
parents:
diff changeset
2783 tag_stack(tos, frame::TagValue, offset-1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2784 ((VMJavaVal64*)&tos[Interpreter::expr_index_at(-offset)])->l =
a61af66fc99e Initial load
duke
parents:
diff changeset
2785 ((VMJavaVal64*)addr)->l;
a61af66fc99e Initial load
duke
parents:
diff changeset
2786 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2787
a61af66fc99e Initial load
duke
parents:
diff changeset
2788 // Locals
a61af66fc99e Initial load
duke
parents:
diff changeset
2789
a61af66fc99e Initial load
duke
parents:
diff changeset
2790 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
2791 void BytecodeInterpreter::verify_locals_tag(intptr_t *locals, frame::Tag tag,
a61af66fc99e Initial load
duke
parents:
diff changeset
2792 int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2793 if (TaggedStackInterpreter) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2794 frame::Tag t = (frame::Tag)locals[Interpreter::local_tag_index_at(-offset)];
a61af66fc99e Initial load
duke
parents:
diff changeset
2795 assert(t == tag, "locals tag mismatch");
a61af66fc99e Initial load
duke
parents:
diff changeset
2796 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2797 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2798 #endif // ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
2799 address BytecodeInterpreter::locals_slot(intptr_t* locals, int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2800 debug_only(verify_locals_tag(locals, frame::TagValue, offset));
a61af66fc99e Initial load
duke
parents:
diff changeset
2801 return (address)locals[Interpreter::local_index_at(-offset)];
a61af66fc99e Initial load
duke
parents:
diff changeset
2802 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2803 jint BytecodeInterpreter::locals_int(intptr_t* locals, int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2804 debug_only(verify_locals_tag(locals, frame::TagValue, offset));
a61af66fc99e Initial load
duke
parents:
diff changeset
2805 return (jint)locals[Interpreter::local_index_at(-offset)];
a61af66fc99e Initial load
duke
parents:
diff changeset
2806 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2807 jfloat BytecodeInterpreter::locals_float(intptr_t* locals, int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2808 debug_only(verify_locals_tag(locals, frame::TagValue, offset));
a61af66fc99e Initial load
duke
parents:
diff changeset
2809 return (jfloat)locals[Interpreter::local_index_at(-offset)];
a61af66fc99e Initial load
duke
parents:
diff changeset
2810 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2811 oop BytecodeInterpreter::locals_object(intptr_t* locals, int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2812 debug_only(verify_locals_tag(locals, frame::TagReference, offset));
a61af66fc99e Initial load
duke
parents:
diff changeset
2813 return (oop)locals[Interpreter::local_index_at(-offset)];
a61af66fc99e Initial load
duke
parents:
diff changeset
2814 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2815 jdouble BytecodeInterpreter::locals_double(intptr_t* locals, int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2816 debug_only(verify_locals_tag(locals, frame::TagValue, offset));
a61af66fc99e Initial load
duke
parents:
diff changeset
2817 debug_only(verify_locals_tag(locals, frame::TagValue, offset));
a61af66fc99e Initial load
duke
parents:
diff changeset
2818 return ((VMJavaVal64*)&locals[Interpreter::local_index_at(-(offset+1))])->d;
a61af66fc99e Initial load
duke
parents:
diff changeset
2819 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2820 jlong BytecodeInterpreter::locals_long(intptr_t* locals, int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2821 debug_only(verify_locals_tag(locals, frame::TagValue, offset));
a61af66fc99e Initial load
duke
parents:
diff changeset
2822 debug_only(verify_locals_tag(locals, frame::TagValue, offset+1));
a61af66fc99e Initial load
duke
parents:
diff changeset
2823 return ((VMJavaVal64*)&locals[Interpreter::local_index_at(-(offset+1))])->l;
a61af66fc99e Initial load
duke
parents:
diff changeset
2824 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2825
a61af66fc99e Initial load
duke
parents:
diff changeset
2826 // Returns the address of locals value.
a61af66fc99e Initial load
duke
parents:
diff changeset
2827 address BytecodeInterpreter::locals_long_at(intptr_t* locals, int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2828 debug_only(verify_locals_tag(locals, frame::TagValue, offset));
a61af66fc99e Initial load
duke
parents:
diff changeset
2829 debug_only(verify_locals_tag(locals, frame::TagValue, offset+1));
a61af66fc99e Initial load
duke
parents:
diff changeset
2830 return ((address)&locals[Interpreter::local_index_at(-(offset+1))]);
a61af66fc99e Initial load
duke
parents:
diff changeset
2831 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2832 address BytecodeInterpreter::locals_double_at(intptr_t* locals, int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2833 debug_only(verify_locals_tag(locals, frame::TagValue, offset));
a61af66fc99e Initial load
duke
parents:
diff changeset
2834 debug_only(verify_locals_tag(locals, frame::TagValue, offset+1));
a61af66fc99e Initial load
duke
parents:
diff changeset
2835 return ((address)&locals[Interpreter::local_index_at(-(offset+1))]);
a61af66fc99e Initial load
duke
parents:
diff changeset
2836 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2837
a61af66fc99e Initial load
duke
parents:
diff changeset
2838 void BytecodeInterpreter::tag_locals(intptr_t *locals, frame::Tag tag, int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2839 if (TaggedStackInterpreter)
a61af66fc99e Initial load
duke
parents:
diff changeset
2840 locals[Interpreter::local_tag_index_at(-offset)] = (intptr_t)tag;
a61af66fc99e Initial load
duke
parents:
diff changeset
2841 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2842
a61af66fc99e Initial load
duke
parents:
diff changeset
2843 // Used for local value or returnAddress
a61af66fc99e Initial load
duke
parents:
diff changeset
2844 void BytecodeInterpreter::set_locals_slot(intptr_t *locals,
a61af66fc99e Initial load
duke
parents:
diff changeset
2845 address value, int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2846 tag_locals(locals, frame::TagValue, offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
2847 *((address*)&locals[Interpreter::local_index_at(-offset)]) = value;
a61af66fc99e Initial load
duke
parents:
diff changeset
2848 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2849 void BytecodeInterpreter::set_locals_int(intptr_t *locals,
a61af66fc99e Initial load
duke
parents:
diff changeset
2850 jint value, int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2851 tag_locals(locals, frame::TagValue, offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
2852 *((jint *)&locals[Interpreter::local_index_at(-offset)]) = value;
a61af66fc99e Initial load
duke
parents:
diff changeset
2853 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2854 void BytecodeInterpreter::set_locals_float(intptr_t *locals,
a61af66fc99e Initial load
duke
parents:
diff changeset
2855 jfloat value, int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2856 tag_locals(locals, frame::TagValue, offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
2857 *((jfloat *)&locals[Interpreter::local_index_at(-offset)]) = value;
a61af66fc99e Initial load
duke
parents:
diff changeset
2858 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2859 void BytecodeInterpreter::set_locals_object(intptr_t *locals,
a61af66fc99e Initial load
duke
parents:
diff changeset
2860 oop value, int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2861 tag_locals(locals, frame::TagReference, offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
2862 *((oop *)&locals[Interpreter::local_index_at(-offset)]) = value;
a61af66fc99e Initial load
duke
parents:
diff changeset
2863 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2864 void BytecodeInterpreter::set_locals_double(intptr_t *locals,
a61af66fc99e Initial load
duke
parents:
diff changeset
2865 jdouble value, int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2866 tag_locals(locals, frame::TagValue, offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
2867 tag_locals(locals, frame::TagValue, offset+1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2868 ((VMJavaVal64*)&locals[Interpreter::local_index_at(-(offset+1))])->d = value;
a61af66fc99e Initial load
duke
parents:
diff changeset
2869 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2870 void BytecodeInterpreter::set_locals_long(intptr_t *locals,
a61af66fc99e Initial load
duke
parents:
diff changeset
2871 jlong value, int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2872 tag_locals(locals, frame::TagValue, offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
2873 tag_locals(locals, frame::TagValue, offset+1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2874 ((VMJavaVal64*)&locals[Interpreter::local_index_at(-(offset+1))])->l = value;
a61af66fc99e Initial load
duke
parents:
diff changeset
2875 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2876 void BytecodeInterpreter::set_locals_double_from_addr(intptr_t *locals,
a61af66fc99e Initial load
duke
parents:
diff changeset
2877 address addr, int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2878 tag_locals(locals, frame::TagValue, offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
2879 tag_locals(locals, frame::TagValue, offset+1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2880 ((VMJavaVal64*)&locals[Interpreter::local_index_at(-(offset+1))])->d = ((VMJavaVal64*)addr)->d;
a61af66fc99e Initial load
duke
parents:
diff changeset
2881 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2882 void BytecodeInterpreter::set_locals_long_from_addr(intptr_t *locals,
a61af66fc99e Initial load
duke
parents:
diff changeset
2883 address addr, int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2884 tag_locals(locals, frame::TagValue, offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
2885 tag_locals(locals, frame::TagValue, offset+1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2886 ((VMJavaVal64*)&locals[Interpreter::local_index_at(-(offset+1))])->l = ((VMJavaVal64*)addr)->l;
a61af66fc99e Initial load
duke
parents:
diff changeset
2887 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2888
a61af66fc99e Initial load
duke
parents:
diff changeset
2889 void BytecodeInterpreter::astore(intptr_t* tos, int stack_offset,
a61af66fc99e Initial load
duke
parents:
diff changeset
2890 intptr_t* locals, int locals_offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2891 // Copy tag from stack to locals. astore's operand can be returnAddress
a61af66fc99e Initial load
duke
parents:
diff changeset
2892 // and may not be TagReference
a61af66fc99e Initial load
duke
parents:
diff changeset
2893 if (TaggedStackInterpreter) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2894 frame::Tag t = (frame::Tag) tos[Interpreter::expr_tag_index_at(-stack_offset)];
a61af66fc99e Initial load
duke
parents:
diff changeset
2895 locals[Interpreter::local_tag_index_at(-locals_offset)] = (intptr_t)t;
a61af66fc99e Initial load
duke
parents:
diff changeset
2896 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2897 intptr_t value = tos[Interpreter::expr_index_at(-stack_offset)];
a61af66fc99e Initial load
duke
parents:
diff changeset
2898 locals[Interpreter::local_index_at(-locals_offset)] = value;
a61af66fc99e Initial load
duke
parents:
diff changeset
2899 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2900
a61af66fc99e Initial load
duke
parents:
diff changeset
2901
a61af66fc99e Initial load
duke
parents:
diff changeset
2902 void BytecodeInterpreter::copy_stack_slot(intptr_t *tos, int from_offset,
a61af66fc99e Initial load
duke
parents:
diff changeset
2903 int to_offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2904 if (TaggedStackInterpreter) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2905 tos[Interpreter::expr_tag_index_at(-to_offset)] =
a61af66fc99e Initial load
duke
parents:
diff changeset
2906 (intptr_t)tos[Interpreter::expr_tag_index_at(-from_offset)];
a61af66fc99e Initial load
duke
parents:
diff changeset
2907 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2908 tos[Interpreter::expr_index_at(-to_offset)] =
a61af66fc99e Initial load
duke
parents:
diff changeset
2909 (intptr_t)tos[Interpreter::expr_index_at(-from_offset)];
a61af66fc99e Initial load
duke
parents:
diff changeset
2910 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2911
a61af66fc99e Initial load
duke
parents:
diff changeset
2912 void BytecodeInterpreter::dup(intptr_t *tos) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2913 copy_stack_slot(tos, -1, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
2914 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2915 void BytecodeInterpreter::dup2(intptr_t *tos) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2916 copy_stack_slot(tos, -2, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
2917 copy_stack_slot(tos, -1, 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2918 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2919
a61af66fc99e Initial load
duke
parents:
diff changeset
2920 void BytecodeInterpreter::dup_x1(intptr_t *tos) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2921 /* insert top word two down */
a61af66fc99e Initial load
duke
parents:
diff changeset
2922 copy_stack_slot(tos, -1, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
2923 copy_stack_slot(tos, -2, -1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2924 copy_stack_slot(tos, 0, -2);
a61af66fc99e Initial load
duke
parents:
diff changeset
2925 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2926
a61af66fc99e Initial load
duke
parents:
diff changeset
2927 void BytecodeInterpreter::dup_x2(intptr_t *tos) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2928 /* insert top word three down */
a61af66fc99e Initial load
duke
parents:
diff changeset
2929 copy_stack_slot(tos, -1, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
2930 copy_stack_slot(tos, -2, -1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2931 copy_stack_slot(tos, -3, -2);
a61af66fc99e Initial load
duke
parents:
diff changeset
2932 copy_stack_slot(tos, 0, -3);
a61af66fc99e Initial load
duke
parents:
diff changeset
2933 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2934 void BytecodeInterpreter::dup2_x1(intptr_t *tos) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2935 /* insert top 2 slots three down */
a61af66fc99e Initial load
duke
parents:
diff changeset
2936 copy_stack_slot(tos, -1, 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2937 copy_stack_slot(tos, -2, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
2938 copy_stack_slot(tos, -3, -1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2939 copy_stack_slot(tos, 1, -2);
a61af66fc99e Initial load
duke
parents:
diff changeset
2940 copy_stack_slot(tos, 0, -3);
a61af66fc99e Initial load
duke
parents:
diff changeset
2941 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2942 void BytecodeInterpreter::dup2_x2(intptr_t *tos) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2943 /* insert top 2 slots four down */
a61af66fc99e Initial load
duke
parents:
diff changeset
2944 copy_stack_slot(tos, -1, 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2945 copy_stack_slot(tos, -2, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
2946 copy_stack_slot(tos, -3, -1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2947 copy_stack_slot(tos, -4, -2);
a61af66fc99e Initial load
duke
parents:
diff changeset
2948 copy_stack_slot(tos, 1, -3);
a61af66fc99e Initial load
duke
parents:
diff changeset
2949 copy_stack_slot(tos, 0, -4);
a61af66fc99e Initial load
duke
parents:
diff changeset
2950 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2951
a61af66fc99e Initial load
duke
parents:
diff changeset
2952
a61af66fc99e Initial load
duke
parents:
diff changeset
2953 void BytecodeInterpreter::swap(intptr_t *tos) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2954 // swap top two elements
a61af66fc99e Initial load
duke
parents:
diff changeset
2955 intptr_t val = tos[Interpreter::expr_index_at(1)];
a61af66fc99e Initial load
duke
parents:
diff changeset
2956 frame::Tag t;
a61af66fc99e Initial load
duke
parents:
diff changeset
2957 if (TaggedStackInterpreter) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2958 t = (frame::Tag) tos[Interpreter::expr_tag_index_at(1)];
a61af66fc99e Initial load
duke
parents:
diff changeset
2959 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2960 // Copy -2 entry to -1
a61af66fc99e Initial load
duke
parents:
diff changeset
2961 copy_stack_slot(tos, -2, -1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2962 // Store saved -1 entry into -2
a61af66fc99e Initial load
duke
parents:
diff changeset
2963 if (TaggedStackInterpreter) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2964 tos[Interpreter::expr_tag_index_at(2)] = (intptr_t)t;
a61af66fc99e Initial load
duke
parents:
diff changeset
2965 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2966 tos[Interpreter::expr_index_at(2)] = val;
a61af66fc99e Initial load
duke
parents:
diff changeset
2967 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2968 // --------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
2969 // Non-product code
a61af66fc99e Initial load
duke
parents:
diff changeset
2970 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
2971
a61af66fc99e Initial load
duke
parents:
diff changeset
2972 const char* BytecodeInterpreter::C_msg(BytecodeInterpreter::messages msg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2973 switch (msg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2974 case BytecodeInterpreter::no_request: return("no_request");
a61af66fc99e Initial load
duke
parents:
diff changeset
2975 case BytecodeInterpreter::initialize: return("initialize");
a61af66fc99e Initial load
duke
parents:
diff changeset
2976 // status message to C++ interpreter
a61af66fc99e Initial load
duke
parents:
diff changeset
2977 case BytecodeInterpreter::method_entry: return("method_entry");
a61af66fc99e Initial load
duke
parents:
diff changeset
2978 case BytecodeInterpreter::method_resume: return("method_resume");
a61af66fc99e Initial load
duke
parents:
diff changeset
2979 case BytecodeInterpreter::got_monitors: return("got_monitors");
a61af66fc99e Initial load
duke
parents:
diff changeset
2980 case BytecodeInterpreter::rethrow_exception: return("rethrow_exception");
a61af66fc99e Initial load
duke
parents:
diff changeset
2981 // requests to frame manager from C++ interpreter
a61af66fc99e Initial load
duke
parents:
diff changeset
2982 case BytecodeInterpreter::call_method: return("call_method");
a61af66fc99e Initial load
duke
parents:
diff changeset
2983 case BytecodeInterpreter::return_from_method: return("return_from_method");
a61af66fc99e Initial load
duke
parents:
diff changeset
2984 case BytecodeInterpreter::more_monitors: return("more_monitors");
a61af66fc99e Initial load
duke
parents:
diff changeset
2985 case BytecodeInterpreter::throwing_exception: return("throwing_exception");
a61af66fc99e Initial load
duke
parents:
diff changeset
2986 case BytecodeInterpreter::popping_frame: return("popping_frame");
a61af66fc99e Initial load
duke
parents:
diff changeset
2987 case BytecodeInterpreter::do_osr: return("do_osr");
a61af66fc99e Initial load
duke
parents:
diff changeset
2988 // deopt
a61af66fc99e Initial load
duke
parents:
diff changeset
2989 case BytecodeInterpreter::deopt_resume: return("deopt_resume");
a61af66fc99e Initial load
duke
parents:
diff changeset
2990 case BytecodeInterpreter::deopt_resume2: return("deopt_resume2");
a61af66fc99e Initial load
duke
parents:
diff changeset
2991 default: return("BAD MSG");
a61af66fc99e Initial load
duke
parents:
diff changeset
2992 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2993 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2994 void
a61af66fc99e Initial load
duke
parents:
diff changeset
2995 BytecodeInterpreter::print() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2996 tty->print_cr("thread: " INTPTR_FORMAT, (uintptr_t) this->_thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
2997 tty->print_cr("bcp: " INTPTR_FORMAT, (uintptr_t) this->_bcp);
a61af66fc99e Initial load
duke
parents:
diff changeset
2998 tty->print_cr("locals: " INTPTR_FORMAT, (uintptr_t) this->_locals);
a61af66fc99e Initial load
duke
parents:
diff changeset
2999 tty->print_cr("constants: " INTPTR_FORMAT, (uintptr_t) this->_constants);
a61af66fc99e Initial load
duke
parents:
diff changeset
3000 {
a61af66fc99e Initial load
duke
parents:
diff changeset
3001 ResourceMark rm;
a61af66fc99e Initial load
duke
parents:
diff changeset
3002 char *method_name = _method->name_and_sig_as_C_string();
a61af66fc99e Initial load
duke
parents:
diff changeset
3003 tty->print_cr("method: " INTPTR_FORMAT "[ %s ]", (uintptr_t) this->_method, method_name);
a61af66fc99e Initial load
duke
parents:
diff changeset
3004 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3005 tty->print_cr("mdx: " INTPTR_FORMAT, (uintptr_t) this->_mdx);
a61af66fc99e Initial load
duke
parents:
diff changeset
3006 tty->print_cr("stack: " INTPTR_FORMAT, (uintptr_t) this->_stack);
a61af66fc99e Initial load
duke
parents:
diff changeset
3007 tty->print_cr("msg: %s", C_msg(this->_msg));
a61af66fc99e Initial load
duke
parents:
diff changeset
3008 tty->print_cr("result_to_call._callee: " INTPTR_FORMAT, (uintptr_t) this->_result._to_call._callee);
a61af66fc99e Initial load
duke
parents:
diff changeset
3009 tty->print_cr("result_to_call._callee_entry_point: " INTPTR_FORMAT, (uintptr_t) this->_result._to_call._callee_entry_point);
a61af66fc99e Initial load
duke
parents:
diff changeset
3010 tty->print_cr("result_to_call._bcp_advance: %d ", this->_result._to_call._bcp_advance);
a61af66fc99e Initial load
duke
parents:
diff changeset
3011 tty->print_cr("osr._osr_buf: " INTPTR_FORMAT, (uintptr_t) this->_result._osr._osr_buf);
a61af66fc99e Initial load
duke
parents:
diff changeset
3012 tty->print_cr("osr._osr_entry: " INTPTR_FORMAT, (uintptr_t) this->_result._osr._osr_entry);
a61af66fc99e Initial load
duke
parents:
diff changeset
3013 tty->print_cr("result_return_kind 0x%x ", (int) this->_result._return_kind);
a61af66fc99e Initial load
duke
parents:
diff changeset
3014 tty->print_cr("prev_link: " INTPTR_FORMAT, (uintptr_t) this->_prev_link);
a61af66fc99e Initial load
duke
parents:
diff changeset
3015 tty->print_cr("native_mirror: " INTPTR_FORMAT, (uintptr_t) this->_oop_temp);
a61af66fc99e Initial load
duke
parents:
diff changeset
3016 tty->print_cr("stack_base: " INTPTR_FORMAT, (uintptr_t) this->_stack_base);
a61af66fc99e Initial load
duke
parents:
diff changeset
3017 tty->print_cr("stack_limit: " INTPTR_FORMAT, (uintptr_t) this->_stack_limit);
a61af66fc99e Initial load
duke
parents:
diff changeset
3018 tty->print_cr("monitor_base: " INTPTR_FORMAT, (uintptr_t) this->_monitor_base);
a61af66fc99e Initial load
duke
parents:
diff changeset
3019 #ifdef SPARC
a61af66fc99e Initial load
duke
parents:
diff changeset
3020 tty->print_cr("last_Java_pc: " INTPTR_FORMAT, (uintptr_t) this->_last_Java_pc);
a61af66fc99e Initial load
duke
parents:
diff changeset
3021 tty->print_cr("frame_bottom: " INTPTR_FORMAT, (uintptr_t) this->_frame_bottom);
a61af66fc99e Initial load
duke
parents:
diff changeset
3022 tty->print_cr("&native_fresult: " INTPTR_FORMAT, (uintptr_t) &this->_native_fresult);
a61af66fc99e Initial load
duke
parents:
diff changeset
3023 tty->print_cr("native_lresult: " INTPTR_FORMAT, (uintptr_t) this->_native_lresult);
a61af66fc99e Initial load
duke
parents:
diff changeset
3024 #endif
1010
354d3184f6b2 6890308: integrate zero assembler hotspot changes
never
parents: 628
diff changeset
3025 #if defined(IA64) && !defined(ZERO)
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3026 tty->print_cr("last_Java_fp: " INTPTR_FORMAT, (uintptr_t) this->_last_Java_fp);
1010
354d3184f6b2 6890308: integrate zero assembler hotspot changes
never
parents: 628
diff changeset
3027 #endif // IA64 && !ZERO
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3028 tty->print_cr("self_link: " INTPTR_FORMAT, (uintptr_t) this->_self_link);
a61af66fc99e Initial load
duke
parents:
diff changeset
3029 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3030
a61af66fc99e Initial load
duke
parents:
diff changeset
3031 extern "C" {
a61af66fc99e Initial load
duke
parents:
diff changeset
3032 void PI(uintptr_t arg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3033 ((BytecodeInterpreter*)arg)->print();
a61af66fc99e Initial load
duke
parents:
diff changeset
3034 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3035 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3036 #endif // PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
3037
a61af66fc99e Initial load
duke
parents:
diff changeset
3038 #endif // JVMTI
a61af66fc99e Initial load
duke
parents:
diff changeset
3039 #endif // CC_INTERP