src/share/vm/interpreter/bytecodeInterpreter.cpp

changeset 435
a61af66fc99e
child 558
9e5a7340635e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/vm/interpreter/bytecodeInterpreter.cpp	Sat Dec 01 00:00:00 2007 +0000
     1.3 @@ -0,0 +1,3047 @@
     1.4 +/*
     1.5 + * Copyright 2002-2007 Sun Microsystems, Inc.  All Rights Reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.
    1.11 + *
    1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.15 + * version 2 for more details (a copy is included in the LICENSE file that
    1.16 + * accompanied this code).
    1.17 + *
    1.18 + * You should have received a copy of the GNU General Public License version
    1.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.21 + *
    1.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    1.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
    1.24 + * have any questions.
    1.25 + *
    1.26 + */
    1.27 +
    1.28 +
    1.29 +// no precompiled headers
    1.30 +#include "incls/_bytecodeInterpreter.cpp.incl"
    1.31 +
    1.32 +#ifdef CC_INTERP
    1.33 +
    1.34 +/*
    1.35 + * USELABELS - If using GCC, then use labels for the opcode dispatching
    1.36 + * rather -then a switch statement. This improves performance because it
    1.37 + * gives us the oportunity to have the instructions that calculate the
    1.38 + * next opcode to jump to be intermixed with the rest of the instructions
    1.39 + * that implement the opcode (see UPDATE_PC_AND_TOS_AND_CONTINUE macro).
    1.40 + */
    1.41 +#undef USELABELS
    1.42 +#ifdef __GNUC__
    1.43 +/*
    1.44 +   ASSERT signifies debugging. It is much easier to step thru bytecodes if we
    1.45 +   don't use the computed goto approach.
    1.46 +*/
    1.47 +#ifndef ASSERT
    1.48 +#define USELABELS
    1.49 +#endif
    1.50 +#endif
    1.51 +
    1.52 +#undef CASE
    1.53 +#ifdef USELABELS
    1.54 +#define CASE(opcode) opc ## opcode
    1.55 +#define DEFAULT opc_default
    1.56 +#else
    1.57 +#define CASE(opcode) case Bytecodes:: opcode
    1.58 +#define DEFAULT default
    1.59 +#endif
    1.60 +
    1.61 +/*
    1.62 + * PREFETCH_OPCCODE - Some compilers do better if you prefetch the next
    1.63 + * opcode before going back to the top of the while loop, rather then having
    1.64 + * the top of the while loop handle it. This provides a better opportunity
    1.65 + * for instruction scheduling. Some compilers just do this prefetch
    1.66 + * automatically. Some actually end up with worse performance if you
    1.67 + * force the prefetch. Solaris gcc seems to do better, but cc does worse.
    1.68 + */
    1.69 +#undef PREFETCH_OPCCODE
    1.70 +#define PREFETCH_OPCCODE
    1.71 +
    1.72 +/*
    1.73 +  Interpreter safepoint: it is expected that the interpreter will have no live
    1.74 +  handles of its own creation live at an interpreter safepoint. Therefore we
    1.75 +  run a HandleMarkCleaner and trash all handles allocated in the call chain
    1.76 +  since the JavaCalls::call_helper invocation that initiated the chain.
    1.77 +  There really shouldn't be any handles remaining to trash but this is cheap
    1.78 +  in relation to a safepoint.
    1.79 +*/
    1.80 +#define SAFEPOINT                                                                 \
    1.81 +    if ( SafepointSynchronize::is_synchronizing()) {                              \
    1.82 +        {                                                                         \
    1.83 +          /* zap freed handles rather than GC'ing them */                         \
    1.84 +          HandleMarkCleaner __hmc(THREAD);                                        \
    1.85 +        }                                                                         \
    1.86 +        CALL_VM(SafepointSynchronize::block(THREAD), handle_exception);           \
    1.87 +    }
    1.88 +
    1.89 +/*
    1.90 + * VM_JAVA_ERROR - Macro for throwing a java exception from
    1.91 + * the interpreter loop. Should really be a CALL_VM but there
    1.92 + * is no entry point to do the transition to vm so we just
    1.93 + * do it by hand here.
    1.94 + */
    1.95 +#define VM_JAVA_ERROR_NO_JUMP(name, msg)                                          \
    1.96 +    DECACHE_STATE();                                                              \
    1.97 +    SET_LAST_JAVA_FRAME();                                                        \
    1.98 +    {                                                                             \
    1.99 +       ThreadInVMfromJava trans(THREAD);                                          \
   1.100 +       Exceptions::_throw_msg(THREAD, __FILE__, __LINE__, name, msg);             \
   1.101 +    }                                                                             \
   1.102 +    RESET_LAST_JAVA_FRAME();                                                      \
   1.103 +    CACHE_STATE();
   1.104 +
   1.105 +// Normal throw of a java error
   1.106 +#define VM_JAVA_ERROR(name, msg)                                                  \
   1.107 +    VM_JAVA_ERROR_NO_JUMP(name, msg)                                              \
   1.108 +    goto handle_exception;
   1.109 +
   1.110 +#ifdef PRODUCT
   1.111 +#define DO_UPDATE_INSTRUCTION_COUNT(opcode)
   1.112 +#else
   1.113 +#define DO_UPDATE_INSTRUCTION_COUNT(opcode)                                                          \
   1.114 +{                                                                                                    \
   1.115 +    BytecodeCounter::_counter_value++;                                                               \
   1.116 +    BytecodeHistogram::_counters[(Bytecodes::Code)opcode]++;                                         \
   1.117 +    if (StopInterpreterAt && StopInterpreterAt == BytecodeCounter::_counter_value) os::breakpoint(); \
   1.118 +    if (TraceBytecodes) {                                                                            \
   1.119 +      CALL_VM((void)SharedRuntime::trace_bytecode(THREAD, 0,               \
   1.120 +                                   topOfStack[Interpreter::expr_index_at(1)],   \
   1.121 +                                   topOfStack[Interpreter::expr_index_at(2)]),  \
   1.122 +                                   handle_exception);                      \
   1.123 +    }                                                                      \
   1.124 +}
   1.125 +#endif
   1.126 +
   1.127 +#undef DEBUGGER_SINGLE_STEP_NOTIFY
   1.128 +#ifdef VM_JVMTI
   1.129 +/* NOTE: (kbr) This macro must be called AFTER the PC has been
   1.130 +   incremented. JvmtiExport::at_single_stepping_point() may cause a
   1.131 +   breakpoint opcode to get inserted at the current PC to allow the
   1.132 +   debugger to coalesce single-step events.
   1.133 +
   1.134 +   As a result if we call at_single_stepping_point() we refetch opcode
   1.135 +   to get the current opcode. This will override any other prefetching
   1.136 +   that might have occurred.
   1.137 +*/
   1.138 +#define DEBUGGER_SINGLE_STEP_NOTIFY()                                            \
   1.139 +{                                                                                \
   1.140 +      if (_jvmti_interp_events) {                                                \
   1.141 +        if (JvmtiExport::should_post_single_step()) {                            \
   1.142 +          DECACHE_STATE();                                                       \
   1.143 +          SET_LAST_JAVA_FRAME();                                                 \
   1.144 +          ThreadInVMfromJava trans(THREAD);                                      \
   1.145 +          JvmtiExport::at_single_stepping_point(THREAD,                          \
   1.146 +                                          istate->method(),                      \
   1.147 +                                          pc);                                   \
   1.148 +          RESET_LAST_JAVA_FRAME();                                               \
   1.149 +          CACHE_STATE();                                                         \
   1.150 +          if (THREAD->pop_frame_pending() &&                                     \
   1.151 +              !THREAD->pop_frame_in_process()) {                                 \
   1.152 +            goto handle_Pop_Frame;                                               \
   1.153 +          }                                                                      \
   1.154 +          opcode = *pc;                                                          \
   1.155 +        }                                                                        \
   1.156 +      }                                                                          \
   1.157 +}
   1.158 +#else
   1.159 +#define DEBUGGER_SINGLE_STEP_NOTIFY()
   1.160 +#endif
   1.161 +
   1.162 +/*
   1.163 + * CONTINUE - Macro for executing the next opcode.
   1.164 + */
   1.165 +#undef CONTINUE
   1.166 +#ifdef USELABELS
   1.167 +// Have to do this dispatch this way in C++ because otherwise gcc complains about crossing an
   1.168 +// initialization (which is is the initialization of the table pointer...)
   1.169 +#define DISPATCH(opcode) goto *dispatch_table[opcode]
   1.170 +#define CONTINUE {                              \
   1.171 +        opcode = *pc;                           \
   1.172 +        DO_UPDATE_INSTRUCTION_COUNT(opcode);    \
   1.173 +        DEBUGGER_SINGLE_STEP_NOTIFY();          \
   1.174 +        DISPATCH(opcode);                       \
   1.175 +    }
   1.176 +#else
   1.177 +#ifdef PREFETCH_OPCCODE
   1.178 +#define CONTINUE {                              \
   1.179 +        opcode = *pc;                           \
   1.180 +        DO_UPDATE_INSTRUCTION_COUNT(opcode);    \
   1.181 +        DEBUGGER_SINGLE_STEP_NOTIFY();          \
   1.182 +        continue;                               \
   1.183 +    }
   1.184 +#else
   1.185 +#define CONTINUE {                              \
   1.186 +        DO_UPDATE_INSTRUCTION_COUNT(opcode);    \
   1.187 +        DEBUGGER_SINGLE_STEP_NOTIFY();          \
   1.188 +        continue;                               \
   1.189 +    }
   1.190 +#endif
   1.191 +#endif
   1.192 +
   1.193 +// JavaStack Implementation
   1.194 +#define MORE_STACK(count)  \
   1.195 +    (topOfStack -= ((count) * Interpreter::stackElementWords()))
   1.196 +
   1.197 +
   1.198 +#define UPDATE_PC(opsize) {pc += opsize; }
   1.199 +/*
   1.200 + * UPDATE_PC_AND_TOS - Macro for updating the pc and topOfStack.
   1.201 + */
   1.202 +#undef UPDATE_PC_AND_TOS
   1.203 +#define UPDATE_PC_AND_TOS(opsize, stack) \
   1.204 +    {pc += opsize; MORE_STACK(stack); }
   1.205 +
   1.206 +/*
   1.207 + * UPDATE_PC_AND_TOS_AND_CONTINUE - Macro for updating the pc and topOfStack,
   1.208 + * and executing the next opcode. It's somewhat similar to the combination
   1.209 + * of UPDATE_PC_AND_TOS and CONTINUE, but with some minor optimizations.
   1.210 + */
   1.211 +#undef UPDATE_PC_AND_TOS_AND_CONTINUE
   1.212 +#ifdef USELABELS
   1.213 +#define UPDATE_PC_AND_TOS_AND_CONTINUE(opsize, stack) {         \
   1.214 +        pc += opsize; opcode = *pc; MORE_STACK(stack);          \
   1.215 +        DO_UPDATE_INSTRUCTION_COUNT(opcode);                    \
   1.216 +        DEBUGGER_SINGLE_STEP_NOTIFY();                          \
   1.217 +        DISPATCH(opcode);                                       \
   1.218 +    }
   1.219 +
   1.220 +#define UPDATE_PC_AND_CONTINUE(opsize) {                        \
   1.221 +        pc += opsize; opcode = *pc;                             \
   1.222 +        DO_UPDATE_INSTRUCTION_COUNT(opcode);                    \
   1.223 +        DEBUGGER_SINGLE_STEP_NOTIFY();                          \
   1.224 +        DISPATCH(opcode);                                       \
   1.225 +    }
   1.226 +#else
   1.227 +#ifdef PREFETCH_OPCCODE
   1.228 +#define UPDATE_PC_AND_TOS_AND_CONTINUE(opsize, stack) {         \
   1.229 +        pc += opsize; opcode = *pc; MORE_STACK(stack);          \
   1.230 +        DO_UPDATE_INSTRUCTION_COUNT(opcode);                    \
   1.231 +        DEBUGGER_SINGLE_STEP_NOTIFY();                          \
   1.232 +        goto do_continue;                                       \
   1.233 +    }
   1.234 +
   1.235 +#define UPDATE_PC_AND_CONTINUE(opsize) {                        \
   1.236 +        pc += opsize; opcode = *pc;                             \
   1.237 +        DO_UPDATE_INSTRUCTION_COUNT(opcode);                    \
   1.238 +        DEBUGGER_SINGLE_STEP_NOTIFY();                          \
   1.239 +        goto do_continue;                                       \
   1.240 +    }
   1.241 +#else
   1.242 +#define UPDATE_PC_AND_TOS_AND_CONTINUE(opsize, stack) { \
   1.243 +        pc += opsize; MORE_STACK(stack);                \
   1.244 +        DO_UPDATE_INSTRUCTION_COUNT(opcode);            \
   1.245 +        DEBUGGER_SINGLE_STEP_NOTIFY();                  \
   1.246 +        goto do_continue;                               \
   1.247 +    }
   1.248 +
   1.249 +#define UPDATE_PC_AND_CONTINUE(opsize) {                \
   1.250 +        pc += opsize;                                   \
   1.251 +        DO_UPDATE_INSTRUCTION_COUNT(opcode);            \
   1.252 +        DEBUGGER_SINGLE_STEP_NOTIFY();                  \
   1.253 +        goto do_continue;                               \
   1.254 +    }
   1.255 +#endif /* PREFETCH_OPCCODE */
   1.256 +#endif /* USELABELS */
   1.257 +
   1.258 +// About to call a new method, update the save the adjusted pc and return to frame manager
   1.259 +#define UPDATE_PC_AND_RETURN(opsize)  \
   1.260 +   DECACHE_TOS();                     \
   1.261 +   istate->set_bcp(pc+opsize);        \
   1.262 +   return;
   1.263 +
   1.264 +
   1.265 +#define METHOD istate->method()
   1.266 +#define INVOCATION_COUNT METHOD->invocation_counter()
   1.267 +#define BACKEDGE_COUNT METHOD->backedge_counter()
   1.268 +
   1.269 +
   1.270 +#define INCR_INVOCATION_COUNT INVOCATION_COUNT->increment()
   1.271 +#define OSR_REQUEST(res, branch_pc) \
   1.272 +            CALL_VM(res=InterpreterRuntime::frequency_counter_overflow(THREAD, branch_pc), handle_exception);
   1.273 +/*
   1.274 + * For those opcodes that need to have a GC point on a backwards branch
   1.275 + */
   1.276 +
   1.277 +// Backedge counting is kind of strange. The asm interpreter will increment
   1.278 +// the backedge counter as a separate counter but it does it's comparisons
   1.279 +// to the sum (scaled) of invocation counter and backedge count to make
   1.280 +// a decision. Seems kind of odd to sum them together like that
   1.281 +
   1.282 +// skip is delta from current bcp/bci for target, branch_pc is pre-branch bcp
   1.283 +
   1.284 +
   1.285 +#define DO_BACKEDGE_CHECKS(skip, branch_pc)                                                         \
   1.286 +    if ((skip) <= 0) {                                                                              \
   1.287 +      if (UseCompiler && UseLoopCounter) {                                                          \
   1.288 +        bool do_OSR = UseOnStackReplacement;                                                        \
   1.289 +        BACKEDGE_COUNT->increment();                                                                \
   1.290 +        if (do_OSR) do_OSR = BACKEDGE_COUNT->reached_InvocationLimit();                             \
   1.291 +        if (do_OSR) {                                                                               \
   1.292 +          nmethod*  osr_nmethod;                                                                    \
   1.293 +          OSR_REQUEST(osr_nmethod, branch_pc);                                                      \
   1.294 +          if (osr_nmethod != NULL && osr_nmethod->osr_entry_bci() != InvalidOSREntryBci) {          \
   1.295 +            intptr_t* buf;                                                                          \
   1.296 +            CALL_VM(buf=SharedRuntime::OSR_migration_begin(THREAD), handle_exception);              \
   1.297 +            istate->set_msg(do_osr);                                                                \
   1.298 +            istate->set_osr_buf((address)buf);                                                      \
   1.299 +            istate->set_osr_entry(osr_nmethod->osr_entry());                                        \
   1.300 +            return;                                                                                 \
   1.301 +          }                                                                                         \
   1.302 +        } else {                                                                                    \
   1.303 +          INCR_INVOCATION_COUNT;                                                                    \
   1.304 +          SAFEPOINT;                                                                                \
   1.305 +        }                                                                                           \
   1.306 +      }  /* UseCompiler ... */                                                                      \
   1.307 +      INCR_INVOCATION_COUNT;                                                                        \
   1.308 +      SAFEPOINT;                                                                                    \
   1.309 +    }
   1.310 +
   1.311 +/*
   1.312 + * For those opcodes that need to have a GC point on a backwards branch
   1.313 + */
   1.314 +
   1.315 +/*
   1.316 + * Macros for caching and flushing the interpreter state. Some local
   1.317 + * variables need to be flushed out to the frame before we do certain
   1.318 + * things (like pushing frames or becomming gc safe) and some need to
   1.319 + * be recached later (like after popping a frame). We could use one
   1.320 + * macro to cache or decache everything, but this would be less then
   1.321 + * optimal because we don't always need to cache or decache everything
   1.322 + * because some things we know are already cached or decached.
   1.323 + */
   1.324 +#undef DECACHE_TOS
   1.325 +#undef CACHE_TOS
   1.326 +#undef CACHE_PREV_TOS
   1.327 +#define DECACHE_TOS()    istate->set_stack(topOfStack);
   1.328 +
   1.329 +#define CACHE_TOS()      topOfStack = (intptr_t *)istate->stack();
   1.330 +
   1.331 +#undef DECACHE_PC
   1.332 +#undef CACHE_PC
   1.333 +#define DECACHE_PC()    istate->set_bcp(pc);
   1.334 +#define CACHE_PC()      pc = istate->bcp();
   1.335 +#define CACHE_CP()      cp = istate->constants();
   1.336 +#define CACHE_LOCALS()  locals = istate->locals();
   1.337 +#undef CACHE_FRAME
   1.338 +#define CACHE_FRAME()
   1.339 +
   1.340 +/*
   1.341 + * CHECK_NULL - Macro for throwing a NullPointerException if the object
   1.342 + * passed is a null ref.
   1.343 + * On some architectures/platforms it should be possible to do this implicitly
   1.344 + */
   1.345 +#undef CHECK_NULL
   1.346 +#define CHECK_NULL(obj_)                                                 \
   1.347 +    if ((obj_) == 0) {                                                   \
   1.348 +        VM_JAVA_ERROR(vmSymbols::java_lang_NullPointerException(), "");  \
   1.349 +    }
   1.350 +
   1.351 +#define VMdoubleConstZero() 0.0
   1.352 +#define VMdoubleConstOne() 1.0
   1.353 +#define VMlongConstZero() (max_jlong-max_jlong)
   1.354 +#define VMlongConstOne() ((max_jlong-max_jlong)+1)
   1.355 +
   1.356 +/*
   1.357 + * Alignment
   1.358 + */
   1.359 +#define VMalignWordUp(val)          (((uintptr_t)(val) + 3) & ~3)
   1.360 +
   1.361 +// Decache the interpreter state that interpreter modifies directly (i.e. GC is indirect mod)
   1.362 +#define DECACHE_STATE() DECACHE_PC(); DECACHE_TOS();
   1.363 +
   1.364 +// Reload interpreter state after calling the VM or a possible GC
   1.365 +#define CACHE_STATE()   \
   1.366 +        CACHE_TOS();    \
   1.367 +        CACHE_PC();     \
   1.368 +        CACHE_CP();     \
   1.369 +        CACHE_LOCALS();
   1.370 +
   1.371 +// Call the VM don't check for pending exceptions
   1.372 +#define CALL_VM_NOCHECK(func)                                     \
   1.373 +          DECACHE_STATE();                                        \
   1.374 +          SET_LAST_JAVA_FRAME();                                  \
   1.375 +          func;                                                   \
   1.376 +          RESET_LAST_JAVA_FRAME();                                \
   1.377 +          CACHE_STATE();                                          \
   1.378 +          if (THREAD->pop_frame_pending() &&                      \
   1.379 +              !THREAD->pop_frame_in_process()) {                  \
   1.380 +            goto handle_Pop_Frame;                                \
   1.381 +          }
   1.382 +
   1.383 +// Call the VM and check for pending exceptions
   1.384 +#define CALL_VM(func, label) {                                    \
   1.385 +          CALL_VM_NOCHECK(func);                                  \
   1.386 +          if (THREAD->has_pending_exception()) goto label;        \
   1.387 +        }
   1.388 +
   1.389 +/*
   1.390 + * BytecodeInterpreter::run(interpreterState istate)
   1.391 + * BytecodeInterpreter::runWithChecks(interpreterState istate)
   1.392 + *
   1.393 + * The real deal. This is where byte codes actually get interpreted.
   1.394 + * Basically it's a big while loop that iterates until we return from
   1.395 + * the method passed in.
   1.396 + *
   1.397 + * The runWithChecks is used if JVMTI is enabled.
   1.398 + *
   1.399 + */
   1.400 +#if defined(VM_JVMTI)
   1.401 +void
   1.402 +BytecodeInterpreter::runWithChecks(interpreterState istate) {
   1.403 +#else
   1.404 +void
   1.405 +BytecodeInterpreter::run(interpreterState istate) {
   1.406 +#endif
   1.407 +
   1.408 +  // In order to simplify some tests based on switches set at runtime
   1.409 +  // we invoke the interpreter a single time after switches are enabled
   1.410 +  // and set simpler to to test variables rather than method calls or complex
   1.411 +  // boolean expressions.
   1.412 +
   1.413 +  static int initialized = 0;
   1.414 +  static int checkit = 0;
   1.415 +  static intptr_t* c_addr = NULL;
   1.416 +  static intptr_t  c_value;
   1.417 +
   1.418 +  if (checkit && *c_addr != c_value) {
   1.419 +    os::breakpoint();
   1.420 +  }
   1.421 +#ifdef VM_JVMTI
   1.422 +  static bool _jvmti_interp_events = 0;
   1.423 +#endif
   1.424 +
   1.425 +  static int _compiling;  // (UseCompiler || CountCompiledCalls)
   1.426 +
   1.427 +#ifdef ASSERT
   1.428 +  if (istate->_msg != initialize) {
   1.429 +    assert(abs(istate->_stack_base - istate->_stack_limit) == (istate->_method->max_stack() + 1), "bad stack limit");
   1.430 +  IA32_ONLY(assert(istate->_stack_limit == istate->_thread->last_Java_sp() + 1, "wrong"));
   1.431 +  }
   1.432 +  // Verify linkages.
   1.433 +  interpreterState l = istate;
   1.434 +  do {
   1.435 +    assert(l == l->_self_link, "bad link");
   1.436 +    l = l->_prev_link;
   1.437 +  } while (l != NULL);
   1.438 +  // Screwups with stack management usually cause us to overwrite istate
   1.439 +  // save a copy so we can verify it.
   1.440 +  interpreterState orig = istate;
   1.441 +#endif
   1.442 +
   1.443 +  static volatile jbyte* _byte_map_base; // adjusted card table base for oop store barrier
   1.444 +
   1.445 +  register intptr_t*        topOfStack = (intptr_t *)istate->stack(); /* access with STACK macros */
   1.446 +  register address          pc = istate->bcp();
   1.447 +  register jubyte opcode;
   1.448 +  register intptr_t*        locals = istate->locals();
   1.449 +  register constantPoolCacheOop  cp = istate->constants(); // method()->constants()->cache()
   1.450 +#ifdef LOTS_OF_REGS
   1.451 +  register JavaThread*      THREAD = istate->thread();
   1.452 +  register volatile jbyte*  BYTE_MAP_BASE = _byte_map_base;
   1.453 +#else
   1.454 +#undef THREAD
   1.455 +#define THREAD istate->thread()
   1.456 +#undef BYTE_MAP_BASE
   1.457 +#define BYTE_MAP_BASE _byte_map_base
   1.458 +#endif
   1.459 +
   1.460 +#ifdef USELABELS
   1.461 +  const static void* const opclabels_data[256] = {
   1.462 +/* 0x00 */ &&opc_nop,     &&opc_aconst_null,&&opc_iconst_m1,&&opc_iconst_0,
   1.463 +/* 0x04 */ &&opc_iconst_1,&&opc_iconst_2,   &&opc_iconst_3, &&opc_iconst_4,
   1.464 +/* 0x08 */ &&opc_iconst_5,&&opc_lconst_0,   &&opc_lconst_1, &&opc_fconst_0,
   1.465 +/* 0x0C */ &&opc_fconst_1,&&opc_fconst_2,   &&opc_dconst_0, &&opc_dconst_1,
   1.466 +
   1.467 +/* 0x10 */ &&opc_bipush, &&opc_sipush, &&opc_ldc,    &&opc_ldc_w,
   1.468 +/* 0x14 */ &&opc_ldc2_w, &&opc_iload,  &&opc_lload,  &&opc_fload,
   1.469 +/* 0x18 */ &&opc_dload,  &&opc_aload,  &&opc_iload_0,&&opc_iload_1,
   1.470 +/* 0x1C */ &&opc_iload_2,&&opc_iload_3,&&opc_lload_0,&&opc_lload_1,
   1.471 +
   1.472 +/* 0x20 */ &&opc_lload_2,&&opc_lload_3,&&opc_fload_0,&&opc_fload_1,
   1.473 +/* 0x24 */ &&opc_fload_2,&&opc_fload_3,&&opc_dload_0,&&opc_dload_1,
   1.474 +/* 0x28 */ &&opc_dload_2,&&opc_dload_3,&&opc_aload_0,&&opc_aload_1,
   1.475 +/* 0x2C */ &&opc_aload_2,&&opc_aload_3,&&opc_iaload, &&opc_laload,
   1.476 +
   1.477 +/* 0x30 */ &&opc_faload,  &&opc_daload,  &&opc_aaload,  &&opc_baload,
   1.478 +/* 0x34 */ &&opc_caload,  &&opc_saload,  &&opc_istore,  &&opc_lstore,
   1.479 +/* 0x38 */ &&opc_fstore,  &&opc_dstore,  &&opc_astore,  &&opc_istore_0,
   1.480 +/* 0x3C */ &&opc_istore_1,&&opc_istore_2,&&opc_istore_3,&&opc_lstore_0,
   1.481 +
   1.482 +/* 0x40 */ &&opc_lstore_1,&&opc_lstore_2,&&opc_lstore_3,&&opc_fstore_0,
   1.483 +/* 0x44 */ &&opc_fstore_1,&&opc_fstore_2,&&opc_fstore_3,&&opc_dstore_0,
   1.484 +/* 0x48 */ &&opc_dstore_1,&&opc_dstore_2,&&opc_dstore_3,&&opc_astore_0,
   1.485 +/* 0x4C */ &&opc_astore_1,&&opc_astore_2,&&opc_astore_3,&&opc_iastore,
   1.486 +
   1.487 +/* 0x50 */ &&opc_lastore,&&opc_fastore,&&opc_dastore,&&opc_aastore,
   1.488 +/* 0x54 */ &&opc_bastore,&&opc_castore,&&opc_sastore,&&opc_pop,
   1.489 +/* 0x58 */ &&opc_pop2,   &&opc_dup,    &&opc_dup_x1, &&opc_dup_x2,
   1.490 +/* 0x5C */ &&opc_dup2,   &&opc_dup2_x1,&&opc_dup2_x2,&&opc_swap,
   1.491 +
   1.492 +/* 0x60 */ &&opc_iadd,&&opc_ladd,&&opc_fadd,&&opc_dadd,
   1.493 +/* 0x64 */ &&opc_isub,&&opc_lsub,&&opc_fsub,&&opc_dsub,
   1.494 +/* 0x68 */ &&opc_imul,&&opc_lmul,&&opc_fmul,&&opc_dmul,
   1.495 +/* 0x6C */ &&opc_idiv,&&opc_ldiv,&&opc_fdiv,&&opc_ddiv,
   1.496 +
   1.497 +/* 0x70 */ &&opc_irem, &&opc_lrem, &&opc_frem,&&opc_drem,
   1.498 +/* 0x74 */ &&opc_ineg, &&opc_lneg, &&opc_fneg,&&opc_dneg,
   1.499 +/* 0x78 */ &&opc_ishl, &&opc_lshl, &&opc_ishr,&&opc_lshr,
   1.500 +/* 0x7C */ &&opc_iushr,&&opc_lushr,&&opc_iand,&&opc_land,
   1.501 +
   1.502 +/* 0x80 */ &&opc_ior, &&opc_lor,&&opc_ixor,&&opc_lxor,
   1.503 +/* 0x84 */ &&opc_iinc,&&opc_i2l,&&opc_i2f, &&opc_i2d,
   1.504 +/* 0x88 */ &&opc_l2i, &&opc_l2f,&&opc_l2d, &&opc_f2i,
   1.505 +/* 0x8C */ &&opc_f2l, &&opc_f2d,&&opc_d2i, &&opc_d2l,
   1.506 +
   1.507 +/* 0x90 */ &&opc_d2f,  &&opc_i2b,  &&opc_i2c,  &&opc_i2s,
   1.508 +/* 0x94 */ &&opc_lcmp, &&opc_fcmpl,&&opc_fcmpg,&&opc_dcmpl,
   1.509 +/* 0x98 */ &&opc_dcmpg,&&opc_ifeq, &&opc_ifne, &&opc_iflt,
   1.510 +/* 0x9C */ &&opc_ifge, &&opc_ifgt, &&opc_ifle, &&opc_if_icmpeq,
   1.511 +
   1.512 +/* 0xA0 */ &&opc_if_icmpne,&&opc_if_icmplt,&&opc_if_icmpge,  &&opc_if_icmpgt,
   1.513 +/* 0xA4 */ &&opc_if_icmple,&&opc_if_acmpeq,&&opc_if_acmpne,  &&opc_goto,
   1.514 +/* 0xA8 */ &&opc_jsr,      &&opc_ret,      &&opc_tableswitch,&&opc_lookupswitch,
   1.515 +/* 0xAC */ &&opc_ireturn,  &&opc_lreturn,  &&opc_freturn,    &&opc_dreturn,
   1.516 +
   1.517 +/* 0xB0 */ &&opc_areturn,     &&opc_return,         &&opc_getstatic,    &&opc_putstatic,
   1.518 +/* 0xB4 */ &&opc_getfield,    &&opc_putfield,       &&opc_invokevirtual,&&opc_invokespecial,
   1.519 +/* 0xB8 */ &&opc_invokestatic,&&opc_invokeinterface,NULL,               &&opc_new,
   1.520 +/* 0xBC */ &&opc_newarray,    &&opc_anewarray,      &&opc_arraylength,  &&opc_athrow,
   1.521 +
   1.522 +/* 0xC0 */ &&opc_checkcast,   &&opc_instanceof,     &&opc_monitorenter, &&opc_monitorexit,
   1.523 +/* 0xC4 */ &&opc_wide,        &&opc_multianewarray, &&opc_ifnull,       &&opc_ifnonnull,
   1.524 +/* 0xC8 */ &&opc_goto_w,      &&opc_jsr_w,          &&opc_breakpoint,   &&opc_fast_igetfield,
   1.525 +/* 0xCC */ &&opc_fastagetfield,&&opc_fast_aload_0,  &&opc_fast_iaccess_0, &&opc__fast_aaccess_0,
   1.526 +
   1.527 +/* 0xD0 */ &&opc_fast_linearswitch, &&opc_fast_binaryswitch, &&opc_return_register_finalizer,      &&opc_default,
   1.528 +/* 0xD4 */ &&opc_default,     &&opc_default,        &&opc_default,      &&opc_default,
   1.529 +/* 0xD8 */ &&opc_default,     &&opc_default,        &&opc_default,      &&opc_default,
   1.530 +/* 0xDC */ &&opc_default,     &&opc_default,        &&opc_default,      &&opc_default,
   1.531 +
   1.532 +/* 0xE0 */ &&opc_default,     &&opc_default,        &&opc_default,      &&opc_default,
   1.533 +/* 0xE4 */ &&opc_default,     &&opc_default,        &&opc_default,      &&opc_default,
   1.534 +/* 0xE8 */ &&opc_default,     &&opc_default,        &&opc_default,      &&opc_default,
   1.535 +/* 0xEC */ &&opc_default,     &&opc_default,        &&opc_default,      &&opc_default,
   1.536 +
   1.537 +/* 0xF0 */ &&opc_default,     &&opc_default,        &&opc_default,      &&opc_default,
   1.538 +/* 0xF4 */ &&opc_default,     &&opc_default,        &&opc_default,      &&opc_default,
   1.539 +/* 0xF8 */ &&opc_default,     &&opc_default,        &&opc_default,      &&opc_default,
   1.540 +/* 0xFC */ &&opc_default,     &&opc_default,        &&opc_default,      &&opc_default
   1.541 +  };
   1.542 +  register uintptr_t *dispatch_table = (uintptr_t*)&opclabels_data[0];
   1.543 +#endif /* USELABELS */
   1.544 +
   1.545 +#ifdef ASSERT
   1.546 +  // this will trigger a VERIFY_OOP on entry
   1.547 +  if (istate->msg() != initialize && ! METHOD->is_static()) {
   1.548 +    oop rcvr = LOCALS_OBJECT(0);
   1.549 +  }
   1.550 +#endif
   1.551 +// #define HACK
   1.552 +#ifdef HACK
   1.553 +  bool interesting = false;
   1.554 +#endif // HACK
   1.555 +
   1.556 +  /* QQQ this should be a stack method so we don't know actual direction */
   1.557 +  assert(istate->msg() == initialize ||
   1.558 +         topOfStack >= istate->stack_limit() &&
   1.559 +         topOfStack < istate->stack_base(),
   1.560 +         "Stack top out of range");
   1.561 +
   1.562 +  switch (istate->msg()) {
   1.563 +    case initialize: {
   1.564 +      if (initialized++) ShouldNotReachHere(); // Only one initialize call
   1.565 +      _compiling = (UseCompiler || CountCompiledCalls);
   1.566 +#ifdef VM_JVMTI
   1.567 +      _jvmti_interp_events = JvmtiExport::can_post_interpreter_events();
   1.568 +#endif
   1.569 +      BarrierSet* bs = Universe::heap()->barrier_set();
   1.570 +      assert(bs->kind() == BarrierSet::CardTableModRef, "Wrong barrier set kind");
   1.571 +      _byte_map_base = (volatile jbyte*)(((CardTableModRefBS*)bs)->byte_map_base);
   1.572 +      return;
   1.573 +    }
   1.574 +    break;
   1.575 +    case method_entry: {
   1.576 +      THREAD->set_do_not_unlock();
   1.577 +      // count invocations
   1.578 +      assert(initialized, "Interpreter not initialized");
   1.579 +      if (_compiling) {
   1.580 +        if (ProfileInterpreter) {
   1.581 +          METHOD->increment_interpreter_invocation_count();
   1.582 +        }
   1.583 +        INCR_INVOCATION_COUNT;
   1.584 +        if (INVOCATION_COUNT->reached_InvocationLimit()) {
   1.585 +            CALL_VM((void)InterpreterRuntime::frequency_counter_overflow(THREAD, NULL), handle_exception);
   1.586 +
   1.587 +            // We no longer retry on a counter overflow
   1.588 +
   1.589 +            // istate->set_msg(retry_method);
   1.590 +            // THREAD->clr_do_not_unlock();
   1.591 +            // return;
   1.592 +        }
   1.593 +        SAFEPOINT;
   1.594 +      }
   1.595 +
   1.596 +      if ((istate->_stack_base - istate->_stack_limit) != istate->method()->max_stack() + 1) {
   1.597 +        // initialize
   1.598 +        os::breakpoint();
   1.599 +      }
   1.600 +
   1.601 +#ifdef HACK
   1.602 +      {
   1.603 +        ResourceMark rm;
   1.604 +        char *method_name = istate->method()->name_and_sig_as_C_string();
   1.605 +        if (strstr(method_name, "runThese$TestRunner.run()V") != NULL) {
   1.606 +          tty->print_cr("entering: depth %d bci: %d",
   1.607 +                         (istate->_stack_base - istate->_stack),
   1.608 +                         istate->_bcp - istate->_method->code_base());
   1.609 +          interesting = true;
   1.610 +        }
   1.611 +      }
   1.612 +#endif // HACK
   1.613 +
   1.614 +
   1.615 +      // lock method if synchronized
   1.616 +      if (METHOD->is_synchronized()) {
   1.617 +          // oop rcvr = locals[0].j.r;
   1.618 +          oop rcvr;
   1.619 +          if (METHOD->is_static()) {
   1.620 +            rcvr = METHOD->constants()->pool_holder()->klass_part()->java_mirror();
   1.621 +          } else {
   1.622 +            rcvr = LOCALS_OBJECT(0);
   1.623 +          }
   1.624 +          // The initial monitor is ours for the taking
   1.625 +          BasicObjectLock* mon = &istate->monitor_base()[-1];
   1.626 +          oop monobj = mon->obj();
   1.627 +          assert(mon->obj() == rcvr, "method monitor mis-initialized");
   1.628 +
   1.629 +          bool success = UseBiasedLocking;
   1.630 +          if (UseBiasedLocking) {
   1.631 +            markOop mark = rcvr->mark();
   1.632 +            if (mark->has_bias_pattern()) {
   1.633 +              // The bias pattern is present in the object's header. Need to check
   1.634 +              // whether the bias owner and the epoch are both still current.
   1.635 +              intptr_t xx = ((intptr_t) THREAD) ^ (intptr_t) mark;
   1.636 +              xx = (intptr_t) rcvr->klass()->klass_part()->prototype_header() ^ xx;
   1.637 +              intptr_t yy = (xx & ~((int) markOopDesc::age_mask_in_place));
   1.638 +              if (yy != 0 ) {
   1.639 +                // At this point we know that the header has the bias pattern and
   1.640 +                // that we are not the bias owner in the current epoch. We need to
   1.641 +                // figure out more details about the state of the header in order to
   1.642 +                // know what operations can be legally performed on the object's
   1.643 +                // header.
   1.644 +
   1.645 +                // If the low three bits in the xor result aren't clear, that means
   1.646 +                // the prototype header is no longer biased and we have to revoke
   1.647 +                // the bias on this object.
   1.648 +
   1.649 +                if (yy & markOopDesc::biased_lock_mask_in_place == 0 ) {
   1.650 +                  // Biasing is still enabled for this data type. See whether the
   1.651 +                  // epoch of the current bias is still valid, meaning that the epoch
   1.652 +                  // bits of the mark word are equal to the epoch bits of the
   1.653 +                  // prototype header. (Note that the prototype header's epoch bits
   1.654 +                  // only change at a safepoint.) If not, attempt to rebias the object
   1.655 +                  // toward the current thread. Note that we must be absolutely sure
   1.656 +                  // that the current epoch is invalid in order to do this because
   1.657 +                  // otherwise the manipulations it performs on the mark word are
   1.658 +                  // illegal.
   1.659 +                  if (yy & markOopDesc::epoch_mask_in_place == 0) {
   1.660 +                    // The epoch of the current bias is still valid but we know nothing
   1.661 +                    // about the owner; it might be set or it might be clear. Try to
   1.662 +                    // acquire the bias of the object using an atomic operation. If this
   1.663 +                    // fails we will go in to the runtime to revoke the object's bias.
   1.664 +                    // Note that we first construct the presumed unbiased header so we
   1.665 +                    // don't accidentally blow away another thread's valid bias.
   1.666 +                    intptr_t unbiased = (intptr_t) mark & (markOopDesc::biased_lock_mask_in_place |
   1.667 +                                                           markOopDesc::age_mask_in_place |
   1.668 +                                                           markOopDesc::epoch_mask_in_place);
   1.669 +                    if (Atomic::cmpxchg_ptr((intptr_t)THREAD | unbiased, (intptr_t*) rcvr->mark_addr(), unbiased) != unbiased) {
   1.670 +                      CALL_VM(InterpreterRuntime::monitorenter(THREAD, mon), handle_exception);
   1.671 +                    }
   1.672 +                  } else {
   1.673 +                    try_rebias:
   1.674 +                    // At this point we know the epoch has expired, meaning that the
   1.675 +                    // current "bias owner", if any, is actually invalid. Under these
   1.676 +                    // circumstances _only_, we are allowed to use the current header's
   1.677 +                    // value as the comparison value when doing the cas to acquire the
   1.678 +                    // bias in the current epoch. In other words, we allow transfer of
   1.679 +                    // the bias from one thread to another directly in this situation.
   1.680 +                    xx = (intptr_t) rcvr->klass()->klass_part()->prototype_header() | (intptr_t) THREAD;
   1.681 +                    if (Atomic::cmpxchg_ptr((intptr_t)THREAD | (intptr_t) rcvr->klass()->klass_part()->prototype_header(),
   1.682 +                                            (intptr_t*) rcvr->mark_addr(),
   1.683 +                                            (intptr_t) mark) != (intptr_t) mark) {
   1.684 +                      CALL_VM(InterpreterRuntime::monitorenter(THREAD, mon), handle_exception);
   1.685 +                    }
   1.686 +                  }
   1.687 +                } else {
   1.688 +                  try_revoke_bias:
   1.689 +                  // The prototype mark in the klass doesn't have the bias bit set any
   1.690 +                  // more, indicating that objects of this data type are not supposed
   1.691 +                  // to be biased any more. We are going to try to reset the mark of
   1.692 +                  // this object to the prototype value and fall through to the
   1.693 +                  // CAS-based locking scheme. Note that if our CAS fails, it means
   1.694 +                  // that another thread raced us for the privilege of revoking the
   1.695 +                  // bias of this particular object, so it's okay to continue in the
   1.696 +                  // normal locking code.
   1.697 +                  //
   1.698 +                  xx = (intptr_t) rcvr->klass()->klass_part()->prototype_header() | (intptr_t) THREAD;
   1.699 +                  if (Atomic::cmpxchg_ptr(rcvr->klass()->klass_part()->prototype_header(),
   1.700 +                                          (intptr_t*) rcvr->mark_addr(),
   1.701 +                                          mark) == mark) {
   1.702 +                    // (*counters->revoked_lock_entry_count_addr())++;
   1.703 +                  success = false;
   1.704 +                  }
   1.705 +                }
   1.706 +              }
   1.707 +            } else {
   1.708 +              cas_label:
   1.709 +              success = false;
   1.710 +            }
   1.711 +          }
   1.712 +          if (!success) {
   1.713 +            markOop displaced = rcvr->mark()->set_unlocked();
   1.714 +            mon->lock()->set_displaced_header(displaced);
   1.715 +            if (Atomic::cmpxchg_ptr(mon, rcvr->mark_addr(), displaced) != displaced) {
   1.716 +              // Is it simple recursive case?
   1.717 +              if (THREAD->is_lock_owned((address) displaced->clear_lock_bits())) {
   1.718 +                mon->lock()->set_displaced_header(NULL);
   1.719 +              } else {
   1.720 +                CALL_VM(InterpreterRuntime::monitorenter(THREAD, mon), handle_exception);
   1.721 +              }
   1.722 +            }
   1.723 +          }
   1.724 +      }
   1.725 +      THREAD->clr_do_not_unlock();
   1.726 +
   1.727 +      // Notify jvmti
   1.728 +#ifdef VM_JVMTI
   1.729 +      if (_jvmti_interp_events) {
   1.730 +        // Whenever JVMTI puts a thread in interp_only_mode, method
   1.731 +        // entry/exit events are sent for that thread to track stack depth.
   1.732 +        if (THREAD->is_interp_only_mode()) {
   1.733 +          CALL_VM(InterpreterRuntime::post_method_entry(THREAD),
   1.734 +                  handle_exception);
   1.735 +        }
   1.736 +      }
   1.737 +#endif /* VM_JVMTI */
   1.738 +
   1.739 +      goto run;
   1.740 +    }
   1.741 +
   1.742 +    case popping_frame: {
   1.743 +      // returned from a java call to pop the frame, restart the call
   1.744 +      // clear the message so we don't confuse ourselves later
   1.745 +      assert(THREAD->pop_frame_in_process(), "wrong frame pop state");
   1.746 +      istate->set_msg(no_request);
   1.747 +      THREAD->clr_pop_frame_in_process();
   1.748 +      goto run;
   1.749 +    }
   1.750 +
   1.751 +    case method_resume: {
   1.752 +      if ((istate->_stack_base - istate->_stack_limit) != istate->method()->max_stack() + 1) {
   1.753 +        // resume
   1.754 +        os::breakpoint();
   1.755 +      }
   1.756 +#ifdef HACK
   1.757 +      {
   1.758 +        ResourceMark rm;
   1.759 +        char *method_name = istate->method()->name_and_sig_as_C_string();
   1.760 +        if (strstr(method_name, "runThese$TestRunner.run()V") != NULL) {
   1.761 +          tty->print_cr("resume: depth %d bci: %d",
   1.762 +                         (istate->_stack_base - istate->_stack) ,
   1.763 +                         istate->_bcp - istate->_method->code_base());
   1.764 +          interesting = true;
   1.765 +        }
   1.766 +      }
   1.767 +#endif // HACK
   1.768 +      // returned from a java call, continue executing.
   1.769 +      if (THREAD->pop_frame_pending() && !THREAD->pop_frame_in_process()) {
   1.770 +        goto handle_Pop_Frame;
   1.771 +      }
   1.772 +
   1.773 +      if (THREAD->has_pending_exception()) goto handle_exception;
   1.774 +      // Update the pc by the saved amount of the invoke bytecode size
   1.775 +      UPDATE_PC(istate->bcp_advance());
   1.776 +      goto run;
   1.777 +    }
   1.778 +
   1.779 +    case deopt_resume2: {
   1.780 +      // Returned from an opcode that will reexecute. Deopt was
   1.781 +      // a result of a PopFrame request.
   1.782 +      //
   1.783 +      goto run;
   1.784 +    }
   1.785 +
   1.786 +    case deopt_resume: {
   1.787 +      // Returned from an opcode that has completed. The stack has
   1.788 +      // the result all we need to do is skip across the bytecode
   1.789 +      // and continue (assuming there is no exception pending)
   1.790 +      //
   1.791 +      // compute continuation length
   1.792 +      //
   1.793 +      // Note: it is possible to deopt at a return_register_finalizer opcode
   1.794 +      // because this requires entering the vm to do the registering. While the
   1.795 +      // opcode is complete we can't advance because there are no more opcodes
   1.796 +      // much like trying to deopt at a poll return. In that has we simply
   1.797 +      // get out of here
   1.798 +      //
   1.799 +      if ( Bytecodes::code_at(pc, METHOD) == Bytecodes::_return_register_finalizer) {
   1.800 +        // this will do the right thing even if an exception is pending.
   1.801 +        goto handle_return;
   1.802 +      }
   1.803 +      UPDATE_PC(Bytecodes::length_at(pc));
   1.804 +      if (THREAD->has_pending_exception()) goto handle_exception;
   1.805 +      goto run;
   1.806 +    }
   1.807 +    case got_monitors: {
   1.808 +      // continue locking now that we have a monitor to use
   1.809 +      // we expect to find newly allocated monitor at the "top" of the monitor stack.
   1.810 +      oop lockee = STACK_OBJECT(-1);
   1.811 +      // derefing's lockee ought to provoke implicit null check
   1.812 +      // find a free monitor
   1.813 +      BasicObjectLock* entry = (BasicObjectLock*) istate->stack_base();
   1.814 +      assert(entry->obj() == NULL, "Frame manager didn't allocate the monitor");
   1.815 +      entry->set_obj(lockee);
   1.816 +
   1.817 +      markOop displaced = lockee->mark()->set_unlocked();
   1.818 +      entry->lock()->set_displaced_header(displaced);
   1.819 +      if (Atomic::cmpxchg_ptr(entry, lockee->mark_addr(), displaced) != displaced) {
   1.820 +        // Is it simple recursive case?
   1.821 +        if (THREAD->is_lock_owned((address) displaced->clear_lock_bits())) {
   1.822 +          entry->lock()->set_displaced_header(NULL);
   1.823 +        } else {
   1.824 +          CALL_VM(InterpreterRuntime::monitorenter(THREAD, entry), handle_exception);
   1.825 +        }
   1.826 +      }
   1.827 +      UPDATE_PC_AND_TOS(1, -1);
   1.828 +      goto run;
   1.829 +    }
   1.830 +    default: {
   1.831 +      fatal("Unexpected message from frame manager");
   1.832 +    }
   1.833 +  }
   1.834 +
   1.835 +run:
   1.836 +
   1.837 +  DO_UPDATE_INSTRUCTION_COUNT(*pc)
   1.838 +  DEBUGGER_SINGLE_STEP_NOTIFY();
   1.839 +#ifdef PREFETCH_OPCCODE
   1.840 +  opcode = *pc;  /* prefetch first opcode */
   1.841 +#endif
   1.842 +
   1.843 +#ifndef USELABELS
   1.844 +  while (1)
   1.845 +#endif
   1.846 +  {
   1.847 +#ifndef PREFETCH_OPCCODE
   1.848 +      opcode = *pc;
   1.849 +#endif
   1.850 +      // Seems like this happens twice per opcode. At worst this is only
   1.851 +      // need at entry to the loop.
   1.852 +      // DEBUGGER_SINGLE_STEP_NOTIFY();
   1.853 +      /* Using this labels avoids double breakpoints when quickening and
   1.854 +       * when returing from transition frames.
   1.855 +       */
   1.856 +  opcode_switch:
   1.857 +      assert(istate == orig, "Corrupted istate");
   1.858 +      /* QQQ Hmm this has knowledge of direction, ought to be a stack method */
   1.859 +      assert(topOfStack >= istate->stack_limit(), "Stack overrun");
   1.860 +      assert(topOfStack < istate->stack_base(), "Stack underrun");
   1.861 +
   1.862 +#ifdef USELABELS
   1.863 +      DISPATCH(opcode);
   1.864 +#else
   1.865 +      switch (opcode)
   1.866 +#endif
   1.867 +      {
   1.868 +      CASE(_nop):
   1.869 +          UPDATE_PC_AND_CONTINUE(1);
   1.870 +
   1.871 +          /* Push miscellaneous constants onto the stack. */
   1.872 +
   1.873 +      CASE(_aconst_null):
   1.874 +          SET_STACK_OBJECT(NULL, 0);
   1.875 +          UPDATE_PC_AND_TOS_AND_CONTINUE(1, 1);
   1.876 +
   1.877 +#undef  OPC_CONST_n
   1.878 +#define OPC_CONST_n(opcode, const_type, value)                          \
   1.879 +      CASE(opcode):                                                     \
   1.880 +          SET_STACK_ ## const_type(value, 0);                           \
   1.881 +          UPDATE_PC_AND_TOS_AND_CONTINUE(1, 1);
   1.882 +
   1.883 +          OPC_CONST_n(_iconst_m1,   INT,       -1);
   1.884 +          OPC_CONST_n(_iconst_0,    INT,        0);
   1.885 +          OPC_CONST_n(_iconst_1,    INT,        1);
   1.886 +          OPC_CONST_n(_iconst_2,    INT,        2);
   1.887 +          OPC_CONST_n(_iconst_3,    INT,        3);
   1.888 +          OPC_CONST_n(_iconst_4,    INT,        4);
   1.889 +          OPC_CONST_n(_iconst_5,    INT,        5);
   1.890 +          OPC_CONST_n(_fconst_0,    FLOAT,      0.0);
   1.891 +          OPC_CONST_n(_fconst_1,    FLOAT,      1.0);
   1.892 +          OPC_CONST_n(_fconst_2,    FLOAT,      2.0);
   1.893 +
   1.894 +#undef  OPC_CONST2_n
   1.895 +#define OPC_CONST2_n(opcname, value, key, kind)                         \
   1.896 +      CASE(_##opcname):                                                 \
   1.897 +      {                                                                 \
   1.898 +          SET_STACK_ ## kind(VM##key##Const##value(), 1);               \
   1.899 +          UPDATE_PC_AND_TOS_AND_CONTINUE(1, 2);                         \
   1.900 +      }
   1.901 +         OPC_CONST2_n(dconst_0, Zero, double, DOUBLE);
   1.902 +         OPC_CONST2_n(dconst_1, One,  double, DOUBLE);
   1.903 +         OPC_CONST2_n(lconst_0, Zero, long, LONG);
   1.904 +         OPC_CONST2_n(lconst_1, One,  long, LONG);
   1.905 +
   1.906 +         /* Load constant from constant pool: */
   1.907 +
   1.908 +          /* Push a 1-byte signed integer value onto the stack. */
   1.909 +      CASE(_bipush):
   1.910 +          SET_STACK_INT((jbyte)(pc[1]), 0);
   1.911 +          UPDATE_PC_AND_TOS_AND_CONTINUE(2, 1);
   1.912 +
   1.913 +          /* Push a 2-byte signed integer constant onto the stack. */
   1.914 +      CASE(_sipush):
   1.915 +          SET_STACK_INT((int16_t)Bytes::get_Java_u2(pc + 1), 0);
   1.916 +          UPDATE_PC_AND_TOS_AND_CONTINUE(3, 1);
   1.917 +
   1.918 +          /* load from local variable */
   1.919 +
   1.920 +      CASE(_aload):
   1.921 +          SET_STACK_OBJECT(LOCALS_OBJECT(pc[1]), 0);
   1.922 +          UPDATE_PC_AND_TOS_AND_CONTINUE(2, 1);
   1.923 +
   1.924 +      CASE(_iload):
   1.925 +      CASE(_fload):
   1.926 +          SET_STACK_SLOT(LOCALS_SLOT(pc[1]), 0);
   1.927 +          UPDATE_PC_AND_TOS_AND_CONTINUE(2, 1);
   1.928 +
   1.929 +      CASE(_lload):
   1.930 +          SET_STACK_LONG_FROM_ADDR(LOCALS_LONG_AT(pc[1]), 1);
   1.931 +          UPDATE_PC_AND_TOS_AND_CONTINUE(2, 2);
   1.932 +
   1.933 +      CASE(_dload):
   1.934 +          SET_STACK_DOUBLE_FROM_ADDR(LOCALS_DOUBLE_AT(pc[1]), 1);
   1.935 +          UPDATE_PC_AND_TOS_AND_CONTINUE(2, 2);
   1.936 +
   1.937 +#undef  OPC_LOAD_n
   1.938 +#define OPC_LOAD_n(num)                                                 \
   1.939 +      CASE(_aload_##num):                                               \
   1.940 +          SET_STACK_OBJECT(LOCALS_OBJECT(num), 0);                      \
   1.941 +          UPDATE_PC_AND_TOS_AND_CONTINUE(1, 1);                         \
   1.942 +                                                                        \
   1.943 +      CASE(_iload_##num):                                               \
   1.944 +      CASE(_fload_##num):                                               \
   1.945 +          SET_STACK_SLOT(LOCALS_SLOT(num), 0);                          \
   1.946 +          UPDATE_PC_AND_TOS_AND_CONTINUE(1, 1);                         \
   1.947 +                                                                        \
   1.948 +      CASE(_lload_##num):                                               \
   1.949 +          SET_STACK_LONG_FROM_ADDR(LOCALS_LONG_AT(num), 1);             \
   1.950 +          UPDATE_PC_AND_TOS_AND_CONTINUE(1, 2);                         \
   1.951 +      CASE(_dload_##num):                                               \
   1.952 +          SET_STACK_DOUBLE_FROM_ADDR(LOCALS_DOUBLE_AT(num), 1);         \
   1.953 +          UPDATE_PC_AND_TOS_AND_CONTINUE(1, 2);
   1.954 +
   1.955 +          OPC_LOAD_n(0);
   1.956 +          OPC_LOAD_n(1);
   1.957 +          OPC_LOAD_n(2);
   1.958 +          OPC_LOAD_n(3);
   1.959 +
   1.960 +          /* store to a local variable */
   1.961 +
   1.962 +      CASE(_astore):
   1.963 +          astore(topOfStack, -1, locals, pc[1]);
   1.964 +          UPDATE_PC_AND_TOS_AND_CONTINUE(2, -1);
   1.965 +
   1.966 +      CASE(_istore):
   1.967 +      CASE(_fstore):
   1.968 +          SET_LOCALS_SLOT(STACK_SLOT(-1), pc[1]);
   1.969 +          UPDATE_PC_AND_TOS_AND_CONTINUE(2, -1);
   1.970 +
   1.971 +      CASE(_lstore):
   1.972 +          SET_LOCALS_LONG(STACK_LONG(-1), pc[1]);
   1.973 +          UPDATE_PC_AND_TOS_AND_CONTINUE(2, -2);
   1.974 +
   1.975 +      CASE(_dstore):
   1.976 +          SET_LOCALS_DOUBLE(STACK_DOUBLE(-1), pc[1]);
   1.977 +          UPDATE_PC_AND_TOS_AND_CONTINUE(2, -2);
   1.978 +
   1.979 +      CASE(_wide): {
   1.980 +          uint16_t reg = Bytes::get_Java_u2(pc + 2);
   1.981 +
   1.982 +          opcode = pc[1];
   1.983 +          switch(opcode) {
   1.984 +              case Bytecodes::_aload:
   1.985 +                  SET_STACK_OBJECT(LOCALS_OBJECT(reg), 0);
   1.986 +                  UPDATE_PC_AND_TOS_AND_CONTINUE(4, 1);
   1.987 +
   1.988 +              case Bytecodes::_iload:
   1.989 +              case Bytecodes::_fload:
   1.990 +                  SET_STACK_SLOT(LOCALS_SLOT(reg), 0);
   1.991 +                  UPDATE_PC_AND_TOS_AND_CONTINUE(4, 1);
   1.992 +
   1.993 +              case Bytecodes::_lload:
   1.994 +                  SET_STACK_LONG_FROM_ADDR(LOCALS_LONG_AT(reg), 1);
   1.995 +                  UPDATE_PC_AND_TOS_AND_CONTINUE(4, 2);
   1.996 +
   1.997 +              case Bytecodes::_dload:
   1.998 +                  SET_STACK_DOUBLE_FROM_ADDR(LOCALS_LONG_AT(reg), 1);
   1.999 +                  UPDATE_PC_AND_TOS_AND_CONTINUE(4, 2);
  1.1000 +
  1.1001 +              case Bytecodes::_astore:
  1.1002 +                  astore(topOfStack, -1, locals, reg);
  1.1003 +                  UPDATE_PC_AND_TOS_AND_CONTINUE(4, -1);
  1.1004 +
  1.1005 +              case Bytecodes::_istore:
  1.1006 +              case Bytecodes::_fstore:
  1.1007 +                  SET_LOCALS_SLOT(STACK_SLOT(-1), reg);
  1.1008 +                  UPDATE_PC_AND_TOS_AND_CONTINUE(4, -1);
  1.1009 +
  1.1010 +              case Bytecodes::_lstore:
  1.1011 +                  SET_LOCALS_LONG(STACK_LONG(-1), reg);
  1.1012 +                  UPDATE_PC_AND_TOS_AND_CONTINUE(4, -2);
  1.1013 +
  1.1014 +              case Bytecodes::_dstore:
  1.1015 +                  SET_LOCALS_DOUBLE(STACK_DOUBLE(-1), reg);
  1.1016 +                  UPDATE_PC_AND_TOS_AND_CONTINUE(4, -2);
  1.1017 +
  1.1018 +              case Bytecodes::_iinc: {
  1.1019 +                  int16_t offset = (int16_t)Bytes::get_Java_u2(pc+4);
  1.1020 +                  // Be nice to see what this generates.... QQQ
  1.1021 +                  SET_LOCALS_INT(LOCALS_INT(reg) + offset, reg);
  1.1022 +                  UPDATE_PC_AND_CONTINUE(6);
  1.1023 +              }
  1.1024 +              case Bytecodes::_ret:
  1.1025 +                  pc = istate->method()->code_base() + (intptr_t)(LOCALS_ADDR(reg));
  1.1026 +                  UPDATE_PC_AND_CONTINUE(0);
  1.1027 +              default:
  1.1028 +                  VM_JAVA_ERROR(vmSymbols::java_lang_InternalError(), "undefined opcode");
  1.1029 +          }
  1.1030 +      }
  1.1031 +
  1.1032 +
  1.1033 +#undef  OPC_STORE_n
  1.1034 +#define OPC_STORE_n(num)                                                \
  1.1035 +      CASE(_astore_##num):                                              \
  1.1036 +          astore(topOfStack, -1, locals, num);                          \
  1.1037 +          UPDATE_PC_AND_TOS_AND_CONTINUE(1, -1);                        \
  1.1038 +      CASE(_istore_##num):                                              \
  1.1039 +      CASE(_fstore_##num):                                              \
  1.1040 +          SET_LOCALS_SLOT(STACK_SLOT(-1), num);                         \
  1.1041 +          UPDATE_PC_AND_TOS_AND_CONTINUE(1, -1);
  1.1042 +
  1.1043 +          OPC_STORE_n(0);
  1.1044 +          OPC_STORE_n(1);
  1.1045 +          OPC_STORE_n(2);
  1.1046 +          OPC_STORE_n(3);
  1.1047 +
  1.1048 +#undef  OPC_DSTORE_n
  1.1049 +#define OPC_DSTORE_n(num)                                               \
  1.1050 +      CASE(_dstore_##num):                                              \
  1.1051 +          SET_LOCALS_DOUBLE(STACK_DOUBLE(-1), num);                     \
  1.1052 +          UPDATE_PC_AND_TOS_AND_CONTINUE(1, -2);                        \
  1.1053 +      CASE(_lstore_##num):                                              \
  1.1054 +          SET_LOCALS_LONG(STACK_LONG(-1), num);                         \
  1.1055 +          UPDATE_PC_AND_TOS_AND_CONTINUE(1, -2);
  1.1056 +
  1.1057 +          OPC_DSTORE_n(0);
  1.1058 +          OPC_DSTORE_n(1);
  1.1059 +          OPC_DSTORE_n(2);
  1.1060 +          OPC_DSTORE_n(3);
  1.1061 +
  1.1062 +          /* stack pop, dup, and insert opcodes */
  1.1063 +
  1.1064 +
  1.1065 +      CASE(_pop):                /* Discard the top item on the stack */
  1.1066 +          UPDATE_PC_AND_TOS_AND_CONTINUE(1, -1);
  1.1067 +
  1.1068 +
  1.1069 +      CASE(_pop2):               /* Discard the top 2 items on the stack */
  1.1070 +          UPDATE_PC_AND_TOS_AND_CONTINUE(1, -2);
  1.1071 +
  1.1072 +
  1.1073 +      CASE(_dup):               /* Duplicate the top item on the stack */
  1.1074 +          dup(topOfStack);
  1.1075 +          UPDATE_PC_AND_TOS_AND_CONTINUE(1, 1);
  1.1076 +
  1.1077 +      CASE(_dup2):              /* Duplicate the top 2 items on the stack */
  1.1078 +          dup2(topOfStack);
  1.1079 +          UPDATE_PC_AND_TOS_AND_CONTINUE(1, 2);
  1.1080 +
  1.1081 +      CASE(_dup_x1):    /* insert top word two down */
  1.1082 +          dup_x1(topOfStack);
  1.1083 +          UPDATE_PC_AND_TOS_AND_CONTINUE(1, 1);
  1.1084 +
  1.1085 +      CASE(_dup_x2):    /* insert top word three down  */
  1.1086 +          dup_x2(topOfStack);
  1.1087 +          UPDATE_PC_AND_TOS_AND_CONTINUE(1, 1);
  1.1088 +
  1.1089 +      CASE(_dup2_x1):   /* insert top 2 slots three down */
  1.1090 +          dup2_x1(topOfStack);
  1.1091 +          UPDATE_PC_AND_TOS_AND_CONTINUE(1, 2);
  1.1092 +
  1.1093 +      CASE(_dup2_x2):   /* insert top 2 slots four down */
  1.1094 +          dup2_x2(topOfStack);
  1.1095 +          UPDATE_PC_AND_TOS_AND_CONTINUE(1, 2);
  1.1096 +
  1.1097 +      CASE(_swap): {        /* swap top two elements on the stack */
  1.1098 +          swap(topOfStack);
  1.1099 +          UPDATE_PC_AND_CONTINUE(1);
  1.1100 +      }
  1.1101 +
  1.1102 +          /* Perform various binary integer operations */
  1.1103 +
  1.1104 +#undef  OPC_INT_BINARY
  1.1105 +#define OPC_INT_BINARY(opcname, opname, test)                           \
  1.1106 +      CASE(_i##opcname):                                                \
  1.1107 +          if (test && (STACK_INT(-1) == 0)) {                           \
  1.1108 +              VM_JAVA_ERROR(vmSymbols::java_lang_ArithmeticException(), \
  1.1109 +                            "/ by int zero");                           \
  1.1110 +          }                                                             \
  1.1111 +          SET_STACK_INT(VMint##opname(STACK_INT(-2),                    \
  1.1112 +                                      STACK_INT(-1)),                   \
  1.1113 +                                      -2);                              \
  1.1114 +          UPDATE_PC_AND_TOS_AND_CONTINUE(1, -1);                        \
  1.1115 +      CASE(_l##opcname):                                                \
  1.1116 +      {                                                                 \
  1.1117 +          if (test) {                                                   \
  1.1118 +            jlong l1 = STACK_LONG(-1);                                  \
  1.1119 +            if (VMlongEqz(l1)) {                                        \
  1.1120 +              VM_JAVA_ERROR(vmSymbols::java_lang_ArithmeticException(), \
  1.1121 +                            "/ by long zero");                          \
  1.1122 +            }                                                           \
  1.1123 +          }                                                             \
  1.1124 +          /* First long at (-1,-2) next long at (-3,-4) */              \
  1.1125 +          SET_STACK_LONG(VMlong##opname(STACK_LONG(-3),                 \
  1.1126 +                                        STACK_LONG(-1)),                \
  1.1127 +                                        -3);                            \
  1.1128 +          UPDATE_PC_AND_TOS_AND_CONTINUE(1, -2);                        \
  1.1129 +      }
  1.1130 +
  1.1131 +      OPC_INT_BINARY(add, Add, 0);
  1.1132 +      OPC_INT_BINARY(sub, Sub, 0);
  1.1133 +      OPC_INT_BINARY(mul, Mul, 0);
  1.1134 +      OPC_INT_BINARY(and, And, 0);
  1.1135 +      OPC_INT_BINARY(or,  Or,  0);
  1.1136 +      OPC_INT_BINARY(xor, Xor, 0);
  1.1137 +      OPC_INT_BINARY(div, Div, 1);
  1.1138 +      OPC_INT_BINARY(rem, Rem, 1);
  1.1139 +
  1.1140 +
  1.1141 +      /* Perform various binary floating number operations */
  1.1142 +      /* On some machine/platforms/compilers div zero check can be implicit */
  1.1143 +
  1.1144 +#undef  OPC_FLOAT_BINARY
  1.1145 +#define OPC_FLOAT_BINARY(opcname, opname)                                  \
  1.1146 +      CASE(_d##opcname): {                                                 \
  1.1147 +          SET_STACK_DOUBLE(VMdouble##opname(STACK_DOUBLE(-3),              \
  1.1148 +                                            STACK_DOUBLE(-1)),             \
  1.1149 +                                            -3);                           \
  1.1150 +          UPDATE_PC_AND_TOS_AND_CONTINUE(1, -2);                           \
  1.1151 +      }                                                                    \
  1.1152 +      CASE(_f##opcname):                                                   \
  1.1153 +          SET_STACK_FLOAT(VMfloat##opname(STACK_FLOAT(-2),                 \
  1.1154 +                                          STACK_FLOAT(-1)),                \
  1.1155 +                                          -2);                             \
  1.1156 +          UPDATE_PC_AND_TOS_AND_CONTINUE(1, -1);
  1.1157 +
  1.1158 +
  1.1159 +     OPC_FLOAT_BINARY(add, Add);
  1.1160 +     OPC_FLOAT_BINARY(sub, Sub);
  1.1161 +     OPC_FLOAT_BINARY(mul, Mul);
  1.1162 +     OPC_FLOAT_BINARY(div, Div);
  1.1163 +     OPC_FLOAT_BINARY(rem, Rem);
  1.1164 +
  1.1165 +      /* Shift operations
  1.1166 +       * Shift left int and long: ishl, lshl
  1.1167 +       * Logical shift right int and long w/zero extension: iushr, lushr
  1.1168 +       * Arithmetic shift right int and long w/sign extension: ishr, lshr
  1.1169 +       */
  1.1170 +
  1.1171 +#undef  OPC_SHIFT_BINARY
  1.1172 +#define OPC_SHIFT_BINARY(opcname, opname)                               \
  1.1173 +      CASE(_i##opcname):                                                \
  1.1174 +         SET_STACK_INT(VMint##opname(STACK_INT(-2),                     \
  1.1175 +                                     STACK_INT(-1)),                    \
  1.1176 +                                     -2);                               \
  1.1177 +         UPDATE_PC_AND_TOS_AND_CONTINUE(1, -1);                         \
  1.1178 +      CASE(_l##opcname):                                                \
  1.1179 +      {                                                                 \
  1.1180 +         SET_STACK_LONG(VMlong##opname(STACK_LONG(-2),                  \
  1.1181 +                                       STACK_INT(-1)),                  \
  1.1182 +                                       -2);                             \
  1.1183 +         UPDATE_PC_AND_TOS_AND_CONTINUE(1, -1);                         \
  1.1184 +      }
  1.1185 +
  1.1186 +      OPC_SHIFT_BINARY(shl, Shl);
  1.1187 +      OPC_SHIFT_BINARY(shr, Shr);
  1.1188 +      OPC_SHIFT_BINARY(ushr, Ushr);
  1.1189 +
  1.1190 +     /* Increment local variable by constant */
  1.1191 +      CASE(_iinc):
  1.1192 +      {
  1.1193 +          // locals[pc[1]].j.i += (jbyte)(pc[2]);
  1.1194 +          SET_LOCALS_INT(LOCALS_INT(pc[1]) + (jbyte)(pc[2]), pc[1]);
  1.1195 +          UPDATE_PC_AND_CONTINUE(3);
  1.1196 +      }
  1.1197 +
  1.1198 +     /* negate the value on the top of the stack */
  1.1199 +
  1.1200 +      CASE(_ineg):
  1.1201 +         SET_STACK_INT(VMintNeg(STACK_INT(-1)), -1);
  1.1202 +         UPDATE_PC_AND_CONTINUE(1);
  1.1203 +
  1.1204 +      CASE(_fneg):
  1.1205 +         SET_STACK_FLOAT(VMfloatNeg(STACK_FLOAT(-1)), -1);
  1.1206 +         UPDATE_PC_AND_CONTINUE(1);
  1.1207 +
  1.1208 +      CASE(_lneg):
  1.1209 +      {
  1.1210 +         SET_STACK_LONG(VMlongNeg(STACK_LONG(-1)), -1);
  1.1211 +         UPDATE_PC_AND_CONTINUE(1);
  1.1212 +      }
  1.1213 +
  1.1214 +      CASE(_dneg):
  1.1215 +      {
  1.1216 +         SET_STACK_DOUBLE(VMdoubleNeg(STACK_DOUBLE(-1)), -1);
  1.1217 +         UPDATE_PC_AND_CONTINUE(1);
  1.1218 +      }
  1.1219 +
  1.1220 +      /* Conversion operations */
  1.1221 +
  1.1222 +      CASE(_i2f):       /* convert top of stack int to float */
  1.1223 +         SET_STACK_FLOAT(VMint2Float(STACK_INT(-1)), -1);
  1.1224 +         UPDATE_PC_AND_CONTINUE(1);
  1.1225 +
  1.1226 +      CASE(_i2l):       /* convert top of stack int to long */
  1.1227 +      {
  1.1228 +          // this is ugly QQQ
  1.1229 +          jlong r = VMint2Long(STACK_INT(-1));
  1.1230 +          MORE_STACK(-1); // Pop
  1.1231 +          SET_STACK_LONG(r, 1);
  1.1232 +
  1.1233 +          UPDATE_PC_AND_TOS_AND_CONTINUE(1, 2);
  1.1234 +      }
  1.1235 +
  1.1236 +      CASE(_i2d):       /* convert top of stack int to double */
  1.1237 +      {
  1.1238 +          // this is ugly QQQ (why cast to jlong?? )
  1.1239 +          jdouble r = (jlong)STACK_INT(-1);
  1.1240 +          MORE_STACK(-1); // Pop
  1.1241 +          SET_STACK_DOUBLE(r, 1);
  1.1242 +
  1.1243 +          UPDATE_PC_AND_TOS_AND_CONTINUE(1, 2);
  1.1244 +      }
  1.1245 +
  1.1246 +      CASE(_l2i):       /* convert top of stack long to int */
  1.1247 +      {
  1.1248 +          jint r = VMlong2Int(STACK_LONG(-1));
  1.1249 +          MORE_STACK(-2); // Pop
  1.1250 +          SET_STACK_INT(r, 0);
  1.1251 +          UPDATE_PC_AND_TOS_AND_CONTINUE(1, 1);
  1.1252 +      }
  1.1253 +
  1.1254 +      CASE(_l2f):   /* convert top of stack long to float */
  1.1255 +      {
  1.1256 +          jlong r = STACK_LONG(-1);
  1.1257 +          MORE_STACK(-2); // Pop
  1.1258 +          SET_STACK_FLOAT(VMlong2Float(r), 0);
  1.1259 +          UPDATE_PC_AND_TOS_AND_CONTINUE(1, 1);
  1.1260 +      }
  1.1261 +
  1.1262 +      CASE(_l2d):       /* convert top of stack long to double */
  1.1263 +      {
  1.1264 +          jlong r = STACK_LONG(-1);
  1.1265 +          MORE_STACK(-2); // Pop
  1.1266 +          SET_STACK_DOUBLE(VMlong2Double(r), 1);
  1.1267 +          UPDATE_PC_AND_TOS_AND_CONTINUE(1, 2);
  1.1268 +      }
  1.1269 +
  1.1270 +      CASE(_f2i):  /* Convert top of stack float to int */
  1.1271 +          SET_STACK_INT(SharedRuntime::f2i(STACK_FLOAT(-1)), -1);
  1.1272 +          UPDATE_PC_AND_CONTINUE(1);
  1.1273 +
  1.1274 +      CASE(_f2l):  /* convert top of stack float to long */
  1.1275 +      {
  1.1276 +          jlong r = SharedRuntime::f2l(STACK_FLOAT(-1));
  1.1277 +          MORE_STACK(-1); // POP
  1.1278 +          SET_STACK_LONG(r, 1);
  1.1279 +          UPDATE_PC_AND_TOS_AND_CONTINUE(1, 2);
  1.1280 +      }
  1.1281 +
  1.1282 +      CASE(_f2d):  /* convert top of stack float to double */
  1.1283 +      {
  1.1284 +          jfloat f;
  1.1285 +          jdouble r;
  1.1286 +          f = STACK_FLOAT(-1);
  1.1287 +#ifdef IA64
  1.1288 +          // IA64 gcc bug
  1.1289 +          r = ( f == 0.0f ) ? (jdouble) f : (jdouble) f + ia64_double_zero;
  1.1290 +#else
  1.1291 +          r = (jdouble) f;
  1.1292 +#endif
  1.1293 +          MORE_STACK(-1); // POP
  1.1294 +          SET_STACK_DOUBLE(r, 1);
  1.1295 +          UPDATE_PC_AND_TOS_AND_CONTINUE(1, 2);
  1.1296 +      }
  1.1297 +
  1.1298 +      CASE(_d2i): /* convert top of stack double to int */
  1.1299 +      {
  1.1300 +          jint r1 = SharedRuntime::d2i(STACK_DOUBLE(-1));
  1.1301 +          MORE_STACK(-2);
  1.1302 +          SET_STACK_INT(r1, 0);
  1.1303 +          UPDATE_PC_AND_TOS_AND_CONTINUE(1, 1);
  1.1304 +      }
  1.1305 +
  1.1306 +      CASE(_d2f): /* convert top of stack double to float */
  1.1307 +      {
  1.1308 +          jfloat r1 = VMdouble2Float(STACK_DOUBLE(-1));
  1.1309 +          MORE_STACK(-2);
  1.1310 +          SET_STACK_FLOAT(r1, 0);
  1.1311 +          UPDATE_PC_AND_TOS_AND_CONTINUE(1, 1);
  1.1312 +      }
  1.1313 +
  1.1314 +      CASE(_d2l): /* convert top of stack double to long */
  1.1315 +      {
  1.1316 +          jlong r1 = SharedRuntime::d2l(STACK_DOUBLE(-1));
  1.1317 +          MORE_STACK(-2);
  1.1318 +          SET_STACK_LONG(r1, 1);
  1.1319 +          UPDATE_PC_AND_TOS_AND_CONTINUE(1, 2);
  1.1320 +      }
  1.1321 +
  1.1322 +      CASE(_i2b):
  1.1323 +          SET_STACK_INT(VMint2Byte(STACK_INT(-1)), -1);
  1.1324 +          UPDATE_PC_AND_CONTINUE(1);
  1.1325 +
  1.1326 +      CASE(_i2c):
  1.1327 +          SET_STACK_INT(VMint2Char(STACK_INT(-1)), -1);
  1.1328 +          UPDATE_PC_AND_CONTINUE(1);
  1.1329 +
  1.1330 +      CASE(_i2s):
  1.1331 +          SET_STACK_INT(VMint2Short(STACK_INT(-1)), -1);
  1.1332 +          UPDATE_PC_AND_CONTINUE(1);
  1.1333 +
  1.1334 +      /* comparison operators */
  1.1335 +
  1.1336 +
  1.1337 +#define COMPARISON_OP(name, comparison)                                      \
  1.1338 +      CASE(_if_icmp##name): {                                                \
  1.1339 +          int skip = (STACK_INT(-2) comparison STACK_INT(-1))                \
  1.1340 +                      ? (int16_t)Bytes::get_Java_u2(pc + 1) : 3;             \
  1.1341 +          address branch_pc = pc;                                            \
  1.1342 +          UPDATE_PC_AND_TOS(skip, -2);                                       \
  1.1343 +          DO_BACKEDGE_CHECKS(skip, branch_pc);                               \
  1.1344 +          CONTINUE;                                                          \
  1.1345 +      }                                                                      \
  1.1346 +      CASE(_if##name): {                                                     \
  1.1347 +          int skip = (STACK_INT(-1) comparison 0)                            \
  1.1348 +                      ? (int16_t)Bytes::get_Java_u2(pc + 1) : 3;             \
  1.1349 +          address branch_pc = pc;                                            \
  1.1350 +          UPDATE_PC_AND_TOS(skip, -1);                                       \
  1.1351 +          DO_BACKEDGE_CHECKS(skip, branch_pc);                               \
  1.1352 +          CONTINUE;                                                          \
  1.1353 +      }
  1.1354 +
  1.1355 +#define COMPARISON_OP2(name, comparison)                                     \
  1.1356 +      COMPARISON_OP(name, comparison)                                        \
  1.1357 +      CASE(_if_acmp##name): {                                                \
  1.1358 +          int skip = (STACK_OBJECT(-2) comparison STACK_OBJECT(-1))          \
  1.1359 +                       ? (int16_t)Bytes::get_Java_u2(pc + 1) : 3;            \
  1.1360 +          address branch_pc = pc;                                            \
  1.1361 +          UPDATE_PC_AND_TOS(skip, -2);                                       \
  1.1362 +          DO_BACKEDGE_CHECKS(skip, branch_pc);                               \
  1.1363 +          CONTINUE;                                                          \
  1.1364 +      }
  1.1365 +
  1.1366 +#define NULL_COMPARISON_NOT_OP(name)                                         \
  1.1367 +      CASE(_if##name): {                                                     \
  1.1368 +          int skip = (!(STACK_OBJECT(-1) == 0))                              \
  1.1369 +                      ? (int16_t)Bytes::get_Java_u2(pc + 1) : 3;             \
  1.1370 +          address branch_pc = pc;                                            \
  1.1371 +          UPDATE_PC_AND_TOS(skip, -1);                                       \
  1.1372 +          DO_BACKEDGE_CHECKS(skip, branch_pc);                               \
  1.1373 +          CONTINUE;                                                          \
  1.1374 +      }
  1.1375 +
  1.1376 +#define NULL_COMPARISON_OP(name)                                             \
  1.1377 +      CASE(_if##name): {                                                     \
  1.1378 +          int skip = ((STACK_OBJECT(-1) == 0))                               \
  1.1379 +                      ? (int16_t)Bytes::get_Java_u2(pc + 1) : 3;             \
  1.1380 +          address branch_pc = pc;                                            \
  1.1381 +          UPDATE_PC_AND_TOS(skip, -1);                                       \
  1.1382 +          DO_BACKEDGE_CHECKS(skip, branch_pc);                               \
  1.1383 +          CONTINUE;                                                          \
  1.1384 +      }
  1.1385 +      COMPARISON_OP(lt, <);
  1.1386 +      COMPARISON_OP(gt, >);
  1.1387 +      COMPARISON_OP(le, <=);
  1.1388 +      COMPARISON_OP(ge, >=);
  1.1389 +      COMPARISON_OP2(eq, ==);  /* include ref comparison */
  1.1390 +      COMPARISON_OP2(ne, !=);  /* include ref comparison */
  1.1391 +      NULL_COMPARISON_OP(null);
  1.1392 +      NULL_COMPARISON_NOT_OP(nonnull);
  1.1393 +
  1.1394 +      /* Goto pc at specified offset in switch table. */
  1.1395 +
  1.1396 +      CASE(_tableswitch): {
  1.1397 +          jint* lpc  = (jint*)VMalignWordUp(pc+1);
  1.1398 +          int32_t  key  = STACK_INT(-1);
  1.1399 +          int32_t  low  = Bytes::get_Java_u4((address)&lpc[1]);
  1.1400 +          int32_t  high = Bytes::get_Java_u4((address)&lpc[2]);
  1.1401 +          int32_t  skip;
  1.1402 +          key -= low;
  1.1403 +          skip = ((uint32_t) key > (uint32_t)(high - low))
  1.1404 +                      ? Bytes::get_Java_u4((address)&lpc[0])
  1.1405 +                      : Bytes::get_Java_u4((address)&lpc[key + 3]);
  1.1406 +          // Does this really need a full backedge check (osr?)
  1.1407 +          address branch_pc = pc;
  1.1408 +          UPDATE_PC_AND_TOS(skip, -1);
  1.1409 +          DO_BACKEDGE_CHECKS(skip, branch_pc);
  1.1410 +          CONTINUE;
  1.1411 +      }
  1.1412 +
  1.1413 +      /* Goto pc whose table entry matches specified key */
  1.1414 +
  1.1415 +      CASE(_lookupswitch): {
  1.1416 +          jint* lpc  = (jint*)VMalignWordUp(pc+1);
  1.1417 +          int32_t  key  = STACK_INT(-1);
  1.1418 +          int32_t  skip = Bytes::get_Java_u4((address) lpc); /* default amount */
  1.1419 +          int32_t  npairs = Bytes::get_Java_u4((address) &lpc[1]);
  1.1420 +          while (--npairs >= 0) {
  1.1421 +              lpc += 2;
  1.1422 +              if (key == (int32_t)Bytes::get_Java_u4((address)lpc)) {
  1.1423 +                  skip = Bytes::get_Java_u4((address)&lpc[1]);
  1.1424 +                  break;
  1.1425 +              }
  1.1426 +          }
  1.1427 +          address branch_pc = pc;
  1.1428 +          UPDATE_PC_AND_TOS(skip, -1);
  1.1429 +          DO_BACKEDGE_CHECKS(skip, branch_pc);
  1.1430 +          CONTINUE;
  1.1431 +      }
  1.1432 +
  1.1433 +      CASE(_fcmpl):
  1.1434 +      CASE(_fcmpg):
  1.1435 +      {
  1.1436 +          SET_STACK_INT(VMfloatCompare(STACK_FLOAT(-2),
  1.1437 +                                        STACK_FLOAT(-1),
  1.1438 +                                        (opcode == Bytecodes::_fcmpl ? -1 : 1)),
  1.1439 +                        -2);
  1.1440 +          UPDATE_PC_AND_TOS_AND_CONTINUE(1, -1);
  1.1441 +      }
  1.1442 +
  1.1443 +      CASE(_dcmpl):
  1.1444 +      CASE(_dcmpg):
  1.1445 +      {
  1.1446 +          int r = VMdoubleCompare(STACK_DOUBLE(-3),
  1.1447 +                                  STACK_DOUBLE(-1),
  1.1448 +                                  (opcode == Bytecodes::_dcmpl ? -1 : 1));
  1.1449 +          MORE_STACK(-4); // Pop
  1.1450 +          SET_STACK_INT(r, 0);
  1.1451 +          UPDATE_PC_AND_TOS_AND_CONTINUE(1, 1);
  1.1452 +      }
  1.1453 +
  1.1454 +      CASE(_lcmp):
  1.1455 +      {
  1.1456 +          int r = VMlongCompare(STACK_LONG(-3), STACK_LONG(-1));
  1.1457 +          MORE_STACK(-4);
  1.1458 +          SET_STACK_INT(r, 0);
  1.1459 +          UPDATE_PC_AND_TOS_AND_CONTINUE(1, 1);
  1.1460 +      }
  1.1461 +
  1.1462 +
  1.1463 +      /* Return from a method */
  1.1464 +
  1.1465 +      CASE(_areturn):
  1.1466 +      CASE(_ireturn):
  1.1467 +      CASE(_freturn):
  1.1468 +      {
  1.1469 +          // Allow a safepoint before returning to frame manager.
  1.1470 +          SAFEPOINT;
  1.1471 +
  1.1472 +          goto handle_return;
  1.1473 +      }
  1.1474 +
  1.1475 +      CASE(_lreturn):
  1.1476 +      CASE(_dreturn):
  1.1477 +      {
  1.1478 +          // Allow a safepoint before returning to frame manager.
  1.1479 +          SAFEPOINT;
  1.1480 +          goto handle_return;
  1.1481 +      }
  1.1482 +
  1.1483 +      CASE(_return_register_finalizer): {
  1.1484 +
  1.1485 +          oop rcvr = LOCALS_OBJECT(0);
  1.1486 +          if (rcvr->klass()->klass_part()->has_finalizer()) {
  1.1487 +            CALL_VM(InterpreterRuntime::register_finalizer(THREAD, rcvr), handle_exception);
  1.1488 +          }
  1.1489 +          goto handle_return;
  1.1490 +      }
  1.1491 +      CASE(_return): {
  1.1492 +
  1.1493 +          // Allow a safepoint before returning to frame manager.
  1.1494 +          SAFEPOINT;
  1.1495 +          goto handle_return;
  1.1496 +      }
  1.1497 +
  1.1498 +      /* Array access byte-codes */
  1.1499 +
  1.1500 +      /* Every array access byte-code starts out like this */
  1.1501 +//        arrayOopDesc* arrObj = (arrayOopDesc*)STACK_OBJECT(arrayOff);
  1.1502 +#define ARRAY_INTRO(arrayOff)                                                  \
  1.1503 +      arrayOop arrObj = (arrayOop)STACK_OBJECT(arrayOff);                      \
  1.1504 +      jint     index  = STACK_INT(arrayOff + 1);                               \
  1.1505 +      char message[jintAsStringSize];                                          \
  1.1506 +      CHECK_NULL(arrObj);                                                      \
  1.1507 +      if ((uint32_t)index >= (uint32_t)arrObj->length()) {                     \
  1.1508 +          sprintf(message, "%d", index);                                       \
  1.1509 +          VM_JAVA_ERROR(vmSymbols::java_lang_ArrayIndexOutOfBoundsException(), \
  1.1510 +                        message);                                              \
  1.1511 +      }
  1.1512 +
  1.1513 +      /* 32-bit loads. These handle conversion from < 32-bit types */
  1.1514 +#define ARRAY_LOADTO32(T, T2, format, stackRes, extra)                                \
  1.1515 +      {                                                                               \
  1.1516 +          ARRAY_INTRO(-2);                                                            \
  1.1517 +          extra;                                                                      \
  1.1518 +          SET_ ## stackRes(*(T2 *)(((address) arrObj->base(T)) + index * sizeof(T2)), \
  1.1519 +                           -2);                                                       \
  1.1520 +          UPDATE_PC_AND_TOS_AND_CONTINUE(1, -1);                                      \
  1.1521 +      }
  1.1522 +
  1.1523 +      /* 64-bit loads */
  1.1524 +#define ARRAY_LOADTO64(T,T2, stackRes, extra)                                              \
  1.1525 +      {                                                                                    \
  1.1526 +          ARRAY_INTRO(-2);                                                                 \
  1.1527 +          SET_ ## stackRes(*(T2 *)(((address) arrObj->base(T)) + index * sizeof(T2)), -1); \
  1.1528 +          extra;                                                                           \
  1.1529 +          UPDATE_PC_AND_CONTINUE(1);                                            \
  1.1530 +      }
  1.1531 +
  1.1532 +      CASE(_iaload):
  1.1533 +          ARRAY_LOADTO32(T_INT, jint,   "%d",   STACK_INT, 0);
  1.1534 +      CASE(_faload):
  1.1535 +          ARRAY_LOADTO32(T_FLOAT, jfloat, "%f",   STACK_FLOAT, 0);
  1.1536 +      CASE(_aaload):
  1.1537 +          ARRAY_LOADTO32(T_OBJECT, oop,   INTPTR_FORMAT, STACK_OBJECT, 0);
  1.1538 +      CASE(_baload):
  1.1539 +          ARRAY_LOADTO32(T_BYTE, jbyte,  "%d",   STACK_INT, 0);
  1.1540 +      CASE(_caload):
  1.1541 +          ARRAY_LOADTO32(T_CHAR,  jchar, "%d",   STACK_INT, 0);
  1.1542 +      CASE(_saload):
  1.1543 +          ARRAY_LOADTO32(T_SHORT, jshort, "%d",   STACK_INT, 0);
  1.1544 +      CASE(_laload):
  1.1545 +          ARRAY_LOADTO64(T_LONG, jlong, STACK_LONG, 0);
  1.1546 +      CASE(_daload):
  1.1547 +          ARRAY_LOADTO64(T_DOUBLE, jdouble, STACK_DOUBLE, 0);
  1.1548 +
  1.1549 +      /* 32-bit stores. These handle conversion to < 32-bit types */
  1.1550 +#define ARRAY_STOREFROM32(T, T2, format, stackSrc, extra)                            \
  1.1551 +      {                                                                              \
  1.1552 +          ARRAY_INTRO(-3);                                                           \
  1.1553 +          extra;                                                                     \
  1.1554 +          *(T2 *)(((address) arrObj->base(T)) + index * sizeof(T2)) = stackSrc( -1); \
  1.1555 +          UPDATE_PC_AND_TOS_AND_CONTINUE(1, -3);                                     \
  1.1556 +      }
  1.1557 +
  1.1558 +      /* 64-bit stores */
  1.1559 +#define ARRAY_STOREFROM64(T, T2, stackSrc, extra)                                    \
  1.1560 +      {                                                                              \
  1.1561 +          ARRAY_INTRO(-4);                                                           \
  1.1562 +          extra;                                                                     \
  1.1563 +          *(T2 *)(((address) arrObj->base(T)) + index * sizeof(T2)) = stackSrc( -1); \
  1.1564 +          UPDATE_PC_AND_TOS_AND_CONTINUE(1, -4);                                     \
  1.1565 +      }
  1.1566 +
  1.1567 +      CASE(_iastore):
  1.1568 +          ARRAY_STOREFROM32(T_INT, jint,   "%d",   STACK_INT, 0);
  1.1569 +      CASE(_fastore):
  1.1570 +          ARRAY_STOREFROM32(T_FLOAT, jfloat, "%f",   STACK_FLOAT, 0);
  1.1571 +      /*
  1.1572 +       * This one looks different because of the assignability check
  1.1573 +       */
  1.1574 +      CASE(_aastore): {
  1.1575 +          oop rhsObject = STACK_OBJECT(-1);
  1.1576 +          ARRAY_INTRO( -3);
  1.1577 +          // arrObj, index are set
  1.1578 +          if (rhsObject != NULL) {
  1.1579 +            /* Check assignability of rhsObject into arrObj */
  1.1580 +            klassOop rhsKlassOop = rhsObject->klass(); // EBX (subclass)
  1.1581 +            assert(arrObj->klass()->klass()->klass_part()->oop_is_objArrayKlass(), "Ack not an objArrayKlass");
  1.1582 +            klassOop elemKlassOop = ((objArrayKlass*) arrObj->klass()->klass_part())->element_klass(); // superklass EAX
  1.1583 +            //
  1.1584 +            // Check for compatibilty. This check must not GC!!
  1.1585 +            // Seems way more expensive now that we must dispatch
  1.1586 +            //
  1.1587 +            if (rhsKlassOop != elemKlassOop && !rhsKlassOop->klass_part()->is_subtype_of(elemKlassOop)) { // ebx->is...
  1.1588 +              VM_JAVA_ERROR(vmSymbols::java_lang_ArrayStoreException(), "");
  1.1589 +            }
  1.1590 +          }
  1.1591 +          oop* elem_loc = (oop*)(((address) arrObj->base(T_OBJECT)) + index * sizeof(oop));
  1.1592 +          // *(oop*)(((address) arrObj->base(T_OBJECT)) + index * sizeof(oop)) = rhsObject;
  1.1593 +          *elem_loc = rhsObject;
  1.1594 +          // Mark the card
  1.1595 +          OrderAccess::release_store(&BYTE_MAP_BASE[(uintptr_t)elem_loc >> CardTableModRefBS::card_shift], 0);
  1.1596 +          UPDATE_PC_AND_TOS_AND_CONTINUE(1, -3);
  1.1597 +      }
  1.1598 +      CASE(_bastore):
  1.1599 +          ARRAY_STOREFROM32(T_BYTE, jbyte,  "%d",   STACK_INT, 0);
  1.1600 +      CASE(_castore):
  1.1601 +          ARRAY_STOREFROM32(T_CHAR, jchar,  "%d",   STACK_INT, 0);
  1.1602 +      CASE(_sastore):
  1.1603 +          ARRAY_STOREFROM32(T_SHORT, jshort, "%d",   STACK_INT, 0);
  1.1604 +      CASE(_lastore):
  1.1605 +          ARRAY_STOREFROM64(T_LONG, jlong, STACK_LONG, 0);
  1.1606 +      CASE(_dastore):
  1.1607 +          ARRAY_STOREFROM64(T_DOUBLE, jdouble, STACK_DOUBLE, 0);
  1.1608 +
  1.1609 +      CASE(_arraylength):
  1.1610 +      {
  1.1611 +          arrayOop ary = (arrayOop) STACK_OBJECT(-1);
  1.1612 +          CHECK_NULL(ary);
  1.1613 +          SET_STACK_INT(ary->length(), -1);
  1.1614 +          UPDATE_PC_AND_CONTINUE(1);
  1.1615 +      }
  1.1616 +
  1.1617 +      /* monitorenter and monitorexit for locking/unlocking an object */
  1.1618 +
  1.1619 +      CASE(_monitorenter): {
  1.1620 +        oop lockee = STACK_OBJECT(-1);
  1.1621 +        // derefing's lockee ought to provoke implicit null check
  1.1622 +        CHECK_NULL(lockee);
  1.1623 +        // find a free monitor or one already allocated for this object
  1.1624 +        // if we find a matching object then we need a new monitor
  1.1625 +        // since this is recursive enter
  1.1626 +        BasicObjectLock* limit = istate->monitor_base();
  1.1627 +        BasicObjectLock* most_recent = (BasicObjectLock*) istate->stack_base();
  1.1628 +        BasicObjectLock* entry = NULL;
  1.1629 +        while (most_recent != limit ) {
  1.1630 +          if (most_recent->obj() == NULL) entry = most_recent;
  1.1631 +          else if (most_recent->obj() == lockee) break;
  1.1632 +          most_recent++;
  1.1633 +        }
  1.1634 +        if (entry != NULL) {
  1.1635 +          entry->set_obj(lockee);
  1.1636 +          markOop displaced = lockee->mark()->set_unlocked();
  1.1637 +          entry->lock()->set_displaced_header(displaced);
  1.1638 +          if (Atomic::cmpxchg_ptr(entry, lockee->mark_addr(), displaced) != displaced) {
  1.1639 +            // Is it simple recursive case?
  1.1640 +            if (THREAD->is_lock_owned((address) displaced->clear_lock_bits())) {
  1.1641 +              entry->lock()->set_displaced_header(NULL);
  1.1642 +            } else {
  1.1643 +              CALL_VM(InterpreterRuntime::monitorenter(THREAD, entry), handle_exception);
  1.1644 +            }
  1.1645 +          }
  1.1646 +          UPDATE_PC_AND_TOS_AND_CONTINUE(1, -1);
  1.1647 +        } else {
  1.1648 +          istate->set_msg(more_monitors);
  1.1649 +          UPDATE_PC_AND_RETURN(0); // Re-execute
  1.1650 +        }
  1.1651 +      }
  1.1652 +
  1.1653 +      CASE(_monitorexit): {
  1.1654 +        oop lockee = STACK_OBJECT(-1);
  1.1655 +        CHECK_NULL(lockee);
  1.1656 +        // derefing's lockee ought to provoke implicit null check
  1.1657 +        // find our monitor slot
  1.1658 +        BasicObjectLock* limit = istate->monitor_base();
  1.1659 +        BasicObjectLock* most_recent = (BasicObjectLock*) istate->stack_base();
  1.1660 +        while (most_recent != limit ) {
  1.1661 +          if ((most_recent)->obj() == lockee) {
  1.1662 +            BasicLock* lock = most_recent->lock();
  1.1663 +            markOop header = lock->displaced_header();
  1.1664 +            most_recent->set_obj(NULL);
  1.1665 +            // If it isn't recursive we either must swap old header or call the runtime
  1.1666 +            if (header != NULL) {
  1.1667 +              if (Atomic::cmpxchg_ptr(header, lockee->mark_addr(), lock) != lock) {
  1.1668 +                // restore object for the slow case
  1.1669 +                most_recent->set_obj(lockee);
  1.1670 +                CALL_VM(InterpreterRuntime::monitorexit(THREAD, most_recent), handle_exception);
  1.1671 +              }
  1.1672 +            }
  1.1673 +            UPDATE_PC_AND_TOS_AND_CONTINUE(1, -1);
  1.1674 +          }
  1.1675 +          most_recent++;
  1.1676 +        }
  1.1677 +        // Need to throw illegal monitor state exception
  1.1678 +        CALL_VM(InterpreterRuntime::throw_illegal_monitor_state_exception(THREAD), handle_exception);
  1.1679 +        // Should never reach here...
  1.1680 +        assert(false, "Should have thrown illegal monitor exception");
  1.1681 +      }
  1.1682 +
  1.1683 +      /* All of the non-quick opcodes. */
  1.1684 +
  1.1685 +      /* -Set clobbersCpIndex true if the quickened opcode clobbers the
  1.1686 +       *  constant pool index in the instruction.
  1.1687 +       */
  1.1688 +      CASE(_getfield):
  1.1689 +      CASE(_getstatic):
  1.1690 +        {
  1.1691 +          u2 index;
  1.1692 +          ConstantPoolCacheEntry* cache;
  1.1693 +          index = Bytes::get_native_u2(pc+1);
  1.1694 +
  1.1695 +          // QQQ Need to make this as inlined as possible. Probably need to
  1.1696 +          // split all the bytecode cases out so c++ compiler has a chance
  1.1697 +          // for constant prop to fold everything possible away.
  1.1698 +
  1.1699 +          cache = cp->entry_at(index);
  1.1700 +          if (!cache->is_resolved((Bytecodes::Code)opcode)) {
  1.1701 +            CALL_VM(InterpreterRuntime::resolve_get_put(THREAD, (Bytecodes::Code)opcode),
  1.1702 +                    handle_exception);
  1.1703 +            cache = cp->entry_at(index);
  1.1704 +          }
  1.1705 +
  1.1706 +#ifdef VM_JVMTI
  1.1707 +          if (_jvmti_interp_events) {
  1.1708 +            int *count_addr;
  1.1709 +            oop obj;
  1.1710 +            // Check to see if a field modification watch has been set
  1.1711 +            // before we take the time to call into the VM.
  1.1712 +            count_addr = (int *)JvmtiExport::get_field_access_count_addr();
  1.1713 +            if ( *count_addr > 0 ) {
  1.1714 +              if ((Bytecodes::Code)opcode == Bytecodes::_getstatic) {
  1.1715 +                obj = (oop)NULL;
  1.1716 +              } else {
  1.1717 +                obj = (oop) STACK_OBJECT(-1);
  1.1718 +              }
  1.1719 +              CALL_VM(InterpreterRuntime::post_field_access(THREAD,
  1.1720 +                                          obj,
  1.1721 +                                          cache),
  1.1722 +                                          handle_exception);
  1.1723 +            }
  1.1724 +          }
  1.1725 +#endif /* VM_JVMTI */
  1.1726 +
  1.1727 +          oop obj;
  1.1728 +          if ((Bytecodes::Code)opcode == Bytecodes::_getstatic) {
  1.1729 +            obj = (oop) cache->f1();
  1.1730 +            MORE_STACK(1);  // Assume single slot push
  1.1731 +          } else {
  1.1732 +            obj = (oop) STACK_OBJECT(-1);
  1.1733 +            CHECK_NULL(obj);
  1.1734 +          }
  1.1735 +
  1.1736 +          //
  1.1737 +          // Now store the result on the stack
  1.1738 +          //
  1.1739 +          TosState tos_type = cache->flag_state();
  1.1740 +          int field_offset = cache->f2();
  1.1741 +          if (cache->is_volatile()) {
  1.1742 +            if (tos_type == atos) {
  1.1743 +              SET_STACK_OBJECT(obj->obj_field_acquire(field_offset), -1);
  1.1744 +            } else if (tos_type == itos) {
  1.1745 +              SET_STACK_INT(obj->int_field_acquire(field_offset), -1);
  1.1746 +            } else if (tos_type == ltos) {
  1.1747 +              SET_STACK_LONG(obj->long_field_acquire(field_offset), 0);
  1.1748 +              MORE_STACK(1);
  1.1749 +            } else if (tos_type == btos) {
  1.1750 +              SET_STACK_INT(obj->byte_field_acquire(field_offset), -1);
  1.1751 +            } else if (tos_type == ctos) {
  1.1752 +              SET_STACK_INT(obj->char_field_acquire(field_offset), -1);
  1.1753 +            } else if (tos_type == stos) {
  1.1754 +              SET_STACK_INT(obj->short_field_acquire(field_offset), -1);
  1.1755 +            } else if (tos_type == ftos) {
  1.1756 +              SET_STACK_FLOAT(obj->float_field_acquire(field_offset), -1);
  1.1757 +            } else {
  1.1758 +              SET_STACK_DOUBLE(obj->double_field_acquire(field_offset), 0);
  1.1759 +              MORE_STACK(1);
  1.1760 +            }
  1.1761 +          } else {
  1.1762 +            if (tos_type == atos) {
  1.1763 +              SET_STACK_OBJECT(obj->obj_field(field_offset), -1);
  1.1764 +            } else if (tos_type == itos) {
  1.1765 +              SET_STACK_INT(obj->int_field(field_offset), -1);
  1.1766 +            } else if (tos_type == ltos) {
  1.1767 +              SET_STACK_LONG(obj->long_field(field_offset), 0);
  1.1768 +              MORE_STACK(1);
  1.1769 +            } else if (tos_type == btos) {
  1.1770 +              SET_STACK_INT(obj->byte_field(field_offset), -1);
  1.1771 +            } else if (tos_type == ctos) {
  1.1772 +              SET_STACK_INT(obj->char_field(field_offset), -1);
  1.1773 +            } else if (tos_type == stos) {
  1.1774 +              SET_STACK_INT(obj->short_field(field_offset), -1);
  1.1775 +            } else if (tos_type == ftos) {
  1.1776 +              SET_STACK_FLOAT(obj->float_field(field_offset), -1);
  1.1777 +            } else {
  1.1778 +              SET_STACK_DOUBLE(obj->double_field(field_offset), 0);
  1.1779 +              MORE_STACK(1);
  1.1780 +            }
  1.1781 +          }
  1.1782 +
  1.1783 +          UPDATE_PC_AND_CONTINUE(3);
  1.1784 +         }
  1.1785 +
  1.1786 +      CASE(_putfield):
  1.1787 +      CASE(_putstatic):
  1.1788 +        {
  1.1789 +          u2 index = Bytes::get_native_u2(pc+1);
  1.1790 +          ConstantPoolCacheEntry* cache = cp->entry_at(index);
  1.1791 +          if (!cache->is_resolved((Bytecodes::Code)opcode)) {
  1.1792 +            CALL_VM(InterpreterRuntime::resolve_get_put(THREAD, (Bytecodes::Code)opcode),
  1.1793 +                    handle_exception);
  1.1794 +            cache = cp->entry_at(index);
  1.1795 +          }
  1.1796 +
  1.1797 +#ifdef VM_JVMTI
  1.1798 +          if (_jvmti_interp_events) {
  1.1799 +            int *count_addr;
  1.1800 +            oop obj;
  1.1801 +            // Check to see if a field modification watch has been set
  1.1802 +            // before we take the time to call into the VM.
  1.1803 +            count_addr = (int *)JvmtiExport::get_field_modification_count_addr();
  1.1804 +            if ( *count_addr > 0 ) {
  1.1805 +              if ((Bytecodes::Code)opcode == Bytecodes::_putstatic) {
  1.1806 +                obj = (oop)NULL;
  1.1807 +              }
  1.1808 +              else {
  1.1809 +                if (cache->is_long() || cache->is_double()) {
  1.1810 +                  obj = (oop) STACK_OBJECT(-3);
  1.1811 +                } else {
  1.1812 +                  obj = (oop) STACK_OBJECT(-2);
  1.1813 +                }
  1.1814 +              }
  1.1815 +
  1.1816 +              CALL_VM(InterpreterRuntime::post_field_modification(THREAD,
  1.1817 +                                          obj,
  1.1818 +                                          cache,
  1.1819 +                                          (jvalue *)STACK_SLOT(-1)),
  1.1820 +                                          handle_exception);
  1.1821 +            }
  1.1822 +          }
  1.1823 +#endif /* VM_JVMTI */
  1.1824 +
  1.1825 +          // QQQ Need to make this as inlined as possible. Probably need to split all the bytecode cases
  1.1826 +          // out so c++ compiler has a chance for constant prop to fold everything possible away.
  1.1827 +
  1.1828 +          oop obj;
  1.1829 +          int count;
  1.1830 +          TosState tos_type = cache->flag_state();
  1.1831 +
  1.1832 +          count = -1;
  1.1833 +          if (tos_type == ltos || tos_type == dtos) {
  1.1834 +            --count;
  1.1835 +          }
  1.1836 +          if ((Bytecodes::Code)opcode == Bytecodes::_putstatic) {
  1.1837 +            obj = (oop) cache->f1();
  1.1838 +          } else {
  1.1839 +            --count;
  1.1840 +            obj = (oop) STACK_OBJECT(count);
  1.1841 +            CHECK_NULL(obj);
  1.1842 +          }
  1.1843 +
  1.1844 +          //
  1.1845 +          // Now store the result
  1.1846 +          //
  1.1847 +          int field_offset = cache->f2();
  1.1848 +          if (cache->is_volatile()) {
  1.1849 +            if (tos_type == itos) {
  1.1850 +              obj->release_int_field_put(field_offset, STACK_INT(-1));
  1.1851 +            } else if (tos_type == atos) {
  1.1852 +              obj->release_obj_field_put(field_offset, STACK_OBJECT(-1));
  1.1853 +              OrderAccess::release_store(&BYTE_MAP_BASE[(uintptr_t)obj >> CardTableModRefBS::card_shift], 0);
  1.1854 +            } else if (tos_type == btos) {
  1.1855 +              obj->release_byte_field_put(field_offset, STACK_INT(-1));
  1.1856 +            } else if (tos_type == ltos) {
  1.1857 +              obj->release_long_field_put(field_offset, STACK_LONG(-1));
  1.1858 +            } else if (tos_type == ctos) {
  1.1859 +              obj->release_char_field_put(field_offset, STACK_INT(-1));
  1.1860 +            } else if (tos_type == stos) {
  1.1861 +              obj->release_short_field_put(field_offset, STACK_INT(-1));
  1.1862 +            } else if (tos_type == ftos) {
  1.1863 +              obj->release_float_field_put(field_offset, STACK_FLOAT(-1));
  1.1864 +            } else {
  1.1865 +              obj->release_double_field_put(field_offset, STACK_DOUBLE(-1));
  1.1866 +            }
  1.1867 +            OrderAccess::storeload();
  1.1868 +          } else {
  1.1869 +            if (tos_type == itos) {
  1.1870 +              obj->int_field_put(field_offset, STACK_INT(-1));
  1.1871 +            } else if (tos_type == atos) {
  1.1872 +              obj->obj_field_put(field_offset, STACK_OBJECT(-1));
  1.1873 +              OrderAccess::release_store(&BYTE_MAP_BASE[(uintptr_t)obj >> CardTableModRefBS::card_shift], 0);
  1.1874 +            } else if (tos_type == btos) {
  1.1875 +              obj->byte_field_put(field_offset, STACK_INT(-1));
  1.1876 +            } else if (tos_type == ltos) {
  1.1877 +              obj->long_field_put(field_offset, STACK_LONG(-1));
  1.1878 +            } else if (tos_type == ctos) {
  1.1879 +              obj->char_field_put(field_offset, STACK_INT(-1));
  1.1880 +            } else if (tos_type == stos) {
  1.1881 +              obj->short_field_put(field_offset, STACK_INT(-1));
  1.1882 +            } else if (tos_type == ftos) {
  1.1883 +              obj->float_field_put(field_offset, STACK_FLOAT(-1));
  1.1884 +            } else {
  1.1885 +              obj->double_field_put(field_offset, STACK_DOUBLE(-1));
  1.1886 +            }
  1.1887 +          }
  1.1888 +
  1.1889 +          UPDATE_PC_AND_TOS_AND_CONTINUE(3, count);
  1.1890 +        }
  1.1891 +
  1.1892 +      CASE(_new): {
  1.1893 +        u2 index = Bytes::get_Java_u2(pc+1);
  1.1894 +        constantPoolOop constants = istate->method()->constants();
  1.1895 +        if (!constants->tag_at(index).is_unresolved_klass()) {
  1.1896 +          // Make sure klass is initialized and doesn't have a finalizer
  1.1897 +          oop entry = (klassOop) *constants->obj_at_addr(index);
  1.1898 +          assert(entry->is_klass(), "Should be resolved klass");
  1.1899 +          klassOop k_entry = (klassOop) entry;
  1.1900 +          assert(k_entry->klass_part()->oop_is_instance(), "Should be instanceKlass");
  1.1901 +          instanceKlass* ik = (instanceKlass*) k_entry->klass_part();
  1.1902 +          if ( ik->is_initialized() && ik->can_be_fastpath_allocated() ) {
  1.1903 +            size_t obj_size = ik->size_helper();
  1.1904 +            oop result = NULL;
  1.1905 +            // If the TLAB isn't pre-zeroed then we'll have to do it
  1.1906 +            bool need_zero = !ZeroTLAB;
  1.1907 +            if (UseTLAB) {
  1.1908 +              result = (oop) THREAD->tlab().allocate(obj_size);
  1.1909 +            }
  1.1910 +            if (result == NULL) {
  1.1911 +              need_zero = true;
  1.1912 +              // Try allocate in shared eden
  1.1913 +        retry:
  1.1914 +              HeapWord* compare_to = *Universe::heap()->top_addr();
  1.1915 +              HeapWord* new_top = compare_to + obj_size;
  1.1916 +              if (new_top <= *Universe::heap()->end_addr()) {
  1.1917 +                if (Atomic::cmpxchg_ptr(new_top, Universe::heap()->top_addr(), compare_to) != compare_to) {
  1.1918 +                  goto retry;
  1.1919 +                }
  1.1920 +                result = (oop) compare_to;
  1.1921 +              }
  1.1922 +            }
  1.1923 +            if (result != NULL) {
  1.1924 +              // Initialize object (if nonzero size and need) and then the header
  1.1925 +              if (need_zero ) {
  1.1926 +                HeapWord* to_zero = (HeapWord*) result + sizeof(oopDesc) / oopSize;
  1.1927 +                obj_size -= sizeof(oopDesc) / oopSize;
  1.1928 +                if (obj_size > 0 ) {
  1.1929 +                  memset(to_zero, 0, obj_size * HeapWordSize);
  1.1930 +                }
  1.1931 +              }
  1.1932 +              if (UseBiasedLocking) {
  1.1933 +                result->set_mark(ik->prototype_header());
  1.1934 +              } else {
  1.1935 +                result->set_mark(markOopDesc::prototype());
  1.1936 +              }
  1.1937 +              result->set_klass(k_entry);
  1.1938 +              SET_STACK_OBJECT(result, 0);
  1.1939 +              UPDATE_PC_AND_TOS_AND_CONTINUE(3, 1);
  1.1940 +            }
  1.1941 +          }
  1.1942 +        }
  1.1943 +        // Slow case allocation
  1.1944 +        CALL_VM(InterpreterRuntime::_new(THREAD, METHOD->constants(), index),
  1.1945 +                handle_exception);
  1.1946 +        SET_STACK_OBJECT(THREAD->vm_result(), 0);
  1.1947 +        THREAD->set_vm_result(NULL);
  1.1948 +        UPDATE_PC_AND_TOS_AND_CONTINUE(3, 1);
  1.1949 +      }
  1.1950 +      CASE(_anewarray): {
  1.1951 +        u2 index = Bytes::get_Java_u2(pc+1);
  1.1952 +        jint size = STACK_INT(-1);
  1.1953 +        CALL_VM(InterpreterRuntime::anewarray(THREAD, METHOD->constants(), index, size),
  1.1954 +                handle_exception);
  1.1955 +        SET_STACK_OBJECT(THREAD->vm_result(), -1);
  1.1956 +        THREAD->set_vm_result(NULL);
  1.1957 +        UPDATE_PC_AND_CONTINUE(3);
  1.1958 +      }
  1.1959 +      CASE(_multianewarray): {
  1.1960 +        jint dims = *(pc+3);
  1.1961 +        jint size = STACK_INT(-1);
  1.1962 +        // stack grows down, dimensions are up!
  1.1963 +        jint *dimarray =
  1.1964 +                   (jint*)&topOfStack[dims * Interpreter::stackElementWords()+
  1.1965 +                                      Interpreter::stackElementWords()-1];
  1.1966 +        //adjust pointer to start of stack element
  1.1967 +        CALL_VM(InterpreterRuntime::multianewarray(THREAD, dimarray),
  1.1968 +                handle_exception);
  1.1969 +        SET_STACK_OBJECT(THREAD->vm_result(), -dims);
  1.1970 +        THREAD->set_vm_result(NULL);
  1.1971 +        UPDATE_PC_AND_TOS_AND_CONTINUE(4, -(dims-1));
  1.1972 +      }
  1.1973 +      CASE(_checkcast):
  1.1974 +          if (STACK_OBJECT(-1) != NULL) {
  1.1975 +            u2 index = Bytes::get_Java_u2(pc+1);
  1.1976 +            if (ProfileInterpreter) {
  1.1977 +              // needs Profile_checkcast QQQ
  1.1978 +              ShouldNotReachHere();
  1.1979 +            }
  1.1980 +            // Constant pool may have actual klass or unresolved klass. If it is
  1.1981 +            // unresolved we must resolve it
  1.1982 +            if (METHOD->constants()->tag_at(index).is_unresolved_klass()) {
  1.1983 +              CALL_VM(InterpreterRuntime::quicken_io_cc(THREAD), handle_exception);
  1.1984 +            }
  1.1985 +            klassOop klassOf = (klassOop) *(METHOD->constants()->obj_at_addr(index));
  1.1986 +            klassOop objKlassOop = STACK_OBJECT(-1)->klass(); //ebx
  1.1987 +            //
  1.1988 +            // Check for compatibilty. This check must not GC!!
  1.1989 +            // Seems way more expensive now that we must dispatch
  1.1990 +            //
  1.1991 +            if (objKlassOop != klassOf &&
  1.1992 +                !objKlassOop->klass_part()->is_subtype_of(klassOf)) {
  1.1993 +              ResourceMark rm(THREAD);
  1.1994 +              const char* objName = Klass::cast(objKlassOop)->external_name();
  1.1995 +              const char* klassName = Klass::cast(klassOf)->external_name();
  1.1996 +              char* message = SharedRuntime::generate_class_cast_message(
  1.1997 +                objName, klassName);
  1.1998 +              VM_JAVA_ERROR(vmSymbols::java_lang_ClassCastException(), message);
  1.1999 +            }
  1.2000 +          } else {
  1.2001 +            if (UncommonNullCast) {
  1.2002 +//              istate->method()->set_null_cast_seen();
  1.2003 +// [RGV] Not sure what to do here!
  1.2004 +
  1.2005 +            }
  1.2006 +          }
  1.2007 +          UPDATE_PC_AND_CONTINUE(3);
  1.2008 +
  1.2009 +      CASE(_instanceof):
  1.2010 +          if (STACK_OBJECT(-1) == NULL) {
  1.2011 +            SET_STACK_INT(0, -1);
  1.2012 +          } else {
  1.2013 +            u2 index = Bytes::get_Java_u2(pc+1);
  1.2014 +            // Constant pool may have actual klass or unresolved klass. If it is
  1.2015 +            // unresolved we must resolve it
  1.2016 +            if (METHOD->constants()->tag_at(index).is_unresolved_klass()) {
  1.2017 +              CALL_VM(InterpreterRuntime::quicken_io_cc(THREAD), handle_exception);
  1.2018 +            }
  1.2019 +            klassOop klassOf = (klassOop) *(METHOD->constants()->obj_at_addr(index));
  1.2020 +            klassOop objKlassOop = STACK_OBJECT(-1)->klass();
  1.2021 +            //
  1.2022 +            // Check for compatibilty. This check must not GC!!
  1.2023 +            // Seems way more expensive now that we must dispatch
  1.2024 +            //
  1.2025 +            if ( objKlassOop == klassOf || objKlassOop->klass_part()->is_subtype_of(klassOf)) {
  1.2026 +              SET_STACK_INT(1, -1);
  1.2027 +            } else {
  1.2028 +              SET_STACK_INT(0, -1);
  1.2029 +            }
  1.2030 +          }
  1.2031 +          UPDATE_PC_AND_CONTINUE(3);
  1.2032 +
  1.2033 +      CASE(_ldc_w):
  1.2034 +      CASE(_ldc):
  1.2035 +        {
  1.2036 +          u2 index;
  1.2037 +          bool wide = false;
  1.2038 +          int incr = 2; // frequent case
  1.2039 +          if (opcode == Bytecodes::_ldc) {
  1.2040 +            index = pc[1];
  1.2041 +          } else {
  1.2042 +            index = Bytes::get_Java_u2(pc+1);
  1.2043 +            incr = 3;
  1.2044 +            wide = true;
  1.2045 +          }
  1.2046 +
  1.2047 +          constantPoolOop constants = METHOD->constants();
  1.2048 +          switch (constants->tag_at(index).value()) {
  1.2049 +          case JVM_CONSTANT_Integer:
  1.2050 +            SET_STACK_INT(constants->int_at(index), 0);
  1.2051 +            break;
  1.2052 +
  1.2053 +          case JVM_CONSTANT_Float:
  1.2054 +            SET_STACK_FLOAT(constants->float_at(index), 0);
  1.2055 +            break;
  1.2056 +
  1.2057 +          case JVM_CONSTANT_String:
  1.2058 +            SET_STACK_OBJECT(constants->resolved_string_at(index), 0);
  1.2059 +            break;
  1.2060 +
  1.2061 +          case JVM_CONSTANT_Class:
  1.2062 +            SET_STACK_OBJECT(constants->resolved_klass_at(index)->klass_part()->java_mirror(), 0);
  1.2063 +            break;
  1.2064 +
  1.2065 +          case JVM_CONSTANT_UnresolvedString:
  1.2066 +          case JVM_CONSTANT_UnresolvedClass:
  1.2067 +          case JVM_CONSTANT_UnresolvedClassInError:
  1.2068 +            CALL_VM(InterpreterRuntime::ldc(THREAD, wide), handle_exception);
  1.2069 +            SET_STACK_OBJECT(THREAD->vm_result(), 0);
  1.2070 +            THREAD->set_vm_result(NULL);
  1.2071 +            break;
  1.2072 +
  1.2073 +#if 0
  1.2074 +          CASE(_fast_igetfield):
  1.2075 +          CASE(_fastagetfield):
  1.2076 +          CASE(_fast_aload_0):
  1.2077 +          CASE(_fast_iaccess_0):
  1.2078 +          CASE(__fast_aaccess_0):
  1.2079 +          CASE(_fast_linearswitch):
  1.2080 +          CASE(_fast_binaryswitch):
  1.2081 +            fatal("unsupported fast bytecode");
  1.2082 +#endif
  1.2083 +
  1.2084 +          default:  ShouldNotReachHere();
  1.2085 +          }
  1.2086 +          UPDATE_PC_AND_TOS_AND_CONTINUE(incr, 1);
  1.2087 +        }
  1.2088 +
  1.2089 +      CASE(_ldc2_w):
  1.2090 +        {
  1.2091 +          u2 index = Bytes::get_Java_u2(pc+1);
  1.2092 +
  1.2093 +          constantPoolOop constants = METHOD->constants();
  1.2094 +          switch (constants->tag_at(index).value()) {
  1.2095 +
  1.2096 +          case JVM_CONSTANT_Long:
  1.2097 +             SET_STACK_LONG(constants->long_at(index), 1);
  1.2098 +            break;
  1.2099 +
  1.2100 +          case JVM_CONSTANT_Double:
  1.2101 +             SET_STACK_DOUBLE(constants->double_at(index), 1);
  1.2102 +            break;
  1.2103 +          default:  ShouldNotReachHere();
  1.2104 +          }
  1.2105 +          UPDATE_PC_AND_TOS_AND_CONTINUE(3, 2);
  1.2106 +        }
  1.2107 +
  1.2108 +      CASE(_invokeinterface): {
  1.2109 +        u2 index = Bytes::get_native_u2(pc+1);
  1.2110 +
  1.2111 +        // QQQ Need to make this as inlined as possible. Probably need to split all the bytecode cases
  1.2112 +        // out so c++ compiler has a chance for constant prop to fold everything possible away.
  1.2113 +
  1.2114 +        ConstantPoolCacheEntry* cache = cp->entry_at(index);
  1.2115 +        if (!cache->is_resolved((Bytecodes::Code)opcode)) {
  1.2116 +          CALL_VM(InterpreterRuntime::resolve_invoke(THREAD, (Bytecodes::Code)opcode),
  1.2117 +                  handle_exception);
  1.2118 +          cache = cp->entry_at(index);
  1.2119 +        }
  1.2120 +
  1.2121 +        istate->set_msg(call_method);
  1.2122 +
  1.2123 +        // Special case of invokeinterface called for virtual method of
  1.2124 +        // java.lang.Object.  See cpCacheOop.cpp for details.
  1.2125 +        // This code isn't produced by javac, but could be produced by
  1.2126 +        // another compliant java compiler.
  1.2127 +        if (cache->is_methodInterface()) {
  1.2128 +          methodOop callee;
  1.2129 +          CHECK_NULL(STACK_OBJECT(-(cache->parameter_size())));
  1.2130 +          if (cache->is_vfinal()) {
  1.2131 +            callee = (methodOop) cache->f2();
  1.2132 +          } else {
  1.2133 +            // get receiver
  1.2134 +            int parms = cache->parameter_size();
  1.2135 +            // Same comments as invokevirtual apply here
  1.2136 +            instanceKlass* rcvrKlass = (instanceKlass*)
  1.2137 +                                 STACK_OBJECT(-parms)->klass()->klass_part();
  1.2138 +            callee = (methodOop) rcvrKlass->start_of_vtable()[ cache->f2()];
  1.2139 +          }
  1.2140 +          istate->set_callee(callee);
  1.2141 +          istate->set_callee_entry_point(callee->from_interpreted_entry());
  1.2142 +#ifdef VM_JVMTI
  1.2143 +          if (JvmtiExport::can_post_interpreter_events() && THREAD->is_interp_only_mode()) {
  1.2144 +            istate->set_callee_entry_point(callee->interpreter_entry());
  1.2145 +          }
  1.2146 +#endif /* VM_JVMTI */
  1.2147 +          istate->set_bcp_advance(5);
  1.2148 +          UPDATE_PC_AND_RETURN(0); // I'll be back...
  1.2149 +        }
  1.2150 +
  1.2151 +        // this could definitely be cleaned up QQQ
  1.2152 +        methodOop callee;
  1.2153 +        klassOop iclass = (klassOop)cache->f1();
  1.2154 +        // instanceKlass* interface = (instanceKlass*) iclass->klass_part();
  1.2155 +        // get receiver
  1.2156 +        int parms = cache->parameter_size();
  1.2157 +        oop rcvr = STACK_OBJECT(-parms);
  1.2158 +        CHECK_NULL(rcvr);
  1.2159 +        instanceKlass* int2 = (instanceKlass*) rcvr->klass()->klass_part();
  1.2160 +        itableOffsetEntry* ki = (itableOffsetEntry*) int2->start_of_itable();
  1.2161 +        int i;
  1.2162 +        for ( i = 0 ; i < int2->itable_length() ; i++, ki++ ) {
  1.2163 +          if (ki->interface_klass() == iclass) break;
  1.2164 +        }
  1.2165 +        // If the interface isn't found, this class doesn't implement this
  1.2166 +        // interface.  The link resolver checks this but only for the first
  1.2167 +        // time this interface is called.
  1.2168 +        if (i == int2->itable_length()) {
  1.2169 +          VM_JAVA_ERROR(vmSymbols::java_lang_IncompatibleClassChangeError(), "");
  1.2170 +        }
  1.2171 +        int mindex = cache->f2();
  1.2172 +        itableMethodEntry* im = ki->first_method_entry(rcvr->klass());
  1.2173 +        callee = im[mindex].method();
  1.2174 +        if (callee == NULL) {
  1.2175 +          VM_JAVA_ERROR(vmSymbols::java_lang_AbstractMethodError(), "");
  1.2176 +        }
  1.2177 +
  1.2178 +        istate->set_callee(callee);
  1.2179 +        istate->set_callee_entry_point(callee->from_interpreted_entry());
  1.2180 +#ifdef VM_JVMTI
  1.2181 +        if (JvmtiExport::can_post_interpreter_events() && THREAD->is_interp_only_mode()) {
  1.2182 +          istate->set_callee_entry_point(callee->interpreter_entry());
  1.2183 +        }
  1.2184 +#endif /* VM_JVMTI */
  1.2185 +        istate->set_bcp_advance(5);
  1.2186 +        UPDATE_PC_AND_RETURN(0); // I'll be back...
  1.2187 +      }
  1.2188 +
  1.2189 +      CASE(_invokevirtual):
  1.2190 +      CASE(_invokespecial):
  1.2191 +      CASE(_invokestatic): {
  1.2192 +        u2 index = Bytes::get_native_u2(pc+1);
  1.2193 +
  1.2194 +        ConstantPoolCacheEntry* cache = cp->entry_at(index);
  1.2195 +        // QQQ Need to make this as inlined as possible. Probably need to split all the bytecode cases
  1.2196 +        // out so c++ compiler has a chance for constant prop to fold everything possible away.
  1.2197 +
  1.2198 +        if (!cache->is_resolved((Bytecodes::Code)opcode)) {
  1.2199 +          CALL_VM(InterpreterRuntime::resolve_invoke(THREAD, (Bytecodes::Code)opcode),
  1.2200 +                  handle_exception);
  1.2201 +          cache = cp->entry_at(index);
  1.2202 +        }
  1.2203 +
  1.2204 +        istate->set_msg(call_method);
  1.2205 +        {
  1.2206 +          methodOop callee;
  1.2207 +          if ((Bytecodes::Code)opcode == Bytecodes::_invokevirtual) {
  1.2208 +            CHECK_NULL(STACK_OBJECT(-(cache->parameter_size())));
  1.2209 +            if (cache->is_vfinal()) callee = (methodOop) cache->f2();
  1.2210 +            else {
  1.2211 +              // get receiver
  1.2212 +              int parms = cache->parameter_size();
  1.2213 +              // this works but needs a resourcemark and seems to create a vtable on every call:
  1.2214 +              // methodOop callee = rcvr->klass()->klass_part()->vtable()->method_at(cache->f2());
  1.2215 +              //
  1.2216 +              // this fails with an assert
  1.2217 +              // instanceKlass* rcvrKlass = instanceKlass::cast(STACK_OBJECT(-parms)->klass());
  1.2218 +              // but this works
  1.2219 +              instanceKlass* rcvrKlass = (instanceKlass*) STACK_OBJECT(-parms)->klass()->klass_part();
  1.2220 +              /*
  1.2221 +                Executing this code in java.lang.String:
  1.2222 +                    public String(char value[]) {
  1.2223 +                          this.count = value.length;
  1.2224 +                          this.value = (char[])value.clone();
  1.2225 +                     }
  1.2226 +
  1.2227 +                 a find on rcvr->klass()->klass_part() reports:
  1.2228 +                 {type array char}{type array class}
  1.2229 +                  - klass: {other class}
  1.2230 +
  1.2231 +                  but using instanceKlass::cast(STACK_OBJECT(-parms)->klass()) causes in assertion failure
  1.2232 +                  because rcvr->klass()->klass_part()->oop_is_instance() == 0
  1.2233 +                  However it seems to have a vtable in the right location. Huh?
  1.2234 +
  1.2235 +              */
  1.2236 +              callee = (methodOop) rcvrKlass->start_of_vtable()[ cache->f2()];
  1.2237 +            }
  1.2238 +          } else {
  1.2239 +            if ((Bytecodes::Code)opcode == Bytecodes::_invokespecial) {
  1.2240 +              CHECK_NULL(STACK_OBJECT(-(cache->parameter_size())));
  1.2241 +            }
  1.2242 +            callee = (methodOop) cache->f1();
  1.2243 +          }
  1.2244 +
  1.2245 +          istate->set_callee(callee);
  1.2246 +          istate->set_callee_entry_point(callee->from_interpreted_entry());
  1.2247 +#ifdef VM_JVMTI
  1.2248 +          if (JvmtiExport::can_post_interpreter_events() && THREAD->is_interp_only_mode()) {
  1.2249 +            istate->set_callee_entry_point(callee->interpreter_entry());
  1.2250 +          }
  1.2251 +#endif /* VM_JVMTI */
  1.2252 +          istate->set_bcp_advance(3);
  1.2253 +          UPDATE_PC_AND_RETURN(0); // I'll be back...
  1.2254 +        }
  1.2255 +      }
  1.2256 +
  1.2257 +      /* Allocate memory for a new java object. */
  1.2258 +
  1.2259 +      CASE(_newarray): {
  1.2260 +        BasicType atype = (BasicType) *(pc+1);
  1.2261 +        jint size = STACK_INT(-1);
  1.2262 +        CALL_VM(InterpreterRuntime::newarray(THREAD, atype, size),
  1.2263 +                handle_exception);
  1.2264 +        SET_STACK_OBJECT(THREAD->vm_result(), -1);
  1.2265 +        THREAD->set_vm_result(NULL);
  1.2266 +
  1.2267 +        UPDATE_PC_AND_CONTINUE(2);
  1.2268 +      }
  1.2269 +
  1.2270 +      /* Throw an exception. */
  1.2271 +
  1.2272 +      CASE(_athrow): {
  1.2273 +          oop except_oop = STACK_OBJECT(-1);
  1.2274 +          CHECK_NULL(except_oop);
  1.2275 +          // set pending_exception so we use common code
  1.2276 +          THREAD->set_pending_exception(except_oop, NULL, 0);
  1.2277 +          goto handle_exception;
  1.2278 +      }
  1.2279 +
  1.2280 +      /* goto and jsr. They are exactly the same except jsr pushes
  1.2281 +       * the address of the next instruction first.
  1.2282 +       */
  1.2283 +
  1.2284 +      CASE(_jsr): {
  1.2285 +          /* push bytecode index on stack */
  1.2286 +          SET_STACK_ADDR(((address)pc - (intptr_t)(istate->method()->code_base()) + 3), 0);
  1.2287 +          MORE_STACK(1);
  1.2288 +          /* FALL THROUGH */
  1.2289 +      }
  1.2290 +
  1.2291 +      CASE(_goto):
  1.2292 +      {
  1.2293 +          int16_t offset = (int16_t)Bytes::get_Java_u2(pc + 1);
  1.2294 +          address branch_pc = pc;
  1.2295 +          UPDATE_PC(offset);
  1.2296 +          DO_BACKEDGE_CHECKS(offset, branch_pc);
  1.2297 +          CONTINUE;
  1.2298 +      }
  1.2299 +
  1.2300 +      CASE(_jsr_w): {
  1.2301 +          /* push return address on the stack */
  1.2302 +          SET_STACK_ADDR(((address)pc - (intptr_t)(istate->method()->code_base()) + 5), 0);
  1.2303 +          MORE_STACK(1);
  1.2304 +          /* FALL THROUGH */
  1.2305 +      }
  1.2306 +
  1.2307 +      CASE(_goto_w):
  1.2308 +      {
  1.2309 +          int32_t offset = Bytes::get_Java_u4(pc + 1);
  1.2310 +          address branch_pc = pc;
  1.2311 +          UPDATE_PC(offset);
  1.2312 +          DO_BACKEDGE_CHECKS(offset, branch_pc);
  1.2313 +          CONTINUE;
  1.2314 +      }
  1.2315 +
  1.2316 +      /* return from a jsr or jsr_w */
  1.2317 +
  1.2318 +      CASE(_ret): {
  1.2319 +          pc = istate->method()->code_base() + (intptr_t)(LOCALS_ADDR(pc[1]));
  1.2320 +          UPDATE_PC_AND_CONTINUE(0);
  1.2321 +      }
  1.2322 +
  1.2323 +      /* debugger breakpoint */
  1.2324 +
  1.2325 +      CASE(_breakpoint): {
  1.2326 +          Bytecodes::Code original_bytecode;
  1.2327 +          DECACHE_STATE();
  1.2328 +          SET_LAST_JAVA_FRAME();
  1.2329 +          original_bytecode = InterpreterRuntime::get_original_bytecode_at(THREAD,
  1.2330 +                              METHOD, pc);
  1.2331 +          RESET_LAST_JAVA_FRAME();
  1.2332 +          CACHE_STATE();
  1.2333 +          if (THREAD->has_pending_exception()) goto handle_exception;
  1.2334 +            CALL_VM(InterpreterRuntime::_breakpoint(THREAD, METHOD, pc),
  1.2335 +                                                    handle_exception);
  1.2336 +
  1.2337 +          opcode = (jubyte)original_bytecode;
  1.2338 +          goto opcode_switch;
  1.2339 +      }
  1.2340 +
  1.2341 +      DEFAULT:
  1.2342 +          fatal2("\t*** Unimplemented opcode: %d = %s\n",
  1.2343 +                 opcode, Bytecodes::name((Bytecodes::Code)opcode));
  1.2344 +          goto finish;
  1.2345 +
  1.2346 +      } /* switch(opc) */
  1.2347 +
  1.2348 +
  1.2349 +#ifdef USELABELS
  1.2350 +    check_for_exception:
  1.2351 +#endif
  1.2352 +    {
  1.2353 +      if (!THREAD->has_pending_exception()) {
  1.2354 +        CONTINUE;
  1.2355 +      }
  1.2356 +      /* We will be gcsafe soon, so flush our state. */
  1.2357 +      DECACHE_PC();
  1.2358 +      goto handle_exception;
  1.2359 +    }
  1.2360 +  do_continue: ;
  1.2361 +
  1.2362 +  } /* while (1) interpreter loop */
  1.2363 +
  1.2364 +
  1.2365 +  // An exception exists in the thread state see whether this activation can handle it
  1.2366 +  handle_exception: {
  1.2367 +
  1.2368 +    HandleMarkCleaner __hmc(THREAD);
  1.2369 +    Handle except_oop(THREAD, THREAD->pending_exception());
  1.2370 +    // Prevent any subsequent HandleMarkCleaner in the VM
  1.2371 +    // from freeing the except_oop handle.
  1.2372 +    HandleMark __hm(THREAD);
  1.2373 +
  1.2374 +    THREAD->clear_pending_exception();
  1.2375 +    assert(except_oop(), "No exception to process");
  1.2376 +    intptr_t continuation_bci;
  1.2377 +    // expression stack is emptied
  1.2378 +    topOfStack = istate->stack_base() - Interpreter::stackElementWords();
  1.2379 +    CALL_VM(continuation_bci = (intptr_t)InterpreterRuntime::exception_handler_for_exception(THREAD, except_oop()),
  1.2380 +            handle_exception);
  1.2381 +
  1.2382 +    except_oop = (oop) THREAD->vm_result();
  1.2383 +    THREAD->set_vm_result(NULL);
  1.2384 +    if (continuation_bci >= 0) {
  1.2385 +      // Place exception on top of stack
  1.2386 +      SET_STACK_OBJECT(except_oop(), 0);
  1.2387 +      MORE_STACK(1);
  1.2388 +      pc = METHOD->code_base() + continuation_bci;
  1.2389 +      if (TraceExceptions) {
  1.2390 +        ttyLocker ttyl;
  1.2391 +        ResourceMark rm;
  1.2392 +        tty->print_cr("Exception <%s> (" INTPTR_FORMAT ")", except_oop->print_value_string(), except_oop());
  1.2393 +        tty->print_cr(" thrown in interpreter method <%s>", METHOD->print_value_string());
  1.2394 +        tty->print_cr(" at bci %d, continuing at %d for thread " INTPTR_FORMAT,
  1.2395 +                      pc - (intptr_t)METHOD->code_base(),
  1.2396 +                      continuation_bci, THREAD);
  1.2397 +      }
  1.2398 +      // for AbortVMOnException flag
  1.2399 +      NOT_PRODUCT(Exceptions::debug_check_abort(except_oop));
  1.2400 +      goto run;
  1.2401 +    }
  1.2402 +    if (TraceExceptions) {
  1.2403 +      ttyLocker ttyl;
  1.2404 +      ResourceMark rm;
  1.2405 +      tty->print_cr("Exception <%s> (" INTPTR_FORMAT ")", except_oop->print_value_string(), except_oop());
  1.2406 +      tty->print_cr(" thrown in interpreter method <%s>", METHOD->print_value_string());
  1.2407 +      tty->print_cr(" at bci %d, unwinding for thread " INTPTR_FORMAT,
  1.2408 +                    pc  - (intptr_t) METHOD->code_base(),
  1.2409 +                    THREAD);
  1.2410 +    }
  1.2411 +    // for AbortVMOnException flag
  1.2412 +    NOT_PRODUCT(Exceptions::debug_check_abort(except_oop));
  1.2413 +    // No handler in this activation, unwind and try again
  1.2414 +    THREAD->set_pending_exception(except_oop(), NULL, 0);
  1.2415 +    goto handle_return;
  1.2416 +  }  /* handle_exception: */
  1.2417 +
  1.2418 +
  1.2419 +
  1.2420 +  // Return from an interpreter invocation with the result of the interpretation
  1.2421 +  // on the top of the Java Stack (or a pending exception)
  1.2422 +
  1.2423 +handle_Pop_Frame:
  1.2424 +
  1.2425 +  // We don't really do anything special here except we must be aware
  1.2426 +  // that we can get here without ever locking the method (if sync).
  1.2427 +  // Also we skip the notification of the exit.
  1.2428 +
  1.2429 +  istate->set_msg(popping_frame);
  1.2430 +  // Clear pending so while the pop is in process
  1.2431 +  // we don't start another one if a call_vm is done.
  1.2432 +  THREAD->clr_pop_frame_pending();
  1.2433 +  // Let interpreter (only) see the we're in the process of popping a frame
  1.2434 +  THREAD->set_pop_frame_in_process();
  1.2435 +
  1.2436 +handle_return:
  1.2437 +  {
  1.2438 +    DECACHE_STATE();
  1.2439 +
  1.2440 +    bool suppress_error = istate->msg() == popping_frame;
  1.2441 +    bool suppress_exit_event = THREAD->has_pending_exception() || suppress_error;
  1.2442 +    Handle original_exception(THREAD, THREAD->pending_exception());
  1.2443 +    Handle illegal_state_oop(THREAD, NULL);
  1.2444 +
  1.2445 +    // We'd like a HandleMark here to prevent any subsequent HandleMarkCleaner
  1.2446 +    // in any following VM entries from freeing our live handles, but illegal_state_oop
  1.2447 +    // isn't really allocated yet and so doesn't become live until later and
  1.2448 +    // in unpredicatable places. Instead we must protect the places where we enter the
  1.2449 +    // VM. It would be much simpler (and safer) if we could allocate a real handle with
  1.2450 +    // a NULL oop in it and then overwrite the oop later as needed. This isn't
  1.2451 +    // unfortunately isn't possible.
  1.2452 +
  1.2453 +    THREAD->clear_pending_exception();
  1.2454 +
  1.2455 +    //
  1.2456 +    // As far as we are concerned we have returned. If we have a pending exception
  1.2457 +    // that will be returned as this invocation's result. However if we get any
  1.2458 +    // exception(s) while checking monitor state one of those IllegalMonitorStateExceptions
  1.2459 +    // will be our final result (i.e. monitor exception trumps a pending exception).
  1.2460 +    //
  1.2461 +
  1.2462 +    // If we never locked the method (or really passed the point where we would have),
  1.2463 +    // there is no need to unlock it (or look for other monitors), since that
  1.2464 +    // could not have happened.
  1.2465 +
  1.2466 +    if (THREAD->do_not_unlock()) {
  1.2467 +
  1.2468 +      // Never locked, reset the flag now because obviously any caller must
  1.2469 +      // have passed their point of locking for us to have gotten here.
  1.2470 +
  1.2471 +      THREAD->clr_do_not_unlock();
  1.2472 +    } else {
  1.2473 +      // At this point we consider that we have returned. We now check that the
  1.2474 +      // locks were properly block structured. If we find that they were not
  1.2475 +      // used properly we will return with an illegal monitor exception.
  1.2476 +      // The exception is checked by the caller not the callee since this
  1.2477 +      // checking is considered to be part of the invocation and therefore
  1.2478 +      // in the callers scope (JVM spec 8.13).
  1.2479 +      //
  1.2480 +      // Another weird thing to watch for is if the method was locked
  1.2481 +      // recursively and then not exited properly. This means we must
  1.2482 +      // examine all the entries in reverse time(and stack) order and
  1.2483 +      // unlock as we find them. If we find the method monitor before
  1.2484 +      // we are at the initial entry then we should throw an exception.
  1.2485 +      // It is not clear the template based interpreter does this
  1.2486 +      // correctly
  1.2487 +
  1.2488 +      BasicObjectLock* base = istate->monitor_base();
  1.2489 +      BasicObjectLock* end = (BasicObjectLock*) istate->stack_base();
  1.2490 +      bool method_unlock_needed = METHOD->is_synchronized();
  1.2491 +      // We know the initial monitor was used for the method don't check that
  1.2492 +      // slot in the loop
  1.2493 +      if (method_unlock_needed) base--;
  1.2494 +
  1.2495 +      // Check all the monitors to see they are unlocked. Install exception if found to be locked.
  1.2496 +      while (end < base) {
  1.2497 +        oop lockee = end->obj();
  1.2498 +        if (lockee != NULL) {
  1.2499 +          BasicLock* lock = end->lock();
  1.2500 +          markOop header = lock->displaced_header();
  1.2501 +          end->set_obj(NULL);
  1.2502 +          // If it isn't recursive we either must swap old header or call the runtime
  1.2503 +          if (header != NULL) {
  1.2504 +            if (Atomic::cmpxchg_ptr(header, lockee->mark_addr(), lock) != lock) {
  1.2505 +              // restore object for the slow case
  1.2506 +              end->set_obj(lockee);
  1.2507 +              {
  1.2508 +                // Prevent any HandleMarkCleaner from freeing our live handles
  1.2509 +                HandleMark __hm(THREAD);
  1.2510 +                CALL_VM_NOCHECK(InterpreterRuntime::monitorexit(THREAD, end));
  1.2511 +              }
  1.2512 +            }
  1.2513 +          }
  1.2514 +          // One error is plenty
  1.2515 +          if (illegal_state_oop() == NULL && !suppress_error) {
  1.2516 +            {
  1.2517 +              // Prevent any HandleMarkCleaner from freeing our live handles
  1.2518 +              HandleMark __hm(THREAD);
  1.2519 +              CALL_VM_NOCHECK(InterpreterRuntime::throw_illegal_monitor_state_exception(THREAD));
  1.2520 +            }
  1.2521 +            assert(THREAD->has_pending_exception(), "Lost our exception!");
  1.2522 +            illegal_state_oop = THREAD->pending_exception();
  1.2523 +            THREAD->clear_pending_exception();
  1.2524 +          }
  1.2525 +        }
  1.2526 +        end++;
  1.2527 +      }
  1.2528 +      // Unlock the method if needed
  1.2529 +      if (method_unlock_needed) {
  1.2530 +        if (base->obj() == NULL) {
  1.2531 +          // The method is already unlocked this is not good.
  1.2532 +          if (illegal_state_oop() == NULL && !suppress_error) {
  1.2533 +            {
  1.2534 +              // Prevent any HandleMarkCleaner from freeing our live handles
  1.2535 +              HandleMark __hm(THREAD);
  1.2536 +              CALL_VM_NOCHECK(InterpreterRuntime::throw_illegal_monitor_state_exception(THREAD));
  1.2537 +            }
  1.2538 +            assert(THREAD->has_pending_exception(), "Lost our exception!");
  1.2539 +            illegal_state_oop = THREAD->pending_exception();
  1.2540 +            THREAD->clear_pending_exception();
  1.2541 +          }
  1.2542 +        } else {
  1.2543 +          //
  1.2544 +          // The initial monitor is always used for the method
  1.2545 +          // However if that slot is no longer the oop for the method it was unlocked
  1.2546 +          // and reused by something that wasn't unlocked!
  1.2547 +          //
  1.2548 +          // deopt can come in with rcvr dead because c2 knows
  1.2549 +          // its value is preserved in the monitor. So we can't use locals[0] at all
  1.2550 +          // and must use first monitor slot.
  1.2551 +          //
  1.2552 +          oop rcvr = base->obj();
  1.2553 +          if (rcvr == NULL) {
  1.2554 +            if (!suppress_error) {
  1.2555 +              VM_JAVA_ERROR_NO_JUMP(vmSymbols::java_lang_NullPointerException(), "");
  1.2556 +              illegal_state_oop = THREAD->pending_exception();
  1.2557 +              THREAD->clear_pending_exception();
  1.2558 +            }
  1.2559 +          } else {
  1.2560 +            BasicLock* lock = base->lock();
  1.2561 +            markOop header = lock->displaced_header();
  1.2562 +            base->set_obj(NULL);
  1.2563 +            // If it isn't recursive we either must swap old header or call the runtime
  1.2564 +            if (header != NULL) {
  1.2565 +              if (Atomic::cmpxchg_ptr(header, rcvr->mark_addr(), lock) != lock) {
  1.2566 +                // restore object for the slow case
  1.2567 +                base->set_obj(rcvr);
  1.2568 +                {
  1.2569 +                  // Prevent any HandleMarkCleaner from freeing our live handles
  1.2570 +                  HandleMark __hm(THREAD);
  1.2571 +                  CALL_VM_NOCHECK(InterpreterRuntime::monitorexit(THREAD, base));
  1.2572 +                }
  1.2573 +                if (THREAD->has_pending_exception()) {
  1.2574 +                  if (!suppress_error) illegal_state_oop = THREAD->pending_exception();
  1.2575 +                  THREAD->clear_pending_exception();
  1.2576 +                }
  1.2577 +              }
  1.2578 +            }
  1.2579 +          }
  1.2580 +        }
  1.2581 +      }
  1.2582 +    }
  1.2583 +
  1.2584 +    //
  1.2585 +    // Notify jvmti/jvmdi
  1.2586 +    //
  1.2587 +    // NOTE: we do not notify a method_exit if we have a pending exception,
  1.2588 +    // including an exception we generate for unlocking checks.  In the former
  1.2589 +    // case, JVMDI has already been notified by our call for the exception handler
  1.2590 +    // and in both cases as far as JVMDI is concerned we have already returned.
  1.2591 +    // If we notify it again JVMDI will be all confused about how many frames
  1.2592 +    // are still on the stack (4340444).
  1.2593 +    //
  1.2594 +    // NOTE Further! It turns out the the JVMTI spec in fact expects to see
  1.2595 +    // method_exit events whenever we leave an activation unless it was done
  1.2596 +    // for popframe. This is nothing like jvmdi. However we are passing the
  1.2597 +    // tests at the moment (apparently because they are jvmdi based) so rather
  1.2598 +    // than change this code and possibly fail tests we will leave it alone
  1.2599 +    // (with this note) in anticipation of changing the vm and the tests
  1.2600 +    // simultaneously.
  1.2601 +
  1.2602 +
  1.2603 +    //
  1.2604 +    suppress_exit_event = suppress_exit_event || illegal_state_oop() != NULL;
  1.2605 +
  1.2606 +
  1.2607 +
  1.2608 +#ifdef VM_JVMTI
  1.2609 +      if (_jvmti_interp_events) {
  1.2610 +        // Whenever JVMTI puts a thread in interp_only_mode, method
  1.2611 +        // entry/exit events are sent for that thread to track stack depth.
  1.2612 +        if ( !suppress_exit_event && THREAD->is_interp_only_mode() ) {
  1.2613 +          {
  1.2614 +            // Prevent any HandleMarkCleaner from freeing our live handles
  1.2615 +            HandleMark __hm(THREAD);
  1.2616 +            CALL_VM_NOCHECK(InterpreterRuntime::post_method_exit(THREAD));
  1.2617 +          }
  1.2618 +        }
  1.2619 +      }
  1.2620 +#endif /* VM_JVMTI */
  1.2621 +
  1.2622 +    //
  1.2623 +    // See if we are returning any exception
  1.2624 +    // A pending exception that was pending prior to a possible popping frame
  1.2625 +    // overrides the popping frame.
  1.2626 +    //
  1.2627 +    assert(!suppress_error || suppress_error && illegal_state_oop() == NULL, "Error was not suppressed");
  1.2628 +    if (illegal_state_oop() != NULL || original_exception() != NULL) {
  1.2629 +      // inform the frame manager we have no result
  1.2630 +      istate->set_msg(throwing_exception);
  1.2631 +      if (illegal_state_oop() != NULL)
  1.2632 +        THREAD->set_pending_exception(illegal_state_oop(), NULL, 0);
  1.2633 +      else
  1.2634 +        THREAD->set_pending_exception(original_exception(), NULL, 0);
  1.2635 +      istate->set_return_kind((Bytecodes::Code)opcode);
  1.2636 +      UPDATE_PC_AND_RETURN(0);
  1.2637 +    }
  1.2638 +
  1.2639 +    if (istate->msg() == popping_frame) {
  1.2640 +      // Make it simpler on the assembly code and set the message for the frame pop.
  1.2641 +      // returns
  1.2642 +      if (istate->prev() == NULL) {
  1.2643 +        // We must be returning to a deoptimized frame (because popframe only happens between
  1.2644 +        // two interpreted frames). We need to save the current arguments in C heap so that
  1.2645 +        // the deoptimized frame when it restarts can copy the arguments to its expression
  1.2646 +        // stack and re-execute the call. We also have to notify deoptimization that this
  1.2647 +        // has occured and to pick the preerved args copy them to the deoptimized frame's
  1.2648 +        // java expression stack. Yuck.
  1.2649 +        //
  1.2650 +        THREAD->popframe_preserve_args(in_ByteSize(METHOD->size_of_parameters() * wordSize),
  1.2651 +                                LOCALS_SLOT(METHOD->size_of_parameters() - 1));
  1.2652 +        THREAD->set_popframe_condition_bit(JavaThread::popframe_force_deopt_reexecution_bit);
  1.2653 +      }
  1.2654 +      UPDATE_PC_AND_RETURN(1);
  1.2655 +    } else {
  1.2656 +      // Normal return
  1.2657 +      // Advance the pc and return to frame manager
  1.2658 +      istate->set_msg(return_from_method);
  1.2659 +      istate->set_return_kind((Bytecodes::Code)opcode);
  1.2660 +      UPDATE_PC_AND_RETURN(1);
  1.2661 +    }
  1.2662 +  } /* handle_return: */
  1.2663 +
  1.2664 +// This is really a fatal error return
  1.2665 +
  1.2666 +finish:
  1.2667 +  DECACHE_TOS();
  1.2668 +  DECACHE_PC();
  1.2669 +
  1.2670 +  return;
  1.2671 +}
  1.2672 +
  1.2673 +/*
  1.2674 + * All the code following this point is only produced once and is not present
  1.2675 + * in the JVMTI version of the interpreter
  1.2676 +*/
  1.2677 +
  1.2678 +#ifndef VM_JVMTI
  1.2679 +
  1.2680 +// This constructor should only be used to contruct the object to signal
  1.2681 +// interpreter initialization. All other instances should be created by
  1.2682 +// the frame manager.
  1.2683 +BytecodeInterpreter::BytecodeInterpreter(messages msg) {
  1.2684 +  if (msg != initialize) ShouldNotReachHere();
  1.2685 +  _msg = msg;
  1.2686 +  _self_link = this;
  1.2687 +  _prev_link = NULL;
  1.2688 +}
  1.2689 +
  1.2690 +// Inline static functions for Java Stack and Local manipulation
  1.2691 +
  1.2692 +// The implementations are platform dependent. We have to worry about alignment
  1.2693 +// issues on some machines which can change on the same platform depending on
  1.2694 +// whether it is an LP64 machine also.
  1.2695 +#ifdef ASSERT
  1.2696 +void BytecodeInterpreter::verify_stack_tag(intptr_t *tos, frame::Tag tag, int offset) {
  1.2697 +  if (TaggedStackInterpreter) {
  1.2698 +    frame::Tag t = (frame::Tag)tos[Interpreter::expr_tag_index_at(-offset)];
  1.2699 +    assert(t == tag, "stack tag mismatch");
  1.2700 +  }
  1.2701 +}
  1.2702 +#endif // ASSERT
  1.2703 +
  1.2704 +address BytecodeInterpreter::stack_slot(intptr_t *tos, int offset) {
  1.2705 +  debug_only(verify_stack_tag(tos, frame::TagValue, offset));
  1.2706 +  return (address) tos[Interpreter::expr_index_at(-offset)];
  1.2707 +}
  1.2708 +
  1.2709 +jint BytecodeInterpreter::stack_int(intptr_t *tos, int offset) {
  1.2710 +  debug_only(verify_stack_tag(tos, frame::TagValue, offset));
  1.2711 +  return *((jint*) &tos[Interpreter::expr_index_at(-offset)]);
  1.2712 +}
  1.2713 +
  1.2714 +jfloat BytecodeInterpreter::stack_float(intptr_t *tos, int offset) {
  1.2715 +  debug_only(verify_stack_tag(tos, frame::TagValue, offset));
  1.2716 +  return *((jfloat *) &tos[Interpreter::expr_index_at(-offset)]);
  1.2717 +}
  1.2718 +
  1.2719 +oop BytecodeInterpreter::stack_object(intptr_t *tos, int offset) {
  1.2720 +  debug_only(verify_stack_tag(tos, frame::TagReference, offset));
  1.2721 +  return (oop)tos [Interpreter::expr_index_at(-offset)];
  1.2722 +}
  1.2723 +
  1.2724 +jdouble BytecodeInterpreter::stack_double(intptr_t *tos, int offset) {
  1.2725 +  debug_only(verify_stack_tag(tos, frame::TagValue, offset));
  1.2726 +  debug_only(verify_stack_tag(tos, frame::TagValue, offset-1));
  1.2727 +  return ((VMJavaVal64*) &tos[Interpreter::expr_index_at(-offset)])->d;
  1.2728 +}
  1.2729 +
  1.2730 +jlong BytecodeInterpreter::stack_long(intptr_t *tos, int offset) {
  1.2731 +  debug_only(verify_stack_tag(tos, frame::TagValue, offset));
  1.2732 +  debug_only(verify_stack_tag(tos, frame::TagValue, offset-1));
  1.2733 +  return ((VMJavaVal64 *) &tos[Interpreter::expr_index_at(-offset)])->l;
  1.2734 +}
  1.2735 +
  1.2736 +void BytecodeInterpreter::tag_stack(intptr_t *tos, frame::Tag tag, int offset) {
  1.2737 +  if (TaggedStackInterpreter)
  1.2738 +    tos[Interpreter::expr_tag_index_at(-offset)] = (intptr_t)tag;
  1.2739 +}
  1.2740 +
  1.2741 +// only used for value types
  1.2742 +void BytecodeInterpreter::set_stack_slot(intptr_t *tos, address value,
  1.2743 +                                                        int offset) {
  1.2744 +  tag_stack(tos, frame::TagValue, offset);
  1.2745 +  *((address *)&tos[Interpreter::expr_index_at(-offset)]) = value;
  1.2746 +}
  1.2747 +
  1.2748 +void BytecodeInterpreter::set_stack_int(intptr_t *tos, int value,
  1.2749 +                                                       int offset) {
  1.2750 +  tag_stack(tos, frame::TagValue, offset);
  1.2751 +  *((jint *)&tos[Interpreter::expr_index_at(-offset)]) = value;
  1.2752 +}
  1.2753 +
  1.2754 +void BytecodeInterpreter::set_stack_float(intptr_t *tos, jfloat value,
  1.2755 +                                                         int offset) {
  1.2756 +  tag_stack(tos, frame::TagValue, offset);
  1.2757 +  *((jfloat *)&tos[Interpreter::expr_index_at(-offset)]) = value;
  1.2758 +}
  1.2759 +
  1.2760 +void BytecodeInterpreter::set_stack_object(intptr_t *tos, oop value,
  1.2761 +                                                          int offset) {
  1.2762 +  tag_stack(tos, frame::TagReference, offset);
  1.2763 +  *((oop *)&tos[Interpreter::expr_index_at(-offset)]) = value;
  1.2764 +}
  1.2765 +
  1.2766 +// needs to be platform dep for the 32 bit platforms.
  1.2767 +void BytecodeInterpreter::set_stack_double(intptr_t *tos, jdouble value,
  1.2768 +                                                          int offset) {
  1.2769 +  tag_stack(tos, frame::TagValue, offset);
  1.2770 +  tag_stack(tos, frame::TagValue, offset-1);
  1.2771 +  ((VMJavaVal64*)&tos[Interpreter::expr_index_at(-offset)])->d = value;
  1.2772 +}
  1.2773 +
  1.2774 +void BytecodeInterpreter::set_stack_double_from_addr(intptr_t *tos,
  1.2775 +                                              address addr, int offset) {
  1.2776 +  tag_stack(tos, frame::TagValue, offset);
  1.2777 +  tag_stack(tos, frame::TagValue, offset-1);
  1.2778 +  (((VMJavaVal64*)&tos[Interpreter::expr_index_at(-offset)])->d =
  1.2779 +                        ((VMJavaVal64*)addr)->d);
  1.2780 +}
  1.2781 +
  1.2782 +void BytecodeInterpreter::set_stack_long(intptr_t *tos, jlong value,
  1.2783 +                                                        int offset) {
  1.2784 +  tag_stack(tos, frame::TagValue, offset);
  1.2785 +  ((VMJavaVal64*)&tos[Interpreter::expr_index_at(-offset+1)])->l = 0xdeedbeeb;
  1.2786 +  tag_stack(tos, frame::TagValue, offset-1);
  1.2787 +  ((VMJavaVal64*)&tos[Interpreter::expr_index_at(-offset)])->l = value;
  1.2788 +}
  1.2789 +
  1.2790 +void BytecodeInterpreter::set_stack_long_from_addr(intptr_t *tos,
  1.2791 +                                            address addr, int offset) {
  1.2792 +  tag_stack(tos, frame::TagValue, offset);
  1.2793 +  ((VMJavaVal64*)&tos[Interpreter::expr_index_at(-offset+1)])->l = 0xdeedbeeb;
  1.2794 +  tag_stack(tos, frame::TagValue, offset-1);
  1.2795 +  ((VMJavaVal64*)&tos[Interpreter::expr_index_at(-offset)])->l =
  1.2796 +                        ((VMJavaVal64*)addr)->l;
  1.2797 +}
  1.2798 +
  1.2799 +// Locals
  1.2800 +
  1.2801 +#ifdef ASSERT
  1.2802 +void BytecodeInterpreter::verify_locals_tag(intptr_t *locals, frame::Tag tag,
  1.2803 +                                     int offset) {
  1.2804 +  if (TaggedStackInterpreter) {
  1.2805 +    frame::Tag t = (frame::Tag)locals[Interpreter::local_tag_index_at(-offset)];
  1.2806 +    assert(t == tag, "locals tag mismatch");
  1.2807 +  }
  1.2808 +}
  1.2809 +#endif // ASSERT
  1.2810 +address BytecodeInterpreter::locals_slot(intptr_t* locals, int offset) {
  1.2811 +  debug_only(verify_locals_tag(locals, frame::TagValue, offset));
  1.2812 +  return (address)locals[Interpreter::local_index_at(-offset)];
  1.2813 +}
  1.2814 +jint BytecodeInterpreter::locals_int(intptr_t* locals, int offset) {
  1.2815 +  debug_only(verify_locals_tag(locals, frame::TagValue, offset));
  1.2816 +  return (jint)locals[Interpreter::local_index_at(-offset)];
  1.2817 +}
  1.2818 +jfloat BytecodeInterpreter::locals_float(intptr_t* locals, int offset) {
  1.2819 +  debug_only(verify_locals_tag(locals, frame::TagValue, offset));
  1.2820 +  return (jfloat)locals[Interpreter::local_index_at(-offset)];
  1.2821 +}
  1.2822 +oop BytecodeInterpreter::locals_object(intptr_t* locals, int offset) {
  1.2823 +  debug_only(verify_locals_tag(locals, frame::TagReference, offset));
  1.2824 +  return (oop)locals[Interpreter::local_index_at(-offset)];
  1.2825 +}
  1.2826 +jdouble BytecodeInterpreter::locals_double(intptr_t* locals, int offset) {
  1.2827 +  debug_only(verify_locals_tag(locals, frame::TagValue, offset));
  1.2828 +  debug_only(verify_locals_tag(locals, frame::TagValue, offset));
  1.2829 +  return ((VMJavaVal64*)&locals[Interpreter::local_index_at(-(offset+1))])->d;
  1.2830 +}
  1.2831 +jlong BytecodeInterpreter::locals_long(intptr_t* locals, int offset) {
  1.2832 +  debug_only(verify_locals_tag(locals, frame::TagValue, offset));
  1.2833 +  debug_only(verify_locals_tag(locals, frame::TagValue, offset+1));
  1.2834 +  return ((VMJavaVal64*)&locals[Interpreter::local_index_at(-(offset+1))])->l;
  1.2835 +}
  1.2836 +
  1.2837 +// Returns the address of locals value.
  1.2838 +address BytecodeInterpreter::locals_long_at(intptr_t* locals, int offset) {
  1.2839 +  debug_only(verify_locals_tag(locals, frame::TagValue, offset));
  1.2840 +  debug_only(verify_locals_tag(locals, frame::TagValue, offset+1));
  1.2841 +  return ((address)&locals[Interpreter::local_index_at(-(offset+1))]);
  1.2842 +}
  1.2843 +address BytecodeInterpreter::locals_double_at(intptr_t* locals, int offset) {
  1.2844 +  debug_only(verify_locals_tag(locals, frame::TagValue, offset));
  1.2845 +  debug_only(verify_locals_tag(locals, frame::TagValue, offset+1));
  1.2846 +  return ((address)&locals[Interpreter::local_index_at(-(offset+1))]);
  1.2847 +}
  1.2848 +
  1.2849 +void BytecodeInterpreter::tag_locals(intptr_t *locals, frame::Tag tag, int offset) {
  1.2850 +  if (TaggedStackInterpreter)
  1.2851 +    locals[Interpreter::local_tag_index_at(-offset)] = (intptr_t)tag;
  1.2852 +}
  1.2853 +
  1.2854 +// Used for local value or returnAddress
  1.2855 +void BytecodeInterpreter::set_locals_slot(intptr_t *locals,
  1.2856 +                                   address value, int offset) {
  1.2857 +  tag_locals(locals, frame::TagValue, offset);
  1.2858 +  *((address*)&locals[Interpreter::local_index_at(-offset)]) = value;
  1.2859 +}
  1.2860 +void BytecodeInterpreter::set_locals_int(intptr_t *locals,
  1.2861 +                                   jint value, int offset) {
  1.2862 +  tag_locals(locals, frame::TagValue, offset);
  1.2863 +  *((jint *)&locals[Interpreter::local_index_at(-offset)]) = value;
  1.2864 +}
  1.2865 +void BytecodeInterpreter::set_locals_float(intptr_t *locals,
  1.2866 +                                   jfloat value, int offset) {
  1.2867 +  tag_locals(locals, frame::TagValue, offset);
  1.2868 +  *((jfloat *)&locals[Interpreter::local_index_at(-offset)]) = value;
  1.2869 +}
  1.2870 +void BytecodeInterpreter::set_locals_object(intptr_t *locals,
  1.2871 +                                   oop value, int offset) {
  1.2872 +  tag_locals(locals, frame::TagReference, offset);
  1.2873 +  *((oop *)&locals[Interpreter::local_index_at(-offset)]) = value;
  1.2874 +}
  1.2875 +void BytecodeInterpreter::set_locals_double(intptr_t *locals,
  1.2876 +                                   jdouble value, int offset) {
  1.2877 +  tag_locals(locals, frame::TagValue, offset);
  1.2878 +  tag_locals(locals, frame::TagValue, offset+1);
  1.2879 +  ((VMJavaVal64*)&locals[Interpreter::local_index_at(-(offset+1))])->d = value;
  1.2880 +}
  1.2881 +void BytecodeInterpreter::set_locals_long(intptr_t *locals,
  1.2882 +                                   jlong value, int offset) {
  1.2883 +  tag_locals(locals, frame::TagValue, offset);
  1.2884 +  tag_locals(locals, frame::TagValue, offset+1);
  1.2885 +  ((VMJavaVal64*)&locals[Interpreter::local_index_at(-(offset+1))])->l = value;
  1.2886 +}
  1.2887 +void BytecodeInterpreter::set_locals_double_from_addr(intptr_t *locals,
  1.2888 +                                   address addr, int offset) {
  1.2889 +  tag_locals(locals, frame::TagValue, offset);
  1.2890 +  tag_locals(locals, frame::TagValue, offset+1);
  1.2891 +  ((VMJavaVal64*)&locals[Interpreter::local_index_at(-(offset+1))])->d = ((VMJavaVal64*)addr)->d;
  1.2892 +}
  1.2893 +void BytecodeInterpreter::set_locals_long_from_addr(intptr_t *locals,
  1.2894 +                                   address addr, int offset) {
  1.2895 +  tag_locals(locals, frame::TagValue, offset);
  1.2896 +  tag_locals(locals, frame::TagValue, offset+1);
  1.2897 +  ((VMJavaVal64*)&locals[Interpreter::local_index_at(-(offset+1))])->l = ((VMJavaVal64*)addr)->l;
  1.2898 +}
  1.2899 +
  1.2900 +void BytecodeInterpreter::astore(intptr_t* tos,    int stack_offset,
  1.2901 +                          intptr_t* locals, int locals_offset) {
  1.2902 +  // Copy tag from stack to locals.  astore's operand can be returnAddress
  1.2903 +  // and may not be TagReference
  1.2904 +  if (TaggedStackInterpreter) {
  1.2905 +    frame::Tag t = (frame::Tag) tos[Interpreter::expr_tag_index_at(-stack_offset)];
  1.2906 +    locals[Interpreter::local_tag_index_at(-locals_offset)] = (intptr_t)t;
  1.2907 +  }
  1.2908 +  intptr_t value = tos[Interpreter::expr_index_at(-stack_offset)];
  1.2909 +  locals[Interpreter::local_index_at(-locals_offset)] = value;
  1.2910 +}
  1.2911 +
  1.2912 +
  1.2913 +void BytecodeInterpreter::copy_stack_slot(intptr_t *tos, int from_offset,
  1.2914 +                                   int to_offset) {
  1.2915 +  if (TaggedStackInterpreter) {
  1.2916 +    tos[Interpreter::expr_tag_index_at(-to_offset)] =
  1.2917 +                      (intptr_t)tos[Interpreter::expr_tag_index_at(-from_offset)];
  1.2918 +  }
  1.2919 +  tos[Interpreter::expr_index_at(-to_offset)] =
  1.2920 +                      (intptr_t)tos[Interpreter::expr_index_at(-from_offset)];
  1.2921 +}
  1.2922 +
  1.2923 +void BytecodeInterpreter::dup(intptr_t *tos) {
  1.2924 +  copy_stack_slot(tos, -1, 0);
  1.2925 +}
  1.2926 +void BytecodeInterpreter::dup2(intptr_t *tos) {
  1.2927 +  copy_stack_slot(tos, -2, 0);
  1.2928 +  copy_stack_slot(tos, -1, 1);
  1.2929 +}
  1.2930 +
  1.2931 +void BytecodeInterpreter::dup_x1(intptr_t *tos) {
  1.2932 +  /* insert top word two down */
  1.2933 +  copy_stack_slot(tos, -1, 0);
  1.2934 +  copy_stack_slot(tos, -2, -1);
  1.2935 +  copy_stack_slot(tos, 0, -2);
  1.2936 +}
  1.2937 +
  1.2938 +void BytecodeInterpreter::dup_x2(intptr_t *tos) {
  1.2939 +  /* insert top word three down  */
  1.2940 +  copy_stack_slot(tos, -1, 0);
  1.2941 +  copy_stack_slot(tos, -2, -1);
  1.2942 +  copy_stack_slot(tos, -3, -2);
  1.2943 +  copy_stack_slot(tos, 0, -3);
  1.2944 +}
  1.2945 +void BytecodeInterpreter::dup2_x1(intptr_t *tos) {
  1.2946 +  /* insert top 2 slots three down */
  1.2947 +  copy_stack_slot(tos, -1, 1);
  1.2948 +  copy_stack_slot(tos, -2, 0);
  1.2949 +  copy_stack_slot(tos, -3, -1);
  1.2950 +  copy_stack_slot(tos, 1, -2);
  1.2951 +  copy_stack_slot(tos, 0, -3);
  1.2952 +}
  1.2953 +void BytecodeInterpreter::dup2_x2(intptr_t *tos) {
  1.2954 +  /* insert top 2 slots four down */
  1.2955 +  copy_stack_slot(tos, -1, 1);
  1.2956 +  copy_stack_slot(tos, -2, 0);
  1.2957 +  copy_stack_slot(tos, -3, -1);
  1.2958 +  copy_stack_slot(tos, -4, -2);
  1.2959 +  copy_stack_slot(tos, 1, -3);
  1.2960 +  copy_stack_slot(tos, 0, -4);
  1.2961 +}
  1.2962 +
  1.2963 +
  1.2964 +void BytecodeInterpreter::swap(intptr_t *tos) {
  1.2965 +  // swap top two elements
  1.2966 +  intptr_t val = tos[Interpreter::expr_index_at(1)];
  1.2967 +  frame::Tag t;
  1.2968 +  if (TaggedStackInterpreter) {
  1.2969 +    t = (frame::Tag) tos[Interpreter::expr_tag_index_at(1)];
  1.2970 +  }
  1.2971 +  // Copy -2 entry to -1
  1.2972 +  copy_stack_slot(tos, -2, -1);
  1.2973 +  // Store saved -1 entry into -2
  1.2974 +  if (TaggedStackInterpreter) {
  1.2975 +    tos[Interpreter::expr_tag_index_at(2)] = (intptr_t)t;
  1.2976 +  }
  1.2977 +  tos[Interpreter::expr_index_at(2)] = val;
  1.2978 +}
  1.2979 +// --------------------------------------------------------------------------------
  1.2980 +// Non-product code
  1.2981 +#ifndef PRODUCT
  1.2982 +
  1.2983 +const char* BytecodeInterpreter::C_msg(BytecodeInterpreter::messages msg) {
  1.2984 +  switch (msg) {
  1.2985 +     case BytecodeInterpreter::no_request:  return("no_request");
  1.2986 +     case BytecodeInterpreter::initialize:  return("initialize");
  1.2987 +     // status message to C++ interpreter
  1.2988 +     case BytecodeInterpreter::method_entry:  return("method_entry");
  1.2989 +     case BytecodeInterpreter::method_resume:  return("method_resume");
  1.2990 +     case BytecodeInterpreter::got_monitors:  return("got_monitors");
  1.2991 +     case BytecodeInterpreter::rethrow_exception:  return("rethrow_exception");
  1.2992 +     // requests to frame manager from C++ interpreter
  1.2993 +     case BytecodeInterpreter::call_method:  return("call_method");
  1.2994 +     case BytecodeInterpreter::return_from_method:  return("return_from_method");
  1.2995 +     case BytecodeInterpreter::more_monitors:  return("more_monitors");
  1.2996 +     case BytecodeInterpreter::throwing_exception:  return("throwing_exception");
  1.2997 +     case BytecodeInterpreter::popping_frame:  return("popping_frame");
  1.2998 +     case BytecodeInterpreter::do_osr:  return("do_osr");
  1.2999 +     // deopt
  1.3000 +     case BytecodeInterpreter::deopt_resume:  return("deopt_resume");
  1.3001 +     case BytecodeInterpreter::deopt_resume2:  return("deopt_resume2");
  1.3002 +     default: return("BAD MSG");
  1.3003 +  }
  1.3004 +}
  1.3005 +void
  1.3006 +BytecodeInterpreter::print() {
  1.3007 +  tty->print_cr("thread: " INTPTR_FORMAT, (uintptr_t) this->_thread);
  1.3008 +  tty->print_cr("bcp: " INTPTR_FORMAT, (uintptr_t) this->_bcp);
  1.3009 +  tty->print_cr("locals: " INTPTR_FORMAT, (uintptr_t) this->_locals);
  1.3010 +  tty->print_cr("constants: " INTPTR_FORMAT, (uintptr_t) this->_constants);
  1.3011 +  {
  1.3012 +    ResourceMark rm;
  1.3013 +    char *method_name = _method->name_and_sig_as_C_string();
  1.3014 +    tty->print_cr("method: " INTPTR_FORMAT "[ %s ]",  (uintptr_t) this->_method, method_name);
  1.3015 +  }
  1.3016 +  tty->print_cr("mdx: " INTPTR_FORMAT, (uintptr_t) this->_mdx);
  1.3017 +  tty->print_cr("stack: " INTPTR_FORMAT, (uintptr_t) this->_stack);
  1.3018 +  tty->print_cr("msg: %s", C_msg(this->_msg));
  1.3019 +  tty->print_cr("result_to_call._callee: " INTPTR_FORMAT, (uintptr_t) this->_result._to_call._callee);
  1.3020 +  tty->print_cr("result_to_call._callee_entry_point: " INTPTR_FORMAT, (uintptr_t) this->_result._to_call._callee_entry_point);
  1.3021 +  tty->print_cr("result_to_call._bcp_advance: %d ", this->_result._to_call._bcp_advance);
  1.3022 +  tty->print_cr("osr._osr_buf: " INTPTR_FORMAT, (uintptr_t) this->_result._osr._osr_buf);
  1.3023 +  tty->print_cr("osr._osr_entry: " INTPTR_FORMAT, (uintptr_t) this->_result._osr._osr_entry);
  1.3024 +  tty->print_cr("result_return_kind 0x%x ", (int) this->_result._return_kind);
  1.3025 +  tty->print_cr("prev_link: " INTPTR_FORMAT, (uintptr_t) this->_prev_link);
  1.3026 +  tty->print_cr("native_mirror: " INTPTR_FORMAT, (uintptr_t) this->_oop_temp);
  1.3027 +  tty->print_cr("stack_base: " INTPTR_FORMAT, (uintptr_t) this->_stack_base);
  1.3028 +  tty->print_cr("stack_limit: " INTPTR_FORMAT, (uintptr_t) this->_stack_limit);
  1.3029 +  tty->print_cr("monitor_base: " INTPTR_FORMAT, (uintptr_t) this->_monitor_base);
  1.3030 +#ifdef SPARC
  1.3031 +  tty->print_cr("last_Java_pc: " INTPTR_FORMAT, (uintptr_t) this->_last_Java_pc);
  1.3032 +  tty->print_cr("frame_bottom: " INTPTR_FORMAT, (uintptr_t) this->_frame_bottom);
  1.3033 +  tty->print_cr("&native_fresult: " INTPTR_FORMAT, (uintptr_t) &this->_native_fresult);
  1.3034 +  tty->print_cr("native_lresult: " INTPTR_FORMAT, (uintptr_t) this->_native_lresult);
  1.3035 +#endif
  1.3036 +#ifdef IA64
  1.3037 +  tty->print_cr("last_Java_fp: " INTPTR_FORMAT, (uintptr_t) this->_last_Java_fp);
  1.3038 +#endif // IA64
  1.3039 +  tty->print_cr("self_link: " INTPTR_FORMAT, (uintptr_t) this->_self_link);
  1.3040 +}
  1.3041 +
  1.3042 +extern "C" {
  1.3043 +    void PI(uintptr_t arg) {
  1.3044 +        ((BytecodeInterpreter*)arg)->print();
  1.3045 +    }
  1.3046 +}
  1.3047 +#endif // PRODUCT
  1.3048 +
  1.3049 +#endif // JVMTI
  1.3050 +#endif // CC_INTERP

mercurial