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