RFR: 8260012: Reduce inclusion of collectedHeap.hpp and heapInspection.hpp

Stefan Karlsson stefank at openjdk.java.net
Tue Feb 2 12:14:45 UTC 2021


On Tue, 2 Feb 2021 04:18:24 GMT, Ioi Lam <iklam at openjdk.org> wrote:

> collectedHeap.hpp is included by 477 out of 1000 .o files in HotSpot. This file in turn includes many other complex header files.
> 
> In many cases, an object file only directly includes this file via:
> 
> - memAllocator.hpp (which does not actually use collectedHeap.hpp)
> - oop.inline.hpp and compressedOops.inline.hpp (only use collectedHeap.hpp in asserts via `Universe::heap()->is_in()`).
> 
> By refactoring the above 3 files, we can reduce the .o files that include collectedHeap.hpp to 242.
> 
> This RFE also removes the unnecessary inclusion of heapInspection.hpp from collectedHeap.hpp.
> 
> Build time of HotSpot is reduced for about 1%.
> 
> Tested with mach5: tier1, builds-tier2, builds-tier3, builds-tier4 and builds-tier5. Also locally: aarch64, arm, ppc64, s390, x86, and zero.

Looks good. A few things that you might want to consider, but I'm also fine with the patch as it is.

src/hotspot/share/gc/shared/memAllocator.hpp line 30:

> 28: #include "memory/memRegion.hpp"
> 29: #include "oops/oopsHierarchy.hpp"
> 30: #include "runtime/thread.hpp"

If we want to, this could be changed to a forward declaration if we removed the default value (Thread* thread = Thread::current()) of the constructors. Not needed for this RFE though.

src/hotspot/cpu/arm/frame_arm.cpp line 518:

> 516:         obj = *(oop*)res_addr;
> 517:       }
> 518:       assert(obj == NULL || Universe::is_in_heap(obj), "sanity check");

Could have been changed to is_in_heap_or_null.

src/hotspot/cpu/ppc/frame_ppc.cpp line 308:

> 306:       case T_ARRAY: {
> 307:         oop obj = *(oop*)tos_addr;
> 308:         assert(obj == NULL || Universe::is_in_heap(obj), "sanity check");

Could have been changed to is_in_heap_or_null.

src/hotspot/cpu/s390/frame_s390.cpp line 321:

> 319:       case T_ARRAY: {
> 320:        oop obj = *(oop*)tos_addr;
> 321:        assert(obj == NULL || Universe::is_in_heap(obj), "sanity check");

Could have been changed to is_in_heap_or_null.

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

Marked as reviewed by stefank (Reviewer).

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



More information about the hotspot-gc-dev mailing list