1*795d594fSAndroid Build Coastguard Worker /* 2*795d594fSAndroid Build Coastguard Worker * Copyright (C) 2011 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_PARSED_OPTIONS_H_ 18*795d594fSAndroid Build Coastguard Worker #define ART_RUNTIME_PARSED_OPTIONS_H_ 19*795d594fSAndroid Build Coastguard Worker 20*795d594fSAndroid Build Coastguard Worker #include <string> 21*795d594fSAndroid Build Coastguard Worker #include <string_view> 22*795d594fSAndroid Build Coastguard Worker #include <vector> 23*795d594fSAndroid Build Coastguard Worker 24*795d594fSAndroid Build Coastguard Worker #include <jni.h> 25*795d594fSAndroid Build Coastguard Worker 26*795d594fSAndroid Build Coastguard Worker #include "arch/instruction_set.h" 27*795d594fSAndroid Build Coastguard Worker #include "base/macros.h" 28*795d594fSAndroid Build Coastguard Worker #include "gc/collector_type.h" 29*795d594fSAndroid Build Coastguard Worker #include "gc/space/large_object_space.h" 30*795d594fSAndroid Build Coastguard Worker // #include "jit/profile_saver_options.h" 31*795d594fSAndroid Build Coastguard Worker #include "runtime_globals.h" 32*795d594fSAndroid Build Coastguard Worker #include "runtime_options.h" 33*795d594fSAndroid Build Coastguard Worker 34*795d594fSAndroid Build Coastguard Worker namespace art HIDDEN { 35*795d594fSAndroid Build Coastguard Worker 36*795d594fSAndroid Build Coastguard Worker class CompilerCallbacks; 37*795d594fSAndroid Build Coastguard Worker class DexFile; 38*795d594fSAndroid Build Coastguard Worker struct RuntimeArgumentMap; 39*795d594fSAndroid Build Coastguard Worker 40*795d594fSAndroid Build Coastguard Worker using RuntimeOptions = std::vector<std::pair<std::string, const void*>>; 41*795d594fSAndroid Build Coastguard Worker 42*795d594fSAndroid Build Coastguard Worker template <typename TVariantMap, 43*795d594fSAndroid Build Coastguard Worker template <typename TKeyValue> class TVariantMapKey> 44*795d594fSAndroid Build Coastguard Worker struct CmdlineParser; 45*795d594fSAndroid Build Coastguard Worker 46*795d594fSAndroid Build Coastguard Worker class ParsedOptions { 47*795d594fSAndroid Build Coastguard Worker public: 48*795d594fSAndroid Build Coastguard Worker using RuntimeParser = CmdlineParser<RuntimeArgumentMap, RuntimeArgumentMap::Key>; 49*795d594fSAndroid Build Coastguard Worker // Create a parser that can turn user-defined input into a RuntimeArgumentMap. 50*795d594fSAndroid Build Coastguard Worker // This visibility is effectively for testing-only, and normal code does not 51*795d594fSAndroid Build Coastguard Worker // need to create its own parser. 52*795d594fSAndroid Build Coastguard Worker static std::unique_ptr<RuntimeParser> MakeParser(bool ignore_unrecognized); 53*795d594fSAndroid Build Coastguard Worker 54*795d594fSAndroid Build Coastguard Worker // returns true if parsing succeeds, and stores the resulting options into runtime_options 55*795d594fSAndroid Build Coastguard Worker static bool Parse(const RuntimeOptions& options, 56*795d594fSAndroid Build Coastguard Worker bool ignore_unrecognized, 57*795d594fSAndroid Build Coastguard Worker RuntimeArgumentMap* runtime_options); 58*795d594fSAndroid Build Coastguard Worker 59*795d594fSAndroid Build Coastguard Worker bool (*hook_is_sensitive_thread_)(); 60*795d594fSAndroid Build Coastguard Worker jint (*hook_vfprintf_)(FILE* stream, const char* format, va_list ap); 61*795d594fSAndroid Build Coastguard Worker void (*hook_exit_)(jint status); 62*795d594fSAndroid Build Coastguard Worker void (*hook_abort_)(); 63*795d594fSAndroid Build Coastguard Worker 64*795d594fSAndroid Build Coastguard Worker private: 65*795d594fSAndroid Build Coastguard Worker ParsedOptions(); 66*795d594fSAndroid Build Coastguard Worker 67*795d594fSAndroid Build Coastguard Worker bool ProcessSpecialOptions(const RuntimeOptions& options, 68*795d594fSAndroid Build Coastguard Worker RuntimeArgumentMap* runtime_options, 69*795d594fSAndroid Build Coastguard Worker std::vector<std::string>* out_options); 70*795d594fSAndroid Build Coastguard Worker 71*795d594fSAndroid Build Coastguard Worker void Usage(const char* fmt, ...); 72*795d594fSAndroid Build Coastguard Worker void UsageMessage(FILE* stream, const char* fmt, ...); 73*795d594fSAndroid Build Coastguard Worker void UsageMessageV(FILE* stream, const char* fmt, va_list ap); 74*795d594fSAndroid Build Coastguard Worker 75*795d594fSAndroid Build Coastguard Worker void Exit(int status); 76*795d594fSAndroid Build Coastguard Worker void Abort(); 77*795d594fSAndroid Build Coastguard Worker 78*795d594fSAndroid Build Coastguard Worker bool DoParse(const RuntimeOptions& options, 79*795d594fSAndroid Build Coastguard Worker bool ignore_unrecognized, 80*795d594fSAndroid Build Coastguard Worker RuntimeArgumentMap* runtime_options); 81*795d594fSAndroid Build Coastguard Worker }; 82*795d594fSAndroid Build Coastguard Worker 83*795d594fSAndroid Build Coastguard Worker } // namespace art 84*795d594fSAndroid Build Coastguard Worker 85*795d594fSAndroid Build Coastguard Worker #endif // ART_RUNTIME_PARSED_OPTIONS_H_ 86