RFR: 8278351: Add function to retrieve worker_id from any context [v2]

Per Liden pliden at openjdk.java.net
Thu Dec 9 17:58:57 UTC 2021


> The `worker_id` argument passed to `WorkerTask::work(uint worker_id)` is sometimes needed in contexts where it today can't be easily accessed, mainly because it's not feasible to pass this argument through many layers of semi-unrelated code. To solve this, I propose that we make the current `worker_id` accessible though a static function `WorkerThread::worker_id()`.
> 
> By doing this, we also pave the way for ZGC to remove its `ZTask` and `ZThread`, which are helper class to make the `worker_id` easily accessible in any context.
> 
> At the same time I propose that we remove `WorkerThread::_id`. This id identifies the actual worker thread. There is currently only one user of `WorkerThread::_id`, the `ReferenceProcessor`. However, we should use `WorkerThread::worker_id()` here instead. The only reason it doesn't use `worker_id` today is that it's not easily accessible in that context (the discover path).
> 
> Testing: Passed Tier1-3

Per Liden has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains three additional commits since the last revision:

 - Merge branch 'master' into 8278351_worker_id
 - Adjustments
 - 8278351: Make WorkerThread::id() map to worker_id

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

Changes:
  - all: https://git.openjdk.java.net/jdk/pull/6747/files
  - new: https://git.openjdk.java.net/jdk/pull/6747/files/50d9abed..f669780d

Webrevs:
 - full: https://webrevs.openjdk.java.net/?repo=jdk&pr=6747&range=01
 - incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=6747&range=00-01

  Stats: 13736 lines in 418 files changed: 9743 ins; 1824 del; 2169 mod
  Patch: https://git.openjdk.java.net/jdk/pull/6747.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/6747/head:pull/6747

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



More information about the hotspot-gc-dev mailing list