1*795d594fSAndroid Build Coastguard Worker /* 2*795d594fSAndroid Build Coastguard Worker * Copyright (C) 2016 The Android Open Source Project 3*795d594fSAndroid Build Coastguard Worker * 4*795d594fSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License"); 5*795d594fSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License. 6*795d594fSAndroid Build Coastguard Worker * You may obtain a copy of the License at 7*795d594fSAndroid Build Coastguard Worker * 8*795d594fSAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0 9*795d594fSAndroid Build Coastguard Worker * * See the License for the specific language governing permissions and 10*795d594fSAndroid Build Coastguard Worker * limitations under the License. 11*795d594fSAndroid Build Coastguard Worker */ 12*795d594fSAndroid Build Coastguard Worker 13*795d594fSAndroid Build Coastguard Worker #ifndef ART_RUNTIME_JIT_PROFILE_SAVER_OPTIONS_H_ 14*795d594fSAndroid Build Coastguard Worker #define ART_RUNTIME_JIT_PROFILE_SAVER_OPTIONS_H_ 15*795d594fSAndroid Build Coastguard Worker 16*795d594fSAndroid Build Coastguard Worker #include <cstdint> 17*795d594fSAndroid Build Coastguard Worker #include <ostream> 18*795d594fSAndroid Build Coastguard Worker #include <string> 19*795d594fSAndroid Build Coastguard Worker 20*795d594fSAndroid Build Coastguard Worker namespace art HIDDEN { 21*795d594fSAndroid Build Coastguard Worker 22*795d594fSAndroid Build Coastguard Worker struct ProfileSaverOptions { 23*795d594fSAndroid Build Coastguard Worker public: 24*795d594fSAndroid Build Coastguard Worker static constexpr uint32_t kMinSavePeriodMs = 40 * 1000; // 40 seconds 25*795d594fSAndroid Build Coastguard Worker // Default value for the min save period on first use, indicating that the 26*795d594fSAndroid Build Coastguard Worker // period is not configured. 27*795d594fSAndroid Build Coastguard Worker static constexpr uint32_t kMinFirstSaveMsNotSet = 0; 28*795d594fSAndroid Build Coastguard Worker static constexpr uint32_t kMinMethodsToSave = 10; 29*795d594fSAndroid Build Coastguard Worker static constexpr uint32_t kMinClassesToSave = 10; 30*795d594fSAndroid Build Coastguard Worker static constexpr uint32_t kMinNotificationBeforeWake = 10; 31*795d594fSAndroid Build Coastguard Worker static constexpr uint32_t kMaxNotificationBeforeWake = 50; 32*795d594fSAndroid Build Coastguard Worker static constexpr uint16_t kInlineCacheThreshold = 4000; 33*795d594fSAndroid Build Coastguard Worker ProfileSaverOptionsProfileSaverOptions34*795d594fSAndroid Build Coastguard Worker ProfileSaverOptions() 35*795d594fSAndroid Build Coastguard Worker : enabled_(false), 36*795d594fSAndroid Build Coastguard Worker min_save_period_ms_(kMinSavePeriodMs), 37*795d594fSAndroid Build Coastguard Worker min_first_save_ms_(kMinFirstSaveMsNotSet), 38*795d594fSAndroid Build Coastguard Worker min_methods_to_save_(kMinMethodsToSave), 39*795d594fSAndroid Build Coastguard Worker min_classes_to_save_(kMinClassesToSave), 40*795d594fSAndroid Build Coastguard Worker min_notification_before_wake_(kMinNotificationBeforeWake), 41*795d594fSAndroid Build Coastguard Worker max_notification_before_wake_(kMaxNotificationBeforeWake), 42*795d594fSAndroid Build Coastguard Worker inline_cache_threshold_(kInlineCacheThreshold), 43*795d594fSAndroid Build Coastguard Worker profile_path_(""), 44*795d594fSAndroid Build Coastguard Worker profile_boot_class_path_(false), 45*795d594fSAndroid Build Coastguard Worker profile_aot_code_(false), 46*795d594fSAndroid Build Coastguard Worker wait_for_jit_notifications_to_save_(true) {} 47*795d594fSAndroid Build Coastguard Worker 48*795d594fSAndroid Build Coastguard Worker ProfileSaverOptions(bool enabled, 49*795d594fSAndroid Build Coastguard Worker uint32_t min_save_period_ms, 50*795d594fSAndroid Build Coastguard Worker uint32_t min_first_save_ms, 51*795d594fSAndroid Build Coastguard Worker uint32_t min_methods_to_save, 52*795d594fSAndroid Build Coastguard Worker uint32_t min_classes_to_save, 53*795d594fSAndroid Build Coastguard Worker uint32_t min_notification_before_wake, 54*795d594fSAndroid Build Coastguard Worker uint32_t max_notification_before_wake, 55*795d594fSAndroid Build Coastguard Worker uint16_t inline_cache_threshold, 56*795d594fSAndroid Build Coastguard Worker const std::string& profile_path, 57*795d594fSAndroid Build Coastguard Worker bool profile_boot_class_path, 58*795d594fSAndroid Build Coastguard Worker bool profile_aot_code = false, 59*795d594fSAndroid Build Coastguard Worker bool wait_for_jit_notifications_to_save = true) enabled_ProfileSaverOptions60*795d594fSAndroid Build Coastguard Worker : enabled_(enabled), 61*795d594fSAndroid Build Coastguard Worker min_save_period_ms_(min_save_period_ms), 62*795d594fSAndroid Build Coastguard Worker min_first_save_ms_(min_first_save_ms), 63*795d594fSAndroid Build Coastguard Worker min_methods_to_save_(min_methods_to_save), 64*795d594fSAndroid Build Coastguard Worker min_classes_to_save_(min_classes_to_save), 65*795d594fSAndroid Build Coastguard Worker min_notification_before_wake_(min_notification_before_wake), 66*795d594fSAndroid Build Coastguard Worker max_notification_before_wake_(max_notification_before_wake), 67*795d594fSAndroid Build Coastguard Worker inline_cache_threshold_(inline_cache_threshold), 68*795d594fSAndroid Build Coastguard Worker profile_path_(profile_path), 69*795d594fSAndroid Build Coastguard Worker profile_boot_class_path_(profile_boot_class_path), 70*795d594fSAndroid Build Coastguard Worker profile_aot_code_(profile_aot_code), 71*795d594fSAndroid Build Coastguard Worker wait_for_jit_notifications_to_save_(wait_for_jit_notifications_to_save) {} 72*795d594fSAndroid Build Coastguard Worker IsEnabledProfileSaverOptions73*795d594fSAndroid Build Coastguard Worker bool IsEnabled() const { 74*795d594fSAndroid Build Coastguard Worker return enabled_; 75*795d594fSAndroid Build Coastguard Worker } SetEnabledProfileSaverOptions76*795d594fSAndroid Build Coastguard Worker void SetEnabled(bool enabled) { 77*795d594fSAndroid Build Coastguard Worker enabled_ = enabled; 78*795d594fSAndroid Build Coastguard Worker } 79*795d594fSAndroid Build Coastguard Worker GetMinSavePeriodMsProfileSaverOptions80*795d594fSAndroid Build Coastguard Worker uint32_t GetMinSavePeriodMs() const { 81*795d594fSAndroid Build Coastguard Worker return min_save_period_ms_; 82*795d594fSAndroid Build Coastguard Worker } GetMinFirstSaveMsProfileSaverOptions83*795d594fSAndroid Build Coastguard Worker uint32_t GetMinFirstSaveMs() const { 84*795d594fSAndroid Build Coastguard Worker return min_first_save_ms_; 85*795d594fSAndroid Build Coastguard Worker } GetMinMethodsToSaveProfileSaverOptions86*795d594fSAndroid Build Coastguard Worker uint32_t GetMinMethodsToSave() const { 87*795d594fSAndroid Build Coastguard Worker return min_methods_to_save_; 88*795d594fSAndroid Build Coastguard Worker } GetMinClassesToSaveProfileSaverOptions89*795d594fSAndroid Build Coastguard Worker uint32_t GetMinClassesToSave() const { 90*795d594fSAndroid Build Coastguard Worker return min_classes_to_save_; 91*795d594fSAndroid Build Coastguard Worker } GetMinNotificationBeforeWakeProfileSaverOptions92*795d594fSAndroid Build Coastguard Worker uint32_t GetMinNotificationBeforeWake() const { 93*795d594fSAndroid Build Coastguard Worker return min_notification_before_wake_; 94*795d594fSAndroid Build Coastguard Worker } GetMaxNotificationBeforeWakeProfileSaverOptions95*795d594fSAndroid Build Coastguard Worker uint32_t GetMaxNotificationBeforeWake() const { 96*795d594fSAndroid Build Coastguard Worker return max_notification_before_wake_; 97*795d594fSAndroid Build Coastguard Worker } GetInlineCacheThresholdProfileSaverOptions98*795d594fSAndroid Build Coastguard Worker uint16_t GetInlineCacheThreshold() const { 99*795d594fSAndroid Build Coastguard Worker return inline_cache_threshold_; 100*795d594fSAndroid Build Coastguard Worker } GetProfilePathProfileSaverOptions101*795d594fSAndroid Build Coastguard Worker std::string GetProfilePath() const { 102*795d594fSAndroid Build Coastguard Worker return profile_path_; 103*795d594fSAndroid Build Coastguard Worker } GetProfileBootClassPathProfileSaverOptions104*795d594fSAndroid Build Coastguard Worker bool GetProfileBootClassPath() const { 105*795d594fSAndroid Build Coastguard Worker return profile_boot_class_path_; 106*795d594fSAndroid Build Coastguard Worker } GetProfileAOTCodeProfileSaverOptions107*795d594fSAndroid Build Coastguard Worker bool GetProfileAOTCode() const { 108*795d594fSAndroid Build Coastguard Worker return profile_aot_code_; 109*795d594fSAndroid Build Coastguard Worker } GetWaitForJitNotificationsToSaveProfileSaverOptions110*795d594fSAndroid Build Coastguard Worker bool GetWaitForJitNotificationsToSave() const { 111*795d594fSAndroid Build Coastguard Worker return wait_for_jit_notifications_to_save_; 112*795d594fSAndroid Build Coastguard Worker } SetWaitForJitNotificationsToSaveProfileSaverOptions113*795d594fSAndroid Build Coastguard Worker void SetWaitForJitNotificationsToSave(bool value) { 114*795d594fSAndroid Build Coastguard Worker wait_for_jit_notifications_to_save_ = value; 115*795d594fSAndroid Build Coastguard Worker } 116*795d594fSAndroid Build Coastguard Worker 117*795d594fSAndroid Build Coastguard Worker friend std::ostream & operator<<(std::ostream &os, const ProfileSaverOptions& pso) { 118*795d594fSAndroid Build Coastguard Worker os << "enabled_" << pso.enabled_ 119*795d594fSAndroid Build Coastguard Worker << ", min_save_period_ms_" << pso.min_save_period_ms_ 120*795d594fSAndroid Build Coastguard Worker << ", min_first_save_ms_" << pso.min_first_save_ms_ 121*795d594fSAndroid Build Coastguard Worker << ", min_methods_to_save_" << pso.min_methods_to_save_ 122*795d594fSAndroid Build Coastguard Worker << ", min_classes_to_save_" << pso.min_classes_to_save_ 123*795d594fSAndroid Build Coastguard Worker << ", min_notification_before_wake_" << pso.min_notification_before_wake_ 124*795d594fSAndroid Build Coastguard Worker << ", max_notification_before_wake_" << pso.max_notification_before_wake_ 125*795d594fSAndroid Build Coastguard Worker << ", inline_cache_threshold_" << pso.inline_cache_threshold_ 126*795d594fSAndroid Build Coastguard Worker << ", profile_boot_class_path_" << pso.profile_boot_class_path_ 127*795d594fSAndroid Build Coastguard Worker << ", profile_aot_code_" << pso.profile_aot_code_ 128*795d594fSAndroid Build Coastguard Worker << ", wait_for_jit_notifications_to_save_" << pso.wait_for_jit_notifications_to_save_; 129*795d594fSAndroid Build Coastguard Worker return os; 130*795d594fSAndroid Build Coastguard Worker } 131*795d594fSAndroid Build Coastguard Worker 132*795d594fSAndroid Build Coastguard Worker bool enabled_; 133*795d594fSAndroid Build Coastguard Worker uint32_t min_save_period_ms_; 134*795d594fSAndroid Build Coastguard Worker uint32_t min_first_save_ms_; 135*795d594fSAndroid Build Coastguard Worker uint32_t min_methods_to_save_; 136*795d594fSAndroid Build Coastguard Worker uint32_t min_classes_to_save_; 137*795d594fSAndroid Build Coastguard Worker uint32_t min_notification_before_wake_; 138*795d594fSAndroid Build Coastguard Worker uint32_t max_notification_before_wake_; 139*795d594fSAndroid Build Coastguard Worker uint16_t inline_cache_threshold_; 140*795d594fSAndroid Build Coastguard Worker std::string profile_path_; 141*795d594fSAndroid Build Coastguard Worker bool profile_boot_class_path_; 142*795d594fSAndroid Build Coastguard Worker bool profile_aot_code_; 143*795d594fSAndroid Build Coastguard Worker bool wait_for_jit_notifications_to_save_; 144*795d594fSAndroid Build Coastguard Worker }; 145*795d594fSAndroid Build Coastguard Worker 146*795d594fSAndroid Build Coastguard Worker } // namespace art 147*795d594fSAndroid Build Coastguard Worker 148*795d594fSAndroid Build Coastguard Worker #endif // ART_RUNTIME_JIT_PROFILE_SAVER_OPTIONS_H_ 149