@@ -978,36 +978,23 @@ void MacroAssembler::li(Register Rd, int64_t imm) {
978978 }
979979}
980980
981+ void MacroAssembler::load_link_jump (const address source, Register temp) {
982+ assert (temp != noreg && temp != x0, " expecting a register" );
983+ assert_cond (source != nullptr );
984+ int64_t distance = source - pc ();
985+ assert (is_simm32 (distance), " Must be" );
986+ auipc (temp, (int32_t )distance + 0x800 );
987+ ld (temp, Address (temp, ((int32_t )distance << 20 ) >> 20 ));
988+ jalr (temp);
989+ }
990+
981991void MacroAssembler::jump_link (const address dest, Register temp) {
992+ assert (UseTrampolines, " Must be" );
982993 assert_cond (dest != nullptr );
983994 int64_t distance = dest - pc ();
984- if (is_simm21 (distance) && ((distance % 2 ) == 0 )) {
985- Assembler::jal (x1, distance);
986- } else {
987- assert (temp != noreg && temp != x0, " expecting a register" );
988- int32_t offset = 0 ;
989- la (temp, dest, offset);
990- jalr (temp, offset);
991- }
992- }
993-
994- void MacroAssembler::jump_link (const Address &adr, Register temp) {
995- switch (adr.getMode ()) {
996- case Address::literal: {
997- relocate (adr.rspec (), [&] {
998- jump_link (adr.target (), temp);
999- });
1000- break ;
1001- }
1002- case Address::base_plus_offset: {
1003- int32_t offset = ((int32_t )adr.offset () << 20 ) >> 20 ;
1004- la (temp, Address (adr.base (), adr.offset () - offset));
1005- jalr (temp, offset);
1006- break ;
1007- }
1008- default :
1009- ShouldNotReachHere ();
1010- }
995+ assert (is_simm21 (distance), " Must be" );
996+ assert ((distance % 2 ) == 0 , " Must be" );
997+ jal (x1, distance);
1011998}
1012999
10131000void MacroAssembler::j (const address dest, Register temp) {
@@ -3941,15 +3928,7 @@ bool MacroAssembler::lookup_secondary_supers_table(Register r_sub_klass,
39413928 // The next slot to be inspected, by the stub we're about to call,
39423929 // is secondary_supers[r_array_index]. Bits 0 and 1 in the bitmap
39433930 // have been checked.
3944- Address stub = RuntimeAddress (StubRoutines::lookup_secondary_supers_table_slow_path_stub ());
3945- if (stub_is_near) {
3946- jump_link (stub, t0);
3947- } else {
3948- address call = trampoline_call (stub);
3949- if (call == nullptr ) {
3950- return false ; // trampoline allocation failed
3951- }
3952- }
3931+ rt_call (StubRoutines::lookup_secondary_supers_table_slow_path_stub ());
39533932
39543933 BLOCK_COMMENT (" } lookup_secondary_supers_table" );
39553934
@@ -4258,12 +4237,42 @@ address MacroAssembler::trampoline_call(Address entry) {
42584237 return call_pc;
42594238}
42604239
4240+ address MacroAssembler::load_and_call (Address entry) {
4241+ assert (entry.rspec ().type () == relocInfo::runtime_call_type ||
4242+ entry.rspec ().type () == relocInfo::opt_virtual_call_type ||
4243+ entry.rspec ().type () == relocInfo::static_call_type ||
4244+ entry.rspec ().type () == relocInfo::virtual_call_type, " wrong reloc type" );
4245+
4246+ address target = entry.target ();
4247+
4248+ if (!in_scratch_emit_size ()) {
4249+ address stub = emit_address_stub (offset (), target);
4250+ if (stub == nullptr ) {
4251+ postcond (pc () == badAddress);
4252+ return nullptr ; // CodeCache is full
4253+ }
4254+ }
4255+
4256+ address call_pc = pc ();
4257+ #ifdef ASSERT
4258+ if (entry.rspec ().type () != relocInfo::runtime_call_type) {
4259+ assert_alignment (call_pc);
4260+ }
4261+ #endif
4262+ relocate (entry.rspec (), [&] {
4263+ load_link_jump (target);
4264+ });
4265+
4266+ postcond (pc () != badAddress);
4267+ return call_pc;
4268+ }
4269+
42614270address MacroAssembler::ic_call (address entry, jint method_index) {
42624271 RelocationHolder rh = virtual_call_Relocation::spec (pc (), method_index);
42634272 IncompressibleRegion ir (this ); // relocations
42644273 movptr (t1, (address)Universe::non_oop_word (), t0);
42654274 assert_cond (entry != nullptr );
4266- return trampoline_call (Address (entry, rh));
4275+ return reloc_call (Address (entry, rh));
42674276}
42684277
42694278int MacroAssembler::ic_check_size () {
@@ -4308,6 +4317,34 @@ int MacroAssembler::ic_check(int end_alignment) {
43084317 return uep_offset;
43094318}
43104319
4320+ address MacroAssembler::emit_address_stub (int insts_call_instruction_offset, address dest) {
4321+ address stub = start_a_stub (max_reloc_call_stub_size ());
4322+ if (stub == nullptr ) {
4323+ return nullptr ; // CodeBuffer::expand failed
4324+ }
4325+
4326+ // We are always 4-byte aligned here.
4327+ assert_alignment (pc ());
4328+
4329+ // Make sure the address of destination 8-byte aligned.
4330+ align (wordSize, 0 );
4331+
4332+ RelocationHolder rh = trampoline_stub_Relocation::spec (code ()->insts ()->start () +
4333+ insts_call_instruction_offset);
4334+ const int stub_start_offset = offset ();
4335+ relocate (rh, [&] {
4336+ assert (offset () - stub_start_offset == 0 ,
4337+ " %ld - %ld == %ld : should be" , (long )offset (), (long )stub_start_offset, (long )0 );
4338+ assert (offset () % wordSize == 0 , " bad alignment" );
4339+ emit_int64 ((int64_t )dest);
4340+ });
4341+
4342+ const address stub_start_addr = addr_at (stub_start_offset);
4343+ end_a_stub ();
4344+
4345+ return stub_start_addr;
4346+ }
4347+
43114348// Emit a trampoline stub for a call to a target which is too far away.
43124349//
43134350// code sequences:
@@ -4322,11 +4359,13 @@ int MacroAssembler::ic_check(int end_alignment) {
43224359address MacroAssembler::emit_trampoline_stub (int insts_call_instruction_offset,
43234360 address dest) {
43244361 // Max stub size: alignment nop, TrampolineStub.
4325- address stub = start_a_stub (max_trampoline_stub_size ());
4362+ address stub = start_a_stub (max_reloc_call_stub_size ());
43264363 if (stub == nullptr ) {
43274364 return nullptr ; // CodeBuffer::expand failed
43284365 }
43294366
4367+ assert (UseTrampolines, " Must be using trampos." );
4368+
43304369 // We are always 4-byte aligned here.
43314370 assert_alignment (pc ());
43324371
@@ -4335,7 +4374,7 @@ address MacroAssembler::emit_trampoline_stub(int insts_call_instruction_offset,
43354374 // instructions code-section.
43364375
43374376 // Make sure the address of destination 8-byte aligned after 3 instructions.
4338- align (wordSize, MacroAssembler::trampoline_stub_data_offset );
4377+ align (wordSize, MacroAssembler::NativeShortCall::trampoline_data_offset );
43394378
43404379 RelocationHolder rh = trampoline_stub_Relocation::spec (code ()->insts ()->start () +
43414380 insts_call_instruction_offset);
@@ -4348,23 +4387,25 @@ address MacroAssembler::emit_trampoline_stub(int insts_call_instruction_offset,
43484387 ld (t0, target); // auipc + ld
43494388 jr (t0); // jalr
43504389 bind (target);
4351- assert (offset () - stub_start_offset == MacroAssembler::trampoline_stub_data_offset ,
4390+ assert (offset () - stub_start_offset == MacroAssembler::NativeShortCall::trampoline_data_offset ,
43524391 " should be" );
43534392 assert (offset () % wordSize == 0 , " bad alignment" );
43544393 emit_int64 ((int64_t )dest);
43554394 });
43564395
43574396 const address stub_start_addr = addr_at (stub_start_offset);
43584397
4359- assert (MacroAssembler::is_trampoline_stub_at (stub_start_addr), " doesn't look like a trampoline" );
4360-
43614398 end_a_stub ();
4399+
43624400 return stub_start_addr;
43634401}
43644402
4365- int MacroAssembler::max_trampoline_stub_size () {
4403+ int MacroAssembler::max_reloc_call_stub_size () {
43664404 // Max stub size: alignment nop, TrampolineStub.
4367- return MacroAssembler::instruction_size + MacroAssembler::trampoline_stub_instruction_size;
4405+ if (UseTrampolines) {
4406+ return instruction_size + MacroAssembler::NativeShortCall::trampoline_size;
4407+ }
4408+ return instruction_size + wordSize;
43684409}
43694410
43704411int MacroAssembler::static_call_stub_size () {
@@ -5083,14 +5124,14 @@ address MacroAssembler::zero_words(Register ptr, Register cnt) {
50835124 RuntimeAddress zero_blocks (StubRoutines::riscv::zero_blocks ());
50845125 assert (zero_blocks.target () != nullptr , " zero_blocks stub has not been generated" );
50855126 if (StubRoutines::riscv::complete ()) {
5086- address tpc = trampoline_call (zero_blocks);
5127+ address tpc = reloc_call (zero_blocks);
50875128 if (tpc == nullptr ) {
50885129 DEBUG_ONLY (reset_labels (around));
50895130 postcond (pc () == badAddress);
50905131 return nullptr ;
50915132 }
50925133 } else {
5093- jump_link (zero_blocks, t0 );
5134+ rt_call (zero_blocks. target () );
50945135 }
50955136 }
50965137 bind (around);
0 commit comments