-
Notifications
You must be signed in to change notification settings - Fork 5.8k
8264004: Don't use TRAPS if no exceptions are thrown #3141
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 coleenp! 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 Coleen,
This looks great! Good to see all those false TRAPS usages disappear. I found one more.
Thanks,
David
PS. Annoying that we often needs TRAPS through a call chain just because some leaf method may trigger an OOME. No escaping that unfortunately.
bool rewrite_cp_refs_in_permitted_subclasses_attribute(InstanceKlass* scratch_class); | ||
|
||
void rewrite_cp_refs_in_method(methodHandle method, | ||
methodHandle * new_method_p, TRAPS); | ||
bool rewrite_cp_refs_in_methods(InstanceKlass* scratch_class, TRAPS); |
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 method clears any pending exception and so should not be a TRAPS method.
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.
VM_RedefineClasses::load_new_class_versions
also seems to never throw. These functions should be changed to take a Thread*
parameter, and should use HandleMark em(thread);
to guarantee that an exception never leaves the function.
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.
Both of these functions are good examples of the convention that we're trying to agree on. In, load_new_class_versions, TRAPS is passed to materialize THREAD. THREAD is used then in a lot of places, and also to pass to SystemDictionary::parse_stream(...TRAPS), which does have an exceptional return that must be handled.
Removing TRAPS then adding:
JavaThread* current = JavaThread::current();
changing THREAD to current in most of the places seems ok, but passing 'current' to SystemDictionary::resolve_from_stream loses the information visually that this function returns an exception that must be handled.
We need some meta-writeup rather than these decisions made in pull requests, because if we made these decisions collectively, I missed out.
@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:
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 36 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.
LGTM. I think suggested TRAPS changes could be done in a separate REF.
Mailing list message from David Holmes on serviceability-dev: On 23/03/2021 9:54 pm, Coleen Phillimore wrote:
Okay ... Only a function that upon return may have directly, or indirectly, If a function is going to call a TRAPS function but clear the exception, How to manifest THREAD depends on the exact context, and we already have In this case I would expect to see: jvmtiError VM_RedefineClasses::load_new_class_versions(Thread* current) { I'll point out, to be clear that I recognise it, that the existing CATCH
Once we've fleshed things out we can propose them for the style guide. The important things (to me at least) at the moment are: - we get rid of TRAPS from non-exception throwing code Cheers, |
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
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.
Latest changes look good.
Thanks, Harold
In your comments above, this makes sense to me: |
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.
Looks good.
You should also do JDI test runs for this changeset and you should wait
to hear from the Serviceability team before integration.
I ran the jvmti and jdi tests, as well as the serviceability/jvmti/RedefineClasses tests, and jdk/java/lang/instrument tests. |
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.
Thread* THREAD = current; // for exception processing
is used only when the current method does not declare TRAPS, which means it should never throw. As a convention, I think the above code should be accompanied with by
HandleMark em(THREAD);
to ensure that the exceptions are not unintentionally leaked.
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.
Updates look good - thanks.
I agree with Ioi about adding ExceptionMark as part of this usage pattern - it captures the intent that no exceptions are allowed to escape.
Thanks,
David
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.
Looks good!
Thanks,
David
Thanks for reviewing! |
@coleenp Since your change was applied there have been 48 commits pushed to the
Your commit was automatically rebased without conflicts. Pushed as commit 5d7e93c. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
Removed the TRAPS in function declarations in jvmtiRedefineClasses and in ConstantPool merging functions.
Tested with vmTestbase/nsk/jvmti and tier1 (in progress).
Progress
Issue
Reviewers
Download
To checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/3141/head:pull/3141
$ git checkout pull/3141
To update a local copy of the PR:
$ git checkout pull/3141
$ git pull https://git.openjdk.java.net/jdk pull/3141/head