< prev index next >

src/hotspot/cpu/aarch64/c1_MacroAssembler_aarch64.cpp

Print this page
@@ -26,10 +26,12 @@
  #include "precompiled.hpp"
  #include "c1/c1_MacroAssembler.hpp"
  #include "c1/c1_Runtime1.hpp"
  #include "gc/shared/barrierSetAssembler.hpp"
  #include "gc/shared/collectedHeap.hpp"
+ #include "gc/shared/barrierSet.hpp"
+ #include "gc/shared/barrierSetAssembler.hpp"
  #include "gc/shared/tlab_globals.hpp"
  #include "interpreter/interpreter.hpp"
  #include "oops/arrayOop.hpp"
  #include "oops/markWord.hpp"
  #include "runtime/basicLock.hpp"

@@ -86,10 +88,16 @@
      lightweight_lock(obj, hdr, temp, rscratch2, slow_case);
    } else if (LockingMode == LM_LEGACY) {
      Label done;
      // and mark it as unlocked
      orr(hdr, hdr, markWord::unlocked_value);
+ 
+     if (EnableValhalla) {
+       // Mask always_locked bit such that we go to the slow path if object is an inline type
+       andr(hdr, hdr, ~markWord::inline_type_bit_in_place);
+     }
+ 
      // save unlocked object header into the displaced header location on the stack
      str(hdr, Address(disp_hdr, 0));
      // test if object header is still the same (i.e. unlocked), and if so, store the
      // displaced header address in the object header - if it is not the same, get the
      // object header instead

@@ -178,12 +186,18 @@
    }
  }
  
  void C1_MacroAssembler::initialize_header(Register obj, Register klass, Register len, Register t1, Register t2) {
    assert_different_registers(obj, klass, len);
-   // This assumes that all prototype bits fit in an int32_t
-   mov(t1, (int32_t)(intptr_t)markWord::prototype().value());
+   if (EnableValhalla) {
+     // Need to copy markWord::prototype header for klass
+     assert_different_registers(obj, klass, len, t1, t2);
+     ldr(t1, Address(klass, Klass::prototype_header_offset()));
+   } else {
+     // This assumes that all prototype bits fit in an int32_t
+     mov(t1, (int32_t)(intptr_t)markWord::prototype().value());
+   }
    str(t1, Address(obj, oopDesc::mark_offset_in_bytes()));
  
    if (UseCompressedClassPointers) { // Take care not to kill klass
      encode_klass_not_null(t1, klass);
      strw(t1, Address(obj, oopDesc::klass_offset_in_bytes()));

@@ -269,10 +283,11 @@
      far_call(RuntimeAddress(Runtime1::entry_for(Runtime1::dtrace_object_alloc_id)));
    }
  
    verify_oop(obj);
  }
+ 
  void C1_MacroAssembler::allocate_array(Register obj, Register len, Register t1, Register t2, int header_size, int f, Register klass, Label& slow_case) {
    assert_different_registers(obj, len, t1, t2, klass);
  
    // determine alignment mask
    assert(!(BytesPerWord & 1), "must be a multiple of 2 for masking code to work");

@@ -316,36 +331,111 @@
    assert(!MacroAssembler::needs_explicit_null_check(oopDesc::klass_offset_in_bytes()), "must add explicit null check");
  
    cmp_klass(receiver, iCache, rscratch1);
  }
  
+ void C1_MacroAssembler::build_frame_helper(int frame_size_in_bytes, int sp_offset_for_orig_pc, int sp_inc, bool reset_orig_pc, bool needs_stack_repair) {
+   MacroAssembler::build_frame(frame_size_in_bytes);
+ 
+   if (needs_stack_repair) {
+     save_stack_increment(sp_inc, frame_size_in_bytes);
+   }
+   if (reset_orig_pc) {
+     // Zero orig_pc to detect deoptimization during buffering in the entry points
+     str(zr, Address(sp, sp_offset_for_orig_pc));
+   }
+ }
  
