1 /** 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #include "runtime/mem/gc/gc_settings.h" 17 18 #include "runtime/include/runtime_options.h" 19 #include "libpandabase/globals.h" 20 21 namespace panda::mem { 22 GCSettings(const RuntimeOptions & options,panda_file::SourceLang lang)23GCSettings::GCSettings(const RuntimeOptions &options, panda_file::SourceLang lang) 24 { 25 auto runtime_lang = plugins::LangToRuntimeType(lang); 26 is_dump_heap_ = options.IsGcDumpHeap(runtime_lang); 27 is_concurrency_enabled_ = options.IsConcurrentGcEnabled(runtime_lang); 28 is_gc_enable_tracing_ = options.IsGcEnableTracing(runtime_lang); 29 run_gc_in_place_ = options.IsRunGcInPlace(runtime_lang); 30 native_gc_trigger_type_ = NativeGcTriggerTypeFromString(options.GetNativeGcTriggerType(runtime_lang)); 31 enable_fast_heap_verifier_ = options.IsEnableFastHeapVerifier(runtime_lang); 32 pre_gc_heap_verification_ = options.IsPreGcHeapVerifyEnabled(runtime_lang); 33 into_gc_heap_verification_ = options.IsIntoGcHeapVerifyEnabled(runtime_lang); 34 post_gc_heap_verification_ = options.IsPostGcHeapVerifyEnabled(runtime_lang); 35 fail_on_heap_verification_ = options.IsFailOnHeapVerification(runtime_lang); 36 g1_region_garbage_rate_threshold_ = options.GetG1RegionGarbageRateThreshold() / PERCENT_100_D; 37 g1_promotion_region_alive_rate_ = options.GetG1PromotionRegionAliveRate(); 38 g1_track_freed_objects_ = options.IsG1TrackFreedObjects(); 39 gc_workers_count_ = options.GetGcWorkersCount(); 40 gc_root_marking_stack_max_size_ = options.GetGcRootMarkingStackMaxSize(); 41 gc_workers_marking_stack_max_size_ = options.GetGcWorkersMarkingStackMaxSize(); 42 young_space_size_ = options.GetYoungSpaceSize(); 43 log_detailed_gc_info_enabled_ = options.IsLogDetailedGcInfoEnabled(); 44 parallel_marking_enabled_ = options.IsGcParallelMarkingEnabled() && (options.GetGcWorkersCount() != 0); 45 parallel_compacting_enabled_ = options.IsGcParallelCompactingEnabled() && (options.GetGcWorkersCount() != 0); 46 g1_enable_concurrent_update_remset_ = options.IsG1EnableConcurrentUpdateRemset(); 47 g1_min_concurrent_cards_to_process_ = options.GetG1MinConcurrentCardsToProcess(); 48 } 49 IsGcEnableTracing() const50bool GCSettings::IsGcEnableTracing() const 51 { 52 return is_gc_enable_tracing_; 53 } 54 GetNativeGcTriggerType() const55NativeGcTriggerType GCSettings::GetNativeGcTriggerType() const 56 { 57 return native_gc_trigger_type_; 58 } 59 IsDumpHeap() const60bool GCSettings::IsDumpHeap() const 61 { 62 return is_dump_heap_; 63 } 64 IsConcurrencyEnabled() const65bool GCSettings::IsConcurrencyEnabled() const 66 { 67 return is_concurrency_enabled_; 68 } 69 RunGCInPlace() const70bool GCSettings::RunGCInPlace() const 71 { 72 return run_gc_in_place_; 73 } 74 EnableFastHeapVerifier() const75bool GCSettings::EnableFastHeapVerifier() const 76 { 77 return enable_fast_heap_verifier_; 78 } 79 PreGCHeapVerification() const80bool GCSettings::PreGCHeapVerification() const 81 { 82 return pre_gc_heap_verification_; 83 } 84 IntoGCHeapVerification() const85bool GCSettings::IntoGCHeapVerification() const 86 { 87 return into_gc_heap_verification_; 88 } 89 PostGCHeapVerification() const90bool GCSettings::PostGCHeapVerification() const 91 { 92 return post_gc_heap_verification_; 93 } 94 FailOnHeapVerification() const95bool GCSettings::FailOnHeapVerification() const 96 { 97 return fail_on_heap_verification_; 98 } 99 G1RegionGarbageRateThreshold() const100double GCSettings::G1RegionGarbageRateThreshold() const 101 { 102 return g1_region_garbage_rate_threshold_; 103 } 104 G1PromotionRegionAliveRate() const105double GCSettings::G1PromotionRegionAliveRate() const 106 { 107 return g1_promotion_region_alive_rate_; 108 } 109 G1TrackFreedObjects() const110bool GCSettings::G1TrackFreedObjects() const 111 { 112 return g1_track_freed_objects_; 113 } 114 GCWorkersCount() const115size_t GCSettings::GCWorkersCount() const 116 { 117 return gc_workers_count_; 118 } 119 SetGCWorkersCount(size_t value)120void GCSettings::SetGCWorkersCount(size_t value) 121 { 122 gc_workers_count_ = value; 123 } 124 GCRootMarkingStackMaxSize() const125size_t GCSettings::GCRootMarkingStackMaxSize() const 126 { 127 return gc_root_marking_stack_max_size_; 128 } 129 GCWorkersMarkingStackMaxSize() const130size_t GCSettings::GCWorkersMarkingStackMaxSize() const 131 { 132 return gc_workers_marking_stack_max_size_; 133 } 134 YoungSpaceSize() const135uint64_t GCSettings::YoungSpaceSize() const 136 { 137 return young_space_size_; 138 } 139 LogDetailedGCInfoEnabled() const140bool GCSettings::LogDetailedGCInfoEnabled() const 141 { 142 return log_detailed_gc_info_enabled_; 143 } 144 ParallelMarkingEnabled() const145bool GCSettings::ParallelMarkingEnabled() const 146 { 147 return parallel_marking_enabled_; 148 } 149 SetParallelMarkingEnabled(bool value)150void GCSettings::SetParallelMarkingEnabled(bool value) 151 { 152 parallel_marking_enabled_ = value; 153 } 154 ParallelCompactingEnabled() const155bool GCSettings::ParallelCompactingEnabled() const 156 { 157 return parallel_compacting_enabled_; 158 } 159 SetParallelCompactingEnabled(bool value)160void GCSettings::SetParallelCompactingEnabled(bool value) 161 { 162 parallel_compacting_enabled_ = value; 163 } 164 G1EnableConcurrentUpdateRemset() const165bool GCSettings::G1EnableConcurrentUpdateRemset() const 166 { 167 return g1_enable_concurrent_update_remset_; 168 } 169 G1MinConcurrentCardsToProcess() const170size_t GCSettings::G1MinConcurrentCardsToProcess() const 171 { 172 return g1_min_concurrent_cards_to_process_; 173 } 174 175 } // namespace panda::mem