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

8256757: Incorrect MachCallRuntimeNode::ret_addr_offset() for CallLeafNoFP on x86_32 #1452

Closed

Conversation

shipilev
Copy link
Member

@shipilev shipilev commented Nov 26, 2020

Importance: fixes one of tier1 tests, including the runs in GH Actions.

JDK-8254231 added new assert in output.cpp:

    assert(!is_mcall || (call_returns[block->_pre_order] <= (uint) current_offset))

Which verifies that the offset returned by MachCallNode::ret_addr_offset() (and sub-types) at matches the emitted code, to avoid potential conflicts between oop maps of different calls.

It caught the failure running compiler/intrinsics/string/TestStringLatin1IndexOfChar.java on Linux x86_32. I think that happened because the test forced lower SSE settings. But more tests fail if you force with lower SSE settings with e.g. TEST_VM_OPTS=-XX:UseSSE=1. The real issue is MachCallRuntimeNode::ret_addr_offset() computing the offset incorrectly for CallLeafNoFP: the match rule for it does not include FFree_Float_Stack_All. With UseSSE < 2, FFree_Float_Stack_All becomes non-zero.

See the definitions in x86_32.ad:

  enc_class FFree_Float_Stack_All %{    // Free_Float_Stack_All
    MacroAssembler masm(&cbuf);
    int start = masm.offset();
    if (UseSSE >= 2) {
      if (VerifyFPU) {
        masm.verify_FPU(0, "must be empty in SSE2+ mode");
      }
    } else { // <---- taking this with UseSSE < 2
      // External c_calling_convention expects the FPU stack to be 'clean'.
      // Compiled code leaves it dirty.  Do cleanup now.
      masm.empty_FPU_stack();  
    }
    if (sizeof_FFree_Float_Stack_All == -1) {
      sizeof_FFree_Float_Stack_All = masm.offset() - start;
    } else {
      assert(masm.offset() - start == sizeof_FFree_Float_Stack_All, "wrong size");
    }
  %}

// Call runtime without safepoint
instruct CallLeafDirect(method meth) %{
  match(CallLeaf);
  effect(USE meth);

  ins_cost(300);
  format %{ "CALL_LEAF,runtime " %}
  opcode(0xE8); /* E8 cd */
  ins_encode( pre_call_resets,
              FFree_Float_Stack_All,
              Java_To_Runtime( meth ),
              Verify_FPU_For_Leaf, post_call_FPU );
  ins_pipe( pipe_slow );
%}

instruct CallLeafNoFPDirect(method meth) %{
  match(CallLeafNoFP);
  effect(USE meth);

  ins_cost(300);
  format %{ "CALL_LEAF_NOFP,runtime " %}
  opcode(0xE8); /* E8 cd */
  ins_encode(pre_call_resets, Java_To_Runtime(meth));
  ins_pipe( pipe_slow );
%}

This does not affect x86_64, AFAICS.

Additional testing:

  • A few known failing tests on Linux x86_32
  • Linux x86_32 tier1
  • Linux x86_32 tier1 with -XX:UseSSE=1

Progress

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

Testing

Linux additional Linux x64 Linux x86 Windows x64 macOS x64
Build ✔️ (8/8 passed) ✔️ (2/2 passed) ✔️ (2/2 passed) ✔️ (2/2 passed) ✔️ (2/2 passed)
Test (tier1) ✔️ (9/9 passed) ✔️ (9/9 passed) ✔️ (9/9 passed) ✔️ (9/9 passed)

Issue

  • JDK-8256757: Incorrect MachCallRuntimeNode::ret_addr_offset() for CallLeafNoFP on x86_32

Reviewers

Download

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

@bridgekeeper
Copy link

bridgekeeper bot commented Nov 26, 2020

👋 Welcome back shade! 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 Nov 26, 2020

