725 static_cast<u1>(get_code), static_cast<u1>(put_code));
726 }
727
728
729 //------------------------------------------------------------------------------------------------------------------------
730 // Synchronization
731 //
732 // The interpreter's synchronization code is factored out so that it can
733 // be shared by method invocation and synchronized blocks.
734 //%note synchronization_3
735
736 //%note monitor_1
737 JRT_ENTRY_NO_ASYNC(void, InterpreterRuntime::monitorenter(JavaThread* current, BasicObjectLock* elem))
738 assert(LockingMode != LM_LIGHTWEIGHT, "Should call monitorenter_obj() when using the new lightweight locking");
739 #ifdef ASSERT
740 current->last_frame().interpreter_frame_verify_monitor(elem);
741 #endif
742 Handle h_obj(current, elem->obj());
743 assert(Universe::heap()->is_in_or_null(h_obj()),
744 "must be null or an object");
745 ObjectSynchronizer::enter(h_obj, elem->lock(), current);
746 assert(Universe::heap()->is_in_or_null(elem->obj()),
747 "must be null or an object");
748 #ifdef ASSERT
749 current->last_frame().interpreter_frame_verify_monitor(elem);
750 #endif
751 JRT_END
752
753 // NOTE: We provide a separate implementation for the new lightweight locking to workaround a limitation
754 // of registers in x86_32. This entry point accepts an oop instead of a BasicObjectLock*.
755 // The problem is that we would need to preserve the register that holds the BasicObjectLock,
756 // but we are using that register to hold the thread. We don't have enough registers to
757 // also keep the BasicObjectLock, but we don't really need it anyway, we only need
758 // the object. See also InterpreterMacroAssembler::lock_object().
759 // As soon as legacy stack-locking goes away we could remove the other monitorenter() entry
760 // point, and only use oop-accepting entries (same for monitorexit() below).
761 JRT_ENTRY_NO_ASYNC(void, InterpreterRuntime::monitorenter_obj(JavaThread* current, oopDesc* obj))
762 assert(LockingMode == LM_LIGHTWEIGHT, "Should call monitorenter() when not using the new lightweight locking");
763 Handle h_obj(current, cast_to_oop(obj));
764 assert(Universe::heap()->is_in_or_null(h_obj()),
765 "must be null or an object");
766 ObjectSynchronizer::enter(h_obj, nullptr, current);
767 return;
768 JRT_END
769
770 JRT_LEAF(void, InterpreterRuntime::monitorexit(BasicObjectLock* elem))
771 oop obj = elem->obj();
772 assert(Universe::heap()->is_in(obj), "must be an object");
773 // The object could become unlocked through a JNI call, which we have no other checks for.
774 // Give a fatal message if CheckJNICalls. Otherwise we ignore it.
775 if (obj->is_unlocked()) {
776 if (CheckJNICalls) {
777 fatal("Object has been unlocked by JNI");
778 }
779 return;
780 }
781 ObjectSynchronizer::exit(obj, elem->lock(), JavaThread::current());
782 // Free entry. If it is not cleared, the exception handling code will try to unlock the monitor
783 // again at method exit or in the case of an exception.
784 elem->set_obj(nullptr);
785 JRT_END
|
725 static_cast<u1>(get_code), static_cast<u1>(put_code));
726 }
727
728
729 //------------------------------------------------------------------------------------------------------------------------
730 // Synchronization
731 //
732 // The interpreter's synchronization code is factored out so that it can
733 // be shared by method invocation and synchronized blocks.
734 //%note synchronization_3
735
736 //%note monitor_1
737 JRT_ENTRY_NO_ASYNC(void, InterpreterRuntime::monitorenter(JavaThread* current, BasicObjectLock* elem))
738 assert(LockingMode != LM_LIGHTWEIGHT, "Should call monitorenter_obj() when using the new lightweight locking");
739 #ifdef ASSERT
740 current->last_frame().interpreter_frame_verify_monitor(elem);
741 #endif
742 Handle h_obj(current, elem->obj());
743 assert(Universe::heap()->is_in_or_null(h_obj()),
744 "must be null or an object");
745 ThreadOnMonitorEnter tme(current);
746 ObjectSynchronizer::enter(h_obj, elem->lock(), current);
747 assert(Universe::heap()->is_in_or_null(elem->obj()),
748 "must be null or an object");
749 #ifdef ASSERT
750 if (!current->preempting()) current->last_frame().interpreter_frame_verify_monitor(elem);
751 #endif
752 JRT_END
753
754 // NOTE: We provide a separate implementation for the new lightweight locking to workaround a limitation
755 // of registers in x86_32. This entry point accepts an oop instead of a BasicObjectLock*.
756 // The problem is that we would need to preserve the register that holds the BasicObjectLock,
757 // but we are using that register to hold the thread. We don't have enough registers to
758 // also keep the BasicObjectLock, but we don't really need it anyway, we only need
759 // the object. See also InterpreterMacroAssembler::lock_object().
760 // As soon as legacy stack-locking goes away we could remove the other monitorenter() entry
761 // point, and only use oop-accepting entries (same for monitorexit() below).
762 JRT_ENTRY_NO_ASYNC(void, InterpreterRuntime::monitorenter_obj(JavaThread* current, oopDesc* obj))
763 assert(LockingMode == LM_LIGHTWEIGHT, "Should call monitorenter() when not using the new lightweight locking");
764 Handle h_obj(current, cast_to_oop(obj));
765 assert(Universe::heap()->is_in_or_null(h_obj()),
766 "must be null or an object");
767 ThreadOnMonitorEnter tme(current);
768 ObjectSynchronizer::enter(h_obj, nullptr, current);
769 return;
770 JRT_END
771
772 JRT_LEAF(void, InterpreterRuntime::monitorexit(BasicObjectLock* elem))
773 oop obj = elem->obj();
774 assert(Universe::heap()->is_in(obj), "must be an object");
775 // The object could become unlocked through a JNI call, which we have no other checks for.
776 // Give a fatal message if CheckJNICalls. Otherwise we ignore it.
777 if (obj->is_unlocked()) {
778 if (CheckJNICalls) {
779 fatal("Object has been unlocked by JNI");
780 }
781 return;
782 }
783 ObjectSynchronizer::exit(obj, elem->lock(), JavaThread::current());
784 // Free entry. If it is not cleared, the exception handling code will try to unlock the monitor
785 // again at method exit or in the case of an exception.
786 elem->set_obj(nullptr);
787 JRT_END
|