Integrated: 8330153: C2: dump barrier information for all Mach nodes

Roberto Castañeda Lozano rcastanedalo at openjdk.org
Tue Apr 23 04:21:35 UTC 2024


On Fri, 12 Apr 2024 10:30:17 GMT, Roberto Castañeda Lozano <rcastanedalo at openjdk.org> wrote:

> This debug-only changeset ensures that GC-specific barrier information is dumped (via [`BarrierSetC2::dump_barrier_data()`](https://github.com/openjdk/jdk/blob/aebfd53e9d19f5939c81fa1a2fc75716c3355900/src/hotspot/share/gc/shared/c2/barrierSetC2.hpp#L311-L313)) for all C2 Mach nodes, not just `MachType` ones. This makes it possible to e.g. write IR tests that verify barrier properties of `CompareAndSwap`/`WeakCompareAndSwap` Mach implementations, which do not inherit from `MachTypeNode`. An example of such a test can be found [here](https://github.com/robcasloz/jdk/blob/e9b3c2a4cb5dd80d85af8320e559acea5920b2ff/test/hotspot/jtreg/compiler/gcbarriers/TestG1BarrierGeneration.java#L283-L292).
> 
> The [following program](https://bugs.openjdk.org/secure/attachment/108921/Example.java) illustrates the effect of the change:
> 
> 
> import java.lang.invoke.VarHandle;
> import java.lang.invoke.MethodHandles;
> 
> public class Example {
>     static class Outer {
>         Object f;
>     }
> 
>     static final VarHandle fVarHandle;
>     static {
>         MethodHandles.Lookup l = MethodHandles.lookup();
>         try {
>             fVarHandle = l.findVarHandle(Outer.class, "f", Object.class);
>         } catch (Exception e) {
>             throw new Error(e);
>         }
>     }
> 
>     static boolean testCompareAndSwap(Outer o, Object oldVal, Object newVal) {
>         return fVarHandle.compareAndSet(o, oldVal, newVal);
>     }
> 
>     public static void main(String[] args) {
>         for (int i = 0; i < 10_000; i++) {
>             Outer o = new Outer();
>             Object oldVal = new Object();
>             o.f = oldVal;
>             Object newVal = new Object();
>             testCompareAndSwap(o, oldVal, newVal);
>         }
>     }
> }
> 
> 
> Before this changeset, issuing this command:
> 
> 
> $ java -Xbatch -XX:+UseZGC -XX:+ZGenerational -XX:CompileOnly=Example::testCompareAndSwap -XX:CompileCommand=PrintIdealPhase,Example::testCompareAndSwap,FINAL_CODE Example.java | grep zCompareAndSwapP
> 
> 
> gives the following dump:
> 
> 
>  R10     37  zCompareAndSwapP  === 28 35 38 54 22 41  [[ 40 42 36 27 56 25 ]]  !jvms: VarHandleReferences$FieldInstanceReadWrite::compareAndSet @ bci:44 (line 180) VarHandleGuards::guard_LLL_Z @ bci:50 (line 68) Example::testCompareAndSwap @ bci:6 (line 20)
> 
> 
> After this changeset, we get:
> 
> 
>  R10     37  zCompareAndSwapP  === 28 35 38 54 22 41  [[ 40 42 36 27 56 25 ]]  barrier(strong )  !jvms: VarHandleReferences$FieldInstanceReadWrite::compareAndSet @ bci:44 (line 180) VarHandleGuards::guard_LLL_Z @ bci:50 (line 68...

This pull request has now been integrated.

Changeset: 57ebd045
Author:    Roberto Castañeda Lozano <rcastanedalo at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/57ebd045eae8ef1bdb5ec96d5eb11d252e08e6bb
Stats:     92 lines in 3 files changed: 87 ins; 5 del; 0 mod

8330153: C2: dump barrier information for all Mach nodes

Reviewed-by: kvn, thartmann

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

PR: https://git.openjdk.org/jdk/pull/18754


More information about the hotspot-compiler-dev mailing list