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

8333722: Fix CompilerDirectives for non-compiler JVM variants #19578

Closed

Conversation

simonis
Copy link
Member

@simonis simonis commented Jun 6, 2024

DirectivesStack::getMatchingDirective() relies on the fact that the default directives set is always enabled. And that's indeed the case for normal builds with C1 and C2 compilers (see DirectivesStack::init() in compilerDirectives.cpp):

// Create a new dirstack and push a default directive
void DirectivesStack::init() {
  CompilerDirectives* _default_directives = new CompilerDirectives();
  char str[] = "*.*";
  const char* error_msg = nullptr;
  _default_directives->add_match(str, error_msg);
#if defined(COMPILER1) || INCLUDE_JVMCI
  _default_directives->_c1_store->EnableOption = true;
#endif
#ifdef COMPILER2
  if (CompilerConfig::is_c2_enabled()) {
    _default_directives->_c2_store->EnableOption = true;
  }
#endif
  assert(error_msg == nullptr, "Must succeed.");
  push(_default_directives);
}

However, if we're building a JVM configuration without compilers (e.g. --with-jvm-variants=core), this is not the case and DirectivesStack::getMatchingDirective() will return the base directive set without incrementing the reference count of its directive:

    CompilerDirectives* dir = _top;
    assert(dir != nullptr, "Must be initialized");

    while (dir != nullptr) {
      if (dir->is_default_directive() || dir->match(method)) {
        match = dir->get_for(comp);
        assert(match != nullptr, "Consistency");
        if (match->EnableOption) {
          // The directiveSet for this compile is also enabled -> success
          dir->inc_refcount();
          break;
        }
      }
      dir = dir->next();
    }
  }
  guarantee(match != nullptr, "There should always be a default directive that matches");

  // Check for legacy compile commands update, without DirectivesStack_lock
  return match->compilecommand_compatibility_init(method);

If this directive set will be released, it will delete the corresponding base directive and subsequent usages of the base directive will lead to a segmentation fault.

After JDK-8329421: Native methods can not be selectively printed which replaced the call to

DirectiveSet* directive = DirectivesStack::getDefaultDirective(CompileBroker::compiler(CompLevel_simple));

by

DirectiveSet* directive = DirectivesStack::getMatchingDirective(method, CompileBroker::compiler(CompLevel_simple));

