jint ParallelScavengeHeap::initialize() { CollectedHeap::pre_initialize(); const size_t heap_size = _collector_policy->max_heap_byte_size(); ReservedSpace heap_rs = Universe::reserve_heap(heap_size, _collector_policy->heap_alignment()); os::trace_page_sizes("ps main", _collector_policy->min_heap_byte_size(), heap_size, generation_alignment(), heap_rs.base(), heap_rs.size()); initialize_reserved_region((HeapWord*)heap_rs.base(), (HeapWord*)(heap_rs.base() + heap_rs.size())); CardTableExtension* const barrier_set = new CardTableExtension(reserved_region()); barrier_set->initialize(); set_barrier_set(barrier_set); // Make up the generations // Calculate the maximum size that a generation can grow. This // includes growth into the other generation. Note that the // parameter _max_gen_size is kept as the maximum // size of the generation as the boundaries currently stand. // _max_gen_size is still used as that value. double max_gc_pause_sec = ((double) MaxGCPauseMillis)/1000.0; double max_gc_minor_pause_sec = ((double) MaxGCMinorPauseMillis)/1000.0; _gens = new AdjoiningGenerations(heap_rs, _collector_policy, generation_alignment()); _old_gen = _gens->old_gen(); _young_gen = _gens->young_gen(); const size_t eden_capacity = _young_gen->eden_space()->capacity_in_bytes(); const size_t old_capacity = _old_gen->capacity_in_bytes(); const size_t initial_promo_size = MIN2(eden_capacity, old_capacity); _size_policy = new PSAdaptiveSizePolicy(eden_capacity, initial_promo_size, young_gen()->to_space()->capacity_in_bytes(), _collector_policy->gen_alignment(), max_gc_pause_sec, max_gc_minor_pause_sec, GCTimeRatio ); assert(!UseAdaptiveGCBoundary || (old_gen()->virtual_space()->high_boundary() == young_gen()->virtual_space()->low_boundary()), "Boundaries must meet"); // initialize the policy counters - 2 collectors, 3 generations _gc_policy_counters = new PSGCAdaptivePolicyCounters("ParScav:MSC", 2, 3, _size_policy); // Set up the GCTaskManager _gc_task_manager = GCTaskManager::create(ParallelGCThreads); if (UseParallelOldGC && !PSParallelCompact::initialize()) { return JNI_ENOMEM; } #ifdef PROFILE_OBJECT_INFO if (ProfileObjectInfo) { AllocPointInfoTable *apit = new AllocPointInfoTable(AllocPointInfoTable::apit_size); guarantee(!apit->allocation_failed(), "apm allocation failed"); Universe::set_alloc_point_info_table(apit); PersistentObjectInfoTable *poit = new PersistentObjectInfoTable( PersistentObjectInfoTable::oit_size, _perm_gen->object_space()->used_region().start()); guarantee(!poit->allocation_failed(), "poit allocation failed"); Universe::set_persistent_object_info_table(poit); } #endif #ifdef PROFILE_OBJECT_ADDRESS_INFO if (ProfileObjectAddressInfo) { unsigned int oait_size = OAIT_SIZE; unsigned int kt_size = KLASS_TABLE_SIZE; KlassRecordTable *krt = new KlassRecordTable(kt_size); guarantee(!krt->allocation_failed(), "krt allocation failed"); Universe::set_klass_record_table(krt); AllocPointInfoTable *apit = new AllocPointInfoTable(AllocPointInfoTable::apit_size); guarantee(!apit->allocation_failed(), "apit allocation failed"); Universe::set_alloc_point_info_table(apit); ObjectAddressInfoTable *oait = new ObjectAddressInfoTable(oait_size, krt, apit); guarantee(!oait->allocation_failed(), "oait allocation failed"); Universe::set_object_address_info_table(oait); ObjectAddressInfoTable *alt_oait = new ObjectAddressInfoTable(oait_size, krt, apit); guarantee(!oait->allocation_failed(), "oait allocation failed"); Universe::set_alt_oait(alt_oait); } #endif return JNI_OK; }
jint ParallelScavengeHeap::initialize() { CollectedHeap::pre_initialize(); const size_t heap_size = _collector_policy->max_heap_byte_size(); ReservedSpace heap_rs = Universe::reserve_heap(heap_size, _collector_policy->heap_alignment()); os::trace_page_sizes("Heap", _collector_policy->min_heap_byte_size(), heap_size, generation_alignment(), heap_rs.base(), heap_rs.size()); initialize_reserved_region((HeapWord*)heap_rs.base(), (HeapWord*)(heap_rs.base() + heap_rs.size())); CardTableExtension* const barrier_set = new CardTableExtension(reserved_region()); barrier_set->initialize(); set_barrier_set(barrier_set); // Make up the generations // Calculate the maximum size that a generation can grow. This // includes growth into the other generation. Note that the // parameter _max_gen_size is kept as the maximum // size of the generation as the boundaries currently stand. // _max_gen_size is still used as that value. double max_gc_pause_sec = ((double) MaxGCPauseMillis)/1000.0; double max_gc_minor_pause_sec = ((double) MaxGCMinorPauseMillis)/1000.0; _gens = new AdjoiningGenerations(heap_rs, _collector_policy, generation_alignment()); _old_gen = _gens->old_gen(); _young_gen = _gens->young_gen(); const size_t eden_capacity = _young_gen->eden_space()->capacity_in_bytes(); const size_t old_capacity = _old_gen->capacity_in_bytes(); const size_t initial_promo_size = MIN2(eden_capacity, old_capacity); _size_policy = new PSAdaptiveSizePolicy(eden_capacity, initial_promo_size, young_gen()->to_space()->capacity_in_bytes(), _collector_policy->gen_alignment(), max_gc_pause_sec, max_gc_minor_pause_sec, GCTimeRatio ); assert(!UseAdaptiveGCBoundary || (old_gen()->virtual_space()->high_boundary() == young_gen()->virtual_space()->low_boundary()), "Boundaries must meet"); // initialize the policy counters - 2 collectors, 3 generations _gc_policy_counters = new PSGCAdaptivePolicyCounters("ParScav:MSC", 2, 3, _size_policy); // Set up the GCTaskManager _gc_task_manager = GCTaskManager::create(ParallelGCThreads); if (UseParallelOldGC && !PSParallelCompact::initialize()) { return JNI_ENOMEM; } return JNI_OK; }
jint ParallelScavengeHeap::initialize() { // Cannot be initialized until after the flags are parsed GenerationSizer flag_parser; size_t max_young_size = flag_parser.max_young_gen_size(); size_t max_old_size = flag_parser.max_old_gen_size(); if (UseMPSS && max_young_size + max_old_size >= LargePageHeapSizeThreshold) { set_generation_alignment(LargePageSizeInBytes); } const size_t alignment = generation_alignment(); // Check alignments // NEEDS_CLEANUP The default TwoGenerationCollectorPolicy uses // NewRatio; it should check UseAdaptiveSizePolicy. Changes from // generationSizer could move to the common code. size_t min_young_size = align_size_up(flag_parser.min_young_gen_size(), alignment); size_t young_size = align_size_up(flag_parser.young_gen_size(), alignment); max_young_size = align_size_up(max_young_size, alignment); size_t min_old_size = align_size_up(flag_parser.min_old_gen_size(), alignment); size_t old_size = align_size_up(flag_parser.old_gen_size(), alignment); old_size = MAX2(old_size, min_old_size); max_old_size = align_size_up(max_old_size, alignment); size_t perm_size = align_size_up(flag_parser.perm_gen_size(), alignment); size_t max_perm_size = align_size_up(flag_parser.max_perm_gen_size(), alignment); // Calculate the total size. size_t total_reserved = max_young_size + max_old_size + max_perm_size; if (UseISM || UsePermISM) { total_reserved = round_to(total_reserved, LargePageSizeInBytes); } ReservedSpace heap_rs(total_reserved, alignment, UseISM || UsePermISM); if (!heap_rs.is_reserved()) { vm_shutdown_during_initialization( "Could not reserve enough space for object heap"); return JNI_ENOMEM; } _reserved_byte_size = heap_rs.size(); _reserved = MemRegion((HeapWord*)heap_rs.base(), (HeapWord*)(heap_rs.base() + heap_rs.size())); HeapWord* boundary = (HeapWord*)(heap_rs.base() + max_young_size); CardTableExtension* card_table_barrier_set = new CardTableExtension(_reserved, 3); _barrier_set = card_table_barrier_set; oopDesc::set_bs(_barrier_set); if (_barrier_set == NULL) { vm_shutdown_during_initialization( "Could not reserve enough space for barrier set"); return JNI_ENOMEM; } // Initial young gen size is 4 Mb size_t init_young_size = align_size_up(4 * M, alignment); init_young_size = MAX2(MIN2(init_young_size, max_young_size), young_size); // Divide up the reserved space: perm, old, young ReservedSpace perm_rs = heap_rs.first_part(max_perm_size); ReservedSpace old_young_rs = heap_rs.last_part(max_perm_size); ReservedSpace old_rs = old_young_rs.first_part(max_old_size); heap_rs = old_young_rs.last_part(max_old_size); ReservedSpace young_rs = heap_rs.first_part(max_young_size); assert(young_rs.size() == heap_rs.size(), "Didn't reserve all of the heap"); // Make up the generations // Calculate the maximum size that a generation can grow. This // includes growth into the other generation. Note that the // parameter _max_gen_size is kept as the maximum // size of the generation as the boundaries currently stand. // _max_gen_size is still used as that value. double max_gc_pause_sec = ((double) MaxGCPauseMillis)/1000.0; double max_gc_minor_pause_sec = ((double) MaxGCMinorPauseMillis)/1000.0; // Regarding SEPARATE_PATHS. If SEPARATE_PATHS is defined, then // the generations are created without the use of AdjoiningGenerations // in the case where boundary moving is not an option. This is // being kept until the code review in case there is some desire // to keep the new code out of the path of the previous code. // One effect of using AdjoiningGenerations for both cases is that // is that the generations in AdjoiningGenerations need to be // PSOldGen and PSYoungGen as opposed to ASPSOldGen and ASPSYoungGen. // This latter means that methods such as available_for_expansion() // need to be defined in PSOldGen. #undef SEPARATE_PATHS #ifdef SEPARATE_PATHS if (UseAdaptiveSizePolicy && UseAdaptiveGCBoundary) { #endif _gens = new AdjoiningGenerations(old_young_rs, old_size, min_old_size, max_old_size, init_young_size, min_young_size, max_young_size, alignment); _old_gen = _gens->old_gen(); _young_gen = _gens->young_gen(); _size_policy = new PSAdaptiveSizePolicy(young_gen()->eden_space()->capacity_in_bytes(), old_gen()->capacity_in_bytes(), young_gen()->to_space()->capacity_in_bytes(), generation_alignment(), intra_generation_alignment(), max_gc_pause_sec, max_gc_minor_pause_sec, GCTimeRatio ); #ifdef SEPARATE_PATHS } else { // Same as for case where boundary does not move. size_t old_size_limit, young_size_limit; old_size_limit = max_old_size; young_size_limit = max_young_size; _young_gen = new PSYoungGen(init_young_size, min_young_size, max_young_size); _old_gen = new PSOldGen(old_size, min_old_size, max_old_size, "old", 1); _gens = 0; _young_gen->initialize(young_rs, alignment); _old_gen->initialize(old_rs, alignment, "old", 1); _size_policy = new PSAdaptiveSizePolicy(young_gen()->eden_space()->capacity_in_bytes(), old_gen()->capacity_in_bytes(), young_gen()->to_space()->capacity_in_bytes(), generation_alignment(), intra_generation_alignment(), max_gc_pause_sec, max_gc_minor_pause_sec, GCTimeRatio ); } #endif _perm_gen = new PSPermGen(perm_rs, alignment, perm_size, perm_size, max_perm_size, "perm", 2); assert(!UseAdaptiveGCBoundary || (old_gen()->virtual_space()->high_boundary() == young_gen()->virtual_space()->low_boundary()), "Boundaries must meet"); // initialize the policy counters - 2 collectors, 3 generations _gc_policy_counters = new PSGCAdaptivePolicyCounters("ParScav:MSC", 2, 3, _size_policy); _psh = this; return JNI_OK; }