RFR: 8295475: Move non-resource allocation strategies out of ResourceObj [v2]

Coleen Phillimore coleenp at openjdk.org
Tue Oct 18 18:10:26 UTC 2022


On Tue, 18 Oct 2022 13:42:40 GMT, Stefan Karlsson <stefank at openjdk.org> wrote:

>> Background to this patch:
>> 
>> This prototype/patch has been discussed with a few HotSpot devs, and I've gotten feedback that I should send it out for broader discussion/review. It could be a first step to make it easier to talk about our allocation super classes and strategies. This in turn would make it easier to have further discussions around how to make our allocation strategies more flexible. E.g. do we really need to tie down utility classes to a specific allocation strategy? Do we really have to provide MEMFLAGS as compile time flags? Etc.
>> 
>> PR RFC:
>> 
>> HotSpot has a few allocation classes that other classes can inherit from to get different dynamic-allocation strategies:
>> 
>> MetaspaceObj - allocates in the Metaspace
>> CHeap - uses malloc
>> ResourceObj - ...
>> 
>> The last class sounds like it provide an allocation strategy to allocate inside a thread's resource area. This is true, but it also provides functions to allow the instances to be allocated in Areanas or even CHeap allocated memory.
>> 
>> This is IMHO misleading, and often leads to confusion among HotSpot developers.
>> 
>> I propose that we simplify ResourceObj to only provide an allocation strategy for resource allocations, and move the multi-allocation strategy feature to another class, which isn't named ResourceObj.
>> 
>> In my proposal and prototype I've used the name AnyObj, as short, simple name. I'm open to changing the name to something else.
>> 
>> The patch also adds a new class named ArenaObj, which is for objects only allocated in provided arenas.
>> 
>> The patch also removes the need to provide ResourceObj/AnyObj::C_HEAP to `operator new`. If you pass in a MEMFLAGS argument it now means that you want to allocate on the CHeap.
>
> Stefan Karlsson has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Fix Shenandoah

I like this change a lot.  If we change the name of AnyObj to something AnyAllocationBase, we should change the rest to ResourceAllocationBase, HeapAllocationBase etc.  We should do this in a separate PR.

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

Marked as reviewed by coleenp (Reviewer).

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


More information about the hotspot-dev mailing list