819 const Register tmp3 = c_rarg5;
820
821 const int obj_offset = in_bytes(BasicObjectLock::obj_offset());
822 const int lock_offset = in_bytes(BasicObjectLock::lock_offset());
823 const int mark_offset = lock_offset +
824 BasicLock::displaced_header_offset_in_bytes();
825
826 Label slow_case;
827
828 // Load object pointer into obj_reg c_rarg3
829 ld(obj_reg, Address(lock_reg, obj_offset));
830
831 if (DiagnoseSyncOnValueBasedClasses != 0) {
832 load_klass(tmp, obj_reg);
833 lwu(tmp, Address(tmp, Klass::access_flags_offset()));
834 test_bit(tmp, tmp, exact_log2(JVM_ACC_IS_VALUE_BASED_CLASS));
835 bnez(tmp, slow_case);
836 }
837
838 if (LockingMode == LM_LIGHTWEIGHT) {
839 ld(tmp, Address(obj_reg, oopDesc::mark_offset_in_bytes()));
840 lightweight_lock(obj_reg, tmp, tmp2, tmp3, slow_case);
841 j(count);
842 } else if (LockingMode == LM_LEGACY) {
843 // Load (object->mark() | 1) into swap_reg
844 ld(t0, Address(obj_reg, oopDesc::mark_offset_in_bytes()));
845 ori(swap_reg, t0, 1);
846
847 // Save (object->mark() | 1) into BasicLock's displaced header
848 sd(swap_reg, Address(lock_reg, mark_offset));
849
850 assert(lock_offset == 0,
851 "displached header must be first word in BasicObjectLock");
852
853 cmpxchg_obj_header(swap_reg, lock_reg, obj_reg, t0, count, /*fallthrough*/nullptr);
854
855 // Test if the oopMark is an obvious stack pointer, i.e.,
856 // 1) (mark & 7) == 0, and
857 // 2) sp <= mark < mark + os::pagesize()
858 //
859 // These 3 tests can be done by evaluating the following
916 const Register header_reg = c_rarg2; // Will contain the old oopMark
917 const Register obj_reg = c_rarg3; // Will contain the oop
918 const Register tmp_reg = c_rarg4; // Temporary used by lightweight_unlock
919
920 save_bcp(); // Save in case of exception
921
922 if (LockingMode != LM_LIGHTWEIGHT) {
923 // Convert from BasicObjectLock structure to object and BasicLock
924 // structure Store the BasicLock address into x10
925 la(swap_reg, Address(lock_reg, BasicObjectLock::lock_offset()));
926 }
927
928 // Load oop into obj_reg(c_rarg3)
929 ld(obj_reg, Address(lock_reg, BasicObjectLock::obj_offset()));
930
931 // Free entry
932 sd(zr, Address(lock_reg, BasicObjectLock::obj_offset()));
933
934 if (LockingMode == LM_LIGHTWEIGHT) {
935 Label slow_case;
936
937 // Check for non-symmetric locking. This is allowed by the spec and the interpreter
938 // must handle it.
939 Register tmp1 = t0;
940 Register tmp2 = header_reg;
941 // First check for lock-stack underflow.
942 lwu(tmp1, Address(xthread, JavaThread::lock_stack_top_offset()));
943 mv(tmp2, (unsigned)LockStack::start_offset());
944 ble(tmp1, tmp2, slow_case);
945 // Then check if the top of the lock-stack matches the unlocked object.
946 subw(tmp1, tmp1, oopSize);
947 add(tmp1, xthread, tmp1);
948 ld(tmp1, Address(tmp1, 0));
949 bne(tmp1, obj_reg, slow_case);
950
951 ld(header_reg, Address(obj_reg, oopDesc::mark_offset_in_bytes()));
952 test_bit(t0, header_reg, exact_log2(markWord::monitor_value));
953 bnez(t0, slow_case);
954 lightweight_unlock(obj_reg, header_reg, swap_reg, tmp_reg, slow_case);
955 j(count);
956
957 bind(slow_case);
958 } else if (LockingMode == LM_LEGACY) {
959 // Load the old header from BasicLock structure
960 ld(header_reg, Address(swap_reg,
961 BasicLock::displaced_header_offset_in_bytes()));
962
963 // Test for recursion
964 beqz(header_reg, count);
965
966 // Atomic swap back the old header
967 cmpxchg_obj_header(swap_reg, header_reg, obj_reg, t0, count, /*fallthrough*/nullptr);
968 }
969
970 // Call the runtime routine for slow case.
971 sd(obj_reg, Address(lock_reg, BasicObjectLock::obj_offset())); // restore obj
972 call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorexit), lock_reg);
973
|
819 const Register tmp3 = c_rarg5;
820
821 const int obj_offset = in_bytes(BasicObjectLock::obj_offset());
822 const int lock_offset = in_bytes(BasicObjectLock::lock_offset());
823 const int mark_offset = lock_offset +
824 BasicLock::displaced_header_offset_in_bytes();
825
826 Label slow_case;
827
828 // Load object pointer into obj_reg c_rarg3
829 ld(obj_reg, Address(lock_reg, obj_offset));
830
831 if (DiagnoseSyncOnValueBasedClasses != 0) {
832 load_klass(tmp, obj_reg);
833 lwu(tmp, Address(tmp, Klass::access_flags_offset()));
834 test_bit(tmp, tmp, exact_log2(JVM_ACC_IS_VALUE_BASED_CLASS));
835 bnez(tmp, slow_case);
836 }
837
838 if (LockingMode == LM_LIGHTWEIGHT) {
839 lightweight_lock(obj_reg, tmp, tmp2, tmp3, slow_case);
840 j(count);
841 } else if (LockingMode == LM_LEGACY) {
842 // Load (object->mark() | 1) into swap_reg
843 ld(t0, Address(obj_reg, oopDesc::mark_offset_in_bytes()));
844 ori(swap_reg, t0, 1);
845
846 // Save (object->mark() | 1) into BasicLock's displaced header
847 sd(swap_reg, Address(lock_reg, mark_offset));
848
849 assert(lock_offset == 0,
850 "displached header must be first word in BasicObjectLock");
851
852 cmpxchg_obj_header(swap_reg, lock_reg, obj_reg, t0, count, /*fallthrough*/nullptr);
853
854 // Test if the oopMark is an obvious stack pointer, i.e.,
855 // 1) (mark & 7) == 0, and
856 // 2) sp <= mark < mark + os::pagesize()
857 //
858 // These 3 tests can be done by evaluating the following
915 const Register header_reg = c_rarg2; // Will contain the old oopMark
916 const Register obj_reg = c_rarg3; // Will contain the oop
917 const Register tmp_reg = c_rarg4; // Temporary used by lightweight_unlock
918
919 save_bcp(); // Save in case of exception
920
921 if (LockingMode != LM_LIGHTWEIGHT) {
922 // Convert from BasicObjectLock structure to object and BasicLock
923 // structure Store the BasicLock address into x10
924 la(swap_reg, Address(lock_reg, BasicObjectLock::lock_offset()));
925 }
926
927 // Load oop into obj_reg(c_rarg3)
928 ld(obj_reg, Address(lock_reg, BasicObjectLock::obj_offset()));
929
930 // Free entry
931 sd(zr, Address(lock_reg, BasicObjectLock::obj_offset()));
932
933 if (LockingMode == LM_LIGHTWEIGHT) {
934 Label slow_case;
935 lightweight_unlock(obj_reg, header_reg, swap_reg, tmp_reg, slow_case);
936 j(count);
937
938 bind(slow_case);
939 } else if (LockingMode == LM_LEGACY) {
940 // Load the old header from BasicLock structure
941 ld(header_reg, Address(swap_reg,
942 BasicLock::displaced_header_offset_in_bytes()));
943
944 // Test for recursion
945 beqz(header_reg, count);
946
947 // Atomic swap back the old header
948 cmpxchg_obj_header(swap_reg, header_reg, obj_reg, t0, count, /*fallthrough*/nullptr);
949 }
950
951 // Call the runtime routine for slow case.
952 sd(obj_reg, Address(lock_reg, BasicObjectLock::obj_offset())); // restore obj
953 call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorexit), lock_reg);
954
|