RFR: 8345322: RISC-V: Add concurrent gtests for cmpxchg variants
Fei Yang
fyang at openjdk.org
Mon Dec 9 10:31:38 UTC 2024
On Mon, 9 Dec 2024 08:15:59 GMT, Robbin Ehn <rehn at openjdk.org> wrote:
>> test/hotspot/gtest/riscv/test_assembler_riscv.cpp line 479:
>>
>>> 477: ttg.doit();
>>> 478: ttg.join();
>>> 479: ASSERT_EQ(data, (TESTSIZE)(num_threads*10000));
>>
>> Seems there is an integer overflow issue for the narrow tests? `num_threads*10000` is 40000 here which is much larger than allowed for `int8_t` and `int16_t` types.
>
> Strictly speaking the first overflow happens here:
> `TESTSIZE newvalue = oldvalue + 1;`
> As '1' is an integer, oldvalue is promoted to an integer and as 128 is not in range of int8_t.
> This is implementation defined, but de facto we know this will wrap around.
>
> The casting of 40000 to TESTIZE the same thing happens, but first the higher bits are truncated and then it may wrap around depending on the MSB.
>
> AFIACT it always produces the same result.
>
> If we don't trust the wrap around as it's outside the spec both cases should be handled.
Yeah. But seems avoidable if we make the loop count smaller for the narrow cases? I think it will be simpler and more readable for people then.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/22574#discussion_r1875736843
More information about the hotspot-dev
mailing list