RFR: 8330153: C2: dump barrier information for all Mach nodes [v3]

Roberto Castañeda Lozano rcastanedalo at openjdk.org
Tue Apr 23 03:57:46 UTC 2024


> 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...

Roberto Castañeda Lozano has updated the pull request incrementally with one additional commit since the last revision:

  Add @bug

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/18754/files
  - new: https://git.openjdk.org/jdk/pull/18754/files/409a1ef4..a842cb68

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=18754&range=02
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=18754&range=01-02

  Stats: 1 line in 1 file changed: 1 ins; 0 del; 0 mod
  Patch: https://git.openjdk.org/jdk/pull/18754.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/18754/head:pull/18754

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


More information about the hotspot-compiler-dev mailing list