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