Skip to content

Commit cb37282

Browse files
eastigsimonis
authored andcommitted
8291752: AArch64: Remove check_emit_size parameter from trampoline_call
Reviewed-by: kvn, aph
1 parent 37d3146 commit cb37282

5 files changed

+33
-24
lines changed

src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "asm/assembler.hpp"
2727
#include "asm/assembler.inline.hpp"
2828
#include "opto/c2_MacroAssembler.hpp"
29+
#include "opto/compile.hpp"
2930
#include "opto/intrinsicnode.hpp"
3031
#include "opto/matcher.hpp"
3132
#include "opto/output.hpp"
@@ -1654,3 +1655,14 @@ void C2_MacroAssembler::vector_round_sve(FloatRegister dst, FloatRegister src, F
16541655
sve_fcvtzs(dst, T, ptrue, dst, T);
16551656
// result in dst
16561657
}
1658+
1659+
bool C2_MacroAssembler::in_scratch_emit_size() {
1660+
if (ciEnv::current()->task() != NULL) {
1661+
PhaseOutput* phase_output = Compile::current()->output();
1662+
if (phase_output != NULL && phase_output->in_scratch_emit_size()) {
1663+
return true;
1664+
}
1665+
}
1666+
return MacroAssembler::in_scratch_emit_size();
1667+
}
1668+

src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.hpp

+4
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
2727

2828
// C2_MacroAssembler contains high-level macros for C2
2929

30+
private:
31+
// Return true if the phase output is in the scratch emit size mode.
32+
virtual bool in_scratch_emit_size() override;
33+
3034
public:
3135
void emit_entry_barrier_stub(C2EntryBarrierStub* stub);
3236
static int entry_barrier_stub_size();

src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp

+10-21
Original file line numberDiff line numberDiff line change
@@ -851,18 +851,19 @@ void MacroAssembler::call_VM_helper(Register oop_result, address entry_point, in
851851

852852
// Maybe emit a call via a trampoline. If the code cache is small
853853
// trampolines won't be emitted.
854-
address MacroAssembler::trampoline_call(Address entry, CodeBuffer* cbuf,
855-
bool check_emit_size) {
854+
address MacroAssembler::trampoline_call(Address entry, CodeBuffer* cbuf) {
856855
assert(entry.rspec().type() == relocInfo::runtime_call_type
857856
|| entry.rspec().type() == relocInfo::opt_virtual_call_type
858857
|| entry.rspec().type() == relocInfo::static_call_type
859858
|| entry.rspec().type() == relocInfo::virtual_call_type, "wrong reloc type");
860859

860+
address target = entry.target();
861+
862+
// We might need a trampoline if branches are far.
861863
bool need_trampoline = far_branches();
862-
if (!need_trampoline && entry.rspec().type() == relocInfo::runtime_call_type && !CodeCache::contains(entry.target())) {
864+
if (!need_trampoline && entry.rspec().type() == relocInfo::runtime_call_type && !CodeCache::contains(target)) {
863865
// If it is a runtime call of an address outside small CodeCache,
864866
// we need to check whether it is in range.
865-
address target = entry.target();
866867
assert(target < CodeCache::low_bound() || target >= CodeCache::high_bound(), "target is inside CodeCache");
867868
// Case 1: -------T-------L====CodeCache====H-------
868869
// ^-------longest branch---|
@@ -873,35 +874,23 @@ address MacroAssembler::trampoline_call(Address entry, CodeBuffer* cbuf,
873874
need_trampoline = !reachable_from_branch_at(longest_branch_start, target);
874875
}
875876

876-
// We need a trampoline if branches are far.
877877
if (need_trampoline) {
878-
bool in_scratch_emit_size = false;
879-
#ifdef COMPILER2
880-
if (check_emit_size) {
878+
if (!in_scratch_emit_size()) {
881879
// We don't want to emit a trampoline if C2 is generating dummy
882880
// code during its branch shortening phase.
883-
CompileTask* task = ciEnv::current()->task();
884-
in_scratch_emit_size =
885-
(task != NULL && is_c2_compile(task->comp_level()) &&
886-
Compile::current()->output()->in_scratch_emit_size());
887-
}
888-
#endif
889-
if (!in_scratch_emit_size) {
890-
address stub = emit_trampoline_stub(offset(), entry.target());
881+
address stub = emit_trampoline_stub(offset(), target);
891882
if (stub == NULL) {
892883
postcond(pc() == badAddress);
893884
return NULL; // CodeCache is full
894885
}
895886
}
887+
target = pc();
896888
}
897889

898890
if (cbuf) cbuf->set_insts_mark();
899891
relocate(entry.rspec());
900-
if (!need_trampoline) {
901-
bl(entry.target());
902-
} else {
903-
bl(pc());
904-
}
892+
bl(target);
893+
905894
// just need to return a non-null address
906895
postcond(pc() != badAddress);
907896
return pc();

src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,10 @@ class MacroAssembler: public Assembler {
633633
static int patch_oop(address insn_addr, address o);
634634
static int patch_narrow_klass(address insn_addr, narrowKlass n);
635635

636+
// Return whether code is emitted to a scratch blob.
637+
virtual bool in_scratch_emit_size() {
638+
return false;
639+
}
636640
address emit_trampoline_stub(int insts_call_instruction_offset, address target);
637641
void emit_static_call_stub();
638642

@@ -1175,7 +1179,7 @@ class MacroAssembler: public Assembler {
11751179
// - relocInfo::virtual_call_type
11761180
//
11771181
// Return: NULL if CodeCache is full.
1178-
address trampoline_call(Address entry, CodeBuffer* cbuf = NULL, bool check_emit_size = true);
1182+
address trampoline_call(Address entry, CodeBuffer* cbuf = NULL);
11791183

11801184
static bool far_branches() {
11811185
return ReservedCodeCacheSize > branch_range;

src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1054,7 +1054,7 @@ static void gen_continuation_enter(MacroAssembler* masm,
10541054
__ br(Assembler::NE, call_thaw);
10551055

10561056
address mark = __ pc();
1057-
__ trampoline_call(resolve, /*cbuf=*/ NULL, /*check_emit_size=*/ false);
1057+
__ trampoline_call(resolve);
10581058

10591059
oop_maps->add_gc_map(__ pc() - start, map);
10601060
__ post_call_nop();
@@ -1080,7 +1080,7 @@ static void gen_continuation_enter(MacroAssembler* masm,
10801080
__ br(Assembler::NE, call_thaw);
10811081

10821082
address mark = __ pc();
1083-
__ trampoline_call(resolve, /*cbuf=*/ NULL, /*check_emit_size=*/ false);
1083+
__ trampoline_call(resolve);
10841084

10851085
oop_maps->add_gc_map(__ pc() - start, map);
10861086
__ post_call_nop();

0 commit comments

Comments
 (0)