--- old/src/hotspot/share/gc/cms/cmsHeap.cpp 2017-11-20 16:28:26.802400780 +0100 +++ new/src/hotspot/share/gc/cms/cmsHeap.cpp 2017-11-20 16:28:26.553403709 +0100 @@ -24,6 +24,7 @@ #include "precompiled.hpp" #include "gc/cms/concurrentMarkSweepThread.hpp" +#include "gc/cms/cmsGCServicabilitySupport.hpp" #include "gc/cms/cmsHeap.hpp" #include "gc/cms/vmCMSOperations.hpp" #include "gc/shared/genOopClosures.inline.hpp" @@ -183,3 +184,7 @@ GenCollectedHeap::gc_epilogue(full); always_do_update_barrier = true; }; + +GCServicabilitySupport* CMSHeap::create_servicability_support() { + return new CMSGCServicabilitySupport(); +} --- old/src/hotspot/share/gc/cms/cmsHeap.hpp 2017-11-20 16:28:27.620391156 +0100 +++ new/src/hotspot/share/gc/cms/cmsHeap.hpp 2017-11-20 16:28:27.360394215 +0100 @@ -98,6 +98,8 @@ virtual void gc_prologue(bool full); virtual void gc_epilogue(bool full); + virtual GCServicabilitySupport* create_servicability_support(); + // Accessor for memory state verification support NOT_PRODUCT( virtual size_t skip_header_HeapWords() { return CMSCollector::skip_header_HeapWords(); } --- old/src/hotspot/share/gc/g1/g1CollectedHeap.cpp 2017-11-20 16:28:28.430381626 +0100 +++ new/src/hotspot/share/gc/g1/g1CollectedHeap.cpp 2017-11-20 16:28:28.171384673 +0100 @@ -41,6 +41,7 @@ #include "gc/g1/g1FullCollector.hpp" #include "gc/g1/g1FullGCScope.hpp" #include "gc/g1/g1GCPhaseTimes.hpp" +#include "gc/g1/g1GCServicabilitySupport.hpp" #include "gc/g1/g1HeapSizingPolicy.hpp" #include "gc/g1/g1HeapTransition.hpp" #include "gc/g1/g1HeapVerifier.hpp" @@ -5394,3 +5395,7 @@ RebuildStrongCodeRootClosure blob_cl(this); CodeCache::blobs_do(&blob_cl); } + +GCServicabilitySupport* G1CollectedHeap::create_servicability_support() { + return new G1GCServicabilitySupport(); +} --- old/src/hotspot/share/gc/g1/g1CollectedHeap.hpp 2017-11-20 16:28:29.319371167 +0100 +++ new/src/hotspot/share/gc/g1/g1CollectedHeap.hpp 2017-11-20 16:28:29.056374261 +0100 @@ -203,6 +203,8 @@ // than the current allocation region(s). size_t _summary_bytes_used; + virtual GCServicabilitySupport* create_servicability_support(); + void increase_used(size_t bytes); void decrease_used(size_t bytes); --- old/src/hotspot/share/gc/parallel/parallelScavengeHeap.cpp 2017-11-20 16:28:30.140361508 +0100 +++ new/src/hotspot/share/gc/parallel/parallelScavengeHeap.cpp 2017-11-20 16:28:29.883364532 +0100 @@ -30,6 +30,7 @@ #include "gc/parallel/gcTaskManager.hpp" #include "gc/parallel/generationSizer.hpp" #include "gc/parallel/objectStartArray.inline.hpp" +#include "gc/parallel/parallelGCServicabilitySupport.hpp" #include "gc/parallel/parallelScavengeHeap.inline.hpp" #include "gc/parallel/psAdaptiveSizePolicy.hpp" #include "gc/parallel/psMarkSweep.hpp" @@ -674,3 +675,7 @@ void ParallelScavengeHeap::verify_nmethod(nmethod* nm) { CodeCache::verify_scavenge_root_nmethod(nm); } + +GCServicabilitySupport* ParallelScavengeHeap::create_servicability_support() { + return new ParallelGCServicabilitySupport(); +} --- old/src/hotspot/share/gc/parallel/parallelScavengeHeap.hpp 2017-11-20 16:28:30.939352108 +0100 +++ new/src/hotspot/share/gc/parallel/parallelScavengeHeap.hpp 2017-11-20 16:28:30.688355061 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2017, 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 @@ -64,6 +64,8 @@ // The task manager static GCTaskManager* _gc_task_manager; + virtual GCServicabilitySupport* create_servicability_support(); + void trace_heap(GCWhen::Type when, const GCTracer* tracer); protected: --- old/src/hotspot/share/gc/serial/serialHeap.cpp 2017-11-20 16:28:31.745342625 +0100 +++ new/src/hotspot/share/gc/serial/serialHeap.cpp 2017-11-20 16:28:31.489345637 +0100 @@ -24,6 +24,7 @@ #include "precompiled.hpp" #include "gc/serial/serialHeap.hpp" +#include "gc/serial/serialGCServicabilitySupport.hpp" SerialHeap::SerialHeap(GenCollectorPolicy* policy) : GenCollectedHeap(policy) {} @@ -33,3 +34,7 @@ assert(old_gen()->kind() == Generation::MarkSweepCompact, "Wrong generation kind"); } + +GCServicabilitySupport* SerialHeap::create_servicability_support() { + return new SerialGCServicabilitySupport(); +} --- old/src/hotspot/share/gc/serial/serialHeap.hpp 2017-11-20 16:28:32.592332660 +0100 +++ new/src/hotspot/share/gc/serial/serialHeap.hpp 2017-11-20 16:28:32.329335754 +0100 @@ -30,6 +30,9 @@ class GenCollectorPolicy; class SerialHeap : public GenCollectedHeap { +private: + virtual GCServicabilitySupport* create_servicability_support(); + protected: virtual void check_gen_kinds(); @@ -52,7 +55,6 @@ virtual bool card_mark_must_follow_store() const { return false; } - }; #endif // SHARE_VM_GC_CMS_CMSHEAP_HPP --- old/src/hotspot/share/gc/shared/collectedHeap.cpp 2017-11-20 16:28:33.406323084 +0100 +++ new/src/hotspot/share/gc/shared/collectedHeap.cpp 2017-11-20 16:28:33.156326025 +0100 @@ -172,6 +172,7 @@ CollectedHeap::CollectedHeap() : _barrier_set(NULL), + _servicability(NULL), _is_gc_active(false), _total_collections(0), _total_full_collections(0), @@ -609,3 +610,11 @@ _reserved.set_start(start); _reserved.set_end(end); } + +GCServicabilitySupport* CollectedHeap::servicability_support() { + if (_servicability == NULL) { + _servicability = create_servicability_support(); + } + assert(_servicability != NULL, "Need servicability support"); + return _servicability; +} --- old/src/hotspot/share/gc/shared/collectedHeap.hpp 2017-11-20 16:28:34.211313613 +0100 +++ new/src/hotspot/share/gc/shared/collectedHeap.hpp 2017-11-20 16:28:33.962316542 +0100 @@ -44,6 +44,7 @@ class BarrierSet; class CollectorPolicy; class GCHeapSummary; +class GCServicabilitySupport; class GCTimer; class GCTracer; class MetaspaceSummary; @@ -104,6 +105,10 @@ MemRegion _reserved; + GCServicabilitySupport* _servicability; + + virtual GCServicabilitySupport* create_servicability_support() = 0; + protected: BarrierSet* _barrier_set; bool _is_gc_active; @@ -462,6 +467,8 @@ BarrierSet* barrier_set() { return _barrier_set; } void set_barrier_set(BarrierSet* barrier_set); + GCServicabilitySupport* servicability_support(); + // Returns "true" iff there is a stop-world GC in progress. (I assume // that it should answer "false" for the concurrent part of a concurrent // collector -- dld). --- old/src/hotspot/share/services/memoryManager.cpp 2017-11-20 16:28:35.012304189 +0100 +++ new/src/hotspot/share/services/memoryManager.cpp 2017-11-20 16:28:34.755307213 +0100 @@ -59,38 +59,6 @@ return (MemoryManager*) new MetaspaceMemoryManager(); } -GCMemoryManager* MemoryManager::get_copy_memory_manager() { - return (GCMemoryManager*) new CopyMemoryManager(); -} - -GCMemoryManager* MemoryManager::get_msc_memory_manager() { - return (GCMemoryManager*) new MSCMemoryManager(); -} - -GCMemoryManager* MemoryManager::get_parnew_memory_manager() { - return (GCMemoryManager*) new ParNewMemoryManager(); -} - -GCMemoryManager* MemoryManager::get_cms_memory_manager() { - return (GCMemoryManager*) new CMSMemoryManager(); -} - -GCMemoryManager* MemoryManager::get_psScavenge_memory_manager() { - return (GCMemoryManager*) new PSScavengeMemoryManager(); -} - -GCMemoryManager* MemoryManager::get_psMarkSweep_memory_manager() { - return (GCMemoryManager*) new PSMarkSweepMemoryManager(); -} - -GCMemoryManager* MemoryManager::get_g1YoungGen_memory_manager() { - return (GCMemoryManager*) new G1YoungGenMemoryManager(); -} - -GCMemoryManager* MemoryManager::get_g1OldGen_memory_manager() { - return (GCMemoryManager*) new G1OldGenMemoryManager(); -} - instanceOop MemoryManager::get_memory_manager_instance(TRAPS) { // Must do an acquire so as to force ordering of subsequent // loads from anything _memory_mgr_obj points to or implies. --- old/src/hotspot/share/services/memoryManager.hpp 2017-11-20 16:28:35.845294389 +0100 +++ new/src/hotspot/share/services/memoryManager.hpp 2017-11-20 16:28:35.578297530 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2017, 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 @@ -75,14 +75,6 @@ // Static factory methods to get a memory manager of a specific type static MemoryManager* get_code_cache_memory_manager(); static MemoryManager* get_metaspace_memory_manager(); - static GCMemoryManager* get_copy_memory_manager(); - static GCMemoryManager* get_msc_memory_manager(); - static GCMemoryManager* get_parnew_memory_manager(); - static GCMemoryManager* get_cms_memory_manager(); - static GCMemoryManager* get_psScavenge_memory_manager(); - static GCMemoryManager* get_psMarkSweep_memory_manager(); - static GCMemoryManager* get_g1YoungGen_memory_manager(); - static GCMemoryManager* get_g1OldGen_memory_manager(); }; class CodeCacheMemoryManager : public MemoryManager { @@ -186,71 +178,4 @@ bool is_notification_enabled() { return _notification_enabled; } }; -// These subclasses of GCMemoryManager are defined to include -// GC-specific information. -// TODO: Add GC-specific information -class CopyMemoryManager : public GCMemoryManager { -private: -public: - CopyMemoryManager() : GCMemoryManager() {} - - const char* name() { return "Copy"; } -}; - -class MSCMemoryManager : public GCMemoryManager { -private: -public: - MSCMemoryManager() : GCMemoryManager() {} - - const char* name() { return "MarkSweepCompact"; } -}; - -class ParNewMemoryManager : public GCMemoryManager { -private: -public: - ParNewMemoryManager() : GCMemoryManager() {} - - const char* name() { return "ParNew"; } -}; - -class CMSMemoryManager : public GCMemoryManager { -private: -public: - CMSMemoryManager() : GCMemoryManager() {} - - const char* name() { return "ConcurrentMarkSweep";} -}; - -class PSScavengeMemoryManager : public GCMemoryManager { -private: -public: - PSScavengeMemoryManager() : GCMemoryManager() {} - - const char* name() { return "PS Scavenge"; } -}; - -class PSMarkSweepMemoryManager : public GCMemoryManager { -private: -public: - PSMarkSweepMemoryManager() : GCMemoryManager() {} - - const char* name() { return "PS MarkSweep"; } -}; - -class G1YoungGenMemoryManager : public GCMemoryManager { -private: -public: - G1YoungGenMemoryManager() : GCMemoryManager() {} - - const char* name() { return "G1 Young Generation"; } -}; - -class G1OldGenMemoryManager : public GCMemoryManager { -private: -public: - G1OldGenMemoryManager() : GCMemoryManager() {} - - const char* name() { return "G1 Old Generation"; } -}; - #endif // SHARE_VM_SERVICES_MEMORYMANAGER_HPP --- old/src/hotspot/share/services/memoryPool.cpp 2017-11-20 16:28:36.652284895 +0100 +++ new/src/hotspot/share/services/memoryPool.cpp 2017-11-20 16:28:36.399287871 +0100 @@ -38,9 +38,6 @@ #include "services/memoryPool.hpp" #include "utilities/globalDefinitions.hpp" #include "utilities/macros.hpp" -#if INCLUDE_ALL_GCS -#include "gc/cms/compactibleFreeListSpace.hpp" -#endif MemoryPool::MemoryPool(const char* name, PoolType type, @@ -228,29 +225,6 @@ return MemoryUsage(initial_size(), used, committed, maxSize); } -#if INCLUDE_ALL_GCS -CompactibleFreeListSpacePool::CompactibleFreeListSpacePool(CompactibleFreeListSpace* space, - const char* name, - PoolType type, - size_t max_size, - bool support_usage_threshold) : - CollectedMemoryPool(name, type, space->capacity(), max_size, - support_usage_threshold), _space(space) { -} - -size_t CompactibleFreeListSpacePool::used_in_bytes() { - return _space->used(); -} - -MemoryUsage CompactibleFreeListSpacePool::get_memory_usage() { - size_t maxSize = (available_for_allocation() ? max_size() : 0); - size_t used = used_in_bytes(); - size_t committed = _space->capacity(); - - return MemoryUsage(initial_size(), used, committed, maxSize); -} -#endif // INCLUDE_ALL_GCS - GenerationPool::GenerationPool(Generation* gen, const char* name, PoolType type, --- old/src/hotspot/share/services/memoryPool.hpp 2017-11-20 16:28:37.529274577 +0100 +++ new/src/hotspot/share/services/memoryPool.hpp 2017-11-20 16:28:37.266277671 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2017, 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 @@ -178,22 +178,6 @@ size_t committed_in_bytes(); }; -#if INCLUDE_ALL_GCS -class CompactibleFreeListSpacePool : public CollectedMemoryPool { -private: - CompactibleFreeListSpace* _space; -public: - CompactibleFreeListSpacePool(CompactibleFreeListSpace* space, - const char* name, - PoolType type, - size_t max_size, - bool support_usage_threshold); - - MemoryUsage get_memory_usage(); - size_t used_in_bytes(); -}; -#endif // INCLUDE_ALL_GCS - class GenerationPool : public CollectedMemoryPool { private: --- old/src/hotspot/share/services/memoryService.cpp 2017-11-20 16:28:38.376264612 +0100 +++ new/src/hotspot/share/services/memoryService.cpp 2017-11-20 16:28:38.108267765 +0100 @@ -25,13 +25,9 @@ #include "precompiled.hpp" #include "classfile/systemDictionary.hpp" #include "classfile/vmSymbols.hpp" -#include "gc/parallel/mutableSpace.hpp" -#include "gc/serial/defNewGeneration.hpp" -#include "gc/serial/tenuredGeneration.hpp" -#include "gc/shared/collectorPolicy.hpp" -#include "gc/shared/genCollectedHeap.hpp" +#include "gc/shared/collectedHeap.hpp" +#include "gc/shared/gcServicabilitySupport.hpp" #include "gc/shared/generation.hpp" -#include "gc/shared/generationSpec.hpp" #include "logging/logConfiguration.hpp" #include "memory/heap.hpp" #include "memory/memRegion.hpp" @@ -46,16 +42,6 @@ #include "services/memoryService.hpp" #include "utilities/growableArray.hpp" #include "utilities/macros.hpp" -#if INCLUDE_ALL_GCS -#include "gc/cms/concurrentMarkSweepGeneration.hpp" -#include "gc/cms/parNewGeneration.hpp" -#include "gc/g1/g1CollectedHeap.inline.hpp" -#include "gc/parallel/parallelScavengeHeap.hpp" -#include "gc/parallel/psOldGen.hpp" -#include "gc/parallel/psYoungGen.hpp" -#include "services/g1MemoryPool.hpp" -#include "services/psMemoryPool.hpp" -#endif // INCLUDE_ALL_GCS GrowableArray* MemoryService::_pools_list = new (ResourceObj::C_HEAP, mtInternal) GrowableArray(init_pools_list_size, true); @@ -84,27 +70,14 @@ } void MemoryService::set_universe_heap(CollectedHeap* heap) { - CollectedHeap::Name kind = heap->kind(); - switch (kind) { - case CollectedHeap::SerialHeap : - case CollectedHeap::CMSHeap : { - add_gen_collected_heap_info(GenCollectedHeap::heap()); - break; - } -#if INCLUDE_ALL_GCS - case CollectedHeap::ParallelScavengeHeap : { - add_parallel_scavenge_heap_info(ParallelScavengeHeap::heap()); - break; - } - case CollectedHeap::G1CollectedHeap : { - add_g1_heap_info(G1CollectedHeap::heap()); - break; - } -#endif // INCLUDE_ALL_GCS - default: { - guarantee(false, "Unrecognized kind of heap"); - } - } + _minor_gc_manager = heap->servicability_support()->create_minor_gc_manager(); + _major_gc_manager = heap->servicability_support()->create_major_gc_manager(); + _managers_list->append(_minor_gc_manager); + _managers_list->append(_major_gc_manager); + + heap->servicability_support()->add_memory_pools(_pools_list, + _minor_gc_manager, + _major_gc_manager); // set the GC thread count GcThreadCountClosure gctcc; @@ -121,274 +94,6 @@ _major_gc_manager->initialize_gc_stat_info(); } -// Add memory pools for GenCollectedHeap -// This function currently only supports two generations collected heap. -// The collector for GenCollectedHeap will have two memory managers. -void MemoryService::add_gen_collected_heap_info(GenCollectedHeap* heap) { - CollectorPolicy* policy = heap->collector_policy(); - - assert(policy->is_generation_policy(), "Only support two generations"); - GenCollectorPolicy* gen_policy = policy->as_generation_policy(); - if (gen_policy != NULL) { - Generation::Name kind = gen_policy->young_gen_spec()->name(); - switch (kind) { - case Generation::DefNew: - _minor_gc_manager = MemoryManager::get_copy_memory_manager(); - break; -#if INCLUDE_ALL_GCS - case Generation::ParNew: - _minor_gc_manager = MemoryManager::get_parnew_memory_manager(); - break; -#endif // INCLUDE_ALL_GCS - default: - guarantee(false, "Unrecognized generation spec"); - break; - } - if (policy->is_mark_sweep_policy()) { - _major_gc_manager = MemoryManager::get_msc_memory_manager(); -#if INCLUDE_ALL_GCS - } else if (policy->is_concurrent_mark_sweep_policy()) { - _major_gc_manager = MemoryManager::get_cms_memory_manager(); -#endif // INCLUDE_ALL_GCS - } else { - guarantee(false, "Unknown two-gen policy"); - } - } else { - guarantee(false, "Non two-gen policy"); - } - _managers_list->append(_minor_gc_manager); - _managers_list->append(_major_gc_manager); - - add_generation_memory_pool(heap->young_gen(), _major_gc_manager, _minor_gc_manager); - add_generation_memory_pool(heap->old_gen(), _major_gc_manager); -} - -#if INCLUDE_ALL_GCS -// Add memory pools for ParallelScavengeHeap -// This function currently only supports two generations collected heap. -// The collector for ParallelScavengeHeap will have two memory managers. -void MemoryService::add_parallel_scavenge_heap_info(ParallelScavengeHeap* heap) { - // Two managers to keep statistics about _minor_gc_manager and _major_gc_manager GC. - _minor_gc_manager = MemoryManager::get_psScavenge_memory_manager(); - _major_gc_manager = MemoryManager::get_psMarkSweep_memory_manager(); - _managers_list->append(_minor_gc_manager); - _managers_list->append(_major_gc_manager); - - add_psYoung_memory_pool(heap->young_gen(), _major_gc_manager, _minor_gc_manager); - add_psOld_memory_pool(heap->old_gen(), _major_gc_manager); -} - -void MemoryService::add_g1_heap_info(G1CollectedHeap* g1h) { - assert(UseG1GC, "sanity"); - - _minor_gc_manager = MemoryManager::get_g1YoungGen_memory_manager(); - _major_gc_manager = MemoryManager::get_g1OldGen_memory_manager(); - _managers_list->append(_minor_gc_manager); - _managers_list->append(_major_gc_manager); - - add_g1YoungGen_memory_pool(g1h, _major_gc_manager, _minor_gc_manager); - add_g1OldGen_memory_pool(g1h, _major_gc_manager); -} -#endif // INCLUDE_ALL_GCS - -MemoryPool* MemoryService::add_gen(Generation* gen, - const char* name, - bool is_heap, - bool support_usage_threshold) { - - MemoryPool::PoolType type = (is_heap ? MemoryPool::Heap : MemoryPool::NonHeap); - GenerationPool* pool = new GenerationPool(gen, name, type, support_usage_threshold); - _pools_list->append(pool); - return (MemoryPool*) pool; -} - -MemoryPool* MemoryService::add_space(ContiguousSpace* space, - const char* name, - bool is_heap, - size_t max_size, - bool support_usage_threshold) { - MemoryPool::PoolType type = (is_heap ? MemoryPool::Heap : MemoryPool::NonHeap); - ContiguousSpacePool* pool = new ContiguousSpacePool(space, name, type, max_size, support_usage_threshold); - - _pools_list->append(pool); - return (MemoryPool*) pool; -} - -MemoryPool* MemoryService::add_survivor_spaces(DefNewGeneration* young_gen, - const char* name, - bool is_heap, - size_t max_size, - bool support_usage_threshold) { - MemoryPool::PoolType type = (is_heap ? MemoryPool::Heap : MemoryPool::NonHeap); - SurvivorContiguousSpacePool* pool = new SurvivorContiguousSpacePool(young_gen, name, type, max_size, support_usage_threshold); - - _pools_list->append(pool); - return (MemoryPool*) pool; -} - -#if INCLUDE_ALL_GCS -MemoryPool* MemoryService::add_cms_space(CompactibleFreeListSpace* space, - const char* name, - bool is_heap, - size_t max_size, - bool support_usage_threshold) { - MemoryPool::PoolType type = (is_heap ? MemoryPool::Heap : MemoryPool::NonHeap); - CompactibleFreeListSpacePool* pool = new CompactibleFreeListSpacePool(space, name, type, max_size, support_usage_threshold); - _pools_list->append(pool); - return (MemoryPool*) pool; -} -#endif // INCLUDE_ALL_GCS - -// Add memory pool(s) for one generation -void MemoryService::add_generation_memory_pool(Generation* gen, - MemoryManager* major_mgr, - MemoryManager* minor_mgr) { - guarantee(gen != NULL, "No generation for memory pool"); - Generation::Name kind = gen->kind(); - int index = _pools_list->length(); - - switch (kind) { - case Generation::DefNew: { - assert(major_mgr != NULL && minor_mgr != NULL, "Should have two managers"); - DefNewGeneration* young_gen = (DefNewGeneration*) gen; - // Add a memory pool for each space and young gen doesn't - // support low memory detection as it is expected to get filled up. - MemoryPool* eden = add_space(young_gen->eden(), - "Eden Space", - true, /* is_heap */ - young_gen->max_eden_size(), - false /* support_usage_threshold */); - MemoryPool* survivor = add_survivor_spaces(young_gen, - "Survivor Space", - true, /* is_heap */ - young_gen->max_survivor_size(), - false /* support_usage_threshold */); - break; - } - -#if INCLUDE_ALL_GCS - case Generation::ParNew: - { - assert(major_mgr != NULL && minor_mgr != NULL, "Should have two managers"); - // Add a memory pool for each space and young gen doesn't - // support low memory detection as it is expected to get filled up. - ParNewGeneration* parnew_gen = (ParNewGeneration*) gen; - MemoryPool* eden = add_space(parnew_gen->eden(), - "Par Eden Space", - true /* is_heap */, - parnew_gen->max_eden_size(), - false /* support_usage_threshold */); - MemoryPool* survivor = add_survivor_spaces(parnew_gen, - "Par Survivor Space", - true, /* is_heap */ - parnew_gen->max_survivor_size(), - false /* support_usage_threshold */); - - break; - } -#endif // INCLUDE_ALL_GCS - - case Generation::MarkSweepCompact: { - assert(major_mgr != NULL && minor_mgr == NULL, "Should have only one manager"); - add_gen(gen, - "Tenured Gen", - true, /* is_heap */ - true /* support_usage_threshold */); - break; - } - -#if INCLUDE_ALL_GCS - case Generation::ConcurrentMarkSweep: - { - assert(major_mgr != NULL && minor_mgr == NULL, "Should have only one manager"); - ConcurrentMarkSweepGeneration* cms = (ConcurrentMarkSweepGeneration*) gen; - MemoryPool* pool = add_cms_space(cms->cmsSpace(), - "CMS Old Gen", - true, /* is_heap */ - cms->reserved().byte_size(), - true /* support_usage_threshold */); - break; - } -#endif // INCLUDE_ALL_GCS - - default: - assert(false, "should not reach here"); - // no memory pool added for others - break; - } - - assert(major_mgr != NULL, "Should have at least one manager"); - // Link managers and the memory pools together - for (int i = index; i < _pools_list->length(); i++) { - MemoryPool* pool = _pools_list->at(i); - major_mgr->add_pool(pool); - if (minor_mgr != NULL) { - minor_mgr->add_pool(pool); - } - } -} - - -#if INCLUDE_ALL_GCS -void MemoryService::add_psYoung_memory_pool(PSYoungGen* young_gen, MemoryManager* major_mgr, MemoryManager* minor_mgr) { - assert(major_mgr != NULL && minor_mgr != NULL, "Should have two managers"); - - // Add a memory pool for each space and young gen doesn't - // support low memory detection as it is expected to get filled up. - EdenMutableSpacePool* eden = new EdenMutableSpacePool(young_gen, - young_gen->eden_space(), - "PS Eden Space", - MemoryPool::Heap, - false /* support_usage_threshold */); - - SurvivorMutableSpacePool* survivor = new SurvivorMutableSpacePool(young_gen, - "PS Survivor Space", - MemoryPool::Heap, - false /* support_usage_threshold */); - - major_mgr->add_pool(eden); - major_mgr->add_pool(survivor); - minor_mgr->add_pool(eden); - minor_mgr->add_pool(survivor); - _pools_list->append(eden); - _pools_list->append(survivor); -} - -void MemoryService::add_psOld_memory_pool(PSOldGen* old_gen, MemoryManager* mgr) { - PSGenerationPool* old_gen_pool = new PSGenerationPool(old_gen, - "PS Old Gen", - MemoryPool::Heap, - true /* support_usage_threshold */); - mgr->add_pool(old_gen_pool); - _pools_list->append(old_gen_pool); -} - -void MemoryService::add_g1YoungGen_memory_pool(G1CollectedHeap* g1h, - MemoryManager* major_mgr, - MemoryManager* minor_mgr) { - assert(major_mgr != NULL && minor_mgr != NULL, "should have two managers"); - - G1EdenPool* eden = new G1EdenPool(g1h); - G1SurvivorPool* survivor = new G1SurvivorPool(g1h); - - major_mgr->add_pool(eden); - major_mgr->add_pool(survivor); - minor_mgr->add_pool(eden); - minor_mgr->add_pool(survivor); - _pools_list->append(eden); - _pools_list->append(survivor); -} - -void MemoryService::add_g1OldGen_memory_pool(G1CollectedHeap* g1h, - MemoryManager* mgr) { - assert(mgr != NULL, "should have one manager"); - - G1OldGenPool* old_gen = new G1OldGenPool(g1h); - mgr->add_pool(old_gen); - _pools_list->append(old_gen); -} -#endif // INCLUDE_ALL_GCS - void MemoryService::add_code_heap_memory_pool(CodeHeap* heap, const char* name) { // Create new memory pool for this heap MemoryPool* code_heap_pool = new CodeHeapPool(heap, name, true /* support_usage_threshold */); --- old/src/hotspot/share/services/memoryService.hpp 2017-11-20 16:28:39.220254682 +0100 +++ new/src/hotspot/share/services/memoryService.hpp 2017-11-20 16:28:38.952257835 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2017, 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 @@ -72,51 +72,6 @@ static MemoryPool* _metaspace_pool; static MemoryPool* _compressed_class_pool; - static void add_generation_memory_pool(Generation* gen, - MemoryManager* major_mgr, - MemoryManager* minor_mgr); - static void add_generation_memory_pool(Generation* gen, - MemoryManager* major_mgr) { - add_generation_memory_pool(gen, major_mgr, NULL); - } - - - static void add_psYoung_memory_pool(PSYoungGen* young_gen, - MemoryManager* major_mgr, - MemoryManager* minor_mgr); - static void add_psOld_memory_pool(PSOldGen* old_gen, - MemoryManager* mgr); - - static void add_g1YoungGen_memory_pool(G1CollectedHeap* g1h, - MemoryManager* major_mgr, - MemoryManager* minor_mgr); - static void add_g1OldGen_memory_pool(G1CollectedHeap* g1h, - MemoryManager* mgr); - - static MemoryPool* add_space(ContiguousSpace* space, - const char* name, - bool is_heap, - size_t max_size, - bool support_usage_threshold); - static MemoryPool* add_survivor_spaces(DefNewGeneration* young_gen, - const char* name, - bool is_heap, - size_t max_size, - bool support_usage_threshold); - static MemoryPool* add_gen(Generation* gen, - const char* name, - bool is_heap, - bool support_usage_threshold); - static MemoryPool* add_cms_space(CompactibleFreeListSpace* space, - const char* name, - bool is_heap, - size_t max_size, - bool support_usage_threshold); - - static void add_gen_collected_heap_info(GenCollectedHeap* heap); - static void add_parallel_scavenge_heap_info(ParallelScavengeHeap* heap); - static void add_g1_heap_info(G1CollectedHeap* g1h); - public: static void set_universe_heap(CollectedHeap* heap); static void add_code_heap_memory_pool(CodeHeap* heap, const char* name); --- /dev/null 2017-11-08 15:25:57.713133075 +0100 +++ new/src/hotspot/share/gc/cms/cmsGCServicabilitySupport.cpp 2017-11-20 16:28:39.786248023 +0100 @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2017, Red Hat, Inc. and/or its affiliates. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#include "precompiled.hpp" +#include "gc/cms/cmsGCServicabilitySupport.hpp" +#include "gc/cms/compactibleFreeListSpace.hpp" +#include "gc/cms/concurrentMarkSweepGeneration.hpp" +#include "gc/cms/parNewGeneration.hpp" +#include "gc/shared/genCollectedHeap.hpp" +#include "services/memoryManager.hpp" +#include "services/memoryPool.hpp" + +class ParNewMemoryManager : public GCMemoryManager { +private: +public: + ParNewMemoryManager() : GCMemoryManager() {} + + const char* name() { return "ParNew"; } +}; + +class CMSMemoryManager : public GCMemoryManager { +private: +public: + CMSMemoryManager() : GCMemoryManager() {} + + const char* name() { return "ConcurrentMarkSweep";} +}; + +GCMemoryManager* CMSGCServicabilitySupport::create_minor_gc_manager() { + return new ParNewMemoryManager(); +} + +GCMemoryManager* CMSGCServicabilitySupport::create_major_gc_manager() { + return new CMSMemoryManager(); +} + +class CompactibleFreeListSpacePool : public CollectedMemoryPool { +private: + CompactibleFreeListSpace* _space; +public: + CompactibleFreeListSpacePool(CompactibleFreeListSpace* space, + const char* name, + PoolType type, + size_t max_size, + bool support_usage_threshold) : + CollectedMemoryPool(name, type, space->capacity(), max_size, + support_usage_threshold), _space(space) { + } + + MemoryUsage get_memory_usage() { + size_t maxSize = (available_for_allocation() ? max_size() : 0); + size_t used = used_in_bytes(); + size_t committed = _space->capacity(); + + return MemoryUsage(initial_size(), used, committed, maxSize); + } + + size_t used_in_bytes() { + return _space->used(); + } +}; + +void CMSGCServicabilitySupport::add_memory_pools(GrowableArray* pools_list, + GCMemoryManager* minor_mgr, + GCMemoryManager* major_mgr) { + + GenCollectedHeap* heap = GenCollectedHeap::heap(); + ParNewGeneration* young_gen = (ParNewGeneration*) heap->young_gen(); + ContiguousSpacePool* eden = new ContiguousSpacePool(young_gen->eden(), "Par Eden Space", MemoryPool::Heap, young_gen->max_eden_size(), false); + SurvivorContiguousSpacePool* survivor = new SurvivorContiguousSpacePool(young_gen, "Par Survivor Space", MemoryPool::Heap, young_gen->max_survivor_size(), false); + + ConcurrentMarkSweepGeneration* cms = (ConcurrentMarkSweepGeneration*) heap->old_gen(); + CompactibleFreeListSpacePool* old = new CompactibleFreeListSpacePool(cms->cmsSpace(), "CMS Old Gen", MemoryPool::Heap, cms->reserved().byte_size(), true); + + pools_list->append(eden); + pools_list->append(survivor); + pools_list->append(old); + + minor_mgr->add_pool(eden); + major_mgr->add_pool(eden); + minor_mgr->add_pool(survivor); + major_mgr->add_pool(survivor); + major_mgr->add_pool(old); +} --- /dev/null 2017-11-08 15:25:57.713133075 +0100 +++ new/src/hotspot/share/gc/cms/cmsGCServicabilitySupport.hpp 2017-11-20 16:28:40.676237552 +0100 @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2017, Red Hat, Inc. and/or its affiliates. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef SHARE_GC_CMS_CMSGCSERVICABILITYSUPPORT_HPP +#define SHARE_GC_CMS_CMSGCSERVICABILITYSUPPORT_HPP + +#include "gc/shared/gcServicabilitySupport.hpp" + +class GCMemoryManager; + +class CMSGCServicabilitySupport : public GCServicabilitySupport { + + GCMemoryManager* create_minor_gc_manager(); + GCMemoryManager* create_major_gc_manager(); + void add_memory_pools(GrowableArray* pools_list, + GCMemoryManager* minor_mgr, + GCMemoryManager* major_mgr); +}; + +#endif // SHARE_GC_CMS_CMSGCSERVICABILITYSUPPORT_HPP --- /dev/null 2017-11-08 15:25:57.713133075 +0100 +++ new/src/hotspot/share/gc/g1/g1GCServicabilitySupport.cpp 2017-11-20 16:28:41.606226611 +0100 @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2017, Red Hat, Inc. and/or its affiliates. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#include "precompiled.hpp" +#include "gc/g1/g1GCServicabilitySupport.hpp" +#include "gc/g1/g1CollectedHeap.hpp" +#include "gc/g1/g1MemoryPool.hpp" + +#include "services/memoryManager.hpp" + +class G1YoungGenMemoryManager : public GCMemoryManager { +private: +public: + G1YoungGenMemoryManager() : GCMemoryManager() {} + + const char* name() { return "G1 Young Generation"; } +}; + +class G1OldGenMemoryManager : public GCMemoryManager { +private: +public: + G1OldGenMemoryManager() : GCMemoryManager() {} + + const char* name() { return "G1 Old Generation"; } +}; + + +GCMemoryManager* G1GCServicabilitySupport::create_minor_gc_manager() { + return new G1YoungGenMemoryManager(); +} + +GCMemoryManager* G1GCServicabilitySupport::create_major_gc_manager() { + return new G1OldGenMemoryManager(); +} + +void G1GCServicabilitySupport::add_memory_pools(GrowableArray* pools_list, + GCMemoryManager* minor_mgr, + GCMemoryManager* major_mgr) { + + G1CollectedHeap* g1h = G1CollectedHeap::heap(); + G1EdenPool* eden = new G1EdenPool(g1h); + G1SurvivorPool* survivor = new G1SurvivorPool(g1h); + G1OldGenPool* old_gen = new G1OldGenPool(g1h); + + major_mgr->add_pool(eden); + major_mgr->add_pool(survivor); + major_mgr->add_pool(old_gen); + minor_mgr->add_pool(eden); + minor_mgr->add_pool(survivor); + pools_list->append(eden); + pools_list->append(survivor); + pools_list->append(old_gen); +} --- /dev/null 2017-11-08 15:25:57.713133075 +0100 +++ new/src/hotspot/share/gc/g1/g1GCServicabilitySupport.hpp 2017-11-20 16:28:42.425216975 +0100 @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2017, Red Hat, Inc. and/or its affiliates. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef SHARE_GC_G1_G1GCSERVICABILITYSUPPORT_HPP +#define SHARE_GC_G1_G1GCSERVICABILITYSUPPORT_HPP + +#include "gc/shared/gcServicabilitySupport.hpp" + +class GCMemoryManager; + +class G1GCServicabilitySupport : public GCServicabilitySupport { + + GCMemoryManager* create_minor_gc_manager(); + GCMemoryManager* create_major_gc_manager(); + void add_memory_pools(GrowableArray* pools_list, + GCMemoryManager* minor_mgr, + GCMemoryManager* major_mgr); +}; + +#endif // SHARE_GC_G1_G1GCSERVICABILITYSUPPORT_HPP --- old/src/hotspot/share/services/g1MemoryPool.cpp 2017-11-20 16:28:43.534203928 +0100 +++ /dev/null 2017-11-08 15:25:57.713133075 +0100 @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2007, 2015, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#include "precompiled.hpp" -#include "gc/g1/g1CollectedHeap.hpp" -#include "gc/g1/heapRegion.hpp" -#include "services/g1MemoryPool.hpp" - -G1MemoryPoolSuper::G1MemoryPoolSuper(G1CollectedHeap* g1h, - const char* name, - size_t init_size, - size_t max_size, - bool support_usage_threshold) : - _g1mm(g1h->g1mm()), CollectedMemoryPool(name, - MemoryPool::Heap, - init_size, - max_size, - support_usage_threshold) { - assert(UseG1GC, "sanity"); -} - -G1EdenPool::G1EdenPool(G1CollectedHeap* g1h) : - G1MemoryPoolSuper(g1h, - "G1 Eden Space", - g1h->g1mm()->eden_space_committed(), /* init_size */ - _undefined_max, - false /* support_usage_threshold */) { } - -MemoryUsage G1EdenPool::get_memory_usage() { - size_t initial_sz = initial_size(); - size_t max_sz = max_size(); - size_t used = used_in_bytes(); - size_t committed = _g1mm->eden_space_committed(); - - return MemoryUsage(initial_sz, used, committed, max_sz); -} - -G1SurvivorPool::G1SurvivorPool(G1CollectedHeap* g1h) : - G1MemoryPoolSuper(g1h, - "G1 Survivor Space", - g1h->g1mm()->survivor_space_committed(), /* init_size */ - _undefined_max, - false /* support_usage_threshold */) { } - -MemoryUsage G1SurvivorPool::get_memory_usage() { - size_t initial_sz = initial_size(); - size_t max_sz = max_size(); - size_t used = used_in_bytes(); - size_t committed = _g1mm->survivor_space_committed(); - - return MemoryUsage(initial_sz, used, committed, max_sz); -} - -G1OldGenPool::G1OldGenPool(G1CollectedHeap* g1h) : - G1MemoryPoolSuper(g1h, - "G1 Old Gen", - g1h->g1mm()->old_space_committed(), /* init_size */ - g1h->g1mm()->old_gen_max(), - true /* support_usage_threshold */) { } - -MemoryUsage G1OldGenPool::get_memory_usage() { - size_t initial_sz = initial_size(); - size_t max_sz = max_size(); - size_t used = used_in_bytes(); - size_t committed = _g1mm->old_space_committed(); - - return MemoryUsage(initial_sz, used, committed, max_sz); -} --- /dev/null 2017-11-08 15:25:57.713133075 +0100 +++ new/src/hotspot/share/gc/g1/g1MemoryPool.cpp 2017-11-20 16:28:43.240207387 +0100 @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2007, 2017, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#include "precompiled.hpp" +#include "gc/g1/g1CollectedHeap.hpp" +#include "gc/g1/g1MemoryPool.hpp" +#include "gc/g1/heapRegion.hpp" + +G1MemoryPoolSuper::G1MemoryPoolSuper(G1CollectedHeap* g1h, + const char* name, + size_t init_size, + size_t max_size, + bool support_usage_threshold) : + _g1mm(g1h->g1mm()), CollectedMemoryPool(name, + MemoryPool::Heap, + init_size, + max_size, + support_usage_threshold) { + assert(UseG1GC, "sanity"); +} + +G1EdenPool::G1EdenPool(G1CollectedHeap* g1h) : + G1MemoryPoolSuper(g1h, + "G1 Eden Space", + g1h->g1mm()->eden_space_committed(), /* init_size */ + _undefined_max, + false /* support_usage_threshold */) { } + +MemoryUsage G1EdenPool::get_memory_usage() { + size_t initial_sz = initial_size(); + size_t max_sz = max_size(); + size_t used = used_in_bytes(); + size_t committed = _g1mm->eden_space_committed(); + + return MemoryUsage(initial_sz, used, committed, max_sz); +} + +G1SurvivorPool::G1SurvivorPool(G1CollectedHeap* g1h) : + G1MemoryPoolSuper(g1h, + "G1 Survivor Space", + g1h->g1mm()->survivor_space_committed(), /* init_size */ + _undefined_max, + false /* support_usage_threshold */) { } + +MemoryUsage G1SurvivorPool::get_memory_usage() { + size_t initial_sz = initial_size(); + size_t max_sz = max_size(); + size_t used = used_in_bytes(); + size_t committed = _g1mm->survivor_space_committed(); + + return MemoryUsage(initial_sz, used, committed, max_sz); +} + +G1OldGenPool::G1OldGenPool(G1CollectedHeap* g1h) : + G1MemoryPoolSuper(g1h, + "G1 Old Gen", + g1h->g1mm()->old_space_committed(), /* init_size */ + g1h->g1mm()->old_gen_max(), + true /* support_usage_threshold */) { } + +MemoryUsage G1OldGenPool::get_memory_usage() { + size_t initial_sz = initial_size(); + size_t max_sz = max_size(); + size_t used = used_in_bytes(); + size_t committed = _g1mm->old_space_committed(); + + return MemoryUsage(initial_sz, used, committed, max_sz); +} --- old/src/hotspot/share/services/g1MemoryPool.hpp 2017-11-20 16:28:44.373194057 +0100 +++ /dev/null 2017-11-08 15:25:57.713133075 +0100 @@ -1,110 +0,0 @@ -/* - * Copyright (c) 2007, 2015, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#ifndef SHARE_VM_SERVICES_G1MEMORYPOOL_HPP -#define SHARE_VM_SERVICES_G1MEMORYPOOL_HPP - -#include "utilities/macros.hpp" -#if INCLUDE_ALL_GCS -#include "gc/g1/g1MonitoringSupport.hpp" -#include "services/memoryPool.hpp" -#include "services/memoryUsage.hpp" -#endif // INCLUDE_ALL_GCS - -// 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. -// -// See comments in g1MonitoringSupport.hpp for additional details -// on this model. -// - -// This class is shared by the three G1 memory pool classes -// (G1EdenPool, G1SurvivorPool, G1OldGenPool). -class G1MemoryPoolSuper : public CollectedMemoryPool { -protected: - const static size_t _undefined_max = (size_t) -1; - G1MonitoringSupport* _g1mm; - - // Would only be called from subclasses. - G1MemoryPoolSuper(G1CollectedHeap* g1h, - const char* name, - size_t init_size, - size_t max_size, - bool support_usage_threshold); -}; - -// Memory pool that represents the G1 eden. -class G1EdenPool : public G1MemoryPoolSuper { -public: - G1EdenPool(G1CollectedHeap* g1h); - - size_t used_in_bytes() { - return _g1mm->eden_space_used(); - } - size_t max_size() const { - return _undefined_max; - } - MemoryUsage get_memory_usage(); -}; - -// Memory pool that represents the G1 survivor. -class G1SurvivorPool : public G1MemoryPoolSuper { -public: - G1SurvivorPool(G1CollectedHeap* g1h); - - size_t used_in_bytes() { - return _g1mm->survivor_space_used(); - } - size_t max_size() const { - return _undefined_max; - } - MemoryUsage get_memory_usage(); -}; - -// Memory pool that represents the G1 old gen. -class G1OldGenPool : public G1MemoryPoolSuper { -public: - G1OldGenPool(G1CollectedHeap* g1h); - - size_t used_in_bytes() { - return _g1mm->old_space_used(); - } - size_t max_size() const { - return _g1mm->old_gen_max(); - } - MemoryUsage get_memory_usage(); -}; - -#endif // SHARE_VM_SERVICES_G1MEMORYPOOL_HPP --- /dev/null 2017-11-08 15:25:57.713133075 +0100 +++ new/src/hotspot/share/gc/g1/g1MemoryPool.hpp 2017-11-20 16:28:44.081197492 +0100 @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2007, 2017, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef SHARE_VM_SERVICES_G1MEMORYPOOL_HPP +#define SHARE_VM_SERVICES_G1MEMORYPOOL_HPP + +#include "utilities/macros.hpp" +#include "gc/g1/g1MonitoringSupport.hpp" +#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. +// +// See comments in g1MonitoringSupport.hpp for additional details +// on this model. +// + +// This class is shared by the three G1 memory pool classes +// (G1EdenPool, G1SurvivorPool, G1OldGenPool). +class G1MemoryPoolSuper : public CollectedMemoryPool { +protected: + const static size_t _undefined_max = (size_t) -1; + G1MonitoringSupport* _g1mm; + + // Would only be called from subclasses. + G1MemoryPoolSuper(G1CollectedHeap* g1h, + const char* name, + size_t init_size, + size_t max_size, + bool support_usage_threshold); +}; + +// Memory pool that represents the G1 eden. +class G1EdenPool : public G1MemoryPoolSuper { +public: + G1EdenPool(G1CollectedHeap* g1h); + + size_t used_in_bytes() { + return _g1mm->eden_space_used(); + } + size_t max_size() const { + return _undefined_max; + } + MemoryUsage get_memory_usage(); +}; + +// Memory pool that represents the G1 survivor. +class G1SurvivorPool : public G1MemoryPoolSuper { +public: + G1SurvivorPool(G1CollectedHeap* g1h); + + size_t used_in_bytes() { + return _g1mm->survivor_space_used(); + } + size_t max_size() const { + return _undefined_max; + } + MemoryUsage get_memory_usage(); +}; + +// Memory pool that represents the G1 old gen. +class G1OldGenPool : public G1MemoryPoolSuper { +public: + G1OldGenPool(G1CollectedHeap* g1h); + + size_t used_in_bytes() { + return _g1mm->old_space_used(); + } + size_t max_size() const { + return _g1mm->old_gen_max(); + } + MemoryUsage get_memory_usage(); +}; + +#endif // SHARE_VM_SERVICES_G1MEMORYPOOL_HPP --- /dev/null 2017-11-08 15:25:57.713133075 +0100 +++ new/src/hotspot/share/gc/parallel/parallelGCServicabilitySupport.cpp 2017-11-20 16:28:44.938187410 +0100 @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2017, Red Hat, Inc. and/or its affiliates. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#include "precompiled.hpp" +#include "gc/parallel/parallelGCServicabilitySupport.hpp" +#include "gc/parallel/parallelScavengeHeap.hpp" +#include "gc/parallel/psMemoryPool.hpp" + +#include "services/memoryManager.hpp" + +class PSScavengeMemoryManager : public GCMemoryManager { +private: +public: + PSScavengeMemoryManager() : GCMemoryManager() {} + + const char* name() { return "PS Scavenge"; } +}; + +class PSMarkSweepMemoryManager : public GCMemoryManager { +private: +public: + PSMarkSweepMemoryManager() : GCMemoryManager() {} + + const char* name() { return "PS MarkSweep"; } +}; + +GCMemoryManager* ParallelGCServicabilitySupport::create_minor_gc_manager() { + return new PSScavengeMemoryManager(); +} + +GCMemoryManager* ParallelGCServicabilitySupport::create_major_gc_manager() { + return new PSMarkSweepMemoryManager(); +} + +void ParallelGCServicabilitySupport::add_memory_pools(GrowableArray* pools_list, + GCMemoryManager* minor_mgr, + GCMemoryManager* major_mgr) { + ParallelScavengeHeap* heap = ParallelScavengeHeap::heap(); + PSYoungGen* young_gen = heap->young_gen(); + EdenMutableSpacePool* eden = new EdenMutableSpacePool(young_gen, + young_gen->eden_space(), + "PS Eden Space", + MemoryPool::Heap, + false /* support_usage_threshold */); + + SurvivorMutableSpacePool* survivor = new SurvivorMutableSpacePool(young_gen, + "PS Survivor Space", + MemoryPool::Heap, + false /* support_usage_threshold */); + + PSGenerationPool* old_gen_pool = new PSGenerationPool(heap->old_gen(), + "PS Old Gen", + MemoryPool::Heap, + true /* support_usage_threshold */); + + major_mgr->add_pool(eden); + major_mgr->add_pool(survivor); + major_mgr->add_pool(old_gen_pool); + + minor_mgr->add_pool(eden); + minor_mgr->add_pool(survivor); + + pools_list->append(eden); + pools_list->append(survivor); + pools_list->append(old_gen_pool); + +} --- /dev/null 2017-11-08 15:25:57.713133075 +0100 +++ new/src/hotspot/share/gc/parallel/parallelGCServicabilitySupport.hpp 2017-11-20 16:28:45.773177586 +0100 @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2017, Red Hat, Inc. and/or its affiliates. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef SHARE_GC_PARALLEL_PARALLELGCSERVICABILITYSUPPORT_HPP +#define SHARE_GC_PARALLEL_PARALLELGCSERVICABILITYSUPPORT_HPP + +#include "gc/shared/gcServicabilitySupport.hpp" + +class GCMemoryManager; + +class ParallelGCServicabilitySupport : public GCServicabilitySupport { + + GCMemoryManager* create_minor_gc_manager(); + GCMemoryManager* create_major_gc_manager(); + void add_memory_pools(GrowableArray* pools_list, + GCMemoryManager* minor_mgr, + GCMemoryManager* major_mgr); +}; + +#endif // SHARE_GC_PARALLEL_PARALLELGCSERVICABILITYSUPPORT_HPP --- old/src/hotspot/share/services/psMemoryPool.cpp 2017-11-20 16:28:46.904164280 +0100 +++ /dev/null 2017-11-08 15:25:57.713133075 +0100 @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2007, 2015, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#include "precompiled.hpp" -#include "classfile/systemDictionary.hpp" -#include "classfile/vmSymbols.hpp" -#include "oops/oop.inline.hpp" -#include "runtime/handles.inline.hpp" -#include "runtime/javaCalls.hpp" -#include "services/lowMemoryDetector.hpp" -#include "services/management.hpp" -#include "services/memoryManager.hpp" -#include "services/psMemoryPool.hpp" - -PSGenerationPool::PSGenerationPool(PSOldGen* old_gen, - const char* name, - PoolType type, - bool support_usage_threshold) : - CollectedMemoryPool(name, type, old_gen->capacity_in_bytes(), - old_gen->reserved().byte_size(), support_usage_threshold), _old_gen(old_gen) { -} - -MemoryUsage PSGenerationPool::get_memory_usage() { - size_t maxSize = (available_for_allocation() ? max_size() : 0); - size_t used = used_in_bytes(); - size_t committed = _old_gen->capacity_in_bytes(); - - return MemoryUsage(initial_size(), used, committed, maxSize); -} - -// The max size of EdenMutableSpacePool = -// max size of the PSYoungGen - capacity of two survivor spaces -// -// Max size of PS eden space is changing due to ergonomic. -// PSYoungGen, PSOldGen, Eden, Survivor spaces are all resizable. -// -EdenMutableSpacePool::EdenMutableSpacePool(PSYoungGen* young_gen, - MutableSpace* space, - const char* name, - PoolType type, - bool support_usage_threshold) : - CollectedMemoryPool(name, type, space->capacity_in_bytes(), - (young_gen->max_size() - young_gen->from_space()->capacity_in_bytes() - young_gen->to_space()->capacity_in_bytes()), - support_usage_threshold), - _young_gen(young_gen), - _space(space) { -} - -MemoryUsage EdenMutableSpacePool::get_memory_usage() { - size_t maxSize = (available_for_allocation() ? max_size() : 0); - size_t used = used_in_bytes(); - size_t committed = _space->capacity_in_bytes(); - - return MemoryUsage(initial_size(), used, committed, maxSize); -} - -// The max size of SurvivorMutableSpacePool = -// current capacity of the from-space -// -// PS from and to survivor spaces could have different sizes. -// -SurvivorMutableSpacePool::SurvivorMutableSpacePool(PSYoungGen* young_gen, - const char* name, - PoolType type, - bool support_usage_threshold) : - CollectedMemoryPool(name, type, young_gen->from_space()->capacity_in_bytes(), - young_gen->from_space()->capacity_in_bytes(), - support_usage_threshold), _young_gen(young_gen) { -} - -MemoryUsage SurvivorMutableSpacePool::get_memory_usage() { - size_t maxSize = (available_for_allocation() ? max_size() : 0); - size_t used = used_in_bytes(); - size_t committed = committed_in_bytes(); - return MemoryUsage(initial_size(), used, committed, maxSize); -} --- /dev/null 2017-11-08 15:25:57.713133075 +0100 +++ new/src/hotspot/share/gc/parallel/psMemoryPool.cpp 2017-11-20 16:28:46.608167762 +0100 @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2007, 2017, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#include "precompiled.hpp" +#include "classfile/systemDictionary.hpp" +#include "classfile/vmSymbols.hpp" +#include "gc/parallel/psMemoryPool.hpp" +#include "oops/oop.inline.hpp" +#include "runtime/handles.inline.hpp" +#include "runtime/javaCalls.hpp" +#include "services/lowMemoryDetector.hpp" +#include "services/management.hpp" +#include "services/memoryManager.hpp" + +PSGenerationPool::PSGenerationPool(PSOldGen* old_gen, + const char* name, + PoolType type, + bool support_usage_threshold) : + CollectedMemoryPool(name, type, old_gen->capacity_in_bytes(), + old_gen->reserved().byte_size(), support_usage_threshold), _old_gen(old_gen) { +} + +MemoryUsage PSGenerationPool::get_memory_usage() { + size_t maxSize = (available_for_allocation() ? max_size() : 0); + size_t used = used_in_bytes(); + size_t committed = _old_gen->capacity_in_bytes(); + + return MemoryUsage(initial_size(), used, committed, maxSize); +} + +// The max size of EdenMutableSpacePool = +// max size of the PSYoungGen - capacity of two survivor spaces +// +// Max size of PS eden space is changing due to ergonomic. +// PSYoungGen, PSOldGen, Eden, Survivor spaces are all resizable. +// +EdenMutableSpacePool::EdenMutableSpacePool(PSYoungGen* young_gen, + MutableSpace* space, + const char* name, + PoolType type, + bool support_usage_threshold) : + CollectedMemoryPool(name, type, space->capacity_in_bytes(), + (young_gen->max_size() - young_gen->from_space()->capacity_in_bytes() - young_gen->to_space()->capacity_in_bytes()), + support_usage_threshold), + _young_gen(young_gen), + _space(space) { +} + +MemoryUsage EdenMutableSpacePool::get_memory_usage() { + size_t maxSize = (available_for_allocation() ? max_size() : 0); + size_t used = used_in_bytes(); + size_t committed = _space->capacity_in_bytes(); + + return MemoryUsage(initial_size(), used, committed, maxSize); +} + +// The max size of SurvivorMutableSpacePool = +// current capacity of the from-space +// +// PS from and to survivor spaces could have different sizes. +// +SurvivorMutableSpacePool::SurvivorMutableSpacePool(PSYoungGen* young_gen, + const char* name, + PoolType type, + bool support_usage_threshold) : + CollectedMemoryPool(name, type, young_gen->from_space()->capacity_in_bytes(), + young_gen->from_space()->capacity_in_bytes(), + support_usage_threshold), _young_gen(young_gen) { +} + +MemoryUsage SurvivorMutableSpacePool::get_memory_usage() { + size_t maxSize = (available_for_allocation() ? max_size() : 0); + size_t used = used_in_bytes(); + size_t committed = committed_in_bytes(); + return MemoryUsage(initial_size(), used, committed, maxSize); +} --- old/src/hotspot/share/services/psMemoryPool.hpp 2017-11-20 16:28:47.747154362 +0100 +++ /dev/null 2017-11-08 15:25:57.713133075 +0100 @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2007, 2015, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#ifndef SHARE_VM_SERVICES_PSMEMORYPOOL_HPP -#define SHARE_VM_SERVICES_PSMEMORYPOOL_HPP - -#include "utilities/macros.hpp" -#if INCLUDE_ALL_GCS -#include "gc/parallel/mutableSpace.hpp" -#include "gc/parallel/psOldGen.hpp" -#include "gc/parallel/psYoungGen.hpp" -#include "gc/serial/defNewGeneration.hpp" -#include "gc/shared/space.hpp" -#include "memory/heap.hpp" -#include "services/memoryPool.hpp" -#include "services/memoryUsage.hpp" -#endif // INCLUDE_ALL_GCS - -class PSGenerationPool : public CollectedMemoryPool { -private: - PSOldGen* _old_gen; - -public: - PSGenerationPool(PSOldGen* pool, const char* name, PoolType type, bool support_usage_threshold); - - MemoryUsage get_memory_usage(); - size_t used_in_bytes() { return _old_gen->used_in_bytes(); } - size_t max_size() const { return _old_gen->reserved().byte_size(); } -}; - -class EdenMutableSpacePool : public CollectedMemoryPool { -private: - PSYoungGen* _young_gen; - MutableSpace* _space; - -public: - EdenMutableSpacePool(PSYoungGen* young_gen, - MutableSpace* space, - const char* name, - PoolType type, - bool support_usage_threshold); - - MutableSpace* space() { return _space; } - MemoryUsage get_memory_usage(); - size_t used_in_bytes() { return space()->used_in_bytes(); } - size_t max_size() const { - // Eden's max_size = max_size of Young Gen - the current committed size of survivor spaces - return _young_gen->max_size() - _young_gen->from_space()->capacity_in_bytes() - _young_gen->to_space()->capacity_in_bytes(); - } -}; - -class SurvivorMutableSpacePool : public CollectedMemoryPool { -private: - PSYoungGen* _young_gen; - -public: - SurvivorMutableSpacePool(PSYoungGen* young_gen, - const char* name, - PoolType type, - bool support_usage_threshold); - - MemoryUsage get_memory_usage(); - - size_t used_in_bytes() { - return _young_gen->from_space()->used_in_bytes(); - } - size_t committed_in_bytes() { - return _young_gen->from_space()->capacity_in_bytes(); - } - size_t max_size() const { - // Return current committed size of the from-space - return _young_gen->from_space()->capacity_in_bytes(); - } -}; - -#endif // SHARE_VM_SERVICES_PSMEMORYPOOL_HPP --- /dev/null 2017-11-08 15:25:57.713133075 +0100 +++ new/src/hotspot/share/gc/parallel/psMemoryPool.hpp 2017-11-20 16:28:47.450157856 +0100 @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2007, 2017, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef SHARE_VM_SERVICES_PSMEMORYPOOL_HPP +#define SHARE_VM_SERVICES_PSMEMORYPOOL_HPP + +#include "utilities/macros.hpp" +#if INCLUDE_ALL_GCS +#include "gc/parallel/mutableSpace.hpp" +#include "gc/parallel/psOldGen.hpp" +#include "gc/parallel/psYoungGen.hpp" +#include "gc/serial/defNewGeneration.hpp" +#include "gc/shared/space.hpp" +#include "memory/heap.hpp" +#include "services/memoryPool.hpp" +#include "services/memoryUsage.hpp" +#endif // INCLUDE_ALL_GCS + +class PSGenerationPool : public CollectedMemoryPool { +private: + PSOldGen* _old_gen; + +public: + PSGenerationPool(PSOldGen* pool, const char* name, PoolType type, bool support_usage_threshold); + + MemoryUsage get_memory_usage(); + size_t used_in_bytes() { return _old_gen->used_in_bytes(); } + size_t max_size() const { return _old_gen->reserved().byte_size(); } +}; + +class EdenMutableSpacePool : public CollectedMemoryPool { +private: + PSYoungGen* _young_gen; + MutableSpace* _space; + +public: + EdenMutableSpacePool(PSYoungGen* young_gen, + MutableSpace* space, + const char* name, + PoolType type, + bool support_usage_threshold); + + MutableSpace* space() { return _space; } + MemoryUsage get_memory_usage(); + size_t used_in_bytes() { return space()->used_in_bytes(); } + size_t max_size() const { + // Eden's max_size = max_size of Young Gen - the current committed size of survivor spaces + return _young_gen->max_size() - _young_gen->from_space()->capacity_in_bytes() - _young_gen->to_space()->capacity_in_bytes(); + } +}; + +class SurvivorMutableSpacePool : public CollectedMemoryPool { +private: + PSYoungGen* _young_gen; + +public: + SurvivorMutableSpacePool(PSYoungGen* young_gen, + const char* name, + PoolType type, + bool support_usage_threshold); + + MemoryUsage get_memory_usage(); + + size_t used_in_bytes() { + return _young_gen->from_space()->used_in_bytes(); + } + size_t committed_in_bytes() { + return _young_gen->from_space()->capacity_in_bytes(); + } + size_t max_size() const { + // Return current committed size of the from-space + return _young_gen->from_space()->capacity_in_bytes(); + } +}; + +#endif // SHARE_VM_SERVICES_PSMEMORYPOOL_HPP --- /dev/null 2017-11-08 15:25:57.713133075 +0100 +++ new/src/hotspot/share/gc/serial/serialGCServicabilitySupport.cpp 2017-11-20 16:28:48.321147609 +0100 @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2017, Red Hat, Inc. and/or its affiliates. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#include "precompiled.hpp" +#include "gc/serial/defNewGeneration.hpp" +#include "gc/serial/serialGCServicabilitySupport.hpp" +#include "gc/shared/genCollectedHeap.hpp" +#include "services/memoryManager.hpp" +#include "services/memoryPool.hpp" + +class CopyMemoryManager : public GCMemoryManager { +private: +public: + CopyMemoryManager() : GCMemoryManager() {} + + const char* name() { return "Copy"; } +}; + +class MSCMemoryManager : public GCMemoryManager { +private: +public: + MSCMemoryManager() : GCMemoryManager() {} + + const char* name() { return "MarkSweepCompact"; } +}; + +GCMemoryManager* SerialGCServicabilitySupport::create_minor_gc_manager() { + return new CopyMemoryManager(); +} + +GCMemoryManager* SerialGCServicabilitySupport::create_major_gc_manager() { + return new MSCMemoryManager(); +} + +void SerialGCServicabilitySupport::add_memory_pools(GrowableArray* pools_list, + GCMemoryManager* minor_mgr, + GCMemoryManager* major_mgr) { + GenCollectedHeap* heap = GenCollectedHeap::heap(); + DefNewGeneration* young_gen = (DefNewGeneration*) heap->young_gen(); + + // Add a memory pool for each space and young gen doesn't + // support low memory detection as it is expected to get filled up. + MemoryPool* eden = new ContiguousSpacePool(young_gen->eden(), + "Eden Space", + MemoryPool::Heap, + young_gen->max_eden_size(), + false /* support_usage_threshold */); + MemoryPool* survivor = new SurvivorContiguousSpacePool(young_gen, + "Survivor Space", + MemoryPool::Heap, + young_gen->max_survivor_size(), + false /* support_usage_threshold */); + GenerationPool* old = new GenerationPool(heap->old_gen(), "Tenured Gen", MemoryPool::Heap, true); + + pools_list->append(eden); + pools_list->append(survivor); + pools_list->append(old); + + minor_mgr->add_pool(eden); + minor_mgr->add_pool(survivor); + + major_mgr->add_pool(eden); + major_mgr->add_pool(survivor); + major_mgr->add_pool(old); +} --- /dev/null 2017-11-08 15:25:57.713133075 +0100 +++ new/src/hotspot/share/gc/serial/serialGCServicabilitySupport.hpp 2017-11-20 16:28:49.206137197 +0100 @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2017, Red Hat, Inc. and/or its affiliates. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef SHARE_GC_SERIAL_SERIALGCSERVICABILITYSUPPORT_HPP +#define SHARE_GC_SERIAL_SERIALGCSERVICABILITYSUPPORT_HPP + +#include "gc/shared/gcServicabilitySupport.hpp" + +class GCMemoryManager; + +class SerialGCServicabilitySupport : public GCServicabilitySupport { +public: + GCMemoryManager* create_minor_gc_manager(); + GCMemoryManager* create_major_gc_manager(); + void add_memory_pools(GrowableArray* pools_list, + GCMemoryManager* minor_mgr, + GCMemoryManager* major_mgr); +}; + +#endif // SHARE_GC_SERIAL_SERIALGCSERVICABILITYSUPPORT_HPP --- /dev/null 2017-11-08 15:25:57.713133075 +0100 +++ new/src/hotspot/share/gc/shared/gcServicabilitySupport.hpp 2017-11-20 16:28:50.078126938 +0100 @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2017, Red Hat, Inc. and/or its affiliates. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef SHARE_GC_SHARED_GCSERVICABILITYSUPPORT_HPP +#define SHARE_GC_SHARED_GCSERVICABILITYSUPPORT_HPP + +#include "memory/allocation.hpp" +#include "utilities/growableArray.hpp" + +class GCMemoryManager; +class MemoryPool; + +class GCServicabilitySupport : public CHeapObj { +public: + virtual GCMemoryManager* create_minor_gc_manager() = 0; + virtual GCMemoryManager* create_major_gc_manager() = 0; + virtual void add_memory_pools(GrowableArray* pools_list, + GCMemoryManager* minor_mgr, + GCMemoryManager* major_mgr) = 0; +}; + +#endif // SHARE_GC_SHARED_GCSERVICABILITYSUPPORT_HPP