-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8340733: Add scope for relaxing constraint on JavaCalls from CompilerThread #21171
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
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/CompilerThreadCanCallJavaScope.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| /* | ||
| * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. | ||
| * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
| * | ||
| * This code is free software; you can redistribute it and/or modify it | ||
| * under the terms of the GNU General Public License version 2 only, as | ||
| * published by the Free Software Foundation. | ||
| * | ||
| * This code is distributed in the hope that it will be useful, but WITHOUT | ||
| * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
| * version 2 for more details (a copy is included in the LICENSE file that | ||
| * accompanied this code). | ||
| * | ||
| * You should have received a copy of the GNU General Public License version | ||
| * 2 along with this work; if not, write to the Free Software Foundation, | ||
| * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
| * | ||
| * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | ||
| * or visit www.oracle.com if you need additional information or have any | ||
| * questions. | ||
| */ | ||
| package jdk.vm.ci.hotspot; | ||
|
|
||
| /** | ||
| * Scope used to potentially change whether the current thread can make VM-to-Java calls. | ||
| * A scope is exited by the {@link #close()} method so it should be used in a | ||
| * try-with-resources statement. | ||
| * | ||
| * The scope does nothing if the current thread is not a HotSpot VM CompilerThread | ||
| * for a JVMCI compiler. | ||
| */ | ||
| public class CompilerThreadCanCallJavaScope implements AutoCloseable { | ||
|
|
||
| /** | ||
| * Thread state used during the scope. | ||
| */ | ||
| private final boolean state; | ||
|
|
||
| /** | ||
| * Non-null iff the thread state needs resetting in {@link #close()}. | ||
| */ | ||
| private final CompilerToVM vm; | ||
|
|
||
| /** | ||
| * The thread on which the constructor was called. | ||
| */ | ||
| private final Thread thread; | ||
|
|
||
| /** | ||
| * Opens a scope to allow/disallow the current thread to make VM-to-Java calls. | ||
| * The scope is a no-op if the current thread is not a HotSpot VM CompilerThread | ||
| * for a JVMCI compiler. | ||
| * | ||
| * @param newState true/false to allow/disallow VM-to-Java calls within the scope | ||
| */ | ||
| public CompilerThreadCanCallJavaScope(boolean newState) { | ||
| this.state = newState; | ||
| this.thread = Thread.currentThread(); | ||
| CompilerToVM vm = HotSpotJVMCIRuntime.runtime().getCompilerToVM(); | ||
| if (vm.updateCompilerThreadCanCallJava(newState)) { | ||
| this.vm = vm; | ||
| } else { | ||
| this.vm = null; | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Resets the state of the current thread with respect to whether it can make | ||
| * VM-to-Java calls to what it was before the constructor was called. | ||
| * | ||
| * @throws IllegalStateException if called on a different thread than the constructor | ||
| */ | ||
| @Override | ||
| public void close() { | ||
| if (this.thread != Thread.currentThread()) { | ||
| throw new IllegalStateException(); | ||
| } | ||
|
|
||
| if (vm != null) { | ||
| vm.updateCompilerThreadCanCallJava(!state); | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not correct.The scope has to capture the original_can_call_javavalue in the constructor and restore it here inclose.Actually it works if
c2v_updateCompilerThreadCanCallJavadoes not haveC2V_BLOCK