Brian Carlstrom | 491ca9e | 2014-03-02 18:24:38 -0800 | [diff] [blame] | 1 | /* |
| 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 Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 21 | #include <vector> |
Brian Carlstrom | 491ca9e | 2014-03-02 18:24:38 -0800 | [diff] [blame] | 22 | |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 23 | #include <jni.h> |
| 24 | |
| 25 | #include "globals.h" |
Ian Rogers | 576ca0c | 2014-06-06 15:58:22 -0700 | [diff] [blame] | 26 | #include "gc/collector_type.h" |
Mathieu Chartier | 2dbe627 | 2014-09-16 10:43:23 -0700 | [diff] [blame] | 27 | #include "gc/space/large_object_space.h" |
Ian Rogers | d582fa4 | 2014-11-05 23:46:43 -0800 | [diff] [blame] | 28 | #include "arch/instruction_set.h" |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 29 | #include "profiler_options.h" |
Igor Murashkin | aaebaa0 | 2015-01-26 10:55:53 -0800 | [diff] [blame] | 30 | #include "runtime_options.h" |
Brian Carlstrom | 491ca9e | 2014-03-02 18:24:38 -0800 | [diff] [blame] | 31 | |
| 32 | namespace art { |
| 33 | |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 34 | class CompilerCallbacks; |
| 35 | class DexFile; |
Igor Murashkin | aaebaa0 | 2015-01-26 10:55:53 -0800 | [diff] [blame] | 36 | struct RuntimeArgumentMap; |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 37 | |
| 38 | typedef std::vector<std::pair<std::string, const void*>> RuntimeOptions; |
| 39 | |
Igor Murashkin | aaebaa0 | 2015-01-26 10:55:53 -0800 | [diff] [blame] | 40 | template <typename TVariantMap, |
| 41 | template <typename TKeyValue> class TVariantMapKey> |
| 42 | struct CmdlineParser; |
| 43 | |
Brian Carlstrom | 491ca9e | 2014-03-02 18:24:38 -0800 | [diff] [blame] | 44 | class ParsedOptions { |
| 45 | public: |
Igor Murashkin | aaebaa0 | 2015-01-26 10:55:53 -0800 | [diff] [blame] | 46 | 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 Carlstrom | 491ca9e | 2014-03-02 18:24:38 -0800 | [diff] [blame] | 51 | |
Igor Murashkin | aaebaa0 | 2015-01-26 10:55:53 -0800 | [diff] [blame] | 52 | // returns true if parsing succeeds, and stores the resulting options into runtime_options |
Igor Murashkin | b1d8c31 | 2015-08-04 11:18:43 -0700 | [diff] [blame] | 53 | static ParsedOptions* Create(const RuntimeOptions& options, bool ignore_unrecognized, |
| 54 | RuntimeArgumentMap* runtime_options); |
Igor Murashkin | aaebaa0 | 2015-01-26 10:55:53 -0800 | [diff] [blame] | 55 | |
Brian Carlstrom | 491ca9e | 2014-03-02 18:24:38 -0800 | [diff] [blame] | 56 | bool (*hook_is_sensitive_thread_)(); |
| 57 | jint (*hook_vfprintf_)(FILE* stream, const char* format, va_list ap); |
| 58 | void (*hook_exit_)(jint status); |
| 59 | void (*hook_abort_)(); |
Nicolas Geoffray | 0025a86 | 2014-07-11 08:26:40 +0000 | [diff] [blame] | 60 | |
Brian Carlstrom | 491ca9e | 2014-03-02 18:24:38 -0800 | [diff] [blame] | 61 | private: |
Andreas Gampe | 313f403 | 2014-08-29 16:01:25 -0700 | [diff] [blame] | 62 | ParsedOptions(); |
Brian Carlstrom | 491ca9e | 2014-03-02 18:24:38 -0800 | [diff] [blame] | 63 | |
Igor Murashkin | aaebaa0 | 2015-01-26 10:55:53 -0800 | [diff] [blame] | 64 | bool ProcessSpecialOptions(const RuntimeOptions& options, |
| 65 | RuntimeArgumentMap* runtime_options, |
| 66 | std::vector<std::string>* out_options); |
| 67 | |
Brian Carlstrom | 491ca9e | 2014-03-02 18:24:38 -0800 | [diff] [blame] | 68 | void Usage(const char* fmt, ...); |
| 69 | void UsageMessage(FILE* stream, const char* fmt, ...); |
| 70 | void UsageMessageV(FILE* stream, const char* fmt, va_list ap); |
| 71 | |
| 72 | void Exit(int status); |
| 73 | void Abort(); |
| 74 | |
Igor Murashkin | b1d8c31 | 2015-08-04 11:18:43 -0700 | [diff] [blame] | 75 | bool Parse(const RuntimeOptions& options, bool ignore_unrecognized, |
| 76 | RuntimeArgumentMap* runtime_options); |
Brian Carlstrom | 491ca9e | 2014-03-02 18:24:38 -0800 | [diff] [blame] | 77 | }; |
| 78 | |
| 79 | } // namespace art |
| 80 | |
| 81 | #endif // ART_RUNTIME_PARSED_OPTIONS_H_ |