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