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