@shipilev 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 Nov 26, 2020
@shipilev shipilev changed the title 8256757: Incorrect MachCallRuntimeNode::ret_addr_offset() for CallLeafNoFP 8256757: Incorrect MachCallRuntimeNode::ret_addr_offset() for CallLeafNoFP in x86_32 Nov 26, 2020
@shipilev shipilev changed the title 8256757: Incorrect MachCallRuntimeNode::ret_addr_offset() for CallLeafNoFP in x86_32 8256757: Incorrect MachCallRuntimeNode::ret_addr_offset() for CallLeafNoFP on x86_32 Nov 26, 2020
@shipilev shipilev marked this pull request as ready for review Nov 26, 2020
@openjdk openjdk bot added the rfr Pull request is ready for review label Nov 26, 2020
@mlbridge
Copy link

mlbridge bot commented Nov 26, 2020

Webrevs

Copy link
Member

@DamonFool DamonFool 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.
And thanks for fixing it.

How about replacing '5' with 'NativeCall::instruction_size' and also keeping the code generation order like this:
return pre_call_resets_size() + (_leaf_no_fp ? 0 : sizeof_FFree_Float_Stack_All) + NativeCall::instruction_size;

@shipilev
Copy link
Member Author

How about replacing '5' with 'NativeCall::instruction_size' and also keeping the code generation order like this:
return pre_call_resets_size() + (_leaf_no_fp ? 0 : sizeof_FFree_Float_Stack_All) + NativeCall::instruction_size;

New style follows what is done for MachCallDynamicJavaNode and MachCallStaticJavaNode. I'd prefer to make this a targeted fix not to risk more regressions.

@DamonFool
Copy link
Member

How about replacing '5' with 'NativeCall::instruction_size' and also keeping the code generation order like this:
return pre_call_resets_size() + (_leaf_no_fp ? 0 : sizeof_FFree_Float_Stack_All) + NativeCall::instruction_size;

New style follows what is done for MachCallDynamicJavaNode and MachCallStaticJavaNode. I'd prefer to make this a targeted fix not to risk more regressions.

Okay, I see. Thanks.

Copy link
Contributor

@vnkozlov vnkozlov left a comment

Choose a reason for hiding this comment

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

Okay.

@openjdk
Copy link

openjdk bot commented Nov 26, 2020

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

8256757: Incorrect MachCallRuntimeNode::ret_addr_offset() for CallLeafNoFP on x86_32

Reviewed-by: jiefu, kvn

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

  • 62d72de: 8220730: sun.security.provider.SecureRandom default constructor has wrong documentation
  • 4e43b28: 8256359: AArch64: runtime/ReservedStack/ReservedStackTestCompiler.java fails
  • 6e00622: 8256488: [aarch64] Use ldpq/stpq instead of ld4/st4 for small copies in StubGenerator::copy_memory
  • a93841a: 8255277: randomDelay in DrainDeadlockT and LoggingDeadlock do not randomly delay
  • 2d30a10: 8257069: C2: Clarify and sanity test RegMask/RegMaskIterator
  • 0a5de50: 8257151: ZGC: Simplify ZVerify
  • bf66d73: 8257073: ZGC: Try forward object before retaining page

Please see this link for an up-to-date comparison between the source branch of this pull request and the master branch.
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 Nov 26, 2020
@shipilev
Copy link
Member Author

/integrate

@openjdk openjdk bot closed this Nov 27, 2020
@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 Nov 27, 2020
@openjdk
Copy link

openjdk bot commented Nov 27, 2020

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

  • 2215e5a: 8255351: Add detection for Graviton 2 CPUs
  • 62d72de: 8220730: sun.security.provider.SecureRandom default constructor has wrong documentation
  • 4e43b28: 8256359: AArch64: runtime/ReservedStack/ReservedStackTestCompiler.java fails
  • 6e00622: 8256488: [aarch64] Use ldpq/stpq instead of ld4/st4 for small copies in StubGenerator::copy_memory
  • a93841a: 8255277: randomDelay in DrainDeadlockT and LoggingDeadlock do not randomly delay
  • 2d30a10: 8257069: C2: Clarify and sanity test RegMask/RegMaskIterator
  • 0a5de50: 8257151: ZGC: Simplify ZVerify
  • bf66d73: 8257073: ZGC: Try forward object before retaining page

Your commit was automatically rebased without conflicts.

Pushed as commit 9a468d8.

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

@shipilev shipilev deleted the JDK-8256757-x86-ret-addr-runtime branch Nov 27, 2020
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
3 participants