Skip to content

Conversation

@albertnetymk
Copy link
Member

@albertnetymk albertnetymk commented May 24, 2021

Convert as_Worker_thread to non-virtual, like other as_*_thread methods.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8252476: as_Worker_thread() doesn't check what it intends

Reviewers

Contributors

  • David Holmes <dholmes@openjdk.org>

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/4167/head:pull/4167
$ git checkout pull/4167

Update a local copy of the PR:
$ git checkout pull/4167
$ git pull https://git.openjdk.java.net/jdk pull/4167/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 4167

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/4167.diff

@bridgekeeper
Copy link

bridgekeeper bot commented May 24, 2021

👋 Welcome back ayang! 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 openjdk bot added the rfr Pull request is ready for review label May 24, 2021
@albertnetymk
Copy link
Member Author

/contributor add dholmes

@openjdk
Copy link

openjdk bot commented May 24, 2021

@albertnetymk
Contributor David Holmes <dholmes@openjdk.org> successfully added.

@openjdk
Copy link

openjdk bot commented May 24, 2021

@albertnetymk The following label will be automatically applied to this pull request:

  • hotspot-runtime

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

@openjdk openjdk bot added the hotspot-runtime hotspot-runtime-dev@openjdk.org label May 24, 2021
@mlbridge
Copy link

mlbridge bot commented May 24, 2021

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.

Hi Albert,

Thanks for fixing this. A couple of nits on the details.

David


inline WorkerThread* Thread::as_Worker_thread() const {
assert(is_Worker_thread(), "Dubious cast to WorkerThread*?");
return (WorkerThread*)this;
Copy link
Member

Choose a reason for hiding this comment

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

Can you use static_cast here rather the C-style cast please.

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 get an compiling error, static_cast from 'const Thread *' to 'WorkerThread *', which are not related by inheritance, is not allowed. As WorkerThread is only declared in this context, the compiler doesn't know the inheritance relation here.

}

