diff --git a/src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp b/src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp index b548444bb4875..73509c2213461 100644 --- a/src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp +++ b/src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp @@ -228,11 +228,7 @@ int LIR_Assembler::emit_unwind_handler() { if (method()->is_synchronized()) { monitor_address(0, FrameMap::R4_opr); stub = new MonitorExitStub(FrameMap::R4_opr, true, 0); - if (LockingMode == LM_MONITOR) { - __ b(*stub->entry()); - } else { - __ unlock_object(R5, R6, R4, *stub->entry()); - } + __ unlock_object(R5, R6, R4, *stub->entry()); __ bind(*stub->continuation()); } @@ -2618,44 +2614,20 @@ void LIR_Assembler::emit_lock(LIR_OpLock* op) { // Obj may not be an oop. if (op->code() == lir_lock) { MonitorEnterStub* stub = (MonitorEnterStub*)op->stub(); - if (LockingMode != LM_MONITOR) { - assert(BasicLock::displaced_header_offset_in_bytes() == 0, "lock_reg must point to the displaced header"); - // Add debug info for NullPointerException only if one is possible. - if (op->info() != nullptr) { - if (!os::zero_page_read_protected() || !ImplicitNullChecks) { - explicit_null_check(obj, op->info()); - } else { - add_debug_info_for_null_check_here(op->info()); - } - } - __ lock_object(hdr, obj, lock, op->scratch_opr()->as_register(), *op->stub()->entry()); - } else { - // always do slow locking - // note: The slow locking code could be inlined here, however if we use - // slow locking, speed doesn't matter anyway and this solution is - // simpler and requires less duplicated code - additionally, the - // slow locking code is the same in either case which simplifies - // debugging. - if (op->info() != nullptr) { + assert(BasicLock::displaced_header_offset_in_bytes() == 0, "lock_reg must point to the displaced header"); + // Add debug info for NullPointerException only if one is possible. + if (op->info() != nullptr) { + if (!os::zero_page_read_protected() || !ImplicitNullChecks) { + explicit_null_check(obj, op->info()); + } else { add_debug_info_for_null_check_here(op->info()); - __ null_check(obj); } - __ b(*op->stub()->entry()); } + __ lock_object(hdr, obj, lock, op->scratch_opr()->as_register(), *op->stub()->entry()); } else { assert (op->code() == lir_unlock, "Invalid code, expected lir_unlock"); - if (LockingMode != LM_MONITOR) { - assert(BasicLock::displaced_header_offset_in_bytes() == 0, "lock_reg must point to the displaced header"); - __ unlock_object(hdr, obj, lock, *op->stub()->entry()); - } else { - // always do slow unlocking - // note: The slow unlocking code could be inlined here, however if we use - // slow unlocking, speed doesn't matter anyway and this solution is - // simpler and requires less duplicated code - additionally, the - // slow unlocking code is the same in either case which simplifies - // debugging. - __ b(*op->stub()->entry()); - } + assert(BasicLock::displaced_header_offset_in_bytes() == 0, "lock_reg must point to the displaced header"); + __ unlock_object(hdr, obj, lock, *op->stub()->entry()); } __ bind(*op->stub()->continuation()); } diff --git a/src/hotspot/cpu/ppc/c1_MacroAssembler_ppc.cpp b/src/hotspot/cpu/ppc/c1_MacroAssembler_ppc.cpp index 23050bff45390..04af473c99ba2 100644 --- a/src/hotspot/cpu/ppc/c1_MacroAssembler_ppc.cpp +++ b/src/hotspot/cpu/ppc/c1_MacroAssembler_ppc.cpp @@ -82,59 +82,13 @@ void C1_MacroAssembler::lock_object(Register Rmark, Register Roop, Register Rbox // Save object being locked into the BasicObjectLock... std(Roop, in_bytes(BasicObjectLock::obj_offset()), Rbox); - if (LockingMode == LM_LIGHTWEIGHT) { - lightweight_lock(Rbox, Roop, Rmark, Rscratch, slow_int); - } else if (LockingMode == LM_LEGACY) { - - if (DiagnoseSyncOnValueBasedClasses != 0) { - load_klass(Rscratch, Roop); - lbz(Rscratch, in_bytes(Klass::misc_flags_offset()), Rscratch); - testbitdi(CR0, R0, Rscratch, exact_log2(KlassFlags::_misc_is_value_based_class)); - bne(CR0, slow_int); - } - - // ... and mark it unlocked. - ori(Rmark, Rmark, markWord::unlocked_value); - - // Save unlocked object header into the displaced header location on the stack. - std(Rmark, BasicLock::displaced_header_offset_in_bytes(), Rbox); - - // Compare object markWord with Rmark and if equal exchange Rscratch with object markWord. - assert(oopDesc::mark_offset_in_bytes() == 0, "cas must take a zero displacement"); - cmpxchgd(/*flag=*/CR0, - /*current_value=*/Rscratch, - /*compare_value=*/Rmark, - /*exchange_value=*/Rbox, - /*where=*/Roop/*+0==mark_offset_in_bytes*/, - MacroAssembler::MemBarRel | MacroAssembler::MemBarAcq, - MacroAssembler::cmpxchgx_hint_acquire_lock(), - noreg, - &cas_failed, - /*check without membar and ldarx first*/true); - // If compare/exchange succeeded we found an unlocked object and we now have locked it - // hence we are done. - } else { - assert(false, "Unhandled LockingMode:%d", LockingMode); - } + lightweight_lock(Rbox, Roop, Rmark, Rscratch, slow_int); b(done); bind(slow_int); b(slow_case); // far - if (LockingMode == LM_LEGACY) { - bind(cas_failed); - // We did not find an unlocked object so see if this is a recursive case. - sub(Rscratch, Rscratch, R1_SP); - load_const_optimized(R0, (~(os::vm_page_size()-1) | markWord::lock_mask_in_place)); - and_(R0/*==0?*/, Rscratch, R0); - std(R0/*==0, perhaps*/, BasicLock::displaced_header_offset_in_bytes(), Rbox); - bne(CR0, slow_int); - } - bind(done); - if (LockingMode == LM_LEGACY) { - inc_held_monitor_count(Rmark /*tmp*/); - } } @@ -146,43 +100,17 @@ void C1_MacroAssembler::unlock_object(Register Rmark, Register Roop, Register Rb Address mark_addr(Roop, oopDesc::mark_offset_in_bytes()); assert(mark_addr.disp() == 0, "cas must take a zero displacement"); - if (LockingMode != LM_LIGHTWEIGHT) { - // Test first if it is a fast recursive unlock. - ld(Rmark, BasicLock::displaced_header_offset_in_bytes(), Rbox); - cmpdi(CR0, Rmark, 0); - beq(CR0, done); - } - // Load object. ld(Roop, in_bytes(BasicObjectLock::obj_offset()), Rbox); verify_oop(Roop, FILE_AND_LINE); - if (LockingMode == LM_LIGHTWEIGHT) { - lightweight_unlock(Roop, Rmark, slow_int); - } else if (LockingMode == LM_LEGACY) { - // Check if it is still a light weight lock, this is is true if we see - // the stack address of the basicLock in the markWord of the object. - cmpxchgd(/*flag=*/CR0, - /*current_value=*/R0, - /*compare_value=*/Rbox, - /*exchange_value=*/Rmark, - /*where=*/Roop, - MacroAssembler::MemBarRel, - MacroAssembler::cmpxchgx_hint_release_lock(), - noreg, - &slow_int); - } else { - assert(false, "Unhandled LockingMode:%d", LockingMode); - } + lightweight_unlock(Roop, Rmark, slow_int); b(done); bind(slow_int); b(slow_case); // far // Done bind(done); - if (LockingMode == LM_LEGACY) { - dec_held_monitor_count(Rmark /*tmp*/); - } } diff --git a/src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp b/src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp index 29fb54250c215..8df2cc5d273ff 100644 --- a/src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp +++ b/src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp @@ -946,121 +946,20 @@ void InterpreterMacroAssembler::leave_jfr_critical_section() { // object - Address of the object to be locked. // void InterpreterMacroAssembler::lock_object(Register monitor, Register object) { - if (LockingMode == LM_MONITOR) { - call_VM_preemptable(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorenter), monitor); - } else { - // template code (for LM_LEGACY): - // - // markWord displaced_header = obj->mark().set_unlocked(); - // monitor->lock()->set_displaced_header(displaced_header); - // if (Atomic::cmpxchg(/*addr*/obj->mark_addr(), /*cmp*/displaced_header, /*ex=*/monitor) == displaced_header) { - // // We stored the monitor address into the object's mark word. - // } else if (THREAD->is_lock_owned((address)displaced_header)) - // // Simple recursive case. - // monitor->lock()->set_displaced_header(nullptr); - // } else { - // // Slow path. - // InterpreterRuntime::monitorenter(THREAD, monitor); - // } - - const Register header = R7_ARG5; - const Register object_mark_addr = R8_ARG6; - const Register current_header = R9_ARG7; - const Register tmp = R10_ARG8; - - Label count_locking, done, slow_case, cas_failed; - - assert_different_registers(header, object_mark_addr, current_header, tmp); - - // markWord displaced_header = obj->mark().set_unlocked(); - - if (LockingMode == LM_LIGHTWEIGHT) { - lightweight_lock(monitor, object, header, tmp, slow_case); - b(done); - } else if (LockingMode == LM_LEGACY) { - - if (DiagnoseSyncOnValueBasedClasses != 0) { - load_klass(tmp, object); - lbz(tmp, in_bytes(Klass::misc_flags_offset()), tmp); - testbitdi(CR0, R0, tmp, exact_log2(KlassFlags::_misc_is_value_based_class)); - bne(CR0, slow_case); - } + const Register header = R7_ARG5; + const Register tmp = R8_ARG6; - // Load markWord from object into header. - ld(header, oopDesc::mark_offset_in_bytes(), object); - - // Set displaced_header to be (markWord of object | UNLOCK_VALUE). - ori(header, header, markWord::unlocked_value); - - // monitor->lock()->set_displaced_header(displaced_header); - const int lock_offset = in_bytes(BasicObjectLock::lock_offset()); - const int mark_offset = lock_offset + - BasicLock::displaced_header_offset_in_bytes(); - - // Initialize the box (Must happen before we update the object mark!). - std(header, mark_offset, monitor); - - // if (Atomic::cmpxchg(/*addr*/obj->mark_addr(), /*cmp*/displaced_header, /*ex=*/monitor) == displaced_header) { - - // Store stack address of the BasicObjectLock (this is monitor) into object. - addi(object_mark_addr, object, oopDesc::mark_offset_in_bytes()); - - // Must fence, otherwise, preceding store(s) may float below cmpxchg. - // CmpxchgX sets CR0 to cmpX(current, displaced). - cmpxchgd(/*flag=*/CR0, - /*current_value=*/current_header, - /*compare_value=*/header, /*exchange_value=*/monitor, - /*where=*/object_mark_addr, - MacroAssembler::MemBarRel | MacroAssembler::MemBarAcq, - MacroAssembler::cmpxchgx_hint_acquire_lock(), - noreg, - &cas_failed, - /*check without membar and ldarx first*/true); - - // If the compare-and-exchange succeeded, then we found an unlocked - // object and we have now locked it. - b(count_locking); - bind(cas_failed); - - // } else if (THREAD->is_lock_owned((address)displaced_header)) - // // Simple recursive case. - // monitor->lock()->set_displaced_header(nullptr); - - // We did not see an unlocked object so try the fast recursive case. - - // Check if owner is self by comparing the value in the markWord of object - // (current_header) with the stack pointer. - sub(current_header, current_header, R1_SP); - - assert(os::vm_page_size() > 0xfff, "page size too small - change the constant"); - load_const_optimized(tmp, ~(os::vm_page_size()-1) | markWord::lock_mask_in_place); - - and_(R0/*==0?*/, current_header, tmp); - // If condition is true we are done and hence we can store 0 in the displaced - // header indicating it is a recursive lock. - bne(CR0, slow_case); - std(R0/*==0!*/, mark_offset, monitor); - b(count_locking); - } + Label done, slow_case; - // } else { - // // Slow path. - // InterpreterRuntime::monitorenter(THREAD, monitor); - - // None of the above fast optimizations worked so we have to get into the - // slow case of monitor enter. - bind(slow_case); - call_VM_preemptable(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorenter), monitor); - // } - - if (LockingMode == LM_LEGACY) { - b(done); - align(32, 12); - bind(count_locking); - inc_held_monitor_count(current_header /*tmp*/); - } - bind(done); - } + assert_different_registers(header, tmp); + + lightweight_lock(monitor, object, header, tmp, slow_case); + b(done); + + bind(slow_case); + call_VM_preemptable(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorenter), monitor); + + bind(done); } // Unlocks an object. Used in monitorexit bytecode and remove_activation. @@ -1071,95 +970,34 @@ void InterpreterMacroAssembler::lock_object(Register monitor, Register object) { // // Throw IllegalMonitorException if object is not locked by current thread. void InterpreterMacroAssembler::unlock_object(Register monitor) { - if (LockingMode == LM_MONITOR) { - call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorexit), monitor); - } else { - - // template code (for LM_LEGACY): - // - // if ((displaced_header = monitor->displaced_header()) == nullptr) { - // // Recursive unlock. Mark the monitor unlocked by setting the object field to null. - // monitor->set_obj(nullptr); - // } else if (Atomic::cmpxchg(obj->mark_addr(), monitor, displaced_header) == monitor) { - // // We swapped the unlocked mark in displaced_header into the object's mark word. - // monitor->set_obj(nullptr); - // } else { - // // Slow path. - // InterpreterRuntime::monitorexit(monitor); - // } - - const Register object = R7_ARG5; - const Register header = R8_ARG6; - const Register object_mark_addr = R9_ARG7; - const Register current_header = R10_ARG8; - - Label free_slot; - Label slow_case; - - assert_different_registers(object, header, object_mark_addr, current_header); - - if (LockingMode != LM_LIGHTWEIGHT) { - // Test first if we are in the fast recursive case. - ld(header, in_bytes(BasicObjectLock::lock_offset()) + - BasicLock::displaced_header_offset_in_bytes(), monitor); - - // If the displaced header is zero, we have a recursive unlock. - cmpdi(CR0, header, 0); - beq(CR0, free_slot); // recursive unlock - } + const Register object = R7_ARG5; + const Register header = R8_ARG6; + const Register current_header = R10_ARG8; - // } else if (Atomic::cmpxchg(obj->mark_addr(), monitor, displaced_header) == monitor) { - // // We swapped the unlocked mark in displaced_header into the object's mark word. - // monitor->set_obj(nullptr); + Label free_slot; + Label slow_case; - // If we still have a lightweight lock, unlock the object and be done. + assert_different_registers(object, header, current_header); - // The object address from the monitor is in object. - ld(object, in_bytes(BasicObjectLock::obj_offset()), monitor); + // The object address from the monitor is in object. + ld(object, in_bytes(BasicObjectLock::obj_offset()), monitor); - if (LockingMode == LM_LIGHTWEIGHT) { - lightweight_unlock(object, header, slow_case); - } else { - addi(object_mark_addr, object, oopDesc::mark_offset_in_bytes()); - - // We have the displaced header in displaced_header. If the lock is still - // lightweight, it will contain the monitor address and we'll store the - // displaced header back into the object's mark word. - // CmpxchgX sets CR0 to cmpX(current, monitor). - cmpxchgd(/*flag=*/CR0, - /*current_value=*/current_header, - /*compare_value=*/monitor, /*exchange_value=*/header, - /*where=*/object_mark_addr, - MacroAssembler::MemBarRel, - MacroAssembler::cmpxchgx_hint_release_lock(), - noreg, - &slow_case); - } - b(free_slot); + lightweight_unlock(object, header, slow_case); - // } else { - // // Slow path. - // InterpreterRuntime::monitorexit(monitor); + b(free_slot); - // The lock has been converted into a heavy lock and hence - // we need to get into the slow case. - bind(slow_case); - call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorexit), monitor); - // } + bind(slow_case); + call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorexit), monitor); - Label done; - b(done); // Monitor register may be overwritten! Runtime has already freed the slot. + Label done; + b(done); // Monitor register may be overwritten! Runtime has already freed the slot. - // Exchange worked, do monitor->set_obj(nullptr); - align(32, 12); - bind(free_slot); - li(R0, 0); - std(R0, in_bytes(BasicObjectLock::obj_offset()), monitor); - if (LockingMode == LM_LEGACY) { - dec_held_monitor_count(current_header /*tmp*/); - } - bind(done); - } + // Do monitor->set_obj(nullptr); + align(32, 12); + bind(free_slot); + li(R0, 0); + std(R0, in_bytes(BasicObjectLock::obj_offset()), monitor); + bind(done); } // Load compiled (i2c) or interpreter entry when calling from interpreted and diff --git a/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp b/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp index 396a50427f852..00a46504e145f 100644 --- a/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp +++ b/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp @@ -2671,238 +2671,6 @@ address MacroAssembler::emit_trampoline_stub(int destination_toc_offset, } // "The box" is the space on the stack where we copy the object mark. -void MacroAssembler::compiler_fast_lock_object(ConditionRegister flag, Register oop, Register box, - Register temp, Register displaced_header, Register current_header) { - assert(LockingMode != LM_LIGHTWEIGHT, "uses fast_lock_lightweight"); - assert_different_registers(oop, box, temp, displaced_header, current_header); - Label object_has_monitor; - Label cas_failed; - Label success, failure; - - // Load markWord from object into displaced_header. - ld(displaced_header, oopDesc::mark_offset_in_bytes(), oop); - - if (DiagnoseSyncOnValueBasedClasses != 0) { - load_klass(temp, oop); - lbz(temp, in_bytes(Klass::misc_flags_offset()), temp); - testbitdi(flag, R0, temp, exact_log2(KlassFlags::_misc_is_value_based_class)); - bne(flag, failure); - } - - // Handle existing monitor. - // The object has an existing monitor iff (mark & monitor_value) != 0. - andi_(temp, displaced_header, markWord::monitor_value); - bne(CR0, object_has_monitor); - - if (LockingMode == LM_MONITOR) { - // Set NE to indicate 'failure' -> take slow-path. - crandc(flag, Assembler::equal, flag, Assembler::equal); - b(failure); - } else { - assert(LockingMode == LM_LEGACY, "must be"); - // Set displaced_header to be (markWord of object | UNLOCK_VALUE). - ori(displaced_header, displaced_header, markWord::unlocked_value); - - // Load Compare Value application register. - - // Initialize the box. (Must happen before we update the object mark!) - std(displaced_header, BasicLock::displaced_header_offset_in_bytes(), box); - - // Must fence, otherwise, preceding store(s) may float below cmpxchg. - // Compare object markWord with mark and if equal exchange scratch1 with object markWord. - cmpxchgd(/*flag=*/flag, - /*current_value=*/current_header, - /*compare_value=*/displaced_header, - /*exchange_value=*/box, - /*where=*/oop, - MacroAssembler::MemBarRel | MacroAssembler::MemBarAcq, - MacroAssembler::cmpxchgx_hint_acquire_lock(), - noreg, - &cas_failed, - /*check without membar and ldarx first*/true); - assert(oopDesc::mark_offset_in_bytes() == 0, "offset of _mark is not 0"); - // If the compare-and-exchange succeeded, then we found an unlocked - // object and we have now locked it. - b(success); - - bind(cas_failed); - // We did not see an unlocked object so try the fast recursive case. - - // Check if the owner is self by comparing the value in the markWord of object - // (current_header) with the stack pointer. - sub(current_header, current_header, R1_SP); - load_const_optimized(temp, ~(os::vm_page_size()-1) | markWord::lock_mask_in_place); - - and_(R0/*==0?*/, current_header, temp); - // If condition is true we are cont and hence we can store 0 as the - // displaced header in the box, which indicates that it is a recursive lock. - std(R0/*==0, perhaps*/, BasicLock::displaced_header_offset_in_bytes(), box); - - if (flag != CR0) { - mcrf(flag, CR0); - } - beq(CR0, success); - b(failure); - } - - // Handle existing monitor. - bind(object_has_monitor); - - // Try to CAS owner (no owner => current thread's _monitor_owner_id). - addi(temp, displaced_header, in_bytes(ObjectMonitor::owner_offset()) - markWord::monitor_value); - Register thread_id = displaced_header; - ld(thread_id, in_bytes(JavaThread::monitor_owner_id_offset()), R16_thread); - cmpxchgd(/*flag=*/flag, - /*current_value=*/current_header, - /*compare_value=*/(intptr_t)0, - /*exchange_value=*/thread_id, - /*where=*/temp, - MacroAssembler::MemBarRel | MacroAssembler::MemBarAcq, - MacroAssembler::cmpxchgx_hint_acquire_lock()); - - // Store a non-null value into the box. - std(box, BasicLock::displaced_header_offset_in_bytes(), box); - beq(flag, success); - - // Check for recursive locking. - cmpd(flag, current_header, thread_id); - bne(flag, failure); - - // Current thread already owns the lock. Just increment recursions. - Register recursions = displaced_header; - ld(recursions, in_bytes(ObjectMonitor::recursions_offset() - ObjectMonitor::owner_offset()), temp); - addi(recursions, recursions, 1); - std(recursions, in_bytes(ObjectMonitor::recursions_offset() - ObjectMonitor::owner_offset()), temp); - - // flag == EQ indicates success, increment held monitor count if LM_LEGACY is enabled - // flag == NE indicates failure - bind(success); - if (LockingMode == LM_LEGACY) { - inc_held_monitor_count(temp); - } -#ifdef ASSERT - // Check that unlocked label is reached with flag == EQ. - Label flag_correct; - beq(flag, flag_correct); - stop("compiler_fast_lock_object: Flag != EQ"); -#endif - bind(failure); -#ifdef ASSERT - // Check that slow_path label is reached with flag == NE. - bne(flag, flag_correct); - stop("compiler_fast_lock_object: Flag != NE"); - bind(flag_correct); -#endif -} - -void MacroAssembler::compiler_fast_unlock_object(ConditionRegister flag, Register oop, Register box, - Register temp, Register displaced_header, Register current_header) { - assert(LockingMode != LM_LIGHTWEIGHT, "uses fast_unlock_lightweight"); - assert_different_registers(oop, box, temp, displaced_header, current_header); - Label success, failure, object_has_monitor, not_recursive; - - if (LockingMode == LM_LEGACY) { - // Find the lock address and load the displaced header from the stack. - ld(displaced_header, BasicLock::displaced_header_offset_in_bytes(), box); - - // If the displaced header is 0, we have a recursive unlock. - cmpdi(flag, displaced_header, 0); - beq(flag, success); - } - - // Handle existing monitor. - // The object has an existing monitor iff (mark & monitor_value) != 0. - ld(current_header, oopDesc::mark_offset_in_bytes(), oop); - andi_(R0, current_header, markWord::monitor_value); - bne(CR0, object_has_monitor); - - if (LockingMode == LM_MONITOR) { - // Set NE to indicate 'failure' -> take slow-path. - crandc(flag, Assembler::equal, flag, Assembler::equal); - b(failure); - } else { - assert(LockingMode == LM_LEGACY, "must be"); - // Check if it is still a light weight lock, this is is true if we see - // the stack address of the basicLock in the markWord of the object. - // Cmpxchg sets flag to cmpd(current_header, box). - cmpxchgd(/*flag=*/flag, - /*current_value=*/current_header, - /*compare_value=*/box, - /*exchange_value=*/displaced_header, - /*where=*/oop, - MacroAssembler::MemBarRel, - MacroAssembler::cmpxchgx_hint_release_lock(), - noreg, - &failure); - assert(oopDesc::mark_offset_in_bytes() == 0, "offset of _mark is not 0"); - b(success); - } - - // Handle existing monitor. - bind(object_has_monitor); - STATIC_ASSERT(markWord::monitor_value <= INT_MAX); - addi(current_header, current_header, -(int)markWord::monitor_value); // monitor - - ld(displaced_header, in_bytes(ObjectMonitor::recursions_offset()), current_header); - addic_(displaced_header, displaced_header, -1); - blt(CR0, not_recursive); // Not recursive if negative after decrement. - - // Recursive unlock - std(displaced_header, in_bytes(ObjectMonitor::recursions_offset()), current_header); - if (flag == CR0) { // Otherwise, flag is already EQ, here. - crorc(CR0, Assembler::equal, CR0, Assembler::equal); // Set CR0 EQ - } - b(success); - - bind(not_recursive); - - // Set owner to null. - // Release to satisfy the JMM - release(); - li(temp, 0); - std(temp, in_bytes(ObjectMonitor::owner_offset()), current_header); - // We need a full fence after clearing owner to avoid stranding. - // StoreLoad achieves this. - membar(StoreLoad); - - // Check if the entry_list is empty. - ld(temp, in_bytes(ObjectMonitor::entry_list_offset()), current_header); - cmpdi(flag, temp, 0); - beq(flag, success); // If so we are done. - - // Check if there is a successor. - ld(temp, in_bytes(ObjectMonitor::succ_offset()), current_header); - cmpdi(flag, temp, 0); - // Invert equal bit - crnand(flag, Assembler::equal, flag, Assembler::equal); - beq(flag, success); // If there is a successor we are done. - - // Save the monitor pointer in the current thread, so we can try - // to reacquire the lock in SharedRuntime::monitor_exit_helper(). - std(current_header, in_bytes(JavaThread::unlocked_inflated_monitor_offset()), R16_thread); - b(failure); // flag == NE - - // flag == EQ indicates success, decrement held monitor count if LM_LEGACY is enabled - // flag == NE indicates failure - bind(success); - if (LockingMode == LM_LEGACY) { - dec_held_monitor_count(temp); - } -#ifdef ASSERT - // Check that unlocked label is reached with flag == EQ. - Label flag_correct; - beq(flag, flag_correct); - stop("compiler_fast_unlock_object: Flag != EQ"); -#endif - bind(failure); -#ifdef ASSERT - // Check that slow_path label is reached with flag == NE. - bne(flag, flag_correct); - stop("compiler_fast_unlock_object: Flag != NE"); - bind(flag_correct); -#endif -} - void MacroAssembler::compiler_fast_lock_lightweight_object(ConditionRegister flag, Register obj, Register box, Register tmp1, Register tmp2, Register tmp3) { assert_different_registers(obj, box, tmp1, tmp2, tmp3); @@ -4769,38 +4537,6 @@ void MacroAssembler::pop_cont_fastpath() { bind(done); } -// Note: Must preserve CR0 EQ (invariant). -void MacroAssembler::inc_held_monitor_count(Register tmp) { - assert(LockingMode == LM_LEGACY, ""); - ld(tmp, in_bytes(JavaThread::held_monitor_count_offset()), R16_thread); -#ifdef ASSERT - Label ok; - cmpdi(CR0, tmp, 0); - bge_predict_taken(CR0, ok); - stop("held monitor count is negativ at increment"); - bind(ok); - crorc(CR0, Assembler::equal, CR0, Assembler::equal); // Restore CR0 EQ -#endif - addi(tmp, tmp, 1); - std(tmp, in_bytes(JavaThread::held_monitor_count_offset()), R16_thread); -} - -// Note: Must preserve CR0 EQ (invariant). -void MacroAssembler::dec_held_monitor_count(Register tmp) { - assert(LockingMode == LM_LEGACY, ""); - ld(tmp, in_bytes(JavaThread::held_monitor_count_offset()), R16_thread); -#ifdef ASSERT - Label ok; - cmpdi(CR0, tmp, 0); - bgt_predict_taken(CR0, ok); - stop("held monitor count is <= 0 at decrement"); - bind(ok); - crorc(CR0, Assembler::equal, CR0, Assembler::equal); // Restore CR0 EQ -#endif - addi(tmp, tmp, -1); - std(tmp, in_bytes(JavaThread::held_monitor_count_offset()), R16_thread); -} - // Function to flip between unlocked and locked state (fast locking). // Branches to failed if the state is not as expected with CR0 NE. // Falls through upon success with CR0 EQ. @@ -4842,7 +4578,6 @@ void MacroAssembler::atomically_flip_locked_state(bool is_unlock, Register obj, // - obj: the object to be locked // - t1, t2: temporary register void MacroAssembler::lightweight_lock(Register box, Register obj, Register t1, Register t2, Label& slow) { - assert(LockingMode == LM_LIGHTWEIGHT, "only used with new lightweight locking"); assert_different_registers(box, obj, t1, t2, R0); Label push; @@ -4899,7 +4634,6 @@ void MacroAssembler::lightweight_lock(Register box, Register obj, Register t1, R // - obj: the object to be unlocked // - t1: temporary register void MacroAssembler::lightweight_unlock(Register obj, Register t1, Label& slow) { - assert(LockingMode == LM_LIGHTWEIGHT, "only used with new lightweight locking"); assert_different_registers(obj, t1); #ifdef ASSERT diff --git a/src/hotspot/cpu/ppc/macroAssembler_ppc.hpp b/src/hotspot/cpu/ppc/macroAssembler_ppc.hpp index 471ebb7459a1f..35ae136a5bc92 100644 --- a/src/hotspot/cpu/ppc/macroAssembler_ppc.hpp +++ b/src/hotspot/cpu/ppc/macroAssembler_ppc.hpp @@ -697,8 +697,6 @@ class MacroAssembler: public Assembler { void push_cont_fastpath(); void pop_cont_fastpath(); - void inc_held_monitor_count(Register tmp); - void dec_held_monitor_count(Register tmp); void atomically_flip_locked_state(bool is_unlock, Register obj, Register tmp, Label& failed, int semantics); void lightweight_lock(Register box, Register obj, Register t1, Register t2, Label& slow); void lightweight_unlock(Register obj, Register t1, Label& slow); diff --git a/src/hotspot/cpu/ppc/ppc.ad b/src/hotspot/cpu/ppc/ppc.ad index bf43ecaba79f2..cd71e298b7d28 100644 --- a/src/hotspot/cpu/ppc/ppc.ad +++ b/src/hotspot/cpu/ppc/ppc.ad @@ -11573,40 +11573,8 @@ instruct partialSubtypeCheckConstSuper(rarg3RegP sub, rarg2RegP super_reg, immP // inlined locking and unlocking -instruct cmpFastLock(flagsRegCR0 crx, iRegPdst oop, iRegPdst box, iRegPdst tmp1, iRegPdst tmp2) %{ - predicate(LockingMode != LM_LIGHTWEIGHT); - match(Set crx (FastLock oop box)); - effect(TEMP tmp1, TEMP tmp2); - - format %{ "FASTLOCK $oop, $box, $tmp1, $tmp2" %} - ins_encode %{ - __ compiler_fast_lock_object($crx$$CondRegister, $oop$$Register, $box$$Register, - $tmp1$$Register, $tmp2$$Register, /*tmp3*/ R0); - // If locking was successful, crx should indicate 'EQ'. - // The compiler generates a branch to the runtime call to - // _complete_monitor_locking_Java for the case where crx is 'NE'. - %} - ins_pipe(pipe_class_compare); -%} - -instruct cmpFastUnlock(flagsRegCR0 crx, iRegPdst oop, iRegPdst box, iRegPdst tmp1, iRegPdst tmp2, iRegPdst tmp3) %{ - predicate(LockingMode != LM_LIGHTWEIGHT); - match(Set crx (FastUnlock oop box)); - effect(TEMP tmp1, TEMP tmp2, TEMP tmp3); - - format %{ "FASTUNLOCK $oop, $box, $tmp1, $tmp2" %} - ins_encode %{ - __ compiler_fast_unlock_object($crx$$CondRegister, $oop$$Register, $box$$Register, - $tmp1$$Register, $tmp2$$Register, $tmp3$$Register); - // If unlocking was successful, crx should indicate 'EQ'. - // The compiler generates a branch to the runtime call to - // _complete_monitor_unlocking_Java for the case where crx is 'NE'. - %} - ins_pipe(pipe_class_compare); -%} - instruct cmpFastLockLightweight(flagsRegCR0 crx, iRegPdst oop, iRegPdst box, iRegPdst tmp1, iRegPdst tmp2) %{ - predicate(LockingMode == LM_LIGHTWEIGHT && !UseObjectMonitorTable); + predicate(!UseObjectMonitorTable); match(Set crx (FastLock oop box)); effect(TEMP tmp1, TEMP tmp2); @@ -11622,7 +11590,7 @@ instruct cmpFastLockLightweight(flagsRegCR0 crx, iRegPdst oop, iRegPdst box, iRe %} instruct cmpFastLockMonitorTable(flagsRegCR0 crx, iRegPdst oop, iRegPdst box, iRegPdst tmp1, iRegPdst tmp2, iRegPdst tmp3, flagsRegCR1 cr1) %{ - predicate(LockingMode == LM_LIGHTWEIGHT && UseObjectMonitorTable); + predicate(UseObjectMonitorTable); match(Set crx (FastLock oop box)); effect(TEMP tmp1, TEMP tmp2, TEMP tmp3, KILL cr1); @@ -11638,7 +11606,6 @@ instruct cmpFastLockMonitorTable(flagsRegCR0 crx, iRegPdst oop, iRegPdst box, iR %} instruct cmpFastUnlockLightweight(flagsRegCR0 crx, iRegPdst oop, iRegPdst box, iRegPdst tmp1, iRegPdst tmp2, iRegPdst tmp3) %{ - predicate(LockingMode == LM_LIGHTWEIGHT); match(Set crx (FastUnlock oop box)); effect(TEMP tmp1, TEMP tmp2, TEMP tmp3); diff --git a/src/hotspot/cpu/ppc/sharedRuntime_ppc.cpp b/src/hotspot/cpu/ppc/sharedRuntime_ppc.cpp index 64bd8dc7812e0..2a9bad059ba22 100644 --- a/src/hotspot/cpu/ppc/sharedRuntime_ppc.cpp +++ b/src/hotspot/cpu/ppc/sharedRuntime_ppc.cpp @@ -2446,14 +2446,9 @@ nmethod *SharedRuntime::generate_native_wrapper(MacroAssembler *masm, __ addi(r_box, R1_SP, lock_offset); // Try fastpath for locking. - if (LockingMode == LM_LIGHTWEIGHT) { - // fast_lock kills r_temp_1, r_temp_2, r_temp_3. - Register r_temp_3_or_noreg = UseObjectMonitorTable ? r_temp_3 : noreg; - __ compiler_fast_lock_lightweight_object(CR0, r_oop, r_box, r_temp_1, r_temp_2, r_temp_3_or_noreg); - } else { - // fast_lock kills r_temp_1, r_temp_2, r_temp_3. - __ compiler_fast_lock_object(CR0, r_oop, r_box, r_temp_1, r_temp_2, r_temp_3); - } + // fast_lock kills r_temp_1, r_temp_2, r_temp_3. + Register r_temp_3_or_noreg = UseObjectMonitorTable ? r_temp_3 : noreg; + __ compiler_fast_lock_lightweight_object(CR0, r_oop, r_box, r_temp_1, r_temp_2, r_temp_3_or_noreg); __ beq(CR0, locked); // None of the above fast optimizations worked so we have to get into the @@ -2620,7 +2615,7 @@ nmethod *SharedRuntime::generate_native_wrapper(MacroAssembler *masm, __ stw(R0, thread_(thread_state)); // Check preemption for Object.wait() - if (LockingMode != LM_LEGACY && method->is_object_wait0()) { + if (method->is_object_wait0()) { Label not_preempted; __ ld(R0, in_bytes(JavaThread::preempt_alternate_return_offset()), R16_thread); __ cmpdi(CR0, R0, 0); @@ -2672,11 +2667,7 @@ nmethod *SharedRuntime::generate_native_wrapper(MacroAssembler *masm, __ addi(r_box, R1_SP, lock_offset); // Try fastpath for unlocking. - if (LockingMode == LM_LIGHTWEIGHT) { - __ compiler_fast_unlock_lightweight_object(CR0, r_oop, r_box, r_temp_1, r_temp_2, r_temp_3); - } else { - __ compiler_fast_unlock_object(CR0, r_oop, r_box, r_temp_1, r_temp_2, r_temp_3); - } + __ compiler_fast_unlock_lightweight_object(CR0, r_oop, r_box, r_temp_1, r_temp_2, r_temp_3); __ beq(CR0, done); // Save and restore any potential method result value around the unlocking operation. @@ -2717,7 +2708,7 @@ nmethod *SharedRuntime::generate_native_wrapper(MacroAssembler *masm, // -------------------------------------------------------------------------- // Last java frame won't be set if we're resuming after preemption - bool maybe_preempted = LockingMode != LM_LEGACY && method->is_object_wait0(); + bool maybe_preempted = method->is_object_wait0(); __ reset_last_Java_frame(!maybe_preempted /* check_last_java_sp */); // Unbox oop result, e.g. JNIHandles::resolve value. diff --git a/src/hotspot/cpu/ppc/templateInterpreterGenerator_ppc.cpp b/src/hotspot/cpu/ppc/templateInterpreterGenerator_ppc.cpp index b5f1c76c5da69..199b578a36f23 100644 --- a/src/hotspot/cpu/ppc/templateInterpreterGenerator_ppc.cpp +++ b/src/hotspot/cpu/ppc/templateInterpreterGenerator_ppc.cpp @@ -1362,7 +1362,7 @@ address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) { // convenient and the slow signature handler can use this same frame // anchor. - bool support_vthread_preemption = Continuations::enabled() && LockingMode != LM_LEGACY; + bool support_vthread_preemption = Continuations::enabled(); // We have a TOP_IJAVA_FRAME here, which belongs to us. Label last_java_pc;