[lworld] RFR: 8372697: [lworld] compiler/c2/irTests/scalarReplacement/ScalarReplacementWithGCBarrierTests.java fails with --enable-preview
Marc Chevalier
mchevalier at openjdk.org
Tue Dec 2 08:40:50 UTC 2025
In
https://github.com/openjdk/valhalla/blob/acb511a9f5c7b750b41e1ce77aab3d1a59613097/test/hotspot/jtreg/compiler/c2/irTests/scalarReplacement/ScalarReplacementWithGCBarrierTests.java#L98-L116
we have 2 allocations: `Iter` and `Integer`. Scalar replacement allows to eliminate the allocation of `Iter`, but we still had the allocation of `Integer`. With value classes, we can also save the allocation of `Integer` since it is a value class. Adapting expectations is enough.
To keep the test robust, I prefered to expect the exact amount, and not something like
@IR(phase = { CompilePhase.PHASEIDEAL_BEFORE_EA }, counts = { IRNode.ALLOC, "<= 2" })
@IR(phase = { CompilePhase.ITER_GVN_AFTER_ELIMINATION }, counts = { IRNode.ALLOC, "<= 1" })
Since that would allow the respective counts 1 and 1 (for instance, if `Integer` allocation is being removed as a value class, but `Iter` is not because EA would be broken with Valhalla).
To allow the test to work precisely with and without Valhalla, I propose a fake flag `enable-valhalla` that checks whether `Integer` is a value class. I preferred that over more generally "enable-preview" because it lacks granularity with respect to other preview features, and `PreviewFeatures.isEnabled()` is internal and not accessible anyway. It's a little hack, but I think the usage is very natural. It would be good if @chhagedorn could take a look at it.
Thanks,
Marc
-------------
Commit messages:
- Fix it
Changes: https://git.openjdk.org/valhalla/pull/1767/files
Webrev: https://webrevs.openjdk.org/?repo=valhalla&pr=1767&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8372697
Stats: 10 lines in 2 files changed: 8 ins; 0 del; 2 mod
Patch: https://git.openjdk.org/valhalla/pull/1767.diff
Fetch: git fetch https://git.openjdk.org/valhalla.git pull/1767/head:pull/1767
PR: https://git.openjdk.org/valhalla/pull/1767
More information about the valhalla-dev
mailing list