On Thu, 19 Mar 2026 16:48:03 GMT, Tobias Hartmann <[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
>> Value...
>
> test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestLWorldProfiling.java 
> line 1250:
> 
>> 1248:     @Test
>> 1249:     @IR(applyIfOr = {"UseACmpProfile", "true", "TypeProfileLevel", "= 
>> 222"},
>> 1250:             failOn = {STATIC_CALL_OF_METHOD, "isSubstitutable.*"},
> 
> Indentation seems a bit off here, same below.

Urgh. Intellij has weird opinion on how these things should be indented. When I 
try to fight it to make it consistent with the rest, it ends up looking like 
that.

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

PR Review Comment: 
https://git.openjdk.org/valhalla/pull/2237#discussion_r2964369765

Reply via email to