-
Notifications
You must be signed in to change notification settings - Fork 156
8367624: [lworld] C2: Missed Value() optimization for CheckCastPP #2242
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
benoitmaillard
wants to merge
11
commits into
openjdk:lworld
Choose a base branch
from
benoitmaillard:JDK-8367624
base: lworld
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
99c6bfe
Add reduced test
benoitmaillard 54e11fd
Fix, first version
benoitmaillard e7698b0
Format
benoitmaillard 11b060b
Remove stuff
benoitmaillard 3a54a62
Revert "8380395: [lworld] ProblemList 4 sub-tests of compiler/valhall…
benoitmaillard 4fe9e68
Cleanup test
benoitmaillard 5700347
Comments
benoitmaillard bebc4c4
Spaces
benoitmaillard 0e086c4
Syntax in comment
benoitmaillard 642e67d
Add comment
benoitmaillard 6e248e4
Reapply "8380395: [lworld] ProblemList 4 sub-tests of compiler/valhal…
benoitmaillard File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestMissingOptCastSpeculative.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| /* | ||
| * Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved. | ||
| * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
| * | ||
| * This code is free software; you can redistribute it and/or modify it | ||
| * under the terms of the GNU General Public License version 2 only, as | ||
| * published by the Free Software Foundation. | ||
| * | ||
| * This code is distributed in the hope that it will be useful, but WITHOUT | ||
| * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
| * version 2 for more details (a copy is included in the LICENSE file that | ||
| * accompanied this code). | ||
| * | ||
| * You should have received a copy of the GNU General Public License version | ||
| * 2 along with this work; if not, write to the Free Software Foundation, | ||
| * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
| * | ||
| * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | ||
| * or visit www.oracle.com if you need additional information or have any | ||
| * questions. | ||
| */ | ||
|
|
||
| package compiler.valhalla.inlinetypes; | ||
|
|
||
| import test.java.lang.invoke.lib.InstructionHelper; | ||
|
|
||
| import java.lang.invoke.MethodHandle; | ||
| import java.lang.invoke.MethodHandles; | ||
| import java.lang.invoke.MethodType; | ||
|
|
||
| import jdk.internal.value.ValueClass; | ||
|
|
||
| import static compiler.valhalla.inlinetypes.InlineTypes.*; | ||
|
|
||
| /* | ||
| * @test | ||
| * @bug 8367624 | ||
| * @summary Writing a null value to an inline type array casts the array to | ||
| * 'not null free'. If there is a speculative type before the cast, | ||
| * we have to make sure to cast it as well, otherwise we get a | ||
| * missed value optimization. | ||
| * @library /test/lib /test/jdk/java/lang/invoke/common / | ||
| * @enablePreview | ||
| * @modules java.base/jdk.internal.value | ||
| * java.base/jdk.internal.vm.annotation | ||
| * @build test.java.lang.invoke.lib.InstructionHelper | ||
| * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+IgnoreUnrecognizedVMOptions | ||
| * -Xbatch -XX:PerMethodSpecTrapLimit=0 -XX:PerMethodTrapLimit=0 | ||
| * -XX:VerifyIterativeGVN=1110 -XX:CompileCommand=compileonly,${test.main.class}::test | ||
| * ${test.main.class} | ||
| * @run main ${test.main.class} | ||
| */ | ||
|
|
||
| public class TestMissingOptCastSpeculative { | ||
| public static void main(String[] args) { | ||
| TestMissingOptCastSpeculative t = new TestMissingOptCastSpeculative(); | ||
| MyValue1[] testValue1Array = (MyValue1[])ValueClass.newNullRestrictedNonAtomicArray(MyValue1.class, 3, MyValue1.DEFAULT); | ||
| for (int i = 0; i < 10000; i++) { | ||
| try { | ||
| t.test(testValue1Array, 0); | ||
| } catch (Throwable e) {} | ||
| } | ||
| } | ||
|
|
||
| // stores null at the specified index in the array | ||
| private static final MethodHandle setArrayElementNull = InstructionHelper.buildMethodHandle(MethodHandles.lookup(), | ||
| "setArrayElementNull", | ||
| MethodType.methodType(void.class, TestMissingOptCastSpeculative.class, MyValue1[].class, int.class), | ||
| CODE -> { | ||
| CODE. | ||
| aload(1). | ||
| iload(2). | ||
| aconst_null(). | ||
| aastore(). | ||
| return_(); | ||
| }); | ||
|
|
||
| private void test(MyValue1[] va, int index) throws Throwable { | ||
| setArrayElementNull.invoke(this, va, index); | ||
| } | ||
| } | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand well, it's doing
va[index] = nulland it's expected to throw? Maybe worth adding a little comment for people who don't enjoy assemblies as much as I do?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, if we do
va[index] = nullintestthe generated IR is a little different and we don't hit the assert. This is all extracted (and reduced) fromTestLWorld.java. I have added a comment