RFR: 8330153: C2: dump barrier information for all Mach nodes [v2]
Roberto Castañeda Lozano
rcastanedalo at openjdk.org
Mon Apr 22 09:30:30 UTC 2024
On Mon, 15 Apr 2024 07:04:11 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: VarHandleRefer...
>
> Roberto Castañeda Lozano has updated the pull request incrementally with one additional commit since the last revision:
>
> Add example
Thanks for reviewing, Tobias!
@vnkozlov: I added a simple IR test as requested, could I get a second review? Thanks!
-------------
PR Comment: https://git.openjdk.org/jdk/pull/18754#issuecomment-2068919807
More information about the hotspot-compiler-dev
mailing list