blob: 095d66e62ca0798faba1653e34fe49220a212f94 [file] [log] [blame]
Brian Carlstrom491ca9e2014-03-02 18:24:38 -08001/*
2 * Copyright (C) 2011 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_PARSED_OPTIONS_H_
18#define ART_RUNTIME_PARSED_OPTIONS_H_
19
20#include <string>
Ian Rogerse63db272014-07-15 15:36:11 -070021#include <vector>
Brian Carlstrom491ca9e2014-03-02 18:24:38 -080022
Ian Rogerse63db272014-07-15 15:36:11 -070023#include <jni.h>
24
Andreas Gampe8cf9cb32017-07-19 09:28:38 -070025#include "arch/instruction_set.h"
Ian Rogers576ca0c2014-06-06 15:58:22 -070026#include "gc/collector_type.h"
Mathieu Chartier2dbe6272014-09-16 10:43:23 -070027#include "gc/space/large_object_space.h"
Andreas Gampe8cf9cb32017-07-19 09:28:38 -070028// #include "jit/profile_saver_options.h"
Andreas Gampe5a0430d2019-01-04 14:33:57 -080029#include "runtime_globals.h"
Igor Murashkinaaebaa02015-01-26 10:55:53 -080030#include "runtime_options.h"
Brian Carlstrom491ca9e2014-03-02 18:24:38 -080031
32namespace art {
33
Ian Rogerse63db272014-07-15 15:36:11 -070034class CompilerCallbacks;
35class DexFile;
Igor Murashkinaaebaa02015-01-26 10:55:53 -080036struct RuntimeArgumentMap;
Ian Rogerse63db272014-07-15 15:36:11 -070037
38typedef std::vector<std::pair<std::string, const void*>> RuntimeOptions;
39
Igor Murashkinaaebaa02015-01-26 10:55:53 -080040template <typename TVariantMap,
41 template <typename TKeyValue> class TVariantMapKey>
42struct CmdlineParser;
43
Brian Carlstrom491ca9e2014-03-02 18:24:38 -080044class ParsedOptions {
45 public:
Igor Murashkinaaebaa02015-01-26 10:55:53 -080046 using RuntimeParser = CmdlineParser<RuntimeArgumentMap, RuntimeArgumentMap::Key>;
47 // Create a parser that can turn user-defined input into a RuntimeArgumentMap.
48 // This visibility is effectively for testing-only, and normal code does not
49 // need to create its own parser.
50 static std::unique_ptr<RuntimeParser> MakeParser(bool ignore_unrecognized);
Brian Carlstrom491ca9e2014-03-02 18:24:38 -080051
Igor Murashkinaaebaa02015-01-26 10:55:53 -080052 // returns true if parsing succeeds, and stores the resulting options into runtime_options
Vladimir Marko88b2b802015-12-04 14:19:04 +000053 static bool Parse(const RuntimeOptions& options,
54 bool ignore_unrecognized,
55 RuntimeArgumentMap* runtime_options);
Igor Murashkinaaebaa02015-01-26 10:55:53 -080056
Brian Carlstrom491ca9e2014-03-02 18:24:38 -080057 bool (*hook_is_sensitive_thread_)();
58 jint (*hook_vfprintf_)(FILE* stream, const char* format, va_list ap);
59 void (*hook_exit_)(jint status);
60 void (*hook_abort_)();
Nicolas Geoffray0025a862014-07-11 08:26:40 +000061
Brian Carlstrom491ca9e2014-03-02 18:24:38 -080062 private:
Andreas Gampe313f4032014-08-29 16:01:25 -070063 ParsedOptions();
Brian Carlstrom491ca9e2014-03-02 18:24:38 -080064
Igor Murashkinaaebaa02015-01-26 10:55:53 -080065 bool ProcessSpecialOptions(const RuntimeOptions& options,
66 RuntimeArgumentMap* runtime_options,
67 std::vector<std::string>* out_options);
68
Brian Carlstrom491ca9e2014-03-02 18:24:38 -080069 void Usage(const char* fmt, ...);
70 void UsageMessage(FILE* stream, const char* fmt, ...);
71 void UsageMessageV(FILE* stream, const char* fmt, va_list ap);
72
73 void Exit(int status);
74 void Abort();
75
Vladimir Marko88b2b802015-12-04 14:19:04 +000076 bool DoParse(const RuntimeOptions& options,
77 bool ignore_unrecognized,
78 RuntimeArgumentMap* runtime_options);
Brian Carlstrom491ca9e2014-03-02 18:24:38 -080079};
80
81} // namespace art
82
83#endif // ART_RUNTIME_PARSED_OPTIONS_H_