< prev index next >

src/hotspot/cpu/x86/stubGenerator_x86_64.cpp

Print this page
@@ -340,25 +340,27 @@
  
      BLOCK_COMMENT("call_stub_return_address:");
      return_address = __ pc();
  
      // store result depending on type (everything that is not
-     // T_OBJECT, T_LONG, T_FLOAT or T_DOUBLE is treated as T_INT)
-     __ movptr(c_rarg0, result);
-     Label is_long, is_float, is_double, exit;
-     __ movl(c_rarg1, result_type);
-     __ cmpl(c_rarg1, T_OBJECT);
+     // T_OBJECT, T_INLINE_TYPE, T_LONG, T_FLOAT or T_DOUBLE is treated as T_INT)
+     __ movptr(r13, result);
+     Label is_long, is_float, is_double, is_value, exit;
+     __ movl(rbx, result_type);
+     __ cmpl(rbx, T_OBJECT);
      __ jcc(Assembler::equal, is_long);
-     __ cmpl(c_rarg1, T_LONG);
+     __ cmpl(rbx, T_INLINE_TYPE);
+     __ jcc(Assembler::equal, is_value);
+     __ cmpl(rbx, T_LONG);
      __ jcc(Assembler::equal, is_long);
-     __ cmpl(c_rarg1, T_FLOAT);
+     __ cmpl(rbx, T_FLOAT);
      __ jcc(Assembler::equal, is_float);
-     __ cmpl(c_rarg1, T_DOUBLE);
+     __ cmpl(rbx, T_DOUBLE);
      __ jcc(Assembler::equal, is_double);
  
      // handle T_INT case
-     __ movl(Address(c_rarg0, 0), rax);
+     __ movl(Address(r13, 0), rax);
  
      __ BIND(exit);
  
      // pop parameters
      __ lea(rsp, rsp_after_call);

@@ -416,20 +418,33 @@
      __ vzeroupper();
      __ pop(rbp);
      __ ret(0);
  
      // handle return types different from T_INT
+     __ BIND(is_value);
+     if (InlineTypeReturnedAsFields) {
+       // Check for flattened return value
+       __ testptr(rax, 1);
+       __ jcc(Assembler::zero, is_long);
+       // Load pack handler address
+       __ andptr(rax, -2);
+       __ movptr(rax, Address(rax, InstanceKlass::adr_inlineklass_fixed_block_offset()));
+       __ movptr(rbx, Address(rax, InlineKlass::pack_handler_jobject_offset()));
+       // Call pack handler to initialize the buffer
+       __ call(rbx);
+       __ jmp(exit);
+     }
      __ BIND(is_long);
-     __ movq(Address(c_rarg0, 0), rax);
+     __ movq(Address(r13, 0), rax);
      __ jmp(exit);
  
      __ BIND(is_float);
-     __ movflt(Address(c_rarg0, 0), xmm0);
+     __ movflt(Address(r13, 0), xmm0);
      __ jmp(exit);
  
      __ BIND(is_double);
-     __ movdbl(Address(c_rarg0, 0), xmm0);
+     __ movdbl(Address(r13, 0), xmm0);
      __ jmp(exit);
  
      return start;
    }
  

@@ -2839,11 +2854,11 @@
      //   for (count = -count; count != 0; count++)
      // Base pointers src, dst are biased by 8*(count-1),to last element.
      __ align(OptoLoopAlignment);
  
      __ BIND(L_store_element);
-     __ store_heap_oop(to_element_addr, rax_oop, noreg, noreg, AS_RAW);  // store the oop
+     __ store_heap_oop(to_element_addr, rax_oop, noreg, noreg, noreg, AS_RAW);  // store the oop
      __ increment(count);               // increment the count toward zero
      __ jcc(Assembler::zero, L_do_card_marks);
  
      // ======== loop entry is here ========
      __ BIND(L_load_element);

@@ -3134,21 +3149,31 @@
      __ jcc(Assembler::notEqual, L_failed);
  
      const Register rax_lh = rax;  // layout helper
      __ movl(rax_lh, Address(r10_src_klass, lh_offset));
  
