623 );
624 }
625
626
627 //------------------------------------------------------------------------------------------------------------------------
628 // Synchronization
629 //
630 // The interpreter's synchronization code is factored out so that it can
631 // be shared by method invocation and synchronized blocks.
632 //%note synchronization_3
633
634 //%note monitor_1
635 IRT_ENTRY_NO_ASYNC(void, InterpreterRuntime::monitorenter(JavaThread* thread, BasicObjectLock* elem))
636 #ifdef ASSERT
637 thread->last_frame().interpreter_frame_verify_monitor(elem);
638 #endif
639 if (PrintBiasedLockingStatistics) {
640 Atomic::inc(BiasedLocking::slow_path_entry_count_addr());
641 }
642 Handle h_obj(thread, elem->obj());
643 assert(Universe::heap()->is_in_reserved_or_null(h_obj()),
644 "must be NULL or an object");
645 if (UseBiasedLocking) {
646 // Retry fast entry if bias is revoked to avoid unnecessary inflation
647 ObjectSynchronizer::fast_enter(h_obj, elem->lock(), true, CHECK);
648 } else {
649 ObjectSynchronizer::slow_enter(h_obj, elem->lock(), CHECK);
650 }
651 assert(Universe::heap()->is_in_reserved_or_null(elem->obj()),
652 "must be NULL or an object");
653 #ifdef ASSERT
654 thread->last_frame().interpreter_frame_verify_monitor(elem);
655 #endif
656 IRT_END
657
658
659 //%note monitor_1
660 IRT_ENTRY_NO_ASYNC(void, InterpreterRuntime::monitorexit(JavaThread* thread, BasicObjectLock* elem))
661 #ifdef ASSERT
662 thread->last_frame().interpreter_frame_verify_monitor(elem);
663 #endif
664 Handle h_obj(thread, elem->obj());
665 assert(Universe::heap()->is_in_reserved_or_null(h_obj()),
666 "must be NULL or an object");
667 if (elem == NULL || h_obj()->is_unlocked()) {
668 THROW(vmSymbols::java_lang_IllegalMonitorStateException());
669 }
670 ObjectSynchronizer::slow_exit(h_obj(), elem->lock(), thread);
671 // Free entry. This must be done here, since a pending exception might be installed on
672 // exit. If it is not cleared, the exception handling code will try to unlock the monitor again.
673 elem->set_obj(NULL);
674 #ifdef ASSERT
675 thread->last_frame().interpreter_frame_verify_monitor(elem);
676 #endif
677 IRT_END
678
679
680 IRT_ENTRY(void, InterpreterRuntime::throw_illegal_monitor_state_exception(JavaThread* thread))
681 THROW(vmSymbols::java_lang_IllegalMonitorStateException());
682 IRT_END
683
684
685 IRT_ENTRY(void, InterpreterRuntime::new_illegal_monitor_state_exception(JavaThread* thread))
710
711 IRT_ENTRY(void, InterpreterRuntime::set_original_bytecode_at(JavaThread* thread, Method* method, address bcp, Bytecodes::Code new_code))
712 method->set_orig_bytecode_at(method->bci_from(bcp), new_code);
713 IRT_END
714
715 IRT_ENTRY(void, InterpreterRuntime::_breakpoint(JavaThread* thread, Method* method, address bcp))
716 JvmtiExport::post_raw_breakpoint(thread, method, bcp);
717 IRT_END
718
719 void InterpreterRuntime::resolve_invoke(JavaThread* thread, Bytecodes::Code bytecode) {
720 Thread* THREAD = thread;
721 // extract receiver from the outgoing argument list if necessary
722 Handle receiver(thread, NULL);
723 if (bytecode == Bytecodes::_invokevirtual || bytecode == Bytecodes::_invokeinterface) {
724 ResourceMark rm(thread);
725 methodHandle m (thread, method(thread));
726 Bytecode_invoke call(m, bci(thread));
727 Symbol* signature = call.signature();
728 receiver = Handle(thread,
729 thread->last_frame().interpreter_callee_receiver(signature));
730 assert(Universe::heap()->is_in_reserved_or_null(receiver()),
731 "sanity check");
732 assert(receiver.is_null() ||
733 !Universe::heap()->is_in_reserved(receiver->klass()),
734 "sanity check");
735 }
736
737 // resolve method
738 CallInfo info;
739 constantPoolHandle pool(thread, method(thread)->constants());
740
741 {
742 JvmtiHideSingleStepping jhss(thread);
743 LinkResolver::resolve_invoke(info, receiver, pool,
744 get_index_u2_cpcache(thread, bytecode), bytecode,
745 CHECK);
746 if (JvmtiExport::can_hotswap_or_post_breakpoint()) {
747 int retry_count = 0;
748 while (info.resolved_method()->is_old()) {
749 // It is very unlikely that method is redefined more than 100 times
750 // in the middle of resolve. If it is looping here more than 100 times
751 // means then there could be a bug here.
752 guarantee((retry_count++ < 100),
753 "Could not resolve to latest version of redefined method");
|
623 );
624 }
625
626
627 //------------------------------------------------------------------------------------------------------------------------
628 // Synchronization
629 //
630 // The interpreter's synchronization code is factored out so that it can
631 // be shared by method invocation and synchronized blocks.
632 //%note synchronization_3
633
634 //%note monitor_1
635 IRT_ENTRY_NO_ASYNC(void, InterpreterRuntime::monitorenter(JavaThread* thread, BasicObjectLock* elem))
636 #ifdef ASSERT
637 thread->last_frame().interpreter_frame_verify_monitor(elem);
638 #endif
639 if (PrintBiasedLockingStatistics) {
640 Atomic::inc(BiasedLocking::slow_path_entry_count_addr());
641 }
642 Handle h_obj(thread, elem->obj());
643 assert(GC::gc()->heap()->is_in_reserved_or_null(h_obj()),
644 "must be NULL or an object");
645 if (UseBiasedLocking) {
646 // Retry fast entry if bias is revoked to avoid unnecessary inflation
647 ObjectSynchronizer::fast_enter(h_obj, elem->lock(), true, CHECK);
648 } else {
649 ObjectSynchronizer::slow_enter(h_obj, elem->lock(), CHECK);
650 }
651 assert(GC::gc()->heap()->is_in_reserved_or_null(elem->obj()),
652 "must be NULL or an object");
653 #ifdef ASSERT
654 thread->last_frame().interpreter_frame_verify_monitor(elem);
655 #endif
656 IRT_END
657
658
659 //%note monitor_1
660 IRT_ENTRY_NO_ASYNC(void, InterpreterRuntime::monitorexit(JavaThread* thread, BasicObjectLock* elem))
661 #ifdef ASSERT
662 thread->last_frame().interpreter_frame_verify_monitor(elem);
663 #endif
664 Handle h_obj(thread, elem->obj());
665 assert(GC::gc()->heap()->is_in_reserved_or_null(h_obj()),
666 "must be NULL or an object");
667 if (elem == NULL || h_obj()->is_unlocked()) {
668 THROW(vmSymbols::java_lang_IllegalMonitorStateException());
669 }
670 ObjectSynchronizer::slow_exit(h_obj(), elem->lock(), thread);
671 // Free entry. This must be done here, since a pending exception might be installed on
672 // exit. If it is not cleared, the exception handling code will try to unlock the monitor again.
673 elem->set_obj(NULL);
674 #ifdef ASSERT
675 thread->last_frame().interpreter_frame_verify_monitor(elem);
676 #endif
677 IRT_END
678
679
680 IRT_ENTRY(void, InterpreterRuntime::throw_illegal_monitor_state_exception(JavaThread* thread))
681 THROW(vmSymbols::java_lang_IllegalMonitorStateException());
682 IRT_END
683
684
685 IRT_ENTRY(void, InterpreterRuntime::new_illegal_monitor_state_exception(JavaThread* thread))
710
711 IRT_ENTRY(void, InterpreterRuntime::set_original_bytecode_at(JavaThread* thread, Method* method, address bcp, Bytecodes::Code new_code))
712 method->set_orig_bytecode_at(method->bci_from(bcp), new_code);
713 IRT_END
714
715 IRT_ENTRY(void, InterpreterRuntime::_breakpoint(JavaThread* thread, Method* method, address bcp))
716 JvmtiExport::post_raw_breakpoint(thread, method, bcp);
717 IRT_END
718
719 void InterpreterRuntime::resolve_invoke(JavaThread* thread, Bytecodes::Code bytecode) {
720 Thread* THREAD = thread;
721 // extract receiver from the outgoing argument list if necessary
722 Handle receiver(thread, NULL);
723 if (bytecode == Bytecodes::_invokevirtual || bytecode == Bytecodes::_invokeinterface) {
724 ResourceMark rm(thread);
725 methodHandle m (thread, method(thread));
726 Bytecode_invoke call(m, bci(thread));
727 Symbol* signature = call.signature();
728 receiver = Handle(thread,
729 thread->last_frame().interpreter_callee_receiver(signature));
730 assert(GC::gc()->heap()->is_in_reserved_or_null(receiver()),
731 "sanity check");
732 assert(receiver.is_null() ||
733 !GC::gc()->heap()->is_in_reserved(receiver->klass()),
734 "sanity check");
735 }
736
737 // resolve method
738 CallInfo info;
739 constantPoolHandle pool(thread, method(thread)->constants());
740
741 {
742 JvmtiHideSingleStepping jhss(thread);
743 LinkResolver::resolve_invoke(info, receiver, pool,
744 get_index_u2_cpcache(thread, bytecode), bytecode,
745 CHECK);
746 if (JvmtiExport::can_hotswap_or_post_breakpoint()) {
747 int retry_count = 0;
748 while (info.resolved_method()->is_old()) {
749 // It is very unlikely that method is redefined more than 100 times
750 // in the middle of resolve. If it is looping here more than 100 times
751 // means then there could be a bug here.
752 guarantee((retry_count++ < 100),
753 "Could not resolve to latest version of redefined method");
|