< prev index next >

src/hotspot/cpu/x86/stubGenerator_x86_64.cpp

Print this page

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

  26 #include "asm/macroAssembler.hpp"
  27 #include "classfile/vmIntrinsics.hpp"
  28 #include "compiler/oopMap.hpp"
  29 #include "gc/shared/barrierSet.hpp"
  30 #include "gc/shared/barrierSetAssembler.hpp"
  31 #include "gc/shared/barrierSetNMethod.hpp"
  32 #include "gc/shared/gc_globals.hpp"
  33 #include "memory/universe.hpp"
  34 #include "prims/jvmtiExport.hpp"
  35 #include "prims/upcallLinker.hpp"
  36 #include "runtime/arguments.hpp"
  37 #include "runtime/javaThread.hpp"
  38 #include "runtime/sharedRuntime.hpp"
  39 #include "runtime/stubRoutines.hpp"


  40 #include "stubGenerator_x86_64.hpp"
  41 #ifdef COMPILER2
  42 #include "opto/runtime.hpp"
  43 #include "opto/c2_globals.hpp"
  44 #endif
  45 #if INCLUDE_JVMCI
  46 #include "jvmci/jvmci_globals.hpp"
  47 #endif
  48 #if INCLUDE_JFR
  49 #include "jfr/support/jfrIntrinsics.hpp"
  50 #endif
  51 
  52 // For a more detailed description of the stub routine structure
  53 // see the comment in stubRoutines.hpp
  54 
  55 #define __ _masm->
  56 #define TIMES_OOP (UseCompressedOops ? Address::times_4 : Address::times_8)
  57 
  58 #ifdef PRODUCT
  59 #define BLOCK_COMMENT(str) /* nothing */

 288   __ BIND(loop);
 289   __ movptr(rax, Address(c_rarg2, 0));// get parameter
 290   __ addptr(c_rarg2, wordSize);       // advance to next parameter
 291   __ decrementl(c_rarg1);             // decrement counter
 292   __ push(rax);                       // pass parameter
 293   __ jcc(Assembler::notZero, loop);
 294 
 295   // call Java function
 296   __ BIND(parameters_done);
 297   __ movptr(rbx, method);             // get Method*
 298   __ movptr(c_rarg1, entry_point);    // get entry_point
 299   __ mov(r13, rsp);                   // set sender sp
 300   BLOCK_COMMENT("call Java function");
 301   __ call(c_rarg1);
 302 
 303   BLOCK_COMMENT("call_stub_return_address:");
 304   return_address = __ pc();
 305 
 306   // store result depending on type (everything that is not
 307   // T_OBJECT, T_LONG, T_FLOAT or T_DOUBLE is treated as T_INT)
 308   __ movptr(c_rarg0, result);
 309   Label is_long, is_float, is_double, exit;
 310   __ movl(c_rarg1, result_type);
 311   __ cmpl(c_rarg1, T_OBJECT);


 312   __ jcc(Assembler::equal, is_long);
 313   __ cmpl(c_rarg1, T_LONG);
 314   __ jcc(Assembler::equal, is_long);
 315   __ cmpl(c_rarg1, T_FLOAT);
 316   __ jcc(Assembler::equal, is_float);
 317   __ cmpl(c_rarg1, T_DOUBLE);
 318   __ jcc(Assembler::equal, is_double);
 319 #ifdef ASSERT
 320   // make sure the type is INT
 321   {
 322     Label L;
 323     __ cmpl(c_rarg1, T_INT);
 324     __ jcc(Assembler::equal, L);
 325     __ stop("StubRoutines::call_stub: unexpected result type");
 326     __ bind(L);
 327   }
 328 #endif
 329 
 330   // handle T_INT case
 331   __ movl(Address(c_rarg0, 0), rax);
 332 
 333   __ BIND(exit);
 334 
 335   // pop parameters
 336   __ lea(rsp, rsp_after_call);
 337 
 338 #ifdef ASSERT
 339   // verify that threads correspond
 340   {
 341    Label L1, L2, L3;
 342     __ cmpptr(r15_thread, thread);
 343     __ jcc(Assembler::equal, L1);
 344     __ stop("StubRoutines::call_stub: r15_thread is corrupted");
 345     __ bind(L1);
 346     __ get_thread(rbx);
 347     __ cmpptr(r15_thread, thread);
 348     __ jcc(Assembler::equal, L2);
 349     __ stop("StubRoutines::call_stub: r15_thread is modified by call");
 350     __ bind(L2);
 351     __ cmpptr(r15_thread, rbx);

 369   __ movptr(r13, r13_save);
 370   __ movptr(r12, r12_save);
 371   __ movptr(rbx, rbx_save);
 372 
 373 #ifdef _WIN64
 374   __ movptr(rdi, rdi_save);
 375   __ movptr(rsi, rsi_save);
 376 #else
 377   __ ldmxcsr(mxcsr_save);
 378 #endif
 379 
 380   // restore rsp
 381   __ addptr(rsp, -rsp_after_call_off * wordSize);
 382 
 383   // return
 384   __ vzeroupper();
 385   __ pop(rbp);
 386   __ ret(0);
 387 
 388   // handle return types different from T_INT













 389   __ BIND(is_long);
 390   __ movq(Address(c_rarg0, 0), rax);
 391   __ jmp(exit);
 392 
 393   __ BIND(is_float);
 394   __ movflt(Address(c_rarg0, 0), xmm0);
 395   __ jmp(exit);
 396 
 397   __ BIND(is_double);
 398   __ movdbl(Address(c_rarg0, 0), xmm0);
 399   __ jmp(exit);
 400 
 401   return start;
 402 }
 403 
 404 // Return point for a Java call if there's an exception thrown in
 405 // Java code.  The exception is caught and transformed into a
 406 // pending exception stored in JavaThread that can be tested from
 407 // within the VM.
 408 //
 409 // Note: Usually the parameters are removed by the callee. In case
 410 // of an exception crossing an activation frame boundary, that is
 411 // not the case if the callee is compiled code => need to setup the
 412 // rsp.
 413 //
 414 // rax: exception oop
 415 
 416 address StubGenerator::generate_catch_exception() {
 417   StubCodeMark mark(this, "StubRoutines", "catch_exception");
 418   address start = __ pc();

4004 // Initialization
4005 void StubGenerator::generate_initial_stubs() {
4006   // Generates all stubs and initializes the entry points
4007 
4008   // This platform-specific settings are needed by generate_call_stub()
4009   create_control_words();
4010 
4011   // Initialize table for unsafe copy memeory check.
4012   if (UnsafeCopyMemory::_table == nullptr) {
4013     UnsafeCopyMemory::create_table(16);
4014   }
4015 
4016   // entry points that exist in all platforms Note: This is code
4017   // that could be shared among different platforms - however the
4018   // benefit seems to be smaller than the disadvantage of having a
4019   // much more complicated generator structure. See also comment in
4020   // stubRoutines.hpp.
4021 
4022   StubRoutines::_forward_exception_entry = generate_forward_exception();
4023 










4024   StubRoutines::_call_stub_entry =
4025     generate_call_stub(StubRoutines::_call_stub_return_address);
4026 
4027   // is referenced by megamorphic call
4028   StubRoutines::_catch_exception_entry = generate_catch_exception();
4029 
4030   // atomic calls
4031   StubRoutines::_fence_entry                = generate_orderaccess_fence();
4032 
4033   // platform dependent
4034   StubRoutines::x86::_get_previous_sp_entry = generate_get_previous_sp();
4035 
4036   StubRoutines::x86::_verify_mxcsr_entry    = generate_verify_mxcsr();
4037 
4038   StubRoutines::x86::_f2i_fixup             = generate_f2i_fixup();
4039   StubRoutines::x86::_f2l_fixup             = generate_f2l_fixup();
4040   StubRoutines::x86::_d2i_fixup             = generate_d2i_fixup();
4041   StubRoutines::x86::_d2l_fixup             = generate_d2l_fixup();
4042 
4043   StubRoutines::x86::_float_sign_mask       = generate_fp_mask("float_sign_mask",  0x7FFFFFFF7FFFFFFF);

4067     StubRoutines::x86::generate_CRC32C_table(supports_clmul);
4068     StubRoutines::_crc32c_table_addr = (address)StubRoutines::x86::_crc32c_table;
4069     StubRoutines::_updateBytesCRC32C = generate_updateBytesCRC32C(supports_clmul);
4070   }
4071 
4072   if (VM_Version::supports_float16()) {
4073     // For results consistency both intrinsics should be enabled.
4074     // vmIntrinsics checks InlineIntrinsics flag, no need to check it here.
4075     if (vmIntrinsics::is_intrinsic_available(vmIntrinsics::_float16ToFloat) &&
4076         vmIntrinsics::is_intrinsic_available(vmIntrinsics::_floatToFloat16)) {
4077       StubRoutines::_hf2f = generate_float16ToFloat();
4078       StubRoutines::_f2hf = generate_floatToFloat16();
4079     }
4080   }
4081 
4082   generate_libm_stubs();
4083 
4084   StubRoutines::_fmod = generate_libmFmod(); // from stubGenerator_x86_64_fmod.cpp
4085 }
4086 
















































































































































