Skip to content

8337702: Use new ForwardExceptionNode to call StubRoutines::forward_exception_entry() #20437

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

Closed
wants to merge 5 commits into from

Conversation

vnkozlov
Copy link
Contributor

@vnkozlov vnkozlov commented Aug 2, 2024

Currently C2 uses TailCall node when it generates code to forward exception in C2 runtime stubs.
StubRoutines::forward_exception_entry() address is passed as constant and method pointer is NULL:
generateOptoStub.cpp#L258

On other hand TailCall mach node uses 2 registers as parameter which is hardcoded in Matcher: matcher.cpp#L828
As result we waste two registers to pass constant and NULL.

Also incorrect relocation is used for such call because the address of forward_exception stub passed in register in mach node. When it is converted to Address for jmp instruction the default external_word_type relocation is used when runtime_call_type should be used. See discussion in PR JDK-8337396

I added new ideal node ForwardExceptionNode to solve these issues. It is similar to Rethrow node (which mach node definition I used as template) but I kept it based on Return node similar to TailCall node.

Tested tier1-3,stress,xcomp


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8337702: Use new ForwardExceptionNode to call StubRoutines::forward_exception_entry() (Enhancement - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/20437/head:pull/20437
$ git checkout pull/20437

Update a local copy of the PR:
$ git checkout pull/20437
$ git pull https://git.openjdk.org/jdk.git pull/20437/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 20437

View PR using the GUI difftool:
$ git pr show -t 20437

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/20437.diff

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Aug 2, 2024

👋 Welcome back kvn! 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
Copy link

openjdk bot commented Aug 2, 2024

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

8337702: Use new ForwardExceptionNode to call StubRoutines::forward_exception_entry()

Reviewed-by: thartmann

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

  • f84240b: 8338011: CDS archived heap object support for 64-bit Windows
  • 04b146a: 8337334: Test tools/javac/7142086/T7142086.java timeout with fastdebug binary
  • a36fb36: 8338108: Give better error message in configure if a full XCode is missing
  • 61d1dc5: 8334466: Ambiguous method call with generics may cause FunctionDescriptorLookupError
  • 89a15f1: 8337681: PNGImageWriter uses much more memory than necessary
  • a6c0630: 8337938: ZUtils::alloc_aligned allocates without reporting to NMT
  • 0320460: 8337958: Out-of-bounds array access in secondary_super_cache
  • 692f5cb: 8338101: remove old remap assertion in map_or_reserve_memory_aligned after JDK-8338058
  • 0e7c1c1: 8338112: Test testlibrary_tests/ir_framework/tests/TestPrivilegedMode.java fails with release build
  • 6a3d045: 8337709: Use allocated states for chunking large array processing
  • ... and 131 more: https://git.openjdk.org/jdk/compare/c4e6255ac3ec5520c4cb6d0d4ad9013da177ba88...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 rfr Pull request is ready for review label Aug 2, 2024
@openjdk
Copy link

openjdk bot commented Aug 2, 2024

@vnkozlov The following label will be automatically applied to this pull request:

  • hotspot-compiler

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.

@openjdk openjdk bot added the hotspot-compiler hotspot-compiler-dev@openjdk.org label Aug 2, 2024
@mlbridge
Copy link

mlbridge bot commented Aug 2, 2024

Webrevs

Copy link
Contributor

@adinn adinn left a comment

Choose a reason for hiding this comment

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

Hi Vladimir.

This looks like a very nice solution. The code changes look ok as far a I can tell. However, I'm not really in a position to approve the patch as I am not very familiar with the details of the matcher and formssel code. Sorry.

@vnkozlov
Copy link
Contributor Author

vnkozlov commented Aug 6, 2024

Thank you, @adinn, for review.

@RealFYang
Copy link
Member

FYI: Also performed tier1-3 test on linux-riscv64. Result looks good.

Copy link
Member

@TobiHartmann TobiHartmann left a comment

Choose a reason for hiding this comment

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

Nice enhancement.

I noticed that TailJump is in vmStructs.cpp, should ForwardException be added as well?

@@ -16184,6 +16184,19 @@ instruct TailjmpInd(iRegPNoSpNoRfp jump_target, iRegP_R0 ex_oop)
ins_pipe(pipe_class_call);
%}

