RFR: 8285487: Do not generate trampolines for runtime calls if they are not needed [v2]

Evgeny Astigeevich duke at openjdk.java.net
Fri Apr 29 13:34:54 UTC 2022


On Thu, 28 Apr 2022 22:16:19 GMT, Vladimir Kozlov <kvn at openjdk.org> wrote:

>>> runtime method, as you correctly pointed, is code in VM which can be in any distance from CodeCache.
>> 
>> Good catch. The function works with assumptions of `MacroAssembler::trampoline_call`. 
>> `MacroAssembler::trampoline_call` implicitly assumes the target is inside `CodeCache`:
>> 
>> // Maybe emit a call via a trampoline.  If the code cache is small
>> // trampolines won't be emitted.
>> 
>> I'll move the code of `target_needs_trampoline` inside of `MacroAssembler::trampoline_call`.
>> I'll also add an assert checking the target address is inside `CodeCache`.
>
> I suggest to put somewhere description where `far` calls and `trampoline` should/can be used.
> 
> Looking on `MacroAssembler::far_call()` and based on the assert there it targets only entries inside CodeCache. Which is strange because if `runtime` entry inside the 2gb range from any place in CodeCache you can use it. We have such check for x86: https://github.com/openjdk/jdk/blob/master/src/hotspot/cpu/x86/assembler_x86.cpp#L11701
> And you don't need trampoline if you can use `far` call to such `runtime` entry.
> 
> If you need trampoline there is also choice how you call/jump to **it**. Trampoline code is inside CodeCache and `target_needs_far_branch()` works to find type of instruction to reach *trampoline*.  That is what I though  your changes are doing.

Yes, you are right. There is an issue that for runtime calls into `CodeCaceh` both `far_call` and `trampoline_call` can be used.
`MacroAssembler::trampoline_call` should be used for runtime calls outside `CodeCache` and Java calls.  If a runtime call is into `CodeCache` then `far_call` should be used.

-------------

PR: https://git.openjdk.java.net/jdk/pull/8403


More information about the hotspot-dev mailing list