-
Notifications
You must be signed in to change notification settings - Fork 5.8k
8296470: Refactor VMError::report STEP macro to improve readability #11018
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
Conversation
👋 Welcome back aboldtch! A progress list of the required criteria for merging this PR into |
Webrevs
|
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.
Hi Axel,
I'm fine with the line break, but unsure about the STEP_IF.
I don't think it adds much readability, but it is a wide-spread patch that will add unnecessary noise for us backporters. Just my opinion, lets see what others think.
Cheers, Thomas
st->print_cr("Will crash now (TestCrashInErrorHandler=%u)...", | ||
TestCrashInErrorHandler); | ||
controlled_crash(TestCrashInErrorHandler); | ||
} | ||
return true; | ||
}()) |
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.
I don't think this is necessary. The tests for secondary crash handling are exhaustive, there is no reason why it should differ from crash condition handling outside of a crash condition. If the signal handler is correctly set up, it should work. If it is not, the prior step is sufficient.
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.
I don't think it adds much readability, but it is a wide-spread patch that will add unnecessary noise for us backporters. Just my opinion, lets see what others think.
I was worried about that too. This patch initially came about when I was writing #11017 which required rewriting the macro logic and add extra nested scope. The fact that the common case for a step was checking the verbose flag made me refactor out just the verbose case. And then I just refactored out the rest the few extra conditions as well.
But I am pretty ambivalent about this change. #11017 contains the newline changes as well. So if there are more opinions that this makes back porting work harder it can be dropped.
I don't think this is necessary. The tests for secondary crash handling are exhaustive, there is no reason why it should differ from crash condition handling outside of a crash condition. If the signal handler is correctly set up, it should work. If it is not, the prior step is sufficient.
I added it because in my initial change (9449501), a theoretical crash in a condition would recover but not proceed to the next step. The test change is to avoid such a regression if someone thinks of doing the same simplification of the macro condition logic. (It would crash before _current_step
was updated.)
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.
Ah, I understand. But you changed this to two nested ifs. So this is no problem anymore.
I still don't think it is needed with your new version. IIUC it prevents us from the problem you describe if someone changes the STEP macros in the future and has a very complex if statement that would crash.
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.
About the STEP_IF, the more I look at it, the more I like it. So I am ambivalent. Let's hear what others say (@coleenp?).
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.
Ok, I was afraid to look at this. I do like STEP_IF. Maybe the longer expressions could be functions ?
Are you think of the conditions in the STEP_IF macro? I think at least some of the longer expressions can be put on multiple lines. I guess it is already done for For the step logic I think there are a few places that things can be refactored without losing the ability of easily comparing the VMError::report code to the hs_err file output. |
One thing that worries me a bit is that our test coverage is not that great. We have jtreg/runtime/Errorhandling, but that is not much. In particular we miss good tests for robustness (e.g. that alert us if more STEPs start failing, that reporting can cope with a partially corrupted JVM context, or an invalid Thread::current, or pre-init, or if we have very little stack or C-Heap left)... Unfortunately, tests like these tend to be annoyingly hard to get right. At SAP, we have more tests, but never really managed to get them completely clean. |
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.
Ok!
record_step_start_time(); \ | ||
_step_did_timeout = false; \ | ||
if ((cond)) { | ||
// [Step logic] |
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.
nit: newline please?
_step_did_timeout = false; \ | ||
if ((cond)) { | ||
// [Step logic] | ||
# define STEP(s) STEP_IF(s, true) |
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.
nit: newline please?
@xmas92 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 316 new commits pushed to the
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 |
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.
I apologize for the latency in reviewing this. It looks really nice. Thank you.
No worries, thanks for the reviews. |
/integrate |
Going to push as commit 1301fb0.
Your commit was automatically rebased without conflicts. |
Refactor the STEP macro in VMError::report to improve readability.
Right now the macro contains multiple statements on one line and the non-conventional control flow is even harder to understand.
This enhancement aims to do two things:
Testing: tier 1 + GHA
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/11018/head:pull/11018
$ git checkout pull/11018
Update a local copy of the PR:
$ git checkout pull/11018
$ git pull https://git.openjdk.org/jdk pull/11018/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 11018
View PR using the GUI difftool:
$ git pr show -t 11018
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/11018.diff