inline WorkerThread* Thread::as_Worker_thread() const {
assert(is_Worker_thread(), "Dubious cast to WorkerThread*?");
Copy link
Member

Choose a reason for hiding this comment

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

More than dubious I would say, just plain wrong.

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.

@mlbridge
Copy link

mlbridge bot commented May 25, 2021

Mailing list message from David Holmes on hotspot-runtime-dev:

On 25/05/2021 4:43 pm, Albert Mingkun Yang wrote:

On Tue, 25 May 2021 01:17:16 GMT, David Holmes <dholmes at openjdk.org> wrote:

Albert Mingkun Yang has updated the pull request incrementally with one additional commit since the last revision:

review

src/hotspot/share/runtime/thread.hpp line 1593:

1591:
1592: inline WorkerThread* Thread::as_Worker_thread() const {
1593: assert(is_Worker_thread(), "Dubious cast to WorkerThread*?");

More than dubious I would say, just plain wrong.

Fixed.

Thanks.

src/hotspot/share/runtime/thread.hpp line 1594:

1592: inline WorkerThread* Thread::as_Worker_thread() const {
1593: assert(is_Worker_thread(), "Dubious cast to WorkerThread*?");
1594: return (WorkerThread*)this;

Can you use static_cast here rather the C-style cast please.

I get an compiling error, `static_cast from 'const Thread *' to 'WorkerThread *', which are not related by inheritance, is not allowed`. As `WorkerThread` is only declared in this context, the compiler doesn't know the inheritance relation here.

Ah I see. That is a downside of moving the NJT declarations to
nonJavaThread.hpp :(

Thanks,
David

1 similar comment
@mlbridge
Copy link

mlbridge bot commented May 25, 2021

Mailing list message from David Holmes on hotspot-runtime-dev:

On 25/05/2021 4:43 pm, Albert Mingkun Yang wrote:

On Tue, 25 May 2021 01:17:16 GMT, David Holmes <dholmes at openjdk.org> wrote:

Albert Mingkun Yang has updated the pull request incrementally with one additional commit since the last revision:

review

src/hotspot/share/runtime/thread.hpp line 1593:

1591:
1592: inline WorkerThread* Thread::as_Worker_thread() const {
1593: assert(is_Worker_thread(), "Dubious cast to WorkerThread*?");

More than dubious I would say, just plain wrong.

Fixed.

Thanks.

src/hotspot/share/runtime/thread.hpp line 1594:

1592: inline WorkerThread* Thread::as_Worker_thread() const {
1593: assert(is_Worker_thread(), "Dubious cast to WorkerThread*?");
1594: return (WorkerThread*)this;

Can you use static_cast here rather the C-style cast please.

I get an compiling error, `static_cast from 'const Thread *' to 'WorkerThread *', which are not related by inheritance, is not allowed`. As `WorkerThread` is only declared in this context, the compiler doesn't know the inheritance relation here.

Ah I see. That is a downside of moving the NJT declarations to
nonJavaThread.hpp :(

Thanks,
David

@openjdk
Copy link

openjdk bot commented May 25, 2021

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

8252476: as_Worker_thread() doesn't check what it intends

Co-authored-by: David Holmes <dholmes@openjdk.org>
Reviewed-by: iklam, kbarrett

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 55 new commits pushed to the master branch:

  • 37bc4e2: 8263635: Add --servername option to jhsdb debugd
  • 6ffa3e6: 8267754: cds/appcds/loaderConstraints/LoaderConstraintsTest.java fails on x86_32 due to customized class loader is not supported
  • 1899f02: 8267805: Add UseVtableBasedCHA to the list of JVM flags known to jtreg
  • 0fc7c8d: 8267751: (test) jtreg.SkippedException has no serial VersionUID
  • a859d87: 8267721: Enable sun/security/pkcs11 tests for Amazon Linux 2 AArch64
  • e630235: 8266851: Implement JEP 403: Strongly Encapsulate JDK Internals
  • 8c4719a: 8265248: Implementation Specific Properties: change prefix, plus add existing properties
  • c59484e: 8267653: Remove Mutex::_safepoint_check_sometimes
  • de91643: 8267611: Print more info when pointer_delta assert fails
  • a4c46e1: 8263202: Update Hebrew/Indonesian/Yiddish ISO 639 language codes to current
  • ... and 45 more: https://git.openjdk.java.net/jdk/compare/49f622c9473464bf1d1f33b88abf46adadd9fa1c...master

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 master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label May 25, 2021
@albertnetymk
Copy link
Member Author

Moved the definition to the inline file so that static_cast can be used.

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.

The update seems fine to me. But you need to check with @iklam whether including nonJavaThread.hpp in thread.inline.hpp negates the point of splitting out nonJavaThread.hpp in the first place.

Thanks,
David

@openjdk openjdk bot removed the ready Pull request is ready to be integrated label May 27, 2021
@iklam
Copy link
Member

iklam commented May 27, 2021

The update seems fine to me. But you need to check with @iklam whether including nonJavaThread.hpp in thread.inline.hpp negates the point of splitting out nonJavaThread.hpp in the first place.

I think it's OK to include nonJavaThread.hpp in thread.inline.hpp (included by about 30% of hotspot .o files). But we should avoid including it in thread.hpp (included by about 80% of hotspot .o files)

BTW, we should make JavaThread::as_CompilerThread consistent as well: move to thread.inline.hpp, change the casting, and rename to as_Compiler_thread (in another RFE??)

@openjdk openjdk bot added the ready Pull request is ready to be integrated label May 27, 2021
Copy link

@kimbarrett kimbarrett 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.

@albertnetymk
Copy link
Member Author

BTW, we should make JavaThread::as_CompilerThread consistent as well: move to thread.inline.hpp, change the casting, and rename to as_Compiler_thread (in another RFE??)

I can do so in another PR. Thank you for the suggestion.

@albertnetymk
Copy link
Member Author

Thanks for the review.

/integrate

@openjdk openjdk bot closed this May 27, 2021
@openjdk openjdk bot added integrated Pull request has been integrated and removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels May 27, 2021
@openjdk
Copy link

openjdk bot commented May 27, 2021

@albertnetymk Since your change was applied there have been 55 commits pushed to the master branch:

  • 37bc4e2: 8263635: Add --servername option to jhsdb debugd
  • 6ffa3e6: 8267754: cds/appcds/loaderConstraints/LoaderConstraintsTest.java fails on x86_32 due to customized class loader is not supported
  • 1899f02: 8267805: Add UseVtableBasedCHA to the list of JVM flags known to jtreg
  • 0fc7c8d: 8267751: (test) jtreg.SkippedException has no serial VersionUID
  • a859d87: 8267721: Enable sun/security/pkcs11 tests for Amazon Linux 2 AArch64
  • e630235: 8266851: Implement JEP 403: Strongly Encapsulate JDK Internals
  • 8c4719a: 8265248: Implementation Specific Properties: change prefix, plus add existing properties
  • c59484e: 8267653: Remove Mutex::_safepoint_check_sometimes
  • de91643: 8267611: Print more info when pointer_delta assert fails
  • a4c46e1: 8263202: Update Hebrew/Indonesian/Yiddish ISO 639 language codes to current
  • ... and 45 more: https://git.openjdk.java.net/jdk/compare/49f622c9473464bf1d1f33b88abf46adadd9fa1c...master

Your commit was automatically rebased without conflicts.

Pushed as commit bfa46f0.

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

@albertnetymk albertnetymk deleted the as_worker_thread branch May 27, 2021 08:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hotspot-runtime hotspot-runtime-dev@openjdk.org integrated Pull request has been integrated

Development

Successfully merging this pull request may close these issues.

4 participants