598 pool->pool_holder() 599 ); 600 } 601 602 603 //------------------------------------------------------------------------------------------------------------------------ 604 // Synchronization 605 // 606 // The interpreter's synchronization code is factored out so that it can 607 // be shared by method invocation and synchronized blocks. 608 //%note synchronization_3 609 610 //%note monitor_1 611 IRT_ENTRY_NO_ASYNC(void, InterpreterRuntime::monitorenter(JavaThread* thread, BasicObjectLock* elem)) 612 #ifdef ASSERT 613 thread->last_frame().interpreter_frame_verify_monitor(elem); 614 #endif 615 if (PrintBiasedLockingStatistics) { 616 Atomic::inc(BiasedLocking::slow_path_entry_count_addr()); 617 } 618 Handle h_obj(thread, elem->obj()); 619 assert(Universe::heap()->is_in_reserved_or_null(h_obj()), 620 "must be NULL or an object"); 621 if (UseBiasedLocking) { 622 // Retry fast entry if bias is revoked to avoid unnecessary inflation 623 ObjectSynchronizer::fast_enter(h_obj, elem->lock(), true, CHECK); 624 } else { 625 ObjectSynchronizer::slow_enter(h_obj, elem->lock(), CHECK); 626 } 627 assert(Universe::heap()->is_in_reserved_or_null(elem->obj()), 628 "must be NULL or an object"); 629 #ifdef ASSERT 630 thread->last_frame().interpreter_frame_verify_monitor(elem); 631 #endif 632 IRT_END 633 634 635 //%note monitor_1 636 IRT_ENTRY_NO_ASYNC(void, InterpreterRuntime::monitorexit(JavaThread* thread, BasicObjectLock* elem)) 637 #ifdef ASSERT 638 thread->last_frame().interpreter_frame_verify_monitor(elem); 639 #endif 640 Handle h_obj(thread, elem->obj()); 641 assert(Universe::heap()->is_in_reserved_or_null(h_obj()), 642 "must be NULL or an object"); 643 if (elem == NULL || h_obj()->is_unlocked()) { 644 THROW(vmSymbols::java_lang_IllegalMonitorStateException()); 645 } 646 ObjectSynchronizer::slow_exit(h_obj(), elem->lock(), thread); 647 // Free entry. This must be done here, since a pending exception might be installed on 648 // exit. If it is not cleared, the exception handling code will try to unlock the monitor again. 649 elem->set_obj(NULL); 650 #ifdef ASSERT 651 thread->last_frame().interpreter_frame_verify_monitor(elem); 652 #endif 653 IRT_END 654 655 656 IRT_ENTRY(void, InterpreterRuntime::throw_illegal_monitor_state_exception(JavaThread* thread)) 657 THROW(vmSymbols::java_lang_IllegalMonitorStateException()); 658 IRT_END 659 660 | 598 pool->pool_holder() 599 ); 600 } 601 602 603 //------------------------------------------------------------------------------------------------------------------------ 604 // Synchronization 605 // 606 // The interpreter's synchronization code is factored out so that it can 607 // be shared by method invocation and synchronized blocks. 608 //%note synchronization_3 609 610 //%note monitor_1 611 IRT_ENTRY_NO_ASYNC(void, InterpreterRuntime::monitorenter(JavaThread* thread, BasicObjectLock* elem)) 612 #ifdef ASSERT 613 thread->last_frame().interpreter_frame_verify_monitor(elem); 614 #endif 615 if (PrintBiasedLockingStatistics) { 616 Atomic::inc(BiasedLocking::slow_path_entry_count_addr()); 617 } 618 Handle h_obj(thread, oopDesc::bs()->write_barrier(elem->obj())); 619 assert(Universe::heap()->is_in_reserved_or_null(h_obj()), 620 "must be NULL or an object"); 621 if (UseBiasedLocking) { 622 // Retry fast entry if bias is revoked to avoid unnecessary inflation 623 ObjectSynchronizer::fast_enter(h_obj, elem->lock(), true, CHECK); 624 } else { 625 ObjectSynchronizer::slow_enter(h_obj, elem->lock(), CHECK); 626 } 627 assert(Universe::heap()->is_in_reserved_or_null(elem->obj()), 628 "must be NULL or an object"); 629 #ifdef ASSERT 630 thread->last_frame().interpreter_frame_verify_monitor(elem); 631 #endif 632 IRT_END 633 634 635 //%note monitor_1 636 IRT_ENTRY_NO_ASYNC(void, InterpreterRuntime::monitorexit(JavaThread* thread, BasicObjectLock* elem)) 637 #ifdef ASSERT 638 thread->last_frame().interpreter_frame_verify_monitor(elem); 639 #endif 640 Handle h_obj(thread, oopDesc::bs()->write_barrier(elem->obj())); 641 assert(Universe::heap()->is_in_reserved_or_null(h_obj()), 642 "must be NULL or an object"); 643 if (elem == NULL || h_obj()->is_unlocked()) { 644 THROW(vmSymbols::java_lang_IllegalMonitorStateException()); 645 } 646 ObjectSynchronizer::slow_exit(h_obj(), elem->lock(), thread); 647 // Free entry. This must be done here, since a pending exception might be installed on 648 // exit. If it is not cleared, the exception handling code will try to unlock the monitor again. 649 elem->set_obj(NULL); 650 #ifdef ASSERT 651 thread->last_frame().interpreter_frame_verify_monitor(elem); 652 #endif 653 IRT_END 654 655 656 IRT_ENTRY(void, InterpreterRuntime::throw_illegal_monitor_state_exception(JavaThread* thread)) 657 THROW(vmSymbols::java_lang_IllegalMonitorStateException()); 658 IRT_END 659 660 |