311 __ mov(r19_sender_sp, sp);
312 __ blr(c_rarg4);
313
314 // we do this here because the notify will already have been done
315 // if we get to the next instruction via an exception
316 //
317 // n.b. adding this instruction here affects the calculation of
318 // whether or not a routine returns to the call stub (used when
319 // doing stack walks) since the normal test is to check the return
320 // pc against the address saved below. so we may need to allow for
321 // this extra instruction in the check.
322
323 // save current address for use by exception handling code
324
325 return_address = __ pc();
326
327 // store result depending on type (everything that is not
328 // T_OBJECT, T_LONG, T_FLOAT or T_DOUBLE is treated as T_INT)
329 // n.b. this assumes Java returns an integral result in r0
330 // and a floating result in j_farg0
331 __ ldr(j_rarg2, result);
332 Label is_long, is_float, is_double, exit;
333 __ ldr(j_rarg1, result_type);
334 __ cmp(j_rarg1, (u1)T_OBJECT);
335 __ br(Assembler::EQ, is_long);
336 __ cmp(j_rarg1, (u1)T_LONG);
337 __ br(Assembler::EQ, is_long);
338 __ cmp(j_rarg1, (u1)T_FLOAT);
339 __ br(Assembler::EQ, is_float);
340 __ cmp(j_rarg1, (u1)T_DOUBLE);
341 __ br(Assembler::EQ, is_double);
342
343 // handle T_INT case
344 __ strw(r0, Address(j_rarg2));
345
346 __ BIND(exit);
347
348 // pop parameters
349 __ sub(esp, rfp, -sp_after_call_off * wordSize);
350
351 #ifdef ASSERT
352 // verify that threads correspond
353 {
354 Label L, S;
355 __ ldr(rscratch1, thread);
356 __ cmp(rthread, rscratch1);
357 __ br(Assembler::NE, S);
358 __ get_thread(rscratch1);
359 __ cmp(rthread, rscratch1);
360 __ br(Assembler::EQ, L);
361 __ BIND(S);
362 __ stop("StubRoutines::call_stub: threads must correspond");
363 __ BIND(L);
364 }
376 __ ldp(r26, r25, r26_save);
377 __ ldp(r24, r23, r24_save);
378 __ ldp(r22, r21, r22_save);
379 __ ldp(r20, r19, r20_save);
380
381 // restore fpcr
382 __ ldr(rscratch1, fpcr_save);
383 __ set_fpcr(rscratch1);
384
385 __ ldp(c_rarg0, c_rarg1, call_wrapper);
386 __ ldrw(c_rarg2, result_type);
387 __ ldr(c_rarg3, method);
388 __ ldp(c_rarg4, c_rarg5, entry_point);
389 __ ldp(c_rarg6, c_rarg7, parameter_size);
390
391 // leave frame and return to caller
392 __ leave();
393 __ ret(lr);
394
395 // handle return types different from T_INT
396
397 __ BIND(is_long);
398 __ str(r0, Address(j_rarg2, 0));
399 __ br(Assembler::AL, exit);
400
401 __ BIND(is_float);
402 __ strs(j_farg0, Address(j_rarg2, 0));
403 __ br(Assembler::AL, exit);
404
405 __ BIND(is_double);
406 __ strd(j_farg0, Address(j_rarg2, 0));
407 __ br(Assembler::AL, exit);
408
409 return start;
410 }
411
412 // Return point for a Java call if there's an exception thrown in
413 // Java code. The exception is caught and transformed into a
414 // pending exception stored in JavaThread that can be tested from
415 // within the VM.
416 //
417 // Note: Usually the parameters are removed by the callee. In case
418 // of an exception crossing an activation frame boundary, that is
419 // not the case if the callee is compiled code => need to setup the
420 // rsp.
421 //
422 // r0: exception oop
423
424 address generate_catch_exception() {
425 StubId stub_id = StubId::stubgen_catch_exception_id;
426 StubCodeMark mark(this, stub_id);
2207 // |array_tag| | header_size | element_type | |log2_element_size|
2208 // 32 30 24 16 8 2 0
2209 //
2210 // array_tag: typeArray = 0x3, objArray = 0x2, non-array = 0x0
2211 //
2212
2213 const int lh_offset = in_bytes(Klass::layout_helper_offset());
2214
2215 // Handle objArrays completely differently...
2216 const jint objArray_lh = Klass::array_layout_helper(T_OBJECT);
2217 __ ldrw(lh, Address(scratch_src_klass, lh_offset));
2218 __ movw(rscratch1, objArray_lh);
2219 __ eorw(rscratch2, lh, rscratch1);
2220 __ cbzw(rscratch2, L_objArray);
2221
2222 // if (src->klass() != dst->klass()) return -1;
2223 __ load_klass(rscratch2, dst);
2224 __ eor(rscratch2, rscratch2, scratch_src_klass);
2225 __ cbnz(rscratch2, L_failed);
2226
2227 // if (!src->is_Array()) return -1;
2228 __ tbz(lh, 31, L_failed); // i.e. (lh >= 0)
2229
2230 // At this point, it is known to be a typeArray (array_tag 0x3).
2231 #ifdef ASSERT
2232 {
2233 BLOCK_COMMENT("assert primitive array {");
2234 Label L;
2235 __ movw(rscratch2, Klass::_lh_array_tag_type_value << Klass::_lh_array_tag_shift);
2236 __ cmpw(lh, rscratch2);
2237 __ br(Assembler::GE, L);
2238 __ stop("must be a primitive array");
2239 __ bind(L);
2240 BLOCK_COMMENT("} assert primitive array done");
2241 }
2242 #endif
2243
2244 arraycopy_range_checks(src, src_pos, dst, dst_pos, scratch_length,
2245 rscratch2, L_failed);
2246
10442 gen_cas_entry(MacroAssembler::xword, memory_order_relaxed);
10443
10444 AtomicStubMark mark_cmpxchg_4_release
10445 (_masm, &aarch64_atomic_cmpxchg_4_release_impl);
10446 gen_cas_entry(MacroAssembler::word, memory_order_release);
10447 AtomicStubMark mark_cmpxchg_8_release
10448 (_masm, &aarch64_atomic_cmpxchg_8_release_impl);
10449 gen_cas_entry(MacroAssembler::xword, memory_order_release);
10450
10451 AtomicStubMark mark_cmpxchg_4_seq_cst
10452 (_masm, &aarch64_atomic_cmpxchg_4_seq_cst_impl);
10453 gen_cas_entry(MacroAssembler::word, memory_order_seq_cst);
10454 AtomicStubMark mark_cmpxchg_8_seq_cst
10455 (_masm, &aarch64_atomic_cmpxchg_8_seq_cst_impl);
10456 gen_cas_entry(MacroAssembler::xword, memory_order_seq_cst);
10457
10458 ICache::invalidate_range(first_entry, __ pc() - first_entry);
10459 }
10460 #endif // LINUX
10461
10462 address generate_cont_thaw(Continuation::thaw_kind kind) {
10463 bool return_barrier = Continuation::is_thaw_return_barrier(kind);
10464 bool return_barrier_exception = Continuation::is_thaw_return_barrier_exception(kind);
10465
10466 address start = __ pc();
10467
10468 if (return_barrier) {
10469 __ ldr(rscratch1, Address(rthread, JavaThread::cont_entry_offset()));
10470 __ mov(sp, rscratch1);
10471 }
10472 assert_asm(_masm, (__ ldr(rscratch1, Address(rthread, JavaThread::cont_entry_offset())), __ cmp(sp, rscratch1)), Assembler::EQ, "incorrect sp");
10473
10474 if (return_barrier) {
10475 // preserve possible return value from a method returning to the return barrier
10476 __ fmovd(rscratch1, v0);
10477 __ stp(rscratch1, r0, Address(__ pre(sp, -2 * wordSize)));
10478 }
10479
10480 __ movw(c_rarg1, (return_barrier ? 1 : 0));
10481 __ call_VM_leaf(CAST_FROM_FN_PTR(address, Continuation::prepare_thaw), rthread, c_rarg1);
10482 __ mov(rscratch2, r0); // r0 contains the size of the frames to thaw, 0 if overflow or no more frames
10483
10484 if (return_barrier) {
10485 // restore return value (no safepoint in the call to thaw, so even an oop return value should be OK)
10486 __ ldp(rscratch1, r0, Address(__ post(sp, 2 * wordSize)));
10487 __ fmovd(v0, rscratch1);
10488 }
10489 assert_asm(_masm, (__ ldr(rscratch1, Address(rthread, JavaThread::cont_entry_offset())), __ cmp(sp, rscratch1)), Assembler::EQ, "incorrect sp");
10490
10491
10492 Label thaw_success;
10493 // rscratch2 contains the size of the frames to thaw, 0 if overflow or no more frames
10494 __ cbnz(rscratch2, thaw_success);
10495 __ lea(rscratch1, RuntimeAddress(SharedRuntime::throw_StackOverflowError_entry()));
10496 __ br(rscratch1);
10497 __ bind(thaw_success);
10498
10499 // make room for the thawed frames
10500 __ sub(rscratch1, sp, rscratch2);
10501 __ andr(rscratch1, rscratch1, -16); // align
10502 __ mov(sp, rscratch1);
10503
10504 if (return_barrier) {
10505 // save original return value -- again
10506 __ fmovd(rscratch1, v0);
10507 __ stp(rscratch1, r0, Address(__ pre(sp, -2 * wordSize)));
10508 }
10509
10510 // If we want, we can templatize thaw by kind, and have three different entries
10511 __ movw(c_rarg1, (uint32_t)kind);
10512
10513 __ call_VM_leaf(Continuation::thaw_entry(), rthread, c_rarg1);
10514 __ mov(rscratch2, r0); // r0 is the sp of the yielding frame
10515
10516 if (return_barrier) {
10517 // restore return value (no safepoint in the call to thaw, so even an oop return value should be OK)
10518 __ ldp(rscratch1, r0, Address(__ post(sp, 2 * wordSize)));
10519 __ fmovd(v0, rscratch1);
10520 } else {
10521 __ mov(r0, zr); // return 0 (success) from doYield
10522 }
10523
10524 // we're now on the yield frame (which is in an address above us b/c rsp has been pushed down)
10525 __ sub(sp, rscratch2, 2*wordSize); // now pointing to rfp spill
10526 __ mov(rfp, sp);
10527
10528 if (return_barrier_exception) {
10529 __ ldr(c_rarg1, Address(rfp, wordSize)); // return address
10530 __ authenticate_return_address(c_rarg1);
10531 __ verify_oop(r0);
10532 // save return value containing the exception oop in callee-saved R19
10533 __ mov(r19, r0);
10534
10535 __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::exception_handler_for_return_address), rthread, c_rarg1);
10536
10537 // Reinitialize the ptrue predicate register, in case the external runtime call clobbers ptrue reg, as we may return to SVE compiled code.
10538 // __ reinitialize_ptrue();
10539
11636 // assert(Ra == Pa_base[j], "must be");
11637 // MACC(Ra, Ra, t0, t1, t2);
11638 // }
11639 // iters = (2*len-i)/2;
11640 // assert(iters == len-j, "must be");
11641 // for (; iters--; j++) {
11642 // assert(Rm == Pm_base[j] && Rn == Pn_base[i-j], "must be");
11643 // MACC(Rm, Rn, t0, t1, t2);
11644 // Rm = *++Pm;
11645 // Rn = *--Pn;
11646 // }
11647 // Pm_base[i-len] = t0;
11648 // t0 = t1; t1 = t2; t2 = 0;
11649 // }
11650
11651 // while (t0)
11652 // t0 = sub(Pm_base, Pn_base, t0, len);
11653 // }
11654 };
11655
11656 // Initialization
11657 void generate_preuniverse_stubs() {
11658 // preuniverse stubs are not needed for aarch64
11659 }
11660
11661 void generate_initial_stubs() {
11662 // Generate initial stubs and initializes the entry points
11663
11664 // entry points that exist in all platforms Note: This is code
11665 // that could be shared among different platforms - however the
11666 // benefit seems to be smaller than the disadvantage of having a
11667 // much more complicated generator structure. See also comment in
11668 // stubRoutines.hpp.
11669
11670 StubRoutines::_forward_exception_entry = generate_forward_exception();
11671
11672 StubRoutines::_call_stub_entry =
11673 generate_call_stub(StubRoutines::_call_stub_return_address);
11674
11675 // is referenced by megamorphic call
11684 StubRoutines::_updateBytesCRC32 = generate_updateBytesCRC32();
11685 }
11686
11687 if (UseCRC32CIntrinsics) {
11688 StubRoutines::_updateBytesCRC32C = generate_updateBytesCRC32C();
11689 }
11690
11691 if (vmIntrinsics::is_intrinsic_available(vmIntrinsics::_dsin)) {
11692 StubRoutines::_dsin = generate_dsin_dcos(/* isCos = */ false);
11693 }
11694
11695 if (vmIntrinsics::is_intrinsic_available(vmIntrinsics::_dcos)) {
11696 StubRoutines::_dcos = generate_dsin_dcos(/* isCos = */ true);
11697 }
11698
11699 if (vmIntrinsics::is_intrinsic_available(vmIntrinsics::_float16ToFloat) &&
11700 vmIntrinsics::is_intrinsic_available(vmIntrinsics::_floatToFloat16)) {
11701 StubRoutines::_hf2f = generate_float16ToFloat();
11702 StubRoutines::_f2hf = generate_floatToFloat16();
11703 }
11704 }
11705
11706 void generate_continuation_stubs() {
11707 // Continuation stubs:
11708 StubRoutines::_cont_thaw = generate_cont_thaw();
11709 StubRoutines::_cont_returnBarrier = generate_cont_returnBarrier();
11710 StubRoutines::_cont_returnBarrierExc = generate_cont_returnBarrier_exception();
11711 StubRoutines::_cont_preempt_stub = generate_cont_preempt_stub();
11712 }
11713
11714 void generate_final_stubs() {
11715 // support for verify_oop (must happen after universe_init)
11716 if (VerifyOops) {
11717 StubRoutines::_verify_oop_subroutine_entry = generate_verify_oop();
11718 }
11719
11720 // arraycopy stubs used by compilers
11721 generate_arraycopy_stubs();
11722
11723 StubRoutines::_method_entry_barrier = generate_method_entry_barrier();
|
311 __ mov(r19_sender_sp, sp);
312 __ blr(c_rarg4);
313
314 // we do this here because the notify will already have been done
315 // if we get to the next instruction via an exception
316 //
317 // n.b. adding this instruction here affects the calculation of
318 // whether or not a routine returns to the call stub (used when
319 // doing stack walks) since the normal test is to check the return
320 // pc against the address saved below. so we may need to allow for
321 // this extra instruction in the check.
322
323 // save current address for use by exception handling code
324
325 return_address = __ pc();
326
327 // store result depending on type (everything that is not
328 // T_OBJECT, T_LONG, T_FLOAT or T_DOUBLE is treated as T_INT)
329 // n.b. this assumes Java returns an integral result in r0
330 // and a floating result in j_farg0
331 // All of j_rargN may be used to return inline type fields so be careful
332 // not to clobber those.
333 // SharedRuntime::generate_buffered_inline_type_adapter() knows the register
334 // assignment of Rresult below.
335 Register Rresult = r14, Rresult_type = r15;
336 __ ldr(Rresult, result);
337 Label is_long, is_float, is_double, check_prim, exit;
338 __ ldr(Rresult_type, result_type);
339 __ cmp(Rresult_type, (u1)T_OBJECT);
340 __ br(Assembler::EQ, check_prim);
341 __ cmp(Rresult_type, (u1)T_LONG);
342 __ br(Assembler::EQ, is_long);
343 __ cmp(Rresult_type, (u1)T_FLOAT);
344 __ br(Assembler::EQ, is_float);
345 __ cmp(Rresult_type, (u1)T_DOUBLE);
346 __ br(Assembler::EQ, is_double);
347
348 // handle T_INT case
349 __ strw(r0, Address(Rresult));
350
351 __ BIND(exit);
352
353 // pop parameters
354 __ sub(esp, rfp, -sp_after_call_off * wordSize);
355
356 #ifdef ASSERT
357 // verify that threads correspond
358 {
359 Label L, S;
360 __ ldr(rscratch1, thread);
361 __ cmp(rthread, rscratch1);
362 __ br(Assembler::NE, S);
363 __ get_thread(rscratch1);
364 __ cmp(rthread, rscratch1);
365 __ br(Assembler::EQ, L);
366 __ BIND(S);
367 __ stop("StubRoutines::call_stub: threads must correspond");
368 __ BIND(L);
369 }
381 __ ldp(r26, r25, r26_save);
382 __ ldp(r24, r23, r24_save);
383 __ ldp(r22, r21, r22_save);
384 __ ldp(r20, r19, r20_save);
385
386 // restore fpcr
387 __ ldr(rscratch1, fpcr_save);
388 __ set_fpcr(rscratch1);
389
390 __ ldp(c_rarg0, c_rarg1, call_wrapper);
391 __ ldrw(c_rarg2, result_type);
392 __ ldr(c_rarg3, method);
393 __ ldp(c_rarg4, c_rarg5, entry_point);
394 __ ldp(c_rarg6, c_rarg7, parameter_size);
395
396 // leave frame and return to caller
397 __ leave();
398 __ ret(lr);
399
400 // handle return types different from T_INT
401 __ BIND(check_prim);
402 if (InlineTypeReturnedAsFields) {
403 // Check for scalarized return value
404 __ tbz(r0, 0, is_long);
405 // Load pack handler address
406 __ andr(rscratch1, r0, -2);
407 __ ldr(rscratch1, Address(rscratch1, InlineKlass::adr_members_offset()));
408 __ ldr(rscratch1, Address(rscratch1, InlineKlass::pack_handler_jobject_offset()));
409 __ blr(rscratch1);
410 __ b(exit);
411 }
412
413 __ BIND(is_long);
414 __ str(r0, Address(Rresult, 0));
415 __ br(Assembler::AL, exit);
416
417 __ BIND(is_float);
418 __ strs(j_farg0, Address(Rresult, 0));
419 __ br(Assembler::AL, exit);
420
421 __ BIND(is_double);
422 __ strd(j_farg0, Address(Rresult, 0));
423 __ br(Assembler::AL, exit);
424
425 return start;
426 }
427
428 // Return point for a Java call if there's an exception thrown in
429 // Java code. The exception is caught and transformed into a
430 // pending exception stored in JavaThread that can be tested from
431 // within the VM.
432 //
433 // Note: Usually the parameters are removed by the callee. In case
434 // of an exception crossing an activation frame boundary, that is
435 // not the case if the callee is compiled code => need to setup the
436 // rsp.
437 //
438 // r0: exception oop
439
440 address generate_catch_exception() {
441 StubId stub_id = StubId::stubgen_catch_exception_id;
442 StubCodeMark mark(this, stub_id);
2223 // |array_tag| | header_size | element_type | |log2_element_size|
2224 // 32 30 24 16 8 2 0
2225 //
2226 // array_tag: typeArray = 0x3, objArray = 0x2, non-array = 0x0
2227 //
2228
2229 const int lh_offset = in_bytes(Klass::layout_helper_offset());
2230
2231 // Handle objArrays completely differently...
2232 const jint objArray_lh = Klass::array_layout_helper(T_OBJECT);
2233 __ ldrw(lh, Address(scratch_src_klass, lh_offset));
2234 __ movw(rscratch1, objArray_lh);
2235 __ eorw(rscratch2, lh, rscratch1);
2236 __ cbzw(rscratch2, L_objArray);
2237
2238 // if (src->klass() != dst->klass()) return -1;
2239 __ load_klass(rscratch2, dst);
2240 __ eor(rscratch2, rscratch2, scratch_src_klass);
2241 __ cbnz(rscratch2, L_failed);
2242
2243 // Check for flat inline type array -> return -1
2244 __ test_flat_array_oop(src, rscratch2, L_failed);
2245
2246 // Check for null-free (non-flat) inline type array -> handle as object array
2247 __ test_null_free_array_oop(src, rscratch2, L_objArray);
2248
2249 // if (!src->is_Array()) return -1;
2250 __ tbz(lh, 31, L_failed); // i.e. (lh >= 0)
2251
2252 // At this point, it is known to be a typeArray (array_tag 0x3).
2253 #ifdef ASSERT
2254 {
2255 BLOCK_COMMENT("assert primitive array {");
2256 Label L;
2257 __ movw(rscratch2, Klass::_lh_array_tag_type_value << Klass::_lh_array_tag_shift);
2258 __ cmpw(lh, rscratch2);
2259 __ br(Assembler::GE, L);
2260 __ stop("must be a primitive array");
2261 __ bind(L);
2262 BLOCK_COMMENT("} assert primitive array done");
2263 }
2264 #endif
2265
2266 arraycopy_range_checks(src, src_pos, dst, dst_pos, scratch_length,
2267 rscratch2, L_failed);
2268
10464 gen_cas_entry(MacroAssembler::xword, memory_order_relaxed);
10465
10466 AtomicStubMark mark_cmpxchg_4_release
10467 (_masm, &aarch64_atomic_cmpxchg_4_release_impl);
10468 gen_cas_entry(MacroAssembler::word, memory_order_release);
10469 AtomicStubMark mark_cmpxchg_8_release
10470 (_masm, &aarch64_atomic_cmpxchg_8_release_impl);
10471 gen_cas_entry(MacroAssembler::xword, memory_order_release);
10472
10473 AtomicStubMark mark_cmpxchg_4_seq_cst
10474 (_masm, &aarch64_atomic_cmpxchg_4_seq_cst_impl);
10475 gen_cas_entry(MacroAssembler::word, memory_order_seq_cst);
10476 AtomicStubMark mark_cmpxchg_8_seq_cst
10477 (_masm, &aarch64_atomic_cmpxchg_8_seq_cst_impl);
10478 gen_cas_entry(MacroAssembler::xword, memory_order_seq_cst);
10479
10480 ICache::invalidate_range(first_entry, __ pc() - first_entry);
10481 }
10482 #endif // LINUX
10483
10484 static void save_return_registers(MacroAssembler* masm) {
10485 if (InlineTypeReturnedAsFields) {
10486 masm->push(RegSet::range(r0, r7), sp);
10487 masm->sub(sp, sp, 4 * wordSize);
10488 masm->st1(v0, v1, v2, v3, masm->T1D, Address(sp));
10489 masm->sub(sp, sp, 4 * wordSize);
10490 masm->st1(v4, v5, v6, v7, masm->T1D, Address(sp));
10491 } else {
10492 masm->fmovd(rscratch1, v0);
10493 masm->stp(rscratch1, r0, Address(masm->pre(sp, -2 * wordSize)));
10494 }
10495 }
10496
10497 static void restore_return_registers(MacroAssembler* masm) {
10498 if (InlineTypeReturnedAsFields) {
10499 masm->ld1(v4, v5, v6, v7, masm->T1D, Address(masm->post(sp, 4 * wordSize)));
10500 masm->ld1(v0, v1, v2, v3, masm->T1D, Address(masm->post(sp, 4 * wordSize)));
10501 masm->pop(RegSet::range(r0, r7), sp);
10502 } else {
10503 masm->ldp(rscratch1, r0, Address(masm->post(sp, 2 * wordSize)));
10504 masm->fmovd(v0, rscratch1);
10505 }
10506 }
10507
10508 address generate_cont_thaw(Continuation::thaw_kind kind) {
10509 bool return_barrier = Continuation::is_thaw_return_barrier(kind);
10510 bool return_barrier_exception = Continuation::is_thaw_return_barrier_exception(kind);
10511
10512 address start = __ pc();
10513
10514 if (return_barrier) {
10515 __ ldr(rscratch1, Address(rthread, JavaThread::cont_entry_offset()));
10516 __ mov(sp, rscratch1);
10517 }
10518 assert_asm(_masm, (__ ldr(rscratch1, Address(rthread, JavaThread::cont_entry_offset())), __ cmp(sp, rscratch1)), Assembler::EQ, "incorrect sp");
10519
10520 if (return_barrier) {
10521 // preserve possible return value from a method returning to the return barrier
10522 save_return_registers(_masm);
10523 }
10524
10525 __ movw(c_rarg1, (return_barrier ? 1 : 0));
10526 __ call_VM_leaf(CAST_FROM_FN_PTR(address, Continuation::prepare_thaw), rthread, c_rarg1);
10527 __ mov(rscratch2, r0); // r0 contains the size of the frames to thaw, 0 if overflow or no more frames
10528
10529 if (return_barrier) {
10530 // restore return value (no safepoint in the call to thaw, so even an oop return value should be OK)
10531 restore_return_registers(_masm);
10532 }
10533 assert_asm(_masm, (__ ldr(rscratch1, Address(rthread, JavaThread::cont_entry_offset())), __ cmp(sp, rscratch1)), Assembler::EQ, "incorrect sp");
10534
10535
10536 Label thaw_success;
10537 // rscratch2 contains the size of the frames to thaw, 0 if overflow or no more frames
10538 __ cbnz(rscratch2, thaw_success);
10539 __ lea(rscratch1, RuntimeAddress(SharedRuntime::throw_StackOverflowError_entry()));
10540 __ br(rscratch1);
10541 __ bind(thaw_success);
10542
10543 // make room for the thawed frames
10544 __ sub(rscratch1, sp, rscratch2);
10545 __ andr(rscratch1, rscratch1, -16); // align
10546 __ mov(sp, rscratch1);
10547
10548 if (return_barrier) {
10549 // save original return value -- again
10550 save_return_registers(_masm);
10551 }
10552
10553 // If we want, we can templatize thaw by kind, and have three different entries
10554 __ movw(c_rarg1, (uint32_t)kind);
10555
10556 __ call_VM_leaf(Continuation::thaw_entry(), rthread, c_rarg1);
10557 __ mov(rscratch2, r0); // r0 is the sp of the yielding frame
10558
10559 if (return_barrier) {
10560 // restore return value (no safepoint in the call to thaw, so even an oop return value should be OK)
10561 restore_return_registers(_masm);
10562 } else {
10563 __ mov(r0, zr); // return 0 (success) from doYield
10564 }
10565
10566 // we're now on the yield frame (which is in an address above us b/c rsp has been pushed down)
10567 __ sub(sp, rscratch2, 2*wordSize); // now pointing to rfp spill
10568 __ mov(rfp, sp);
10569
10570 if (return_barrier_exception) {
10571 __ ldr(c_rarg1, Address(rfp, wordSize)); // return address
10572 __ authenticate_return_address(c_rarg1);
10573 __ verify_oop(r0);
10574 // save return value containing the exception oop in callee-saved R19
10575 __ mov(r19, r0);
10576
10577 __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::exception_handler_for_return_address), rthread, c_rarg1);
10578
10579 // Reinitialize the ptrue predicate register, in case the external runtime call clobbers ptrue reg, as we may return to SVE compiled code.
10580 // __ reinitialize_ptrue();
10581
11678 // assert(Ra == Pa_base[j], "must be");
11679 // MACC(Ra, Ra, t0, t1, t2);
11680 // }
11681 // iters = (2*len-i)/2;
11682 // assert(iters == len-j, "must be");
11683 // for (; iters--; j++) {
11684 // assert(Rm == Pm_base[j] && Rn == Pn_base[i-j], "must be");
11685 // MACC(Rm, Rn, t0, t1, t2);
11686 // Rm = *++Pm;
11687 // Rn = *--Pn;
11688 // }
11689 // Pm_base[i-len] = t0;
11690 // t0 = t1; t1 = t2; t2 = 0;
11691 // }
11692
11693 // while (t0)
11694 // t0 = sub(Pm_base, Pn_base, t0, len);
11695 // }
11696 };
11697
11698 // Call here from the interpreter or compiled code to either load
11699 // multiple returned values from the inline type instance being
11700 // returned to registers or to store returned values to a newly
11701 // allocated inline type instance.
11702 address generate_return_value_stub(address destination, const char* name, bool has_res) {
11703 // We need to save all registers the calling convention may use so
11704 // the runtime calls read or update those registers. This needs to
11705 // be in sync with SharedRuntime::java_return_convention().
11706 // n.b. aarch64 asserts that frame::arg_reg_save_area_bytes == 0
11707 enum layout {
11708 j_rarg7_off = 0, j_rarg7_2, // j_rarg7 is r0
11709 j_rarg6_off, j_rarg6_2,
11710 j_rarg5_off, j_rarg5_2,
11711 j_rarg4_off, j_rarg4_2,
11712 j_rarg3_off, j_rarg3_2,
11713 j_rarg2_off, j_rarg2_2,
11714 j_rarg1_off, j_rarg1_2,
11715 j_rarg0_off, j_rarg0_2,
11716
11717 j_farg7_off, j_farg7_2,
11718 j_farg6_off, j_farg6_2,
11719 j_farg5_off, j_farg5_2,
11720 j_farg4_off, j_farg4_2,
11721 j_farg3_off, j_farg3_2,
11722 j_farg2_off, j_farg2_2,
11723 j_farg1_off, j_farg1_2,
11724 j_farg0_off, j_farg0_2,
11725
11726 rfp_off, rfp_off2,
11727 return_off, return_off2,
11728
11729 framesize // inclusive of return address
11730 };
11731
11732 CodeBuffer code(name, 512, 64);
11733 MacroAssembler* masm = new MacroAssembler(&code);
11734
11735 int frame_size_in_bytes = align_up(framesize*BytesPerInt, 16);
11736 assert(frame_size_in_bytes == framesize*BytesPerInt, "misaligned");
11737 int frame_size_in_slots = frame_size_in_bytes / BytesPerInt;
11738 int frame_size_in_words = frame_size_in_bytes / wordSize;
11739
11740 OopMapSet* oop_maps = new OopMapSet();
11741 OopMap* map = new OopMap(frame_size_in_slots, 0);
11742
11743 map->set_callee_saved(VMRegImpl::stack2reg(j_rarg7_off), j_rarg7->as_VMReg());
11744 map->set_callee_saved(VMRegImpl::stack2reg(j_rarg6_off), j_rarg6->as_VMReg());
11745 map->set_callee_saved(VMRegImpl::stack2reg(j_rarg5_off), j_rarg5->as_VMReg());
11746 map->set_callee_saved(VMRegImpl::stack2reg(j_rarg4_off), j_rarg4->as_VMReg());
11747 map->set_callee_saved(VMRegImpl::stack2reg(j_rarg3_off), j_rarg3->as_VMReg());
11748 map->set_callee_saved(VMRegImpl::stack2reg(j_rarg2_off), j_rarg2->as_VMReg());
11749 map->set_callee_saved(VMRegImpl::stack2reg(j_rarg1_off), j_rarg1->as_VMReg());
11750 map->set_callee_saved(VMRegImpl::stack2reg(j_rarg0_off), j_rarg0->as_VMReg());
11751
11752 map->set_callee_saved(VMRegImpl::stack2reg(j_farg0_off), j_farg0->as_VMReg());
11753 map->set_callee_saved(VMRegImpl::stack2reg(j_farg1_off), j_farg1->as_VMReg());
11754 map->set_callee_saved(VMRegImpl::stack2reg(j_farg2_off), j_farg2->as_VMReg());
11755 map->set_callee_saved(VMRegImpl::stack2reg(j_farg3_off), j_farg3->as_VMReg());
11756 map->set_callee_saved(VMRegImpl::stack2reg(j_farg4_off), j_farg4->as_VMReg());
11757 map->set_callee_saved(VMRegImpl::stack2reg(j_farg5_off), j_farg5->as_VMReg());
11758 map->set_callee_saved(VMRegImpl::stack2reg(j_farg6_off), j_farg6->as_VMReg());
11759 map->set_callee_saved(VMRegImpl::stack2reg(j_farg7_off), j_farg7->as_VMReg());
11760
11761 address start = __ pc();
11762
11763 __ enter(); // Save FP and LR before call
11764
11765 __ stpd(j_farg1, j_farg0, Address(__ pre(sp, -2 * wordSize)));
11766 __ stpd(j_farg3, j_farg2, Address(__ pre(sp, -2 * wordSize)));
11767 __ stpd(j_farg5, j_farg4, Address(__ pre(sp, -2 * wordSize)));
11768 __ stpd(j_farg7, j_farg6, Address(__ pre(sp, -2 * wordSize)));
11769
11770 __ stp(j_rarg1, j_rarg0, Address(__ pre(sp, -2 * wordSize)));
11771 __ stp(j_rarg3, j_rarg2, Address(__ pre(sp, -2 * wordSize)));
11772 __ stp(j_rarg5, j_rarg4, Address(__ pre(sp, -2 * wordSize)));
11773 __ stp(j_rarg7, j_rarg6, Address(__ pre(sp, -2 * wordSize)));
11774
11775 int frame_complete = __ offset();
11776
11777 // Set up last_Java_sp and last_Java_fp
11778 address the_pc = __ pc();
11779 __ set_last_Java_frame(sp, noreg, the_pc, rscratch1);
11780
11781 // Call runtime
11782 __ mov(c_rarg1, r0);
11783 __ mov(c_rarg0, rthread);
11784
11785 __ mov(rscratch1, destination);
11786 __ blr(rscratch1);
11787
11788 oop_maps->add_gc_map(the_pc - start, map);
11789
11790 __ reset_last_Java_frame(false);
11791
11792 __ ldp(j_rarg7, j_rarg6, Address(__ post(sp, 2 * wordSize)));
11793 __ ldp(j_rarg5, j_rarg4, Address(__ post(sp, 2 * wordSize)));
11794 __ ldp(j_rarg3, j_rarg2, Address(__ post(sp, 2 * wordSize)));
11795 __ ldp(j_rarg1, j_rarg0, Address(__ post(sp, 2 * wordSize)));
11796
11797 __ ldpd(j_farg7, j_farg6, Address(__ post(sp, 2 * wordSize)));
11798 __ ldpd(j_farg5, j_farg4, Address(__ post(sp, 2 * wordSize)));
11799 __ ldpd(j_farg3, j_farg2, Address(__ post(sp, 2 * wordSize)));
11800 __ ldpd(j_farg1, j_farg0, Address(__ post(sp, 2 * wordSize)));
11801
11802 __ leave();
11803
11804 // check for pending exceptions
11805 Label pending;
11806 __ ldr(rscratch1, Address(rthread, in_bytes(Thread::pending_exception_offset())));
11807 __ cbnz(rscratch1, pending);
11808
11809 if (has_res) {
11810 __ get_vm_result_oop(r0, rthread);
11811 }
11812
11813 __ ret(lr);
11814
11815 __ bind(pending);
11816 __ far_jump(RuntimeAddress(StubRoutines::forward_exception_entry()));
11817
11818 // -------------
11819 // make sure all code is generated
11820 masm->flush();
11821
11822 RuntimeStub* stub = RuntimeStub::new_runtime_stub(name, &code, frame_complete, frame_size_in_words, oop_maps, false);
11823 return stub->entry_point();
11824 }
11825
11826 // Initialization
11827 void generate_preuniverse_stubs() {
11828 // preuniverse stubs are not needed for aarch64
11829 }
11830
11831 void generate_initial_stubs() {
11832 // Generate initial stubs and initializes the entry points
11833
11834 // entry points that exist in all platforms Note: This is code
11835 // that could be shared among different platforms - however the
11836 // benefit seems to be smaller than the disadvantage of having a
11837 // much more complicated generator structure. See also comment in
11838 // stubRoutines.hpp.
11839
11840 StubRoutines::_forward_exception_entry = generate_forward_exception();
11841
11842 StubRoutines::_call_stub_entry =
11843 generate_call_stub(StubRoutines::_call_stub_return_address);
11844
11845 // is referenced by megamorphic call
11854 StubRoutines::_updateBytesCRC32 = generate_updateBytesCRC32();
11855 }
11856
11857 if (UseCRC32CIntrinsics) {
11858 StubRoutines::_updateBytesCRC32C = generate_updateBytesCRC32C();
11859 }
11860
11861 if (vmIntrinsics::is_intrinsic_available(vmIntrinsics::_dsin)) {
11862 StubRoutines::_dsin = generate_dsin_dcos(/* isCos = */ false);
11863 }
11864
11865 if (vmIntrinsics::is_intrinsic_available(vmIntrinsics::_dcos)) {
11866 StubRoutines::_dcos = generate_dsin_dcos(/* isCos = */ true);
11867 }
11868
11869 if (vmIntrinsics::is_intrinsic_available(vmIntrinsics::_float16ToFloat) &&
11870 vmIntrinsics::is_intrinsic_available(vmIntrinsics::_floatToFloat16)) {
11871 StubRoutines::_hf2f = generate_float16ToFloat();
11872 StubRoutines::_f2hf = generate_floatToFloat16();
11873 }
11874
11875 if (InlineTypeReturnedAsFields) {
11876 StubRoutines::_load_inline_type_fields_in_regs =
11877 generate_return_value_stub(CAST_FROM_FN_PTR(address, SharedRuntime::load_inline_type_fields_in_regs), "load_inline_type_fields_in_regs", false);
11878 StubRoutines::_store_inline_type_fields_to_buf =
11879 generate_return_value_stub(CAST_FROM_FN_PTR(address, SharedRuntime::store_inline_type_fields_to_buf), "store_inline_type_fields_to_buf", true);
11880 }
11881
11882 }
11883
11884 void generate_continuation_stubs() {
11885 // Continuation stubs:
11886 StubRoutines::_cont_thaw = generate_cont_thaw();
11887 StubRoutines::_cont_returnBarrier = generate_cont_returnBarrier();
11888 StubRoutines::_cont_returnBarrierExc = generate_cont_returnBarrier_exception();
11889 StubRoutines::_cont_preempt_stub = generate_cont_preempt_stub();
11890 }
11891
11892 void generate_final_stubs() {
11893 // support for verify_oop (must happen after universe_init)
11894 if (VerifyOops) {
11895 StubRoutines::_verify_oop_subroutine_entry = generate_verify_oop();
11896 }
11897
11898 // arraycopy stubs used by compilers
11899 generate_arraycopy_stubs();
11900
11901 StubRoutines::_method_entry_barrier = generate_method_entry_barrier();
|