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