< 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();

3916 // Initialization
3917 void StubGenerator::generate_initial_stubs() {
3918   // Generates all stubs and initializes the entry points
3919 
3920   // This platform-specific settings are needed by generate_call_stub()
3921   create_control_words();
3922 
3923   // Initialize table for unsafe copy memeory check.
3924   if (UnsafeCopyMemory::_table == nullptr) {
3925     UnsafeCopyMemory::create_table(16);
3926   }
3927 
3928   // entry points that exist in all platforms Note: This is code
3929   // that could be shared among different platforms - however the
3930   // benefit seems to be smaller than the disadvantage of having a
3931   // much more complicated generator structure. See also comment in
3932   // stubRoutines.hpp.
3933 
3934   StubRoutines::_forward_exception_entry = generate_forward_exception();
3935 










3936   StubRoutines::_call_stub_entry =
3937     generate_call_stub(StubRoutines::_call_stub_return_address);
3938 
3939   // is referenced by megamorphic call
3940   StubRoutines::_catch_exception_entry = generate_catch_exception();
3941 
3942   // atomic calls
3943   StubRoutines::_fence_entry                = generate_orderaccess_fence();
3944 
3945   // platform dependent
3946   StubRoutines::x86::_get_previous_sp_entry = generate_get_previous_sp();
3947 
3948   StubRoutines::x86::_verify_mxcsr_entry    = generate_verify_mxcsr();
3949 
3950   StubRoutines::x86::_f2i_fixup             = generate_f2i_fixup();
3951   StubRoutines::x86::_f2l_fixup             = generate_f2l_fixup();
3952   StubRoutines::x86::_d2i_fixup             = generate_d2i_fixup();
3953   StubRoutines::x86::_d2l_fixup             = generate_d2l_fixup();
3954 
3955   StubRoutines::x86::_float_sign_mask       = generate_fp_mask("float_sign_mask",  0x7FFFFFFF7FFFFFFF);

3979     StubRoutines::x86::generate_CRC32C_table(supports_clmul);
3980     StubRoutines::_crc32c_table_addr = (address)StubRoutines::x86::_crc32c_table;
3981     StubRoutines::_updateBytesCRC32C = generate_updateBytesCRC32C(supports_clmul);
3982   }
3983 
3984   if (VM_Version::supports_float16()) {
3985     // For results consistency both intrinsics should be enabled.
3986     // vmIntrinsics checks InlineIntrinsics flag, no need to check it here.
3987     if (vmIntrinsics::is_intrinsic_available(vmIntrinsics::_float16ToFloat) &&
3988         vmIntrinsics::is_intrinsic_available(vmIntrinsics::_floatToFloat16)) {
3989       StubRoutines::_hf2f = generate_float16ToFloat();
3990       StubRoutines::_f2hf = generate_floatToFloat16();
3991     }
3992   }
3993 
3994   generate_libm_stubs();
3995 
3996   StubRoutines::_fmod = generate_libmFmod(); // from stubGenerator_x86_64_fmod.cpp
3997 }
3998 
















































































































