in sharedRuntime.cpp this issue is now triggered at JVM startup for non-compiler configurations when native wrappers are generated (see #18567 (comment)).

The fix is trivial. Just increment the reference count of a compiler directive in DirectivesStack::getMatchingDirective() if it is the base directive, even if it is not enabled.


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-8333722: Fix CompilerDirectives for non-compiler JVM variants (Bug - P2)(⚠️ The fixVersion in this issue is [23] but the fixVersion in .jcheck/conf is 24, a new backport will be created when this pr is integrated.)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 19578

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

Using diff file

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

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jun 6, 2024

👋 Welcome back simonis! 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 Jun 6, 2024

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

8333722: Fix CompilerDirectives for non-compiler JVM variants

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

  • f7862bd: 8331311: C2: Big Endian Port of 8318446: optimize stores into primitive arrays by combining values into larger store
  • b4beda2: 8332537: C2: High memory usage reported for compiler/loopopts/superword/TestAlignVectorFuzzer.java
  • e5383d7: 8333713: C2 SuperWord: cleanup in vectornode.cpp/hpp
  • 944aeb8: 8325155: C2 SuperWord: remove alignment boundaries
  • d8af589: 8026127: Deflater/Inflater documentation incomplete/misleading
  • 6238bc8: 8333456: CompactNumberFormat integer parsing fails when string has no suffix
  • 2a37764: 8333743: Change .jcheck/conf branches property to match valid branches
  • 75dc2f8: 8330182: Start of release updates for JDK 24
  • 054362a: 8332550: [macos] Voice Over: java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
  • 9b436d0: 8333674: Disable CollectorPolicy.young_min_ergo_vm for PPC64
  • ... and 7 more: https://git.openjdk.org/jdk/compare/1a50bd09ef7abfa3709edb388c7dbb003d483561...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 Jun 6, 2024
@openjdk
Copy link

openjdk bot commented Jun 6, 2024

@simonis 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 Jun 6, 2024
@mlbridge
Copy link

mlbridge bot commented Jun 6, 2024

Webrevs

@dcubed-ojdk
Copy link
Member

I fixed the typo in the bug's synopsis. The easiest way to update this PR to match is: /issue JDK-8333722

@simonis
Copy link
Member Author

simonis commented Jun 6, 2024

/issue JDK-8333722

@simonis
Copy link
Member Author

simonis commented Jun 6, 2024

I fixed the typo in the bug's synopsis. The easiest way to update this PR to match is: /issue JDK-8333722

Thanks @dcubed-ojdk !

@openjdk openjdk bot changed the title 8333722: Fix CompilerDirectevies for non-compiler JVM variants 8333722: Fix CompilerDirectives for non-compiler JVM variants Jun 6, 2024
@openjdk
Copy link

openjdk bot commented Jun 6, 2024

@simonis This issue is referenced in the PR title - it will now be updated.

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 openjdk bot added the ready Pull request is ready to be integrated label Jun 6, 2024
@simonis
Copy link
Member Author

simonis commented Jun 6, 2024

Okay.

Thanks @vnkozlov !

@simonis
Copy link
Member Author

simonis commented Jun 10, 2024

/integrate

@openjdk
Copy link

openjdk bot commented Jun 10, 2024

Going to push as commit 5f9d3e3.
Since your change was applied there have been 39 commits pushed to the master branch:

  • 83b3441: 8322811: jcmd System.dump_map help info has conflicting statements
  • 8aa35ca: 8333833: Remove the use of ByteArrayLittleEndian from UUID::toString
  • de55db2: 8333522: JFR SwapSpace event might read wrong free swap space size
  • a941397: 8329031: CPUID feature detection for Advanced Performance Extensions (Intel® APX)
  • 8d2f9e5: 8333749: Consolidate ConstantDesc conversion in java.base
  • a6fc2f8: 8333412: [s390x] Add support for branch on count instruction
  • cf677c9: 8333823: Update --release 23 symbol information for JDK 23 build 26
  • 18e7d7b: 8333716: Shenandoah: Check for disarmed method before taking the nmethod lock
  • c37d02a: 8312412: Uninitialized klassVtable::_verify_count field
  • 17bd483: 8333680: com/sun/tools/attach/BasicTests.java fails with "SocketException: Permission denied: connect"
  • ... and 29 more: https://git.openjdk.org/jdk/compare/1a50bd09ef7abfa3709edb388c7dbb003d483561...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Jun 10, 2024

@simonis Pushed as commit 5f9d3e3.

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

@simonis
Copy link
Member Author

simonis commented Jun 10, 2024

/backport jdk:jdk23

@openjdk
Copy link

openjdk bot commented Jun 10, 2024

@simonis the backport was successfully created on the branch backport-simonis-5f9d3e3a-jdk23 in my personal fork of openjdk/jdk. To create a pull request with this backport targeting openjdk/jdk:jdk23, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 5f9d3e3a from the openjdk/jdk repository.

The commit being backported was authored by Volker Simonis on 10 Jun 2024 and was reviewed by Vladimir Kozlov.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk:

$ git fetch https://github.com/openjdk-bots/jdk.git backport-simonis-5f9d3e3a-jdk23:backport-simonis-5f9d3e3a-jdk23
$ git checkout backport-simonis-5f9d3e3a-jdk23
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk.git backport-simonis-5f9d3e3a-jdk23

⚠️ @simonis You are not yet a collaborator in my fork openjdk-bots/jdk. An invite will be sent out and you need to accept it before you can proceed.

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.

3 participants