RFR: 8313224: Avoid calling JavaThread::current() in MemAllocator::Allocation constructor [v3]

Ioi Lam iklam at openjdk.org
Fri Aug 11 00:09:28 UTC 2023


> Summary: Avoid calling `JavaThread::current()` since we already have a `Thread*` in `MemAllocator::_thread`.
> 
> Although the latter is declared to be a `Thead*` and not a `JavaThread*`, the calling context requires the current thread to be a `JavaThread`, and  `MemAllocator::_thread` was initialized to be  `Thread::current`, so I changed the code from 
> 
> 
> _thread(JavaThread::current()),
> 
> 
> to
> 
> 
> assert(Thread::current()->is_Java_thread(), "must be used by JavaThreads only");
> assert(Thread::current() == allocator._thread, "do not pass MemAllocator across threads");
> _thread = JavaThread::cast(allocator._thread);
> 
> 
> I also clean up a few other lines to limit the explicit use of `JavaThread*`.
> 
> This fix improved `java --version` by about 0.6% for my prototype of [JDK-8310823](https://bugs.openjdk.org/browse/JDK-8310823), which allocates ~24000 heap objects at VM start-up.

Ioi Lam 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 four additional commits since the last revision:

 - @coleenp comments
 - Merge branch 'master' into 8313224-avoid-JavaThread-current-in-MemAllocator
 - @tschatzl comments
 - 8313224: Avoid calling JavaThread::current() in MemAllocator::Allocation constructor

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/15058/files
  - new: https://git.openjdk.org/jdk/pull/15058/files/19d64c57..548eb78d

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=15058&range=02
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=15058&range=01-02

  Stats: 23895 lines in 1005 files changed: 10881 ins; 6423 del; 6591 mod
  Patch: https://git.openjdk.org/jdk/pull/15058.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/15058/head:pull/15058

PR: https://git.openjdk.org/jdk/pull/15058


More information about the hotspot-gc-dev mailing list