RFR: 8286066: FillerObject_klass should be loaded as early as possible [v5]

Jie Fu jiefu at openjdk.java.net
Wed May 4 08:23:17 UTC 2022


On Wed, 4 May 2022 07:49:24 GMT, Thomas Schatzl <tschatzl at openjdk.org> wrote:

> An alternative fix which seems more comprehensive could be to use `java_lang_Object()` for filling these gaps while the other isn't initialized.
> 
> E.g. in
> 
> ```
> CollectedHeap::fill_with_object_impl(HeapWord* start, size_t words, bool zap)
> {
>   assert(words <= filler_array_max_size(), "too big for a single object");
> 
>   if (words >= filler_array_min_size()) {
>     fill_with_array(start, words, zap);
>   } else if (words > 0) {
>     assert(words == min_fill_size(), "unaligned size");
>     ObjAllocator allocator(vmClasses::FillerObject_klass(), words);
>     allocator.initialize(start);
>   }
> }
> ```
> 
> instead of direct use of `vmClasses::FillerObject_klass()`, add a helper function that selects it based on some predicate; not sure if `Universe::is_initialized()` (or so) isn't too lenient.
> 
> I see that `vmClasses` already has some `XXXX_class_loaded()` methods - maybe add one of these for the filler objects and select on that?
> 
> Use of the small filler objects is really rare, additionally it only happens at most once per TLAB/PLAB fill, and is mostly done by the application anyway, so I do not see an issue with such an additional flag.
> 
> Another option is to have some global variable containing that klass (either in `Universe` or maybe better in `CollectedHeap`) that initially aliases `java_lang_Object` and after this class loading is complete, set it to the filler object klass (that is then used by `CollectedHeap::fill_with_object_impl`.
> 
> This would completely avoid the somewhat brittle guessing about the initialization order of the klasses, and avoids any runtime overhead by checking whether the klass has already been loaded during runtime at the cost of a single global variable. At this time I kind of prefer this second option.

Thanks @tschatzl for your review and suggestion.

Then part of the unused memory would be filled with `Object` and the others would be filled with `FillerObject`.
I'm not sure if this kind of change is safe and if it would complicate the design/implementation/optimization of HotSpot GC algorithms.
What do you think of my worries?
Thanks.

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

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



More information about the hotspot-gc-dev mailing list