--- old/src/hotspot/share/gc/g1/g1MemoryPool.hpp 2018-10-19 10:53:59.000000000 -0400 +++ new/src/hotspot/share/gc/g1/g1MemoryPool.hpp 2018-10-19 10:53:59.000000000 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,28 +29,28 @@ #include "services/memoryPool.hpp" #include "services/memoryUsage.hpp" -// This file contains the three classes that represent the memory -// pools of the G1 spaces: G1EdenPool, G1SurvivorPool, and -// G1OldGenPool. In G1, unlike our other GCs, we do not have a -// physical space for each of those spaces. Instead, we allocate -// regions for all three spaces out of a single pool of regions (that -// pool basically covers the entire heap). As a result, the eden, -// survivor, and old gen are considered logical spaces in G1, as each -// is a set of non-contiguous regions. This is also reflected in the -// way we map them to memory pools here. The easiest way to have done -// this would have been to map the entire G1 heap to a single memory -// pool. However, it's helpful to show how large the eden and survivor -// get, as this does affect the performance and behavior of G1. Which -// is why we introduce the three memory pools implemented here. +// This file contains definitions for two memory pool models for the G1 heap +// spaces. Which to use is determined by the G1UseLegacyMonitoring switch. If +// true, we use a model that defines three pools, G1EdenPool, G1SurvivorPool +// and G1OldPool. If false (the default), we use a more accurate model +// that defines two additional pools, G1HumongousPool and G1ArchivePool. // -// See comments in g1MonitoringSupport.hpp for additional details -// on this model. +// In G1, unlike our other GCs, we do not have a contiguous virtual address +// space for each pool. The pools are logical spaces in G1, and each pool +// consists of a non-contiguous region set allocated out of a single region +// pool which covers the entire heap. This is also reflected in the way we +// map them to memory pools here. The easiest way to have done this would +// have been to map the entire G1 heap to a single memory pool. However, it +// is helpful to show how large each space gets, as their sizes affect G1's +// performance and behavior. // +// See comments in g1MonitoringSupport.hpp for additional details on this +// model. class G1CollectedHeap; -// This class is shared by the three G1 memory pool classes -// (G1EdenPool, G1SurvivorPool, G1OldGenPool). +// This class is shared by all G1 memory pool classes: G1EdenPool, +// G1SurvivorPool, G1OldPool, G1HumongousPool, and G1ArchivePool class G1MemoryPoolSuper : public CollectedMemoryPool { protected: G1MonitoringSupport* _g1mm; @@ -63,33 +63,54 @@ bool support_usage_threshold); }; -// Memory pool that represents the G1 eden. +// In legacy mode, G1EdenPool, G1SurvivorPool, and G1OldPool represent +// the G1 memory pools, and G1OldPool includes regions occupied by +// humongous and archive objects. + +// Memory pool that represents the G1 eden space class G1EdenPool : public G1MemoryPoolSuper { public: G1EdenPool(G1CollectedHeap* g1h, size_t initial_size); - size_t used_in_bytes() { return _g1mm->eden_space_used(); } - MemoryUsage get_memory_usage(); }; -// Memory pool that represents the G1 survivor. +// Memory pool that represents the G1 survivor space class G1SurvivorPool : public G1MemoryPoolSuper { public: G1SurvivorPool(G1CollectedHeap* g1h, size_t initial_size); - size_t used_in_bytes() { return _g1mm->survivor_space_used(); } - MemoryUsage get_memory_usage(); }; -// Memory pool that represents the G1 old gen. -class G1OldGenPool : public G1MemoryPoolSuper { +// Memory pool that represents the G1 old generation (legacy) +// or G1 old space (default) +class G1OldPool : public G1MemoryPoolSuper { public: - G1OldGenPool(G1CollectedHeap* g1h, size_t initial_size, size_t max_size); + G1OldPool(G1CollectedHeap* g1h, size_t initial_size, size_t max_size); + size_t used_in_bytes() { return _g1mm->old_space_used(); } + MemoryUsage get_memory_usage(); +}; - size_t used_in_bytes() { return _g1mm->old_gen_used(); } +// The default model includes the three legacy pools plus G1ArchivePool +// and G1HumongousPool, and G1OldPool does not include regions occupied +// by humongous and archive objects. Instead, humongous and archive +// objects each get their own pool. + +// Memory pool that represents the G1 archive space. The archive space +// contains read-only class metadata from the class data sharing archives. +class G1ArchivePool : public G1MemoryPoolSuper { +public: + G1ArchivePool(G1CollectedHeap* g1h, size_t initial_size); + size_t used_in_bytes() { return _g1mm->archive_space_used(); } + MemoryUsage get_memory_usage(); +}; +// Memory pool that represents the G1 humongous space +class G1HumongousPool : public G1MemoryPoolSuper { +public: + G1HumongousPool(G1CollectedHeap* g1h, size_t initial_size); + size_t used_in_bytes() { return _g1mm->humongous_space_used(); } MemoryUsage get_memory_usage(); };