src/share/vm/interpreter/bytecodeInterpreter.cpp

Print this page
rev 4899 : 8019519: PPC64 (part 105): C interpreter: implement support for jvmti early return.


  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 // no precompiled headers
  26 #include "classfile/vmSymbols.hpp"
  27 #include "gc_interface/collectedHeap.hpp"
  28 #include "interpreter/bytecodeHistogram.hpp"
  29 #include "interpreter/bytecodeInterpreter.hpp"
  30 #include "interpreter/bytecodeInterpreter.inline.hpp"
  31 #include "interpreter/interpreter.hpp"
  32 #include "interpreter/interpreterRuntime.hpp"
  33 #include "memory/resourceArea.hpp"
  34 #include "oops/methodCounters.hpp"
  35 #include "oops/objArrayKlass.hpp"
  36 #include "oops/oop.inline.hpp"
  37 #include "prims/jvmtiExport.hpp"

  38 #include "runtime/biasedLocking.hpp"
  39 #include "runtime/frame.inline.hpp"
  40 #include "runtime/handles.inline.hpp"
  41 #include "runtime/interfaceSupport.hpp"
  42 #include "runtime/sharedRuntime.hpp"
  43 #include "runtime/threadCritical.hpp"
  44 #include "utilities/exceptions.hpp"
  45 #ifdef TARGET_OS_ARCH_linux_x86
  46 # include "orderAccess_linux_x86.inline.hpp"
  47 #endif
  48 #ifdef TARGET_OS_ARCH_linux_sparc
  49 # include "orderAccess_linux_sparc.inline.hpp"
  50 #endif
  51 #ifdef TARGET_OS_ARCH_linux_zero
  52 # include "orderAccess_linux_zero.inline.hpp"
  53 #endif
  54 #ifdef TARGET_OS_ARCH_solaris_x86
  55 # include "orderAccess_solaris_x86.inline.hpp"
  56 #endif
  57 #ifdef TARGET_OS_ARCH_solaris_sparc


 180    As a result if we call at_single_stepping_point() we refetch opcode
 181    to get the current opcode. This will override any other prefetching
 182    that might have occurred.
 183 */
 184 #define DEBUGGER_SINGLE_STEP_NOTIFY()                                            \
 185 {                                                                                \
 186       if (_jvmti_interp_events) {                                                \
 187         if (JvmtiExport::should_post_single_step()) {                            \
 188           DECACHE_STATE();                                                       \
 189           SET_LAST_JAVA_FRAME();                                                 \
 190           ThreadInVMfromJava trans(THREAD);                                      \
 191           JvmtiExport::at_single_stepping_point(THREAD,                          \
 192                                           istate->method(),                      \
 193                                           pc);                                   \
 194           RESET_LAST_JAVA_FRAME();                                               \
 195           CACHE_STATE();                                                         \
 196           if (THREAD->pop_frame_pending() &&                                     \
 197               !THREAD->pop_frame_in_process()) {                                 \
 198             goto handle_Pop_Frame;                                               \
 199           }                                                                      \




 200           opcode = *pc;                                                          \
 201         }                                                                        \
 202       }                                                                          \
 203 }
 204 #else
 205 #define DEBUGGER_SINGLE_STEP_NOTIFY()
 206 #endif
 207 
 208 /*
 209  * CONTINUE - Macro for executing the next opcode.
 210  */
 211 #undef CONTINUE
 212 #ifdef USELABELS
 213 // Have to do this dispatch this way in C++ because otherwise gcc complains about crossing an
 214 // initialization (which is is the initialization of the table pointer...)
 215 #define DISPATCH(opcode) goto *(void*)dispatch_table[opcode]
 216 #define CONTINUE {                              \
 217         opcode = *pc;                           \
 218         DO_UPDATE_INSTRUCTION_COUNT(opcode);    \
 219         DEBUGGER_SINGLE_STEP_NOTIFY();          \


 403 // Decache the interpreter state that interpreter modifies directly (i.e. GC is indirect mod)
 404 #define DECACHE_STATE() DECACHE_PC(); DECACHE_TOS();
 405 
 406 // Reload interpreter state after calling the VM or a possible GC
 407 #define CACHE_STATE()   \
 408         CACHE_TOS();    \
 409         CACHE_PC();     \
 410         CACHE_CP();     \
 411         CACHE_LOCALS();
 412 
 413 // Call the VM don't check for pending exceptions
 414 #define CALL_VM_NOCHECK(func)                                     \
 415           DECACHE_STATE();                                        \
 416           SET_LAST_JAVA_FRAME();                                  \
 417           func;                                                   \
 418           RESET_LAST_JAVA_FRAME();                                \
 419           CACHE_STATE();                                          \
 420           if (THREAD->pop_frame_pending() &&                      \
 421               !THREAD->pop_frame_in_process()) {                  \
 422             goto handle_Pop_Frame;                                \




 423           }
 424 
 425 // Call the VM and check for pending exceptions
 426 #define CALL_VM(func, label) {                                    \
 427           CALL_VM_NOCHECK(func);                                  \
 428           if (THREAD->has_pending_exception()) goto label;        \
 429         }
 430 
 431 /*
 432  * BytecodeInterpreter::run(interpreterState istate)
 433  * BytecodeInterpreter::runWithChecks(interpreterState istate)
 434  *
 435  * The real deal. This is where byte codes actually get interpreted.
 436  * Basically it's a big while loop that iterates until we return from
 437  * the method passed in.
 438  *
 439  * The runWithChecks is used if JVMTI is enabled.
 440  *
 441  */
 442 #if defined(VM_JVMTI)


 766       THREAD->clr_do_not_unlock();
 767 
 768       // Notify jvmti
 769 #ifdef VM_JVMTI
 770       if (_jvmti_interp_events) {
 771         // Whenever JVMTI puts a thread in interp_only_mode, method
 772         // entry/exit events are sent for that thread to track stack depth.
 773         if (THREAD->is_interp_only_mode()) {
 774           CALL_VM(InterpreterRuntime::post_method_entry(THREAD),
 775                   handle_exception);
 776         }
 777       }
 778 #endif /* VM_JVMTI */
 779 
 780       goto run;
 781     }
 782 
 783     case popping_frame: {
 784       // returned from a java call to pop the frame, restart the call
 785       // clear the message so we don't confuse ourselves later
 786       ShouldNotReachHere();  // we don't return this.
 787       assert(THREAD->pop_frame_in_process(), "wrong frame pop state");
 788       istate->set_msg(no_request);
 789       THREAD->clr_pop_frame_in_process();
 790       goto run;
 791     }
 792 
 793     case method_resume: {
 794       if ((istate->_stack_base - istate->_stack_limit) != istate->method()->max_stack() + 1) {
 795         // resume
 796         os::breakpoint();
 797       }
 798 #ifdef HACK
 799       {
 800         ResourceMark rm;
 801         char *method_name = istate->method()->name_and_sig_as_C_string();
 802         if (strstr(method_name, "runThese$TestRunner.run()V") != NULL) {
 803           tty->print_cr("resume: depth %d bci: %d",
 804                          (istate->_stack_base - istate->_stack) ,
 805                          istate->_bcp - istate->_method->code_base());
 806           interesting = true;
 807         }
 808       }
 809 #endif // HACK
 810       // returned from a java call, continue executing.
 811       if (THREAD->pop_frame_pending() && !THREAD->pop_frame_in_process()) {
 812         goto handle_Pop_Frame;
 813       }




 814 
 815       if (THREAD->has_pending_exception()) goto handle_exception;
 816       // Update the pc by the saved amount of the invoke bytecode size
 817       UPDATE_PC(istate->bcp_advance());
 818       goto run;
 819     }
 820 
 821     case deopt_resume2: {
 822       // Returned from an opcode that will reexecute. Deopt was
 823       // a result of a PopFrame request.
 824       //
 825       goto run;
 826     }
 827 
 828     case deopt_resume: {
 829       // Returned from an opcode that has completed. The stack has
 830       // the result all we need to do is skip across the bytecode
 831       // and continue (assuming there is no exception pending)
 832       //
 833       // compute continuation length


2691                       continuation_bci, THREAD);
2692       }
2693       // for AbortVMOnException flag
2694       NOT_PRODUCT(Exceptions::debug_check_abort(except_oop));
2695       goto run;
2696     }
2697     if (TraceExceptions) {
2698       ttyLocker ttyl;
2699       ResourceMark rm;
2700       tty->print_cr("Exception <%s> (" INTPTR_FORMAT ")", except_oop->print_value_string(), except_oop());
2701       tty->print_cr(" thrown in interpreter method <%s>", METHOD->print_value_string());
2702       tty->print_cr(" at bci %d, unwinding for thread " INTPTR_FORMAT,
2703                     pc  - (intptr_t) METHOD->code_base(),
2704                     THREAD);
2705     }
2706     // for AbortVMOnException flag
2707     NOT_PRODUCT(Exceptions::debug_check_abort(except_oop));
2708     // No handler in this activation, unwind and try again
2709     THREAD->set_pending_exception(except_oop(), NULL, 0);
2710     goto handle_return;
2711   }  /* handle_exception: */
2712 
2713 
2714 
2715   // Return from an interpreter invocation with the result of the interpretation
2716   // on the top of the Java Stack (or a pending exception)
2717 
2718 handle_Pop_Frame:
2719 
2720   // We don't really do anything special here except we must be aware
2721   // that we can get here without ever locking the method (if sync).
2722   // Also we skip the notification of the exit.
2723 
2724   istate->set_msg(popping_frame);
2725   // Clear pending so while the pop is in process
2726   // we don't start another one if a call_vm is done.
2727   THREAD->clr_pop_frame_pending();
2728   // Let interpreter (only) see the we're in the process of popping a frame
2729   THREAD->set_pop_frame_in_process();
2730 
2731 handle_return:
2732   {



















































2733     DECACHE_STATE();
2734 
2735     bool suppress_error = istate->msg() == popping_frame;
2736     bool suppress_exit_event = THREAD->has_pending_exception() || suppress_error;
2737     Handle original_exception(THREAD, THREAD->pending_exception());
2738     Handle illegal_state_oop(THREAD, NULL);
2739 
2740     // We'd like a HandleMark here to prevent any subsequent HandleMarkCleaner
2741     // in any following VM entries from freeing our live handles, but illegal_state_oop
2742     // isn't really allocated yet and so doesn't become live until later and
2743     // in unpredicatable places. Instead we must protect the places where we enter the
2744     // VM. It would be much simpler (and safer) if we could allocate a real handle with
2745     // a NULL oop in it and then overwrite the oop later as needed. This isn't
2746     // unfortunately isn't possible.
2747 
2748     THREAD->clear_pending_exception();
2749 
2750     //
2751     // As far as we are concerned we have returned. If we have a pending exception
2752     // that will be returned as this invocation's result. However if we get any
2753     // exception(s) while checking monitor state one of those IllegalMonitorStateExceptions
2754     // will be our final result (i.e. monitor exception trumps a pending exception).
2755     //
2756 


2929             HandleMark __hm(THREAD);
2930             CALL_VM_NOCHECK(InterpreterRuntime::post_method_exit(THREAD));
2931           }
2932         }
2933       }
2934 #endif /* VM_JVMTI */
2935 
2936     //
2937     // See if we are returning any exception
2938     // A pending exception that was pending prior to a possible popping frame
2939     // overrides the popping frame.
2940     //
2941     assert(!suppress_error || suppress_error && illegal_state_oop() == NULL, "Error was not suppressed");
2942     if (illegal_state_oop() != NULL || original_exception() != NULL) {
2943       // inform the frame manager we have no result
2944       istate->set_msg(throwing_exception);
2945       if (illegal_state_oop() != NULL)
2946         THREAD->set_pending_exception(illegal_state_oop(), NULL, 0);
2947       else
2948         THREAD->set_pending_exception(original_exception(), NULL, 0);
2949       istate->set_return_kind((Bytecodes::Code)opcode);
2950       UPDATE_PC_AND_RETURN(0);
2951     }
2952 
2953     if (istate->msg() == popping_frame) {
2954       // Make it simpler on the assembly code and set the message for the frame pop.
2955       // returns
2956       if (istate->prev() == NULL) {
2957         // We must be returning to a deoptimized frame (because popframe only happens between
2958         // two interpreted frames). We need to save the current arguments in C heap so that
2959         // the deoptimized frame when it restarts can copy the arguments to its expression
2960         // stack and re-execute the call. We also have to notify deoptimization that this
2961         // has occurred and to pick the preserved args copy them to the deoptimized frame's
2962         // java expression stack. Yuck.
2963         //
2964         THREAD->popframe_preserve_args(in_ByteSize(METHOD->size_of_parameters() * wordSize),
2965                                 LOCALS_SLOT(METHOD->size_of_parameters() - 1));
2966         THREAD->set_popframe_condition_bit(JavaThread::popframe_force_deopt_reexecution_bit);
2967       }
2968       THREAD->clr_pop_frame_in_process();

2969     }
2970 
2971     // Normal return
2972     // Advance the pc and return to frame manager
2973     istate->set_msg(return_from_method);
2974     istate->set_return_kind((Bytecodes::Code)opcode);
2975     UPDATE_PC_AND_RETURN(1);
2976   } /* handle_return: */
2977 
2978 // This is really a fatal error return
2979 
2980 finish:
2981   DECACHE_TOS();
2982   DECACHE_PC();
2983 
2984   return;
2985 }
2986 
2987 /*
2988  * All the code following this point is only produced once and is not present
2989  * in the JVMTI version of the interpreter
2990 */
2991 
2992 #ifndef VM_JVMTI
2993 
2994 // This constructor should only be used to contruct the object to signal


