< prev index next >

src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp

Print this page


   1 /*
   2  * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * Copyright (c) 2014, 2015, Red Hat Inc. All rights reserved.
   4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   5  *
   6  * This code is free software; you can redistribute it and/or modify it
   7  * under the terms of the GNU General Public License version 2 only, as
   8  * published by the Free Software Foundation.
   9  *
  10  * This code is distributed in the hope that it will be useful, but WITHOUT
  11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  13  * version 2 for more details (a copy is included in the LICENSE file that
  14  * accompanied this code).
  15  *
  16  * You should have received a copy of the GNU General Public License version
  17  * 2 along with this work; if not, write to the Free Software Foundation,
  18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  19  *
  20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  21  * or visit www.oracle.com if you need additional information or have any
  22  * questions.
  23  *


2573   // printf("start = %lx\n", start);
2574   int byteCount =  aarch64_stub_prolog_size();
2575   // printf("byteCount = %x\n", byteCount);
2576   int instructionCount = (byteCount + 3)/ 4;
2577   // printf("instructionCount = %x\n", instructionCount);
2578   for (int i = 0; i < instructionCount; i++) {
2579     nop();
2580   }
2581 
2582   memcpy(start, (void*)aarch64_stub_prolog, byteCount);
2583 
2584   // write the address of the setup routine and the call format at the
2585   // end of into the copied code
2586   u_int64_t *patch_end = (u_int64_t *)(start + byteCount);
2587   if (prolog_ptr)
2588     patch_end[-2] = (u_int64_t)prolog_ptr;
2589   patch_end[-1] = calltype;
2590 }
2591 #endif
2592 
2593 void MacroAssembler::push_call_clobbered_registers() {
2594   int step = 4 * wordSize;
2595   push(RegSet::range(r0, r18) - RegSet::of(rscratch1, rscratch2), sp);
2596   sub(sp, sp, step);
2597   mov(rscratch1, -step);
2598   // Push v0-v7, v16-v31.
2599   for (int i = 31; i>= 4; i -= 4) {
2600     if (i <= v7->encoding() || i >= v16->encoding())
2601       st1(as_FloatRegister(i-3), as_FloatRegister(i-2), as_FloatRegister(i-1),
2602           as_FloatRegister(i), T1D, Address(post(sp, rscratch1)));
2603   }
2604   st1(as_FloatRegister(0), as_FloatRegister(1), as_FloatRegister(2),
2605       as_FloatRegister(3), T1D, Address(sp));
2606 }
2607 
2608 void MacroAssembler::pop_call_clobbered_registers() {
2609   for (int i = 0; i < 32; i += 4) {
2610     if (i <= v7->encoding() || i >= v16->encoding())
2611       ld1(as_FloatRegister(i), as_FloatRegister(i+1), as_FloatRegister(i+2),
2612           as_FloatRegister(i+3), T1D, Address(post(sp, 4 * wordSize)));
2613   }






2614 


2615   pop(RegSet::range(r0, r18) - RegSet::of(rscratch1, rscratch2), sp);
2616 }
2617 
2618 void MacroAssembler::push_CPU_state(bool save_vectors) {
2619   int step = (save_vectors ? 8 : 4) * wordSize;
2620   push(0x3fffffff, sp);         // integer registers except lr & sp
2621   mov(rscratch1, -step);
2622   sub(sp, sp, step);
2623   for (int i = 28; i >= 4; i -= 4) {
2624     st1(as_FloatRegister(i), as_FloatRegister(i+1), as_FloatRegister(i+2),
2625         as_FloatRegister(i+3), save_vectors ? T2D : T1D, Address(post(sp, rscratch1)));
2626   }
2627   st1(v0, v1, v2, v3, save_vectors ? T2D : T1D, sp);
2628 }
2629 
2630 void MacroAssembler::pop_CPU_state(bool restore_vectors) {
2631   int step = (restore_vectors ? 8 : 4) * wordSize;
2632   for (int i = 0; i <= 28; i += 4)
2633     ld1(as_FloatRegister(i), as_FloatRegister(i+1), as_FloatRegister(i+2),
2634         as_FloatRegister(i+3), restore_vectors ? T2D : T1D, Address(post(sp, step)));


3977   int oop_index = oop_recorder()->find_index(obj);
3978   InstructionMark im(this);
3979   RelocationHolder rspec = oop_Relocation::spec(oop_index);
3980   code_section()->relocate(inst_mark(), rspec);
3981   movz(dst, 0xDEAD, 16);
3982   movk(dst, 0xBEEF);
3983 }
3984 
3985 void  MacroAssembler::set_narrow_klass(Register dst, Klass* k) {
3986   assert (UseCompressedClassPointers, "should only be used for compressed headers");
3987   assert (oop_recorder() != NULL, "this assembler needs an OopRecorder");
3988   int index = oop_recorder()->find_index(k);
3989   assert(! Universe::heap()->is_in_reserved(k), "should not be an oop");
3990 
3991   InstructionMark im(this);
3992   RelocationHolder rspec = metadata_Relocation::spec(index);
3993   code_section()->relocate(inst_mark(), rspec);
3994   narrowKlass nk = Klass::encode_klass(k);
3995   movz(dst, (nk >> 16), 16);
3996   movk(dst, nk & 0xffff);










3997 }
3998 
3999 void MacroAssembler::access_load_at(BasicType type, DecoratorSet decorators,
4000                                     Register dst, Address src,
4001                                     Register tmp1, Register thread_tmp) {
4002   BarrierSetAssembler *bs = BarrierSet::barrier_set()->barrier_set_assembler();
4003   decorators = AccessInternal::decorator_fixup(decorators);
4004   bool as_raw = (decorators & AS_RAW) != 0;
4005   if (as_raw) {
4006     bs->BarrierSetAssembler::load_at(this, decorators, type, dst, src, tmp1, thread_tmp);
4007   } else {
4008     bs->load_at(this, decorators, type, dst, src, tmp1, thread_tmp);
4009   }
4010 }
4011 
4012 void MacroAssembler::access_store_at(BasicType type, DecoratorSet decorators,
4013                                      Address dst, Register src,
4014                                      Register tmp1, Register thread_tmp) {
4015   BarrierSetAssembler *bs = BarrierSet::barrier_set()->barrier_set_assembler();
4016   decorators = AccessInternal::decorator_fixup(decorators);


   1 /*
   2  * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * Copyright (c) 2014, 2018, Red Hat, Inc. All rights reserved.
   4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   5  *
   6  * This code is free software; you can redistribute it and/or modify it
   7  * under the terms of the GNU General Public License version 2 only, as
   8  * published by the Free Software Foundation.
   9  *
  10  * This code is distributed in the hope that it will be useful, but WITHOUT
  11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  13  * version 2 for more details (a copy is included in the LICENSE file that
  14  * accompanied this code).
  15  *
  16  * You should have received a copy of the GNU General Public License version
  17  * 2 along with this work; if not, write to the Free Software Foundation,
  18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  19  *
  20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  21  * or visit www.oracle.com if you need additional information or have any
  22  * questions.
  23  *


2573   // printf("start = %lx\n", start);
2574   int byteCount =  aarch64_stub_prolog_size();
2575   // printf("byteCount = %x\n", byteCount);
2576   int instructionCount = (byteCount + 3)/ 4;
2577   // printf("instructionCount = %x\n", instructionCount);
2578   for (int i = 0; i < instructionCount; i++) {
2579     nop();
2580   }
2581 
2582   memcpy(start, (void*)aarch64_stub_prolog, byteCount);
2583 
2584   // write the address of the setup routine and the call format at the
2585   // end of into the copied code
2586   u_int64_t *patch_end = (u_int64_t *)(start + byteCount);
2587   if (prolog_ptr)
2588     patch_end[-2] = (u_int64_t)prolog_ptr;
2589   patch_end[-1] = calltype;
2590 }
2591 #endif
2592 
2593 void MacroAssembler::push_call_clobbered_fp_registers() {
2594   int step = 4 * wordSize;

2595   sub(sp, sp, step);
2596   mov(rscratch1, -step);
2597   // Push v0-v7, v16-v31.
2598   for (int i = 31; i>= 4; i -= 4) {
2599     if (i <= v7->encoding() || i >= v16->encoding())
2600       st1(as_FloatRegister(i-3), as_FloatRegister(i-2), as_FloatRegister(i-1),
2601           as_FloatRegister(i), T1D, Address(post(sp, rscratch1)));
2602   }
2603   st1(as_FloatRegister(0), as_FloatRegister(1), as_FloatRegister(2),
2604       as_FloatRegister(3), T1D, Address(sp));
2605 }
2606 
2607 void MacroAssembler::pop_call_clobbered_fp_registers() {
2608   for (int i = 0; i < 32; i += 4) {
2609     if (i <= v7->encoding() || i >= v16->encoding())
2610       ld1(as_FloatRegister(i), as_FloatRegister(i+1), as_FloatRegister(i+2),
2611           as_FloatRegister(i+3), T1D, Address(post(sp, 4 * wordSize)));
2612   }
2613 }
2614 
2615 void MacroAssembler::push_call_clobbered_registers() {
2616   push(RegSet::range(r0, r18) - RegSet::of(rscratch1, rscratch2), sp);
2617   push_call_clobbered_fp_registers();
2618 }
2619 
2620 void MacroAssembler::pop_call_clobbered_registers() {
2621   pop_call_clobbered_fp_registers();
2622   pop(RegSet::range(r0, r18) - RegSet::of(rscratch1, rscratch2), sp);
2623 }
2624 
2625 void MacroAssembler::push_CPU_state(bool save_vectors) {
2626   int step = (save_vectors ? 8 : 4) * wordSize;
2627   push(0x3fffffff, sp);         // integer registers except lr & sp
2628   mov(rscratch1, -step);
2629   sub(sp, sp, step);
2630   for (int i = 28; i >= 4; i -= 4) {
2631     st1(as_FloatRegister(i), as_FloatRegister(i+1), as_FloatRegister(i+2),
2632         as_FloatRegister(i+3), save_vectors ? T2D : T1D, Address(post(sp, rscratch1)));
2633   }
2634   st1(v0, v1, v2, v3, save_vectors ? T2D : T1D, sp);
2635 }
2636 
2637 void MacroAssembler::pop_CPU_state(bool restore_vectors) {
2638   int step = (restore_vectors ? 8 : 4) * wordSize;
2639   for (int i = 0; i <= 28; i += 4)
2640     ld1(as_FloatRegister(i), as_FloatRegister(i+1), as_FloatRegister(i+2),
2641         as_FloatRegister(i+3), restore_vectors ? T2D : T1D, Address(post(sp, step)));


3984   int oop_index = oop_recorder()->find_index(obj);
3985   InstructionMark im(this);
3986   RelocationHolder rspec = oop_Relocation::spec(oop_index);
3987   code_section()->relocate(inst_mark(), rspec);
3988   movz(dst, 0xDEAD, 16);
3989   movk(dst, 0xBEEF);
3990 }
3991 
3992 void  MacroAssembler::set_narrow_klass(Register dst, Klass* k) {
3993   assert (UseCompressedClassPointers, "should only be used for compressed headers");
3994   assert (oop_recorder() != NULL, "this assembler needs an OopRecorder");
3995   int index = oop_recorder()->find_index(k);
3996   assert(! Universe::heap()->is_in_reserved(k), "should not be an oop");
3997 
3998   InstructionMark im(this);
3999   RelocationHolder rspec = metadata_Relocation::spec(index);
4000   code_section()->relocate(inst_mark(), rspec);
4001   narrowKlass nk = Klass::encode_klass(k);
4002   movz(dst, (nk >> 16), 16);
4003   movk(dst, nk & 0xffff);
4004 }
4005 
4006 void MacroAssembler::resolve_for_read(DecoratorSet decorators, Register obj) {
4007   BarrierSetAssembler* bs = BarrierSet::barrier_set()->barrier_set_assembler();
4008   bs->resolve_for_read(this, decorators, obj);
4009 }
4010 
4011 void MacroAssembler::resolve_for_write(DecoratorSet decorators, Register obj) {
4012   BarrierSetAssembler* bs = BarrierSet::barrier_set()->barrier_set_assembler();
4013   bs->resolve_for_write(this, decorators, obj);
4014 }
4015 
4016 void MacroAssembler::access_load_at(BasicType type, DecoratorSet decorators,
4017                                     Register dst, Address src,
4018                                     Register tmp1, Register thread_tmp) {
4019   BarrierSetAssembler *bs = BarrierSet::barrier_set()->barrier_set_assembler();
4020   decorators = AccessInternal::decorator_fixup(decorators);
4021   bool as_raw = (decorators & AS_RAW) != 0;
4022   if (as_raw) {
4023     bs->BarrierSetAssembler::load_at(this, decorators, type, dst, src, tmp1, thread_tmp);
4024   } else {
4025     bs->load_at(this, decorators, type, dst, src, tmp1, thread_tmp);
4026   }
4027 }
4028 
4029 void MacroAssembler::access_store_at(BasicType type, DecoratorSet decorators,
4030                                      Address dst, Register src,
4031                                      Register tmp1, Register thread_tmp) {
4032   BarrierSetAssembler *bs = BarrierSet::barrier_set()->barrier_set_assembler();
4033   decorators = AccessInternal::decorator_fixup(decorators);


< prev index next >