3999 void StubGenerator::generate_continuation_stubs() {
4000   // Continuation stubs:
4001   StubRoutines::_cont_thaw          = generate_cont_thaw();
4002   StubRoutines::_cont_returnBarrier = generate_cont_returnBarrier();
4003   StubRoutines::_cont_returnBarrierExc = generate_cont_returnBarrier_exception();
4004 
4005   JFR_ONLY(generate_jfr_stubs();)
4006 }
4007 
4008 #if INCLUDE_JFR
4009 void StubGenerator::generate_jfr_stubs() {
4010   StubRoutines::_jfr_write_checkpoint_stub = generate_jfr_write_checkpoint();
4011   StubRoutines::_jfr_write_checkpoint = StubRoutines::_jfr_write_checkpoint_stub->entry_point();
4012   StubRoutines::_jfr_return_lease_stub = generate_jfr_return_lease();
4013   StubRoutines::_jfr_return_lease = StubRoutines::_jfr_return_lease_stub->entry_point();
4014 }
4015 #endif
4016 
4017 void StubGenerator::generate_final_stubs() {
4018   // 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();

3932 // Initialization
3933 void StubGenerator::generate_initial_stubs() {
3934   // Generates all stubs and initializes the entry points
3935 
3936   // This platform-specific settings are needed by generate_call_stub()
3937   create_control_words();
3938 
3939   // Initialize table for unsafe copy memeory check.
3940   if (UnsafeCopyMemory::_table == nullptr) {
3941     UnsafeCopyMemory::create_table(16);
3942   }
3943 
3944   // entry points that exist in all platforms Note: This is code
3945   // that could be shared among different platforms - however the
3946   // benefit seems to be smaller than the disadvantage of having a
3947   // much more complicated generator structure. See also comment in
3948   // stubRoutines.hpp.
3949 
3950   StubRoutines::_forward_exception_entry = generate_forward_exception();
3951 
3952   // Generate these first because they are called from other stubs
3953   if (InlineTypeReturnedAsFields) {
3954     StubRoutines::_load_inline_type_fields_in_regs =
3955       generate_return_value_stub(CAST_FROM_FN_PTR(address, SharedRuntime::load_inline_type_fields_in_regs),
3956                                  "load_inline_type_fields_in_regs", false);
3957     StubRoutines::_store_inline_type_fields_to_buf =
3958       generate_return_value_stub(CAST_FROM_FN_PTR(address, SharedRuntime::store_inline_type_fields_to_buf),
3959                                  "store_inline_type_fields_to_buf", true);
3960   }
3961 
3962   StubRoutines::_call_stub_entry =
3963     generate_call_stub(StubRoutines::_call_stub_return_address);
3964 
3965   // is referenced by megamorphic call
3966   StubRoutines::_catch_exception_entry = generate_catch_exception();
3967 
3968   // atomic calls
3969   StubRoutines::_fence_entry                = generate_orderaccess_fence();
3970 
3971   // platform dependent
3972   StubRoutines::x86::_get_previous_sp_entry = generate_get_previous_sp();
3973 
3974   StubRoutines::x86::_verify_mxcsr_entry    = generate_verify_mxcsr();
3975 
3976   StubRoutines::x86::_f2i_fixup             = generate_f2i_fixup();
3977   StubRoutines::x86::_f2l_fixup             = generate_f2l_fixup();
3978   StubRoutines::x86::_d2i_fixup             = generate_d2i_fixup();
3979   StubRoutines::x86::_d2l_fixup             = generate_d2l_fixup();
3980 
3981   StubRoutines::x86::_float_sign_mask       = generate_fp_mask("float_sign_mask",  0x7FFFFFFF7FFFFFFF);

4005     StubRoutines::x86::generate_CRC32C_table(supports_clmul);
4006     StubRoutines::_crc32c_table_addr = (address)StubRoutines::x86::_crc32c_table;
4007     StubRoutines::_updateBytesCRC32C = generate_updateBytesCRC32C(supports_clmul);
4008   }
4009 
4010   if (VM_Version::supports_float16()) {
4011     // For results consistency both intrinsics should be enabled.
4012     // vmIntrinsics checks InlineIntrinsics flag, no need to check it here.
4013     if (vmIntrinsics::is_intrinsic_available(vmIntrinsics::_float16ToFloat) &&
4014         vmIntrinsics::is_intrinsic_available(vmIntrinsics::_floatToFloat16)) {
4015       StubRoutines::_hf2f = generate_float16ToFloat();
4016       StubRoutines::_f2hf = generate_floatToFloat16();
4017     }
4018   }
4019 
4020   generate_libm_stubs();
4021 
4022   StubRoutines::_fmod = generate_libmFmod(); // from stubGenerator_x86_64_fmod.cpp
4023 }
4024 
4025 // Call here from the interpreter or compiled code to either load
4026 // multiple returned values from the inline type instance being
4027 // returned to registers or to store returned values to a newly
4028 // allocated inline type instance.
4029 // Register is a class, but it would be assigned numerical value.
4030 // "0" is assigned for xmm0. Thus we need to ignore -Wnonnull.
4031 PRAGMA_DIAG_PUSH
4032 PRAGMA_NONNULL_IGNORED
4033 address StubGenerator::generate_return_value_stub(address destination, const char* name, bool has_res) {
4034   // We need to save all registers the calling convention may use so
4035   // the runtime calls read or update those registers. This needs to
4036   // be in sync with SharedRuntime::java_return_convention().
4037   enum layout {
4038     pad_off = frame::arg_reg_save_area_bytes/BytesPerInt, pad_off_2,
4039     rax_off, rax_off_2,
4040     j_rarg5_off, j_rarg5_2,
4041     j_rarg4_off, j_rarg4_2,
4042     j_rarg3_off, j_rarg3_2,
4043     j_rarg2_off, j_rarg2_2,
4044     j_rarg1_off, j_rarg1_2,
4045     j_rarg0_off, j_rarg0_2,
4046     j_farg0_off, j_farg0_2,
4047     j_farg1_off, j_farg1_2,
4048     j_farg2_off, j_farg2_2,
4049     j_farg3_off, j_farg3_2,
4050     j_farg4_off, j_farg4_2,
4051     j_farg5_off, j_farg5_2,
4052     j_farg6_off, j_farg6_2,
4053     j_farg7_off, j_farg7_2,
4054     rbp_off, rbp_off_2,
4055     return_off, return_off_2,
4056 
4057     framesize
4058   };
4059 
4060   CodeBuffer buffer(name, 1000, 512);
4061   MacroAssembler* _masm = new MacroAssembler(&buffer);
4062 
4063   int frame_size_in_bytes = align_up(framesize*BytesPerInt, 16);
4064   assert(frame_size_in_bytes == framesize*BytesPerInt, "misaligned");
4065   int frame_size_in_slots = frame_size_in_bytes / BytesPerInt;
4066   int frame_size_in_words = frame_size_in_bytes / wordSize;
4067 
4068   OopMapSet *oop_maps = new OopMapSet();
4069   OopMap* map = new OopMap(frame_size_in_slots, 0);
4070 
4071   map->set_callee_saved(VMRegImpl::stack2reg(rax_off), rax->as_VMReg());
4072   map->set_callee_saved(VMRegImpl::stack2reg(j_rarg5_off), j_rarg5->as_VMReg());
4073   map->set_callee_saved(VMRegImpl::stack2reg(j_rarg4_off), j_rarg4->as_VMReg());
4074   map->set_callee_saved(VMRegImpl::stack2reg(j_rarg3_off), j_rarg3->as_VMReg());
4075   map->set_callee_saved(VMRegImpl::stack2reg(j_rarg2_off), j_rarg2->as_VMReg());
4076   map->set_callee_saved(VMRegImpl::stack2reg(j_rarg1_off), j_rarg1->as_VMReg());
4077   map->set_callee_saved(VMRegImpl::stack2reg(j_rarg0_off), j_rarg0->as_VMReg());
4078   map->set_callee_saved(VMRegImpl::stack2reg(j_farg0_off), j_farg0->as_VMReg());
4079   map->set_callee_saved(VMRegImpl::stack2reg(j_farg1_off), j_farg1->as_VMReg());
4080   map->set_callee_saved(VMRegImpl::stack2reg(j_farg2_off), j_farg2->as_VMReg());
4081   map->set_callee_saved(VMRegImpl::stack2reg(j_farg3_off), j_farg3->as_VMReg());
4082   map->set_callee_saved(VMRegImpl::stack2reg(j_farg4_off), j_farg4->as_VMReg());
4083   map->set_callee_saved(VMRegImpl::stack2reg(j_farg5_off), j_farg5->as_VMReg());
4084   map->set_callee_saved(VMRegImpl::stack2reg(j_farg6_off), j_farg6->as_VMReg());
4085   map->set_callee_saved(VMRegImpl::stack2reg(j_farg7_off), j_farg7->as_VMReg());
4086 
4087   int start = __ offset();
4088 
4089   __ subptr(rsp, frame_size_in_bytes - 8 /* return address*/);
4090 
4091   __ movptr(Address(rsp, rbp_off * BytesPerInt), rbp);
4092   __ movdbl(Address(rsp, j_farg7_off * BytesPerInt), j_farg7);
4093   __ movdbl(Address(rsp, j_farg6_off * BytesPerInt), j_farg6);
4094   __ movdbl(Address(rsp, j_farg5_off * BytesPerInt), j_farg5);
4095   __ movdbl(Address(rsp, j_farg4_off * BytesPerInt), j_farg4);
4096   __ movdbl(Address(rsp, j_farg3_off * BytesPerInt), j_farg3);
4097   __ movdbl(Address(rsp, j_farg2_off * BytesPerInt), j_farg2);
4098   __ movdbl(Address(rsp, j_farg1_off * BytesPerInt), j_farg1);
4099   __ movdbl(Address(rsp, j_farg0_off * BytesPerInt), j_farg0);
4100 
4101   __ movptr(Address(rsp, j_rarg0_off * BytesPerInt), j_rarg0);
4102   __ movptr(Address(rsp, j_rarg1_off * BytesPerInt), j_rarg1);
4103   __ movptr(Address(rsp, j_rarg2_off * BytesPerInt), j_rarg2);
4104   __ movptr(Address(rsp, j_rarg3_off * BytesPerInt), j_rarg3);
4105   __ movptr(Address(rsp, j_rarg4_off * BytesPerInt), j_rarg4);
4106   __ movptr(Address(rsp, j_rarg5_off * BytesPerInt), j_rarg5);
4107   __ movptr(Address(rsp, rax_off * BytesPerInt), rax);
4108 
4109   int frame_complete = __ offset();
4110 
4111   __ set_last_Java_frame(noreg, noreg, nullptr, rscratch1);
4112 
4113   __ mov(c_rarg0, r15_thread);
4114   __ mov(c_rarg1, rax);
4115 
4116   __ call(RuntimeAddress(destination));
4117 
4118   // Set an oopmap for the call site.
4119 
4120   oop_maps->add_gc_map( __ offset() - start, map);
4121 
4122   // clear last_Java_sp
4123   __ reset_last_Java_frame(false);
4124 
4125   __ movptr(rbp, Address(rsp, rbp_off * BytesPerInt));
4126   __ movdbl(j_farg7, Address(rsp, j_farg7_off * BytesPerInt));
4127   __ movdbl(j_farg6, Address(rsp, j_farg6_off * BytesPerInt));
4128   __ movdbl(j_farg5, Address(rsp, j_farg5_off * BytesPerInt));
4129   __ movdbl(j_farg4, Address(rsp, j_farg4_off * BytesPerInt));
4130   __ movdbl(j_farg3, Address(rsp, j_farg3_off * BytesPerInt));
4131   __ movdbl(j_farg2, Address(rsp, j_farg2_off * BytesPerInt));
4132   __ movdbl(j_farg1, Address(rsp, j_farg1_off * BytesPerInt));
4133   __ movdbl(j_farg0, Address(rsp, j_farg0_off * BytesPerInt));
4134 
4135   __ movptr(j_rarg0, Address(rsp, j_rarg0_off * BytesPerInt));
4136   __ movptr(j_rarg1, Address(rsp, j_rarg1_off * BytesPerInt));
4137   __ movptr(j_rarg2, Address(rsp, j_rarg2_off * BytesPerInt));
4138   __ movptr(j_rarg3, Address(rsp, j_rarg3_off * BytesPerInt));
4139   __ movptr(j_rarg4, Address(rsp, j_rarg4_off * BytesPerInt));
4140   __ movptr(j_rarg5, Address(rsp, j_rarg5_off * BytesPerInt));
4141   __ movptr(rax, Address(rsp, rax_off * BytesPerInt));
4142 
4143   __ addptr(rsp, frame_size_in_bytes-8);
4144 
4145   // check for pending exceptions
4146   Label pending;
4147   __ cmpptr(Address(r15_thread, Thread::pending_exception_offset()), (int32_t)NULL_WORD);
4148   __ jcc(Assembler::notEqual, pending);
4149 
4150   if (has_res) {
4151     __ get_vm_result(rax, r15_thread);
4152   }
4153 
4154   __ ret(0);
4155 
4156   __ bind(pending);
4157 
4158   __ movptr(rax, Address(r15_thread, Thread::pending_exception_offset()));
4159   __ jump(RuntimeAddress(StubRoutines::forward_exception_entry()));
4160 
4161   // -------------
4162   // make sure all code is generated
4163   _masm->flush();
4164 
4165   RuntimeStub* stub = RuntimeStub::new_runtime_stub(name, &buffer, frame_complete, frame_size_in_words, oop_maps, false);
4166   return stub->entry_point();
4167 }
4168 
4169 void StubGenerator::generate_continuation_stubs() {
4170   // Continuation stubs:
4171   StubRoutines::_cont_thaw          = generate_cont_thaw();
4172   StubRoutines::_cont_returnBarrier = generate_cont_returnBarrier();
4173   StubRoutines::_cont_returnBarrierExc = generate_cont_returnBarrier_exception();
4174 
4175   JFR_ONLY(generate_jfr_stubs();)
4176 }
4177 
4178 #if INCLUDE_JFR
4179 void StubGenerator::generate_jfr_stubs() {
4180   StubRoutines::_jfr_write_checkpoint_stub = generate_jfr_write_checkpoint();
4181   StubRoutines::_jfr_write_checkpoint = StubRoutines::_jfr_write_checkpoint_stub->entry_point();
4182   StubRoutines::_jfr_return_lease_stub = generate_jfr_return_lease();
4183   StubRoutines::_jfr_return_lease = StubRoutines::_jfr_return_lease_stub->entry_point();
4184 }
4185 #endif
4186 
4187 void StubGenerator::generate_final_stubs() {
4188   // Generates the rest of stubs and initializes the entry points
< prev index next >