// Forward exception.
instruct ForwardExceptionjmp()
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
instruct ForwardExceptionjmp()
instruct ForwardException()

Same for other AD files.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can't use the same name for Mach node as for Ideal node:

src/hotspot/cpu/x86/x86_64.ad(12596) Syntax Error: :duplicate name ForwardException for instruction
Error Context:  >>>(<<<)
src/hotspot/cpu/x86/x86_64.ad(12597) Syntax Error: :Identifier expected, but found '%{
  match(ForwardEx[...]'.
Error Context:  >>>%<<<{

Copy link
Member

Choose a reason for hiding this comment

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

Ah, makes sense.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Aug 9, 2024
Co-authored-by: Tobias Hartmann <tobias.hartmann@oracle.com>
@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Aug 9, 2024
@vnkozlov
Copy link
Contributor Author

vnkozlov commented Aug 9, 2024

Thank you, @RealFYang, for testing.

@vnkozlov
Copy link
Contributor Author

vnkozlov commented Aug 9, 2024

Hi, @TobiHartmann

I cleaned ForwardExceptionNode constructor using your suggestion and added its type to vmStruct.

I kept name of Mach instructions unchanged (with jump at the end) because we can't use the same name as Ideal node. We do generate `jump' instruction so the name is appropriate in this sense I think.

Copy link
Member

@TobiHartmann TobiHartmann 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!

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Aug 12, 2024
@@ -256,12 +256,11 @@ void GraphKit::gen_stub(address C_function,

assert (StubRoutines::forward_exception_entry() != nullptr, "must be generated before");
Node *exc_target = makecon(TypeRawPtr::make( StubRoutines::forward_exception_entry() ));
Copy link
Contributor

Choose a reason for hiding this comment

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

exc_target is no longer used, so this should probably be removed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed

@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Aug 12, 2024
Copy link
Member

@TobiHartmann TobiHartmann left a comment

Choose a reason for hiding this comment

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

Still good.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Aug 12, 2024
@vnkozlov
Copy link
Contributor Author

Thank you, Tobias

@vnkozlov
Copy link
Contributor Author

/integrate

@openjdk
Copy link

openjdk bot commented Aug 12, 2024

Going to push as commit 99edb4a.
Since your change was applied there have been 142 commits pushed to the master branch:

  • 8d08314: 8337795: Type annotation attached to incorrect type during class reading
  • f84240b: 8338011: CDS archived heap object support for 64-bit Windows
  • 04b146a: 8337334: Test tools/javac/7142086/T7142086.java timeout with fastdebug binary
  • a36fb36: 8338108: Give better error message in configure if a full XCode is missing
  • 61d1dc5: 8334466: Ambiguous method call with generics may cause FunctionDescriptorLookupError
  • 89a15f1: 8337681: PNGImageWriter uses much more memory than necessary
  • a6c0630: 8337938: ZUtils::alloc_aligned allocates without reporting to NMT
  • 0320460: 8337958: Out-of-bounds array access in secondary_super_cache
  • 692f5cb: 8338101: remove old remap assertion in map_or_reserve_memory_aligned after JDK-8338058
  • 0e7c1c1: 8338112: Test testlibrary_tests/ir_framework/tests/TestPrivilegedMode.java fails with release build
  • ... and 132 more: https://git.openjdk.org/jdk/compare/c4e6255ac3ec5520c4cb6d0d4ad9013da177ba88...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Aug 12, 2024
@openjdk openjdk bot closed this Aug 12, 2024
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Aug 12, 2024
@openjdk
Copy link

openjdk bot commented Aug 12, 2024

@vnkozlov Pushed as commit 99edb4a.

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

@vnkozlov vnkozlov deleted the 8337702 branch August 12, 2024 17:23
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.

5 participants