Skip to content
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

8289230: Move PlatformXXX class declarations out of os_xxx.hpp #9303

Conversation

iklam
Copy link
Member

@iklam iklam commented Jun 28, 2022

There are only two implementations of these classes (one for windows, and one for posix):

  • PlatformEvent
  • PlatformParker
  • PlatformMutex
  • PlatformMonitor
  • ThreadCrashProtection

Before this PR, these classes are declared in os_xxx.hpp. This causes excessive inclusion of the large header file os.hpp by popular headers such as mutex.hpp, which needs only the declaration of PlatformMutex but not the other stuff in os.hpp

This PR moves the declarations to park_posix.hpp, mutex_posix.hpp, etc.

Note: ideally, the definition of PlatformParker/PlatformEvent should be moved to park_posix.cpp, and PlatformMutex/PlatformMonitor should be moved to mutex_posix.cpp. However, the definition of these 4 classes are intertwined, so I'll leave them inside os_posix.cpp for now. (Same for the Windows version).


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8289230: Move PlatformXXX class declarations out of os_xxx.hpp

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/9303/head:pull/9303
$ git checkout pull/9303

Update a local copy of the PR:
$ git checkout pull/9303
$ git pull https://git.openjdk.org/jdk pull/9303/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 9303

View PR using the GUI difftool:
$ git pr show -t 9303

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/9303.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Jun 28, 2022

👋 Welcome back iklam! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Jun 28, 2022

@iklam The following labels will be automatically applied to this pull request:

  • hotspot
  • serviceability
  • shenandoah

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added serviceability serviceability-dev@openjdk.org hotspot hotspot-dev@openjdk.org labels Jun 28, 2022
@iklam iklam force-pushed the 8289230-move-Platform-classes-out-of-os-xxx-hpp branch from 63d1532 to 27ddeb0 Compare June 28, 2022 06:20
@openjdk openjdk bot added the shenandoah shenandoah-dev@openjdk.org label Jun 28, 2022
@iklam iklam marked this pull request as ready for review June 28, 2022 06:21
@openjdk openjdk bot added the rfr Pull request is ready for review label Jun 28, 2022
@mlbridge
Copy link

mlbridge bot commented Jun 28, 2022

Webrevs

Copy link
Member

@dholmes-ora dholmes-ora left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just took a quick skim through to get the general sense of things. Header file split is okay. Pity about the .cpp situation though - maybe move to platform_posix.cpp and platform_windows.cpp to at least get them out of the os_xxx.cpp file?

void notify_all();
};

#endif // OS_POSIX_PARK_POSIX_HPP
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong comment.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

}

/*
* See the caveats for this class in os_posix.hpp
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment needs updating

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

void notify_all();
};

#endif // OS_WINDOWS_PARK_WINDOWS_HPP
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong comment

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@openjdk-notifier
Copy link

@iklam Please do not rebase or force-push to an active PR as it invalidates existing review comments. All changes will be squashed into a single commit automatically when integrating. See OpenJDK Developers’ Guide for more information.

@iklam
Copy link
Member Author

iklam commented Jun 28, 2022

Just took a quick skim through to get the general sense of things. Header file split is okay. Pity about the .cpp situation though - maybe move to platform_posix.cpp and platform_windows.cpp to at least get them out of the os_xxx.cpp file?

Unfortunately it's worse than I thought. There's a static function, to_abstime() that shared between os::Posix::to_RTC_abstime() and the PlatformEvent::park().

To clean things up, I would need to move some static fields/functions into the os::Posix class. Maybe I should do the refactoring in a separate PR, to keep this PR simple?

Copy link
Contributor

@coleenp coleenp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I very much like this incremental approach to reducing our over-inclusion.

@@ -192,7 +200,7 @@ class Mutex : public CHeapObj<mtSynchronizer> {
void print_on_error(outputStream* st) const;
#ifndef PRODUCT
void print_on(outputStream* st) const;
void print() const { print_on(::tty); }
void print() const { /*print_on(::tty); */ } // FIXME
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you move this print implementation into the .cpp file?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

# include "threadCrashProtection_windows.hpp"
#else
# error "No ThreadCrashProtection implementation provided for this OS"
#endif
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't you use this?
#define OS_HEADER(basename) XSTR(OS_HEADER_STEM(basename).hpp)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed it as you suggested. I also fixed semaphore.hpp where I copied the old pattern from.

Copy link
Contributor

@coleenp coleenp Jun 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't the OS_HEADER() -similar macro that handles the posix case too? I don't see it though.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OS_HEADER(threadCrashProtection) will give threadCrashProtection_linux.hpp, etc. It won't give us threadCrashProtection_posix.hpp. I didn't want to write three threadCrashProtection_{aix,bsd,linux}.hpp files that each just has a single line that includes the _posix version.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah no posix support with OS_HEADER.

@openjdk
Copy link

openjdk bot commented Jun 28, 2022

@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:

8289230: Move PlatformXXX class declarations out of os_xxx.hpp

Reviewed-by: coleenp, ccheung

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 master branch. If another commit should be pushed before you perform the /integrate command, your PR will be automatically rebased. If you prefer to avoid any potential automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jun 28, 2022


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 334 deleted by accident?

Copy link
Member

@calvinccheung calvinccheung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Just one nit.

@iklam
Copy link
Member Author

iklam commented Jul 2, 2022

Thanks @coleenp @calvinccheung @dholmes-ora for the review.
/integrate

@openjdk
Copy link

openjdk bot commented Jul 2, 2022

Going to push as commit cdf6979.

@openjdk openjdk bot added the integrated Pull request has been integrated label Jul 2, 2022
@openjdk openjdk bot closed this Jul 2, 2022
@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Jul 2, 2022
@openjdk openjdk bot removed the rfr Pull request is ready for review label Jul 2, 2022
@openjdk
Copy link

openjdk bot commented Jul 2, 2022

@iklam Pushed as commit cdf6979.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot hotspot-dev@openjdk.org integrated Pull request has been integrated serviceability serviceability-dev@openjdk.org shenandoah shenandoah-dev@openjdk.org
4 participants