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

8263582: WB_IsMethodCompilable ignores compiler directives #3195

Closed
wants to merge 3 commits into from

Conversation

chhagedorn
Copy link
Member

@chhagedorn chhagedorn commented Mar 25, 2021

While playing around with WB_IsMethodCompilable together with compileonly I ran into some surprising results for methods that should never be compiled (not part of compileonly): isMethodCompilable returns true instead of false when such an excluded method was not yet tried to be compiled.

The reason for it is that WB_IsMethodCompilable directly checks CompilationPolicy::can_be_compiled() which calls Method::is_not_compilable(). However, the ExcludeOption compiler directive is only evaluated lazily upon a compilation attempt. Therefore, if a method was not tried to be compiled, yet, Method::is_not_compilable() always returns false, regardless of any set compiler directive.

I therefore suggest to additionally check the ExcludeOption in WB_IsMethodCompilable. I also cleaned up some wrong use of CompLevel_any and CompLevel_all as suggested by @veresov: CompLevel_any should only be used to query the state as in is_*() methods and CompLevel_all when changing the state is in set_*() methods.

Thanks,
Christian


Progress

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

Issue

  • JDK-8263582: WB_IsMethodCompilable ignores compiler directives

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/3195/head:pull/3195
$ git checkout pull/3195

Update a local copy of the PR:
$ git checkout pull/3195
$ git pull https://git.openjdk.java.net/jdk pull/3195/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 3195

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/3195.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Mar 25, 2021

👋 Welcome back chagedorn! 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 the rfr Pull request is ready for review label Mar 25, 2021
@openjdk
Copy link

openjdk bot commented Mar 25, 2021

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

  • hotspot

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 hotspot-dev@openjdk.org label Mar 25, 2021
@mlbridge
Copy link

mlbridge bot commented Mar 25, 2021

Webrevs

@chhagedorn
Copy link
Member Author

/label add hotspot-compiler

@openjdk openjdk bot added the hotspot-compiler hotspot-compiler-dev@openjdk.org label Mar 25, 2021
@openjdk
Copy link

openjdk bot commented Mar 25, 2021

@chhagedorn
The hotspot-compiler label was successfully added.

// returns false regardless of any compiler directives if m was not yet tried to be compiled. The compiler directive ExcludeOption
// to prevent a compilation is evaluated lazily and is only applied when a compilation for m is attempted.
// Another problem is that Method::is_not_compilable() only returns true for CompLevel_any if C1 AND C2 cannot compile it.
// This means that a compilation of m must have been attempted for C1 and C2 before WB::isMethodCompilable(m, CompLevl_any) will
Copy link
Contributor

Choose a reason for hiding this comment

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

A typo "CompLevl_any" -> "CompLevel_any".

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, fixed it.

@openjdk
Copy link

openjdk bot commented Mar 25, 2021

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

8263582: WB_IsMethodCompilable ignores compiler directives

Reviewed-by: iveresov, kvn, 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 128 new commits pushed to the master branch:

  • 21e7402: 8263707: C1 RangeCheckEliminator support constant array and NewMultiArray
  • 2ad6f2d: 8263896: Make not_suspended parameter from ObjectMonitor::exit() have default value
  • b652198: 8264429: Test runtime/cds/appcds/VerifyWithDefaultArchive.java assumes OpenJDK build
  • 2c9365d: 8264271: Avoid creating non_oop_word oops
  • daeca3f: 8262958: (fs) UnixUserDefinedFileAttributeView cleanup
  • af02883: 8264191: Javadoc search is broken in Internet Explorer
  • 6e74c3a: 8264193: Remove TRAPS parameters for modules and defaultmethods
  • ee5e00b: 8264279: Shenandoah: Missing handshake after JDK-8263427
  • ac604a1: 8264374: Shenandoah: Remove leftover parallel reference processing argument
  • f3726a8: 8264020: Optimize double negation elimination
  • ... and 118 more: https://git.openjdk.java.net/jdk/compare/7b81f8e34b228772e4b05a7826801d31cbef640f...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 25, 2021
@chhagedorn
Copy link
Member Author

Thanks Igor for your review!

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.

I would like to hear from @neliasso why ExcludeOption is treated so specially ().
Why m->is_not_compilable() returns false when ExcludeOption is used?

