RFR: JDK-8272112: Arena code simplifications

Kim Barrett kbarrett at openjdk.java.net
Mon Aug 9 06:35:30 UTC 2021


On Mon, 9 Aug 2021 04:45:38 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:

>> src/hotspot/share/memory/arena.cpp line 62:
>> 
>>> 60: 
>>> 61:   // Remove a chunk from the pool and return it; NULL if pool is empty.
>>> 62:   Chunk* remove_chunk() {
>> 
>> I think I prefer the old allocate/free nomenclature.  `remove_chunk` sounds like it should be discarding.  And `return_chunk` is confusing about "return".  I think allocate/free from a pool/free-list is well-understood naming.
>
> I renamed ChunkPool::allocate() because it does not allocate anymore, it just stores existing chunks.
> 
> Is it just the naming, or do you also prefer that the old ChunkPool::allocate() actually allocated the Chunks (it called os::malloc)? I found that unnecessary for a pure cache and it duplicated the allocation code in Chunk::operator new().

It's the names that I'm not a fan of.  The new implementation is good.  And it _is_ allocating, from a free-list.  I think it's pretty common for a free-list allocator design to have "failure" leave it to the client to decide what to do, rather than having the fallback built into the free-list allocator.

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

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


More information about the hotspot-dev mailing list