From cb37282a12698ae66c27889db9251a5b278624b0 Mon Sep 17 00:00:00 2001 From: Evgeny Astigeevich Date: Wed, 10 Aug 2022 14:56:17 +0000 Subject: [PATCH] 8291752: AArch64: Remove check_emit_size parameter from trampoline_call Reviewed-by: kvn, aph --- .../cpu/aarch64/c2_MacroAssembler_aarch64.cpp | 12 +++++++ .../cpu/aarch64/c2_MacroAssembler_aarch64.hpp | 4 +++ .../cpu/aarch64/macroAssembler_aarch64.cpp | 31 ++++++------------- .../cpu/aarch64/macroAssembler_aarch64.hpp | 6 +++- .../cpu/aarch64/sharedRuntime_aarch64.cpp | 4 +-- 5 files changed, 33 insertions(+), 24 deletions(-) diff --git a/src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.cpp b/src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.cpp index 26b2ab9a5fa..3f463a0585a 100644 --- a/src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.cpp @@ -26,6 +26,7 @@ #include "asm/assembler.hpp" #include "asm/assembler.inline.hpp" #include "opto/c2_MacroAssembler.hpp" +#include "opto/compile.hpp" #include "opto/intrinsicnode.hpp" #include "opto/matcher.hpp" #include "opto/output.hpp" @@ -1654,3 +1655,14 @@ void C2_MacroAssembler::vector_round_sve(FloatRegister dst, FloatRegister src, F sve_fcvtzs(dst, T, ptrue, dst, T); // result in dst } + +bool C2_MacroAssembler::in_scratch_emit_size() { + if (ciEnv::current()->task() != NULL) { + PhaseOutput* phase_output = Compile::current()->output(); + if (phase_output != NULL && phase_output->in_scratch_emit_size()) { + return true; + } + } + return MacroAssembler::in_scratch_emit_size(); +} + diff --git a/src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.hpp b/src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.hpp index 289b9c7322f..e241a42c81f 100644 --- a/src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.hpp +++ b/src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.hpp @@ -27,6 +27,10 @@ // C2_MacroAssembler contains high-level macros for C2 + private: + // Return true if the phase output is in the scratch emit size mode. + virtual bool in_scratch_emit_size() override; + public: void emit_entry_barrier_stub(C2EntryBarrierStub* stub); static int entry_barrier_stub_size(); diff --git a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp index 1f559b49491..72d2103fc6a 100644 --- a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp @@ -851,18 +851,19 @@ void MacroAssembler::call_VM_helper(Register oop_result, address entry_point, in // Maybe emit a call via a trampoline. If the code cache is small // trampolines won't be emitted. -address MacroAssembler::trampoline_call(Address entry, CodeBuffer* cbuf, - bool check_emit_size) { +address MacroAssembler::trampoline_call(Address entry, CodeBuffer* cbuf) { assert(entry.rspec().type() == relocInfo::runtime_call_type || entry.rspec().type() == relocInfo::opt_virtual_call_type || entry.rspec().type() == relocInfo::static_call_type || entry.rspec().type() == relocInfo::virtual_call_type, "wrong reloc type"); + address target = entry.target(); + + // We might need a trampoline if branches are far. bool need_trampoline = far_branches(); - if (!need_trampoline && entry.rspec().type() == relocInfo::runtime_call_type && !CodeCache::contains(entry.target())) { + if (!need_trampoline && entry.rspec().type() == relocInfo::runtime_call_type && !CodeCache::contains(target)) { // If it is a runtime call of an address outside small CodeCache, // we need to check whether it is in range. - address target = entry.target(); assert(target < CodeCache::low_bound() || target >= CodeCache::high_bound(), "target is inside CodeCache"); // Case 1: -------T-------L====CodeCache====H------- // ^-------longest branch---| @@ -873,35 +874,23 @@ address MacroAssembler::trampoline_call(Address entry, CodeBuffer* cbuf, need_trampoline = !reachable_from_branch_at(longest_branch_start, target); } - // We need a trampoline if branches are far. if (need_trampoline) { - bool in_scratch_emit_size = false; -#ifdef COMPILER2 - if (check_emit_size) { + if (!in_scratch_emit_size()) { // We don't want to emit a trampoline if C2 is generating dummy // code during its branch shortening phase. - CompileTask* task = ciEnv::current()->task(); - in_scratch_emit_size = - (task != NULL && is_c2_compile(task->comp_level()) && - Compile::current()->output()->in_scratch_emit_size()); - } -#endif - if (!in_scratch_emit_size) { - address stub = emit_trampoline_stub(offset(), entry.target()); + address stub = emit_trampoline_stub(offset(), target); if (stub == NULL) { postcond(pc() == badAddress); return NULL; // CodeCache is full } } + target = pc(); } if (cbuf) cbuf->set_insts_mark(); relocate(entry.rspec()); - if (!need_trampoline) { - bl(entry.target()); - } else { - bl(pc()); - } + bl(target); + // just need to return a non-null address postcond(pc() != badAddress); return pc(); diff --git a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp index 21141fa745d..46e0166842c 100644 --- a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp +++ b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp @@ -633,6 +633,10 @@ public: static int patch_oop(address insn_addr, address o); static int patch_narrow_klass(address insn_addr, narrowKlass n); + // Return whether code is emitted to a scratch blob. + virtual bool in_scratch_emit_size() { + return false; + } address emit_trampoline_stub(int insts_call_instruction_offset, address target); void emit_static_call_stub(); @@ -1175,7 +1179,7 @@ public: // - relocInfo::virtual_call_type // // Return: NULL if CodeCache is full. - address trampoline_call(Address entry, CodeBuffer* cbuf = NULL, bool check_emit_size = true); + address trampoline_call(Address entry, CodeBuffer* cbuf = NULL); static bool far_branches() { return ReservedCodeCacheSize > branch_range; diff --git a/src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp b/src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp index 2a576c60dfd..55a49594fb3 100644 --- a/src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp @@ -1054,7 +1054,7 @@ static void gen_continuation_enter(MacroAssembler* masm, __ br(Assembler::NE, call_thaw); address mark = __ pc(); - __ trampoline_call(resolve, /*cbuf=*/ NULL, /*check_emit_size=*/ false); + __ trampoline_call(resolve); oop_maps->add_gc_map(__ pc() - start, map); __ post_call_nop(); @@ -1080,7 +1080,7 @@ static void gen_continuation_enter(MacroAssembler* masm, __ br(Assembler::NE, call_thaw); address mark = __ pc(); - __ trampoline_call(resolve, /*cbuf=*/ NULL, /*check_emit_size=*/ false); + __ trampoline_call(resolve); oop_maps->add_gc_map(__ pc() - start, map); __ post_call_nop();