< prev index next >

src/hotspot/cpu/x86/gc/shenandoah/shenandoahBarrierSetAssembler_x86.cpp

Print this page
rev 53399 : Redo: Avoid stub when calling to write-barrier from C2, remove all related code
rev 53400 : Improve/trim register saving/restoring around WB slowpath call in stub

@@ -40,11 +40,10 @@
 #endif
 
 #define __ masm->
 
 address ShenandoahBarrierSetAssembler::_shenandoah_wb = NULL;
-address ShenandoahBarrierSetAssembler::_shenandoah_wb_C = NULL;
 
 void ShenandoahBarrierSetAssembler::arraycopy_prologue(MacroAssembler* masm, DecoratorSet decorators, BasicType type,
                                                        Register src, Register dst, Register count) {
 
   bool checkcast = (decorators & ARRAYCOPY_CHECKCAST) != 0;

@@ -952,18 +951,13 @@
 address ShenandoahBarrierSetAssembler::shenandoah_wb() {
   assert(_shenandoah_wb != NULL, "need write barrier stub");
   return _shenandoah_wb;
 }
 
-address ShenandoahBarrierSetAssembler::shenandoah_wb_C() {
-  assert(_shenandoah_wb_C != NULL, "need write barrier stub");
-  return _shenandoah_wb_C;
-}
-
 #define __ cgen->assembler()->
 
-address ShenandoahBarrierSetAssembler::generate_shenandoah_wb(StubCodeGenerator* cgen, bool c_abi, bool do_cset_test) {
+address ShenandoahBarrierSetAssembler::generate_shenandoah_wb(StubCodeGenerator* cgen) {
   __ align(CodeEntryAlignment);
   StubCodeMark mark(cgen, "StubRoutines", "shenandoah_wb");
   address start = __ pc();
 
 #ifdef _LP64

@@ -971,84 +965,69 @@
 
   // We use RDI, which also serves as argument register for slow call.
   // RAX always holds the src object ptr, except after the slow call and
   // the cmpxchg, then it holds the result.
   // R8 and RCX are used as temporary registers.
-  if (!c_abi) {
     __ push(rdi);
     __ push(r8);
-  }
 
   // Check for object beeing in the collection set.
   // TODO: Can we use only 1 register here?
   // The source object arrives here in rax.
   // live: rax
   // live: rdi
-  if (!c_abi) {
     __ mov(rdi, rax);
-  } else {
-    if (rax != c_rarg0) {
-      __ mov(rax, c_rarg0);
-    }
-  }
-  if (do_cset_test) {
     __ shrptr(rdi, ShenandoahHeapRegion::region_size_bytes_shift_jint());
     // live: r8
     __ movptr(r8, (intptr_t) ShenandoahHeap::in_cset_fast_test_addr());
     __ movbool(r8, Address(r8, rdi, Address::times_1));
     // unlive: rdi
     __ testbool(r8);
     // unlive: r8
     __ jccb(Assembler::notZero, not_done);
 
-    if (!c_abi) {
       __ pop(r8);
       __ pop(rdi);
-    }
     __ ret(0);
 
     __ bind(not_done);
-  }
 
-  if (!c_abi) {
-    __ push(rcx);
-  }
+  // Save general purpose registers
+  __ subq(rsp, 6 * wordSize);
+  // Skip rax because it's used for return anyway
+  __ movq(Address(rsp, 5 * wordSize), rcx);
+  __ movq(Address(rsp, 4 * wordSize), rdx);
+  // Skip rbx and rbp because they are callee saved in all calling conventions
+  // skip rsp
+  __ movq(Address(rsp, 3 * wordSize), rsi);
+  // Skip r8 and rdi, we already pushed them above
+  __ movq(Address(rsp, 2 * wordSize), r9);
+  __ movq(Address(rsp, 1 * wordSize), r10);
+  __ movq(Address(rsp, 0 * wordSize), r11);
+  // Skip r12..r15 because they are callee saved in all calling conventions
 
-  if (!c_abi) {
-    __ push(rdx);
-    __ push(rdi);
-    __ push(rsi);
-    __ push(r8);
-    __ push(r9);
-    __ push(r10);
-    __ push(r11);
-    __ push(r12);
-    __ push(r13);
-    __ push(r14);
-    __ push(r15);
-  }
   save_vector_registers(cgen->assembler());
-  __ movptr(rdi, rax);
-  __ call_VM_leaf(CAST_FROM_FN_PTR(address, ShenandoahRuntime::write_barrier_JRT), rdi);
+  __ movptr(c_rarg0, rax);
+  __ call_VM_leaf(CAST_FROM_FN_PTR(address, ShenandoahRuntime::write_barrier_JRT), c_rarg0);
   restore_vector_registers(cgen->assembler());
-  if (!c_abi) {
-    __ pop(r15);
-    __ pop(r14);
-    __ pop(r13);
-    __ pop(r12);
-    __ pop(r11);
-    __ pop(r10);
-    __ pop(r9);
-    __ pop(r8);
-    __ pop(rsi);
-    __ pop(rdi);
-    __ pop(rdx);
 
-    __ pop(rcx);
-    __ pop(r8);
-    __ pop(rdi);
-  }
+  // Restore general purpose registers
+  // Skip r12..r15
+  __ movq(r11, Address(rsp, 0 * wordSize));
+  __ movq(r10, Address(rsp, 1 * wordSize));
+  __ movq(r9,  Address(rsp, 2 * wordSize));
+  // Skip r8 and rdi
+  __ movq(rsi, Address(rsp, 3 * wordSize));
+  // skip rdb, rsp and rbx
+  __ movq(rdx, Address(rsp, 4 * wordSize));
+  __ movq(rcx, Address(rsp, 5 * wordSize));
+
+  // Restore r8 and rdi from outermost pushes
+  __ movq(r8,  Address(rsp, 6 * wordSize));
+  __ movq(rdi, Address(rsp, 7 * wordSize));
+  __ addq(rsp, 8 * wordSize);
+
   __ ret(0);
 #else
   ShouldNotReachHere();
 #endif
   return start;

@@ -1061,9 +1040,8 @@
     int stub_code_size = 4096;
     ResourceMark rm;
     BufferBlob* bb = BufferBlob::create("shenandoah_barrier_stubs", stub_code_size);
     CodeBuffer buf(bb);
     StubCodeGenerator cgen(&buf);
-    _shenandoah_wb = generate_shenandoah_wb(&cgen, false, true);
-    _shenandoah_wb_C = generate_shenandoah_wb(&cgen, true, false);
+    _shenandoah_wb = generate_shenandoah_wb(&cgen);
   }
 }
< prev index next >