duke@435: /* duke@435: * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved. duke@435: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@435: * duke@435: * This code is free software; you can redistribute it and/or modify it duke@435: * under the terms of the GNU General Public License version 2 only, as duke@435: * published by the Free Software Foundation. duke@435: * duke@435: * This code is distributed in the hope that it will be useful, but WITHOUT duke@435: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@435: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@435: * version 2 for more details (a copy is included in the LICENSE file that duke@435: * accompanied this code). duke@435: * duke@435: * You should have received a copy of the GNU General Public License version duke@435: * 2 along with this work; if not, write to the Free Software Foundation, duke@435: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@435: * duke@435: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, duke@435: * CA 95054 USA or visit www.sun.com if you need additional information or duke@435: * have any questions. duke@435: * duke@435: */ duke@435: duke@435: duke@435: // no precompiled headers duke@435: #include "incls/_bytecodeInterpreter.cpp.incl" duke@435: duke@435: #ifdef CC_INTERP duke@435: duke@435: /* duke@435: * USELABELS - If using GCC, then use labels for the opcode dispatching duke@435: * rather -then a switch statement. This improves performance because it duke@435: * gives us the oportunity to have the instructions that calculate the duke@435: * next opcode to jump to be intermixed with the rest of the instructions duke@435: * that implement the opcode (see UPDATE_PC_AND_TOS_AND_CONTINUE macro). duke@435: */ duke@435: #undef USELABELS duke@435: #ifdef __GNUC__ duke@435: /* duke@435: ASSERT signifies debugging. It is much easier to step thru bytecodes if we duke@435: don't use the computed goto approach. duke@435: */ duke@435: #ifndef ASSERT duke@435: #define USELABELS duke@435: #endif duke@435: #endif duke@435: duke@435: #undef CASE duke@435: #ifdef USELABELS duke@435: #define CASE(opcode) opc ## opcode duke@435: #define DEFAULT opc_default duke@435: #else duke@435: #define CASE(opcode) case Bytecodes:: opcode duke@435: #define DEFAULT default duke@435: #endif duke@435: duke@435: /* duke@435: * PREFETCH_OPCCODE - Some compilers do better if you prefetch the next duke@435: * opcode before going back to the top of the while loop, rather then having duke@435: * the top of the while loop handle it. This provides a better opportunity duke@435: * for instruction scheduling. Some compilers just do this prefetch duke@435: * automatically. Some actually end up with worse performance if you duke@435: * force the prefetch. Solaris gcc seems to do better, but cc does worse. duke@435: */ duke@435: #undef PREFETCH_OPCCODE duke@435: #define PREFETCH_OPCCODE duke@435: duke@435: /* duke@435: Interpreter safepoint: it is expected that the interpreter will have no live duke@435: handles of its own creation live at an interpreter safepoint. Therefore we duke@435: run a HandleMarkCleaner and trash all handles allocated in the call chain duke@435: since the JavaCalls::call_helper invocation that initiated the chain. duke@435: There really shouldn't be any handles remaining to trash but this is cheap duke@435: in relation to a safepoint. duke@435: */ duke@435: #define SAFEPOINT \ duke@435: if ( SafepointSynchronize::is_synchronizing()) { \ duke@435: { \ duke@435: /* zap freed handles rather than GC'ing them */ \ duke@435: HandleMarkCleaner __hmc(THREAD); \ duke@435: } \ duke@435: CALL_VM(SafepointSynchronize::block(THREAD), handle_exception); \ duke@435: } duke@435: duke@435: /* duke@435: * VM_JAVA_ERROR - Macro for throwing a java exception from duke@435: * the interpreter loop. Should really be a CALL_VM but there duke@435: * is no entry point to do the transition to vm so we just duke@435: * do it by hand here. duke@435: */ duke@435: #define VM_JAVA_ERROR_NO_JUMP(name, msg) \ duke@435: DECACHE_STATE(); \ duke@435: SET_LAST_JAVA_FRAME(); \ duke@435: { \ duke@435: ThreadInVMfromJava trans(THREAD); \ duke@435: Exceptions::_throw_msg(THREAD, __FILE__, __LINE__, name, msg); \ duke@435: } \ duke@435: RESET_LAST_JAVA_FRAME(); \ duke@435: CACHE_STATE(); duke@435: duke@435: // Normal throw of a java error duke@435: #define VM_JAVA_ERROR(name, msg) \ duke@435: VM_JAVA_ERROR_NO_JUMP(name, msg) \ duke@435: goto handle_exception; duke@435: duke@435: #ifdef PRODUCT duke@435: #define DO_UPDATE_INSTRUCTION_COUNT(opcode) duke@435: #else duke@435: #define DO_UPDATE_INSTRUCTION_COUNT(opcode) \ duke@435: { \ duke@435: BytecodeCounter::_counter_value++; \ duke@435: BytecodeHistogram::_counters[(Bytecodes::Code)opcode]++; \ duke@435: if (StopInterpreterAt && StopInterpreterAt == BytecodeCounter::_counter_value) os::breakpoint(); \ duke@435: if (TraceBytecodes) { \ duke@435: CALL_VM((void)SharedRuntime::trace_bytecode(THREAD, 0, \ duke@435: topOfStack[Interpreter::expr_index_at(1)], \ duke@435: topOfStack[Interpreter::expr_index_at(2)]), \ duke@435: handle_exception); \ duke@435: } \ duke@435: } duke@435: #endif duke@435: duke@435: #undef DEBUGGER_SINGLE_STEP_NOTIFY duke@435: #ifdef VM_JVMTI duke@435: /* NOTE: (kbr) This macro must be called AFTER the PC has been duke@435: incremented. JvmtiExport::at_single_stepping_point() may cause a duke@435: breakpoint opcode to get inserted at the current PC to allow the duke@435: debugger to coalesce single-step events. duke@435: duke@435: As a result if we call at_single_stepping_point() we refetch opcode duke@435: to get the current opcode. This will override any other prefetching duke@435: that might have occurred. duke@435: */ duke@435: #define DEBUGGER_SINGLE_STEP_NOTIFY() \ duke@435: { \ duke@435: if (_jvmti_interp_events) { \ duke@435: if (JvmtiExport::should_post_single_step()) { \ duke@435: DECACHE_STATE(); \ duke@435: SET_LAST_JAVA_FRAME(); \ duke@435: ThreadInVMfromJava trans(THREAD); \ duke@435: JvmtiExport::at_single_stepping_point(THREAD, \ duke@435: istate->method(), \ duke@435: pc); \ duke@435: RESET_LAST_JAVA_FRAME(); \ duke@435: CACHE_STATE(); \ duke@435: if (THREAD->pop_frame_pending() && \ duke@435: !THREAD->pop_frame_in_process()) { \ duke@435: goto handle_Pop_Frame; \ duke@435: } \ duke@435: opcode = *pc; \ duke@435: } \ duke@435: } \ duke@435: } duke@435: #else duke@435: #define DEBUGGER_SINGLE_STEP_NOTIFY() duke@435: #endif duke@435: duke@435: /* duke@435: * CONTINUE - Macro for executing the next opcode. duke@435: */ duke@435: #undef CONTINUE duke@435: #ifdef USELABELS duke@435: // Have to do this dispatch this way in C++ because otherwise gcc complains about crossing an duke@435: // initialization (which is is the initialization of the table pointer...) duke@435: #define DISPATCH(opcode) goto *dispatch_table[opcode] duke@435: #define CONTINUE { \ duke@435: opcode = *pc; \ duke@435: DO_UPDATE_INSTRUCTION_COUNT(opcode); \ duke@435: DEBUGGER_SINGLE_STEP_NOTIFY(); \ duke@435: DISPATCH(opcode); \ duke@435: } duke@435: #else duke@435: #ifdef PREFETCH_OPCCODE duke@435: #define CONTINUE { \ duke@435: opcode = *pc; \ duke@435: DO_UPDATE_INSTRUCTION_COUNT(opcode); \ duke@435: DEBUGGER_SINGLE_STEP_NOTIFY(); \ duke@435: continue; \ duke@435: } duke@435: #else duke@435: #define CONTINUE { \ duke@435: DO_UPDATE_INSTRUCTION_COUNT(opcode); \ duke@435: DEBUGGER_SINGLE_STEP_NOTIFY(); \ duke@435: continue; \ duke@435: } duke@435: #endif duke@435: #endif duke@435: duke@435: // JavaStack Implementation duke@435: #define MORE_STACK(count) \ duke@435: (topOfStack -= ((count) * Interpreter::stackElementWords())) duke@435: duke@435: duke@435: #define UPDATE_PC(opsize) {pc += opsize; } duke@435: /* duke@435: * UPDATE_PC_AND_TOS - Macro for updating the pc and topOfStack. duke@435: */ duke@435: #undef UPDATE_PC_AND_TOS duke@435: #define UPDATE_PC_AND_TOS(opsize, stack) \ duke@435: {pc += opsize; MORE_STACK(stack); } duke@435: duke@435: /* duke@435: * UPDATE_PC_AND_TOS_AND_CONTINUE - Macro for updating the pc and topOfStack, duke@435: * and executing the next opcode. It's somewhat similar to the combination duke@435: * of UPDATE_PC_AND_TOS and CONTINUE, but with some minor optimizations. duke@435: */ duke@435: #undef UPDATE_PC_AND_TOS_AND_CONTINUE duke@435: #ifdef USELABELS duke@435: #define UPDATE_PC_AND_TOS_AND_CONTINUE(opsize, stack) { \ duke@435: pc += opsize; opcode = *pc; MORE_STACK(stack); \ duke@435: DO_UPDATE_INSTRUCTION_COUNT(opcode); \ duke@435: DEBUGGER_SINGLE_STEP_NOTIFY(); \ duke@435: DISPATCH(opcode); \ duke@435: } duke@435: duke@435: #define UPDATE_PC_AND_CONTINUE(opsize) { \ duke@435: pc += opsize; opcode = *pc; \ duke@435: DO_UPDATE_INSTRUCTION_COUNT(opcode); \ duke@435: DEBUGGER_SINGLE_STEP_NOTIFY(); \ duke@435: DISPATCH(opcode); \ duke@435: } duke@435: #else duke@435: #ifdef PREFETCH_OPCCODE duke@435: #define UPDATE_PC_AND_TOS_AND_CONTINUE(opsize, stack) { \ duke@435: pc += opsize; opcode = *pc; MORE_STACK(stack); \ duke@435: DO_UPDATE_INSTRUCTION_COUNT(opcode); \ duke@435: DEBUGGER_SINGLE_STEP_NOTIFY(); \ duke@435: goto do_continue; \ duke@435: } duke@435: duke@435: #define UPDATE_PC_AND_CONTINUE(opsize) { \ duke@435: pc += opsize; opcode = *pc; \ duke@435: DO_UPDATE_INSTRUCTION_COUNT(opcode); \ duke@435: DEBUGGER_SINGLE_STEP_NOTIFY(); \ duke@435: goto do_continue; \ duke@435: } duke@435: #else duke@435: #define UPDATE_PC_AND_TOS_AND_CONTINUE(opsize, stack) { \ duke@435: pc += opsize; MORE_STACK(stack); \ duke@435: DO_UPDATE_INSTRUCTION_COUNT(opcode); \ duke@435: DEBUGGER_SINGLE_STEP_NOTIFY(); \ duke@435: goto do_continue; \ duke@435: } duke@435: duke@435: #define UPDATE_PC_AND_CONTINUE(opsize) { \ duke@435: pc += opsize; \ duke@435: DO_UPDATE_INSTRUCTION_COUNT(opcode); \ duke@435: DEBUGGER_SINGLE_STEP_NOTIFY(); \ duke@435: goto do_continue; \ duke@435: } duke@435: #endif /* PREFETCH_OPCCODE */ duke@435: #endif /* USELABELS */ duke@435: duke@435: // About to call a new method, update the save the adjusted pc and return to frame manager duke@435: #define UPDATE_PC_AND_RETURN(opsize) \ duke@435: DECACHE_TOS(); \ duke@435: istate->set_bcp(pc+opsize); \ duke@435: return; duke@435: duke@435: duke@435: #define METHOD istate->method() duke@435: #define INVOCATION_COUNT METHOD->invocation_counter() duke@435: #define BACKEDGE_COUNT METHOD->backedge_counter() duke@435: duke@435: duke@435: #define INCR_INVOCATION_COUNT INVOCATION_COUNT->increment() duke@435: #define OSR_REQUEST(res, branch_pc) \ duke@435: CALL_VM(res=InterpreterRuntime::frequency_counter_overflow(THREAD, branch_pc), handle_exception); duke@435: /* duke@435: * For those opcodes that need to have a GC point on a backwards branch duke@435: */ duke@435: duke@435: // Backedge counting is kind of strange. The asm interpreter will increment duke@435: // the backedge counter as a separate counter but it does it's comparisons duke@435: // to the sum (scaled) of invocation counter and backedge count to make duke@435: // a decision. Seems kind of odd to sum them together like that duke@435: duke@435: // skip is delta from current bcp/bci for target, branch_pc is pre-branch bcp duke@435: duke@435: duke@435: #define DO_BACKEDGE_CHECKS(skip, branch_pc) \ duke@435: if ((skip) <= 0) { \ duke@435: if (UseCompiler && UseLoopCounter) { \ duke@435: bool do_OSR = UseOnStackReplacement; \ duke@435: BACKEDGE_COUNT->increment(); \ duke@435: if (do_OSR) do_OSR = BACKEDGE_COUNT->reached_InvocationLimit(); \ duke@435: if (do_OSR) { \ duke@435: nmethod* osr_nmethod; \ duke@435: OSR_REQUEST(osr_nmethod, branch_pc); \ duke@435: if (osr_nmethod != NULL && osr_nmethod->osr_entry_bci() != InvalidOSREntryBci) { \ duke@435: intptr_t* buf; \ duke@435: CALL_VM(buf=SharedRuntime::OSR_migration_begin(THREAD), handle_exception); \ duke@435: istate->set_msg(do_osr); \ duke@435: istate->set_osr_buf((address)buf); \ duke@435: istate->set_osr_entry(osr_nmethod->osr_entry()); \ duke@435: return; \ duke@435: } \ duke@435: } else { \ duke@435: INCR_INVOCATION_COUNT; \ duke@435: SAFEPOINT; \ duke@435: } \ duke@435: } /* UseCompiler ... */ \ duke@435: INCR_INVOCATION_COUNT; \ duke@435: SAFEPOINT; \ duke@435: } duke@435: duke@435: /* duke@435: * For those opcodes that need to have a GC point on a backwards branch duke@435: */ duke@435: duke@435: /* duke@435: * Macros for caching and flushing the interpreter state. Some local duke@435: * variables need to be flushed out to the frame before we do certain duke@435: * things (like pushing frames or becomming gc safe) and some need to duke@435: * be recached later (like after popping a frame). We could use one duke@435: * macro to cache or decache everything, but this would be less then duke@435: * optimal because we don't always need to cache or decache everything duke@435: * because some things we know are already cached or decached. duke@435: */ duke@435: #undef DECACHE_TOS duke@435: #undef CACHE_TOS duke@435: #undef CACHE_PREV_TOS duke@435: #define DECACHE_TOS() istate->set_stack(topOfStack); duke@435: duke@435: #define CACHE_TOS() topOfStack = (intptr_t *)istate->stack(); duke@435: duke@435: #undef DECACHE_PC duke@435: #undef CACHE_PC duke@435: #define DECACHE_PC() istate->set_bcp(pc); duke@435: #define CACHE_PC() pc = istate->bcp(); duke@435: #define CACHE_CP() cp = istate->constants(); duke@435: #define CACHE_LOCALS() locals = istate->locals(); duke@435: #undef CACHE_FRAME duke@435: #define CACHE_FRAME() duke@435: duke@435: /* duke@435: * CHECK_NULL - Macro for throwing a NullPointerException if the object duke@435: * passed is a null ref. duke@435: * On some architectures/platforms it should be possible to do this implicitly duke@435: */ duke@435: #undef CHECK_NULL duke@435: #define CHECK_NULL(obj_) \ duke@435: if ((obj_) == 0) { \ duke@435: VM_JAVA_ERROR(vmSymbols::java_lang_NullPointerException(), ""); \ duke@435: } duke@435: duke@435: #define VMdoubleConstZero() 0.0 duke@435: #define VMdoubleConstOne() 1.0 duke@435: #define VMlongConstZero() (max_jlong-max_jlong) duke@435: #define VMlongConstOne() ((max_jlong-max_jlong)+1) duke@435: duke@435: /* duke@435: * Alignment duke@435: */ duke@435: #define VMalignWordUp(val) (((uintptr_t)(val) + 3) & ~3) duke@435: duke@435: // Decache the interpreter state that interpreter modifies directly (i.e. GC is indirect mod) duke@435: #define DECACHE_STATE() DECACHE_PC(); DECACHE_TOS(); duke@435: duke@435: // Reload interpreter state after calling the VM or a possible GC duke@435: #define CACHE_STATE() \ duke@435: CACHE_TOS(); \ duke@435: CACHE_PC(); \ duke@435: CACHE_CP(); \ duke@435: CACHE_LOCALS(); duke@435: duke@435: // Call the VM don't check for pending exceptions duke@435: #define CALL_VM_NOCHECK(func) \ duke@435: DECACHE_STATE(); \ duke@435: SET_LAST_JAVA_FRAME(); \ duke@435: func; \ duke@435: RESET_LAST_JAVA_FRAME(); \ duke@435: CACHE_STATE(); \ duke@435: if (THREAD->pop_frame_pending() && \ duke@435: !THREAD->pop_frame_in_process()) { \ duke@435: goto handle_Pop_Frame; \ duke@435: } duke@435: duke@435: // Call the VM and check for pending exceptions duke@435: #define CALL_VM(func, label) { \ duke@435: CALL_VM_NOCHECK(func); \ duke@435: if (THREAD->has_pending_exception()) goto label; \ duke@435: } duke@435: duke@435: /* duke@435: * BytecodeInterpreter::run(interpreterState istate) duke@435: * BytecodeInterpreter::runWithChecks(interpreterState istate) duke@435: * duke@435: * The real deal. This is where byte codes actually get interpreted. duke@435: * Basically it's a big while loop that iterates until we return from duke@435: * the method passed in. duke@435: * duke@435: * The runWithChecks is used if JVMTI is enabled. duke@435: * duke@435: */ duke@435: #if defined(VM_JVMTI) duke@435: void duke@435: BytecodeInterpreter::runWithChecks(interpreterState istate) { duke@435: #else duke@435: void duke@435: BytecodeInterpreter::run(interpreterState istate) { duke@435: #endif duke@435: duke@435: // In order to simplify some tests based on switches set at runtime duke@435: // we invoke the interpreter a single time after switches are enabled duke@435: // and set simpler to to test variables rather than method calls or complex duke@435: // boolean expressions. duke@435: duke@435: static int initialized = 0; duke@435: static int checkit = 0; duke@435: static intptr_t* c_addr = NULL; duke@435: static intptr_t c_value; duke@435: duke@435: if (checkit && *c_addr != c_value) { duke@435: os::breakpoint(); duke@435: } duke@435: #ifdef VM_JVMTI duke@435: static bool _jvmti_interp_events = 0; duke@435: #endif duke@435: duke@435: static int _compiling; // (UseCompiler || CountCompiledCalls) duke@435: duke@435: #ifdef ASSERT duke@435: if (istate->_msg != initialize) { duke@435: assert(abs(istate->_stack_base - istate->_stack_limit) == (istate->_method->max_stack() + 1), "bad stack limit"); duke@435: IA32_ONLY(assert(istate->_stack_limit == istate->_thread->last_Java_sp() + 1, "wrong")); duke@435: } duke@435: // Verify linkages. duke@435: interpreterState l = istate; duke@435: do { duke@435: assert(l == l->_self_link, "bad link"); duke@435: l = l->_prev_link; duke@435: } while (l != NULL); duke@435: // Screwups with stack management usually cause us to overwrite istate duke@435: // save a copy so we can verify it. duke@435: interpreterState orig = istate; duke@435: #endif duke@435: duke@435: static volatile jbyte* _byte_map_base; // adjusted card table base for oop store barrier duke@435: duke@435: register intptr_t* topOfStack = (intptr_t *)istate->stack(); /* access with STACK macros */ duke@435: register address pc = istate->bcp(); duke@435: register jubyte opcode; duke@435: register intptr_t* locals = istate->locals(); duke@435: register constantPoolCacheOop cp = istate->constants(); // method()->constants()->cache() duke@435: #ifdef LOTS_OF_REGS duke@435: register JavaThread* THREAD = istate->thread(); duke@435: register volatile jbyte* BYTE_MAP_BASE = _byte_map_base; duke@435: #else duke@435: #undef THREAD duke@435: #define THREAD istate->thread() duke@435: #undef BYTE_MAP_BASE duke@435: #define BYTE_MAP_BASE _byte_map_base duke@435: #endif duke@435: duke@435: #ifdef USELABELS duke@435: const static void* const opclabels_data[256] = { duke@435: /* 0x00 */ &&opc_nop, &&opc_aconst_null,&&opc_iconst_m1,&&opc_iconst_0, duke@435: /* 0x04 */ &&opc_iconst_1,&&opc_iconst_2, &&opc_iconst_3, &&opc_iconst_4, duke@435: /* 0x08 */ &&opc_iconst_5,&&opc_lconst_0, &&opc_lconst_1, &&opc_fconst_0, duke@435: /* 0x0C */ &&opc_fconst_1,&&opc_fconst_2, &&opc_dconst_0, &&opc_dconst_1, duke@435: duke@435: /* 0x10 */ &&opc_bipush, &&opc_sipush, &&opc_ldc, &&opc_ldc_w, duke@435: /* 0x14 */ &&opc_ldc2_w, &&opc_iload, &&opc_lload, &&opc_fload, duke@435: /* 0x18 */ &&opc_dload, &&opc_aload, &&opc_iload_0,&&opc_iload_1, duke@435: /* 0x1C */ &&opc_iload_2,&&opc_iload_3,&&opc_lload_0,&&opc_lload_1, duke@435: duke@435: /* 0x20 */ &&opc_lload_2,&&opc_lload_3,&&opc_fload_0,&&opc_fload_1, duke@435: /* 0x24 */ &&opc_fload_2,&&opc_fload_3,&&opc_dload_0,&&opc_dload_1, duke@435: /* 0x28 */ &&opc_dload_2,&&opc_dload_3,&&opc_aload_0,&&opc_aload_1, duke@435: /* 0x2C */ &&opc_aload_2,&&opc_aload_3,&&opc_iaload, &&opc_laload, duke@435: duke@435: /* 0x30 */ &&opc_faload, &&opc_daload, &&opc_aaload, &&opc_baload, duke@435: /* 0x34 */ &&opc_caload, &&opc_saload, &&opc_istore, &&opc_lstore, duke@435: /* 0x38 */ &&opc_fstore, &&opc_dstore, &&opc_astore, &&opc_istore_0, duke@435: /* 0x3C */ &&opc_istore_1,&&opc_istore_2,&&opc_istore_3,&&opc_lstore_0, duke@435: duke@435: /* 0x40 */ &&opc_lstore_1,&&opc_lstore_2,&&opc_lstore_3,&&opc_fstore_0, duke@435: /* 0x44 */ &&opc_fstore_1,&&opc_fstore_2,&&opc_fstore_3,&&opc_dstore_0, duke@435: /* 0x48 */ &&opc_dstore_1,&&opc_dstore_2,&&opc_dstore_3,&&opc_astore_0, duke@435: /* 0x4C */ &&opc_astore_1,&&opc_astore_2,&&opc_astore_3,&&opc_iastore, duke@435: duke@435: /* 0x50 */ &&opc_lastore,&&opc_fastore,&&opc_dastore,&&opc_aastore, duke@435: /* 0x54 */ &&opc_bastore,&&opc_castore,&&opc_sastore,&&opc_pop, duke@435: /* 0x58 */ &&opc_pop2, &&opc_dup, &&opc_dup_x1, &&opc_dup_x2, duke@435: /* 0x5C */ &&opc_dup2, &&opc_dup2_x1,&&opc_dup2_x2,&&opc_swap, duke@435: duke@435: /* 0x60 */ &&opc_iadd,&&opc_ladd,&&opc_fadd,&&opc_dadd, duke@435: /* 0x64 */ &&opc_isub,&&opc_lsub,&&opc_fsub,&&opc_dsub, duke@435: /* 0x68 */ &&opc_imul,&&opc_lmul,&&opc_fmul,&&opc_dmul, duke@435: /* 0x6C */ &&opc_idiv,&&opc_ldiv,&&opc_fdiv,&&opc_ddiv, duke@435: duke@435: /* 0x70 */ &&opc_irem, &&opc_lrem, &&opc_frem,&&opc_drem, duke@435: /* 0x74 */ &&opc_ineg, &&opc_lneg, &&opc_fneg,&&opc_dneg, duke@435: /* 0x78 */ &&opc_ishl, &&opc_lshl, &&opc_ishr,&&opc_lshr, duke@435: /* 0x7C */ &&opc_iushr,&&opc_lushr,&&opc_iand,&&opc_land, duke@435: duke@435: /* 0x80 */ &&opc_ior, &&opc_lor,&&opc_ixor,&&opc_lxor, duke@435: /* 0x84 */ &&opc_iinc,&&opc_i2l,&&opc_i2f, &&opc_i2d, duke@435: /* 0x88 */ &&opc_l2i, &&opc_l2f,&&opc_l2d, &&opc_f2i, duke@435: /* 0x8C */ &&opc_f2l, &&opc_f2d,&&opc_d2i, &&opc_d2l, duke@435: duke@435: /* 0x90 */ &&opc_d2f, &&opc_i2b, &&opc_i2c, &&opc_i2s, duke@435: /* 0x94 */ &&opc_lcmp, &&opc_fcmpl,&&opc_fcmpg,&&opc_dcmpl, duke@435: /* 0x98 */ &&opc_dcmpg,&&opc_ifeq, &&opc_ifne, &&opc_iflt, duke@435: /* 0x9C */ &&opc_ifge, &&opc_ifgt, &&opc_ifle, &&opc_if_icmpeq, duke@435: duke@435: /* 0xA0 */ &&opc_if_icmpne,&&opc_if_icmplt,&&opc_if_icmpge, &&opc_if_icmpgt, duke@435: /* 0xA4 */ &&opc_if_icmple,&&opc_if_acmpeq,&&opc_if_acmpne, &&opc_goto, duke@435: /* 0xA8 */ &&opc_jsr, &&opc_ret, &&opc_tableswitch,&&opc_lookupswitch, duke@435: /* 0xAC */ &&opc_ireturn, &&opc_lreturn, &&opc_freturn, &&opc_dreturn, duke@435: duke@435: /* 0xB0 */ &&opc_areturn, &&opc_return, &&opc_getstatic, &&opc_putstatic, duke@435: /* 0xB4 */ &&opc_getfield, &&opc_putfield, &&opc_invokevirtual,&&opc_invokespecial, duke@435: /* 0xB8 */ &&opc_invokestatic,&&opc_invokeinterface,NULL, &&opc_new, duke@435: /* 0xBC */ &&opc_newarray, &&opc_anewarray, &&opc_arraylength, &&opc_athrow, duke@435: duke@435: /* 0xC0 */ &&opc_checkcast, &&opc_instanceof, &&opc_monitorenter, &&opc_monitorexit, duke@435: /* 0xC4 */ &&opc_wide, &&opc_multianewarray, &&opc_ifnull, &&opc_ifnonnull, sgoldman@558: /* 0xC8 */ &&opc_goto_w, &&opc_jsr_w, &&opc_breakpoint, &&opc_default, sgoldman@558: /* 0xCC */ &&opc_default, &&opc_default, &&opc_default, &&opc_default, sgoldman@558: sgoldman@558: /* 0xD0 */ &&opc_default, &&opc_default, &&opc_default, &&opc_default, duke@435: /* 0xD4 */ &&opc_default, &&opc_default, &&opc_default, &&opc_default, duke@435: /* 0xD8 */ &&opc_default, &&opc_default, &&opc_default, &&opc_default, duke@435: /* 0xDC */ &&opc_default, &&opc_default, &&opc_default, &&opc_default, duke@435: duke@435: /* 0xE0 */ &&opc_default, &&opc_default, &&opc_default, &&opc_default, sgoldman@558: /* 0xE4 */ &&opc_default, &&opc_return_register_finalizer, &&opc_default, &&opc_default, duke@435: /* 0xE8 */ &&opc_default, &&opc_default, &&opc_default, &&opc_default, duke@435: /* 0xEC */ &&opc_default, &&opc_default, &&opc_default, &&opc_default, duke@435: duke@435: /* 0xF0 */ &&opc_default, &&opc_default, &&opc_default, &&opc_default, duke@435: /* 0xF4 */ &&opc_default, &&opc_default, &&opc_default, &&opc_default, duke@435: /* 0xF8 */ &&opc_default, &&opc_default, &&opc_default, &&opc_default, duke@435: /* 0xFC */ &&opc_default, &&opc_default, &&opc_default, &&opc_default duke@435: }; duke@435: register uintptr_t *dispatch_table = (uintptr_t*)&opclabels_data[0]; duke@435: #endif /* USELABELS */ duke@435: duke@435: #ifdef ASSERT duke@435: // this will trigger a VERIFY_OOP on entry duke@435: if (istate->msg() != initialize && ! METHOD->is_static()) { duke@435: oop rcvr = LOCALS_OBJECT(0); duke@435: } duke@435: #endif duke@435: // #define HACK duke@435: #ifdef HACK duke@435: bool interesting = false; duke@435: #endif // HACK duke@435: duke@435: /* QQQ this should be a stack method so we don't know actual direction */ duke@435: assert(istate->msg() == initialize || duke@435: topOfStack >= istate->stack_limit() && duke@435: topOfStack < istate->stack_base(), duke@435: "Stack top out of range"); duke@435: duke@435: switch (istate->msg()) { duke@435: case initialize: { duke@435: if (initialized++) ShouldNotReachHere(); // Only one initialize call duke@435: _compiling = (UseCompiler || CountCompiledCalls); duke@435: #ifdef VM_JVMTI duke@435: _jvmti_interp_events = JvmtiExport::can_post_interpreter_events(); duke@435: #endif duke@435: BarrierSet* bs = Universe::heap()->barrier_set(); duke@435: assert(bs->kind() == BarrierSet::CardTableModRef, "Wrong barrier set kind"); duke@435: _byte_map_base = (volatile jbyte*)(((CardTableModRefBS*)bs)->byte_map_base); duke@435: return; duke@435: } duke@435: break; duke@435: case method_entry: { duke@435: THREAD->set_do_not_unlock(); duke@435: // count invocations duke@435: assert(initialized, "Interpreter not initialized"); duke@435: if (_compiling) { duke@435: if (ProfileInterpreter) { duke@435: METHOD->increment_interpreter_invocation_count(); duke@435: } duke@435: INCR_INVOCATION_COUNT; duke@435: if (INVOCATION_COUNT->reached_InvocationLimit()) { duke@435: CALL_VM((void)InterpreterRuntime::frequency_counter_overflow(THREAD, NULL), handle_exception); duke@435: duke@435: // We no longer retry on a counter overflow duke@435: duke@435: // istate->set_msg(retry_method); duke@435: // THREAD->clr_do_not_unlock(); duke@435: // return; duke@435: } duke@435: SAFEPOINT; duke@435: } duke@435: duke@435: if ((istate->_stack_base - istate->_stack_limit) != istate->method()->max_stack() + 1) { duke@435: // initialize duke@435: os::breakpoint(); duke@435: } duke@435: duke@435: #ifdef HACK duke@435: { duke@435: ResourceMark rm; duke@435: char *method_name = istate->method()->name_and_sig_as_C_string(); duke@435: if (strstr(method_name, "runThese$TestRunner.run()V") != NULL) { duke@435: tty->print_cr("entering: depth %d bci: %d", duke@435: (istate->_stack_base - istate->_stack), duke@435: istate->_bcp - istate->_method->code_base()); duke@435: interesting = true; duke@435: } duke@435: } duke@435: #endif // HACK duke@435: duke@435: duke@435: // lock method if synchronized duke@435: if (METHOD->is_synchronized()) { duke@435: // oop rcvr = locals[0].j.r; duke@435: oop rcvr; duke@435: if (METHOD->is_static()) { duke@435: rcvr = METHOD->constants()->pool_holder()->klass_part()->java_mirror(); duke@435: } else { duke@435: rcvr = LOCALS_OBJECT(0); duke@435: } duke@435: // The initial monitor is ours for the taking duke@435: BasicObjectLock* mon = &istate->monitor_base()[-1]; duke@435: oop monobj = mon->obj(); duke@435: assert(mon->obj() == rcvr, "method monitor mis-initialized"); duke@435: duke@435: bool success = UseBiasedLocking; duke@435: if (UseBiasedLocking) { duke@435: markOop mark = rcvr->mark(); duke@435: if (mark->has_bias_pattern()) { duke@435: // The bias pattern is present in the object's header. Need to check duke@435: // whether the bias owner and the epoch are both still current. duke@435: intptr_t xx = ((intptr_t) THREAD) ^ (intptr_t) mark; duke@435: xx = (intptr_t) rcvr->klass()->klass_part()->prototype_header() ^ xx; duke@435: intptr_t yy = (xx & ~((int) markOopDesc::age_mask_in_place)); duke@435: if (yy != 0 ) { duke@435: // At this point we know that the header has the bias pattern and duke@435: // that we are not the bias owner in the current epoch. We need to duke@435: // figure out more details about the state of the header in order to duke@435: // know what operations can be legally performed on the object's duke@435: // header. duke@435: duke@435: // If the low three bits in the xor result aren't clear, that means duke@435: // the prototype header is no longer biased and we have to revoke duke@435: // the bias on this object. duke@435: duke@435: if (yy & markOopDesc::biased_lock_mask_in_place == 0 ) { duke@435: // Biasing is still enabled for this data type. See whether the duke@435: // epoch of the current bias is still valid, meaning that the epoch duke@435: // bits of the mark word are equal to the epoch bits of the duke@435: // prototype header. (Note that the prototype header's epoch bits duke@435: // only change at a safepoint.) If not, attempt to rebias the object duke@435: // toward the current thread. Note that we must be absolutely sure duke@435: // that the current epoch is invalid in order to do this because duke@435: // otherwise the manipulations it performs on the mark word are duke@435: // illegal. duke@435: if (yy & markOopDesc::epoch_mask_in_place == 0) { duke@435: // The epoch of the current bias is still valid but we know nothing duke@435: // about the owner; it might be set or it might be clear. Try to duke@435: // acquire the bias of the object using an atomic operation. If this duke@435: // fails we will go in to the runtime to revoke the object's bias. duke@435: // Note that we first construct the presumed unbiased header so we duke@435: // don't accidentally blow away another thread's valid bias. duke@435: intptr_t unbiased = (intptr_t) mark & (markOopDesc::biased_lock_mask_in_place | duke@435: markOopDesc::age_mask_in_place | duke@435: markOopDesc::epoch_mask_in_place); duke@435: if (Atomic::cmpxchg_ptr((intptr_t)THREAD | unbiased, (intptr_t*) rcvr->mark_addr(), unbiased) != unbiased) { duke@435: CALL_VM(InterpreterRuntime::monitorenter(THREAD, mon), handle_exception); duke@435: } duke@435: } else { duke@435: try_rebias: duke@435: // At this point we know the epoch has expired, meaning that the duke@435: // current "bias owner", if any, is actually invalid. Under these duke@435: // circumstances _only_, we are allowed to use the current header's duke@435: // value as the comparison value when doing the cas to acquire the duke@435: // bias in the current epoch. In other words, we allow transfer of duke@435: // the bias from one thread to another directly in this situation. duke@435: xx = (intptr_t) rcvr->klass()->klass_part()->prototype_header() | (intptr_t) THREAD; duke@435: if (Atomic::cmpxchg_ptr((intptr_t)THREAD | (intptr_t) rcvr->klass()->klass_part()->prototype_header(), duke@435: (intptr_t*) rcvr->mark_addr(), duke@435: (intptr_t) mark) != (intptr_t) mark) { duke@435: CALL_VM(InterpreterRuntime::monitorenter(THREAD, mon), handle_exception); duke@435: } duke@435: } duke@435: } else { duke@435: try_revoke_bias: duke@435: // The prototype mark in the klass doesn't have the bias bit set any duke@435: // more, indicating that objects of this data type are not supposed duke@435: // to be biased any more. We are going to try to reset the mark of duke@435: // this object to the prototype value and fall through to the duke@435: // CAS-based locking scheme. Note that if our CAS fails, it means duke@435: // that another thread raced us for the privilege of revoking the duke@435: // bias of this particular object, so it's okay to continue in the duke@435: // normal locking code. duke@435: // duke@435: xx = (intptr_t) rcvr->klass()->klass_part()->prototype_header() | (intptr_t) THREAD; duke@435: if (Atomic::cmpxchg_ptr(rcvr->klass()->klass_part()->prototype_header(), duke@435: (intptr_t*) rcvr->mark_addr(), duke@435: mark) == mark) { duke@435: // (*counters->revoked_lock_entry_count_addr())++; duke@435: success = false; duke@435: } duke@435: } duke@435: } duke@435: } else { duke@435: cas_label: duke@435: success = false; duke@435: } duke@435: } duke@435: if (!success) { duke@435: markOop displaced = rcvr->mark()->set_unlocked(); duke@435: mon->lock()->set_displaced_header(displaced); duke@435: if (Atomic::cmpxchg_ptr(mon, rcvr->mark_addr(), displaced) != displaced) { duke@435: // Is it simple recursive case? duke@435: if (THREAD->is_lock_owned((address) displaced->clear_lock_bits())) { duke@435: mon->lock()->set_displaced_header(NULL); duke@435: } else { duke@435: CALL_VM(InterpreterRuntime::monitorenter(THREAD, mon), handle_exception); duke@435: } duke@435: } duke@435: } duke@435: } duke@435: THREAD->clr_do_not_unlock(); duke@435: duke@435: // Notify jvmti duke@435: #ifdef VM_JVMTI duke@435: if (_jvmti_interp_events) { duke@435: // Whenever JVMTI puts a thread in interp_only_mode, method duke@435: // entry/exit events are sent for that thread to track stack depth. duke@435: if (THREAD->is_interp_only_mode()) { duke@435: CALL_VM(InterpreterRuntime::post_method_entry(THREAD), duke@435: handle_exception); duke@435: } duke@435: } duke@435: #endif /* VM_JVMTI */ duke@435: duke@435: goto run; duke@435: } duke@435: duke@435: case popping_frame: { duke@435: // returned from a java call to pop the frame, restart the call duke@435: // clear the message so we don't confuse ourselves later duke@435: assert(THREAD->pop_frame_in_process(), "wrong frame pop state"); duke@435: istate->set_msg(no_request); duke@435: THREAD->clr_pop_frame_in_process(); duke@435: goto run; duke@435: } duke@435: duke@435: case method_resume: { duke@435: if ((istate->_stack_base - istate->_stack_limit) != istate->method()->max_stack() + 1) { duke@435: // resume duke@435: os::breakpoint(); duke@435: } duke@435: #ifdef HACK duke@435: { duke@435: ResourceMark rm; duke@435: char *method_name = istate->method()->name_and_sig_as_C_string(); duke@435: if (strstr(method_name, "runThese$TestRunner.run()V") != NULL) { duke@435: tty->print_cr("resume: depth %d bci: %d", duke@435: (istate->_stack_base - istate->_stack) , duke@435: istate->_bcp - istate->_method->code_base()); duke@435: interesting = true; duke@435: } duke@435: } duke@435: #endif // HACK duke@435: // returned from a java call, continue executing. duke@435: if (THREAD->pop_frame_pending() && !THREAD->pop_frame_in_process()) { duke@435: goto handle_Pop_Frame; duke@435: } duke@435: duke@435: if (THREAD->has_pending_exception()) goto handle_exception; duke@435: // Update the pc by the saved amount of the invoke bytecode size duke@435: UPDATE_PC(istate->bcp_advance()); duke@435: goto run; duke@435: } duke@435: duke@435: case deopt_resume2: { duke@435: // Returned from an opcode that will reexecute. Deopt was duke@435: // a result of a PopFrame request. duke@435: // duke@435: goto run; duke@435: } duke@435: duke@435: case deopt_resume: { duke@435: // Returned from an opcode that has completed. The stack has duke@435: // the result all we need to do is skip across the bytecode duke@435: // and continue (assuming there is no exception pending) duke@435: // duke@435: // compute continuation length duke@435: // duke@435: // Note: it is possible to deopt at a return_register_finalizer opcode duke@435: // because this requires entering the vm to do the registering. While the duke@435: // opcode is complete we can't advance because there are no more opcodes duke@435: // much like trying to deopt at a poll return. In that has we simply duke@435: // get out of here duke@435: // duke@435: if ( Bytecodes::code_at(pc, METHOD) == Bytecodes::_return_register_finalizer) { duke@435: // this will do the right thing even if an exception is pending. duke@435: goto handle_return; duke@435: } duke@435: UPDATE_PC(Bytecodes::length_at(pc)); duke@435: if (THREAD->has_pending_exception()) goto handle_exception; duke@435: goto run; duke@435: } duke@435: case got_monitors: { duke@435: // continue locking now that we have a monitor to use duke@435: // we expect to find newly allocated monitor at the "top" of the monitor stack. duke@435: oop lockee = STACK_OBJECT(-1); duke@435: // derefing's lockee ought to provoke implicit null check duke@435: // find a free monitor duke@435: BasicObjectLock* entry = (BasicObjectLock*) istate->stack_base(); duke@435: assert(entry->obj() == NULL, "Frame manager didn't allocate the monitor"); duke@435: entry->set_obj(lockee); duke@435: duke@435: markOop displaced = lockee->mark()->set_unlocked(); duke@435: entry->lock()->set_displaced_header(displaced); duke@435: if (Atomic::cmpxchg_ptr(entry, lockee->mark_addr(), displaced) != displaced) { duke@435: // Is it simple recursive case? duke@435: if (THREAD->is_lock_owned((address) displaced->clear_lock_bits())) { duke@435: entry->lock()->set_displaced_header(NULL); duke@435: } else { duke@435: CALL_VM(InterpreterRuntime::monitorenter(THREAD, entry), handle_exception); duke@435: } duke@435: } duke@435: UPDATE_PC_AND_TOS(1, -1); duke@435: goto run; duke@435: } duke@435: default: { duke@435: fatal("Unexpected message from frame manager"); duke@435: } duke@435: } duke@435: duke@435: run: duke@435: duke@435: DO_UPDATE_INSTRUCTION_COUNT(*pc) duke@435: DEBUGGER_SINGLE_STEP_NOTIFY(); duke@435: #ifdef PREFETCH_OPCCODE duke@435: opcode = *pc; /* prefetch first opcode */ duke@435: #endif duke@435: duke@435: #ifndef USELABELS duke@435: while (1) duke@435: #endif duke@435: { duke@435: #ifndef PREFETCH_OPCCODE duke@435: opcode = *pc; duke@435: #endif duke@435: // Seems like this happens twice per opcode. At worst this is only duke@435: // need at entry to the loop. duke@435: // DEBUGGER_SINGLE_STEP_NOTIFY(); duke@435: /* Using this labels avoids double breakpoints when quickening and duke@435: * when returing from transition frames. duke@435: */ duke@435: opcode_switch: duke@435: assert(istate == orig, "Corrupted istate"); duke@435: /* QQQ Hmm this has knowledge of direction, ought to be a stack method */ duke@435: assert(topOfStack >= istate->stack_limit(), "Stack overrun"); duke@435: assert(topOfStack < istate->stack_base(), "Stack underrun"); duke@435: duke@435: #ifdef USELABELS duke@435: DISPATCH(opcode); duke@435: #else duke@435: switch (opcode) duke@435: #endif duke@435: { duke@435: CASE(_nop): duke@435: UPDATE_PC_AND_CONTINUE(1); duke@435: duke@435: /* Push miscellaneous constants onto the stack. */ duke@435: duke@435: CASE(_aconst_null): duke@435: SET_STACK_OBJECT(NULL, 0); duke@435: UPDATE_PC_AND_TOS_AND_CONTINUE(1, 1); duke@435: duke@435: #undef OPC_CONST_n duke@435: #define OPC_CONST_n(opcode, const_type, value) \ duke@435: CASE(opcode): \ duke@435: SET_STACK_ ## const_type(value, 0); \ duke@435: UPDATE_PC_AND_TOS_AND_CONTINUE(1, 1); duke@435: duke@435: OPC_CONST_n(_iconst_m1, INT, -1); duke@435: OPC_CONST_n(_iconst_0, INT, 0); duke@435: OPC_CONST_n(_iconst_1, INT, 1); duke@435: OPC_CONST_n(_iconst_2, INT, 2); duke@435: OPC_CONST_n(_iconst_3, INT, 3); duke@435: OPC_CONST_n(_iconst_4, INT, 4); duke@435: OPC_CONST_n(_iconst_5, INT, 5); duke@435: OPC_CONST_n(_fconst_0, FLOAT, 0.0); duke@435: OPC_CONST_n(_fconst_1, FLOAT, 1.0); duke@435: OPC_CONST_n(_fconst_2, FLOAT, 2.0); duke@435: duke@435: #undef OPC_CONST2_n duke@435: #define OPC_CONST2_n(opcname, value, key, kind) \ duke@435: CASE(_##opcname): \ duke@435: { \ duke@435: SET_STACK_ ## kind(VM##key##Const##value(), 1); \ duke@435: UPDATE_PC_AND_TOS_AND_CONTINUE(1, 2); \ duke@435: } duke@435: OPC_CONST2_n(dconst_0, Zero, double, DOUBLE); duke@435: OPC_CONST2_n(dconst_1, One, double, DOUBLE); duke@435: OPC_CONST2_n(lconst_0, Zero, long, LONG); duke@435: OPC_CONST2_n(lconst_1, One, long, LONG); duke@435: duke@435: /* Load constant from constant pool: */ duke@435: duke@435: /* Push a 1-byte signed integer value onto the stack. */ duke@435: CASE(_bipush): duke@435: SET_STACK_INT((jbyte)(pc[1]), 0); duke@435: UPDATE_PC_AND_TOS_AND_CONTINUE(2, 1); duke@435: duke@435: /* Push a 2-byte signed integer constant onto the stack. */ duke@435: CASE(_sipush): duke@435: SET_STACK_INT((int16_t)Bytes::get_Java_u2(pc + 1), 0); duke@435: UPDATE_PC_AND_TOS_AND_CONTINUE(3, 1); duke@435: duke@435: /* load from local variable */ duke@435: duke@435: CASE(_aload): duke@435: SET_STACK_OBJECT(LOCALS_OBJECT(pc[1]), 0); duke@435: UPDATE_PC_AND_TOS_AND_CONTINUE(2, 1); duke@435: duke@435: CASE(_iload): duke@435: CASE(_fload): duke@435: SET_STACK_SLOT(LOCALS_SLOT(pc[1]), 0); duke@435: UPDATE_PC_AND_TOS_AND_CONTINUE(2, 1); duke@435: duke@435: CASE(_lload): duke@435: SET_STACK_LONG_FROM_ADDR(LOCALS_LONG_AT(pc[1]), 1); duke@435: UPDATE_PC_AND_TOS_AND_CONTINUE(2, 2); duke@435: duke@435: CASE(_dload): duke@435: SET_STACK_DOUBLE_FROM_ADDR(LOCALS_DOUBLE_AT(pc[1]), 1); duke@435: UPDATE_PC_AND_TOS_AND_CONTINUE(2, 2); duke@435: duke@435: #undef OPC_LOAD_n duke@435: #define OPC_LOAD_n(num) \ duke@435: CASE(_aload_##num): \ duke@435: SET_STACK_OBJECT(LOCALS_OBJECT(num), 0); \ duke@435: UPDATE_PC_AND_TOS_AND_CONTINUE(1, 1); \ duke@435: \ duke@435: CASE(_iload_##num): \ duke@435: CASE(_fload_##num): \ duke@435: SET_STACK_SLOT(LOCALS_SLOT(num), 0); \ duke@435: UPDATE_PC_AND_TOS_AND_CONTINUE(1, 1); \ duke@435: \ duke@435: CASE(_lload_##num): \ duke@435: SET_STACK_LONG_FROM_ADDR(LOCALS_LONG_AT(num), 1); \ duke@435: UPDATE_PC_AND_TOS_AND_CONTINUE(1, 2); \ duke@435: CASE(_dload_##num): \ duke@435: SET_STACK_DOUBLE_FROM_ADDR(LOCALS_DOUBLE_AT(num), 1); \ duke@435: UPDATE_PC_AND_TOS_AND_CONTINUE(1, 2); duke@435: duke@435: OPC_LOAD_n(0); duke@435: OPC_LOAD_n(1); duke@435: OPC_LOAD_n(2); duke@435: OPC_LOAD_n(3); duke@435: duke@435: /* store to a local variable */ duke@435: duke@435: CASE(_astore): duke@435: astore(topOfStack, -1, locals, pc[1]); duke@435: UPDATE_PC_AND_TOS_AND_CONTINUE(2, -1); duke@435: duke@435: CASE(_istore): duke@435: CASE(_fstore): duke@435: SET_LOCALS_SLOT(STACK_SLOT(-1), pc[1]); duke@435: UPDATE_PC_AND_TOS_AND_CONTINUE(2, -1); duke@435: duke@435: CASE(_lstore): duke@435: SET_LOCALS_LONG(STACK_LONG(-1), pc[1]); duke@435: UPDATE_PC_AND_TOS_AND_CONTINUE(2, -2); duke@435: duke@435: CASE(_dstore): duke@435: SET_LOCALS_DOUBLE(STACK_DOUBLE(-1), pc[1]); duke@435: UPDATE_PC_AND_TOS_AND_CONTINUE(2, -2); duke@435: duke@435: CASE(_wide): { duke@435: uint16_t reg = Bytes::get_Java_u2(pc + 2); duke@435: duke@435: opcode = pc[1]; duke@435: switch(opcode) { duke@435: case Bytecodes::_aload: duke@435: SET_STACK_OBJECT(LOCALS_OBJECT(reg), 0); duke@435: UPDATE_PC_AND_TOS_AND_CONTINUE(4, 1); duke@435: duke@435: case Bytecodes::_iload: duke@435: case Bytecodes::_fload: duke@435: SET_STACK_SLOT(LOCALS_SLOT(reg), 0); duke@435: UPDATE_PC_AND_TOS_AND_CONTINUE(4, 1); duke@435: duke@435: case Bytecodes::_lload: duke@435: SET_STACK_LONG_FROM_ADDR(LOCALS_LONG_AT(reg), 1); duke@435: UPDATE_PC_AND_TOS_AND_CONTINUE(4, 2); duke@435: duke@435: case Bytecodes::_dload: duke@435: SET_STACK_DOUBLE_FROM_ADDR(LOCALS_LONG_AT(reg), 1); duke@435: UPDATE_PC_AND_TOS_AND_CONTINUE(4, 2); duke@435: duke@435: case Bytecodes::_astore: duke@435: astore(topOfStack, -1, locals, reg); duke@435: UPDATE_PC_AND_TOS_AND_CONTINUE(4, -1); duke@435: duke@435: case Bytecodes::_istore: duke@435: case Bytecodes::_fstore: duke@435: SET_LOCALS_SLOT(STACK_SLOT(-1), reg); duke@435: UPDATE_PC_AND_TOS_AND_CONTINUE(4, -1); duke@435: duke@435: case Bytecodes::_lstore: duke@435: SET_LOCALS_LONG(STACK_LONG(-1), reg); duke@435: UPDATE_PC_AND_TOS_AND_CONTINUE(4, -2); duke@435: duke@435: case Bytecodes::_dstore: duke@435: SET_LOCALS_DOUBLE(STACK_DOUBLE(-1), reg); duke@435: UPDATE_PC_AND_TOS_AND_CONTINUE(4, -2); duke@435: duke@435: case Bytecodes::_iinc: { duke@435: int16_t offset = (int16_t)Bytes::get_Java_u2(pc+4); duke@435: // Be nice to see what this generates.... QQQ duke@435: SET_LOCALS_INT(LOCALS_INT(reg) + offset, reg); duke@435: UPDATE_PC_AND_CONTINUE(6); duke@435: } duke@435: case Bytecodes::_ret: duke@435: pc = istate->method()->code_base() + (intptr_t)(LOCALS_ADDR(reg)); duke@435: UPDATE_PC_AND_CONTINUE(0); duke@435: default: duke@435: VM_JAVA_ERROR(vmSymbols::java_lang_InternalError(), "undefined opcode"); duke@435: } duke@435: } duke@435: duke@435: duke@435: #undef OPC_STORE_n duke@435: #define OPC_STORE_n(num) \ duke@435: CASE(_astore_##num): \ duke@435: astore(topOfStack, -1, locals, num); \ duke@435: UPDATE_PC_AND_TOS_AND_CONTINUE(1, -1); \ duke@435: CASE(_istore_##num): \ duke@435: CASE(_fstore_##num): \ duke@435: SET_LOCALS_SLOT(STACK_SLOT(-1), num); \ duke@435: UPDATE_PC_AND_TOS_AND_CONTINUE(1, -1); duke@435: duke@435: OPC_STORE_n(0); duke@435: OPC_STORE_n(1); duke@435: OPC_STORE_n(2); duke@435: OPC_STORE_n(3); duke@435: duke@435: #undef OPC_DSTORE_n duke@435: #define OPC_DSTORE_n(num) \ duke@435: CASE(_dstore_##num): \ duke@435: SET_LOCALS_DOUBLE(STACK_DOUBLE(-1), num); \ duke@435: UPDATE_PC_AND_TOS_AND_CONTINUE(1, -2); \ duke@435: CASE(_lstore_##num): \ duke@435: SET_LOCALS_LONG(STACK_LONG(-1), num); \ duke@435: UPDATE_PC_AND_TOS_AND_CONTINUE(1, -2); duke@435: duke@435: OPC_DSTORE_n(0); duke@435: OPC_DSTORE_n(1); duke@435: OPC_DSTORE_n(2); duke@435: OPC_DSTORE_n(3); duke@435: duke@435: /* stack pop, dup, and insert opcodes */ duke@435: duke@435: duke@435: CASE(_pop): /* Discard the top item on the stack */ duke@435: UPDATE_PC_AND_TOS_AND_CONTINUE(1, -1); duke@435: duke@435: duke@435: CASE(_pop2): /* Discard the top 2 items on the stack */ duke@435: UPDATE_PC_AND_TOS_AND_CONTINUE(1, -2); duke@435: duke@435: duke@435: CASE(_dup): /* Duplicate the top item on the stack */ duke@435: dup(topOfStack); duke@435: UPDATE_PC_AND_TOS_AND_CONTINUE(1, 1); duke@435: duke@435: CASE(_dup2): /* Duplicate the top 2 items on the stack */ duke@435: dup2(topOfStack); duke@435: UPDATE_PC_AND_TOS_AND_CONTINUE(1, 2); duke@435: duke@435: CASE(_dup_x1): /* insert top word two down */ duke@435: dup_x1(topOfStack); duke@435: UPDATE_PC_AND_TOS_AND_CONTINUE(1, 1); duke@435: duke@435: CASE(_dup_x2): /* insert top word three down */ duke@435: dup_x2(topOfStack); duke@435: UPDATE_PC_AND_TOS_AND_CONTINUE(1, 1); duke@435: duke@435: CASE(_dup2_x1): /* insert top 2 slots three down */ duke@435: dup2_x1(topOfStack); duke@435: UPDATE_PC_AND_TOS_AND_CONTINUE(1, 2); duke@435: duke@435: CASE(_dup2_x2): /* insert top 2 slots four down */ duke@435: dup2_x2(topOfStack); duke@435: UPDATE_PC_AND_TOS_AND_CONTINUE(1, 2); duke@435: duke@435: CASE(_swap): { /* swap top two elements on the stack */ duke@435: swap(topOfStack); duke@435: UPDATE_PC_AND_CONTINUE(1); duke@435: } duke@435: duke@435: /* Perform various binary integer operations */ duke@435: duke@435: #undef OPC_INT_BINARY duke@435: #define OPC_INT_BINARY(opcname, opname, test) \ duke@435: CASE(_i##opcname): \ duke@435: if (test && (STACK_INT(-1) == 0)) { \ duke@435: VM_JAVA_ERROR(vmSymbols::java_lang_ArithmeticException(), \ duke@435: "/ by int zero"); \ duke@435: } \ duke@435: SET_STACK_INT(VMint##opname(STACK_INT(-2), \ duke@435: STACK_INT(-1)), \ duke@435: -2); \ duke@435: UPDATE_PC_AND_TOS_AND_CONTINUE(1, -1); \ duke@435: CASE(_l##opcname): \ duke@435: { \ duke@435: if (test) { \ duke@435: jlong l1 = STACK_LONG(-1); \ duke@435: if (VMlongEqz(l1)) { \ duke@435: VM_JAVA_ERROR(vmSymbols::java_lang_ArithmeticException(), \ duke@435: "/ by long zero"); \ duke@435: } \ duke@435: } \ duke@435: /* First long at (-1,-2) next long at (-3,-4) */ \ duke@435: SET_STACK_LONG(VMlong##opname(STACK_LONG(-3), \ duke@435: STACK_LONG(-1)), \ duke@435: -3); \ duke@435: UPDATE_PC_AND_TOS_AND_CONTINUE(1, -2); \ duke@435: } duke@435: duke@435: OPC_INT_BINARY(add, Add, 0); duke@435: OPC_INT_BINARY(sub, Sub, 0); duke@435: OPC_INT_BINARY(mul, Mul, 0); duke@435: OPC_INT_BINARY(and, And, 0); duke@435: OPC_INT_BINARY(or, Or, 0); duke@435: OPC_INT_BINARY(xor, Xor, 0); duke@435: OPC_INT_BINARY(div, Div, 1); duke@435: OPC_INT_BINARY(rem, Rem, 1); duke@435: duke@435: duke@435: /* Perform various binary floating number operations */ duke@435: /* On some machine/platforms/compilers div zero check can be implicit */ duke@435: duke@435: #undef OPC_FLOAT_BINARY duke@435: #define OPC_FLOAT_BINARY(opcname, opname) \ duke@435: CASE(_d##opcname): { \ duke@435: SET_STACK_DOUBLE(VMdouble##opname(STACK_DOUBLE(-3), \ duke@435: STACK_DOUBLE(-1)), \ duke@435: -3); \ duke@435: UPDATE_PC_AND_TOS_AND_CONTINUE(1, -2); \ duke@435: } \ duke@435: CASE(_f##opcname): \ duke@435: SET_STACK_FLOAT(VMfloat##opname(STACK_FLOAT(-2), \ duke@435: STACK_FLOAT(-1)), \ duke@435: -2); \ duke@435: UPDATE_PC_AND_TOS_AND_CONTINUE(1, -1); duke@435: duke@435: duke@435: OPC_FLOAT_BINARY(add, Add); duke@435: OPC_FLOAT_BINARY(sub, Sub); duke@435: OPC_FLOAT_BINARY(mul, Mul); duke@435: OPC_FLOAT_BINARY(div, Div); duke@435: OPC_FLOAT_BINARY(rem, Rem); duke@435: duke@435: /* Shift operations duke@435: * Shift left int and long: ishl, lshl duke@435: * Logical shift right int and long w/zero extension: iushr, lushr duke@435: * Arithmetic shift right int and long w/sign extension: ishr, lshr duke@435: */ duke@435: duke@435: #undef OPC_SHIFT_BINARY duke@435: #define OPC_SHIFT_BINARY(opcname, opname) \ duke@435: CASE(_i##opcname): \ duke@435: SET_STACK_INT(VMint##opname(STACK_INT(-2), \ duke@435: STACK_INT(-1)), \ duke@435: -2); \ duke@435: UPDATE_PC_AND_TOS_AND_CONTINUE(1, -1); \ duke@435: CASE(_l##opcname): \ duke@435: { \ duke@435: SET_STACK_LONG(VMlong##opname(STACK_LONG(-2), \ duke@435: STACK_INT(-1)), \ duke@435: -2); \ duke@435: UPDATE_PC_AND_TOS_AND_CONTINUE(1, -1); \ duke@435: } duke@435: duke@435: OPC_SHIFT_BINARY(shl, Shl); duke@435: OPC_SHIFT_BINARY(shr, Shr); duke@435: OPC_SHIFT_BINARY(ushr, Ushr); duke@435: duke@435: /* Increment local variable by constant */ duke@435: CASE(_iinc): duke@435: { duke@435: // locals[pc[1]].j.i += (jbyte)(pc[2]); duke@435: SET_LOCALS_INT(LOCALS_INT(pc[1]) + (jbyte)(pc[2]), pc[1]); duke@435: UPDATE_PC_AND_CONTINUE(3); duke@435: } duke@435: duke@435: /* negate the value on the top of the stack */ duke@435: duke@435: CASE(_ineg): duke@435: SET_STACK_INT(VMintNeg(STACK_INT(-1)), -1); duke@435: UPDATE_PC_AND_CONTINUE(1); duke@435: duke@435: CASE(_fneg): duke@435: SET_STACK_FLOAT(VMfloatNeg(STACK_FLOAT(-1)), -1); duke@435: UPDATE_PC_AND_CONTINUE(1); duke@435: duke@435: CASE(_lneg): duke@435: { duke@435: SET_STACK_LONG(VMlongNeg(STACK_LONG(-1)), -1); duke@435: UPDATE_PC_AND_CONTINUE(1); duke@435: } duke@435: duke@435: CASE(_dneg): duke@435: { duke@435: SET_STACK_DOUBLE(VMdoubleNeg(STACK_DOUBLE(-1)), -1); duke@435: UPDATE_PC_AND_CONTINUE(1); duke@435: } duke@435: duke@435: /* Conversion operations */ duke@435: duke@435: CASE(_i2f): /* convert top of stack int to float */ duke@435: SET_STACK_FLOAT(VMint2Float(STACK_INT(-1)), -1); duke@435: UPDATE_PC_AND_CONTINUE(1); duke@435: duke@435: CASE(_i2l): /* convert top of stack int to long */ duke@435: { duke@435: // this is ugly QQQ duke@435: jlong r = VMint2Long(STACK_INT(-1)); duke@435: MORE_STACK(-1); // Pop duke@435: SET_STACK_LONG(r, 1); duke@435: duke@435: UPDATE_PC_AND_TOS_AND_CONTINUE(1, 2); duke@435: } duke@435: duke@435: CASE(_i2d): /* convert top of stack int to double */ duke@435: { duke@435: // this is ugly QQQ (why cast to jlong?? ) duke@435: jdouble r = (jlong)STACK_INT(-1); duke@435: MORE_STACK(-1); // Pop duke@435: SET_STACK_DOUBLE(r, 1); duke@435: duke@435: UPDATE_PC_AND_TOS_AND_CONTINUE(1, 2); duke@435: } duke@435: duke@435: CASE(_l2i): /* convert top of stack long to int */ duke@435: { duke@435: jint r = VMlong2Int(STACK_LONG(-1)); duke@435: MORE_STACK(-2); // Pop duke@435: SET_STACK_INT(r, 0); duke@435: UPDATE_PC_AND_TOS_AND_CONTINUE(1, 1); duke@435: } duke@435: duke@435: CASE(_l2f): /* convert top of stack long to float */ duke@435: { duke@435: jlong r = STACK_LONG(-1); duke@435: MORE_STACK(-2); // Pop duke@435: SET_STACK_FLOAT(VMlong2Float(r), 0); duke@435: UPDATE_PC_AND_TOS_AND_CONTINUE(1, 1); duke@435: } duke@435: duke@435: CASE(_l2d): /* convert top of stack long to double */ duke@435: { duke@435: jlong r = STACK_LONG(-1); duke@435: MORE_STACK(-2); // Pop duke@435: SET_STACK_DOUBLE(VMlong2Double(r), 1); duke@435: UPDATE_PC_AND_TOS_AND_CONTINUE(1, 2); duke@435: } duke@435: duke@435: CASE(_f2i): /* Convert top of stack float to int */ duke@435: SET_STACK_INT(SharedRuntime::f2i(STACK_FLOAT(-1)), -1); duke@435: UPDATE_PC_AND_CONTINUE(1); duke@435: duke@435: CASE(_f2l): /* convert top of stack float to long */ duke@435: { duke@435: jlong r = SharedRuntime::f2l(STACK_FLOAT(-1)); duke@435: MORE_STACK(-1); // POP duke@435: SET_STACK_LONG(r, 1); duke@435: UPDATE_PC_AND_TOS_AND_CONTINUE(1, 2); duke@435: } duke@435: duke@435: CASE(_f2d): /* convert top of stack float to double */ duke@435: { duke@435: jfloat f; duke@435: jdouble r; duke@435: f = STACK_FLOAT(-1); duke@435: #ifdef IA64 duke@435: // IA64 gcc bug duke@435: r = ( f == 0.0f ) ? (jdouble) f : (jdouble) f + ia64_double_zero; duke@435: #else duke@435: r = (jdouble) f; duke@435: #endif duke@435: MORE_STACK(-1); // POP duke@435: SET_STACK_DOUBLE(r, 1); duke@435: UPDATE_PC_AND_TOS_AND_CONTINUE(1, 2); duke@435: } duke@435: duke@435: CASE(_d2i): /* convert top of stack double to int */ duke@435: { duke@435: jint r1 = SharedRuntime::d2i(STACK_DOUBLE(-1)); duke@435: MORE_STACK(-2); duke@435: SET_STACK_INT(r1, 0); duke@435: UPDATE_PC_AND_TOS_AND_CONTINUE(1, 1); duke@435: } duke@435: duke@435: CASE(_d2f): /* convert top of stack double to float */ duke@435: { duke@435: jfloat r1 = VMdouble2Float(STACK_DOUBLE(-1)); duke@435: MORE_STACK(-2); duke@435: SET_STACK_FLOAT(r1, 0); duke@435: UPDATE_PC_AND_TOS_AND_CONTINUE(1, 1); duke@435: } duke@435: duke@435: CASE(_d2l): /* convert top of stack double to long */ duke@435: { duke@435: jlong r1 = SharedRuntime::d2l(STACK_DOUBLE(-1)); duke@435: MORE_STACK(-2); duke@435: SET_STACK_LONG(r1, 1); duke@435: UPDATE_PC_AND_TOS_AND_CONTINUE(1, 2); duke@435: } duke@435: duke@435: CASE(_i2b): duke@435: SET_STACK_INT(VMint2Byte(STACK_INT(-1)), -1); duke@435: UPDATE_PC_AND_CONTINUE(1); duke@435: duke@435: CASE(_i2c): duke@435: SET_STACK_INT(VMint2Char(STACK_INT(-1)), -1); duke@435: UPDATE_PC_AND_CONTINUE(1); duke@435: duke@435: CASE(_i2s): duke@435: SET_STACK_INT(VMint2Short(STACK_INT(-1)), -1); duke@435: UPDATE_PC_AND_CONTINUE(1); duke@435: duke@435: /* comparison operators */ duke@435: duke@435: duke@435: #define COMPARISON_OP(name, comparison) \ duke@435: CASE(_if_icmp##name): { \ duke@435: int skip = (STACK_INT(-2) comparison STACK_INT(-1)) \ duke@435: ? (int16_t)Bytes::get_Java_u2(pc + 1) : 3; \ duke@435: address branch_pc = pc; \ duke@435: UPDATE_PC_AND_TOS(skip, -2); \ duke@435: DO_BACKEDGE_CHECKS(skip, branch_pc); \ duke@435: CONTINUE; \ duke@435: } \ duke@435: CASE(_if##name): { \ duke@435: int skip = (STACK_INT(-1) comparison 0) \ duke@435: ? (int16_t)Bytes::get_Java_u2(pc + 1) : 3; \ duke@435: address branch_pc = pc; \ duke@435: UPDATE_PC_AND_TOS(skip, -1); \ duke@435: DO_BACKEDGE_CHECKS(skip, branch_pc); \ duke@435: CONTINUE; \ duke@435: } duke@435: duke@435: #define COMPARISON_OP2(name, comparison) \ duke@435: COMPARISON_OP(name, comparison) \ duke@435: CASE(_if_acmp##name): { \ duke@435: int skip = (STACK_OBJECT(-2) comparison STACK_OBJECT(-1)) \ duke@435: ? (int16_t)Bytes::get_Java_u2(pc + 1) : 3; \ duke@435: address branch_pc = pc; \ duke@435: UPDATE_PC_AND_TOS(skip, -2); \ duke@435: DO_BACKEDGE_CHECKS(skip, branch_pc); \ duke@435: CONTINUE; \ duke@435: } duke@435: duke@435: #define NULL_COMPARISON_NOT_OP(name) \ duke@435: CASE(_if##name): { \ duke@435: int skip = (!(STACK_OBJECT(-1) == 0)) \ duke@435: ? (int16_t)Bytes::get_Java_u2(pc + 1) : 3; \ duke@435: address branch_pc = pc; \ duke@435: UPDATE_PC_AND_TOS(skip, -1); \ duke@435: DO_BACKEDGE_CHECKS(skip, branch_pc); \ duke@435: CONTINUE; \ duke@435: } duke@435: duke@435: #define NULL_COMPARISON_OP(name) \ duke@435: CASE(_if##name): { \ duke@435: int skip = ((STACK_OBJECT(-1) == 0)) \ duke@435: ? (int16_t)Bytes::get_Java_u2(pc + 1) : 3; \ duke@435: address branch_pc = pc; \ duke@435: UPDATE_PC_AND_TOS(skip, -1); \ duke@435: DO_BACKEDGE_CHECKS(skip, branch_pc); \ duke@435: CONTINUE; \ duke@435: } duke@435: COMPARISON_OP(lt, <); duke@435: COMPARISON_OP(gt, >); duke@435: COMPARISON_OP(le, <=); duke@435: COMPARISON_OP(ge, >=); duke@435: COMPARISON_OP2(eq, ==); /* include ref comparison */ duke@435: COMPARISON_OP2(ne, !=); /* include ref comparison */ duke@435: NULL_COMPARISON_OP(null); duke@435: NULL_COMPARISON_NOT_OP(nonnull); duke@435: duke@435: /* Goto pc at specified offset in switch table. */ duke@435: duke@435: CASE(_tableswitch): { duke@435: jint* lpc = (jint*)VMalignWordUp(pc+1); duke@435: int32_t key = STACK_INT(-1); duke@435: int32_t low = Bytes::get_Java_u4((address)&lpc[1]); duke@435: int32_t high = Bytes::get_Java_u4((address)&lpc[2]); duke@435: int32_t skip; duke@435: key -= low; duke@435: skip = ((uint32_t) key > (uint32_t)(high - low)) duke@435: ? Bytes::get_Java_u4((address)&lpc[0]) duke@435: : Bytes::get_Java_u4((address)&lpc[key + 3]); duke@435: // Does this really need a full backedge check (osr?) duke@435: address branch_pc = pc; duke@435: UPDATE_PC_AND_TOS(skip, -1); duke@435: DO_BACKEDGE_CHECKS(skip, branch_pc); duke@435: CONTINUE; duke@435: } duke@435: duke@435: /* Goto pc whose table entry matches specified key */ duke@435: duke@435: CASE(_lookupswitch): { duke@435: jint* lpc = (jint*)VMalignWordUp(pc+1); duke@435: int32_t key = STACK_INT(-1); duke@435: int32_t skip = Bytes::get_Java_u4((address) lpc); /* default amount */ duke@435: int32_t npairs = Bytes::get_Java_u4((address) &lpc[1]); duke@435: while (--npairs >= 0) { duke@435: lpc += 2; duke@435: if (key == (int32_t)Bytes::get_Java_u4((address)lpc)) { duke@435: skip = Bytes::get_Java_u4((address)&lpc[1]); duke@435: break; duke@435: } duke@435: } duke@435: address branch_pc = pc; duke@435: UPDATE_PC_AND_TOS(skip, -1); duke@435: DO_BACKEDGE_CHECKS(skip, branch_pc); duke@435: CONTINUE; duke@435: } duke@435: duke@435: CASE(_fcmpl): duke@435: CASE(_fcmpg): duke@435: { duke@435: SET_STACK_INT(VMfloatCompare(STACK_FLOAT(-2), duke@435: STACK_FLOAT(-1), duke@435: (opcode == Bytecodes::_fcmpl ? -1 : 1)), duke@435: -2); duke@435: UPDATE_PC_AND_TOS_AND_CONTINUE(1, -1); duke@435: } duke@435: duke@435: CASE(_dcmpl): duke@435: CASE(_dcmpg): duke@435: { duke@435: int r = VMdoubleCompare(STACK_DOUBLE(-3), duke@435: STACK_DOUBLE(-1), duke@435: (opcode == Bytecodes::_dcmpl ? -1 : 1)); duke@435: MORE_STACK(-4); // Pop duke@435: SET_STACK_INT(r, 0); duke@435: UPDATE_PC_AND_TOS_AND_CONTINUE(1, 1); duke@435: } duke@435: duke@435: CASE(_lcmp): duke@435: { duke@435: int r = VMlongCompare(STACK_LONG(-3), STACK_LONG(-1)); duke@435: MORE_STACK(-4); duke@435: SET_STACK_INT(r, 0); duke@435: UPDATE_PC_AND_TOS_AND_CONTINUE(1, 1); duke@435: } duke@435: duke@435: duke@435: /* Return from a method */ duke@435: duke@435: CASE(_areturn): duke@435: CASE(_ireturn): duke@435: CASE(_freturn): duke@435: { duke@435: // Allow a safepoint before returning to frame manager. duke@435: SAFEPOINT; duke@435: duke@435: goto handle_return; duke@435: } duke@435: duke@435: CASE(_lreturn): duke@435: CASE(_dreturn): duke@435: { duke@435: // Allow a safepoint before returning to frame manager. duke@435: SAFEPOINT; duke@435: goto handle_return; duke@435: } duke@435: duke@435: CASE(_return_register_finalizer): { duke@435: duke@435: oop rcvr = LOCALS_OBJECT(0); duke@435: if (rcvr->klass()->klass_part()->has_finalizer()) { duke@435: CALL_VM(InterpreterRuntime::register_finalizer(THREAD, rcvr), handle_exception); duke@435: } duke@435: goto handle_return; duke@435: } duke@435: CASE(_return): { duke@435: duke@435: // Allow a safepoint before returning to frame manager. duke@435: SAFEPOINT; duke@435: goto handle_return; duke@435: } duke@435: duke@435: /* Array access byte-codes */ duke@435: duke@435: /* Every array access byte-code starts out like this */ duke@435: // arrayOopDesc* arrObj = (arrayOopDesc*)STACK_OBJECT(arrayOff); duke@435: #define ARRAY_INTRO(arrayOff) \ duke@435: arrayOop arrObj = (arrayOop)STACK_OBJECT(arrayOff); \ duke@435: jint index = STACK_INT(arrayOff + 1); \ duke@435: char message[jintAsStringSize]; \ duke@435: CHECK_NULL(arrObj); \ duke@435: if ((uint32_t)index >= (uint32_t)arrObj->length()) { \ duke@435: sprintf(message, "%d", index); \ duke@435: VM_JAVA_ERROR(vmSymbols::java_lang_ArrayIndexOutOfBoundsException(), \ duke@435: message); \ duke@435: } duke@435: duke@435: /* 32-bit loads. These handle conversion from < 32-bit types */ duke@435: #define ARRAY_LOADTO32(T, T2, format, stackRes, extra) \ duke@435: { \ duke@435: ARRAY_INTRO(-2); \ duke@435: extra; \ duke@435: SET_ ## stackRes(*(T2 *)(((address) arrObj->base(T)) + index * sizeof(T2)), \ duke@435: -2); \ duke@435: UPDATE_PC_AND_TOS_AND_CONTINUE(1, -1); \ duke@435: } duke@435: duke@435: /* 64-bit loads */ duke@435: #define ARRAY_LOADTO64(T,T2, stackRes, extra) \ duke@435: { \ duke@435: ARRAY_INTRO(-2); \ duke@435: SET_ ## stackRes(*(T2 *)(((address) arrObj->base(T)) + index * sizeof(T2)), -1); \ duke@435: extra; \ duke@435: UPDATE_PC_AND_CONTINUE(1); \ duke@435: } duke@435: duke@435: CASE(_iaload): duke@435: ARRAY_LOADTO32(T_INT, jint, "%d", STACK_INT, 0); duke@435: CASE(_faload): duke@435: ARRAY_LOADTO32(T_FLOAT, jfloat, "%f", STACK_FLOAT, 0); duke@435: CASE(_aaload): duke@435: ARRAY_LOADTO32(T_OBJECT, oop, INTPTR_FORMAT, STACK_OBJECT, 0); duke@435: CASE(_baload): duke@435: ARRAY_LOADTO32(T_BYTE, jbyte, "%d", STACK_INT, 0); duke@435: CASE(_caload): duke@435: ARRAY_LOADTO32(T_CHAR, jchar, "%d", STACK_INT, 0); duke@435: CASE(_saload): duke@435: ARRAY_LOADTO32(T_SHORT, jshort, "%d", STACK_INT, 0); duke@435: CASE(_laload): duke@435: ARRAY_LOADTO64(T_LONG, jlong, STACK_LONG, 0); duke@435: CASE(_daload): duke@435: ARRAY_LOADTO64(T_DOUBLE, jdouble, STACK_DOUBLE, 0); duke@435: duke@435: /* 32-bit stores. These handle conversion to < 32-bit types */ duke@435: #define ARRAY_STOREFROM32(T, T2, format, stackSrc, extra) \ duke@435: { \ duke@435: ARRAY_INTRO(-3); \ duke@435: extra; \ duke@435: *(T2 *)(((address) arrObj->base(T)) + index * sizeof(T2)) = stackSrc( -1); \ duke@435: UPDATE_PC_AND_TOS_AND_CONTINUE(1, -3); \ duke@435: } duke@435: duke@435: /* 64-bit stores */ duke@435: #define ARRAY_STOREFROM64(T, T2, stackSrc, extra) \ duke@435: { \ duke@435: ARRAY_INTRO(-4); \ duke@435: extra; \ duke@435: *(T2 *)(((address) arrObj->base(T)) + index * sizeof(T2)) = stackSrc( -1); \ duke@435: UPDATE_PC_AND_TOS_AND_CONTINUE(1, -4); \ duke@435: } duke@435: duke@435: CASE(_iastore): duke@435: ARRAY_STOREFROM32(T_INT, jint, "%d", STACK_INT, 0); duke@435: CASE(_fastore): duke@435: ARRAY_STOREFROM32(T_FLOAT, jfloat, "%f", STACK_FLOAT, 0); duke@435: /* duke@435: * This one looks different because of the assignability check duke@435: */ duke@435: CASE(_aastore): { duke@435: oop rhsObject = STACK_OBJECT(-1); duke@435: ARRAY_INTRO( -3); duke@435: // arrObj, index are set duke@435: if (rhsObject != NULL) { duke@435: /* Check assignability of rhsObject into arrObj */ duke@435: klassOop rhsKlassOop = rhsObject->klass(); // EBX (subclass) duke@435: assert(arrObj->klass()->klass()->klass_part()->oop_is_objArrayKlass(), "Ack not an objArrayKlass"); duke@435: klassOop elemKlassOop = ((objArrayKlass*) arrObj->klass()->klass_part())->element_klass(); // superklass EAX duke@435: // duke@435: // Check for compatibilty. This check must not GC!! duke@435: // Seems way more expensive now that we must dispatch duke@435: // duke@435: if (rhsKlassOop != elemKlassOop && !rhsKlassOop->klass_part()->is_subtype_of(elemKlassOop)) { // ebx->is... duke@435: VM_JAVA_ERROR(vmSymbols::java_lang_ArrayStoreException(), ""); duke@435: } duke@435: } duke@435: oop* elem_loc = (oop*)(((address) arrObj->base(T_OBJECT)) + index * sizeof(oop)); duke@435: // *(oop*)(((address) arrObj->base(T_OBJECT)) + index * sizeof(oop)) = rhsObject; duke@435: *elem_loc = rhsObject; duke@435: // Mark the card duke@435: OrderAccess::release_store(&BYTE_MAP_BASE[(uintptr_t)elem_loc >> CardTableModRefBS::card_shift], 0); duke@435: UPDATE_PC_AND_TOS_AND_CONTINUE(1, -3); duke@435: } duke@435: CASE(_bastore): duke@435: ARRAY_STOREFROM32(T_BYTE, jbyte, "%d", STACK_INT, 0); duke@435: CASE(_castore): duke@435: ARRAY_STOREFROM32(T_CHAR, jchar, "%d", STACK_INT, 0); duke@435: CASE(_sastore): duke@435: ARRAY_STOREFROM32(T_SHORT, jshort, "%d", STACK_INT, 0); duke@435: CASE(_lastore): duke@435: ARRAY_STOREFROM64(T_LONG, jlong, STACK_LONG, 0); duke@435: CASE(_dastore): duke@435: ARRAY_STOREFROM64(T_DOUBLE, jdouble, STACK_DOUBLE, 0); duke@435: duke@435: CASE(_arraylength): duke@435: { duke@435: arrayOop ary = (arrayOop) STACK_OBJECT(-1); duke@435: CHECK_NULL(ary); duke@435: SET_STACK_INT(ary->length(), -1); duke@435: UPDATE_PC_AND_CONTINUE(1); duke@435: } duke@435: duke@435: /* monitorenter and monitorexit for locking/unlocking an object */ duke@435: duke@435: CASE(_monitorenter): { duke@435: oop lockee = STACK_OBJECT(-1); duke@435: // derefing's lockee ought to provoke implicit null check duke@435: CHECK_NULL(lockee); duke@435: // find a free monitor or one already allocated for this object duke@435: // if we find a matching object then we need a new monitor duke@435: // since this is recursive enter duke@435: BasicObjectLock* limit = istate->monitor_base(); duke@435: BasicObjectLock* most_recent = (BasicObjectLock*) istate->stack_base(); duke@435: BasicObjectLock* entry = NULL; duke@435: while (most_recent != limit ) { duke@435: if (most_recent->obj() == NULL) entry = most_recent; duke@435: else if (most_recent->obj() == lockee) break; duke@435: most_recent++; duke@435: } duke@435: if (entry != NULL) { duke@435: entry->set_obj(lockee); duke@435: markOop displaced = lockee->mark()->set_unlocked(); duke@435: entry->lock()->set_displaced_header(displaced); duke@435: if (Atomic::cmpxchg_ptr(entry, lockee->mark_addr(), displaced) != displaced) { duke@435: // Is it simple recursive case? duke@435: if (THREAD->is_lock_owned((address) displaced->clear_lock_bits())) { duke@435: entry->lock()->set_displaced_header(NULL); duke@435: } else { duke@435: CALL_VM(InterpreterRuntime::monitorenter(THREAD, entry), handle_exception); duke@435: } duke@435: } duke@435: UPDATE_PC_AND_TOS_AND_CONTINUE(1, -1); duke@435: } else { duke@435: istate->set_msg(more_monitors); duke@435: UPDATE_PC_AND_RETURN(0); // Re-execute duke@435: } duke@435: } duke@435: duke@435: CASE(_monitorexit): { duke@435: oop lockee = STACK_OBJECT(-1); duke@435: CHECK_NULL(lockee); duke@435: // derefing's lockee ought to provoke implicit null check duke@435: // find our monitor slot duke@435: BasicObjectLock* limit = istate->monitor_base(); duke@435: BasicObjectLock* most_recent = (BasicObjectLock*) istate->stack_base(); duke@435: while (most_recent != limit ) { duke@435: if ((most_recent)->obj() == lockee) { duke@435: BasicLock* lock = most_recent->lock(); duke@435: markOop header = lock->displaced_header(); duke@435: most_recent->set_obj(NULL); duke@435: // If it isn't recursive we either must swap old header or call the runtime duke@435: if (header != NULL) { duke@435: if (Atomic::cmpxchg_ptr(header, lockee->mark_addr(), lock) != lock) { duke@435: // restore object for the slow case duke@435: most_recent->set_obj(lockee); duke@435: CALL_VM(InterpreterRuntime::monitorexit(THREAD, most_recent), handle_exception); duke@435: } duke@435: } duke@435: UPDATE_PC_AND_TOS_AND_CONTINUE(1, -1); duke@435: } duke@435: most_recent++; duke@435: } duke@435: // Need to throw illegal monitor state exception duke@435: CALL_VM(InterpreterRuntime::throw_illegal_monitor_state_exception(THREAD), handle_exception); duke@435: // Should never reach here... duke@435: assert(false, "Should have thrown illegal monitor exception"); duke@435: } duke@435: duke@435: /* All of the non-quick opcodes. */ duke@435: duke@435: /* -Set clobbersCpIndex true if the quickened opcode clobbers the duke@435: * constant pool index in the instruction. duke@435: */ duke@435: CASE(_getfield): duke@435: CASE(_getstatic): duke@435: { duke@435: u2 index; duke@435: ConstantPoolCacheEntry* cache; duke@435: index = Bytes::get_native_u2(pc+1); duke@435: duke@435: // QQQ Need to make this as inlined as possible. Probably need to duke@435: // split all the bytecode cases out so c++ compiler has a chance duke@435: // for constant prop to fold everything possible away. duke@435: duke@435: cache = cp->entry_at(index); duke@435: if (!cache->is_resolved((Bytecodes::Code)opcode)) { duke@435: CALL_VM(InterpreterRuntime::resolve_get_put(THREAD, (Bytecodes::Code)opcode), duke@435: handle_exception); duke@435: cache = cp->entry_at(index); duke@435: } duke@435: duke@435: #ifdef VM_JVMTI duke@435: if (_jvmti_interp_events) { duke@435: int *count_addr; duke@435: oop obj; duke@435: // Check to see if a field modification watch has been set duke@435: // before we take the time to call into the VM. duke@435: count_addr = (int *)JvmtiExport::get_field_access_count_addr(); duke@435: if ( *count_addr > 0 ) { duke@435: if ((Bytecodes::Code)opcode == Bytecodes::_getstatic) { duke@435: obj = (oop)NULL; duke@435: } else { duke@435: obj = (oop) STACK_OBJECT(-1); duke@435: } duke@435: CALL_VM(InterpreterRuntime::post_field_access(THREAD, duke@435: obj, duke@435: cache), duke@435: handle_exception); duke@435: } duke@435: } duke@435: #endif /* VM_JVMTI */ duke@435: duke@435: oop obj; duke@435: if ((Bytecodes::Code)opcode == Bytecodes::_getstatic) { duke@435: obj = (oop) cache->f1(); duke@435: MORE_STACK(1); // Assume single slot push duke@435: } else { duke@435: obj = (oop) STACK_OBJECT(-1); duke@435: CHECK_NULL(obj); duke@435: } duke@435: duke@435: // duke@435: // Now store the result on the stack duke@435: // duke@435: TosState tos_type = cache->flag_state(); duke@435: int field_offset = cache->f2(); duke@435: if (cache->is_volatile()) { duke@435: if (tos_type == atos) { duke@435: SET_STACK_OBJECT(obj->obj_field_acquire(field_offset), -1); duke@435: } else if (tos_type == itos) { duke@435: SET_STACK_INT(obj->int_field_acquire(field_offset), -1); duke@435: } else if (tos_type == ltos) { duke@435: SET_STACK_LONG(obj->long_field_acquire(field_offset), 0); duke@435: MORE_STACK(1); duke@435: } else if (tos_type == btos) { duke@435: SET_STACK_INT(obj->byte_field_acquire(field_offset), -1); duke@435: } else if (tos_type == ctos) { duke@435: SET_STACK_INT(obj->char_field_acquire(field_offset), -1); duke@435: } else if (tos_type == stos) { duke@435: SET_STACK_INT(obj->short_field_acquire(field_offset), -1); duke@435: } else if (tos_type == ftos) { duke@435: SET_STACK_FLOAT(obj->float_field_acquire(field_offset), -1); duke@435: } else { duke@435: SET_STACK_DOUBLE(obj->double_field_acquire(field_offset), 0); duke@435: MORE_STACK(1); duke@435: } duke@435: } else { duke@435: if (tos_type == atos) { duke@435: SET_STACK_OBJECT(obj->obj_field(field_offset), -1); duke@435: } else if (tos_type == itos) { duke@435: SET_STACK_INT(obj->int_field(field_offset), -1); duke@435: } else if (tos_type == ltos) { duke@435: SET_STACK_LONG(obj->long_field(field_offset), 0); duke@435: MORE_STACK(1); duke@435: } else if (tos_type == btos) { duke@435: SET_STACK_INT(obj->byte_field(field_offset), -1); duke@435: } else if (tos_type == ctos) { duke@435: SET_STACK_INT(obj->char_field(field_offset), -1); duke@435: } else if (tos_type == stos) { duke@435: SET_STACK_INT(obj->short_field(field_offset), -1); duke@435: } else if (tos_type == ftos) { duke@435: SET_STACK_FLOAT(obj->float_field(field_offset), -1); duke@435: } else { duke@435: SET_STACK_DOUBLE(obj->double_field(field_offset), 0); duke@435: MORE_STACK(1); duke@435: } duke@435: } duke@435: duke@435: UPDATE_PC_AND_CONTINUE(3); duke@435: } duke@435: duke@435: CASE(_putfield): duke@435: CASE(_putstatic): duke@435: { duke@435: u2 index = Bytes::get_native_u2(pc+1); duke@435: ConstantPoolCacheEntry* cache = cp->entry_at(index); duke@435: if (!cache->is_resolved((Bytecodes::Code)opcode)) { duke@435: CALL_VM(InterpreterRuntime::resolve_get_put(THREAD, (Bytecodes::Code)opcode), duke@435: handle_exception); duke@435: cache = cp->entry_at(index); duke@435: } duke@435: duke@435: #ifdef VM_JVMTI duke@435: if (_jvmti_interp_events) { duke@435: int *count_addr; duke@435: oop obj; duke@435: // Check to see if a field modification watch has been set duke@435: // before we take the time to call into the VM. duke@435: count_addr = (int *)JvmtiExport::get_field_modification_count_addr(); duke@435: if ( *count_addr > 0 ) { duke@435: if ((Bytecodes::Code)opcode == Bytecodes::_putstatic) { duke@435: obj = (oop)NULL; duke@435: } duke@435: else { duke@435: if (cache->is_long() || cache->is_double()) { duke@435: obj = (oop) STACK_OBJECT(-3); duke@435: } else { duke@435: obj = (oop) STACK_OBJECT(-2); duke@435: } duke@435: } duke@435: duke@435: CALL_VM(InterpreterRuntime::post_field_modification(THREAD, duke@435: obj, duke@435: cache, duke@435: (jvalue *)STACK_SLOT(-1)), duke@435: handle_exception); duke@435: } duke@435: } duke@435: #endif /* VM_JVMTI */ duke@435: duke@435: // QQQ Need to make this as inlined as possible. Probably need to split all the bytecode cases duke@435: // out so c++ compiler has a chance for constant prop to fold everything possible away. duke@435: duke@435: oop obj; duke@435: int count; duke@435: TosState tos_type = cache->flag_state(); duke@435: duke@435: count = -1; duke@435: if (tos_type == ltos || tos_type == dtos) { duke@435: --count; duke@435: } duke@435: if ((Bytecodes::Code)opcode == Bytecodes::_putstatic) { duke@435: obj = (oop) cache->f1(); duke@435: } else { duke@435: --count; duke@435: obj = (oop) STACK_OBJECT(count); duke@435: CHECK_NULL(obj); duke@435: } duke@435: duke@435: // duke@435: // Now store the result duke@435: // duke@435: int field_offset = cache->f2(); duke@435: if (cache->is_volatile()) { duke@435: if (tos_type == itos) { duke@435: obj->release_int_field_put(field_offset, STACK_INT(-1)); duke@435: } else if (tos_type == atos) { duke@435: obj->release_obj_field_put(field_offset, STACK_OBJECT(-1)); duke@435: OrderAccess::release_store(&BYTE_MAP_BASE[(uintptr_t)obj >> CardTableModRefBS::card_shift], 0); duke@435: } else if (tos_type == btos) { duke@435: obj->release_byte_field_put(field_offset, STACK_INT(-1)); duke@435: } else if (tos_type == ltos) { duke@435: obj->release_long_field_put(field_offset, STACK_LONG(-1)); duke@435: } else if (tos_type == ctos) { duke@435: obj->release_char_field_put(field_offset, STACK_INT(-1)); duke@435: } else if (tos_type == stos) { duke@435: obj->release_short_field_put(field_offset, STACK_INT(-1)); duke@435: } else if (tos_type == ftos) { duke@435: obj->release_float_field_put(field_offset, STACK_FLOAT(-1)); duke@435: } else { duke@435: obj->release_double_field_put(field_offset, STACK_DOUBLE(-1)); duke@435: } duke@435: OrderAccess::storeload(); duke@435: } else { duke@435: if (tos_type == itos) { duke@435: obj->int_field_put(field_offset, STACK_INT(-1)); duke@435: } else if (tos_type == atos) { duke@435: obj->obj_field_put(field_offset, STACK_OBJECT(-1)); duke@435: OrderAccess::release_store(&BYTE_MAP_BASE[(uintptr_t)obj >> CardTableModRefBS::card_shift], 0); duke@435: } else if (tos_type == btos) { duke@435: obj->byte_field_put(field_offset, STACK_INT(-1)); duke@435: } else if (tos_type == ltos) { duke@435: obj->long_field_put(field_offset, STACK_LONG(-1)); duke@435: } else if (tos_type == ctos) { duke@435: obj->char_field_put(field_offset, STACK_INT(-1)); duke@435: } else if (tos_type == stos) { duke@435: obj->short_field_put(field_offset, STACK_INT(-1)); duke@435: } else if (tos_type == ftos) { duke@435: obj->float_field_put(field_offset, STACK_FLOAT(-1)); duke@435: } else { duke@435: obj->double_field_put(field_offset, STACK_DOUBLE(-1)); duke@435: } duke@435: } duke@435: duke@435: UPDATE_PC_AND_TOS_AND_CONTINUE(3, count); duke@435: } duke@435: duke@435: CASE(_new): { duke@435: u2 index = Bytes::get_Java_u2(pc+1); duke@435: constantPoolOop constants = istate->method()->constants(); duke@435: if (!constants->tag_at(index).is_unresolved_klass()) { duke@435: // Make sure klass is initialized and doesn't have a finalizer duke@435: oop entry = (klassOop) *constants->obj_at_addr(index); duke@435: assert(entry->is_klass(), "Should be resolved klass"); duke@435: klassOop k_entry = (klassOop) entry; duke@435: assert(k_entry->klass_part()->oop_is_instance(), "Should be instanceKlass"); duke@435: instanceKlass* ik = (instanceKlass*) k_entry->klass_part(); duke@435: if ( ik->is_initialized() && ik->can_be_fastpath_allocated() ) { duke@435: size_t obj_size = ik->size_helper(); duke@435: oop result = NULL; duke@435: // If the TLAB isn't pre-zeroed then we'll have to do it duke@435: bool need_zero = !ZeroTLAB; duke@435: if (UseTLAB) { duke@435: result = (oop) THREAD->tlab().allocate(obj_size); duke@435: } duke@435: if (result == NULL) { duke@435: need_zero = true; duke@435: // Try allocate in shared eden duke@435: retry: duke@435: HeapWord* compare_to = *Universe::heap()->top_addr(); duke@435: HeapWord* new_top = compare_to + obj_size; duke@435: if (new_top <= *Universe::heap()->end_addr()) { duke@435: if (Atomic::cmpxchg_ptr(new_top, Universe::heap()->top_addr(), compare_to) != compare_to) { duke@435: goto retry; duke@435: } duke@435: result = (oop) compare_to; duke@435: } duke@435: } duke@435: if (result != NULL) { duke@435: // Initialize object (if nonzero size and need) and then the header duke@435: if (need_zero ) { duke@435: HeapWord* to_zero = (HeapWord*) result + sizeof(oopDesc) / oopSize; duke@435: obj_size -= sizeof(oopDesc) / oopSize; duke@435: if (obj_size > 0 ) { duke@435: memset(to_zero, 0, obj_size * HeapWordSize); duke@435: } duke@435: } duke@435: if (UseBiasedLocking) { duke@435: result->set_mark(ik->prototype_header()); duke@435: } else { duke@435: result->set_mark(markOopDesc::prototype()); duke@435: } duke@435: result->set_klass(k_entry); duke@435: SET_STACK_OBJECT(result, 0); duke@435: UPDATE_PC_AND_TOS_AND_CONTINUE(3, 1); duke@435: } duke@435: } duke@435: } duke@435: // Slow case allocation duke@435: CALL_VM(InterpreterRuntime::_new(THREAD, METHOD->constants(), index), duke@435: handle_exception); duke@435: SET_STACK_OBJECT(THREAD->vm_result(), 0); duke@435: THREAD->set_vm_result(NULL); duke@435: UPDATE_PC_AND_TOS_AND_CONTINUE(3, 1); duke@435: } duke@435: CASE(_anewarray): { duke@435: u2 index = Bytes::get_Java_u2(pc+1); duke@435: jint size = STACK_INT(-1); duke@435: CALL_VM(InterpreterRuntime::anewarray(THREAD, METHOD->constants(), index, size), duke@435: handle_exception); duke@435: SET_STACK_OBJECT(THREAD->vm_result(), -1); duke@435: THREAD->set_vm_result(NULL); duke@435: UPDATE_PC_AND_CONTINUE(3); duke@435: } duke@435: CASE(_multianewarray): { duke@435: jint dims = *(pc+3); duke@435: jint size = STACK_INT(-1); duke@435: // stack grows down, dimensions are up! duke@435: jint *dimarray = duke@435: (jint*)&topOfStack[dims * Interpreter::stackElementWords()+ duke@435: Interpreter::stackElementWords()-1]; duke@435: //adjust pointer to start of stack element duke@435: CALL_VM(InterpreterRuntime::multianewarray(THREAD, dimarray), duke@435: handle_exception); duke@435: SET_STACK_OBJECT(THREAD->vm_result(), -dims); duke@435: THREAD->set_vm_result(NULL); duke@435: UPDATE_PC_AND_TOS_AND_CONTINUE(4, -(dims-1)); duke@435: } duke@435: CASE(_checkcast): duke@435: if (STACK_OBJECT(-1) != NULL) { duke@435: u2 index = Bytes::get_Java_u2(pc+1); duke@435: if (ProfileInterpreter) { duke@435: // needs Profile_checkcast QQQ duke@435: ShouldNotReachHere(); duke@435: } duke@435: // Constant pool may have actual klass or unresolved klass. If it is duke@435: // unresolved we must resolve it duke@435: if (METHOD->constants()->tag_at(index).is_unresolved_klass()) { duke@435: CALL_VM(InterpreterRuntime::quicken_io_cc(THREAD), handle_exception); duke@435: } duke@435: klassOop klassOf = (klassOop) *(METHOD->constants()->obj_at_addr(index)); duke@435: klassOop objKlassOop = STACK_OBJECT(-1)->klass(); //ebx duke@435: // duke@435: // Check for compatibilty. This check must not GC!! duke@435: // Seems way more expensive now that we must dispatch duke@435: // duke@435: if (objKlassOop != klassOf && duke@435: !objKlassOop->klass_part()->is_subtype_of(klassOf)) { duke@435: ResourceMark rm(THREAD); duke@435: const char* objName = Klass::cast(objKlassOop)->external_name(); duke@435: const char* klassName = Klass::cast(klassOf)->external_name(); duke@435: char* message = SharedRuntime::generate_class_cast_message( duke@435: objName, klassName); duke@435: VM_JAVA_ERROR(vmSymbols::java_lang_ClassCastException(), message); duke@435: } duke@435: } else { duke@435: if (UncommonNullCast) { duke@435: // istate->method()->set_null_cast_seen(); duke@435: // [RGV] Not sure what to do here! duke@435: duke@435: } duke@435: } duke@435: UPDATE_PC_AND_CONTINUE(3); duke@435: duke@435: CASE(_instanceof): duke@435: if (STACK_OBJECT(-1) == NULL) { duke@435: SET_STACK_INT(0, -1); duke@435: } else { duke@435: u2 index = Bytes::get_Java_u2(pc+1); duke@435: // Constant pool may have actual klass or unresolved klass. If it is duke@435: // unresolved we must resolve it duke@435: if (METHOD->constants()->tag_at(index).is_unresolved_klass()) { duke@435: CALL_VM(InterpreterRuntime::quicken_io_cc(THREAD), handle_exception); duke@435: } duke@435: klassOop klassOf = (klassOop) *(METHOD->constants()->obj_at_addr(index)); duke@435: klassOop objKlassOop = STACK_OBJECT(-1)->klass(); duke@435: // duke@435: // Check for compatibilty. This check must not GC!! duke@435: // Seems way more expensive now that we must dispatch duke@435: // duke@435: if ( objKlassOop == klassOf || objKlassOop->klass_part()->is_subtype_of(klassOf)) { duke@435: SET_STACK_INT(1, -1); duke@435: } else { duke@435: SET_STACK_INT(0, -1); duke@435: } duke@435: } duke@435: UPDATE_PC_AND_CONTINUE(3); duke@435: duke@435: CASE(_ldc_w): duke@435: CASE(_ldc): duke@435: { duke@435: u2 index; duke@435: bool wide = false; duke@435: int incr = 2; // frequent case duke@435: if (opcode == Bytecodes::_ldc) { duke@435: index = pc[1]; duke@435: } else { duke@435: index = Bytes::get_Java_u2(pc+1); duke@435: incr = 3; duke@435: wide = true; duke@435: } duke@435: duke@435: constantPoolOop constants = METHOD->constants(); duke@435: switch (constants->tag_at(index).value()) { duke@435: case JVM_CONSTANT_Integer: duke@435: SET_STACK_INT(constants->int_at(index), 0); duke@435: break; duke@435: duke@435: case JVM_CONSTANT_Float: duke@435: SET_STACK_FLOAT(constants->float_at(index), 0); duke@435: break; duke@435: duke@435: case JVM_CONSTANT_String: duke@435: SET_STACK_OBJECT(constants->resolved_string_at(index), 0); duke@435: break; duke@435: duke@435: case JVM_CONSTANT_Class: duke@435: SET_STACK_OBJECT(constants->resolved_klass_at(index)->klass_part()->java_mirror(), 0); duke@435: break; duke@435: duke@435: case JVM_CONSTANT_UnresolvedString: duke@435: case JVM_CONSTANT_UnresolvedClass: duke@435: case JVM_CONSTANT_UnresolvedClassInError: duke@435: CALL_VM(InterpreterRuntime::ldc(THREAD, wide), handle_exception); duke@435: SET_STACK_OBJECT(THREAD->vm_result(), 0); duke@435: THREAD->set_vm_result(NULL); duke@435: break; duke@435: duke@435: #if 0 duke@435: CASE(_fast_igetfield): duke@435: CASE(_fastagetfield): duke@435: CASE(_fast_aload_0): duke@435: CASE(_fast_iaccess_0): duke@435: CASE(__fast_aaccess_0): duke@435: CASE(_fast_linearswitch): duke@435: CASE(_fast_binaryswitch): duke@435: fatal("unsupported fast bytecode"); duke@435: #endif duke@435: duke@435: default: ShouldNotReachHere(); duke@435: } duke@435: UPDATE_PC_AND_TOS_AND_CONTINUE(incr, 1); duke@435: } duke@435: duke@435: CASE(_ldc2_w): duke@435: { duke@435: u2 index = Bytes::get_Java_u2(pc+1); duke@435: duke@435: constantPoolOop constants = METHOD->constants(); duke@435: switch (constants->tag_at(index).value()) { duke@435: duke@435: case JVM_CONSTANT_Long: duke@435: SET_STACK_LONG(constants->long_at(index), 1); duke@435: break; duke@435: duke@435: case JVM_CONSTANT_Double: duke@435: SET_STACK_DOUBLE(constants->double_at(index), 1); duke@435: break; duke@435: default: ShouldNotReachHere(); duke@435: } duke@435: UPDATE_PC_AND_TOS_AND_CONTINUE(3, 2); duke@435: } duke@435: duke@435: CASE(_invokeinterface): { duke@435: u2 index = Bytes::get_native_u2(pc+1); duke@435: duke@435: // QQQ Need to make this as inlined as possible. Probably need to split all the bytecode cases duke@435: // out so c++ compiler has a chance for constant prop to fold everything possible away. duke@435: duke@435: ConstantPoolCacheEntry* cache = cp->entry_at(index); duke@435: if (!cache->is_resolved((Bytecodes::Code)opcode)) { duke@435: CALL_VM(InterpreterRuntime::resolve_invoke(THREAD, (Bytecodes::Code)opcode), duke@435: handle_exception); duke@435: cache = cp->entry_at(index); duke@435: } duke@435: duke@435: istate->set_msg(call_method); duke@435: duke@435: // Special case of invokeinterface called for virtual method of duke@435: // java.lang.Object. See cpCacheOop.cpp for details. duke@435: // This code isn't produced by javac, but could be produced by duke@435: // another compliant java compiler. duke@435: if (cache->is_methodInterface()) { duke@435: methodOop callee; duke@435: CHECK_NULL(STACK_OBJECT(-(cache->parameter_size()))); duke@435: if (cache->is_vfinal()) { duke@435: callee = (methodOop) cache->f2(); duke@435: } else { duke@435: // get receiver duke@435: int parms = cache->parameter_size(); duke@435: // Same comments as invokevirtual apply here duke@435: instanceKlass* rcvrKlass = (instanceKlass*) duke@435: STACK_OBJECT(-parms)->klass()->klass_part(); duke@435: callee = (methodOop) rcvrKlass->start_of_vtable()[ cache->f2()]; duke@435: } duke@435: istate->set_callee(callee); duke@435: istate->set_callee_entry_point(callee->from_interpreted_entry()); duke@435: #ifdef VM_JVMTI duke@435: if (JvmtiExport::can_post_interpreter_events() && THREAD->is_interp_only_mode()) { duke@435: istate->set_callee_entry_point(callee->interpreter_entry()); duke@435: } duke@435: #endif /* VM_JVMTI */ duke@435: istate->set_bcp_advance(5); duke@435: UPDATE_PC_AND_RETURN(0); // I'll be back... duke@435: } duke@435: duke@435: // this could definitely be cleaned up QQQ duke@435: methodOop callee; duke@435: klassOop iclass = (klassOop)cache->f1(); duke@435: // instanceKlass* interface = (instanceKlass*) iclass->klass_part(); duke@435: // get receiver duke@435: int parms = cache->parameter_size(); duke@435: oop rcvr = STACK_OBJECT(-parms); duke@435: CHECK_NULL(rcvr); duke@435: instanceKlass* int2 = (instanceKlass*) rcvr->klass()->klass_part(); duke@435: itableOffsetEntry* ki = (itableOffsetEntry*) int2->start_of_itable(); duke@435: int i; duke@435: for ( i = 0 ; i < int2->itable_length() ; i++, ki++ ) { duke@435: if (ki->interface_klass() == iclass) break; duke@435: } duke@435: // If the interface isn't found, this class doesn't implement this duke@435: // interface. The link resolver checks this but only for the first duke@435: // time this interface is called. duke@435: if (i == int2->itable_length()) { duke@435: VM_JAVA_ERROR(vmSymbols::java_lang_IncompatibleClassChangeError(), ""); duke@435: } duke@435: int mindex = cache->f2(); duke@435: itableMethodEntry* im = ki->first_method_entry(rcvr->klass()); duke@435: callee = im[mindex].method(); duke@435: if (callee == NULL) { duke@435: VM_JAVA_ERROR(vmSymbols::java_lang_AbstractMethodError(), ""); duke@435: } duke@435: duke@435: istate->set_callee(callee); duke@435: istate->set_callee_entry_point(callee->from_interpreted_entry()); duke@435: #ifdef VM_JVMTI duke@435: if (JvmtiExport::can_post_interpreter_events() && THREAD->is_interp_only_mode()) { duke@435: istate->set_callee_entry_point(callee->interpreter_entry()); duke@435: } duke@435: #endif /* VM_JVMTI */ duke@435: istate->set_bcp_advance(5); duke@435: UPDATE_PC_AND_RETURN(0); // I'll be back... duke@435: } duke@435: duke@435: CASE(_invokevirtual): duke@435: CASE(_invokespecial): duke@435: CASE(_invokestatic): { duke@435: u2 index = Bytes::get_native_u2(pc+1); duke@435: duke@435: ConstantPoolCacheEntry* cache = cp->entry_at(index); duke@435: // QQQ Need to make this as inlined as possible. Probably need to split all the bytecode cases duke@435: // out so c++ compiler has a chance for constant prop to fold everything possible away. duke@435: duke@435: if (!cache->is_resolved((Bytecodes::Code)opcode)) { duke@435: CALL_VM(InterpreterRuntime::resolve_invoke(THREAD, (Bytecodes::Code)opcode), duke@435: handle_exception); duke@435: cache = cp->entry_at(index); duke@435: } duke@435: duke@435: istate->set_msg(call_method); duke@435: { duke@435: methodOop callee; duke@435: if ((Bytecodes::Code)opcode == Bytecodes::_invokevirtual) { duke@435: CHECK_NULL(STACK_OBJECT(-(cache->parameter_size()))); duke@435: if (cache->is_vfinal()) callee = (methodOop) cache->f2(); duke@435: else { duke@435: // get receiver duke@435: int parms = cache->parameter_size(); duke@435: // this works but needs a resourcemark and seems to create a vtable on every call: duke@435: // methodOop callee = rcvr->klass()->klass_part()->vtable()->method_at(cache->f2()); duke@435: // duke@435: // this fails with an assert duke@435: // instanceKlass* rcvrKlass = instanceKlass::cast(STACK_OBJECT(-parms)->klass()); duke@435: // but this works duke@435: instanceKlass* rcvrKlass = (instanceKlass*) STACK_OBJECT(-parms)->klass()->klass_part(); duke@435: /* duke@435: Executing this code in java.lang.String: duke@435: public String(char value[]) { duke@435: this.count = value.length; duke@435: this.value = (char[])value.clone(); duke@435: } duke@435: duke@435: a find on rcvr->klass()->klass_part() reports: duke@435: {type array char}{type array class} duke@435: - klass: {other class} duke@435: duke@435: but using instanceKlass::cast(STACK_OBJECT(-parms)->klass()) causes in assertion failure duke@435: because rcvr->klass()->klass_part()->oop_is_instance() == 0 duke@435: However it seems to have a vtable in the right location. Huh? duke@435: duke@435: */ duke@435: callee = (methodOop) rcvrKlass->start_of_vtable()[ cache->f2()]; duke@435: } duke@435: } else { duke@435: if ((Bytecodes::Code)opcode == Bytecodes::_invokespecial) { duke@435: CHECK_NULL(STACK_OBJECT(-(cache->parameter_size()))); duke@435: } duke@435: callee = (methodOop) cache->f1(); duke@435: } duke@435: duke@435: istate->set_callee(callee); duke@435: istate->set_callee_entry_point(callee->from_interpreted_entry()); duke@435: #ifdef VM_JVMTI duke@435: if (JvmtiExport::can_post_interpreter_events() && THREAD->is_interp_only_mode()) { duke@435: istate->set_callee_entry_point(callee->interpreter_entry()); duke@435: } duke@435: #endif /* VM_JVMTI */ duke@435: istate->set_bcp_advance(3); duke@435: UPDATE_PC_AND_RETURN(0); // I'll be back... duke@435: } duke@435: } duke@435: duke@435: /* Allocate memory for a new java object. */ duke@435: duke@435: CASE(_newarray): { duke@435: BasicType atype = (BasicType) *(pc+1); duke@435: jint size = STACK_INT(-1); duke@435: CALL_VM(InterpreterRuntime::newarray(THREAD, atype, size), duke@435: handle_exception); duke@435: SET_STACK_OBJECT(THREAD->vm_result(), -1); duke@435: THREAD->set_vm_result(NULL); duke@435: duke@435: UPDATE_PC_AND_CONTINUE(2); duke@435: } duke@435: duke@435: /* Throw an exception. */ duke@435: duke@435: CASE(_athrow): { duke@435: oop except_oop = STACK_OBJECT(-1); duke@435: CHECK_NULL(except_oop); duke@435: // set pending_exception so we use common code duke@435: THREAD->set_pending_exception(except_oop, NULL, 0); duke@435: goto handle_exception; duke@435: } duke@435: duke@435: /* goto and jsr. They are exactly the same except jsr pushes duke@435: * the address of the next instruction first. duke@435: */ duke@435: duke@435: CASE(_jsr): { duke@435: /* push bytecode index on stack */ duke@435: SET_STACK_ADDR(((address)pc - (intptr_t)(istate->method()->code_base()) + 3), 0); duke@435: MORE_STACK(1); duke@435: /* FALL THROUGH */ duke@435: } duke@435: duke@435: CASE(_goto): duke@435: { duke@435: int16_t offset = (int16_t)Bytes::get_Java_u2(pc + 1); duke@435: address branch_pc = pc; duke@435: UPDATE_PC(offset); duke@435: DO_BACKEDGE_CHECKS(offset, branch_pc); duke@435: CONTINUE; duke@435: } duke@435: duke@435: CASE(_jsr_w): { duke@435: /* push return address on the stack */ duke@435: SET_STACK_ADDR(((address)pc - (intptr_t)(istate->method()->code_base()) + 5), 0); duke@435: MORE_STACK(1); duke@435: /* FALL THROUGH */ duke@435: } duke@435: duke@435: CASE(_goto_w): duke@435: { duke@435: int32_t offset = Bytes::get_Java_u4(pc + 1); duke@435: address branch_pc = pc; duke@435: UPDATE_PC(offset); duke@435: DO_BACKEDGE_CHECKS(offset, branch_pc); duke@435: CONTINUE; duke@435: } duke@435: duke@435: /* return from a jsr or jsr_w */ duke@435: duke@435: CASE(_ret): { duke@435: pc = istate->method()->code_base() + (intptr_t)(LOCALS_ADDR(pc[1])); duke@435: UPDATE_PC_AND_CONTINUE(0); duke@435: } duke@435: duke@435: /* debugger breakpoint */ duke@435: duke@435: CASE(_breakpoint): { duke@435: Bytecodes::Code original_bytecode; duke@435: DECACHE_STATE(); duke@435: SET_LAST_JAVA_FRAME(); duke@435: original_bytecode = InterpreterRuntime::get_original_bytecode_at(THREAD, duke@435: METHOD, pc); duke@435: RESET_LAST_JAVA_FRAME(); duke@435: CACHE_STATE(); duke@435: if (THREAD->has_pending_exception()) goto handle_exception; duke@435: CALL_VM(InterpreterRuntime::_breakpoint(THREAD, METHOD, pc), duke@435: handle_exception); duke@435: duke@435: opcode = (jubyte)original_bytecode; duke@435: goto opcode_switch; duke@435: } duke@435: duke@435: DEFAULT: duke@435: fatal2("\t*** Unimplemented opcode: %d = %s\n", duke@435: opcode, Bytecodes::name((Bytecodes::Code)opcode)); duke@435: goto finish; duke@435: duke@435: } /* switch(opc) */ duke@435: duke@435: duke@435: #ifdef USELABELS duke@435: check_for_exception: duke@435: #endif duke@435: { duke@435: if (!THREAD->has_pending_exception()) { duke@435: CONTINUE; duke@435: } duke@435: /* We will be gcsafe soon, so flush our state. */ duke@435: DECACHE_PC(); duke@435: goto handle_exception; duke@435: } duke@435: do_continue: ; duke@435: duke@435: } /* while (1) interpreter loop */ duke@435: duke@435: duke@435: // An exception exists in the thread state see whether this activation can handle it duke@435: handle_exception: { duke@435: duke@435: HandleMarkCleaner __hmc(THREAD); duke@435: Handle except_oop(THREAD, THREAD->pending_exception()); duke@435: // Prevent any subsequent HandleMarkCleaner in the VM duke@435: // from freeing the except_oop handle. duke@435: HandleMark __hm(THREAD); duke@435: duke@435: THREAD->clear_pending_exception(); duke@435: assert(except_oop(), "No exception to process"); duke@435: intptr_t continuation_bci; duke@435: // expression stack is emptied duke@435: topOfStack = istate->stack_base() - Interpreter::stackElementWords(); duke@435: CALL_VM(continuation_bci = (intptr_t)InterpreterRuntime::exception_handler_for_exception(THREAD, except_oop()), duke@435: handle_exception); duke@435: duke@435: except_oop = (oop) THREAD->vm_result(); duke@435: THREAD->set_vm_result(NULL); duke@435: if (continuation_bci >= 0) { duke@435: // Place exception on top of stack duke@435: SET_STACK_OBJECT(except_oop(), 0); duke@435: MORE_STACK(1); duke@435: pc = METHOD->code_base() + continuation_bci; duke@435: if (TraceExceptions) { duke@435: ttyLocker ttyl; duke@435: ResourceMark rm; duke@435: tty->print_cr("Exception <%s> (" INTPTR_FORMAT ")", except_oop->print_value_string(), except_oop()); duke@435: tty->print_cr(" thrown in interpreter method <%s>", METHOD->print_value_string()); duke@435: tty->print_cr(" at bci %d, continuing at %d for thread " INTPTR_FORMAT, duke@435: pc - (intptr_t)METHOD->code_base(), duke@435: continuation_bci, THREAD); duke@435: } duke@435: // for AbortVMOnException flag duke@435: NOT_PRODUCT(Exceptions::debug_check_abort(except_oop)); duke@435: goto run; duke@435: } duke@435: if (TraceExceptions) { duke@435: ttyLocker ttyl; duke@435: ResourceMark rm; duke@435: tty->print_cr("Exception <%s> (" INTPTR_FORMAT ")", except_oop->print_value_string(), except_oop()); duke@435: tty->print_cr(" thrown in interpreter method <%s>", METHOD->print_value_string()); duke@435: tty->print_cr(" at bci %d, unwinding for thread " INTPTR_FORMAT, duke@435: pc - (intptr_t) METHOD->code_base(), duke@435: THREAD); duke@435: } duke@435: // for AbortVMOnException flag duke@435: NOT_PRODUCT(Exceptions::debug_check_abort(except_oop)); duke@435: // No handler in this activation, unwind and try again duke@435: THREAD->set_pending_exception(except_oop(), NULL, 0); duke@435: goto handle_return; duke@435: } /* handle_exception: */ duke@435: duke@435: duke@435: duke@435: // Return from an interpreter invocation with the result of the interpretation duke@435: // on the top of the Java Stack (or a pending exception) duke@435: duke@435: handle_Pop_Frame: duke@435: duke@435: // We don't really do anything special here except we must be aware duke@435: // that we can get here without ever locking the method (if sync). duke@435: // Also we skip the notification of the exit. duke@435: duke@435: istate->set_msg(popping_frame); duke@435: // Clear pending so while the pop is in process duke@435: // we don't start another one if a call_vm is done. duke@435: THREAD->clr_pop_frame_pending(); duke@435: // Let interpreter (only) see the we're in the process of popping a frame duke@435: THREAD->set_pop_frame_in_process(); duke@435: duke@435: handle_return: duke@435: { duke@435: DECACHE_STATE(); duke@435: duke@435: bool suppress_error = istate->msg() == popping_frame; duke@435: bool suppress_exit_event = THREAD->has_pending_exception() || suppress_error; duke@435: Handle original_exception(THREAD, THREAD->pending_exception()); duke@435: Handle illegal_state_oop(THREAD, NULL); duke@435: duke@435: // We'd like a HandleMark here to prevent any subsequent HandleMarkCleaner duke@435: // in any following VM entries from freeing our live handles, but illegal_state_oop duke@435: // isn't really allocated yet and so doesn't become live until later and duke@435: // in unpredicatable places. Instead we must protect the places where we enter the duke@435: // VM. It would be much simpler (and safer) if we could allocate a real handle with duke@435: // a NULL oop in it and then overwrite the oop later as needed. This isn't duke@435: // unfortunately isn't possible. duke@435: duke@435: THREAD->clear_pending_exception(); duke@435: duke@435: // duke@435: // As far as we are concerned we have returned. If we have a pending exception duke@435: // that will be returned as this invocation's result. However if we get any duke@435: // exception(s) while checking monitor state one of those IllegalMonitorStateExceptions duke@435: // will be our final result (i.e. monitor exception trumps a pending exception). duke@435: // duke@435: duke@435: // If we never locked the method (or really passed the point where we would have), duke@435: // there is no need to unlock it (or look for other monitors), since that duke@435: // could not have happened. duke@435: duke@435: if (THREAD->do_not_unlock()) { duke@435: duke@435: // Never locked, reset the flag now because obviously any caller must duke@435: // have passed their point of locking for us to have gotten here. duke@435: duke@435: THREAD->clr_do_not_unlock(); duke@435: } else { duke@435: // At this point we consider that we have returned. We now check that the duke@435: // locks were properly block structured. If we find that they were not duke@435: // used properly we will return with an illegal monitor exception. duke@435: // The exception is checked by the caller not the callee since this duke@435: // checking is considered to be part of the invocation and therefore duke@435: // in the callers scope (JVM spec 8.13). duke@435: // duke@435: // Another weird thing to watch for is if the method was locked duke@435: // recursively and then not exited properly. This means we must duke@435: // examine all the entries in reverse time(and stack) order and duke@435: // unlock as we find them. If we find the method monitor before duke@435: // we are at the initial entry then we should throw an exception. duke@435: // It is not clear the template based interpreter does this duke@435: // correctly duke@435: duke@435: BasicObjectLock* base = istate->monitor_base(); duke@435: BasicObjectLock* end = (BasicObjectLock*) istate->stack_base(); duke@435: bool method_unlock_needed = METHOD->is_synchronized(); duke@435: // We know the initial monitor was used for the method don't check that duke@435: // slot in the loop duke@435: if (method_unlock_needed) base--; duke@435: duke@435: // Check all the monitors to see they are unlocked. Install exception if found to be locked. duke@435: while (end < base) { duke@435: oop lockee = end->obj(); duke@435: if (lockee != NULL) { duke@435: BasicLock* lock = end->lock(); duke@435: markOop header = lock->displaced_header(); duke@435: end->set_obj(NULL); duke@435: // If it isn't recursive we either must swap old header or call the runtime duke@435: if (header != NULL) { duke@435: if (Atomic::cmpxchg_ptr(header, lockee->mark_addr(), lock) != lock) { duke@435: // restore object for the slow case duke@435: end->set_obj(lockee); duke@435: { duke@435: // Prevent any HandleMarkCleaner from freeing our live handles duke@435: HandleMark __hm(THREAD); duke@435: CALL_VM_NOCHECK(InterpreterRuntime::monitorexit(THREAD, end)); duke@435: } duke@435: } duke@435: } duke@435: // One error is plenty duke@435: if (illegal_state_oop() == NULL && !suppress_error) { duke@435: { duke@435: // Prevent any HandleMarkCleaner from freeing our live handles duke@435: HandleMark __hm(THREAD); duke@435: CALL_VM_NOCHECK(InterpreterRuntime::throw_illegal_monitor_state_exception(THREAD)); duke@435: } duke@435: assert(THREAD->has_pending_exception(), "Lost our exception!"); duke@435: illegal_state_oop = THREAD->pending_exception(); duke@435: THREAD->clear_pending_exception(); duke@435: } duke@435: } duke@435: end++; duke@435: } duke@435: // Unlock the method if needed duke@435: if (method_unlock_needed) { duke@435: if (base->obj() == NULL) { duke@435: // The method is already unlocked this is not good. duke@435: if (illegal_state_oop() == NULL && !suppress_error) { duke@435: { duke@435: // Prevent any HandleMarkCleaner from freeing our live handles duke@435: HandleMark __hm(THREAD); duke@435: CALL_VM_NOCHECK(InterpreterRuntime::throw_illegal_monitor_state_exception(THREAD)); duke@435: } duke@435: assert(THREAD->has_pending_exception(), "Lost our exception!"); duke@435: illegal_state_oop = THREAD->pending_exception(); duke@435: THREAD->clear_pending_exception(); duke@435: } duke@435: } else { duke@435: // duke@435: // The initial monitor is always used for the method duke@435: // However if that slot is no longer the oop for the method it was unlocked duke@435: // and reused by something that wasn't unlocked! duke@435: // duke@435: // deopt can come in with rcvr dead because c2 knows duke@435: // its value is preserved in the monitor. So we can't use locals[0] at all duke@435: // and must use first monitor slot. duke@435: // duke@435: oop rcvr = base->obj(); duke@435: if (rcvr == NULL) { duke@435: if (!suppress_error) { duke@435: VM_JAVA_ERROR_NO_JUMP(vmSymbols::java_lang_NullPointerException(), ""); duke@435: illegal_state_oop = THREAD->pending_exception(); duke@435: THREAD->clear_pending_exception(); duke@435: } duke@435: } else { duke@435: BasicLock* lock = base->lock(); duke@435: markOop header = lock->displaced_header(); duke@435: base->set_obj(NULL); duke@435: // If it isn't recursive we either must swap old header or call the runtime duke@435: if (header != NULL) { duke@435: if (Atomic::cmpxchg_ptr(header, rcvr->mark_addr(), lock) != lock) { duke@435: // restore object for the slow case duke@435: base->set_obj(rcvr); duke@435: { duke@435: // Prevent any HandleMarkCleaner from freeing our live handles duke@435: HandleMark __hm(THREAD); duke@435: CALL_VM_NOCHECK(InterpreterRuntime::monitorexit(THREAD, base)); duke@435: } duke@435: if (THREAD->has_pending_exception()) { duke@435: if (!suppress_error) illegal_state_oop = THREAD->pending_exception(); duke@435: THREAD->clear_pending_exception(); duke@435: } duke@435: } duke@435: } duke@435: } duke@435: } duke@435: } duke@435: } duke@435: duke@435: // duke@435: // Notify jvmti/jvmdi duke@435: // duke@435: // NOTE: we do not notify a method_exit if we have a pending exception, duke@435: // including an exception we generate for unlocking checks. In the former duke@435: // case, JVMDI has already been notified by our call for the exception handler duke@435: // and in both cases as far as JVMDI is concerned we have already returned. duke@435: // If we notify it again JVMDI will be all confused about how many frames duke@435: // are still on the stack (4340444). duke@435: // duke@435: // NOTE Further! It turns out the the JVMTI spec in fact expects to see duke@435: // method_exit events whenever we leave an activation unless it was done duke@435: // for popframe. This is nothing like jvmdi. However we are passing the duke@435: // tests at the moment (apparently because they are jvmdi based) so rather duke@435: // than change this code and possibly fail tests we will leave it alone duke@435: // (with this note) in anticipation of changing the vm and the tests duke@435: // simultaneously. duke@435: duke@435: duke@435: // duke@435: suppress_exit_event = suppress_exit_event || illegal_state_oop() != NULL; duke@435: duke@435: duke@435: duke@435: #ifdef VM_JVMTI duke@435: if (_jvmti_interp_events) { duke@435: // Whenever JVMTI puts a thread in interp_only_mode, method duke@435: // entry/exit events are sent for that thread to track stack depth. duke@435: if ( !suppress_exit_event && THREAD->is_interp_only_mode() ) { duke@435: { duke@435: // Prevent any HandleMarkCleaner from freeing our live handles duke@435: HandleMark __hm(THREAD); duke@435: CALL_VM_NOCHECK(InterpreterRuntime::post_method_exit(THREAD)); duke@435: } duke@435: } duke@435: } duke@435: #endif /* VM_JVMTI */ duke@435: duke@435: // duke@435: // See if we are returning any exception duke@435: // A pending exception that was pending prior to a possible popping frame duke@435: // overrides the popping frame. duke@435: // duke@435: assert(!suppress_error || suppress_error && illegal_state_oop() == NULL, "Error was not suppressed"); duke@435: if (illegal_state_oop() != NULL || original_exception() != NULL) { duke@435: // inform the frame manager we have no result duke@435: istate->set_msg(throwing_exception); duke@435: if (illegal_state_oop() != NULL) duke@435: THREAD->set_pending_exception(illegal_state_oop(), NULL, 0); duke@435: else duke@435: THREAD->set_pending_exception(original_exception(), NULL, 0); duke@435: istate->set_return_kind((Bytecodes::Code)opcode); duke@435: UPDATE_PC_AND_RETURN(0); duke@435: } duke@435: duke@435: if (istate->msg() == popping_frame) { duke@435: // Make it simpler on the assembly code and set the message for the frame pop. duke@435: // returns duke@435: if (istate->prev() == NULL) { duke@435: // We must be returning to a deoptimized frame (because popframe only happens between duke@435: // two interpreted frames). We need to save the current arguments in C heap so that duke@435: // the deoptimized frame when it restarts can copy the arguments to its expression duke@435: // stack and re-execute the call. We also have to notify deoptimization that this duke@435: // has occured and to pick the preerved args copy them to the deoptimized frame's duke@435: // java expression stack. Yuck. duke@435: // duke@435: THREAD->popframe_preserve_args(in_ByteSize(METHOD->size_of_parameters() * wordSize), duke@435: LOCALS_SLOT(METHOD->size_of_parameters() - 1)); duke@435: THREAD->set_popframe_condition_bit(JavaThread::popframe_force_deopt_reexecution_bit); duke@435: } duke@435: UPDATE_PC_AND_RETURN(1); duke@435: } else { duke@435: // Normal return duke@435: // Advance the pc and return to frame manager duke@435: istate->set_msg(return_from_method); duke@435: istate->set_return_kind((Bytecodes::Code)opcode); duke@435: UPDATE_PC_AND_RETURN(1); duke@435: } duke@435: } /* handle_return: */ duke@435: duke@435: // This is really a fatal error return duke@435: duke@435: finish: duke@435: DECACHE_TOS(); duke@435: DECACHE_PC(); duke@435: duke@435: return; duke@435: } duke@435: duke@435: /* duke@435: * All the code following this point is only produced once and is not present duke@435: * in the JVMTI version of the interpreter duke@435: */ duke@435: duke@435: #ifndef VM_JVMTI duke@435: duke@435: // This constructor should only be used to contruct the object to signal duke@435: // interpreter initialization. All other instances should be created by duke@435: // the frame manager. duke@435: BytecodeInterpreter::BytecodeInterpreter(messages msg) { duke@435: if (msg != initialize) ShouldNotReachHere(); duke@435: _msg = msg; duke@435: _self_link = this; duke@435: _prev_link = NULL; duke@435: } duke@435: duke@435: // Inline static functions for Java Stack and Local manipulation duke@435: duke@435: // The implementations are platform dependent. We have to worry about alignment duke@435: // issues on some machines which can change on the same platform depending on duke@435: // whether it is an LP64 machine also. duke@435: #ifdef ASSERT duke@435: void BytecodeInterpreter::verify_stack_tag(intptr_t *tos, frame::Tag tag, int offset) { duke@435: if (TaggedStackInterpreter) { duke@435: frame::Tag t = (frame::Tag)tos[Interpreter::expr_tag_index_at(-offset)]; duke@435: assert(t == tag, "stack tag mismatch"); duke@435: } duke@435: } duke@435: #endif // ASSERT duke@435: duke@435: address BytecodeInterpreter::stack_slot(intptr_t *tos, int offset) { duke@435: debug_only(verify_stack_tag(tos, frame::TagValue, offset)); duke@435: return (address) tos[Interpreter::expr_index_at(-offset)]; duke@435: } duke@435: duke@435: jint BytecodeInterpreter::stack_int(intptr_t *tos, int offset) { duke@435: debug_only(verify_stack_tag(tos, frame::TagValue, offset)); duke@435: return *((jint*) &tos[Interpreter::expr_index_at(-offset)]); duke@435: } duke@435: duke@435: jfloat BytecodeInterpreter::stack_float(intptr_t *tos, int offset) { duke@435: debug_only(verify_stack_tag(tos, frame::TagValue, offset)); duke@435: return *((jfloat *) &tos[Interpreter::expr_index_at(-offset)]); duke@435: } duke@435: duke@435: oop BytecodeInterpreter::stack_object(intptr_t *tos, int offset) { duke@435: debug_only(verify_stack_tag(tos, frame::TagReference, offset)); duke@435: return (oop)tos [Interpreter::expr_index_at(-offset)]; duke@435: } duke@435: duke@435: jdouble BytecodeInterpreter::stack_double(intptr_t *tos, int offset) { duke@435: debug_only(verify_stack_tag(tos, frame::TagValue, offset)); duke@435: debug_only(verify_stack_tag(tos, frame::TagValue, offset-1)); duke@435: return ((VMJavaVal64*) &tos[Interpreter::expr_index_at(-offset)])->d; duke@435: } duke@435: duke@435: jlong BytecodeInterpreter::stack_long(intptr_t *tos, int offset) { duke@435: debug_only(verify_stack_tag(tos, frame::TagValue, offset)); duke@435: debug_only(verify_stack_tag(tos, frame::TagValue, offset-1)); duke@435: return ((VMJavaVal64 *) &tos[Interpreter::expr_index_at(-offset)])->l; duke@435: } duke@435: duke@435: void BytecodeInterpreter::tag_stack(intptr_t *tos, frame::Tag tag, int offset) { duke@435: if (TaggedStackInterpreter) duke@435: tos[Interpreter::expr_tag_index_at(-offset)] = (intptr_t)tag; duke@435: } duke@435: duke@435: // only used for value types duke@435: void BytecodeInterpreter::set_stack_slot(intptr_t *tos, address value, duke@435: int offset) { duke@435: tag_stack(tos, frame::TagValue, offset); duke@435: *((address *)&tos[Interpreter::expr_index_at(-offset)]) = value; duke@435: } duke@435: duke@435: void BytecodeInterpreter::set_stack_int(intptr_t *tos, int value, duke@435: int offset) { duke@435: tag_stack(tos, frame::TagValue, offset); duke@435: *((jint *)&tos[Interpreter::expr_index_at(-offset)]) = value; duke@435: } duke@435: duke@435: void BytecodeInterpreter::set_stack_float(intptr_t *tos, jfloat value, duke@435: int offset) { duke@435: tag_stack(tos, frame::TagValue, offset); duke@435: *((jfloat *)&tos[Interpreter::expr_index_at(-offset)]) = value; duke@435: } duke@435: duke@435: void BytecodeInterpreter::set_stack_object(intptr_t *tos, oop value, duke@435: int offset) { duke@435: tag_stack(tos, frame::TagReference, offset); duke@435: *((oop *)&tos[Interpreter::expr_index_at(-offset)]) = value; duke@435: } duke@435: duke@435: // needs to be platform dep for the 32 bit platforms. duke@435: void BytecodeInterpreter::set_stack_double(intptr_t *tos, jdouble value, duke@435: int offset) { duke@435: tag_stack(tos, frame::TagValue, offset); duke@435: tag_stack(tos, frame::TagValue, offset-1); duke@435: ((VMJavaVal64*)&tos[Interpreter::expr_index_at(-offset)])->d = value; duke@435: } duke@435: duke@435: void BytecodeInterpreter::set_stack_double_from_addr(intptr_t *tos, duke@435: address addr, int offset) { duke@435: tag_stack(tos, frame::TagValue, offset); duke@435: tag_stack(tos, frame::TagValue, offset-1); duke@435: (((VMJavaVal64*)&tos[Interpreter::expr_index_at(-offset)])->d = duke@435: ((VMJavaVal64*)addr)->d); duke@435: } duke@435: duke@435: void BytecodeInterpreter::set_stack_long(intptr_t *tos, jlong value, duke@435: int offset) { duke@435: tag_stack(tos, frame::TagValue, offset); duke@435: ((VMJavaVal64*)&tos[Interpreter::expr_index_at(-offset+1)])->l = 0xdeedbeeb; duke@435: tag_stack(tos, frame::TagValue, offset-1); duke@435: ((VMJavaVal64*)&tos[Interpreter::expr_index_at(-offset)])->l = value; duke@435: } duke@435: duke@435: void BytecodeInterpreter::set_stack_long_from_addr(intptr_t *tos, duke@435: address addr, int offset) { duke@435: tag_stack(tos, frame::TagValue, offset); duke@435: ((VMJavaVal64*)&tos[Interpreter::expr_index_at(-offset+1)])->l = 0xdeedbeeb; duke@435: tag_stack(tos, frame::TagValue, offset-1); duke@435: ((VMJavaVal64*)&tos[Interpreter::expr_index_at(-offset)])->l = duke@435: ((VMJavaVal64*)addr)->l; duke@435: } duke@435: duke@435: // Locals duke@435: duke@435: #ifdef ASSERT duke@435: void BytecodeInterpreter::verify_locals_tag(intptr_t *locals, frame::Tag tag, duke@435: int offset) { duke@435: if (TaggedStackInterpreter) { duke@435: frame::Tag t = (frame::Tag)locals[Interpreter::local_tag_index_at(-offset)]; duke@435: assert(t == tag, "locals tag mismatch"); duke@435: } duke@435: } duke@435: #endif // ASSERT duke@435: address BytecodeInterpreter::locals_slot(intptr_t* locals, int offset) { duke@435: debug_only(verify_locals_tag(locals, frame::TagValue, offset)); duke@435: return (address)locals[Interpreter::local_index_at(-offset)]; duke@435: } duke@435: jint BytecodeInterpreter::locals_int(intptr_t* locals, int offset) { duke@435: debug_only(verify_locals_tag(locals, frame::TagValue, offset)); duke@435: return (jint)locals[Interpreter::local_index_at(-offset)]; duke@435: } duke@435: jfloat BytecodeInterpreter::locals_float(intptr_t* locals, int offset) { duke@435: debug_only(verify_locals_tag(locals, frame::TagValue, offset)); duke@435: return (jfloat)locals[Interpreter::local_index_at(-offset)]; duke@435: } duke@435: oop BytecodeInterpreter::locals_object(intptr_t* locals, int offset) { duke@435: debug_only(verify_locals_tag(locals, frame::TagReference, offset)); duke@435: return (oop)locals[Interpreter::local_index_at(-offset)]; duke@435: } duke@435: jdouble BytecodeInterpreter::locals_double(intptr_t* locals, int offset) { duke@435: debug_only(verify_locals_tag(locals, frame::TagValue, offset)); duke@435: debug_only(verify_locals_tag(locals, frame::TagValue, offset)); duke@435: return ((VMJavaVal64*)&locals[Interpreter::local_index_at(-(offset+1))])->d; duke@435: } duke@435: jlong BytecodeInterpreter::locals_long(intptr_t* locals, int offset) { duke@435: debug_only(verify_locals_tag(locals, frame::TagValue, offset)); duke@435: debug_only(verify_locals_tag(locals, frame::TagValue, offset+1)); duke@435: return ((VMJavaVal64*)&locals[Interpreter::local_index_at(-(offset+1))])->l; duke@435: } duke@435: duke@435: // Returns the address of locals value. duke@435: address BytecodeInterpreter::locals_long_at(intptr_t* locals, int offset) { duke@435: debug_only(verify_locals_tag(locals, frame::TagValue, offset)); duke@435: debug_only(verify_locals_tag(locals, frame::TagValue, offset+1)); duke@435: return ((address)&locals[Interpreter::local_index_at(-(offset+1))]); duke@435: } duke@435: address BytecodeInterpreter::locals_double_at(intptr_t* locals, int offset) { duke@435: debug_only(verify_locals_tag(locals, frame::TagValue, offset)); duke@435: debug_only(verify_locals_tag(locals, frame::TagValue, offset+1)); duke@435: return ((address)&locals[Interpreter::local_index_at(-(offset+1))]); duke@435: } duke@435: duke@435: void BytecodeInterpreter::tag_locals(intptr_t *locals, frame::Tag tag, int offset) { duke@435: if (TaggedStackInterpreter) duke@435: locals[Interpreter::local_tag_index_at(-offset)] = (intptr_t)tag; duke@435: } duke@435: duke@435: // Used for local value or returnAddress duke@435: void BytecodeInterpreter::set_locals_slot(intptr_t *locals, duke@435: address value, int offset) { duke@435: tag_locals(locals, frame::TagValue, offset); duke@435: *((address*)&locals[Interpreter::local_index_at(-offset)]) = value; duke@435: } duke@435: void BytecodeInterpreter::set_locals_int(intptr_t *locals, duke@435: jint value, int offset) { duke@435: tag_locals(locals, frame::TagValue, offset); duke@435: *((jint *)&locals[Interpreter::local_index_at(-offset)]) = value; duke@435: } duke@435: void BytecodeInterpreter::set_locals_float(intptr_t *locals, duke@435: jfloat value, int offset) { duke@435: tag_locals(locals, frame::TagValue, offset); duke@435: *((jfloat *)&locals[Interpreter::local_index_at(-offset)]) = value; duke@435: } duke@435: void BytecodeInterpreter::set_locals_object(intptr_t *locals, duke@435: oop value, int offset) { duke@435: tag_locals(locals, frame::TagReference, offset); duke@435: *((oop *)&locals[Interpreter::local_index_at(-offset)]) = value; duke@435: } duke@435: void BytecodeInterpreter::set_locals_double(intptr_t *locals, duke@435: jdouble value, int offset) { duke@435: tag_locals(locals, frame::TagValue, offset); duke@435: tag_locals(locals, frame::TagValue, offset+1); duke@435: ((VMJavaVal64*)&locals[Interpreter::local_index_at(-(offset+1))])->d = value; duke@435: } duke@435: void BytecodeInterpreter::set_locals_long(intptr_t *locals, duke@435: jlong value, int offset) { duke@435: tag_locals(locals, frame::TagValue, offset); duke@435: tag_locals(locals, frame::TagValue, offset+1); duke@435: ((VMJavaVal64*)&locals[Interpreter::local_index_at(-(offset+1))])->l = value; duke@435: } duke@435: void BytecodeInterpreter::set_locals_double_from_addr(intptr_t *locals, duke@435: address addr, int offset) { duke@435: tag_locals(locals, frame::TagValue, offset); duke@435: tag_locals(locals, frame::TagValue, offset+1); duke@435: ((VMJavaVal64*)&locals[Interpreter::local_index_at(-(offset+1))])->d = ((VMJavaVal64*)addr)->d; duke@435: } duke@435: void BytecodeInterpreter::set_locals_long_from_addr(intptr_t *locals, duke@435: address addr, int offset) { duke@435: tag_locals(locals, frame::TagValue, offset); duke@435: tag_locals(locals, frame::TagValue, offset+1); duke@435: ((VMJavaVal64*)&locals[Interpreter::local_index_at(-(offset+1))])->l = ((VMJavaVal64*)addr)->l; duke@435: } duke@435: duke@435: void BytecodeInterpreter::astore(intptr_t* tos, int stack_offset, duke@435: intptr_t* locals, int locals_offset) { duke@435: // Copy tag from stack to locals. astore's operand can be returnAddress duke@435: // and may not be TagReference duke@435: if (TaggedStackInterpreter) { duke@435: frame::Tag t = (frame::Tag) tos[Interpreter::expr_tag_index_at(-stack_offset)]; duke@435: locals[Interpreter::local_tag_index_at(-locals_offset)] = (intptr_t)t; duke@435: } duke@435: intptr_t value = tos[Interpreter::expr_index_at(-stack_offset)]; duke@435: locals[Interpreter::local_index_at(-locals_offset)] = value; duke@435: } duke@435: duke@435: duke@435: void BytecodeInterpreter::copy_stack_slot(intptr_t *tos, int from_offset, duke@435: int to_offset) { duke@435: if (TaggedStackInterpreter) { duke@435: tos[Interpreter::expr_tag_index_at(-to_offset)] = duke@435: (intptr_t)tos[Interpreter::expr_tag_index_at(-from_offset)]; duke@435: } duke@435: tos[Interpreter::expr_index_at(-to_offset)] = duke@435: (intptr_t)tos[Interpreter::expr_index_at(-from_offset)]; duke@435: } duke@435: duke@435: void BytecodeInterpreter::dup(intptr_t *tos) { duke@435: copy_stack_slot(tos, -1, 0); duke@435: } duke@435: void BytecodeInterpreter::dup2(intptr_t *tos) { duke@435: copy_stack_slot(tos, -2, 0); duke@435: copy_stack_slot(tos, -1, 1); duke@435: } duke@435: duke@435: void BytecodeInterpreter::dup_x1(intptr_t *tos) { duke@435: /* insert top word two down */ duke@435: copy_stack_slot(tos, -1, 0); duke@435: copy_stack_slot(tos, -2, -1); duke@435: copy_stack_slot(tos, 0, -2); duke@435: } duke@435: duke@435: void BytecodeInterpreter::dup_x2(intptr_t *tos) { duke@435: /* insert top word three down */ duke@435: copy_stack_slot(tos, -1, 0); duke@435: copy_stack_slot(tos, -2, -1); duke@435: copy_stack_slot(tos, -3, -2); duke@435: copy_stack_slot(tos, 0, -3); duke@435: } duke@435: void BytecodeInterpreter::dup2_x1(intptr_t *tos) { duke@435: /* insert top 2 slots three down */ duke@435: copy_stack_slot(tos, -1, 1); duke@435: copy_stack_slot(tos, -2, 0); duke@435: copy_stack_slot(tos, -3, -1); duke@435: copy_stack_slot(tos, 1, -2); duke@435: copy_stack_slot(tos, 0, -3); duke@435: } duke@435: void BytecodeInterpreter::dup2_x2(intptr_t *tos) { duke@435: /* insert top 2 slots four down */ duke@435: copy_stack_slot(tos, -1, 1); duke@435: copy_stack_slot(tos, -2, 0); duke@435: copy_stack_slot(tos, -3, -1); duke@435: copy_stack_slot(tos, -4, -2); duke@435: copy_stack_slot(tos, 1, -3); duke@435: copy_stack_slot(tos, 0, -4); duke@435: } duke@435: duke@435: duke@435: void BytecodeInterpreter::swap(intptr_t *tos) { duke@435: // swap top two elements duke@435: intptr_t val = tos[Interpreter::expr_index_at(1)]; duke@435: frame::Tag t; duke@435: if (TaggedStackInterpreter) { duke@435: t = (frame::Tag) tos[Interpreter::expr_tag_index_at(1)]; duke@435: } duke@435: // Copy -2 entry to -1 duke@435: copy_stack_slot(tos, -2, -1); duke@435: // Store saved -1 entry into -2 duke@435: if (TaggedStackInterpreter) { duke@435: tos[Interpreter::expr_tag_index_at(2)] = (intptr_t)t; duke@435: } duke@435: tos[Interpreter::expr_index_at(2)] = val; duke@435: } duke@435: // -------------------------------------------------------------------------------- duke@435: // Non-product code duke@435: #ifndef PRODUCT duke@435: duke@435: const char* BytecodeInterpreter::C_msg(BytecodeInterpreter::messages msg) { duke@435: switch (msg) { duke@435: case BytecodeInterpreter::no_request: return("no_request"); duke@435: case BytecodeInterpreter::initialize: return("initialize"); duke@435: // status message to C++ interpreter duke@435: case BytecodeInterpreter::method_entry: return("method_entry"); duke@435: case BytecodeInterpreter::method_resume: return("method_resume"); duke@435: case BytecodeInterpreter::got_monitors: return("got_monitors"); duke@435: case BytecodeInterpreter::rethrow_exception: return("rethrow_exception"); duke@435: // requests to frame manager from C++ interpreter duke@435: case BytecodeInterpreter::call_method: return("call_method"); duke@435: case BytecodeInterpreter::return_from_method: return("return_from_method"); duke@435: case BytecodeInterpreter::more_monitors: return("more_monitors"); duke@435: case BytecodeInterpreter::throwing_exception: return("throwing_exception"); duke@435: case BytecodeInterpreter::popping_frame: return("popping_frame"); duke@435: case BytecodeInterpreter::do_osr: return("do_osr"); duke@435: // deopt duke@435: case BytecodeInterpreter::deopt_resume: return("deopt_resume"); duke@435: case BytecodeInterpreter::deopt_resume2: return("deopt_resume2"); duke@435: default: return("BAD MSG"); duke@435: } duke@435: } duke@435: void duke@435: BytecodeInterpreter::print() { duke@435: tty->print_cr("thread: " INTPTR_FORMAT, (uintptr_t) this->_thread); duke@435: tty->print_cr("bcp: " INTPTR_FORMAT, (uintptr_t) this->_bcp); duke@435: tty->print_cr("locals: " INTPTR_FORMAT, (uintptr_t) this->_locals); duke@435: tty->print_cr("constants: " INTPTR_FORMAT, (uintptr_t) this->_constants); duke@435: { duke@435: ResourceMark rm; duke@435: char *method_name = _method->name_and_sig_as_C_string(); duke@435: tty->print_cr("method: " INTPTR_FORMAT "[ %s ]", (uintptr_t) this->_method, method_name); duke@435: } duke@435: tty->print_cr("mdx: " INTPTR_FORMAT, (uintptr_t) this->_mdx); duke@435: tty->print_cr("stack: " INTPTR_FORMAT, (uintptr_t) this->_stack); duke@435: tty->print_cr("msg: %s", C_msg(this->_msg)); duke@435: tty->print_cr("result_to_call._callee: " INTPTR_FORMAT, (uintptr_t) this->_result._to_call._callee); duke@435: tty->print_cr("result_to_call._callee_entry_point: " INTPTR_FORMAT, (uintptr_t) this->_result._to_call._callee_entry_point); duke@435: tty->print_cr("result_to_call._bcp_advance: %d ", this->_result._to_call._bcp_advance); duke@435: tty->print_cr("osr._osr_buf: " INTPTR_FORMAT, (uintptr_t) this->_result._osr._osr_buf); duke@435: tty->print_cr("osr._osr_entry: " INTPTR_FORMAT, (uintptr_t) this->_result._osr._osr_entry); duke@435: tty->print_cr("result_return_kind 0x%x ", (int) this->_result._return_kind); duke@435: tty->print_cr("prev_link: " INTPTR_FORMAT, (uintptr_t) this->_prev_link); duke@435: tty->print_cr("native_mirror: " INTPTR_FORMAT, (uintptr_t) this->_oop_temp); duke@435: tty->print_cr("stack_base: " INTPTR_FORMAT, (uintptr_t) this->_stack_base); duke@435: tty->print_cr("stack_limit: " INTPTR_FORMAT, (uintptr_t) this->_stack_limit); duke@435: tty->print_cr("monitor_base: " INTPTR_FORMAT, (uintptr_t) this->_monitor_base); duke@435: #ifdef SPARC duke@435: tty->print_cr("last_Java_pc: " INTPTR_FORMAT, (uintptr_t) this->_last_Java_pc); duke@435: tty->print_cr("frame_bottom: " INTPTR_FORMAT, (uintptr_t) this->_frame_bottom); duke@435: tty->print_cr("&native_fresult: " INTPTR_FORMAT, (uintptr_t) &this->_native_fresult); duke@435: tty->print_cr("native_lresult: " INTPTR_FORMAT, (uintptr_t) this->_native_lresult); duke@435: #endif duke@435: #ifdef IA64 duke@435: tty->print_cr("last_Java_fp: " INTPTR_FORMAT, (uintptr_t) this->_last_Java_fp); duke@435: #endif // IA64 duke@435: tty->print_cr("self_link: " INTPTR_FORMAT, (uintptr_t) this->_self_link); duke@435: } duke@435: duke@435: extern "C" { duke@435: void PI(uintptr_t arg) { duke@435: ((BytecodeInterpreter*)arg)->print(); duke@435: } duke@435: } duke@435: #endif // PRODUCT duke@435: duke@435: #endif // JVMTI duke@435: #endif // CC_INTERP