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

Vladimir Ivanov vlivanov at openjdk.org
Wed Apr 23 21:41:53 UTC 2025


On Tue, 22 Apr 2025 17:10:34 GMT, Quan Anh Mai <qamai at openjdk.org> wrote:

>> Hi,
>> 
>> This patch adds a develop flag `VerifyConstraintCasts`, which will verify the correctness of `CastIINode`s and `CastLLNode`s at runtime and crash the VM if the dynamic value lies outside the type value range.
>> 
>> Please take a look, thanks a lot.
>
> 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/66aec1b1...8d140fd9

Looks good. Thanks.

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.

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

Marked as reviewed by vlivanov (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/22880#pullrequestreview-2788341212
PR Review Comment: https://git.openjdk.org/jdk/pull/22880#discussion_r2056658683


More information about the hotspot-compiler-dev mailing list