xref: /aosp_15_r20/art/runtime/runtime_options.h (revision 795d594fd825385562da6b089ea9b2033f3abf5a)
1*795d594fSAndroid Build Coastguard Worker /*
2*795d594fSAndroid Build Coastguard Worker  * Copyright (C) 2015 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  *
10*795d594fSAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
11*795d594fSAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
12*795d594fSAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*795d594fSAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
14*795d594fSAndroid Build Coastguard Worker  * limitations under the License.
15*795d594fSAndroid Build Coastguard Worker  */
16*795d594fSAndroid Build Coastguard Worker 
17*795d594fSAndroid Build Coastguard Worker #ifndef ART_RUNTIME_RUNTIME_OPTIONS_H_
18*795d594fSAndroid Build Coastguard Worker #define ART_RUNTIME_RUNTIME_OPTIONS_H_
19*795d594fSAndroid Build Coastguard Worker 
20*795d594fSAndroid Build Coastguard Worker #include <cstdarg>
21*795d594fSAndroid Build Coastguard Worker #include <cstdio>
22*795d594fSAndroid Build Coastguard Worker #include <string>
23*795d594fSAndroid Build Coastguard Worker #include <vector>
24*795d594fSAndroid Build Coastguard Worker 
25*795d594fSAndroid Build Coastguard Worker #include "arch/instruction_set.h"
26*795d594fSAndroid Build Coastguard Worker #include "base/macros.h"
27*795d594fSAndroid Build Coastguard Worker #include "base/variant_map.h"
28*795d594fSAndroid Build Coastguard Worker #include "cmdline_types.h"  // TODO: don't need to include this file here
29*795d594fSAndroid Build Coastguard Worker #include "gc/collector_type.h"
30*795d594fSAndroid Build Coastguard Worker #include "gc/space/large_object_space.h"
31*795d594fSAndroid Build Coastguard Worker #include "hidden_api.h"
32*795d594fSAndroid Build Coastguard Worker #include "jit/jit_code_cache.h"
33*795d594fSAndroid Build Coastguard Worker #include "jit/jit_options.h"
34*795d594fSAndroid Build Coastguard Worker #include "jit/profile_saver_options.h"
35*795d594fSAndroid Build Coastguard Worker #include "verifier/verifier_enums.h"
36*795d594fSAndroid Build Coastguard Worker 
37*795d594fSAndroid Build Coastguard Worker namespace art HIDDEN {
38*795d594fSAndroid Build Coastguard Worker 
39*795d594fSAndroid Build Coastguard Worker class CompilerCallbacks;
40*795d594fSAndroid Build Coastguard Worker class DexFile;
41*795d594fSAndroid Build Coastguard Worker struct XGcOption;
42*795d594fSAndroid Build Coastguard Worker struct BackgroundGcOption;
43*795d594fSAndroid Build Coastguard Worker 
44*795d594fSAndroid Build Coastguard Worker // Define a key that is usable with a RuntimeArgumentMap.
45*795d594fSAndroid Build Coastguard Worker // This key will *not* work with other subtypes of VariantMap.
46*795d594fSAndroid Build Coastguard Worker template <typename TValue>
47*795d594fSAndroid Build Coastguard Worker struct RuntimeArgumentMapKey : VariantMapKey<TValue> {
RuntimeArgumentMapKeyRuntimeArgumentMapKey48*795d594fSAndroid Build Coastguard Worker   RuntimeArgumentMapKey() {}
RuntimeArgumentMapKeyRuntimeArgumentMapKey49*795d594fSAndroid Build Coastguard Worker   explicit RuntimeArgumentMapKey(TValue default_value)
50*795d594fSAndroid Build Coastguard Worker     : VariantMapKey<TValue>(std::move(default_value)) {}
51*795d594fSAndroid Build Coastguard Worker   // Don't ODR-use constexpr default values, which means that Struct::Fields
52*795d594fSAndroid Build Coastguard Worker   // that are declared 'static constexpr T Name = Value' don't need to have a matching definition.
53*795d594fSAndroid Build Coastguard Worker };
54*795d594fSAndroid Build Coastguard Worker 
55*795d594fSAndroid Build Coastguard Worker // Defines a type-safe heterogeneous key->value map.
56*795d594fSAndroid Build Coastguard Worker // Use the VariantMap interface to look up or to store a RuntimeArgumentMapKey,Value pair.
57*795d594fSAndroid Build Coastguard Worker //
58*795d594fSAndroid Build Coastguard Worker // Example:
59*795d594fSAndroid Build Coastguard Worker //    auto map = RuntimeArgumentMap();
60*795d594fSAndroid Build Coastguard Worker //    map.Set(RuntimeArgumentMap::HeapTargetUtilization, 5.0);
61*795d594fSAndroid Build Coastguard Worker //    double *target_utilization = map.Get(RuntimeArgumentMap);
62*795d594fSAndroid Build Coastguard Worker //
63*795d594fSAndroid Build Coastguard Worker struct EXPORT RuntimeArgumentMap : VariantMap<RuntimeArgumentMap, RuntimeArgumentMapKey> {
64*795d594fSAndroid Build Coastguard Worker   // This 'using' line is necessary to inherit the variadic constructor.
65*795d594fSAndroid Build Coastguard Worker   using VariantMap<RuntimeArgumentMap, RuntimeArgumentMapKey>::VariantMap;
66*795d594fSAndroid Build Coastguard Worker 
67*795d594fSAndroid Build Coastguard Worker   // Make the next many usages of Key slightly shorter to type.
68*795d594fSAndroid Build Coastguard Worker   template <typename TValue>
69*795d594fSAndroid Build Coastguard Worker   using Key = RuntimeArgumentMapKey<TValue>;
70*795d594fSAndroid Build Coastguard Worker 
71*795d594fSAndroid Build Coastguard Worker   // List of key declarations, shorthand for 'static const Key<T> Name'
72*795d594fSAndroid Build Coastguard Worker #define RUNTIME_OPTIONS_KEY(Type, Name, ...) static const Key<Type> (Name);
73*795d594fSAndroid Build Coastguard Worker #include "runtime_options.def"
74*795d594fSAndroid Build Coastguard Worker };
75*795d594fSAndroid Build Coastguard Worker 
76*795d594fSAndroid Build Coastguard Worker #undef RUNTIME_OPTIONS_KEY
77*795d594fSAndroid Build Coastguard Worker 
78*795d594fSAndroid Build Coastguard Worker   // using RuntimeOptions = RuntimeArgumentMap;
79*795d594fSAndroid Build Coastguard Worker }  // namespace art
80*795d594fSAndroid Build Coastguard Worker 
81*795d594fSAndroid Build Coastguard Worker #endif  // ART_RUNTIME_RUNTIME_OPTIONS_H_
82