# HG changeset patch # User rkennke # Date 1569855260 -7200 # Mon Sep 30 16:54:20 2019 +0200 # Node ID 964415a05aa7c8ccbd3505e3a0b98f2072158669 # Parent 4107e5a422b6ece5a6d063eb0b8e1a1043857954 8231583: Shenandoah: Fix register clash in SBSA::resolve_forwarding_pointer() borrowing diff --git a/src/hotspot/cpu/x86/gc/shenandoah/shenandoahBarrierSetAssembler_x86.cpp b/src/hotspot/cpu/x86/gc/shenandoah/shenandoahBarrierSetAssembler_x86.cpp --- a/src/hotspot/cpu/x86/gc/shenandoah/shenandoahBarrierSetAssembler_x86.cpp +++ b/src/hotspot/cpu/x86/gc/shenandoah/shenandoahBarrierSetAssembler_x86.cpp @@ -247,16 +247,16 @@ __ bind(done); } -void ShenandoahBarrierSetAssembler::resolve_forward_pointer(MacroAssembler* masm, Register dst, Register tmp) { +void ShenandoahBarrierSetAssembler::resolve_forward_pointer(MacroAssembler* masm, Register dst) { assert(ShenandoahCASBarrier, "should be enabled"); Label is_null; __ testptr(dst, dst); __ jcc(Assembler::zero, is_null); - resolve_forward_pointer_not_null(masm, dst, tmp); + resolve_forward_pointer_not_null(masm, dst); __ bind(is_null); } -void ShenandoahBarrierSetAssembler::resolve_forward_pointer_not_null(MacroAssembler* masm, Register dst, Register tmp) { +void ShenandoahBarrierSetAssembler::resolve_forward_pointer_not_null(MacroAssembler* masm, Register dst) { assert(ShenandoahCASBarrier || ShenandoahLoadRefBarrier, "should be enabled"); // The below loads the mark word, checks if the lowest two bits are // set, and if so, clear the lowest two bits and copy the result @@ -267,12 +267,15 @@ // - If so, set the lowest two bits // - Invert the result back, and copy to dst - bool borrow_reg = (tmp == noreg); - if (borrow_reg) { - // No free registers available. Make one useful. - tmp = LP64_ONLY(rscratch1) NOT_LP64(rdx); - __ push(tmp); + // No free registers available. Make one useful. + Register tmp = rscratch1; + tmp = LP64_ONLY(rscratch1) NOT_LP64(rdx); + if (tmp == dst) { + tmp = LP64_ONLY(rscratch2) NOT_LP64(rcx); } + __ push(tmp); + + assert_different_registers(dst, tmp); Label done; __ movptr(tmp, Address(dst, oopDesc::mark_offset_in_bytes())); @@ -284,9 +287,7 @@ __ mov(dst, tmp); __ bind(done); - if (borrow_reg) { - __ pop(tmp); - } + __ pop(tmp); } diff --git a/src/hotspot/cpu/x86/gc/shenandoah/shenandoahBarrierSetAssembler_x86.hpp b/src/hotspot/cpu/x86/gc/shenandoah/shenandoahBarrierSetAssembler_x86.hpp --- a/src/hotspot/cpu/x86/gc/shenandoah/shenandoahBarrierSetAssembler_x86.hpp +++ b/src/hotspot/cpu/x86/gc/shenandoah/shenandoahBarrierSetAssembler_x86.hpp @@ -55,8 +55,8 @@ bool tosca_live, bool expand_call); - void resolve_forward_pointer(MacroAssembler* masm, Register dst, Register tmp = noreg); - void resolve_forward_pointer_not_null(MacroAssembler* masm, Register dst, Register tmp = noreg); + void resolve_forward_pointer(MacroAssembler* masm, Register dst); + void resolve_forward_pointer_not_null(MacroAssembler* masm, Register dst); void load_reference_barrier_not_null(MacroAssembler* masm, Register dst);