-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
8260341: CDS dump VM init code does not check exceptions #2494
8260341: CDS dump VM init code does not check exceptions #2494
Conversation
👋 Welcome back iklam! A progress list of the required criteria for merging this PR into |
Webrevs
|
Hi Ioi, 1503 void ClassLoader::initialize_module_path(TRAPS) { |
I thought it was a commonly used coding convention, but I could only find a few cases where the code wasn't written by me :-(
I will go back to Using |
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.
What Harold said. We use THREAD if the call is the last call in the function because I thought there was a tail call problem with one of the compilers once. I think this was the bug I was thinking about and it's only in the return statement:
https://bugs.openjdk.java.net/browse/JDK-6889002
If you verified that the HAS_PENDING_EXCEPTION check evaporates, that's fine then, and better to have CHECK. As you say, someone might add some code after it.
@iklam 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:
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 no new commits pushed to the ➡️ To integrate this PR with the above commit message to the |
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.
The changes look good. Thanks!
Harold
I think the problem in JDK-6889002 is only with using
->
The cases that I have changed in this PR are functions with
would be expanded to
I suppose any C++ compiler that can compile HotSpot will elide the |
Could we then get rid of the special CDS handling in jdk/src/hotspot/share/memory/metaspace.cpp Lines 825 to 836 in 837bd89
? |
I filed https://bugs.openjdk.java.net/browse/JDK-8261551 . We need to fix JDK-8261480 first, since we still have some inappropriate use of THREAD during dumping. I split the work into several steps so that the review can be easier. |
Okay, thanks. |
Mailing list message from David Holmes on hotspot-dev: On 11/02/2021 4:13 am, Ioi Lam wrote:
It is something we have been gradually fixing. I'm made a number of
Do all our C++ compilers do this? If they do that is great, but if they
I prefer not to rely on the C++ compiler to remove the exception David |
Mailing list message from Ioi Lam on hotspot-dev: Converting this from a PR discussion What are people's opinion of: ??? void bar(TRAPS); ??? void foo(TRAPS) { vs ??? void foo(TRAPS) { There's no mention of this in Advantage of CHECK: - More readable -- you don't need to ask yourself: - More maintainable. You don't accidentally miss a check if you add new ??? void foo(TRAPS) { Note that we MUST use THREAD when returning a value (see ??? int x(TRAPS); ??? int y(TRAPS) { so there's inconsistency. However, the compiler will given an error if ??? int Y(TRAPS) { Disadvantage of CHECK: - It's not guaranteed that the C compiler will elide it. The code gets ??? inlined bool ThreadShadow::has_pending_exception() const { ??? void foo(Thread*? __the_thread__) { Is it safe to assume that any C compiler that can efficiently compile I am a little worried about the maintenance issue. If we really want to ??? void foo(TRAPS) { which will be preprocessed to ??? void foo(....) { So you can't accidentally add code below it. Thanks |
Mailing list message from David Holmes on hotspot-dev: Hi Ioi,
This isn't really about void functions, nor check at the end. It is if (EXCEPTION_OCCURRED) On 18/02/2021 8:16 am, Ioi Lam wrote: Thanks for doing that.
But you also don't need to ask yourself that because it doesn't matter
True but I would argue that you need to think about the behaviour of bar bar(CHECK);
I think this is an anti-pattern and we should prefer the more explicit: RetType ret = x(CHECK_*); if we want to emphasize use of CHECK.
Don't quite follow that as you wouldn't write anything after a return
I've no idea, but if we can rely on it then I'm okay with always using
I agree that a new macro might be preferable than just using THREAD. Thanks,
|
Mailing list message from Coleen Phillimore on hotspot-dev: My preference is to keep THREAD as an argument if you were going to use For the most part, I don't think it matters if the compiler can optimize Lastly, please no, I don't want to see yet another macro for this Coleen On 2/17/21 8:55 PM, David Holmes wrote:
|
When CDS dumping is enabled, special initialization happens during VM init. However, many of these calls do not properly check for exception. Instead, they rely on the implicit knowledge that
metaspace::allocate()
will exit the VM when allocation fails during CDS dumping. This makes the code hard to understand and tightly coupled tometaspace::allocate()
.The fix is: all code that makes allocation should be using CHECK macros, so each block of code can be individually understood without considering the behavior of
metaspace::allocate()
.I added
TRAPS
to a bunch of CDS-related functions that are called during VM init. In some cases, I changedThread* THREAD
toTRAPS
. This also eliminated a fewThread* THREAD = Thread::current()
calls.The "root" of these calls, such as
MetaspaceShared::prepare_for_dumping()
, now follows this pattern:Progress
Issue
Reviewers
Download
$ git fetch https://git.openjdk.java.net/jdk pull/2494/head:pull/2494
$ git checkout pull/2494