8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 #include "precompiled.hpp" 26 #include "code/codeCache.hpp" 27 #include "gc/parallel/adjoiningGenerations.hpp" 28 #include "gc/parallel/adjoiningVirtualSpaces.hpp" 29 #include "gc/parallel/gcTaskManager.hpp" 30 #include "gc/parallel/generationSizer.hpp" 31 #include "gc/parallel/objectStartArray.inline.hpp" 32 #include "gc/parallel/parallelScavengeHeap.inline.hpp" 33 #include "gc/parallel/psAdaptiveSizePolicy.hpp" 34 #include "gc/parallel/psMarkSweepProxy.hpp" 35 #include "gc/parallel/psMemoryPool.hpp" 36 #include "gc/parallel/psParallelCompact.inline.hpp" 37 #include "gc/parallel/psPromotionManager.hpp" 38 #include "gc/parallel/psScavenge.hpp" 39 #include "gc/parallel/vmPSOperations.hpp" 40 #include "gc/shared/gcHeapSummary.hpp" 41 #include "gc/shared/gcLocker.hpp" 42 #include "gc/shared/gcWhen.hpp" 43 #include "logging/log.hpp" 44 #include "memory/metaspaceCounters.hpp" 45 #include "oops/oop.inline.hpp" 46 #include "runtime/handles.inline.hpp" 47 #include "runtime/java.hpp" 48 #include "runtime/vmThread.hpp" 49 #include "services/memoryManager.hpp" 50 #include "services/memTracker.hpp" 51 #include "utilities/macros.hpp" 52 #include "utilities/vmError.hpp" 53 54 PSYoungGen* ParallelScavengeHeap::_young_gen = NULL; 55 PSOldGen* ParallelScavengeHeap::_old_gen = NULL; 56 PSAdaptiveSizePolicy* ParallelScavengeHeap::_size_policy = NULL; 57 PSGCAdaptivePolicyCounters* ParallelScavengeHeap::_gc_policy_counters = NULL; 58 GCTaskManager* ParallelScavengeHeap::_gc_task_manager = NULL; 59 60 jint ParallelScavengeHeap::initialize() { 61 const size_t heap_size = _collector_policy->max_heap_byte_size(); 62 63 ReservedSpace heap_rs = Universe::reserve_heap(heap_size, _collector_policy->heap_alignment()); 64 65 os::trace_page_sizes("Heap", 66 _collector_policy->min_heap_byte_size(), 67 heap_size, 68 generation_alignment(), 69 heap_rs.base(), 70 heap_rs.size()); 71 72 initialize_reserved_region((HeapWord*)heap_rs.base(), (HeapWord*)(heap_rs.base() + heap_rs.size())); 73 74 PSCardTable* card_table = new PSCardTable(reserved_region()); 75 card_table->initialize(); 76 CardTableBarrierSet* const barrier_set = new CardTableBarrierSet(card_table); 77 barrier_set->initialize(); 78 BarrierSet::set_barrier_set(barrier_set); 79 80 // Make up the generations 81 // Calculate the maximum size that a generation can grow. This 82 // includes growth into the other generation. Note that the 83 // parameter _max_gen_size is kept as the maximum 84 // size of the generation as the boundaries currently stand. 85 // _max_gen_size is still used as that value. 86 double max_gc_pause_sec = ((double) MaxGCPauseMillis)/1000.0; 87 double max_gc_minor_pause_sec = ((double) MaxGCMinorPauseMillis)/1000.0; 88 89 _gens = new AdjoiningGenerations(heap_rs, _collector_policy, generation_alignment()); 90 91 _old_gen = _gens->old_gen(); 92 _young_gen = _gens->young_gen(); 93 94 const size_t eden_capacity = _young_gen->eden_space()->capacity_in_bytes(); 95 const size_t old_capacity = _old_gen->capacity_in_bytes(); 96 const size_t initial_promo_size = MIN2(eden_capacity, old_capacity); 97 _size_policy = 98 new PSAdaptiveSizePolicy(eden_capacity, 99 initial_promo_size, 100 young_gen()->to_space()->capacity_in_bytes(), 101 _collector_policy->gen_alignment(), 102 max_gc_pause_sec, 103 max_gc_minor_pause_sec, 104 GCTimeRatio 105 ); 106 107 assert(!UseAdaptiveGCBoundary || 108 (old_gen()->virtual_space()->high_boundary() == 109 young_gen()->virtual_space()->low_boundary()), 110 "Boundaries must meet"); 111 // initialize the policy counters - 2 collectors, 2 generations 112 _gc_policy_counters = 113 new PSGCAdaptivePolicyCounters("ParScav:MSC", 2, 2, _size_policy); 114 115 // Set up the GCTaskManager 116 _gc_task_manager = GCTaskManager::create(ParallelGCThreads); 117 118 if (UseParallelOldGC && !PSParallelCompact::initialize()) { 119 return JNI_ENOMEM; 120 } 121 122 return JNI_OK; 123 } 124 125 void ParallelScavengeHeap::initialize_serviceability() { 126 127 _eden_pool = new EdenMutableSpacePool(_young_gen, | 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 #include "precompiled.hpp" 26 #include "code/codeCache.hpp" 27 #include "gc/parallel/adjoiningGenerations.hpp" 28 #include "gc/parallel/adjoiningGenerationsForHeteroHeap.hpp" 29 #include "gc/parallel/adjoiningVirtualSpaces.hpp" 30 #include "gc/parallel/gcTaskManager.hpp" 31 #include "gc/parallel/generationSizer.hpp" 32 #include "gc/parallel/objectStartArray.inline.hpp" 33 #include "gc/parallel/parallelScavengeHeap.inline.hpp" 34 #include "gc/parallel/psAdaptiveSizePolicy.hpp" 35 #include "gc/parallel/psMarkSweepProxy.hpp" 36 #include "gc/parallel/psMemoryPool.hpp" 37 #include "gc/parallel/psParallelCompact.inline.hpp" 38 #include "gc/parallel/psPromotionManager.hpp" 39 #include "gc/parallel/psScavenge.hpp" 40 #include "gc/parallel/vmPSOperations.hpp" 41 #include "gc/shared/gcHeapSummary.hpp" 42 #include "gc/shared/gcLocker.hpp" 43 #include "gc/shared/gcWhen.hpp" 44 #include "logging/log.hpp" 45 #include "memory/metaspaceCounters.hpp" 46 #include "oops/oop.inline.hpp" 47 #include "runtime/handles.inline.hpp" 48 #include "runtime/java.hpp" 49 #include "runtime/vmThread.hpp" 50 #include "services/memoryManager.hpp" 51 #include "services/memTracker.hpp" 52 #include "utilities/macros.hpp" 53 #include "utilities/vmError.hpp" 54 55 PSYoungGen* ParallelScavengeHeap::_young_gen = NULL; 56 PSOldGen* ParallelScavengeHeap::_old_gen = NULL; 57 PSAdaptiveSizePolicy* ParallelScavengeHeap::_size_policy = NULL; 58 PSGCAdaptivePolicyCounters* ParallelScavengeHeap::_gc_policy_counters = NULL; 59 GCTaskManager* ParallelScavengeHeap::_gc_task_manager = NULL; 60 61 jint ParallelScavengeHeap::initialize() { 62 size_t heap_size = _collector_policy->max_heap_byte_size(); 63 64 if (AllocateOldGenAt != NULL && UseAdaptiveGCBoundary) { 65 heap_size = AdjoiningGenerationsForHeteroHeap::required_reserved_memory(_collector_policy); 66 } 67 68 ReservedSpace heap_rs = Universe::reserve_heap(heap_size, _collector_policy->heap_alignment()); 69 70 os::trace_page_sizes("Heap", 71 _collector_policy->min_heap_byte_size(), 72 heap_size, 73 generation_alignment(), 74 heap_rs.base(), 75 heap_rs.size()); 76 77 initialize_reserved_region((HeapWord*)heap_rs.base(), (HeapWord*)(heap_rs.base() + heap_rs.size())); 78 79 PSCardTable* card_table = new PSCardTable(reserved_region()); 80 card_table->initialize(); 81 CardTableBarrierSet* const barrier_set = new CardTableBarrierSet(card_table); 82 barrier_set->initialize(); 83 BarrierSet::set_barrier_set(barrier_set); 84 85 // Make up the generations 86 // Calculate the maximum size that a generation can grow. This 87 // includes growth into the other generation. Note that the 88 // parameter _max_gen_size is kept as the maximum 89 // size of the generation as the boundaries currently stand. 90 // _max_gen_size is still used as that value. 91 double max_gc_pause_sec = ((double) MaxGCPauseMillis)/1000.0; 92 double max_gc_minor_pause_sec = ((double) MaxGCMinorPauseMillis)/1000.0; 93 94 if (AllocateOldGenAt != NULL && UseAdaptiveGCBoundary) { 95 _gens = new AdjoiningGenerationsForHeteroHeap(heap_rs, _collector_policy->max_heap_byte_size() /* total_size_limit */, 96 _collector_policy, generation_alignment()); 97 } 98 else { 99 _gens = new AdjoiningGenerations(heap_rs, _collector_policy, generation_alignment()); 100 } 101 102 _old_gen = _gens->old_gen(); 103 _young_gen = _gens->young_gen(); 104 105 const size_t eden_capacity = _young_gen->eden_space()->capacity_in_bytes(); 106 const size_t old_capacity = _old_gen->capacity_in_bytes(); 107 const size_t initial_promo_size = MIN2(eden_capacity, old_capacity); 108 _size_policy = 109 new PSAdaptiveSizePolicy(eden_capacity, 110 initial_promo_size, 111 young_gen()->to_space()->capacity_in_bytes(), 112 _collector_policy->gen_alignment(), 113 max_gc_pause_sec, 114 max_gc_minor_pause_sec, 115 GCTimeRatio 116 ); 117 118 assert(AllocateOldGenAt != NULL || !UseAdaptiveGCBoundary || 119 (old_gen()->virtual_space()->high_boundary() == 120 young_gen()->virtual_space()->low_boundary()), 121 "Boundaries must meet"); 122 // initialize the policy counters - 2 collectors, 2 generations 123 _gc_policy_counters = 124 new PSGCAdaptivePolicyCounters("ParScav:MSC", 2, 2, _size_policy); 125 126 // Set up the GCTaskManager 127 _gc_task_manager = GCTaskManager::create(ParallelGCThreads); 128 129 if (UseParallelOldGC && !PSParallelCompact::initialize()) { 130 return JNI_ENOMEM; 131 } 132 133 return JNI_OK; 134 } 135 136 void ParallelScavengeHeap::initialize_serviceability() { 137 138 _eden_pool = new EdenMutableSpacePool(_young_gen, |