754 755 756 //------------------------------------------------------------------------------------------------------------------------ 757 // Synchronization 758 // 759 // The interpreter's synchronization code is factored out so that it can 760 // be shared by method invocation and synchronized blocks. 761 //%note synchronization_3 762 763 //%note monitor_1 764 JRT_ENTRY_NO_ASYNC(void, InterpreterRuntime::monitorenter(JavaThread* thread, BasicObjectLock* elem)) 765 #ifdef ASSERT 766 thread->last_frame().interpreter_frame_verify_monitor(elem); 767 #endif 768 if (PrintBiasedLockingStatistics) { 769 Atomic::inc(BiasedLocking::slow_path_entry_count_addr()); 770 } 771 Handle h_obj(thread, elem->obj()); 772 assert(Universe::heap()->is_in_reserved_or_null(h_obj()), 773 "must be NULL or an object"); 774 if (UseBiasedLocking) { 775 // Retry fast entry if bias is revoked to avoid unnecessary inflation 776 ObjectSynchronizer::fast_enter(h_obj, elem->lock(), true, CHECK); 777 } else { 778 ObjectSynchronizer::slow_enter(h_obj, elem->lock(), CHECK); 779 } 780 assert(Universe::heap()->is_in_reserved_or_null(elem->obj()), 781 "must be NULL or an object"); 782 #ifdef ASSERT 783 thread->last_frame().interpreter_frame_verify_monitor(elem); 784 #endif 785 JRT_END 786 787 788 //%note monitor_1 789 JRT_ENTRY_NO_ASYNC(void, InterpreterRuntime::monitorexit(JavaThread* thread, BasicObjectLock* elem)) 790 #ifdef ASSERT 791 thread->last_frame().interpreter_frame_verify_monitor(elem); 792 #endif 793 Handle h_obj(thread, elem->obj()); 794 assert(Universe::heap()->is_in_reserved_or_null(h_obj()), 795 "must be NULL or an object"); 796 if (elem == NULL || h_obj()->is_unlocked()) { 797 THROW(vmSymbols::java_lang_IllegalMonitorStateException()); 798 } 799 ObjectSynchronizer::slow_exit(h_obj(), elem->lock(), thread); 800 // Free entry. This must be done here, since a pending exception might be installed on 801 // exit. If it is not cleared, the exception handling code will try to unlock the monitor again. 802 elem->set_obj(NULL); 803 #ifdef ASSERT 804 thread->last_frame().interpreter_frame_verify_monitor(elem); 805 #endif 806 JRT_END 807 808 809 JRT_ENTRY(void, InterpreterRuntime::throw_illegal_monitor_state_exception(JavaThread* thread)) 810 THROW(vmSymbols::java_lang_IllegalMonitorStateException()); 811 JRT_END 812 813 814 JRT_ENTRY(void, InterpreterRuntime::new_illegal_monitor_state_exception(JavaThread* thread)) 815 // Returns an illegal exception to install into the current thread. The 816 // pending_exception flag is cleared so normal exception handling does not 817 // trigger. Any current installed exception will be overwritten. This 818 // method will be called during an exception unwind. 819 | 754 755 756 //------------------------------------------------------------------------------------------------------------------------ 757 // Synchronization 758 // 759 // The interpreter's synchronization code is factored out so that it can 760 // be shared by method invocation and synchronized blocks. 761 //%note synchronization_3 762 763 //%note monitor_1 764 JRT_ENTRY_NO_ASYNC(void, InterpreterRuntime::monitorenter(JavaThread* thread, BasicObjectLock* elem)) 765 #ifdef ASSERT 766 thread->last_frame().interpreter_frame_verify_monitor(elem); 767 #endif 768 if (PrintBiasedLockingStatistics) { 769 Atomic::inc(BiasedLocking::slow_path_entry_count_addr()); 770 } 771 Handle h_obj(thread, elem->obj()); 772 assert(Universe::heap()->is_in_reserved_or_null(h_obj()), 773 "must be NULL or an object"); 774 ObjectSynchronizer::enter(h_obj, elem->lock(), CHECK); 775 assert(Universe::heap()->is_in_reserved_or_null(elem->obj()), 776 "must be NULL or an object"); 777 #ifdef ASSERT 778 thread->last_frame().interpreter_frame_verify_monitor(elem); 779 #endif 780 JRT_END 781 782 783 //%note monitor_1 784 JRT_ENTRY_NO_ASYNC(void, InterpreterRuntime::monitorexit(JavaThread* thread, BasicObjectLock* elem)) 785 #ifdef ASSERT 786 thread->last_frame().interpreter_frame_verify_monitor(elem); 787 #endif 788 Handle h_obj(thread, elem->obj()); 789 assert(Universe::heap()->is_in_reserved_or_null(h_obj()), 790 "must be NULL or an object"); 791 if (elem == NULL || h_obj()->is_unlocked()) { 792 THROW(vmSymbols::java_lang_IllegalMonitorStateException()); 793 } 794 ObjectSynchronizer::exit(h_obj(), elem->lock(), thread); 795 // Free entry. This must be done here, since a pending exception might be installed on 796 // exit. If it is not cleared, the exception handling code will try to unlock the monitor again. 797 elem->set_obj(NULL); 798 #ifdef ASSERT 799 thread->last_frame().interpreter_frame_verify_monitor(elem); 800 #endif 801 JRT_END 802 803 804 JRT_ENTRY(void, InterpreterRuntime::throw_illegal_monitor_state_exception(JavaThread* thread)) 805 THROW(vmSymbols::java_lang_IllegalMonitorStateException()); 806 JRT_END 807 808 809 JRT_ENTRY(void, InterpreterRuntime::new_illegal_monitor_state_exception(JavaThread* thread)) 810 // Returns an illegal exception to install into the current thread. The 811 // pending_exception flag is cleared so normal exception handling does not 812 // trigger. Any current installed exception will be overwritten. This 813 // method will be called during an exception unwind. 814 |