3229 }
3230 void
3231 BytecodeInterpreter::print() {
3232   tty->print_cr("thread: " INTPTR_FORMAT, (uintptr_t) this->_thread);
3233   tty->print_cr("bcp: " INTPTR_FORMAT, (uintptr_t) this->_bcp);
3234   tty->print_cr("locals: " INTPTR_FORMAT, (uintptr_t) this->_locals);
3235   tty->print_cr("constants: " INTPTR_FORMAT, (uintptr_t) this->_constants);
3236   {
3237     ResourceMark rm;
3238     char *method_name = _method->name_and_sig_as_C_string();
3239     tty->print_cr("method: " INTPTR_FORMAT "[ %s ]",  (uintptr_t) this->_method, method_name);
3240   }
3241   tty->print_cr("mdx: " INTPTR_FORMAT, (uintptr_t) this->_mdx);
3242   tty->print_cr("stack: " INTPTR_FORMAT, (uintptr_t) this->_stack);
3243   tty->print_cr("msg: %s", C_msg(this->_msg));
3244   tty->print_cr("result_to_call._callee: " INTPTR_FORMAT, (uintptr_t) this->_result._to_call._callee);
3245   tty->print_cr("result_to_call._callee_entry_point: " INTPTR_FORMAT, (uintptr_t) this->_result._to_call._callee_entry_point);
3246   tty->print_cr("result_to_call._bcp_advance: %d ", this->_result._to_call._bcp_advance);
3247   tty->print_cr("osr._osr_buf: " INTPTR_FORMAT, (uintptr_t) this->_result._osr._osr_buf);
3248   tty->print_cr("osr._osr_entry: " INTPTR_FORMAT, (uintptr_t) this->_result._osr._osr_entry);
3249   tty->print_cr("result_return_kind 0x%x ", (int) this->_result._return_kind);
3250   tty->print_cr("prev_link: " INTPTR_FORMAT, (uintptr_t) this->_prev_link);
3251   tty->print_cr("native_mirror: " INTPTR_FORMAT, (uintptr_t) this->_oop_temp);
3252   tty->print_cr("stack_base: " INTPTR_FORMAT, (uintptr_t) this->_stack_base);
3253   tty->print_cr("stack_limit: " INTPTR_FORMAT, (uintptr_t) this->_stack_limit);
3254   tty->print_cr("monitor_base: " INTPTR_FORMAT, (uintptr_t) this->_monitor_base);
3255 #ifdef SPARC
3256   tty->print_cr("last_Java_pc: " INTPTR_FORMAT, (uintptr_t) this->_last_Java_pc);
3257   tty->print_cr("frame_bottom: " INTPTR_FORMAT, (uintptr_t) this->_frame_bottom);
3258   tty->print_cr("&native_fresult: " INTPTR_FORMAT, (uintptr_t) &this->_native_fresult);
3259   tty->print_cr("native_lresult: " INTPTR_FORMAT, (uintptr_t) this->_native_lresult);
3260 #endif
3261 #if !defined(ZERO)
3262   tty->print_cr("last_Java_fp: " INTPTR_FORMAT, (uintptr_t) this->_last_Java_fp);
3263 #endif // !ZERO
3264   tty->print_cr("self_link: " INTPTR_FORMAT, (uintptr_t) this->_self_link);
3265 }
3266 
3267 extern "C" {
3268   void PI(uintptr_t arg) {
3269     ((BytecodeInterpreter*)arg)->print();


  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 // no precompiled headers
  26 #include "classfile/vmSymbols.hpp"
  27 #include "gc_interface/collectedHeap.hpp"
  28 #include "interpreter/bytecodeHistogram.hpp"
  29 #include "interpreter/bytecodeInterpreter.hpp"
  30 #include "interpreter/bytecodeInterpreter.inline.hpp"
  31 #include "interpreter/interpreter.hpp"
  32 #include "interpreter/interpreterRuntime.hpp"
  33 #include "memory/resourceArea.hpp"
  34 #include "oops/methodCounters.hpp"
  35 #include "oops/objArrayKlass.hpp"
  36 #include "oops/oop.inline.hpp"
  37 #include "prims/jvmtiExport.hpp"
  38 #include "prims/jvmtiThreadState.hpp"
  39 #include "runtime/biasedLocking.hpp"
  40 #include "runtime/frame.inline.hpp"
  41 #include "runtime/handles.inline.hpp"
  42 #include "runtime/interfaceSupport.hpp"
  43 #include "runtime/sharedRuntime.hpp"
  44 #include "runtime/threadCritical.hpp"
  45 #include "utilities/exceptions.hpp"
  46 #ifdef TARGET_OS_ARCH_linux_x86
  47 # include "orderAccess_linux_x86.inline.hpp"
  48 #endif
  49 #ifdef TARGET_OS_ARCH_linux_sparc
  50 # include "orderAccess_linux_sparc.inline.hpp"
  51 #endif
  52 #ifdef TARGET_OS_ARCH_linux_zero
  53 # include "orderAccess_linux_zero.inline.hpp"
  54 #endif
  55 #ifdef TARGET_OS_ARCH_solaris_x86
  56 # include "orderAccess_solaris_x86.inline.hpp"
  57 #endif
  58 #ifdef TARGET_OS_ARCH_solaris_sparc


 181    As a result if we call at_single_stepping_point() we refetch opcode
 182    to get the current opcode. This will override any other prefetching
 183    that might have occurred.
 184 */
 185 #define DEBUGGER_SINGLE_STEP_NOTIFY()                                            \
 186 {                                                                                \
 187       if (_jvmti_interp_events) {                                                \
 188         if (JvmtiExport::should_post_single_step()) {                            \
 189           DECACHE_STATE();                                                       \
 190           SET_LAST_JAVA_FRAME();                                                 \
 191           ThreadInVMfromJava trans(THREAD);                                      \
 192           JvmtiExport::at_single_stepping_point(THREAD,                          \
 193                                           istate->method(),                      \
 194                                           pc);                                   \
 195           RESET_LAST_JAVA_FRAME();                                               \
 196           CACHE_STATE();                                                         \
 197           if (THREAD->pop_frame_pending() &&                                     \
 198               !THREAD->pop_frame_in_process()) {                                 \
 199             goto handle_Pop_Frame;                                               \
 200           }                                                                      \
 201           if (THREAD->jvmti_thread_state() &&                                    \
 202               THREAD->jvmti_thread_state()->is_earlyret_pending()) {             \
 203             goto handle_Early_Return;                                            \
 204           }                                                                      \
 205           opcode = *pc;                                                          \
 206         }                                                                        \
 207       }                                                                          \
 208 }
 209 #else
 210 #define DEBUGGER_SINGLE_STEP_NOTIFY()
 211 #endif
 212 
 213 /*
 214  * CONTINUE - Macro for executing the next opcode.
 215  */
 216 #undef CONTINUE
 217 #ifdef USELABELS
 218 // Have to do this dispatch this way in C++ because otherwise gcc complains about crossing an
 219 // initialization (which is is the initialization of the table pointer...)
 220 #define DISPATCH(opcode) goto *(void*)dispatch_table[opcode]
 221 #define CONTINUE {                              \
 222         opcode = *pc;                           \
 223         DO_UPDATE_INSTRUCTION_COUNT(opcode);    \
 224         DEBUGGER_SINGLE_STEP_NOTIFY();          \


 408 // Decache the interpreter state that interpreter modifies directly (i.e. GC is indirect mod)
 409 #define DECACHE_STATE() DECACHE_PC(); DECACHE_TOS();
 410 
 411 // Reload interpreter state after calling the VM or a possible GC
 412 #define CACHE_STATE()   \
 413         CACHE_TOS();    \
 414         CACHE_PC();     \
 415         CACHE_CP();     \
 416         CACHE_LOCALS();
 417 
 418 // Call the VM don't check for pending exceptions
 419 #define CALL_VM_NOCHECK(func)                                      \
 420         DECACHE_STATE();                                           \
 421         SET_LAST_JAVA_FRAME();                                     \
 422         func;                                                      \
 423         RESET_LAST_JAVA_FRAME();                                   \
 424         CACHE_STATE();                                             \
 425         if (THREAD->pop_frame_pending() &&                         \
 426             !THREAD->pop_frame_in_process()) {                     \
 427           goto handle_Pop_Frame;                                   \
 428         }                                                          \
 429         if (THREAD->jvmti_thread_state() &&                        \
 430             THREAD->jvmti_thread_state()->is_earlyret_pending()) { \
 431           goto handle_Early_Return;                                \
 432         }
 433 
 434 // Call the VM and check for pending exceptions
 435 #define CALL_VM(func, label) {                                     \
 436           CALL_VM_NOCHECK(func);                                   \
 437           if (THREAD->has_pending_exception()) goto label;         \
 438         }
 439 
 440 /*
 441  * BytecodeInterpreter::run(interpreterState istate)
 442  * BytecodeInterpreter::runWithChecks(interpreterState istate)
 443  *
 444  * The real deal. This is where byte codes actually get interpreted.
 445  * Basically it's a big while loop that iterates until we return from
 446  * the method passed in.
 447  *
 448  * The runWithChecks is used if JVMTI is enabled.
 449  *
 450  */
 451 #if defined(VM_JVMTI)


 775       THREAD->clr_do_not_unlock();
 776 
 777       // Notify jvmti
 778 #ifdef VM_JVMTI
 779       if (_jvmti_interp_events) {
 780         // Whenever JVMTI puts a thread in interp_only_mode, method
 781         // entry/exit events are sent for that thread to track stack depth.
 782         if (THREAD->is_interp_only_mode()) {
 783           CALL_VM(InterpreterRuntime::post_method_entry(THREAD),
 784                   handle_exception);
 785         }
 786       }
 787 #endif /* VM_JVMTI */
 788 
 789       goto run;
 790     }
 791 
 792     case popping_frame: {
 793       // returned from a java call to pop the frame, restart the call
 794       // clear the message so we don't confuse ourselves later

 795       assert(THREAD->pop_frame_in_process(), "wrong frame pop state");
 796       istate->set_msg(no_request);
 797       THREAD->clr_pop_frame_in_process();
 798       goto run;
 799     }
 800 
 801     case method_resume: {
 802       if ((istate->_stack_base - istate->_stack_limit) != istate->method()->max_stack() + 1) {
 803         // resume
 804         os::breakpoint();
 805       }
 806 #ifdef HACK
 807       {
 808         ResourceMark rm;
 809         char *method_name = istate->method()->name_and_sig_as_C_string();
 810         if (strstr(method_name, "runThese$TestRunner.run()V") != NULL) {
 811           tty->print_cr("resume: depth %d bci: %d",
 812                          (istate->_stack_base - istate->_stack) ,
 813                          istate->_bcp - istate->_method->code_base());
 814           interesting = true;
 815         }
 816       }
 817 #endif // HACK
 818       // returned from a java call, continue executing.
 819       if (THREAD->pop_frame_pending() && !THREAD->pop_frame_in_process()) {
 820         goto handle_Pop_Frame;
 821       }
 822       if (THREAD->jvmti_thread_state() &&
 823           THREAD->jvmti_thread_state()->is_earlyret_pending()) {
 824         goto handle_Early_Return;
 825       }
 826 
 827       if (THREAD->has_pending_exception()) goto handle_exception;
 828       // Update the pc by the saved amount of the invoke bytecode size
 829       UPDATE_PC(istate->bcp_advance());
 830       goto run;
 831     }
 832 
 833     case deopt_resume2: {
 834       // Returned from an opcode that will reexecute. Deopt was
 835       // a result of a PopFrame request.
 836       //
 837       goto run;
 838     }
 839 
 840     case deopt_resume: {
 841       // Returned from an opcode that has completed. The stack has
 842       // the result all we need to do is skip across the bytecode
 843       // and continue (assuming there is no exception pending)
 844       //
 845       // compute continuation length


2703                       continuation_bci, THREAD);
2704       }
2705       // for AbortVMOnException flag
2706       NOT_PRODUCT(Exceptions::debug_check_abort(except_oop));
2707       goto run;
2708     }
2709     if (TraceExceptions) {
2710       ttyLocker ttyl;
2711       ResourceMark rm;
2712       tty->print_cr("Exception <%s> (" INTPTR_FORMAT ")", except_oop->print_value_string(), except_oop());
2713       tty->print_cr(" thrown in interpreter method <%s>", METHOD->print_value_string());
2714       tty->print_cr(" at bci %d, unwinding for thread " INTPTR_FORMAT,
2715                     pc  - (intptr_t) METHOD->code_base(),
2716                     THREAD);
2717     }
2718     // for AbortVMOnException flag
2719     NOT_PRODUCT(Exceptions::debug_check_abort(except_oop));
2720     // No handler in this activation, unwind and try again
2721     THREAD->set_pending_exception(except_oop(), NULL, 0);
2722     goto handle_return;
2723   }  // handle_exception:


