Skip to content

8276711: compiler/codecache/cli tests failing when SegmentedCodeCache used with -Xint #7650

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 3 commits into from

Conversation

coleenp
Copy link
Contributor

@coleenp coleenp commented Mar 1, 2022

In Loom, when using -Xint, the +SegmentedCodeCache option cannot be used because it doesn't generate a code heap for nmethods, and in loom the compiler needs to generate an nmethod for Continuation.enterSpecial even with -Xint.
This change is @rickard 's loom change with the tests fixed so they pass for it. One tests for the new warning message and code cache usage, and the others remove the Xint tests.
Tested with tier1-4.


Progress

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

Issue

  • JDK-8276711: compiler/codecache/cli tests failing when SegmentedCodeCache used with -Xint

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 7650

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

Using diff file

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

@bridgekeeper
Copy link

bridgekeeper bot commented Mar 1, 2022

👋 Welcome back coleenp! 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 1, 2022
@openjdk
Copy link

openjdk bot commented Mar 1, 2022

@coleenp 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 1, 2022
@mlbridge
Copy link

mlbridge bot commented Mar 1, 2022

Webrevs

Comment on lines 4117 to 4122
if (_mode == _int) {
if (SegmentedCodeCache) {
warning("SegmentedCodeCache has no meaningful effect with -Xint");
FLAG_SET_DEFAULT(SegmentedCodeCache, false);
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Isn't this better placed in Arguments::set_mode_flags where the other compiler related flags get turned off?

Copy link
Contributor

Choose a reason for hiding this comment

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

SegmentedCodeCache should be set in compiler/compilerDefinitions.cpp:
https://github.com/openjdk/jdk/blob/master/src/hotspot/share/compiler/compilerDefinitions.cpp#L294

Copy link
Contributor Author

@coleenp coleenp Mar 1, 2022

Choose a reason for hiding this comment

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

I replied on email but I don't see it and this is better here. I should really change this to be:

if (FLAG_IS_CMDLINE(SegmentedCodeCache)) {
}
Since this code is checking for someone setting it on the command line with -Xint. The code in compilerDefinitions.cpp sets the flag ergonomically if the code cache is big and if tiered compilation is on. I believe this is after the code in arguments.cpp. So this code won't reset it to true, if I'm following it right.
edit: yes, I'll check the flag in compilerDefinitions.cpp.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree that the warning should be issued if flag is set on command line together with -Xint.
In this case you need add this check to CompilerConfig::check_args_consistency() where different compiler flags are set to false when we run with Interpreter:
https://github.com/openjdk/jdk/blob/master/src/hotspot/share/compiler/compilerDefinitions.cpp#L493

Copy link
Member

Choose a reason for hiding this comment

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

Thanks Coleen, seems the use of set_mode_flags is somewhat flawed as you can change any of the flags that it tries to force on/off simply by having them later on the command-line.

You could do as @vnkozlov suggests and move this check into compilerDefinitions.cpp as CompilerConfig::ergo_initialize() is called just a few lines above this.

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 Vladimir, that's a better place for it. There are other checks for inconsistent flags with -Xint in check_args_consistency(). One of the tests still fails with that change so I'll have to figure out why.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I moved the check but TieredStopAtLevel=0 still allocates code heaps for nmethods, so the check only checks for the -Xint in arguments. I don't know if this makes sense or not in the code heap allocation code, but the codecache/cli tests test for sizes of code heaps pass with this change.

@mlbridge
Copy link

mlbridge bot commented Mar 2, 2022

Mailing list message from coleen.phillimore at oracle.com on hotspot-dev:

On 3/1/22 4:29 PM, David Holmes wrote:

On Tue, 1 Mar 2022 20:50:23 GMT, Coleen Phillimore <coleenp at openjdk.org> wrote:

In Loom, when using -Xint, the +SegmentedCodeCache option cannot be used because it doesn't generate a code heap for nmethods, and in loom the compiler needs to generate an nmethod for Continuation.enterSpecial even with -Xint.
This change is @rickard 's loom change with the tests fixed so they pass for it. One tests for the new warning message and code cache usage, and the others remove the Xint tests.
Tested with tier1-4.
src/hotspot/share/runtime/arguments.cpp line 4122:

4120: FLAG_SET_DEFAULT(SegmentedCodeCache, false);
4121: }
4122: }
Isn't this better placed in Arguments::set_mode_flags where the other compiler related flags get turned off?

Well, the default for SegmentedCodeCache is off.? It's set here because
it's after that option is found on the command line.? Maybe the line
should be

if (FLAG_IS_CMDLINE(SegmentedCodeCache)) {
}

to make it more clear.

Coleen

@@ -524,6 +523,13 @@ bool CompilerConfig::check_args_consistency(bool status) {
#endif
}

