2773 } /* while (1) interpreter loop */
2774
2775
2776 // An exception exists in the thread state see whether this activation can handle it
2777 handle_exception: {
2778
2779 HandleMarkCleaner __hmc(THREAD);
2780 Handle except_oop(THREAD, THREAD->pending_exception());
2781 // Prevent any subsequent HandleMarkCleaner in the VM
2782 // from freeing the except_oop handle.
2783 HandleMark __hm(THREAD);
2784
2785 THREAD->clear_pending_exception();
2786 assert(except_oop(), "No exception to process");
2787 intptr_t continuation_bci;
2788 // expression stack is emptied
2789 topOfStack = istate->stack_base() - Interpreter::stackElementWords;
2790 CALL_VM(continuation_bci = (intptr_t)InterpreterRuntime::exception_handler_for_exception(THREAD, except_oop()),
2791 handle_exception);
2792
2793 except_oop = THREAD->vm_result();
2794 THREAD->set_vm_result(NULL);
2795 if (continuation_bci >= 0) {
2796 // Place exception on top of stack
2797 SET_STACK_OBJECT(except_oop(), 0);
2798 MORE_STACK(1);
2799 pc = METHOD->code_base() + continuation_bci;
2800 if (log_is_enabled(Info, exceptions)) {
2801 ResourceMark rm(THREAD);
2802 stringStream tempst;
2803 tempst.print("interpreter method <%s>\n"
2804 " at bci %d, continuing at %d for thread " INTPTR_FORMAT,
2805 METHOD->print_value_string(),
2806 (int)(istate->bcp() - METHOD->code_base()),
2807 (int)continuation_bci, p2i(THREAD));
2808 Exceptions::log_exception(except_oop, tempst);
2809 }
2810 // for AbortVMOnException flag
2811 Exceptions::debug_check_abort(except_oop);
2812
2813 // Update profiling data.
2977 if (header != NULL) {
2978 if (Atomic::cmpxchg_ptr(header, lockee->mark_addr(), lock) != lock) {
2979 // restore object for the slow case
2980 end->set_obj(lockee);
2981 {
2982 // Prevent any HandleMarkCleaner from freeing our live handles
2983 HandleMark __hm(THREAD);
2984 CALL_VM_NOCHECK(InterpreterRuntime::monitorexit(THREAD, end));
2985 }
2986 }
2987 }
2988 }
2989 // One error is plenty
2990 if (illegal_state_oop() == NULL && !suppress_error) {
2991 {
2992 // Prevent any HandleMarkCleaner from freeing our live handles
2993 HandleMark __hm(THREAD);
2994 CALL_VM_NOCHECK(InterpreterRuntime::throw_illegal_monitor_state_exception(THREAD));
2995 }
2996 assert(THREAD->has_pending_exception(), "Lost our exception!");
2997 illegal_state_oop = THREAD->pending_exception();
2998 THREAD->clear_pending_exception();
2999 }
3000 }
3001 end++;
3002 }
3003 // Unlock the method if needed
3004 if (method_unlock_needed) {
3005 if (base->obj() == NULL) {
3006 // The method is already unlocked this is not good.
3007 if (illegal_state_oop() == NULL && !suppress_error) {
3008 {
3009 // Prevent any HandleMarkCleaner from freeing our live handles
3010 HandleMark __hm(THREAD);
3011 CALL_VM_NOCHECK(InterpreterRuntime::throw_illegal_monitor_state_exception(THREAD));
3012 }
3013 assert(THREAD->has_pending_exception(), "Lost our exception!");
3014 illegal_state_oop = THREAD->pending_exception();
3015 THREAD->clear_pending_exception();
3016 }
3017 } else {
3018 //
3019 // The initial monitor is always used for the method
3020 // However if that slot is no longer the oop for the method it was unlocked
3021 // and reused by something that wasn't unlocked!
3022 //
3023 // deopt can come in with rcvr dead because c2 knows
3024 // its value is preserved in the monitor. So we can't use locals[0] at all
3025 // and must use first monitor slot.
3026 //
3027 oop rcvr = base->obj();
3028 if (rcvr == NULL) {
3029 if (!suppress_error) {
3030 VM_JAVA_ERROR_NO_JUMP(vmSymbols::java_lang_NullPointerException(), "", note_nullCheck_trap);
3031 illegal_state_oop = THREAD->pending_exception();
3032 THREAD->clear_pending_exception();
3033 }
3034 } else if (UseHeavyMonitors) {
3035 {
3036 // Prevent any HandleMarkCleaner from freeing our live handles.
3037 HandleMark __hm(THREAD);
3038 CALL_VM_NOCHECK(InterpreterRuntime::monitorexit(THREAD, base));
3039 }
3040 if (THREAD->has_pending_exception()) {
3041 if (!suppress_error) illegal_state_oop = THREAD->pending_exception();
3042 THREAD->clear_pending_exception();
3043 }
3044 } else {
3045 BasicLock* lock = base->lock();
3046 markOop header = lock->displaced_header();
3047 base->set_obj(NULL);
3048
3049 if (!rcvr->mark()->has_bias_pattern()) {
3050 base->set_obj(NULL);
3051 // If it isn't recursive we either must swap old header or call the runtime
3052 if (header != NULL) {
3053 if (Atomic::cmpxchg_ptr(header, rcvr->mark_addr(), lock) != lock) {
3054 // restore object for the slow case
3055 base->set_obj(rcvr);
3056 {
3057 // Prevent any HandleMarkCleaner from freeing our live handles
3058 HandleMark __hm(THREAD);
3059 CALL_VM_NOCHECK(InterpreterRuntime::monitorexit(THREAD, base));
3060 }
3061 if (THREAD->has_pending_exception()) {
3062 if (!suppress_error) illegal_state_oop = THREAD->pending_exception();
3063 THREAD->clear_pending_exception();
3064 }
3065 }
3066 }
3067 }
3068 }
3069 }
3070 }
3071 }
3072 // Clear the do_not_unlock flag now.
3073 THREAD->clr_do_not_unlock();
3074
3075 //
3076 // Notify jvmti/jvmdi
3077 //
3078 // NOTE: we do not notify a method_exit if we have a pending exception,
3079 // including an exception we generate for unlocking checks. In the former
3080 // case, JVMDI has already been notified by our call for the exception handler
3081 // and in both cases as far as JVMDI is concerned we have already returned.
3082 // If we notify it again JVMDI will be all confused about how many frames
|
2773 } /* while (1) interpreter loop */
2774
2775
2776 // An exception exists in the thread state see whether this activation can handle it
2777 handle_exception: {
2778
2779 HandleMarkCleaner __hmc(THREAD);
2780 Handle except_oop(THREAD, THREAD->pending_exception());
2781 // Prevent any subsequent HandleMarkCleaner in the VM
2782 // from freeing the except_oop handle.
2783 HandleMark __hm(THREAD);
2784
2785 THREAD->clear_pending_exception();
2786 assert(except_oop(), "No exception to process");
2787 intptr_t continuation_bci;
2788 // expression stack is emptied
2789 topOfStack = istate->stack_base() - Interpreter::stackElementWords;
2790 CALL_VM(continuation_bci = (intptr_t)InterpreterRuntime::exception_handler_for_exception(THREAD, except_oop()),
2791 handle_exception);
2792
2793 except_oop = Handle(THREAD, THREAD->vm_result());
2794 THREAD->set_vm_result(NULL);
2795 if (continuation_bci >= 0) {
2796 // Place exception on top of stack
2797 SET_STACK_OBJECT(except_oop(), 0);
2798 MORE_STACK(1);
2799 pc = METHOD->code_base() + continuation_bci;
2800 if (log_is_enabled(Info, exceptions)) {
2801 ResourceMark rm(THREAD);
2802 stringStream tempst;
2803 tempst.print("interpreter method <%s>\n"
2804 " at bci %d, continuing at %d for thread " INTPTR_FORMAT,
2805 METHOD->print_value_string(),
2806 (int)(istate->bcp() - METHOD->code_base()),
2807 (int)continuation_bci, p2i(THREAD));
2808 Exceptions::log_exception(except_oop, tempst);
2809 }
2810 // for AbortVMOnException flag
2811 Exceptions::debug_check_abort(except_oop);
2812
2813 // Update profiling data.
2977 if (header != NULL) {
2978 if (Atomic::cmpxchg_ptr(header, lockee->mark_addr(), lock) != lock) {
2979 // restore object for the slow case
2980 end->set_obj(lockee);
2981 {
2982 // Prevent any HandleMarkCleaner from freeing our live handles
2983 HandleMark __hm(THREAD);
2984 CALL_VM_NOCHECK(InterpreterRuntime::monitorexit(THREAD, end));
2985 }
2986 }
2987 }
2988 }
2989 // One error is plenty
2990 if (illegal_state_oop() == NULL && !suppress_error) {
2991 {
2992 // Prevent any HandleMarkCleaner from freeing our live handles
2993 HandleMark __hm(THREAD);
2994 CALL_VM_NOCHECK(InterpreterRuntime::throw_illegal_monitor_state_exception(THREAD));
2995 }
2996 assert(THREAD->has_pending_exception(), "Lost our exception!");
2997 illegal_state_oop = Handle(THREAD, THREAD->pending_exception());
2998 THREAD->clear_pending_exception();
2999 }
3000 }
3001 end++;
3002 }
3003 // Unlock the method if needed
3004 if (method_unlock_needed) {
3005 if (base->obj() == NULL) {
3006 // The method is already unlocked this is not good.
3007 if (illegal_state_oop() == NULL && !suppress_error) {
3008 {
3009 // Prevent any HandleMarkCleaner from freeing our live handles
3010 HandleMark __hm(THREAD);
3011 CALL_VM_NOCHECK(InterpreterRuntime::throw_illegal_monitor_state_exception(THREAD));
3012 }
3013 assert(THREAD->has_pending_exception(), "Lost our exception!");
3014 illegal_state_oop = Handle(THREAD, THREAD->pending_exception());
3015 THREAD->clear_pending_exception();
3016 }
3017 } else {
3018 //
3019 // The initial monitor is always used for the method
3020 // However if that slot is no longer the oop for the method it was unlocked
3021 // and reused by something that wasn't unlocked!
3022 //
3023 // deopt can come in with rcvr dead because c2 knows
3024 // its value is preserved in the monitor. So we can't use locals[0] at all
3025 // and must use first monitor slot.
3026 //
3027 oop rcvr = base->obj();
3028 if (rcvr == NULL) {
3029 if (!suppress_error) {
3030 VM_JAVA_ERROR_NO_JUMP(vmSymbols::java_lang_NullPointerException(), "", note_nullCheck_trap);
3031 illegal_state_oop = Handle(THREAD, THREAD->pending_exception());
3032 THREAD->clear_pending_exception();
3033 }
3034 } else if (UseHeavyMonitors) {
3035 {
3036 // Prevent any HandleMarkCleaner from freeing our live handles.
3037 HandleMark __hm(THREAD);
3038 CALL_VM_NOCHECK(InterpreterRuntime::monitorexit(THREAD, base));
3039 }
3040 if (THREAD->has_pending_exception()) {
3041 if (!suppress_error) illegal_state_oop = Handle(THREAD, THREAD->pending_exception());
3042 THREAD->clear_pending_exception();
3043 }
3044 } else {
3045 BasicLock* lock = base->lock();
3046 markOop header = lock->displaced_header();
3047 base->set_obj(NULL);
3048
3049 if (!rcvr->mark()->has_bias_pattern()) {
3050 base->set_obj(NULL);
3051 // If it isn't recursive we either must swap old header or call the runtime
3052 if (header != NULL) {
3053 if (Atomic::cmpxchg_ptr(header, rcvr->mark_addr(), lock) != lock) {
3054 // restore object for the slow case
3055 base->set_obj(rcvr);
3056 {
3057 // Prevent any HandleMarkCleaner from freeing our live handles
3058 HandleMark __hm(THREAD);
3059 CALL_VM_NOCHECK(InterpreterRuntime::monitorexit(THREAD, base));
3060 }
3061 if (THREAD->has_pending_exception()) {
3062 if (!suppress_error) illegal_state_oop = Handle(THREAD, THREAD->pending_exception());
3063 THREAD->clear_pending_exception();
3064 }
3065 }
3066 }
3067 }
3068 }
3069 }
3070 }
3071 }
3072 // Clear the do_not_unlock flag now.
3073 THREAD->clr_do_not_unlock();
3074
3075 //
3076 // Notify jvmti/jvmdi
3077 //
3078 // NOTE: we do not notify a method_exit if we have a pending exception,
3079 // including an exception we generate for unlocking checks. In the former
3080 // case, JVMDI has already been notified by our call for the exception handler
3081 // and in both cases as far as JVMDI is concerned we have already returned.
3082 // If we notify it again JVMDI will be all confused about how many frames
|