2724 
2725   // Return from an interpreter invocation with the result of the interpretation
2726   // on the top of the Java Stack (or a pending exception)
2727 
2728   handle_Pop_Frame: {
2729 
2730     // We don't really do anything special here except we must be aware
2731     // that we can get here without ever locking the method (if sync).
2732     // Also we skip the notification of the exit.
2733     
2734     istate->set_msg(popping_frame);
2735     // Clear pending so while the pop is in process
2736     // we don't start another one if a call_vm is done.
2737     THREAD->clr_pop_frame_pending();
2738     // Let interpreter (only) see the we're in the process of popping a frame
2739     THREAD->set_pop_frame_in_process();
2740     
2741     goto handle_return;
2742 
2743   } // handle_Pop_Frame
2744 
2745   // ForceEarlyReturn ends a method, and returns to the caller with a return value
2746   // given by the invoker of the early return.
2747   handle_Early_Return: {
2748 
2749     istate->set_msg(early_return);
2750     
2751     // Clear expression stack.
2752     topOfStack = istate->stack_base() - Interpreter::stackElementWords;
2753 
2754     JvmtiThreadState *ts = THREAD->jvmti_thread_state();
2755 
2756     // Push the value to be returned.
2757     switch (istate->method()->result_type()) {
2758       case T_BOOLEAN:
2759       case T_SHORT:
2760       case T_BYTE:
2761       case T_CHAR:
2762       case T_INT:
2763         SET_STACK_INT(->earlyret_value().i, 0);
2764         MORE_STACK(1);
2765         break;
2766       case T_LONG:
2767         SET_STACK_LONG(ts->earlyret_value().j, 1);
2768         MORE_STACK(2);
2769         break;
2770       case T_FLOAT:
2771         SET_STACK_FLOAT(ts->earlyret_value().f, 0);
2772         MORE_STACK(1);
2773         break;
2774       case T_DOUBLE:
2775         SET_STACK_DOUBLE(ts->earlyret_value().d, 1);
2776         MORE_STACK(2);
2777         break;
2778       case T_ARRAY:
2779       case T_OBJECT:
2780         SET_STACK_OBJECT(ts->earlyret_oop(), 0);
2781         MORE_STACK(1);
2782         break;
2783     }
2784     
2785     ts->clr_earlyret_value();
2786     ts->set_earlyret_oop(NULL);
2787     ts->clr_earlyret_pending();
2788     
2789     // Fall through to handle_return.
2790 
2791   } // handle_Early_Return
2792 
2793   handle_return: {
2794     DECACHE_STATE();
2795 
2796     bool suppress_error = istate->msg() == popping_frame || istate->msg() == early_return;
2797     bool suppress_exit_event = THREAD->has_pending_exception() || istate->msg() == popping_frame;
2798     Handle original_exception(THREAD, THREAD->pending_exception());
2799     Handle illegal_state_oop(THREAD, NULL);
2800 
2801     // We'd like a HandleMark here to prevent any subsequent HandleMarkCleaner
2802     // in any following VM entries from freeing our live handles, but illegal_state_oop
2803     // isn't really allocated yet and so doesn't become live until later and
2804     // in unpredicatable places. Instead we must protect the places where we enter the
2805     // VM. It would be much simpler (and safer) if we could allocate a real handle with
2806     // a NULL oop in it and then overwrite the oop later as needed. This isn't
2807     // unfortunately isn't possible.
2808 
2809     THREAD->clear_pending_exception();
2810 
2811     //
2812     // As far as we are concerned we have returned. If we have a pending exception
2813     // that will be returned as this invocation's result. However if we get any
2814     // exception(s) while checking monitor state one of those IllegalMonitorStateExceptions
2815     // will be our final result (i.e. monitor exception trumps a pending exception).
2816     //
2817 


2990             HandleMark __hm(THREAD);
2991             CALL_VM_NOCHECK(InterpreterRuntime::post_method_exit(THREAD));
2992           }
2993         }
2994       }
2995 #endif /* VM_JVMTI */
2996 
2997     //
2998     // See if we are returning any exception
2999     // A pending exception that was pending prior to a possible popping frame
3000     // overrides the popping frame.
3001     //
3002     assert(!suppress_error || suppress_error && illegal_state_oop() == NULL, "Error was not suppressed");
3003     if (illegal_state_oop() != NULL || original_exception() != NULL) {
3004       // inform the frame manager we have no result
3005       istate->set_msg(throwing_exception);
3006       if (illegal_state_oop() != NULL)
3007         THREAD->set_pending_exception(illegal_state_oop(), NULL, 0);
3008       else
3009         THREAD->set_pending_exception(original_exception(), NULL, 0);

3010       UPDATE_PC_AND_RETURN(0);
3011     }
3012 
3013     if (istate->msg() == popping_frame) {
3014       // Make it simpler on the assembly code and set the message for the frame pop.
3015       // returns
3016       if (istate->prev() == NULL) {
3017         // We must be returning to a deoptimized frame (because popframe only happens between
3018         // two interpreted frames). We need to save the current arguments in C heap so that
3019         // the deoptimized frame when it restarts can copy the arguments to its expression
3020         // stack and re-execute the call. We also have to notify deoptimization that this
3021         // has occurred and to pick the preserved args copy them to the deoptimized frame's
3022         // java expression stack. Yuck.
3023         //
3024         THREAD->popframe_preserve_args(in_ByteSize(METHOD->size_of_parameters() * wordSize),
3025                                 LOCALS_SLOT(METHOD->size_of_parameters() - 1));
3026         THREAD->set_popframe_condition_bit(JavaThread::popframe_force_deopt_reexecution_bit);
3027       }
3028     } else {
3029       istate->set_msg(return_from_method);
3030     }
3031 
3032     // Normal return
3033     // Advance the pc and return to frame manager


