-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
8329797: Shenandoah: Default case invoked for: "MaxL" (bad AD file) #18824
Conversation
👋 Welcome back caojoshua! A progress list of the required criteria for merging this PR into |
@caojoshua This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been no new commits pushed to the As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@shipilev, @TobiHartmann) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
@caojoshua The following label will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command. |
Webrevs
|
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.
Good catch!
src/hotspot/share/opto/compile.hpp
Outdated
@@ -318,6 +318,7 @@ class Compile : public Phase { | |||
uintx _max_node_limit; // Max unique node count during a single compilation. | |||
|
|||
bool _post_loop_opts_phase; // Loop opts are finished. | |||
bool _began_macro_expansion; // Macro expansion is started. |
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.
I think this sounds better as inverse, bool _allow_macro_nodes; // Allow creating macro nodes
. Then we can also assert _allow_macro_nodes
in add_macro_node
?
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.
Can't add the assert for free. Apparently macro nodes are added later in the compiler pipeline, Matcher in this case.
Stack: [0x00007fb2c6d50000,0x00007fb2c6e51000], sp=0x00007fb2c6e4caa0, free space=1010k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V [libjvm.so+0x63bd9d] Compile::add_macro_node(Node*)+0x49 (compile.hpp:742)
V [libjvm.so+0x124ccc5] Node::clone() const+0x15f (node.cpp:501)
V [libjvm.so+0x119a93a] Matcher::xform(Node*, int)+0x3a2 (matcher.cpp:1150)
V [libjvm.so+0x1195413] Matcher::match()+0xe8b (matcher.cpp:359)
V [libjvm.so+0x9a9723] Compile::Code_Gen()+0x95 (compile.cpp:2947)
V [libjvm.so+0x99fd8d] Compile::Compile(ciEnv*, ciMethod*, int, Options, DirectiveSet*)+0x1827 (compile.cpp:895)
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.
Eh? We do Compile::add_macro_node
from Code_Gen
while cloning the nodes during matching, which means we add to _macro_nodes
unnecessarily? Same for expensive nodes. That's unfortunate...
*/ | ||
public class TestIfMinMax { | ||
private static final Random RANDOM = Utils.getRandomInstance(); | ||
|
||
public static void main(String[] args) { | ||
TestFramework.run(); | ||
TestFramework.runWithFlags("-XX:+UseShenandoahGC"); |
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.
I don't think we add GC-specific testing here. For one, the test would fail for the builds that do not include Shenandoah.
The common practice it to rely on test pipelines running the test suites with different GCs. Does make test TEST=compiler/c2/irTests/TestIfMinMax.java TEST_VM_OPTS=-XX:+UseShenandoahGC
work?
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, it works. Confirms it can reproduce the crash. Will remove that line.
@shipilev updated based on your comments and also updated the comment in |
src/hotspot/share/opto/compile.hpp
Outdated
bool allow_macro_nodes() { return _allow_macro_nodes; } | ||
void dont_allow_macro_nodes() { _allow_macro_nodes = false; } |
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.
dont_allow_macro_nodes
is a confusing name here, especially given it is a setter in contrast to allow_macro_nodes
. Let's call it reset_allow_macro_nodes()
.
src/hotspot/share/opto/macro.cpp
Outdated
@@ -2445,6 +2445,7 @@ void PhaseMacroExpand::eliminate_macro_nodes() { | |||
//------------------------------expand_macro_nodes---------------------- | |||
// Returns true if a failure occurred. | |||
bool PhaseMacroExpand::expand_macro_nodes() { | |||
C->dont_allow_macro_nodes(); |
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.
Leave a comment here:
// Do not allow new macro nodes once we started to expand
dont_allow_macro_nodes to reset_allow_macro_nodes.
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.
I am good with this version, but of course someone from compiler team needs to take a look.
/reviewers 2
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.
Looks good to me. I submitted testing and will report back once it passed.
Please adjust the description of JDK-8330531 according to the new naming.
Somehow the CMove condition is converted to non-canonical >, which is not accepted by the Idealization. The MinL is never created and there is no crash.
Is the problem that the condition is not canonicalized or that the CMoveNode is not process by IGVN after canonicalization of the cmp?
The jdk/src/hotspot/share/opto/loopopts.cpp Line 842 in 0b9350e
|
All tests passed.
Maybe verify if a |
Correction: The |
/integrate |
@caojoshua |
Thanks for the additional details and filing JDK-8331090! |
/sponsor |
Going to push as commit d32f109.
Your commit was automatically rebased without conflicts. |
@TobiHartmann @caojoshua Pushed as commit d32f109. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
The bug occurs when Shenandoah optimizations resets post_loop_opts, and we may create a MaxL after macro expansion.
MaxL
does not have a matcher rule, and we run into an assertion failure.This PR guards the
MaxL
creation with a newbegan_macro_expansion()
flag. I think there are many other instances in code that should use the new flag instead ofpost_loop_opts()
, which can be explored in JDK-8330531.The bug was originally found in h2 Index::getCostRangeIndex() through Dacapo. Its easy to reproduce by creating a loop that includes a
ShenandoahLoadReferenceBarrier
(load any object) and aMaxL
.Caveat: I created test cases for both
MaxL
andMinL
for completeness. TheMinL
test case does not actually fail before this PR. Somehow theCMove
condition is converted to non-canonical>
, which is not accepted by the Idealization. TheMinL
is never created and there is no crash.Passing hotspot tier1 locally on Linux machine.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/18824/head:pull/18824
$ git checkout pull/18824
Update a local copy of the PR:
$ git checkout pull/18824
$ git pull https://git.openjdk.org/jdk.git pull/18824/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 18824
View PR using the GUI difftool:
$ git pr show -t 18824
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/18824.diff
Webrev
Link to Webrev Comment