2057 TraceMemoryManagerStats tms(true /* Full GC */,gc_cause); 2058 2059 if (TraceOldGenTime) accumulated_time()->start(); 2060 2061 // Let the size policy know we're starting 2062 size_policy->major_collection_begin(); 2063 2064 CodeCache::gc_prologue(); 2065 2066 COMPILER2_PRESENT(DerivedPointerTable::clear()); 2067 2068 ref_processor()->enable_discovery(); 2069 ref_processor()->setup_policy(maximum_heap_compaction); 2070 2071 bool marked_for_unloading = false; 2072 2073 marking_start.update(); 2074 marking_phase(vmthread_cm, maximum_heap_compaction, &_gc_tracer); 2075 2076 bool max_on_system_gc = UseMaximumCompactionOnSystemGC 2077 && gc_cause == GCCause::_java_lang_system_gc; 2078 summary_phase(vmthread_cm, maximum_heap_compaction || max_on_system_gc); 2079 2080 COMPILER2_PRESENT(assert(DerivedPointerTable::is_active(), "Sanity")); 2081 COMPILER2_PRESENT(DerivedPointerTable::set_active(false)); 2082 2083 // adjust_roots() updates Universe::_intArrayKlassObj which is 2084 // needed by the compaction for filling holes in the dense prefix. 2085 adjust_roots(); 2086 2087 compaction_start.update(); 2088 compact(); 2089 2090 // Reset the mark bitmap, summary data, and do other bookkeeping. Must be 2091 // done before resizing. 2092 post_compact(); 2093 2094 // Let the size policy know we're done 2095 size_policy->major_collection_end(old_gen->used_in_bytes(), gc_cause); 2096 2097 if (UseAdaptiveSizePolicy) { 2098 if (PrintAdaptiveSizePolicy) { 2099 gclog_or_tty->print("AdaptiveSizeStart: "); 2100 gclog_or_tty->stamp(); 2101 gclog_or_tty->print_cr(" collection: %d ", 2102 heap->total_collections()); 2103 if (Verbose) { 2104 gclog_or_tty->print("old_gen_capacity: " SIZE_FORMAT 2105 " young_gen_capacity: " SIZE_FORMAT, 2106 old_gen->capacity_in_bytes(), young_gen->capacity_in_bytes()); 2107 } 2108 } 2109 2110 // Don't check if the size_policy is ready here. Let 2111 // the size_policy check that internally. 2112 if (UseAdaptiveGenerationSizePolicyAtMajorCollection && 2113 ((gc_cause != GCCause::_java_lang_system_gc) || 2114 UseAdaptiveSizePolicyWithSystemGC)) { 2115 // Swap the survivor spaces if from_space is empty. The 2116 // resize_young_gen() called below is normally used after 2117 // a successful young GC and swapping of survivor spaces; 2118 // otherwise, it will fail to resize the young gen with 2119 // the current implementation. 2120 if (young_gen->from_space()->is_empty()) { 2121 young_gen->from_space()->clear(SpaceDecorator::Mangle); 2122 young_gen->swap_spaces(); 2123 } 2124 2125 // Calculate optimal free space amounts 2126 assert(young_gen->max_size() > 2127 young_gen->from_space()->capacity_in_bytes() + 2128 young_gen->to_space()->capacity_in_bytes(), 2129 "Sizes of space in young gen are out-of-bounds"); 2130 2131 size_t young_live = young_gen->used_in_bytes(); 2132 size_t eden_live = young_gen->eden_space()->used_in_bytes(); 2133 size_t old_live = old_gen->used_in_bytes(); | 2057 TraceMemoryManagerStats tms(true /* Full GC */,gc_cause); 2058 2059 if (TraceOldGenTime) accumulated_time()->start(); 2060 2061 // Let the size policy know we're starting 2062 size_policy->major_collection_begin(); 2063 2064 CodeCache::gc_prologue(); 2065 2066 COMPILER2_PRESENT(DerivedPointerTable::clear()); 2067 2068 ref_processor()->enable_discovery(); 2069 ref_processor()->setup_policy(maximum_heap_compaction); 2070 2071 bool marked_for_unloading = false; 2072 2073 marking_start.update(); 2074 marking_phase(vmthread_cm, maximum_heap_compaction, &_gc_tracer); 2075 2076 bool max_on_system_gc = UseMaximumCompactionOnSystemGC 2077 && GCCause::is_user_requested_gc(gc_cause); 2078 summary_phase(vmthread_cm, maximum_heap_compaction || max_on_system_gc); 2079 2080 COMPILER2_PRESENT(assert(DerivedPointerTable::is_active(), "Sanity")); 2081 COMPILER2_PRESENT(DerivedPointerTable::set_active(false)); 2082 2083 // adjust_roots() updates Universe::_intArrayKlassObj which is 2084 // needed by the compaction for filling holes in the dense prefix. 2085 adjust_roots(); 2086 2087 compaction_start.update(); 2088 compact(); 2089 2090 // Reset the mark bitmap, summary data, and do other bookkeeping. Must be 2091 // done before resizing. 2092 post_compact(); 2093 2094 // Let the size policy know we're done 2095 size_policy->major_collection_end(old_gen->used_in_bytes(), gc_cause); 2096 2097 if (UseAdaptiveSizePolicy) { 2098 if (PrintAdaptiveSizePolicy) { 2099 gclog_or_tty->print("AdaptiveSizeStart: "); 2100 gclog_or_tty->stamp(); 2101 gclog_or_tty->print_cr(" collection: %d ", 2102 heap->total_collections()); 2103 if (Verbose) { 2104 gclog_or_tty->print("old_gen_capacity: " SIZE_FORMAT 2105 " young_gen_capacity: " SIZE_FORMAT, 2106 old_gen->capacity_in_bytes(), young_gen->capacity_in_bytes()); 2107 } 2108 } 2109 2110 // Don't check if the size_policy is ready here. Let 2111 // the size_policy check that internally. 2112 if (UseAdaptiveGenerationSizePolicyAtMajorCollection && 2113 (!GCCause::is_user_requested_gc(gc_cause) || 2114 UseAdaptiveSizePolicyWithSystemGC)) { 2115 // Swap the survivor spaces if from_space is empty. The 2116 // resize_young_gen() called below is normally used after 2117 // a successful young GC and swapping of survivor spaces; 2118 // otherwise, it will fail to resize the young gen with 2119 // the current implementation. 2120 if (young_gen->from_space()->is_empty()) { 2121 young_gen->from_space()->clear(SpaceDecorator::Mangle); 2122 young_gen->swap_spaces(); 2123 } 2124 2125 // Calculate optimal free space amounts 2126 assert(young_gen->max_size() > 2127 young_gen->from_space()->capacity_in_bytes() + 2128 young_gen->to_space()->capacity_in_bytes(), 2129 "Sizes of space in young gen are out-of-bounds"); 2130 2131 size_t young_live = young_gen->used_in_bytes(); 2132 size_t eden_live = young_gen->eden_space()->used_in_bytes(); 2133 size_t old_live = old_gen->used_in_bytes(); |