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