compiler/c2/irTests/AllocationMergesTests.java contains many IR tests to verify that allocation merges are correctly done during EA.
But that is only done on an IR level.
We've had a few issues in the past (e.g.JDK-8335977) where debug information was wrong and we failed to re-materialize scalar replaced objects correctly later when taking a deoptimization path. These bugs are really hard to find because we first need to deopt at the correct place where the info is wrong and then we also need to observe the wrong state.
In Valhalla, we have this test:
https://github.com/openjdk/valhalla/blob/8580a4eea6d533512b1e5d6e115c03fc0fcc773a/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestValueConstruction.java
where we do the following trick to trigger deoptimizations at various places: We insert some If conditions that are first never taken. As a result, C2 just inserts uncommon traps because it was never observed that we take the paths. Later we make the If conditions true and thus we trigger a deoptimization.
The idea of this RFE is to apply the same trick to AllocationMergesTests. I once started this work and then foundJDK-8335977. I attached the patch from back there which can be used as a starting point. It is by no means complete or refactored but can be used as guidance. Note that IR matching should be disabled, for example with -DVerifyIR=false, due to triggering deoptimizations.
The current patch is passing with current latest mainline.
But that is only done on an IR level.
We've had a few issues in the past (e.g.
In Valhalla, we have this test:
https://github.com/openjdk/valhalla/blob/8580a4eea6d533512b1e5d6e115c03fc0fcc773a/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestValueConstruction.java
where we do the following trick to trigger deoptimizations at various places: We insert some If conditions that are first never taken. As a result, C2 just inserts uncommon traps because it was never observed that we take the paths. Later we make the If conditions true and thus we trigger a deoptimization.
The idea of this RFE is to apply the same trick to AllocationMergesTests. I once started this work and then found
The current patch is passing with current latest mainline.
- relates to
-
JDK-8331964 [lworld] C2: Support abstract value class fields
-
- Resolved
-
-
JDK-8335977 Deoptimization fails with assert "object should be reallocated already"
-
- Closed
-
-
JDK-8341856 [lworld] Add value type tests for the cases in compiler/c2/irTests/scalarReplacement/AllocationMergesTests.java
-
- Open
-