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