On Tue, 17 Mar 2026 10:07:58 GMT, Marc Chevalier <[email protected]> wrote:

> To do `acmp`, if the pointer comparison fails, we check nullity of operands, 
> whether operands have the same class, and if this class is a value class. And 
> if everything works, we call `isSubstitutable`.
> 
> Currently, when we have profiling information, we use it to speculate that 
> operands are null or of an identity class (in which case, pointer comparison 
> is all we should do). This patch proposes to take advantage of the profiling 
> when it hints that operands are value objects. By speculating that at least 
> one operand is of a given value class, the call to `isSubstitutable` can be 
> intrinsified later, and thus, spare the Java call.
> 
> Speculating on one operand is enough since we will check that operands are of 
> the same type.
> 
> 
> Some relevant microbenchmark in `valhalla.acmp.array.Value032` (in ns/op 
> (lower is better)):
> 
> |               | branch_obj_equals000 | branch_val_equals000 | 
> branch_obj_equals025 | branch_val_equals025 |
> |---------------|----------------------|----------------------|----------------------|----------------------|
> | Before        | 4.361 ± 0.153  ns/op | 0.907 ± 0.015  ns/op | 3.332 ± 0.040 
>  ns/op | 0.845 ± 0.032  ns/op |
> | With this fix | 0.911 ± 0.019  ns/op | 0.899 ± 0.021  ns/op | 0.838 ± 0.023 
>  ns/op | 0.806 ± 0.012  ns/op |
> 
> 
> 
> <details>
> <summary>Full results of <tt>micro:valhalla.acmp.array.Value032</tt></summary>
> In more details, before:
> 
> 
> Benchmark                                       Mode  Cnt  Score   Error  
> Units
> Value032.branch_obj_equals000                   avgt   15  4.087 ± 0.122  
> ns/op
> Value032.branch_obj_equals025                   avgt   15  3.117 ± 0.067  
> ns/op
> Value032.branch_obj_equals050                   avgt   15  2.235 ± 0.083  
> ns/op
> Value032.branch_obj_equals075                   avgt   15  1.292 ± 0.077  
> ns/op
> Value032.branch_obj_equals100                   avgt   15  0.316 ± 0.004  
> ns/op
> Value032.branch_val_equals000                   avgt   15  0.891 ± 0.024  
> ns/op
> Value032.branch_val_equals025                   avgt   15  0.839 ± 0.033  
> ns/op
> Value032.branch_val_equals050                   avgt   15  0.869 ± 0.087  
> ns/op
> Value032.branch_val_equals075                   avgt   15  0.816 ± 0.023  
> ns/op
> Value032.branch_val_equals100                   avgt   15  0.906 ± 0.032  
> ns/op
> Value032.result_obj_equals000                   avgt   15  4.115 ± 0.185  
> ns/op
> Value032.result_obj_equals025                   avgt   15  3.326 ± 0.346  
> ns/op
> Value032.result_obj_equals050                   avgt   15  2.353 ± 0.516  n...

For the first prototype, and significant refactoring.

test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestMissingOptAcmp.java line 
45:

> 43:  */
> 44: 
> 45: value class MyValue1MissingOptAcmp {

After [8368988: [lworld] Rename classes in valhalla/inlinetypes to be 
distinct](https://bugs.openjdk.org/browse/JDK-8368988), the class in 
`TestNewAcmp.java` was copy-pasted here. I'm just redoing the fix as it makes 
my IDE complain again.

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

PR Comment: https://git.openjdk.org/valhalla/pull/2237#issuecomment-4073784885
PR Review Comment: 
https://git.openjdk.org/valhalla/pull/2237#discussion_r2945736272

Reply via email to