Skip to content
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

8263577: C2: reachable nodes shouldn't have dead uses at the end of optimizations #3012

Closed
wants to merge 3 commits into from

Conversation

rwestrel
Copy link
Contributor

@rwestrel rwestrel commented Mar 15, 2021

It's not uncommon for c2 to leave dead uses hanging from reachable
nodes. It's usually harmless but can cause confusion (such as in
valhalla JDK-8262289, not reproducible with non valhalla code AFAICT).

Most of the time, these are caused by calls to set_req() during igvn
that should be set_req_X() calls. I added a verification pass at the
end of optimization and fixed all the ones I found.

/cc hotspot-compiler


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8263577: C2: reachable nodes shouldn't have dead uses at the end of optimizations

Reviewers

Download

$ git fetch https://git.openjdk.java.net/jdk pull/3012/head:pull/3012
$ git checkout pull/3012

@bridgekeeper
Copy link

bridgekeeper bot commented Mar 15, 2021

👋 Welcome back roland! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added rfr Pull request is ready for review hotspot-compiler hotspot-compiler-dev@openjdk.org labels Mar 15, 2021
@openjdk
Copy link

openjdk bot commented Mar 15, 2021

@rwestrel
The hotspot-compiler label was successfully added.

@mlbridge
Copy link

mlbridge bot commented Mar 15, 2021

Webrevs

Copy link
Contributor

@iwanowww iwanowww left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

Changes in src/hotspot/share/opto/subtypenode.cpp don't look relevant. I assume new verification logic uncovered a problem there. Does it make sense to integrate the fix separately?

int replace_edge(Node* old, Node* neww);
int replace_edges_in_range(Node* old, Node* neww, int start, int end);
int replace_edge(Node* old, Node* neww, PhaseGVN* gvn = NULL);
int replace_edges_in_range(Node* old, Node* neww, int start, int end, PhaseGVN* gv);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/gv/gvn/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right. Will fix that.

@openjdk
Copy link

openjdk bot commented Mar 15, 2021

@rwestrel 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:

8263577: C2: reachable nodes shouldn't have dead uses at the end of optimizations

Reviewed-by: vlivanov, neliasso

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 32 new commits pushed to the master branch:

  • d6b5e18: 8263191: Consolidate ThreadInVMfromJavaNoAsyncException and ThreadBlockInVMWithDeadlockCheck with existing wrappers
  • 80cdf78: 8263544: Unused argument in ConstantPoolCacheEntry::set_field()
  • c0176c4: 8263552: Use String.valueOf() for char-to-String conversions
  • fac39fe: 8263508: Remove dead code in MethodHandleImpl
  • 7b4aefe: 8263530: sun.awt.X11.ListHelper.removeAll() should use clear()
  • 32c7fcc: 8263490: [macos] Crash occurs on JPasswordField with activated InputMethod
  • 8afec70: 8260931: Implement JEP 382: New macOS Rendering Pipeline
  • 0638303: 8263497: Clean up sun.security.krb5.PrincipalName::toByteArray
  • ba22e6f: 8263446: Avoid unary minus over unsigned type in ObjectSynchronizer::dec_in_use_list_ceiling
  • b371f90: 8263504: Some OutputMachOpcodes fields are uninitialized
  • ... and 22 more: https://git.openjdk.java.net/jdk/compare/a9b156d358b0436584a33f71abc00c9bed9d47a3...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Mar 15, 2021
@rwestrel
Copy link
Contributor Author

rwestrel commented Mar 15, 2021

Changes in src/hotspot/share/opto/subtypenode.cpp don't look relevant. I assume new verification logic uncovered a problem there. Does it make sense to integrate the fix separately?

In the case of subtypenode.cpp, some nodes were created and never attached to any use.

Thanks for the review!

@iwanowww
Copy link
Contributor

In the case of subtypenode.cpp, some nodes were created and never attached to any use.

Ok, makes sense.

So, you move the code out of if (super_t->singleton() && ...) { to avoid putting subklass on the worklist?

@rwestrel
Copy link
Contributor Author

So, you move the code out of if (super_t->singleton() && ...) { to avoid putting subklass on the worklist?

Right.

set_req(2,x2);
set_req(1,x1);
}
set_req_X(2,x2,phase);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space after comma in argument list. Same a bit further down to.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review. Should be fixed now.

@rwestrel
Copy link
Contributor Author

/integrate

@openjdk openjdk bot closed this Mar 16, 2021
@openjdk openjdk bot added integrated Pull request has been integrated and removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Mar 16, 2021
@openjdk
Copy link

openjdk bot commented Mar 16, 2021

@rwestrel Since your change was applied there have been 46 commits pushed to the master branch:

  • c484d89: 8263557: Possible NULL dereference in Arena::destruct_contents()
  • ba35193: 8263559: Add missing initializers to VM_PopulateDumpSharedSpace
  • e03a594: 8262504: Some CLHSDB command cannot know they run on remote debugger
  • d896246: 8263420: Incorrect function name in NSAccessibilityStaticText native peer implementation
  • 8c1112a: 8261916: gtest/GTestWrapper.java vmErrorTest.unimplemented1_vm_assert failed
  • 1e57087: 8263392: Allow current thread to be specified in ExceptionMark
  • 4d1c08c: 8263616: 'Deprecatd' typo in src/hotspot/share/classfile/classFileParser.cpp
  • 0c718ab: 8262277: URLClassLoader.getResource throws undocumented IllegalArgumentException
  • 4f1cda4: 8263387: G1GarbageCollection JFR event gets gc phase, not gc type
  • 5ab5244: 8263514: Minor issue in JavacFileManager.SortFiles.REVERSE
  • ... and 36 more: https://git.openjdk.java.net/jdk/compare/a9b156d358b0436584a33f71abc00c9bed9d47a3...master

Your commit was automatically rebased without conflicts.

Pushed as commit 20297a1.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@navyxliu
Copy link
Member

hi, @rwestrel

Is Node::set_req_X() same as PhaseIterGVN::replace_input_of()?
This even supports delayed hash. can I use them interchangeably?

  // Replace ith edge of "n" with "in"
  void replace_input_of(Node* n, int i, Node* in) {
    rehash_node_delayed(n);
    n->set_req_X(i, in, this);
  }

@rwestrel
Copy link
Contributor Author

hi, @rwestrel

Is Node::set_req_X() same as PhaseIterGVN::replace_input_of()?
This even supports delayed hash. can I use them interchangeably?

They are not quite the same as replace_input_of() has the rehash_node_delayed() call. When modifying an existing node, it's a requirement to call has_delete() which rehash_node_delayed() does for you. If you're in Ideal() modifying the "this" node, the hash_delete() call happened before the ideal call.

So I guess roughly: in Ideal modifying this's input -> set_req_X(), otherwise replace_input_of()

@navyxliu
Copy link
Member

@rwestrel
I see. Thanks for the explanation.
verify that your patch invokes "set_req_X" in Node::ideal() and its overrides.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot-compiler hotspot-compiler-dev@openjdk.org integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

4 participants