RFR: JDK-8267916: Make as_CompilerThread consistent with other as_*_thread methods [v2]

Ioi Lam iklam at openjdk.java.net
Wed Jun 2 17:22:31 UTC 2021


On Wed, 2 Jun 2021 14:50:03 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:

> > I encountered some circular dependencies after moving the definition to `thread.inline.hpp`, so I replaced it with a static `cast` method, as Kim instructed from an offline discussion. Note now there's a discrepancy: `CompilerThread::cast(t)` vs `t->as_Worker_thread()` (or `t->as_Java_thread()`). I can do the same for other `as_*_thread` methods as well (in this PR or another one) if people feel like this approach.
> 
> as_Worker_thread => WorkerThread::cast could pretty easily be added to this change. There's only one call.
> 
> There are lots of as_Java_thread calls. Maybe check with runtime team how they feel about the inconsistency vs code churn.

I prefer `JavaThread::cast()` over `Thread::as_Java_thread()`. The former style is consistent with other functions such as `InstanceKlass:cast()`.

As far as code churn, [JDK-8252685](https://bugs.openjdk.java.net/browse/JDK-8252685) already removed a bunch of `as_Java_thread()` calls (we have about 110 of them now, vs about 180 in JDK 16), so we may as well fix the rest for a more consistent style, which is also better with header dependencies. @dholmes-ora what do you think? In any case, we should do that in a different PR.

-------------

PR: https://git.openjdk.java.net/jdk/pull/4240


More information about the hotspot-dev mailing list