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