RFR: 8270086: ARM32-softfp: Do not load CONSTANT_double using the condy helper methods in the interpreter

Christoph Göttschkes cgo at openjdk.java.net
Mon Jul 26 10:43:08 UTC 2021


On Tue, 13 Jul 2021 13:17:58 GMT, Christoph Göttschkes <cgo at openjdk.org> wrote:

> Hi,
> 
> please review this fix for the template interpreter for ARM32-softfp.
> 
> With the introduction of condy, the interpreter started to load double constants using the condy_helper, which is unnecessary. Also, the [resolve_ldc](https://github.com/openjdk/jdk/blob/8973867fb9568a3a527b763c9ce10cebdfb306d0/src/hotspot/share/interpreter/interpreterRuntime.cpp#L148) implementation of the interpreter runtime might not be designed to load constant values. It should only load strings and condy.
> 
> https://github.com/openjdk/jdk/blob/2ee56fd1cf4acd634e19cc77b7c9a6858e1c315a/src/hotspot/cpu/arm/templateTable_arm.cpp#L515-L560
> 
> I refactored the ldc2_w bytecode imlpementation. Now, the ifdef between soft and hard float covers both types, CONSTANT_Long and CONSTANT_Double. I did this, because for the softfp, we can use a conditional cmp, since double and long are both placed on the stack in the same way. The same is also done for CONSTANT_Integer and CONSTANT_Float in the ldc bytecode implementation. Also, I think it is easier to follow the code this way.
> 
> Old ldc2_w implementation (before condy was implemented for ARM32):
> 
> https://github.com/openjdk/jdk/blob/7101b28dc3903be27cb46a00781f4d74f81f1114/src/hotspot/cpu/arm/templateTable_arm.cpp#L497-L537
> 
> Testing: ARMv7-A (hardfp) hotspot tier1, ARMv5TE (softfp) hotspot tier1

> AFAIU, ABI_HARD and SOFTFP are defining different things. SOFTFP defines whether to use hardware instructions or software emulation to deal with FP. Whereas ABI_HARD covers the ABI parts, i.e. which registers to use to pass FP values between calls. Here we don't call anything, but only do loads. This reasoning seems to be consistent with what TemplateTable::dload does. Seeing how -mfloat-abi takes three values, I can see ABI_HARD and SOFTFP might be not mutually exclusive?

That makes sense.
I checked with my GCC:

* `-mfloat-abi=soft` defines `__SOFTFP__`
* `-mfloat-abi=softfp` defines neither `__ARM_PCS_VFP`, nor `__SOFTFP__` (`__ARM_PCS_VFP` is used to define `__ABI_HARD__` in `globalDefinitions_arm.hpp`)
* `-mfloat-abi=hard` defines `__ARM_PCS_VFP`

My assumption was that `__SOFTFP__` is defined for both, `-mfloat-abi=soft` and `-mfloat-abi=softfp`, which is not the case. Thanks for pointing that out.

This suggests that we need to be consistent within the template interpreter and always use `__SOFTFP__` if we want to know which registers to use to pass floating point values inside the interpreter. `__ABI_HARD__` has to be used if it is required to follow the native ABI.

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

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


More information about the hotspot-compiler-dev mailing list