// TieredStopAtLevel==0 allocates nmethod space in the code heap with
// SegmentedCodeCache so only disallow the option for -Xint.
if (Arguments::is_interpreter_only() && FLAG_IS_CMDLINE(SegmentedCodeCache)) {
Copy link
Member

Choose a reason for hiding this comment

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

You need to check SegmentedCodeCache==true else you will generate the warning if someone is explicitly turning it off in combination with -Xint.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, code should follow pattern in previous lines:

    if (SegmentedCodeCache) {
      if (!FLAG_IS_DEFAULT(SegmentedCodeCache)) {
        warning("SegmentedCodeCache has no meaningful effect with -Xint");
      }
      FLAG_SET_CMDLINE(SegmentedCodeCache, false);
    }

Copy link
Contributor

Choose a reason for hiding this comment

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

And you should include it in previous scope which checks if (Arguments::is_interpreter_only())

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The previous scope checks CompilerConfig::is_interpreter_only() which includes TieredStopAtLevel == 0, so it's not the same there.

@@ -524,6 +523,13 @@ bool CompilerConfig::check_args_consistency(bool status) {
#endif
}

// TieredStopAtLevel==0 allocates nmethod space in the code heap with
Copy link
Contributor

Choose a reason for hiding this comment

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

I would prefer to not have special case TieredStopAtLevel==0. Unless you want to test loom when JIT compilers are disabled. Currently we don't run any tests with such setting.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tested with this setting and it works fine with -XX:+SegmentedCodeCache because the code for segmented code cache only checks Arguments::is_interpreter_only(). This doesn't seem right to me, but the testing also expects this to work. I could fix the tests to not do this. Now I don't know what anyone wants!

… a nmethod heaps, and fix tests accordingly.
@coleenp
Copy link
Contributor Author

coleenp commented Mar 2, 2022

I pushed a change to make TieredStopAtLevel=0 also disable SegmentCodeCache and fixed the tests for that also, but am rerunning tests tier1-4, then 5-6.

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.

Good.

@openjdk
Copy link

openjdk bot commented Mar 2, 2022

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

8276711: compiler/codecache/cli tests failing when SegmentedCodeCache used with -Xint

Reviewed-by: kvn, dholmes

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 12 new commits pushed to 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 Mar 2, 2022
@coleenp
Copy link
Contributor Author

coleenp commented Mar 2, 2022

Thanks Vladimir. Tiers 1-4 passed. Now 5-6 also.

@@ -368,7 +368,7 @@ bool CodeCache::heap_available(int code_blob_type) {
if (!SegmentedCodeCache) {
// No segmentation: use a single code heap
return (code_blob_type == CodeBlobType::All);
} else if (Arguments::is_interpreter_only()) {
} else if (CompilerConfig::is_interpreter_only()) {
Copy link
Member

Choose a reason for hiding this comment

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

Doesn't this introduce a very subtle change in behaviour in relation to the handling of MethodNonProfiled?
@vnkozlov please confirm this is what you intended - I don't know the implications.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

According to my conversation with Rickard, TierStopAtLevel=0 is the same as -Xint. If TieredStopAtLevel=0, the compiler won't allocate nmethods in the MethodProfiled and MethodNonProfiled areas anyway, so this won't allocate them now.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this code was missed during Igor's V. changes which introduced CompilerConfig::is_interpreter_only().
Coleen is correct, with TieredStopAtLevel=0 all JIT compilers are disabled. MethodNonProfiled is codeheap for tier1 (C1) and tier4 (C2) compiled nmethods. It does not make sense to have such codeheap when compilation disabled.

Copy link
Member

Choose a reason for hiding this comment

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

Okay, so does that mean this block:

} else {
    // No TieredCompilation: we only need the non-nmethod and non-profiled code heap
    return (code_blob_type == CodeBlobType::NonNMethod) ||
           (code_blob_type == CodeBlobType::MethodNonProfiled);
}

is actually unreachable?

Copy link
Contributor

Choose a reason for hiding this comment

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

It is reachable for -XX:-TieredCompilation when only C2 is used. Or when only tier1 C1 is used with -XX:TieredStopAtLevel=1.

Copy link
Member

Choose a reason for hiding this comment

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

Ah I see. Thanks for clarifying @vnkozlov !

Copy link
Contributor Author

Choose a reason for hiding this comment

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

-XX:TieredStopAtLevel=1 is the old -client switch. Thanks Vladimir for confirming.

@coleenp
Copy link
Contributor Author

coleenp commented Mar 3, 2022

Thanks David.
/integrate

@openjdk
Copy link

openjdk bot commented Mar 3, 2022

Going to push as commit 7822cbc.
Since your change was applied there have been 17 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Mar 3, 2022

@coleenp Pushed as commit 7822cbc.

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

@coleenp coleenp deleted the xint branch March 3, 2022 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot hotspot-dev@openjdk.org integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

3 participants