RFR: 8346836: C2: Verify CastII/CastLL bounds at runtime [v10]

Quan Anh Mai qamai at openjdk.org
Thu Apr 24 16:12:46 UTC 2025


On Wed, 23 Apr 2025 18:21:47 GMT, Vladimir Ivanov <vlivanov at openjdk.org> wrote:

>> Quan Anh Mai has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains 16 additional commits since the last revision:
>> 
>>  - Reconstruct FP
>>  - aarch64 support
>>  - Merge branch 'master' into verifycast
>>  - assert CastLL
>>  - reviews
>>  - make the flag diagnostic
>>  - Merge branch 'master' into verifycast
>>  - draft
>>  - Merge branch 'master' into verifycast
>>  - Merge branch 'master' into verifycast
>>  - ... and 6 more: https://git.openjdk.org/jdk/compare/9195a811...8d140fd9
>
> src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.cpp line 2763:
> 
>> 2761: 
>> 2762:   if (lo != min_jint && hi != max_jint) {
>> 2763:     subsw(rtmp, rval, lo);
> 
> It turns out it's equivalent to `cmpw(rval, lo)` which is clearer IMO.

I don't think it is, `cmpw(rval, lo)` is equivalent to `subsw(zr, rval, lo)`. However, if `lo` does not fit into an immediate instruction, `MacroAssembler::subsw`, which calls into `wrap_adds_subs_imm_insn`, will use `Rd` as a temporary register to store `lo`, this is invalid if `Rd` is `zr`. Am I understanding it right?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/22880#discussion_r2058796364


More information about the hotspot-compiler-dev mailing list