3034     UPDATE_PC_AND_RETURN(1);
3035   } /* handle_return: */
3036 
3037 // This is really a fatal error return
3038 
3039 finish:
3040   DECACHE_TOS();
3041   DECACHE_PC();
3042 
3043   return;
3044 }
3045 
3046 /*
3047  * All the code following this point is only produced once and is not present
3048  * in the JVMTI version of the interpreter
3049 */
3050 
3051 #ifndef VM_JVMTI
3052 
3053 // This constructor should only be used to contruct the object to signal


3288 }
3289 void
3290 BytecodeInterpreter::print() {
3291   tty->print_cr("thread: " INTPTR_FORMAT, (uintptr_t) this->_thread);
3292   tty->print_cr("bcp: " INTPTR_FORMAT, (uintptr_t) this->_bcp);
3293   tty->print_cr("locals: " INTPTR_FORMAT, (uintptr_t) this->_locals);
3294   tty->print_cr("constants: " INTPTR_FORMAT, (uintptr_t) this->_constants);
3295   {
3296     ResourceMark rm;
3297     char *method_name = _method->name_and_sig_as_C_string();
3298     tty->print_cr("method: " INTPTR_FORMAT "[ %s ]",  (uintptr_t) this->_method, method_name);
3299   }
3300   tty->print_cr("mdx: " INTPTR_FORMAT, (uintptr_t) this->_mdx);
3301   tty->print_cr("stack: " INTPTR_FORMAT, (uintptr_t) this->_stack);
3302   tty->print_cr("msg: %s", C_msg(this->_msg));
3303   tty->print_cr("result_to_call._callee: " INTPTR_FORMAT, (uintptr_t) this->_result._to_call._callee);
3304   tty->print_cr("result_to_call._callee_entry_point: " INTPTR_FORMAT, (uintptr_t) this->_result._to_call._callee_entry_point);
3305   tty->print_cr("result_to_call._bcp_advance: %d ", this->_result._to_call._bcp_advance);
3306   tty->print_cr("osr._osr_buf: " INTPTR_FORMAT, (uintptr_t) this->_result._osr._osr_buf);
3307   tty->print_cr("osr._osr_entry: " INTPTR_FORMAT, (uintptr_t) this->_result._osr._osr_entry);

3308   tty->print_cr("prev_link: " INTPTR_FORMAT, (uintptr_t) this->_prev_link);
3309   tty->print_cr("native_mirror: " INTPTR_FORMAT, (uintptr_t) this->_oop_temp);
3310   tty->print_cr("stack_base: " INTPTR_FORMAT, (uintptr_t) this->_stack_base);
3311   tty->print_cr("stack_limit: " INTPTR_FORMAT, (uintptr_t) this->_stack_limit);
3312   tty->print_cr("monitor_base: " INTPTR_FORMAT, (uintptr_t) this->_monitor_base);
3313 #ifdef SPARC
3314   tty->print_cr("last_Java_pc: " INTPTR_FORMAT, (uintptr_t) this->_last_Java_pc);
3315   tty->print_cr("frame_bottom: " INTPTR_FORMAT, (uintptr_t) this->_frame_bottom);
3316   tty->print_cr("&native_fresult: " INTPTR_FORMAT, (uintptr_t) &this->_native_fresult);
3317   tty->print_cr("native_lresult: " INTPTR_FORMAT, (uintptr_t) this->_native_lresult);
3318 #endif
3319 #if !defined(ZERO)
3320   tty->print_cr("last_Java_fp: " INTPTR_FORMAT, (uintptr_t) this->_last_Java_fp);
3321 #endif // !ZERO
3322   tty->print_cr("self_link: " INTPTR_FORMAT, (uintptr_t) this->_self_link);
3323 }
3324 
3325 extern "C" {
3326   void PI(uintptr_t arg) {
3327     ((BytecodeInterpreter*)arg)->print();