-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8341413: Stop including osThread_os.hpp in the middle of the OSThread class #21306
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 stefank! A progress list of the required criteria for merging this PR into |
|
@stefank 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 45 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 |
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.
I personally don't have an issue with the current technique to generate a single platform-specific OSThread class, but this refactoring is also okay. There is some unfortunate duplication of the boiler-plate code for the class but not too bad.
I'm tempted to suggest pushing the _startThread_lock support into OSThreadBase under #ifndef windows, just to reduce some duplication. (I may also look at using that for Windows too in the near future, which would address it then.)
I could not see where thread_type() is actually used so possibly an additional cleanup opportunity there (not necessarily for this PR).
I don't have any concerns with any of the items that you flagged.
Thanks
|
Aside: forgot to mention, something that seemed odd to me is why we have the OSThread stuff in the os-cpu VMStructs files instead of the os one? I didn't spot anything CPU specific about that. |
|
It is interesting to me that we are using Even though I am not sure about the usefulness of |
True. The problem with allocations within the constructor is that we have no way to convey to the caller that we had a failure. So if allocation of OSThread fails we act like it is non-fatal because we can just throw a Java exception from |
Setting a bool field during construction is something we do in a lot of places to signal if the construction was successful. OSThread* osthread = new (std::nothrow) OSThread();
if (osthread == nullptr || osthread->has_constructor_failed()) {
delete osthread;
return false;
} |
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.
Nice cleanup but one question about SA.
| /* Threads (NOTE: incomplete) */ \ | ||
| /******************************/ \ | ||
| nonstatic_field(OSThread, _thread_id, OSThread::thread_id_t) \ | ||
| nonstatic_field(OSThread, _unique_thread_id, uint64_t) |
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.
Does the SA actually use these? I don't see any SA changes in this patch. If it doesn't, we should remove it until there is someone that might add support for this. We're not enhancing the SA at this point.
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 think the SA is using these. There are references to them in the various SA files.
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 see now why you don't also have to change SA.
Thanks for not blocking this suggestion.
I pushed a change that moved the NONCOPYABLE macro. I did a little experiment with moving even more code to the OSThreadBase, but I'm not sure if this is wanted or not. I've put that change here in-case someone wants to take a look:
I'll leave this for next time someone wants to do a little bit of clean-up in this area. One interesting thing that we found while looking at this is that the AIX port has the
Maybe one reason to keep it is as an aid when debugging with a debugger? OTOH, while playing around with the patch linked above I found that the field is not available on Windows, and it's also left uninitialized when we call
Thanks for reviewing! |
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 for removing this inline include.
| /* Threads (NOTE: incomplete) */ \ | ||
| /******************************/ \ | ||
| nonstatic_field(OSThread, _thread_id, OSThread::thread_id_t) \ | ||
| nonstatic_field(OSThread, _unique_thread_id, uint64_t) |
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 see now why you don't also have to change SA.
|
Thanks for reviewing! |
Looks like a copy'n'paste bug. AIX starts the new thread in the suspended state the same as Windows. So less sharing of the startThread_lock than I thought at present. |
I did some archaeology on this one. The thread_type was introduced way back in May 2000 on Linux as it was needed for the newly started thread to determine whether it had to install (and later remove) an alternate signal stack. When we later stopped using alt-signal-stack (I'm going to guess this was when we switched from LinuxThreads to NPTL) the field was no longer used, but meanwhile we used the ThreadType enum to control initial stack sizes. So Windows never had a thread_type field and BSD/AIX likely just blindly copied it from the Linux code. Attaching a thread never involved using alt-signal-stack so for attached threads it was left uninitialized. So I think we can clean this up - I will file a RFE. |
|
/integrate |
|
Going to push as commit 72ac72f.
Your commit was automatically rebased without conflicts. |
Some HotSpot files have an interesting include pattern where the platform dependent code is included straight into the class containing the shared implementation.
This has various interesting effects to the code layout and readability of the code. I propose we stop doing this, where possible, and instead clearly separate the shared code and the platform specific code in separate classes. This then allows us to use the standard include patterns that we use for most of our code.
This PR is a suggestion for how to untangle this for the OSThread class.
Things in the code that changed with this patch that might be good to take an extra look at:
pd_initialize/pd_destroywas converted into constructor/destructor_caller_sigmaskis one of the interesting once, because it's sizable array. I still don't think that is problematic because all the other code we run to start threads, but if I get push back on this I'll comment it out.new Monitorcall and thesigemptysetcall_thread_idto the platform filesthread_id_ttypedef.thread_id_for_printingfunction for those calls that want a unified integer type that can be printed. An alternative to this could be to use a non-virtual call, but that requires us to to defineOSThreadBase::thread_id_for_printingin the platform files.Tested: tier1-3, (excluding AIX, which I can't build/test)
Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/21306/head:pull/21306$ git checkout pull/21306Update a local copy of the PR:
$ git checkout pull/21306$ git pull https://git.openjdk.org/jdk.git pull/21306/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 21306View PR using the GUI difftool:
$ git pr show -t 21306Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/21306.diff
Webrev
Link to Webrev Comment