< prev index next >

src/hotspot/cpu/aarch64/gc/shenandoah/shenandoahBarrierSetAssembler_aarch64.cpp

Print this page
rev 50905 : Move Shenandoah stubs generation into ShenandoahBarrierSetAssembler
rev 50906 : [mq]: stubgen-v2.patch


   8  * This code is distributed in the hope that it will be useful, but WITHOUT
   9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  11  * version 2 for more details (a copy is included in the LICENSE file that
  12  * accompanied this code).
  13  *
  14  * You should have received a copy of the GNU General Public License version
  15  * 2 along with this work; if not, write to the Free Software Foundation,
  16  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  17  *
  18  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  19  * or visit www.oracle.com if you need additional information or have any
  20  * questions.
  21  *
  22  */
  23 
  24 #include "precompiled.hpp"
  25 #include "gc/shenandoah/brooksPointer.hpp"
  26 #include "gc/shenandoah/shenandoahBarrierSetAssembler.hpp"
  27 #include "gc/shenandoah/shenandoahConnectionMatrix.hpp"

  28 #include "gc/shenandoah/shenandoahHeapRegion.hpp"
  29 #include "gc/shenandoah/shenandoahRuntime.hpp"
  30 #include "gc/shenandoah/shenandoahThreadLocalData.hpp"
  31 #include "interpreter/interpreter.hpp"
  32 #include "interpreter/interp_masm.hpp"
  33 #include "runtime/sharedRuntime.hpp"
  34 #include "runtime/thread.hpp"
  35 #ifdef COMPILER1
  36 #include "c1/c1_LIRAssembler.hpp"
  37 #include "c1/c1_MacroAssembler.hpp"
  38 #include "gc/shenandoah/c1/shenandoahBarrierSetC1.hpp"
  39 #endif
  40 
  41 #define __ masm->
  42 



  43 void ShenandoahBarrierSetAssembler::arraycopy_prologue(MacroAssembler* masm, DecoratorSet decorators, bool is_oop,
  44                                                        Register addr, Register count, RegSet saved_regs) {
  45   if (is_oop) {
  46     bool dest_uninitialized = (decorators & AS_DEST_NOT_INITIALIZED) != 0;
  47     if (!dest_uninitialized) {
  48       __ push(saved_regs, sp);
  49       if (count == c_rarg0) {
  50         if (addr == c_rarg1) {
  51           // exactly backwards!!
  52           __ mov(rscratch1, c_rarg0);
  53           __ mov(c_rarg0, c_rarg1);
  54           __ mov(c_rarg1, rscratch1);
  55         } else {
  56           __ mov(c_rarg1, count);
  57           __ mov(c_rarg0, addr);
  58         }
  59       } else {
  60         __ mov(c_rarg0, addr);
  61         __ mov(c_rarg1, count);
  62       }


 557   __ str(tmp, queue_index);
 558   __ ldr(rscratch2, buffer);
 559   __ add(tmp, tmp, rscratch2);
 560   __ load_parameter(0, rscratch2);
 561   __ str(rscratch2, Address(tmp, 0));
 562   __ b(done);
 563 
 564   __ bind(runtime);
 565   __ push_call_clobbered_registers();
 566   __ load_parameter(0, pre_val);
 567   __ call_VM_leaf(CAST_FROM_FN_PTR(address, ShenandoahRuntime::write_ref_field_pre_entry), pre_val, thread);
 568   __ pop_call_clobbered_registers();
 569   __ bind(done);
 570 
 571   __ epilogue();
 572 }
 573 
 574 #undef __
 575 
 576 #endif // COMPILER1















































































   8  * This code is distributed in the hope that it will be useful, but WITHOUT
   9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  11  * version 2 for more details (a copy is included in the LICENSE file that
  12  * accompanied this code).
  13  *
  14  * You should have received a copy of the GNU General Public License version
  15  * 2 along with this work; if not, write to the Free Software Foundation,
  16  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  17  *
  18  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  19  * or visit www.oracle.com if you need additional information or have any
  20  * questions.
  21  *
  22  */
  23 
  24 #include "precompiled.hpp"
  25 #include "gc/shenandoah/brooksPointer.hpp"
  26 #include "gc/shenandoah/shenandoahBarrierSetAssembler.hpp"
  27 #include "gc/shenandoah/shenandoahConnectionMatrix.hpp"
  28 #include "gc/shenandoah/shenandoahHeap.hpp"
  29 #include "gc/shenandoah/shenandoahHeapRegion.hpp"
  30 #include "gc/shenandoah/shenandoahRuntime.hpp"
  31 #include "gc/shenandoah/shenandoahThreadLocalData.hpp"
  32 #include "interpreter/interpreter.hpp"
  33 #include "interpreter/interp_masm.hpp"
  34 #include "runtime/sharedRuntime.hpp"
  35 #include "runtime/thread.hpp"
  36 #ifdef COMPILER1
  37 #include "c1/c1_LIRAssembler.hpp"
  38 #include "c1/c1_MacroAssembler.hpp"
  39 #include "gc/shenandoah/c1/shenandoahBarrierSetC1.hpp"
  40 #endif
  41 
  42 #define __ masm->
  43 
  44 address ShenandoahBarrierSetAssembler::_shenandoah_wb = NULL;
  45 address ShenandoahBarrierSetAssembler::_shenandoah_wb_C = NULL;
  46 
  47 void ShenandoahBarrierSetAssembler::arraycopy_prologue(MacroAssembler* masm, DecoratorSet decorators, bool is_oop,
  48                                                        Register addr, Register count, RegSet saved_regs) {
  49   if (is_oop) {
  50     bool dest_uninitialized = (decorators & AS_DEST_NOT_INITIALIZED) != 0;
  51     if (!dest_uninitialized) {
  52       __ push(saved_regs, sp);
  53       if (count == c_rarg0) {
  54         if (addr == c_rarg1) {
  55           // exactly backwards!!
  56           __ mov(rscratch1, c_rarg0);
  57           __ mov(c_rarg0, c_rarg1);
  58           __ mov(c_rarg1, rscratch1);
  59         } else {
  60           __ mov(c_rarg1, count);
  61           __ mov(c_rarg0, addr);
  62         }
  63       } else {
  64         __ mov(c_rarg0, addr);
  65         __ mov(c_rarg1, count);
  66       }


 561   __ str(tmp, queue_index);
 562   __ ldr(rscratch2, buffer);
 563   __ add(tmp, tmp, rscratch2);
 564   __ load_parameter(0, rscratch2);
 565   __ str(rscratch2, Address(tmp, 0));
 566   __ b(done);
 567 
 568   __ bind(runtime);
 569   __ push_call_clobbered_registers();
 570   __ load_parameter(0, pre_val);
 571   __ call_VM_leaf(CAST_FROM_FN_PTR(address, ShenandoahRuntime::write_ref_field_pre_entry), pre_val, thread);
 572   __ pop_call_clobbered_registers();
 573   __ bind(done);
 574 
 575   __ epilogue();
 576 }
 577 
 578 #undef __
 579 
 580 #endif // COMPILER1
 581 
 582 address ShenandoahBarrierSetAssembler::shenandoah_wb() {
 583   assert(_shenandoah_wb != NULL || !(ShenandoahWriteBarrier || ShenandoahStoreValEnqueueBarrier), "need write barrier stub");
 584   return _shenandoah_wb;
 585 }
 586 
 587 address ShenandoahBarrierSetAssembler::shenandoah_wb_C() {
 588   assert(_shenandoah_wb_C != NULL || !(ShenandoahWriteBarrier || ShenandoahStoreValEnqueueBarrier), "need write barrier stub");
 589   return _shenandoah_wb_C;
 590 }
 591 
 592 #define __ cgen->assembler()->
 593 
 594 // Shenandoah write barrier.
 595 //
 596 // Input:
 597 //   r0: OOP to evacuate.  Not null.
 598 //
 599 // Output:
 600 //   r0: Pointer to evacuated OOP.
 601 //
 602 // Trash rscratch1, rscratch2.  Preserve everything else.
 603 address ShenandoahBarrierSetAssembler::generate_shenandoah_wb(StubCodeGenerator* cgen, bool c_abi, bool do_cset_test) {
 604 
 605   __ align(6);
 606   StubCodeMark mark(cgen, "StubRoutines", "shenandoah_wb");
 607   address start = __ pc();
 608 
 609   if (do_cset_test) {
 610     Label work;
 611     __ mov(rscratch2, ShenandoahHeap::in_cset_fast_test_addr());
 612     __ lsr(rscratch1, r0, ShenandoahHeapRegion::region_size_bytes_shift_jint());
 613     __ ldrb(rscratch2, Address(rscratch2, rscratch1));
 614     __ tbnz(rscratch2, 0, work);
 615     __ ret(lr);
 616     __ bind(work);
 617   }
 618 
 619   Register obj = r0;
 620 
 621   __ enter(); // required for proper stackwalking of RuntimeStub frame
 622 
 623   if (!c_abi) {
 624     __ push_call_clobbered_registers();
 625   } else {
 626     __ push_call_clobbered_fp_registers();
 627   }
 628 
 629   __ mov(lr, CAST_FROM_FN_PTR(address, ShenandoahRuntime::write_barrier_JRT));
 630   __ blrt(lr, 1, 0, MacroAssembler::ret_type_integral);
 631   if (!c_abi) {
 632     __ mov(rscratch1, obj);
 633     __ pop_call_clobbered_registers();
 634     __ mov(obj, rscratch1);
 635   } else {
 636     __ pop_call_clobbered_fp_registers();
 637   }
 638 
 639   __ leave(); // required for proper stackwalking of RuntimeStub frame
 640   __ ret(lr);
 641 
 642   return start;
 643 }
 644 
 645 #undef __
 646 
 647 void ShenandoahBarrierSetAssembler::barrier_stubs_init() {
 648   if (ShenandoahWriteBarrier || ShenandoahStoreValEnqueueBarrier) {
 649     int stub_code_size = 2048;
 650     ResourceMark rm;
 651     BufferBlob* bb = BufferBlob::create("shenandoah_barrier_stubs", stub_code_size);
 652     CodeBuffer buf(bb);
 653     StubCodeGenerator cgen(&buf);
 654     _shenandoah_wb = generate_shenandoah_wb(&cgen, false, true);
 655     _shenandoah_wb_C = generate_shenandoah_wb(&cgen, true, !ShenandoahWriteBarrierCsetTestInIR);
 656   }
 657 }
< prev index next >