# HG changeset patch # Parent 789ca76047b0de1f9684ca0f0c56cd7af41a5d82 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 @@ -46,6 +46,11 @@ address ShenandoahBarrierSetAssembler::_shenandoah_wb = NULL; address ShenandoahBarrierSetAssembler::_shenandoah_wb_C = NULL; +ShenandoahBarrierSetAssembler* ShenandoahBarrierSetAssembler::barrier_set_assembler() { + ShenandoahBarrierSet* bsa = ShenandoahBarrierSet::barrier_set(); + return reinterpret_cast(bsa->barrier_set_assembler()); +} + void ShenandoahBarrierSetAssembler::arraycopy_prologue(MacroAssembler* masm, DecoratorSet decorators, BasicType type, Register src, Register dst, Register count) { @@ -373,83 +378,34 @@ } void ShenandoahBarrierSetAssembler::write_barrier_impl(MacroAssembler* masm, Register dst) { - assert(UseShenandoahGC && (ShenandoahWriteBarrier || ShenandoahStoreValEnqueueBarrier), "should be enabled"); + assert(UseShenandoahGC && (ShenandoahWriteBarrier || ShenandoahStoreValEnqueueBarrier), "Should be enabled"); #ifdef _LP64 - assert(dst != rscratch1, "different regs"); - Label done; Address gc_state(r15_thread, in_bytes(ShenandoahThreadLocalData::gc_state_offset())); - __ testb(gc_state, ShenandoahHeap::EVACUATION | ShenandoahHeap::TRAVERSAL); - // Now check if evacuation is in progress. - read_barrier_not_null(masm, dst); + // Check for heap stability + __ cmpb(gc_state, 0); + __ jccb(Assembler::zero, done); - __ jcc(Assembler::zero, done); - __ push(rscratch1); - __ push(rscratch2); - - __ movptr(rscratch1, dst); - __ shrptr(rscratch1, ShenandoahHeapRegion::region_size_bytes_shift_jint()); - __ movptr(rscratch2, (intptr_t) ShenandoahHeap::in_cset_fast_test_addr()); - __ movbool(rscratch2, Address(rscratch2, rscratch1, Address::times_1)); - __ testb(rscratch2, 0x1); - - __ pop(rscratch2); - __ pop(rscratch1); - - __ jcc(Assembler::zero, done); - - __ push(rscratch1); - - // Save possibly live regs. - if (dst != rax) { - __ push(rax); - } - if (dst != rbx) { - __ push(rbx); - } - if (dst != rcx) { - __ push(rcx); - } - if (dst != rdx) { - __ push(rdx); - } - if (dst != c_rarg1) { - __ push(c_rarg1); + // Heap is unstable, need to perform the read-barrier even if WB is inactive + if (ShenandoahWriteBarrierRB) { + __ movptr(dst, Address(dst, BrooksPointer::byte_offset())); } - __ subptr(rsp, 2 * Interpreter::stackElementSize); - __ movdbl(Address(rsp, 0), xmm0); + // Check for evacuation-in-progress and jump to WB slow-path if needed + __ testb(gc_state, ShenandoahHeap::EVACUATION | ShenandoahHeap::TRAVERSAL); + __ jccb(Assembler::zero, done); - // Call into runtime - __ super_call_VM_leaf(CAST_FROM_FN_PTR(address, ShenandoahRuntime::write_barrier_IRT), dst); - __ mov(rscratch1, rax); - - // Restore possibly live regs. - __ movdbl(xmm0, Address(rsp, 0)); - __ addptr(rsp, 2 * Interpreter::stackElementSize); - - if (dst != c_rarg1) { - __ pop(c_rarg1); - } - if (dst != rdx) { - __ pop(rdx); - } - if (dst != rcx) { - __ pop(rcx); - } - if (dst != rbx) { - __ pop(rbx); - } if (dst != rax) { - __ pop(rax); + __ xchgptr(dst, rax); // Move obj into rax and save rax into obj. } - // Move result into dst reg. - __ mov(dst, rscratch1); + __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, ShenandoahBarrierSetAssembler::shenandoah_wb()))); - __ pop(rscratch1); + if (dst != rax) { + __ xchgptr(rax, dst); // Swap back obj with rax. + } __ bind(done); #else @@ -861,7 +817,7 @@ __ jcc(Assembler::zero, done); } - __ shenandoah_write_barrier(res); + write_barrier(ce->masm(), res); __ bind(done); __ jmp(*stub->continuation()); 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 @@ -65,7 +65,6 @@ void read_barrier_not_null(MacroAssembler* masm, Register dst); void read_barrier_not_null_impl(MacroAssembler* masm, Register dst); - void write_barrier(MacroAssembler* masm, Register dst); void write_barrier_impl(MacroAssembler* masm, Register dst); void storeval_barrier(MacroAssembler* masm, Register dst, Register tmp); @@ -85,6 +84,10 @@ void generate_c1_pre_barrier_runtime_stub(StubAssembler* sasm); #endif + static ShenandoahBarrierSetAssembler* barrier_set_assembler(); + + void write_barrier(MacroAssembler* masm, Register dst); + virtual void cmpxchg_oop(MacroAssembler* masm, DecoratorSet decorators, Register res, Address addr, Register oldval, Register newval, bool exchange, bool encode, Register tmp1, Register tmp2); diff --git a/src/hotspot/cpu/x86/macroAssembler_x86.cpp b/src/hotspot/cpu/x86/macroAssembler_x86.cpp --- a/src/hotspot/cpu/x86/macroAssembler_x86.cpp +++ b/src/hotspot/cpu/x86/macroAssembler_x86.cpp @@ -5267,48 +5267,6 @@ bind(done); } -#if INCLUDE_SHENANDOAHGC -#ifndef _LP64 -void MacroAssembler::shenandoah_write_barrier(Register dst) { - Unimplemented(); -} -#else -void MacroAssembler::shenandoah_write_barrier(Register dst) { - assert(UseShenandoahGC && (ShenandoahWriteBarrier || ShenandoahStoreValEnqueueBarrier), "Should be enabled"); - - Label done; - - Address gc_state(r15_thread, in_bytes(ShenandoahThreadLocalData::gc_state_offset())); - - // Check for heap stability - cmpb(gc_state, 0); - jccb(Assembler::zero, done); - - // Heap is unstable, need to perform the read-barrier even if WB is inactive - if (ShenandoahWriteBarrierRB) { - movptr(dst, Address(dst, BrooksPointer::byte_offset())); - } - - // Check for evacuation-in-progress and jump to WB slow-path if needed - testb(gc_state, ShenandoahHeap::EVACUATION | ShenandoahHeap::TRAVERSAL); - jccb(Assembler::zero, done); - - if (dst != rax) { - xchgptr(dst, rax); // Move obj into rax and save rax into obj. - } - - call(RuntimeAddress(CAST_FROM_FN_PTR(address, ShenandoahBarrierSetAssembler::shenandoah_wb()))); - - if (dst != rax) { - xchgptr(rax, dst); // Swap back obj with rax. - } - - bind(done); -} -#endif // _LP64 - -#endif // INCLUDE_SHENANDOAHGC - void MacroAssembler::subptr(Register dst, int32_t imm32) { LP64_ONLY(subq(dst, imm32)) NOT_LP64(subl(dst, imm32)); } diff --git a/src/hotspot/cpu/x86/macroAssembler_x86.hpp b/src/hotspot/cpu/x86/macroAssembler_x86.hpp --- a/src/hotspot/cpu/x86/macroAssembler_x86.hpp +++ b/src/hotspot/cpu/x86/macroAssembler_x86.hpp @@ -297,10 +297,6 @@ void clear_jweak_tag(Register possibly_jweak); void resolve_jobject(Register value, Register thread, Register tmp); -#if INCLUDE_SHENANDOAHGC - void shenandoah_write_barrier(Register dst); -#endif - // C 'boolean' to Java boolean: x == 0 ? 0 : 1 void c2bool(Register x); diff --git a/src/hotspot/cpu/x86/x86_64.ad b/src/hotspot/cpu/x86/x86_64.ad --- a/src/hotspot/cpu/x86/x86_64.ad +++ b/src/hotspot/cpu/x86/x86_64.ad @@ -540,7 +540,9 @@ source_hpp %{ +#if INCLUDE_SHENANDOAHGC #include "gc/shenandoah/brooksPointer.hpp" +#endif #if INCLUDE_ZGC #include "gc/z/zBarrierSetAssembler.hpp" diff --git a/src/hotspot/share/gc/shenandoah/shenandoahRuntime.cpp b/src/hotspot/share/gc/shenandoah/shenandoahRuntime.cpp --- a/src/hotspot/share/gc/shenandoah/shenandoahRuntime.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahRuntime.cpp @@ -59,11 +59,6 @@ return (oopDesc*) result; JRT_END -IRT_LEAF(oopDesc*, ShenandoahRuntime::write_barrier_IRT(oopDesc* src)) - oop result = ShenandoahBarrierSet::barrier_set()->write_barrier(src); - return (oopDesc*) result; -IRT_END - // Shenandoah clone barrier: makes sure that references point to to-space // in cloned objects. JRT_LEAF(void, ShenandoahRuntime::shenandoah_clone_barrier(oopDesc* obj)) diff --git a/src/hotspot/share/gc/shenandoah/shenandoahRuntime.hpp b/src/hotspot/share/gc/shenandoah/shenandoahRuntime.hpp --- a/src/hotspot/share/gc/shenandoah/shenandoahRuntime.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahRuntime.hpp @@ -38,7 +38,6 @@ static void write_ref_array_post_entry(HeapWord* dst, size_t length); static void write_ref_field_pre_entry(oopDesc* orig, JavaThread* thread); - static oopDesc* write_barrier_IRT(oopDesc* src); static oopDesc* write_barrier_JRT(oopDesc* src); static void shenandoah_clone_barrier(oopDesc* obj);