RFR: 8334223: Make Arena MEMFLAGs immutable

Johan Sjölen jsjolen at openjdk.org
Mon Jun 17 10:11:13 UTC 2024


On Thu, 13 Jun 2024 11:59:05 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:

> Arenas carry NMT flags. 
> 
> An arena should never change that flag. But it does: Arenas (as ResourceAreas), used by CompilerThread, are accounted toward mtCompiler. But since the RA is already created in the parent class constructor (as mtThread), we then have to awkwardly change the flag of an already existing RA in the CompilerThread constructor.
> 
> As a prerequisite for future NMT work I would like Arena MEMFLAGS to be immutable.
> 
> The patch does that:
> - we hand in MEMFLAGS to the Thread constructor now (defaults to mtThread)
> - CompilerThread hands in mtCompiler, all other threads rely on the default
> - on creation, both ResourceArea and HandleArea are now accounted toward the flag handed in
> - that allows us to make Arena::flags const, and to remove ResourceArea::bias_to which changed the flag in-flight for the arena
> - it also allows us to make Arena::flags private
> 
> Other, unrelated cleanups:
> - Made Arena::_size_in_bytes and Arena::_tag private
> - Merged both Arena constructors into one by specifying a default value of `Chunk::init_size` for `init_size` argument. That makes it equivalent to the old `Arena(flag, tag)` constructor
> - removed `JavaThread::JavaThread(bool)`. That constructor was used when creating threads that are getting attached. There was only a single use for that constructor, and I replaced it with functionally equivalent code.
> 
> Tests:
> 
> I manually verified that the NMT numbers printed don't change.

Hi Thomas,

This looks like a very good cleanup to me, thank you.

All the best,
Johan

src/hotspot/share/compiler/compilerThread.cpp line 35:

> 33: CompilerThread::CompilerThread(CompileQueue* queue,
> 34:                                CompilerCounters* counters)
> 35:                                : JavaThread(&CompilerThread::thread_entry, 0, mtCompiler) {

Style, pre-existing: Shouldn't be this far indented.

src/hotspot/share/memory/arena.hpp line 98:

> 96: 
> 97: private:
> 98: 

Style: No space between access specifier and next declaration.

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

Marked as reviewed by jsjolen (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/19693#pullrequestreview-2122466958
PR Review Comment: https://git.openjdk.org/jdk/pull/19693#discussion_r1642548209
PR Review Comment: https://git.openjdk.org/jdk/pull/19693#discussion_r1642547269


More information about the hotspot-dev mailing list