< prev index next >

src/hotspot/cpu/x86/c1_MacroAssembler_x86.cpp

Print this page
*** 31,10 ***
--- 31,11 ---
  #include "gc/shared/tlab_globals.hpp"
  #include "interpreter/interpreter.hpp"
  #include "oops/arrayOop.hpp"
  #include "oops/markWord.hpp"
  #include "runtime/basicLock.hpp"
+ #include "runtime/frame.inline.hpp"
  #include "runtime/os.hpp"
  #include "runtime/sharedRuntime.hpp"
  #include "runtime/stubRoutines.hpp"
  
  int C1_MacroAssembler::lock_object(Register hdr, Register obj, Register disp_hdr, Label& slow_case) {

*** 62,10 ***
--- 63,14 ---
  
    // Load object header
    movptr(hdr, Address(obj, hdr_offset));
    // and mark it as unlocked
    orptr(hdr, markWord::unlocked_value);
+   if (EnableValhalla) {
+     // Mask inline_type bit such that we go to the slow path if object is an inline type
+     andptr(hdr, ~((int) markWord::inline_type_bit_in_place));
+   }
    // save unlocked object header into the displaced header location on the stack
    movptr(Address(disp_hdr, 0), hdr);
    // 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

*** 140,12 ***
  
  
  void C1_MacroAssembler::initialize_header(Register obj, Register klass, Register len, Register t1, Register t2) {
    assert_different_registers(obj, klass, len);
    Register tmp_encode_klass = LP64_ONLY(rscratch1) NOT_LP64(noreg);
!   // This assumes that all prototype bits fit in an int32_t
!   movptr(Address(obj, oopDesc::mark_offset_in_bytes ()), (int32_t)(intptr_t)markWord::prototype().value());
  #ifdef _LP64
    if (UseCompressedClassPointers) { // Take care not to kill klass
      movptr(t1, klass);
      encode_klass_not_null(t1, tmp_encode_klass);
      movl(Address(obj, oopDesc::klass_offset_in_bytes()), t1);
--- 145,19 ---
  
  
  void C1_MacroAssembler::initialize_header(Register obj, Register klass, Register len, Register t1, Register t2) {
    assert_different_registers(obj, klass, len);
    Register tmp_encode_klass = LP64_ONLY(rscratch1) NOT_LP64(noreg);
!   if (EnableValhalla) {
!     // Need to copy markWord::prototype header for klass
+     assert_different_registers(obj, klass, len, t1, t2);
+     movptr(t1, Address(klass, Klass::prototype_header_offset()));
+     movptr(Address(obj, oopDesc::mark_offset_in_bytes()), t1);
+   } else {
+     // This assumes that all prototype bits fit in an int32_t
+     movptr(Address(obj, oopDesc::mark_offset_in_bytes ()), (int32_t)(intptr_t)markWord::prototype().value());
+   }
  #ifdef _LP64
    if (UseCompressedClassPointers) { // Take care not to kill klass
      movptr(t1, klass);
      encode_klass_not_null(t1, tmp_encode_klass);
      movl(Address(obj, oopDesc::klass_offset_in_bytes()), t1);

*** 296,43 ***
            RuntimeAddress(SharedRuntime::get_ic_miss_stub()));
    const int ic_cmp_size = LP64_ONLY(10) NOT_LP64(9);
    assert(UseCompressedClassPointers || offset() - start_offset == ic_cmp_size, "check alignment in emit_method_entry");
  }
  
  
! void C1_MacroAssembler::build_frame(int frame_size_in_bytes, int bang_size_in_bytes) {
!   assert(bang_size_in_bytes >= frame_size_in_bytes, "stack bang size incorrect");
    // Make sure there is enough stack space for this method's activation.
    // Note that we do this before doing an enter(). This matches the
    // ordering of C2's stack overflow check / rsp decrement and allows
    // the SharedRuntime stack overflow handling to be consistent
    // between the two compilers.
    generate_stack_overflow_check(bang_size_in_bytes);
  
!   push(rbp);
-   if (PreserveFramePointer) {
-     mov(rbp, rsp);
-   }
- #if !defined(_LP64) && defined(COMPILER2)
-   if (UseSSE < 2 && !CompilerConfig::is_c1_only_no_jvmci()) {
-     // c2 leaves fpu stack dirty. Clean it on entry
-     empty_FPU_stack();
-   }
- #endif // !_LP64 && COMPILER2
-   decrement(rsp, frame_size_in_bytes); // does not emit code for frame_size == 0
  
    BarrierSetAssembler* bs = BarrierSet::barrier_set()->barrier_set_assembler();
    bs->nmethod_entry_barrier(this);
- }
- 
  
! void C1_MacroAssembler::remove_frame(int frame_size_in_bytes) {
!   increment(rsp, frame_size_in_bytes);  // Does not emit code for frame_size == 0
!   pop(rbp);
  }
  
- 
  void C1_MacroAssembler::verified_entry() {
    if (C1Breakpoint || VerifyFPU) {
      // Verified Entry first instruction should be 5 bytes long for correct
      // patching by patch_verified_entry().
      //
--- 308,59 ---
            RuntimeAddress(SharedRuntime::get_ic_miss_stub()));
    const int ic_cmp_size = LP64_ONLY(10) NOT_LP64(9);
    assert(UseCompressedClassPointers || offset() - start_offset == ic_cmp_size, "check alignment in emit_method_entry");
  }
  
+ void C1_MacroAssembler::build_frame_helper(int frame_size_in_bytes, int sp_inc, bool needs_stack_repair) {
+   push(rbp);
+   if (PreserveFramePointer) {
+     mov(rbp, rsp);
+   }
+ #if !defined(_LP64) && defined(COMPILER2)
+   if (UseSSE < 2 && !CompilerConfig::is_c1_only_no_jvmci()) {
+       // c2 leaves fpu stack dirty. Clean it on entry
+       empty_FPU_stack();
+     }
+ #endif // !_LP64 && COMPILER2
+   decrement(rsp, frame_size_in_bytes);
  
!   if (needs_stack_repair) {
!     // Save stack increment (also account for fixed framesize and rbp)
+     assert((sp_inc & (StackAlignmentInBytes-1)) == 0, "stack increment not aligned");
+     int real_frame_size = sp_inc + frame_size_in_bytes + wordSize;
+     movptr(Address(rsp, frame_size_in_bytes - wordSize), real_frame_size);
+   }
+ }
+ 
+ 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) {
+   if (has_scalarized_args) {
+     // Initialize orig_pc to detect deoptimization during buffering in the entry points
+     movptr(Address(rsp, sp_offset_for_orig_pc - frame_size_in_bytes - wordSize), 0);
+   }
+   if (!needs_stack_repair && verified_inline_entry_label != NULL) {
+     bind(*verified_inline_entry_label);
+   }
    // Make sure there is enough stack space for this method's activation.
    // Note that we do this before doing an enter(). This matches the
    // ordering of C2's stack overflow check / rsp decrement and allows
    // the SharedRuntime stack overflow handling to be consistent
    // between the two compilers.
+   assert(bang_size_in_bytes >= frame_size_in_bytes, "stack bang size incorrect");
    generate_stack_overflow_check(bang_size_in_bytes);
  
!   build_frame_helper(frame_size_in_bytes, 0, needs_stack_repair);
  
    BarrierSetAssembler* bs = BarrierSet::barrier_set()->barrier_set_assembler();
    bs->nmethod_entry_barrier(this);
  
!   if (needs_stack_repair && verified_inline_entry_label != NULL) {
!     // Jump here from the scalarized entry points that require additional stack space
!     // for packing scalarized arguments and therefore already created the frame.
+     bind(*verified_inline_entry_label);
+   }
  }
  
  void C1_MacroAssembler::verified_entry() {
    if (C1Breakpoint || VerifyFPU) {
      // Verified Entry first instruction should be 5 bytes long for correct
      // patching by patch_verified_entry().
      //

*** 345,10 ***
--- 373,72 ---
    if (C1Breakpoint)int3();
    // build frame
    IA32_ONLY( verify_FPU(0, "method_entry"); )
  }
  
+ 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);
+ 
+   // 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);
+   }
+ 
+   // 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_inc, ces->c1_needs_stack_repair());
+ 
+   // Initialize orig_pc to detect deoptimization during buffering in below runtime call
+   movptr(Address(rsp, sp_offset_for_orig_pc), 0);
+ 
+   // The runtime call might safepoint, make sure nmethod entry barrier is executed
+   BarrierSetAssembler* bs = BarrierSet::barrier_set()->barrier_set_assembler();
+   bs->nmethod_entry_barrier(this);
+ 
+   // FIXME -- call runtime only if we cannot in-line allocate all the incoming inline type args.
+   movptr(rbx, (intptr_t)(ces->method()));
+   if (is_inline_ro_entry) {
+     call(RuntimeAddress(Runtime1::entry_for(Runtime1::buffer_inline_args_no_receiver_id)));
+   } else {
+     call(RuntimeAddress(Runtime1::entry_for(Runtime1::buffer_inline_args_id)));
+   }
+   int rt_call_offset = offset();
+ 
+   // Remove the temp frame
+   addptr(rsp, frame_size_in_bytes);
+   pop(rbp);
+ 
+   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, rax);
+ 
+   if (ces->c1_needs_stack_repair()) {
+     // 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_inc, true);
+   }
+ 
+   jmp(verified_inline_entry_label);
+   return rt_call_offset;
+ }
+ 
  void C1_MacroAssembler::load_parameter(int offset_in_words, Register reg) {
    // rbp, + 0: link
    //     + 1: return address
    //     + 2: argument with offset 0
    //     + 3: argument with offset 1
< prev index next >