4087 void StubGenerator::generate_continuation_stubs() {
4088   // Continuation stubs:
4089   StubRoutines::_cont_thaw          = generate_cont_thaw();
4090   StubRoutines::_cont_returnBarrier = generate_cont_returnBarrier();
4091   StubRoutines::_cont_returnBarrierExc = generate_cont_returnBarrier_exception();
4092 
4093   JFR_ONLY(generate_jfr_stubs();)
4094 }
4095 
4096 #if INCLUDE_JFR
4097 void StubGenerator::generate_jfr_stubs() {
4098   StubRoutines::_jfr_write_checkpoint_stub = generate_jfr_write_checkpoint();
4099   StubRoutines::_jfr_write_checkpoint = StubRoutines::_jfr_write_checkpoint_stub->entry_point();
4100   StubRoutines::_jfr_return_lease_stub = generate_jfr_return_lease();
4101   StubRoutines::_jfr_return_lease = StubRoutines::_jfr_return_lease_stub->entry_point();
4102 }
4103 #endif
4104 
4105 void StubGenerator::generate_final_stubs() {
4106   // Generates the rest of stubs and initializes the entry points

   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "asm/assembler.hpp"
  27 #include "asm/macroAssembler.hpp"
  28 #include "classfile/vmIntrinsics.hpp"
  29 #include "compiler/oopMap.hpp"
  30 #include "gc/shared/barrierSet.hpp"
  31 #include "gc/shared/barrierSetAssembler.hpp"
  32 #include "gc/shared/barrierSetNMethod.hpp"
  33 #include "gc/shared/gc_globals.hpp"
  34 #include "memory/universe.hpp"
  35 #include "prims/jvmtiExport.hpp"
  36 #include "prims/upcallLinker.hpp"
  37 #include "runtime/arguments.hpp"
  38 #include "runtime/javaThread.hpp"
  39 #include "runtime/sharedRuntime.hpp"
  40 #include "runtime/stubRoutines.hpp"
  41 #include "utilities/macros.hpp"
  42 #include "vmreg_x86.inline.hpp"
  43 #include "stubGenerator_x86_64.hpp"
  44 #ifdef COMPILER2
  45 #include "opto/runtime.hpp"
  46 #include "opto/c2_globals.hpp"
  47 #endif
  48 #if INCLUDE_JVMCI
  49 #include "jvmci/jvmci_globals.hpp"
  50 #endif
  51 #if INCLUDE_JFR
  52 #include "jfr/support/jfrIntrinsics.hpp"
  53 #endif
  54 
  55 // For a more detailed description of the stub routine structure
  56 // see the comment in stubRoutines.hpp
  57 
  58 #define __ _masm->
  59 #define TIMES_OOP (UseCompressedOops ? Address::times_4 : Address::times_8)
  60 
  61 #ifdef PRODUCT
  62 #define BLOCK_COMMENT(str) /* nothing */

 291   __ BIND(loop);
 292   __ movptr(rax, Address(c_rarg2, 0));// get parameter
 293   __ addptr(c_rarg2, wordSize);       // advance to next parameter
 294   __ decrementl(c_rarg1);             // decrement counter
 295   __ push(rax);                       // pass parameter
 296   __ jcc(Assembler::notZero, loop);
 297 
 298   // call Java function
 299   __ BIND(parameters_done);
 300   __ movptr(rbx, method);             // get Method*
 301   __ movptr(c_rarg1, entry_point);    // get entry_point
 302   __ mov(r13, rsp);                   // set sender sp
 303   BLOCK_COMMENT("call Java function");
 304   __ call(c_rarg1);
 305 
 306   BLOCK_COMMENT("call_stub_return_address:");
 307   return_address = __ pc();
 308 
 309   // store result depending on type (everything that is not
 310   // T_OBJECT, T_LONG, T_FLOAT or T_DOUBLE is treated as T_INT)
 311   __ movptr(r13, result);
 312   Label is_long, is_float, is_double, check_prim, exit;
 313   __ movl(rbx, result_type);
 314   __ cmpl(rbx, T_OBJECT);
 315   __ jcc(Assembler::equal, check_prim);
 316   __ cmpl(rbx, T_LONG);
 317   __ jcc(Assembler::equal, is_long);
 318   __ cmpl(rbx, T_FLOAT);


 319   __ jcc(Assembler::equal, is_float);
 320   __ cmpl(rbx, T_DOUBLE);
 321   __ jcc(Assembler::equal, is_double);
 322 #ifdef ASSERT
 323   // make sure the type is INT
 324   {
 325     Label L;
 326     __ cmpl(rbx, T_INT);
 327     __ jcc(Assembler::equal, L);
 328     __ stop("StubRoutines::call_stub: unexpected result type");
 329     __ bind(L);
 330   }
 331 #endif
 332 
 333   // handle T_INT case
 334   __ movl(Address(r13, 0), rax);
 335 
 336   __ BIND(exit);
 337 
 338   // pop parameters
 339   __ lea(rsp, rsp_after_call);
 340 
 341 #ifdef ASSERT
 342   // verify that threads correspond
 343   {
 344    Label L1, L2, L3;
 345     __ cmpptr(r15_thread, thread);
 346     __ jcc(Assembler::equal, L1);
 347     __ stop("StubRoutines::call_stub: r15_thread is corrupted");
 348     __ bind(L1);
 349     __ get_thread(rbx);
 350     __ cmpptr(r15_thread, thread);
 351     __ jcc(Assembler::equal, L2);
 352     __ stop("StubRoutines::call_stub: r15_thread is modified by call");
 353     __ bind(L2);
 354     __ cmpptr(r15_thread, rbx);

 372   __ movptr(r13, r13_save);
 373   __ movptr(r12, r12_save);
 374   __ movptr(rbx, rbx_save);
 375 
 376 #ifdef _WIN64
 377   __ movptr(rdi, rdi_save);
 378   __ movptr(rsi, rsi_save);
 379 #else
 380   __ ldmxcsr(mxcsr_save);
 381 #endif
 382 
 383   // restore rsp
 384   __ addptr(rsp, -rsp_after_call_off * wordSize);
 385 
 386   // return
 387   __ vzeroupper();
 388   __ pop(rbp);
 389   __ ret(0);
 390 
 391   // handle return types different from T_INT
 392   __ BIND(check_prim);
 393   if (InlineTypeReturnedAsFields) {
 394     // Check for scalarized return value
 395     __ testptr(rax, 1);
 396     __ jcc(Assembler::zero, is_long);
 397     // Load pack handler address
 398     __ andptr(rax, -2);
 399     __ movptr(rax, Address(rax, InstanceKlass::adr_inlineklass_fixed_block_offset()));
 400     __ movptr(rbx, Address(rax, InlineKlass::pack_handler_jobject_offset()));
 401     // Call pack handler to initialize the buffer
 402     __ call(rbx);
 403     __ jmp(exit);
 404   }
 405   __ BIND(is_long);
 406   __ movq(Address(r13, 0), rax);
 407   __ jmp(exit);
 408 
 409   __ BIND(is_float);
 410   __ movflt(Address(r13, 0), xmm0);
 411   __ jmp(exit);
 412 
 413   __ BIND(is_double);
 414   __ movdbl(Address(r13, 0), xmm0);
 415   __ jmp(exit);
 416 
 417   return start;
 418 }
 419 
 420 // Return point for a Java call if there's an exception thrown in
 421 // Java code.  The exception is caught and transformed into a
 422 // pending exception stored in JavaThread that can be tested from
 423 // within the VM.
 424 //
 425 // Note: Usually the parameters are removed by the callee. In case
 426 // of an exception crossing an activation frame boundary, that is
 427 // not the case if the callee is compiled code => need to setup the
 428 // rsp.
 429 //
 430 // rax: exception oop
 431 
 432 address StubGenerator::generate_catch_exception() {
 433   StubCodeMark mark(this, "StubRoutines", "catch_exception");
 434   address start = __ pc();

4020 // Initialization
4021 void StubGenerator::generate_initial_stubs() {
4022   // Generates all stubs and initializes the entry points
4023 
4024   // This platform-specific settings are needed by generate_call_stub()
4025   create_control_words();
4026 
4027   // Initialize table for unsafe copy memeory check.
4028   if (UnsafeCopyMemory::_table == nullptr) {
4029     UnsafeCopyMemory::create_table(16);
4030   }
4031 
4032   // entry points that exist in all platforms Note: This is code
4033   // that could be shared among different platforms - however the
4034   // benefit seems to be smaller than the disadvantage of having a
4035   // much more complicated generator structure. See also comment in
4036   // stubRoutines.hpp.
4037 
4038   StubRoutines::_forward_exception_entry = generate_forward_exception();
4039 
4040   // Generate these first because they are called from other stubs
4041   if (InlineTypeReturnedAsFields) {
4042     StubRoutines::_load_inline_type_fields_in_regs =
4043       generate_return_value_stub(CAST_FROM_FN_PTR(address, SharedRuntime::load_inline_type_fields_in_regs),
4044                                  "load_inline_type_fields_in_regs", false);
4045     StubRoutines::_store_inline_type_fields_to_buf =
4046       generate_return_value_stub(CAST_FROM_FN_PTR(address, SharedRuntime::store_inline_type_fields_to_buf),
4047                                  "store_inline_type_fields_to_buf", true);
4048   }
4049 
4050   StubRoutines::_call_stub_entry =
4051     generate_call_stub(StubRoutines::_call_stub_return_address);
4052 
4053   // is referenced by megamorphic call
4054   StubRoutines::_catch_exception_entry = generate_catch_exception();
4055 
4056   // atomic calls
4057   StubRoutines::_fence_entry                = generate_orderaccess_fence();
4058 
4059   // platform dependent
4060   StubRoutines::x86::_get_previous_sp_entry = generate_get_previous_sp();
4061 
4062   StubRoutines::x86::_verify_mxcsr_entry    = generate_verify_mxcsr();
4063 
4064   StubRoutines::x86::_f2i_fixup             = generate_f2i_fixup();
4065   StubRoutines::x86::_f2l_fixup             = generate_f2l_fixup();
4066   StubRoutines::x86::_d2i_fixup             = generate_d2i_fixup();
4067   StubRoutines::x86::_d2l_fixup             = generate_d2l_fixup();
4068 
4069   StubRoutines::x86::_float_sign_mask       = generate_fp_mask("float_sign_mask",  0x7FFFFFFF7FFFFFFF);

4093     StubRoutines::x86::generate_CRC32C_table(supports_clmul);
4094     StubRoutines::_crc32c_table_addr = (address)StubRoutines::x86::_crc32c_table;
4095     StubRoutines::_updateBytesCRC32C = generate_updateBytesCRC32C(supports_clmul);
4096   }
4097 
4098   if (VM_Version::supports_float16()) {
4099     // For results consistency both intrinsics should be enabled.
4100     // vmIntrinsics checks InlineIntrinsics flag, no need to check it here.
4101     if (vmIntrinsics::is_intrinsic_available(vmIntrinsics::_float16ToFloat) &&
4102         vmIntrinsics::is_intrinsic_available(vmIntrinsics::_floatToFloat16)) {
4103       StubRoutines::_hf2f = generate_float16ToFloat();
4104       StubRoutines::_f2hf = generate_floatToFloat16();
4105     }
4106   }
4107 
4108   generate_libm_stubs();
4109 
4110   StubRoutines::_fmod = generate_libmFmod(); // from stubGenerator_x86_64_fmod.cpp
4111 }
4112 
4113 // Call here from the interpreter or compiled code to either load
4114 // multiple returned values from the inline type instance being
4115 // returned to registers or to store returned values to a newly
4116 // allocated inline type instance.
4117 // Register is a class, but it would be assigned numerical value.
4118 // "0" is assigned for xmm0. Thus we need to ignore -Wnonnull.
4119 PRAGMA_DIAG_PUSH
4120 PRAGMA_NONNULL_IGNORED
4121 address StubGenerator::generate_return_value_stub(address destination, const char* name, bool has_res) {
4122   // We need to save all registers the calling convention may use so
4123   // the runtime calls read or update those registers. This needs to
4124   // be in sync with SharedRuntime::java_return_convention().
4125   enum layout {
4126     pad_off = frame::arg_reg_save_area_bytes/BytesPerInt, pad_off_2,
4127     rax_off, rax_off_2,
4128     j_rarg5_off, j_rarg5_2,
4129     j_rarg4_off, j_rarg4_2,
4130     j_rarg3_off, j_rarg3_2,
4131     j_rarg2_off, j_rarg2_2,
4132     j_rarg1_off, j_rarg1_2,
4133     j_rarg0_off, j_rarg0_2,
4134     j_farg0_off, j_farg0_2,
4135     j_farg1_off, j_farg1_2,
4136     j_farg2_off, j_farg2_2,
4137     j_farg3_off, j_farg3_2,
4138     j_farg4_off, j_farg4_2,
4139     j_farg5_off, j_farg5_2,
4140     j_farg6_off, j_farg6_2,
4141     j_farg7_off, j_farg7_2,
4142     rbp_off, rbp_off_2,
4143     return_off, return_off_2,
4144 
4145     framesize
4146   };
4147 
4148   CodeBuffer buffer(name, 1000, 512);
4149   MacroAssembler* _masm = new MacroAssembler(&buffer);
4150 
4151   int frame_size_in_bytes = align_up(framesize*BytesPerInt, 16);
4152   assert(frame_size_in_bytes == framesize*BytesPerInt, "misaligned");
4153   int frame_size_in_slots = frame_size_in_bytes / BytesPerInt;
4154   int frame_size_in_words = frame_size_in_bytes / wordSize;
4155 
4156   OopMapSet *oop_maps = new OopMapSet();
4157   OopMap* map = new OopMap(frame_size_in_slots, 0);
4158 
4159   map->set_callee_saved(VMRegImpl::stack2reg(rax_off), rax->as_VMReg());
4160   map->set_callee_saved(VMRegImpl::stack2reg(j_rarg5_off), j_rarg5->as_VMReg());
4161   map->set_callee_saved(VMRegImpl::stack2reg(j_rarg4_off), j_rarg4->as_VMReg());
4162   map->set_callee_saved(VMRegImpl::stack2reg(j_rarg3_off), j_rarg3->as_VMReg());
4163   map->set_callee_saved(VMRegImpl::stack2reg(j_rarg2_off), j_rarg2->as_VMReg());
4164   map->set_callee_saved(VMRegImpl::stack2reg(j_rarg1_off), j_rarg1->as_VMReg());
4165   map->set_callee_saved(VMRegImpl::stack2reg(j_rarg0_off), j_rarg0->as_VMReg());
4166   map->set_callee_saved(VMRegImpl::stack2reg(j_farg0_off), j_farg0->as_VMReg());
4167   map->set_callee_saved(VMRegImpl::stack2reg(j_farg1_off), j_farg1->as_VMReg());
4168   map->set_callee_saved(VMRegImpl::stack2reg(j_farg2_off), j_farg2->as_VMReg());
4169   map->set_callee_saved(VMRegImpl::stack2reg(j_farg3_off), j_farg3->as_VMReg());
4170   map->set_callee_saved(VMRegImpl::stack2reg(j_farg4_off), j_farg4->as_VMReg());
4171   map->set_callee_saved(VMRegImpl::stack2reg(j_farg5_off), j_farg5->as_VMReg());
4172   map->set_callee_saved(VMRegImpl::stack2reg(j_farg6_off), j_farg6->as_VMReg());
4173   map->set_callee_saved(VMRegImpl::stack2reg(j_farg7_off), j_farg7->as_VMReg());
4174 
4175   int start = __ offset();
4176 
4177   __ subptr(rsp, frame_size_in_bytes - 8 /* return address*/);
4178 
4179   __ movptr(Address(rsp, rbp_off * BytesPerInt), rbp);
4180   __ movdbl(Address(rsp, j_farg7_off * BytesPerInt), j_farg7);
4181   __ movdbl(Address(rsp, j_farg6_off * BytesPerInt), j_farg6);
4182   __ movdbl(Address(rsp, j_farg5_off * BytesPerInt), j_farg5);
4183   __ movdbl(Address(rsp, j_farg4_off * BytesPerInt), j_farg4);
4184   __ movdbl(Address(rsp, j_farg3_off * BytesPerInt), j_farg3);
4185   __ movdbl(Address(rsp, j_farg2_off * BytesPerInt), j_farg2);
4186   __ movdbl(Address(rsp, j_farg1_off * BytesPerInt), j_farg1);
4187   __ movdbl(Address(rsp, j_farg0_off * BytesPerInt), j_farg0);
4188 
4189   __ movptr(Address(rsp, j_rarg0_off * BytesPerInt), j_rarg0);
4190   __ movptr(Address(rsp, j_rarg1_off * BytesPerInt), j_rarg1);
4191   __ movptr(Address(rsp, j_rarg2_off * BytesPerInt), j_rarg2);
4192   __ movptr(Address(rsp, j_rarg3_off * BytesPerInt), j_rarg3);
4193   __ movptr(Address(rsp, j_rarg4_off * BytesPerInt), j_rarg4);
4194   __ movptr(Address(rsp, j_rarg5_off * BytesPerInt), j_rarg5);
4195   __ movptr(Address(rsp, rax_off * BytesPerInt), rax);
4196 
4197   int frame_complete = __ offset();
4198 
4199   __ set_last_Java_frame(noreg, noreg, nullptr, rscratch1);
4200 
4201   __ mov(c_rarg0, r15_thread);
4202   __ mov(c_rarg1, rax);
4203 
4204   __ call(RuntimeAddress(destination));
4205 
4206   // Set an oopmap for the call site.
4207 
4208   oop_maps->add_gc_map( __ offset() - start, map);
4209 
4210   // clear last_Java_sp
4211   __ reset_last_Java_frame(false);
4212 
4213   __ movptr(rbp, Address(rsp, rbp_off * BytesPerInt));
4214   __ movdbl(j_farg7, Address(rsp, j_farg7_off * BytesPerInt));
4215   __ movdbl(j_farg6, Address(rsp, j_farg6_off * BytesPerInt));
4216   __ movdbl(j_farg5, Address(rsp, j_farg5_off * BytesPerInt));
4217   __ movdbl(j_farg4, Address(rsp, j_farg4_off * BytesPerInt));
4218   __ movdbl(j_farg3, Address(rsp, j_farg3_off * BytesPerInt));
4219   __ movdbl(j_farg2, Address(rsp, j_farg2_off * BytesPerInt));
4220   __ movdbl(j_farg1, Address(rsp, j_farg1_off * BytesPerInt));
4221   __ movdbl(j_farg0, Address(rsp, j_farg0_off * BytesPerInt));
4222 
4223   __ movptr(j_rarg0, Address(rsp, j_rarg0_off * BytesPerInt));
4224   __ movptr(j_rarg1, Address(rsp, j_rarg1_off * BytesPerInt));
4225   __ movptr(j_rarg2, Address(rsp, j_rarg2_off * BytesPerInt));
4226   __ movptr(j_rarg3, Address(rsp, j_rarg3_off * BytesPerInt));
4227   __ movptr(j_rarg4, Address(rsp, j_rarg4_off * BytesPerInt));
4228   __ movptr(j_rarg5, Address(rsp, j_rarg5_off * BytesPerInt));
4229   __ movptr(rax, Address(rsp, rax_off * BytesPerInt));
4230 
4231   __ addptr(rsp, frame_size_in_bytes-8);
4232 
4233   // check for pending exceptions
4234   Label pending;
4235   __ cmpptr(Address(r15_thread, Thread::pending_exception_offset()), (int32_t)NULL_WORD);
4236   __ jcc(Assembler::notEqual, pending);
4237 
4238   if (has_res) {
4239     __ get_vm_result(rax, r15_thread);
4240   }
4241 
4242   __ ret(0);
4243 
4244   __ bind(pending);
4245 
4246   __ movptr(rax, Address(r15_thread, Thread::pending_exception_offset()));
4247   __ jump(RuntimeAddress(StubRoutines::forward_exception_entry()));
4248 
4249   // -------------
4250   // make sure all code is generated
4251   _masm->flush();
4252 
4253   RuntimeStub* stub = RuntimeStub::new_runtime_stub(name, &buffer, frame_complete, frame_size_in_words, oop_maps, false);
4254   return stub->entry_point();
4255 }
4256 
4257 void StubGenerator::generate_continuation_stubs() {
4258   // Continuation stubs:
4259   StubRoutines::_cont_thaw          = generate_cont_thaw();
4260   StubRoutines::_cont_returnBarrier = generate_cont_returnBarrier();
4261   StubRoutines::_cont_returnBarrierExc = generate_cont_returnBarrier_exception();
4262 
4263   JFR_ONLY(generate_jfr_stubs();)
4264 }
4265 
4266 #if INCLUDE_JFR
4267 void StubGenerator::generate_jfr_stubs() {
4268   StubRoutines::_jfr_write_checkpoint_stub = generate_jfr_write_checkpoint();
4269   StubRoutines::_jfr_write_checkpoint = StubRoutines::_jfr_write_checkpoint_stub->entry_point();
4270   StubRoutines::_jfr_return_lease_stub = generate_jfr_return_lease();
4271   StubRoutines::_jfr_return_lease = StubRoutines::_jfr_return_lease_stub->entry_point();
4272 }
4273 #endif
4274 
4275 void StubGenerator::generate_final_stubs() {
4276   // Generates the rest of stubs and initializes the entry points
< prev index next >