+     // Check for flat inline type array -> return -1
+     __ testl(rax_lh, Klass::_lh_array_tag_vt_value_bit_inplace);
+     __ jcc(Assembler::notZero, L_failed);
+ 
+     // Check for null-free (non-flat) inline type array -> handle as object array
+     __ testl(rax_lh, Klass::_lh_null_free_bit_inplace);
+     __ jcc(Assembler::notZero, L_objArray);
+ 
      //  if (!src->is_Array()) return -1;
      __ cmpl(rax_lh, Klass::_lh_neutral_value);
      __ jcc(Assembler::greaterEqual, L_failed);
  
      // At this point, it is known to be a typeArray (array_tag 0x3).
  #ifdef ASSERT
      {
        BLOCK_COMMENT("assert primitive array {");
        Label L;
-       __ cmpl(rax_lh, (Klass::_lh_array_tag_type_value << Klass::_lh_array_tag_shift));
-       __ jcc(Assembler::greaterEqual, L);
+       __ movl(rklass_tmp, rax_lh);
+       __ sarl(rklass_tmp, Klass::_lh_array_tag_shift);
+       __ cmpl(rklass_tmp, Klass::_lh_array_tag_type_value);
+       __ jcc(Assembler::equal, L);
        __ stop("must be a primitive array");
        __ bind(L);
        BLOCK_COMMENT("} assert primitive array done");
      }
  #endif

