-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8231269: CompileTask::is_unloaded is slow due to JNIHandles type checks #24018
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
Open
shipilev
wants to merge
43
commits into
openjdk:master
Choose a base branch
from
shipilev:JDK-8231269-compile-task-weaks
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+352
−43
Open
Changes from all commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
cc8345e
JNIHandles -> VM(Weak)
shipilev 2978cb5
Merge branch 'master' into JDK-8231269-compile-task-weaks
shipilev d965fef
Shared utility class for method unload blocking
shipilev 669dc6a
Merge branch 'master' into JDK-8231269-compile-task-weaks
shipilev b454cd4
Fully encapsulate Method*
shipilev bc4ab32
Renames
shipilev 7f32b31
Touchups
shipilev 2ec579c
Purge extra fluff
shipilev 63650fa
Fix VMStructs
shipilev 91d38ff
Allow UMH::_method access from VMStructs
shipilev 6f26b73
Merge branch 'master' into JDK-8231269-compile-task-weaks
shipilev e165f59
Inline guard
shipilev eb5e21d
Merge branch 'master' into JDK-8231269-compile-task-weaks
shipilev 4db23b3
Attempt at phasing doc
shipilev 07a3cae
Do not accept nullptr methods
shipilev be3a3d6
Merge branch 'master' into JDK-8231269-compile-task-weaks
shipilev eaf3f14
Simplify a bit
shipilev 9f44cb5
Improve get_method_blocker
shipilev baea6cd
Move to oops
shipilev f53cf7a
Merge branch 'master' into JDK-8231269-compile-task-weaks
shipilev ff5463a
Rework for safer concurrency
shipilev 1cdbed2
Tracking UMH state more accurately
shipilev f60bf96
Fix build failures: add more headers
shipilev ce737c5
More thorough locking and redefinition escape hatch
shipilev f239c22
Fix release builds
shipilev 33e545e
More touchups
shipilev a2f9955
Merge branch 'master' into JDK-8231269-compile-task-weaks
shipilev 7f4ed16
Simplify select_for_compilation
shipilev 59798bd
Rename CompilerTask::is_unloaded back to avoid losing comment context
shipilev 4d33a4d
Merge branch 'master' into JDK-8231269-compile-task-weaks
shipilev 43e5fca
Merge branch 'master' into JDK-8231269-compile-task-weaks
shipilev 51390bc
Spin lock induces false sharing
shipilev f6bbc8d
More touchups
shipilev 22b6629
Merge branch 'master' into JDK-8231269-compile-task-weaks
shipilev 0c1c5d6
Switch to mutable
shipilev d5e482a
Merge branch 'master' into JDK-8231269-compile-task-weaks
shipilev d5a8a27
Merge branch 'master' into JDK-8231269-compile-task-weaks
shipilev 41dbb21
Deal with things without spinlocks
shipilev 54733a6
Move release() to destructor
shipilev 70a8b4b
Tune up for release builds
shipilev 576a259
Further simplify the API
shipilev 66bb4da
Use enum class
shipilev b27c063
Docs touchup
shipilev 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright Amazon.com Inc. 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. | ||
* | ||
*/ | ||
|
||
#ifndef SHARE_COMPILER_COMPILETASK_INLINE_HPP | ||
#define SHARE_COMPILER_COMPILETASK_INLINE_HPP | ||
|
||
#include "compiler/compileTask.hpp" | ||
|
||
#include "oops/unloadableMethodHandle.inline.hpp" | ||
|
||
inline Method* CompileTask::method() const { | ||
return _method_handle.method(); | ||
} | ||
|
||
#endif // SHARE_COMPILER_COMPILETASK_INLINE_HPP |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
/* | ||
* Copyright Amazon.com Inc. 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. | ||
* | ||
*/ | ||
|
||
#ifndef SHARE_OOPS_UNLOADABLE_METHOD_HANDLE_HPP | ||
#define SHARE_OOPS_UNLOADABLE_METHOD_HANDLE_HPP | ||
|
||
#include "memory/padded.hpp" | ||
#include "oops/oopHandle.hpp" | ||
#include "oops/weakHandle.hpp" | ||
|
||
// Unloadable method handle. | ||
// | ||
// This handle allows holding to Method* safely without delaying class unloading | ||
// of its holder. | ||
// | ||
// This handle can be in 2 states: | ||
// 1. Unsafe (weak). Method* is present, but its holder is only weakly-reachable, and can | ||
// be unloaded. Users need to check is_safe() before calling method(). | ||
// method() is safe to call iff we have not crossed a safepoint since construction | ||
// or last is_safe() check. Calling make_always_safe() after is_safe() check | ||
// moves handle to the strong state. | ||
// 2. Safe (strong). Method* holder is strongly reachable, cannot be unloaded. | ||
// Calling method() is always safe in this state. | ||
// | ||
// The handle transitions are one-shot: | ||
// unsafe (weak) --(make_always_safe) --> safe (strong) | ||
// | ||
// There are internal shortcuts that bypass this mechanics when handle knows | ||
// the method holder is permanent and would not be unloaded. This is an implementation | ||
// detail, it does not change any external contract. Using this handle for permanent | ||
// method holders provides future safety. | ||
// | ||
// Common usage pattern: | ||
// | ||
// UnloadableMethodHandle mh(method); // Now in unsafe (weak) state. | ||
// mh.method()->print_on(tty); // method() is good until the next safepoint. | ||
// <safepoint> | ||
// if (!mh.is_safe()) { // Safe to use method()? | ||
// return; // Nope! | ||
// } | ||
// mh.method()->print_on(tty); // method() is good until the next safepoint. | ||
// mh.make_always_safe(); // Now in safe (strong) state. | ||
// <safepoint> | ||
// mh.method()->print_on(tty); // method() is always safe now. | ||
// | ||
|
||
class Method; | ||
|
||
class UnloadableMethodHandle { | ||
friend class VMStructs; | ||
private: | ||
enum class State { | ||
PERMANENT, | ||
WEAK, | ||
STRONG, | ||
RELEASED, | ||
}; | ||
|
||
State volatile _state; | ||
|
||
Method* _method; | ||
WeakHandle _weak_handle; | ||
OopHandle _strong_handle; | ||
|
||
inline State get_state() const; | ||
inline void set_state(State to); | ||
inline bool transit_state(State from, State to); | ||
inline oop get_unload_blocker(Method* method); | ||
|
||
public: | ||
UnloadableMethodHandle(Method* method); | ||
~UnloadableMethodHandle(); | ||
|
||
inline Method* method() const; | ||
inline Method* method_unsafe() const; | ||
|
||
inline bool is_safe() const; | ||
void make_always_safe(); | ||
}; | ||
|
||
#endif // SHARE_OOPS_UNLOADABLE_METHOD_HANDLE_HPP |
Oops, something went wrong.
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.