RFR: 8326306: RISC-V: Re-structure MASM calls and jumps [v2]

Fei Yang fyang at openjdk.org
Fri Apr 26 09:42:37 UTC 2024


On Fri, 26 Apr 2024 09:24:09 GMT, Robbin Ehn <rehn at openjdk.org> wrote:

>> A couple of point, all calls to VM runtime should use "call_VM_leaf".
>> E.g.
>> `  __ call_VM_leaf(Continuation::freeze_entry(), 2);`
>> AFIACT it is only Shenandoah which calls VM is this 'wrong' way.
>> 
>> call_VM_leaf always use mv -> li.
>> 
>> - It would be much better to change call_VM_leaf to use auipc is possible. (and fix Shenandoah to use call_VM_leaf)
>> - We can probably remove rt_call, and just have call.
>
> I found some other places which uses plain calls to leaf, instead of call_VM_leaf.
> It seems like it's a guess that registers don't need push/pop, I don't think such speculation is good.
> If it must be there we should have a argument to call_VM_leaf saying we don't want to push/pop.
> 
> x86 is this case uses the correct:
> ` __ call_VM_leaf(CAST_FROM_FN_PTR(address, ShenandoahRuntime::load_reference_barrier_weak), c_rarg0, c_rarg1);`
> 
> rt_call for non-code-cache do not need relocation, i.e. movptr.
> So rt_call and call is not simply interchangeable, i.e. you now need relocation (pc relative calls). 
> 
> Yes, we can probably do better here, but as the change is mv/li + jalr to movptr + jalr, there is no regression.
> So improvement should be done outside of this PR.

Another difference is that `rt_call` calls `relocate()` which is similar with aarch64's version of `rt_call` which delegates work to `lea` or `adrp` which does similar things [1][2]. I think we should check whether this will make a difference if we want to remove `rt_call`.

[1] https://github.com/openjdk/jdk/blob/master/src/hotspot/cpu/aarch64/assembler_aarch64.cpp#L141
[2] https://github.com/openjdk/jdk/blob/master/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp#L5398

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

PR Review Comment: https://git.openjdk.org/jdk/pull/18942#discussion_r1580761143


More information about the hotspot-dev mailing list