RFR: 8346836: C2: Introduce a way to verify the correctness of ConstraintCastNodes at runtime

Emanuel Peter epeter at openjdk.org
Fri Jan 17 07:41:42 UTC 2025


On Wed, 25 Dec 2024 14:54:02 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.

I like this idea a lot. I'm personally on the fence if it is ok to integrate a flag that does not yet pass in the tests. The risk is that nobody fixes it.

What do you think about that @TobiHartmann @vnkozlov ?

Did you run testing with and without the flag? Cannot see the link posted on JIRA.

src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp line 849:

> 847:   jccb(Assembler::lessEqual, succeed);
> 848:   bind(fail);
> 849:   stop("Invalid CastII");

Is there any way to print the `[lo,hi]` and `dst`? I suppose one can always get that via the debugger, would just be convenient.

src/hotspot/share/opto/castnode.cpp line 511:

> 509: 
> 510:   // Keep these casts for verification
> 511:   if (VerifyConstraintCasts) {

Can we have 2 modes, one where we do the widening, and one where we do not?

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

PR Review: https://git.openjdk.org/jdk/pull/22880#pullrequestreview-2558150367
PR Review Comment: https://git.openjdk.org/jdk/pull/22880#discussion_r1919678850
PR Review Comment: https://git.openjdk.org/jdk/pull/22880#discussion_r1919676685


More information about the hotspot-compiler-dev mailing list