8379667: C2: Deep recursion with cmovP_regNode::bottom_type#30765
8379667: C2: Deep recursion with cmovP_regNode::bottom_type#30765merykitty wants to merge 1 commit intoopenjdk:masterfrom
Conversation
|
👋 Welcome back qamai! A progress list of the required criteria for merging this PR into |
|
❗ This change is not yet ready to be integrated. |
|
@merykitty 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. |
|
The total number of required reviews for this PR has been set to 2 based on the presence of this label: |
|
This looks nice @merykitty! It's great to see such a cleanup too :) |
| // Special case, with AllocatePrefetchStyle == 3, this should be Type::MEMORY, but the graph | ||
| // seems unsound, needs further investigation |
There was a problem hiding this comment.
What do you mean by "unsound" here? Can you create a follow-up to track this?
There was a problem hiding this comment.
Currently, in the ideal graph, a PrefetchAllocationNode is a Type::ABIO or Type::MEMORY. As a result, they are connected to previous and subsequent abio and memory nodes, respectively. However, when lowered to MachNodes, since the rule are declared match(PrefetchAllocation mem), they become Type::BOTTOM, but their inputs and outputs are still abio or memory nodes, hence the unsoundness.
With the PR, at least when AllocatePrefetchStyle != 3, they preserve their correct type after matching. For AllocatePrefetchStyle == 3, it is more difficult, because memory nodes participate in anti-dependency computations, so we need to make further modifications to ensure that a PrefetchAllocationNode has a control input, and they act as a full store (its anti-dependencies do not need computing).
I filed JDK-8382547.
| if (_bottom_type != nullptr) { | ||
| _bottom_type->dump_on(st); | ||
| } else { | ||
| st->print(" null"); |
There was a problem hiding this comment.
Your change seems to leave out this printout we would get before. I'm unsure about if keeping it makes easier to read/parse the dump spec or more cluttered, though...
There was a problem hiding this comment.
You mean the st->print(" null")? Since most nodes have bottom_type set, and the one that does not is either MachTemp, or something that is not a pointer (guaranteed by MachNode::bottom_type()), I think it is a little unnecessary.
anton-seoane
left a comment
There was a problem hiding this comment.
Looks good. Thanks!
Hi,
The issue that leads to the failure is in the implementation of
cmoveP_regNode::bottom_type, which recursively invokesNode::bottom_typeon its inputs:This deep recursion results in the number of
Type::meetbeing called being a quadratic function of the number ofcmovP_regNodein the chain.Type::meeteventually callsTypeInterfaces::intersection_with, each time that method is called, it allocates aGrowableArrayto store the_interfacesof the result, this allocation is not guarded with aResourceMark, which results in the resource area being overloaded, hitting theMemLimit.Simply adding a
ResourceMarktoTypeInterfaces::intersection_withdoes not work, the recursion is still expensive, and the compilation won't terminate in a reasonable amount of time. As a result, I go with a more comprehensive solution, that is to keep thebottom_typeof allMachNode.It also helps alleviate a potential issue. The type of a pointer needs to be correctly recorded for scheduling and builing of oop maps at safepoints. For this, we have a pretty ad-hoc list of
MachTypeNodethat store theirbottom_typeinside their instances. By making allMachNodekeeping theirbottom_type, we can remove this ad-hoc list.Testing:
Please take a look and leave your reviews, thanks a lot.
Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/30765/head:pull/30765$ git checkout pull/30765Update a local copy of the PR:
$ git checkout pull/30765$ git pull https://git.openjdk.org/jdk.git pull/30765/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 30765View PR using the GUI difftool:
$ git pr show -t 30765Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/30765.diff
Using Webrev
Link to Webrev Comment