if (comp_level == CompLevel_any) {
// Both compilers could have ExcludeOption set. Check all combinations.
bool excluded_c1 = is_excluded_for_compiler(CompileBroker::compiler1(), mh);
bool excluded_c2 = is_excluded_for_compiler(CompileBroker::compiler2(), mh);
Copy link
Contributor

Choose a reason for hiding this comment

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

May be use next instead as we do in WhiteBox::compile_method at line #992:
AbstractCompiler *comp = CompileBroker::compiler(comp_level);

Copy link
Member Author

Choose a reason for hiding this comment

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

The problem is that CompileBroker::compiler() returns NULL for CompLevel_any. And even if it returned one compiler, I also need to check the other one to decide if the method is completly non-compilable. That's why I added this additional logic for CompLevel_any.

Copy link
Contributor

Choose a reason for hiding this comment

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

I thought exclude command does not specify which compilation level (and corresponding compiler) is disabled - it disables all compilations.
But may be it is not true for directives. @neliasso, please, correct me if I am wrong.

Choose a reason for hiding this comment

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

I thought exclude command does not specify which compilation level (and corresponding compiler) is disabled - it disables all compilations.
But may be it is not true for directives. @neliasso, please, correct me if I am wrong.

You can set Exclude differently for c1 and c2. That's sometimes very handy when creating more complex combinations of directives.

Copy link
Contributor

Choose a reason for hiding this comment

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

Changes good then.

Copy link

@neliasso neliasso 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.

if (comp_level == CompLevel_any) {
// Both compilers could have ExcludeOption set. Check all combinations.
bool excluded_c1 = is_excluded_for_compiler(CompileBroker::compiler1(), mh);
bool excluded_c2 = is_excluded_for_compiler(CompileBroker::compiler2(), mh);

Choose a reason for hiding this comment

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

I thought exclude command does not specify which compilation level (and corresponding compiler) is disabled - it disables all compilations.
But may be it is not true for directives. @neliasso, please, correct me if I am wrong.

You can set Exclude differently for c1 and c2. That's sometimes very handy when creating more complex combinations of directives.

if (comp_level == CompLevel_any) {
// Both compilers could have ExcludeOption set. Check all combinations.
bool excluded_c1 = is_excluded_for_compiler(CompileBroker::compiler1(), mh);
bool excluded_c2 = is_excluded_for_compiler(CompileBroker::compiler2(), mh);
Copy link
Contributor

Choose a reason for hiding this comment

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

Changes good then.

@chhagedorn
Copy link
Member Author

Thanks @vnkozlov and @neliasso for your reviews!

@chhagedorn
Copy link
Member Author

/integrate

@openjdk openjdk bot closed this Mar 31, 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 31, 2021
@openjdk
Copy link

openjdk bot commented Mar 31, 2021

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

  • 928fa5b: 8244540: Print more information with -XX:+PrintSharedArchiveAndExit
  • e073486: 8262093: java/util/concurrent/tck/JSR166TestCase.java failed "assert(false) failed: unexpected node"
  • 815248a: 8264148: Update spec for exceptions retrofitted for exception chaining
  • 353807c: 8263898: (fs) Files.newOutputStream on the "NUL" special device throws FileSystemException: "nul: Incorrect function" (win)
  • 2bd80f9: 8264326: Modernize javax.script.ScriptEngineManager and related classes' implementation
  • b08d638: 8262503: Support records in Dynalink
  • 21e7402: 8263707: C1 RangeCheckEliminator support constant array and NewMultiArray
  • 2ad6f2d: 8263896: Make not_suspended parameter from ObjectMonitor::exit() have default value
  • b652198: 8264429: Test runtime/cds/appcds/VerifyWithDefaultArchive.java assumes OpenJDK build
  • 2c9365d: 8264271: Avoid creating non_oop_word oops
  • ... and 124 more: https://git.openjdk.java.net/jdk/compare/7b81f8e34b228772e4b05a7826801d31cbef640f...master

Your commit was automatically rebased without conflicts.

Pushed as commit ab6faa6.

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

@chhagedorn chhagedorn deleted the JDK-8263582 branch May 31, 2021 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot hotspot-dev@openjdk.org hotspot-compiler hotspot-compiler-dev@openjdk.org integrated Pull request has been integrated
4 participants