RFR: 8283327: Add methods to save/restore registers when calling into the VM from C1/interpreter barrier code/improve push pop stuff for x86

Thomas Schatzl tschatzl at openjdk.java.net
Fri Mar 18 17:34:28 UTC 2022


On Fri, 18 Mar 2022 15:52:52 GMT, Erik Österlund <eosterlund at openjdk.org> wrote:

>> Hi all,
>> 
>>   can I have reviews for this change that adds an API to save/restore caller-saved registers for VM upcalls for C1/interpreter.
>> 
>> Currently, for x86, this is done in a very ad-hoc (copy&pasty) way, which starts to fall apart. Additionally this fixes some problems with wrong stack alignment.
>> 
>> There is some cleanup to do separately to remove that copy&paste code in another CR. At the moment the API (`push_call_clobbered_registers/pop_call_clobbered_registers`) is only used for g1.
>> 
>> It's based on `RegSet` from AArch64.
>> 
>> Testing: tier1-5, tier1 testing with x64 and x86, with some at this point obscure combinations (like x86 UseSSE=0/1).
>> 
>> Thanks,
>>   Thomas
>
> src/hotspot/cpu/x86/macroAssembler_x86.cpp line 3599:
> 
>> 3597: #if defined(WINDOWS) && defined(_LP64)
>> 3598:   XMMRegSet result = XMMRegSet::range(xmm0, xmm5);
>> 3599:   if (FrameMap::get_num_caller_save_xmms() > 16) {
> 
> Why is this part needed?

In the x64 Windows ABI xmm0-5 and xmm16-31 are volatile, i.e. caller save. That's why, unlike in the SysV ABI, xmm6-15 are not in the set, and hence not saved by the caller.

The code says: if we have more than 16 xmm registers (AVX), then add xmm16 to 31 to the set of caller saved registers.
If we added xmm16 to 31 unconditionally, the code generator would complain that xmm16 to 31 are not available with e.g. SSE2 only.

Thomas

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

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


More information about the hotspot-dev mailing list