- void C1_MacroAssembler::build_frame(int framesize, int bang_size_in_bytes) {
-   assert(bang_size_in_bytes >= framesize, "stack bang size incorrect");
+ void C1_MacroAssembler::build_frame(int frame_size_in_bytes, int bang_size_in_bytes, int sp_offset_for_orig_pc, bool needs_stack_repair, bool has_scalarized_args, Label* verified_inline_entry_label) {
    // Make sure there is enough stack space for this method's activation.
    // Note that we do this before creating a frame.
+   assert(bang_size_in_bytes >= frame_size_in_bytes, "stack bang size incorrect");
    generate_stack_overflow_check(bang_size_in_bytes);
-   MacroAssembler::build_frame(framesize);
+ 
+   build_frame_helper(frame_size_in_bytes, sp_offset_for_orig_pc, 0, has_scalarized_args, needs_stack_repair);
  
    // Insert nmethod entry barrier into frame.
    BarrierSetAssembler* bs = BarrierSet::barrier_set()->barrier_set_assembler();
    bs->nmethod_entry_barrier(this, nullptr /* slow_path */, nullptr /* continuation */, nullptr /* guard */);
- }
  
- void C1_MacroAssembler::remove_frame(int framesize) {
-   MacroAssembler::remove_frame(framesize);
+   if (verified_inline_entry_label != nullptr) {
+     // Jump here from the scalarized entry points that already created the frame.
+     bind(*verified_inline_entry_label);
+   }
  }
  
- 
  void C1_MacroAssembler::verified_entry(bool breakAtEntry) {
    // If we have to make this method not-entrant we'll overwrite its
    // first instruction with a jump.  For this action to be legal we
    // must ensure that this first instruction is a B, BL, NOP, BKPT,
    // SVC, HVC, or SMC.  Make it a NOP.
    nop();
+   if (C1Breakpoint) brk(1);
+ }
+ 
+ int C1_MacroAssembler::scalarized_entry(const CompiledEntrySignature* ces, int frame_size_in_bytes, int bang_size_in_bytes, int sp_offset_for_orig_pc, Label& verified_inline_entry_label, bool is_inline_ro_entry) {
+   assert(InlineTypePassFieldsAsArgs, "sanity");
+   // Make sure there is enough stack space for this method's activation.
+   assert(bang_size_in_bytes >= frame_size_in_bytes, "stack bang size incorrect");
+   generate_stack_overflow_check(bang_size_in_bytes);
+ 
+   GrowableArray<SigEntry>* sig    = ces->sig();
+   GrowableArray<SigEntry>* sig_cc = is_inline_ro_entry ? ces->sig_cc_ro() : ces->sig_cc();
+   VMRegPair* regs      = ces->regs();
+   VMRegPair* regs_cc   = is_inline_ro_entry ? ces->regs_cc_ro() : ces->regs_cc();
+   int args_on_stack    = ces->args_on_stack();
+   int args_on_stack_cc = is_inline_ro_entry ? ces->args_on_stack_cc_ro() : ces->args_on_stack_cc();
+ 
+   assert(sig->length() <= sig_cc->length(), "Zero-sized inline class not allowed!");
+   BasicType* sig_bt = NEW_RESOURCE_ARRAY(BasicType, sig_cc->length());
+   int args_passed = sig->length();
+   int args_passed_cc = SigEntry::fill_sig_bt(sig_cc, sig_bt);
+ 
+   // Create a temp frame so we can call into the runtime. It must be properly set up to accommodate GC.
+   build_frame_helper(frame_size_in_bytes, sp_offset_for_orig_pc, 0, true, ces->c1_needs_stack_repair());
+ 
+   // The runtime call might safepoint, make sure nmethod entry barrier is executed
+   BarrierSetAssembler* bs = BarrierSet::barrier_set()->barrier_set_assembler();
+   // C1 code is not hot enough to micro optimize the nmethod entry barrier with an out-of-line stub
+   bs->nmethod_entry_barrier(this, nullptr /* slow_path */, nullptr /* continuation */, nullptr /* guard */);
+ 
+   // FIXME -- call runtime only if we cannot in-line allocate all the incoming inline type args.
+   mov(r19, (intptr_t) ces->method());
+   if (is_inline_ro_entry) {
+     far_call(RuntimeAddress(Runtime1::entry_for(Runtime1::buffer_inline_args_no_receiver_id)));
+   } else {
+     far_call(RuntimeAddress(Runtime1::entry_for(Runtime1::buffer_inline_args_id)));
+   }
+   int rt_call_offset = offset();
+ 
+   // The runtime call returns the new array in r20 instead of the usual r0
+   // because r0 is also j_rarg7 which may be holding a live argument here.
+   Register val_array = r20;
+ 
+   // Remove the temp frame
+   MacroAssembler::remove_frame(frame_size_in_bytes);
+ 
+   // Check if we need to extend the stack for packing
+   int sp_inc = 0;
+   if (args_on_stack > args_on_stack_cc) {
+     sp_inc = extend_stack_for_inline_args(args_on_stack);
+   }
+ 
+   shuffle_inline_args(true, is_inline_ro_entry, sig_cc,
+                       args_passed_cc, args_on_stack_cc, regs_cc, // from
+                       args_passed, args_on_stack, regs,          // to
+                       sp_inc, val_array);
+ 
+   // Create the real frame. Below jump will then skip over the stack banging and frame
+   // setup code in the verified_inline_entry (which has a different real_frame_size).
+   build_frame_helper(frame_size_in_bytes, sp_offset_for_orig_pc, sp_inc, false, ces->c1_needs_stack_repair());
+ 
+   b(verified_inline_entry_label);
+   return rt_call_offset;
  }
  
+ 
  void C1_MacroAssembler::load_parameter(int offset_in_words, Register reg) {
    // rfp, + 0: link
    //     + 1: return address
    //     + 2: argument with offset 0
    //     + 3: argument with offset 1
< prev index next >