@@ -3252,13 +3277,27 @@
  
    __ BIND(L_checkcast_copy);
      // live at this point:  r10_src_klass, r11_length, rax (dst_klass)
      {
        // Before looking at dst.length, make sure dst is also an objArray.
+       // This check also fails for flat/null-free arrays which are not supported.
        __ cmpl(Address(rax, lh_offset), objArray_lh);
        __ jcc(Assembler::notEqual, L_failed);
  
+ #ifdef ASSERT
+       {
+         BLOCK_COMMENT("assert not null-free array {");
+         Label L;
+         __ movl(rklass_tmp, Address(rax, lh_offset));
+         __ testl(rklass_tmp, Klass::_lh_null_free_bit_inplace);
+         __ jcc(Assembler::zero, L);
+         __ stop("unexpected null-free array");
+         __ bind(L);
+         BLOCK_COMMENT("} assert not null-free array");
+       }
+ #endif
+ 
        // It is safe to examine both src.length and dst.length.
        arraycopy_range_checks(src, src_pos, dst, dst_pos, r11_length,
                               rax, L_failed);
  
        const Register r11_dst_klass = r11;

@@ -7525,10 +7564,150 @@
    void create_control_words() {
      // Round to nearest, 64-bit mode, exceptions masked
      StubRoutines::x86::_mxcsr_std = 0x1F80;
    }
  
+   // Call here from the interpreter or compiled code to either load
+   // multiple returned values from the inline type instance being
+   // returned to registers or to store returned values to a newly
+   // allocated inline type instance.
+   address generate_return_value_stub(address destination, const char* name, bool has_res) {
+     // We need to save all registers the calling convention may use so
+     // the runtime calls read or update those registers. This needs to
+     // be in sync with SharedRuntime::java_return_convention().
+     enum layout {
+       pad_off = frame::arg_reg_save_area_bytes/BytesPerInt, pad_off_2,
+       rax_off, rax_off_2,
+       j_rarg5_off, j_rarg5_2,
+       j_rarg4_off, j_rarg4_2,
+       j_rarg3_off, j_rarg3_2,
+       j_rarg2_off, j_rarg2_2,
+       j_rarg1_off, j_rarg1_2,
+       j_rarg0_off, j_rarg0_2,
+       j_farg0_off, j_farg0_2,
+       j_farg1_off, j_farg1_2,
+       j_farg2_off, j_farg2_2,
+       j_farg3_off, j_farg3_2,
+       j_farg4_off, j_farg4_2,
+       j_farg5_off, j_farg5_2,
+       j_farg6_off, j_farg6_2,
+       j_farg7_off, j_farg7_2,
+       rbp_off, rbp_off_2,
+       return_off, return_off_2,
+ 
+       framesize
+     };
+ 
+     CodeBuffer buffer(name, 1000, 512);
+     MacroAssembler* masm = new MacroAssembler(&buffer);
+ 
+     int frame_size_in_bytes = align_up(framesize*BytesPerInt, 16);
+     assert(frame_size_in_bytes == framesize*BytesPerInt, "misaligned");
+     int frame_size_in_slots = frame_size_in_bytes / BytesPerInt;
+     int frame_size_in_words = frame_size_in_bytes / wordSize;
+ 
+     OopMapSet *oop_maps = new OopMapSet();
+     OopMap* map = new OopMap(frame_size_in_slots, 0);
+ 
+     map->set_callee_saved(VMRegImpl::stack2reg(rax_off), rax->as_VMReg());
+     map->set_callee_saved(VMRegImpl::stack2reg(j_rarg5_off), j_rarg5->as_VMReg());
+     map->set_callee_saved(VMRegImpl::stack2reg(j_rarg4_off), j_rarg4->as_VMReg());
+     map->set_callee_saved(VMRegImpl::stack2reg(j_rarg3_off), j_rarg3->as_VMReg());
+     map->set_callee_saved(VMRegImpl::stack2reg(j_rarg2_off), j_rarg2->as_VMReg());
+     map->set_callee_saved(VMRegImpl::stack2reg(j_rarg1_off), j_rarg1->as_VMReg());
+     map->set_callee_saved(VMRegImpl::stack2reg(j_rarg0_off), j_rarg0->as_VMReg());
+     map->set_callee_saved(VMRegImpl::stack2reg(j_farg0_off), j_farg0->as_VMReg());
+     map->set_callee_saved(VMRegImpl::stack2reg(j_farg1_off), j_farg1->as_VMReg());
+     map->set_callee_saved(VMRegImpl::stack2reg(j_farg2_off), j_farg2->as_VMReg());
+     map->set_callee_saved(VMRegImpl::stack2reg(j_farg3_off), j_farg3->as_VMReg());
+     map->set_callee_saved(VMRegImpl::stack2reg(j_farg4_off), j_farg4->as_VMReg());
+     map->set_callee_saved(VMRegImpl::stack2reg(j_farg5_off), j_farg5->as_VMReg());
+     map->set_callee_saved(VMRegImpl::stack2reg(j_farg6_off), j_farg6->as_VMReg());
+     map->set_callee_saved(VMRegImpl::stack2reg(j_farg7_off), j_farg7->as_VMReg());
+ 
+     int start = __ offset();
+ 
+     __ subptr(rsp, frame_size_in_bytes - 8 /* return address*/);
+ 
+     __ movptr(Address(rsp, rbp_off * BytesPerInt), rbp);
+     __ movdbl(Address(rsp, j_farg7_off * BytesPerInt), j_farg7);
+     __ movdbl(Address(rsp, j_farg6_off * BytesPerInt), j_farg6);
+     __ movdbl(Address(rsp, j_farg5_off * BytesPerInt), j_farg5);
+     __ movdbl(Address(rsp, j_farg4_off * BytesPerInt), j_farg4);
+     __ movdbl(Address(rsp, j_farg3_off * BytesPerInt), j_farg3);
+     __ movdbl(Address(rsp, j_farg2_off * BytesPerInt), j_farg2);
+     __ movdbl(Address(rsp, j_farg1_off * BytesPerInt), j_farg1);
+     __ movdbl(Address(rsp, j_farg0_off * BytesPerInt), j_farg0);
+ 
+     __ movptr(Address(rsp, j_rarg0_off * BytesPerInt), j_rarg0);
+     __ movptr(Address(rsp, j_rarg1_off * BytesPerInt), j_rarg1);
+     __ movptr(Address(rsp, j_rarg2_off * BytesPerInt), j_rarg2);
+     __ movptr(Address(rsp, j_rarg3_off * BytesPerInt), j_rarg3);
+     __ movptr(Address(rsp, j_rarg4_off * BytesPerInt), j_rarg4);
+     __ movptr(Address(rsp, j_rarg5_off * BytesPerInt), j_rarg5);
+     __ movptr(Address(rsp, rax_off * BytesPerInt), rax);
+ 
+     int frame_complete = __ offset();
+ 
+     __ set_last_Java_frame(noreg, noreg, NULL);
+ 
+     __ mov(c_rarg0, r15_thread);
+     __ mov(c_rarg1, rax);
+ 
+     __ call(RuntimeAddress(destination));
+ 
+     // Set an oopmap for the call site.
+ 
+     oop_maps->add_gc_map( __ offset() - start, map);
+ 
+     // clear last_Java_sp
+     __ reset_last_Java_frame(false);
+ 
+     __ movptr(rbp, Address(rsp, rbp_off * BytesPerInt));
+     __ movdbl(j_farg7, Address(rsp, j_farg7_off * BytesPerInt));
+     __ movdbl(j_farg6, Address(rsp, j_farg6_off * BytesPerInt));
+     __ movdbl(j_farg5, Address(rsp, j_farg5_off * BytesPerInt));
+     __ movdbl(j_farg4, Address(rsp, j_farg4_off * BytesPerInt));
+     __ movdbl(j_farg3, Address(rsp, j_farg3_off * BytesPerInt));
+     __ movdbl(j_farg2, Address(rsp, j_farg2_off * BytesPerInt));
+     __ movdbl(j_farg1, Address(rsp, j_farg1_off * BytesPerInt));
+     __ movdbl(j_farg0, Address(rsp, j_farg0_off * BytesPerInt));
+ 
+     __ movptr(j_rarg0, Address(rsp, j_rarg0_off * BytesPerInt));
+     __ movptr(j_rarg1, Address(rsp, j_rarg1_off * BytesPerInt));
+     __ movptr(j_rarg2, Address(rsp, j_rarg2_off * BytesPerInt));
+     __ movptr(j_rarg3, Address(rsp, j_rarg3_off * BytesPerInt));
+     __ movptr(j_rarg4, Address(rsp, j_rarg4_off * BytesPerInt));
+     __ movptr(j_rarg5, Address(rsp, j_rarg5_off * BytesPerInt));
+     __ movptr(rax, Address(rsp, rax_off * BytesPerInt));
+ 
+     __ addptr(rsp, frame_size_in_bytes-8);
+ 
+     // check for pending exceptions
+     Label pending;
+     __ cmpptr(Address(r15_thread, Thread::pending_exception_offset()), (int32_t)NULL_WORD);
+     __ jcc(Assembler::notEqual, pending);
+ 
+     if (has_res) {
+       __ get_vm_result(rax, r15_thread);
+     }
+ 
+     __ ret(0);
+ 
+     __ bind(pending);
+ 
+     __ movptr(rax, Address(r15_thread, Thread::pending_exception_offset()));
+     __ jump(RuntimeAddress(StubRoutines::forward_exception_entry()));
+ 
+     // -------------
+     // make sure all code is generated
+     masm->flush();
+ 
+     RuntimeStub* stub = RuntimeStub::new_runtime_stub(name, &buffer, frame_complete, frame_size_in_words, oop_maps, false);
+     return stub->entry_point();
+   }
+ 
    // Initialization
    void generate_initial() {
      // Generates all stubs and initializes the entry points
  
      // This platform-specific settings are needed by generate_call_stub()

@@ -7540,12 +7719,18 @@
      // much more complicated generator structure. See also comment in
      // stubRoutines.hpp.
  
      StubRoutines::_forward_exception_entry = generate_forward_exception();
  
-     StubRoutines::_call_stub_entry =
-       generate_call_stub(StubRoutines::_call_stub_return_address);
+     // Generate these first because they are called from other stubs
+     if (InlineTypeReturnedAsFields) {
+       StubRoutines::_load_inline_type_fields_in_regs =
+         generate_return_value_stub(CAST_FROM_FN_PTR(address, SharedRuntime::load_inline_type_fields_in_regs), "load_inline_type_fields_in_regs", false);
+       StubRoutines::_store_inline_type_fields_to_buf =
+         generate_return_value_stub(CAST_FROM_FN_PTR(address, SharedRuntime::store_inline_type_fields_to_buf), "store_inline_type_fields_to_buf", true);
+     }
+     StubRoutines::_call_stub_entry = generate_call_stub(StubRoutines::_call_stub_return_address);
  
      // is referenced by megamorphic call
      StubRoutines::_catch_exception_entry = generate_catch_exception();
  
      // atomic calls
< prev index next >