Igor Murashkin | aaebaa0 | 2015-01-26 10:55:53 -0800 | [diff] [blame] | 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 | #ifndef ART_CMDLINE_CMDLINE_TYPES_H_ |
| 17 | #define ART_CMDLINE_CMDLINE_TYPES_H_ |
| 18 | |
| 19 | #define CMDLINE_NDEBUG 1 // Do not output any debugging information for parsing. |
| 20 | |
Vladimir Marko | 88b2b80 | 2015-12-04 14:19:04 +0000 | [diff] [blame] | 21 | #include "memory_representation.h" |
| 22 | #include "detail/cmdline_debug_detail.h" |
Igor Murashkin | aaebaa0 | 2015-01-26 10:55:53 -0800 | [diff] [blame] | 23 | #include "cmdline_type_parser.h" |
| 24 | |
| 25 | // Includes for the types that are being specialized |
| 26 | #include <string> |
Vladimir Marko | 88b2b80 | 2015-12-04 14:19:04 +0000 | [diff] [blame] | 27 | #include "base/logging.h" |
| 28 | #include "base/time_utils.h" |
| 29 | #include "experimental_flags.h" |
Igor Murashkin | aaebaa0 | 2015-01-26 10:55:53 -0800 | [diff] [blame] | 30 | #include "gc/collector_type.h" |
| 31 | #include "gc/space/large_object_space.h" |
Alex Light | 7233c7e | 2016-07-28 10:07:45 -0700 | [diff] [blame] | 32 | #include "jdwp/jdwp.h" |
Calin Juravle | 138dbff | 2016-06-28 19:36:58 +0100 | [diff] [blame] | 33 | #include "jit/profile_saver_options.h" |
Alex Light | 185d134 | 2016-08-11 10:48:03 -0700 | [diff] [blame] | 34 | #include "plugin.h" |
Alex Light | 7233c7e | 2016-07-28 10:07:45 -0700 | [diff] [blame] | 35 | #include "ti/agent.h" |
| 36 | #include "unit.h" |
Igor Murashkin | aaebaa0 | 2015-01-26 10:55:53 -0800 | [diff] [blame] | 37 | |
| 38 | namespace art { |
| 39 | |
| 40 | // The default specialization will always fail parsing the type from a string. |
| 41 | // Provide your own specialization that inherits from CmdlineTypeParser<T> |
| 42 | // and implements either Parse or ParseAndAppend |
| 43 | // (only if the argument was defined with ::AppendValues()) but not both. |
| 44 | template <typename T> |
| 45 | struct CmdlineType : CmdlineTypeParser<T> { |
| 46 | }; |
| 47 | |
| 48 | // Specializations for CmdlineType<T> follow: |
| 49 | |
| 50 | // Parse argument definitions for Unit-typed arguments. |
| 51 | template <> |
| 52 | struct CmdlineType<Unit> : CmdlineTypeParser<Unit> { |
| 53 | Result Parse(const std::string& args) { |
| 54 | if (args == "") { |
| 55 | return Result::Success(Unit{}); // NOLINT [whitespace/braces] [5] |
| 56 | } |
| 57 | return Result::Failure("Unexpected extra characters " + args); |
| 58 | } |
| 59 | }; |
| 60 | |
| 61 | template <> |
| 62 | struct CmdlineType<JDWP::JdwpOptions> : CmdlineTypeParser<JDWP::JdwpOptions> { |
Sebastien Hertz | 3be6e9d | 2015-02-05 16:30:58 +0100 | [diff] [blame] | 63 | /* |
| 64 | * Handle one of the JDWP name/value pairs. |
| 65 | * |
| 66 | * JDWP options are: |
| 67 | * help: if specified, show help message and bail |
| 68 | * transport: may be dt_socket or dt_shmem |
| 69 | * address: for dt_socket, "host:port", or just "port" when listening |
| 70 | * server: if "y", wait for debugger to attach; if "n", attach to debugger |
| 71 | * timeout: how long to wait for debugger to connect / listen |
| 72 | * |
| 73 | * Useful with server=n (these aren't supported yet): |
| 74 | * onthrow=<exception-name>: connect to debugger when exception thrown |
| 75 | * onuncaught=y|n: connect to debugger when uncaught exception thrown |
| 76 | * launch=<command-line>: launch the debugger itself |
| 77 | * |
| 78 | * The "transport" option is required, as is "address" if server=n. |
| 79 | */ |
Igor Murashkin | aaebaa0 | 2015-01-26 10:55:53 -0800 | [diff] [blame] | 80 | Result Parse(const std::string& options) { |
| 81 | VLOG(jdwp) << "ParseJdwpOptions: " << options; |
| 82 | |
| 83 | if (options == "help") { |
| 84 | return Result::Usage( |
| 85 | "Example: -Xrunjdwp:transport=dt_socket,address=8000,server=y\n" |
| 86 | "Example: -Xrunjdwp:transport=dt_socket,address=localhost:6500,server=n\n"); |
| 87 | } |
| 88 | |
| 89 | const std::string s; |
| 90 | |
| 91 | std::vector<std::string> pairs; |
| 92 | Split(options, ',', &pairs); |
| 93 | |
Sebastien Hertz | 3be6e9d | 2015-02-05 16:30:58 +0100 | [diff] [blame] | 94 | JDWP::JdwpOptions jdwp_options; |
Igor Murashkin | aaebaa0 | 2015-01-26 10:55:53 -0800 | [diff] [blame] | 95 | |
Sebastien Hertz | 3be6e9d | 2015-02-05 16:30:58 +0100 | [diff] [blame] | 96 | for (const std::string& jdwp_option : pairs) { |
| 97 | std::string::size_type equals_pos = jdwp_option.find('='); |
| 98 | if (equals_pos == std::string::npos) { |
Igor Murashkin | aaebaa0 | 2015-01-26 10:55:53 -0800 | [diff] [blame] | 99 | return Result::Failure(s + |
Sebastien Hertz | 3be6e9d | 2015-02-05 16:30:58 +0100 | [diff] [blame] | 100 | "Can't parse JDWP option '" + jdwp_option + "' in '" + options + "'"); |
Igor Murashkin | aaebaa0 | 2015-01-26 10:55:53 -0800 | [diff] [blame] | 101 | } |
| 102 | |
Sebastien Hertz | b3b173b | 2015-02-06 09:16:32 +0100 | [diff] [blame] | 103 | Result parse_attempt = ParseJdwpOption(jdwp_option.substr(0, equals_pos), |
| 104 | jdwp_option.substr(equals_pos + 1), |
| 105 | &jdwp_options); |
| 106 | if (parse_attempt.IsError()) { |
| 107 | // We fail to parse this JDWP option. |
| 108 | return parse_attempt; |
Igor Murashkin | aaebaa0 | 2015-01-26 10:55:53 -0800 | [diff] [blame] | 109 | } |
| 110 | } |
| 111 | |
| 112 | if (jdwp_options.transport == JDWP::kJdwpTransportUnknown) { |
| 113 | return Result::Failure(s + "Must specify JDWP transport: " + options); |
| 114 | } |
| 115 | if (!jdwp_options.server && (jdwp_options.host.empty() || jdwp_options.port == 0)) { |
| 116 | return Result::Failure(s + "Must specify JDWP host and port when server=n: " + options); |
| 117 | } |
| 118 | |
| 119 | return Result::Success(std::move(jdwp_options)); |
| 120 | } |
| 121 | |
Sebastien Hertz | b3b173b | 2015-02-06 09:16:32 +0100 | [diff] [blame] | 122 | Result ParseJdwpOption(const std::string& name, const std::string& value, |
| 123 | JDWP::JdwpOptions* jdwp_options) { |
Igor Murashkin | aaebaa0 | 2015-01-26 10:55:53 -0800 | [diff] [blame] | 124 | if (name == "transport") { |
| 125 | if (value == "dt_socket") { |
Sebastien Hertz | 3be6e9d | 2015-02-05 16:30:58 +0100 | [diff] [blame] | 126 | jdwp_options->transport = JDWP::kJdwpTransportSocket; |
Igor Murashkin | aaebaa0 | 2015-01-26 10:55:53 -0800 | [diff] [blame] | 127 | } else if (value == "dt_android_adb") { |
Sebastien Hertz | 3be6e9d | 2015-02-05 16:30:58 +0100 | [diff] [blame] | 128 | jdwp_options->transport = JDWP::kJdwpTransportAndroidAdb; |
Igor Murashkin | aaebaa0 | 2015-01-26 10:55:53 -0800 | [diff] [blame] | 129 | } else { |
Sebastien Hertz | b3b173b | 2015-02-06 09:16:32 +0100 | [diff] [blame] | 130 | return Result::Failure("JDWP transport not supported: " + value); |
Igor Murashkin | aaebaa0 | 2015-01-26 10:55:53 -0800 | [diff] [blame] | 131 | } |
| 132 | } else if (name == "server") { |
| 133 | if (value == "n") { |
Sebastien Hertz | 3be6e9d | 2015-02-05 16:30:58 +0100 | [diff] [blame] | 134 | jdwp_options->server = false; |
Igor Murashkin | aaebaa0 | 2015-01-26 10:55:53 -0800 | [diff] [blame] | 135 | } else if (value == "y") { |
Sebastien Hertz | 3be6e9d | 2015-02-05 16:30:58 +0100 | [diff] [blame] | 136 | jdwp_options->server = true; |
Igor Murashkin | aaebaa0 | 2015-01-26 10:55:53 -0800 | [diff] [blame] | 137 | } else { |
Sebastien Hertz | b3b173b | 2015-02-06 09:16:32 +0100 | [diff] [blame] | 138 | return Result::Failure("JDWP option 'server' must be 'y' or 'n'"); |
Igor Murashkin | aaebaa0 | 2015-01-26 10:55:53 -0800 | [diff] [blame] | 139 | } |
| 140 | } else if (name == "suspend") { |
| 141 | if (value == "n") { |
Sebastien Hertz | 3be6e9d | 2015-02-05 16:30:58 +0100 | [diff] [blame] | 142 | jdwp_options->suspend = false; |
Igor Murashkin | aaebaa0 | 2015-01-26 10:55:53 -0800 | [diff] [blame] | 143 | } else if (value == "y") { |
Sebastien Hertz | 3be6e9d | 2015-02-05 16:30:58 +0100 | [diff] [blame] | 144 | jdwp_options->suspend = true; |
Igor Murashkin | aaebaa0 | 2015-01-26 10:55:53 -0800 | [diff] [blame] | 145 | } else { |
Sebastien Hertz | b3b173b | 2015-02-06 09:16:32 +0100 | [diff] [blame] | 146 | return Result::Failure("JDWP option 'suspend' must be 'y' or 'n'"); |
Igor Murashkin | aaebaa0 | 2015-01-26 10:55:53 -0800 | [diff] [blame] | 147 | } |
| 148 | } else if (name == "address") { |
| 149 | /* this is either <port> or <host>:<port> */ |
| 150 | std::string port_string; |
Sebastien Hertz | 3be6e9d | 2015-02-05 16:30:58 +0100 | [diff] [blame] | 151 | jdwp_options->host.clear(); |
Igor Murashkin | aaebaa0 | 2015-01-26 10:55:53 -0800 | [diff] [blame] | 152 | std::string::size_type colon = value.find(':'); |
| 153 | if (colon != std::string::npos) { |
Sebastien Hertz | 3be6e9d | 2015-02-05 16:30:58 +0100 | [diff] [blame] | 154 | jdwp_options->host = value.substr(0, colon); |
Igor Murashkin | aaebaa0 | 2015-01-26 10:55:53 -0800 | [diff] [blame] | 155 | port_string = value.substr(colon + 1); |
| 156 | } else { |
| 157 | port_string = value; |
| 158 | } |
| 159 | if (port_string.empty()) { |
Sebastien Hertz | b3b173b | 2015-02-06 09:16:32 +0100 | [diff] [blame] | 160 | return Result::Failure("JDWP address missing port: " + value); |
Igor Murashkin | aaebaa0 | 2015-01-26 10:55:53 -0800 | [diff] [blame] | 161 | } |
| 162 | char* end; |
| 163 | uint64_t port = strtoul(port_string.c_str(), &end, 10); |
| 164 | if (*end != '\0' || port > 0xffff) { |
Sebastien Hertz | b3b173b | 2015-02-06 09:16:32 +0100 | [diff] [blame] | 165 | return Result::Failure("JDWP address has junk in port field: " + value); |
Igor Murashkin | aaebaa0 | 2015-01-26 10:55:53 -0800 | [diff] [blame] | 166 | } |
Sebastien Hertz | 3be6e9d | 2015-02-05 16:30:58 +0100 | [diff] [blame] | 167 | jdwp_options->port = port; |
Igor Murashkin | aaebaa0 | 2015-01-26 10:55:53 -0800 | [diff] [blame] | 168 | } else if (name == "launch" || name == "onthrow" || name == "oncaught" || name == "timeout") { |
| 169 | /* valid but unsupported */ |
| 170 | LOG(INFO) << "Ignoring JDWP option '" << name << "'='" << value << "'"; |
| 171 | } else { |
| 172 | LOG(INFO) << "Ignoring unrecognized JDWP option '" << name << "'='" << value << "'"; |
| 173 | } |
| 174 | |
Sebastien Hertz | b3b173b | 2015-02-06 09:16:32 +0100 | [diff] [blame] | 175 | return Result::SuccessNoValue(); |
Igor Murashkin | aaebaa0 | 2015-01-26 10:55:53 -0800 | [diff] [blame] | 176 | } |
| 177 | |
| 178 | static const char* Name() { return "JdwpOptions"; } |
| 179 | }; |
| 180 | |
| 181 | template <size_t Divisor> |
| 182 | struct CmdlineType<Memory<Divisor>> : CmdlineTypeParser<Memory<Divisor>> { |
| 183 | using typename CmdlineTypeParser<Memory<Divisor>>::Result; |
| 184 | |
Vladimir Marko | 5c657fe | 2016-11-03 15:12:29 +0000 | [diff] [blame] | 185 | Result Parse(const std::string& arg) { |
Igor Murashkin | aaebaa0 | 2015-01-26 10:55:53 -0800 | [diff] [blame] | 186 | CMDLINE_DEBUG_LOG << "Parsing memory: " << arg << std::endl; |
| 187 | size_t val = ParseMemoryOption(arg.c_str(), Divisor); |
| 188 | CMDLINE_DEBUG_LOG << "Memory parsed to size_t value: " << val << std::endl; |
| 189 | |
| 190 | if (val == 0) { |
| 191 | return Result::Failure(std::string("not a valid memory value, or not divisible by ") |
| 192 | + std::to_string(Divisor)); |
| 193 | } |
| 194 | |
| 195 | return Result::Success(Memory<Divisor>(val)); |
| 196 | } |
| 197 | |
| 198 | // Parse a string of the form /[0-9]+[kKmMgG]?/, which is used to specify |
| 199 | // memory sizes. [kK] indicates kilobytes, [mM] megabytes, and |
| 200 | // [gG] gigabytes. |
| 201 | // |
| 202 | // "s" should point just past the "-Xm?" part of the string. |
| 203 | // "div" specifies a divisor, e.g. 1024 if the value must be a multiple |
| 204 | // of 1024. |
| 205 | // |
| 206 | // The spec says the -Xmx and -Xms options must be multiples of 1024. It |
| 207 | // doesn't say anything about -Xss. |
| 208 | // |
| 209 | // Returns 0 (a useless size) if "s" is malformed or specifies a low or |
| 210 | // non-evenly-divisible value. |
| 211 | // |
| 212 | static size_t ParseMemoryOption(const char* s, size_t div) { |
| 213 | // strtoul accepts a leading [+-], which we don't want, |
| 214 | // so make sure our string starts with a decimal digit. |
| 215 | if (isdigit(*s)) { |
| 216 | char* s2; |
| 217 | size_t val = strtoul(s, &s2, 10); |
| 218 | if (s2 != s) { |
| 219 | // s2 should be pointing just after the number. |
| 220 | // If this is the end of the string, the user |
| 221 | // has specified a number of bytes. Otherwise, |
| 222 | // there should be exactly one more character |
| 223 | // that specifies a multiplier. |
| 224 | if (*s2 != '\0') { |
| 225 | // The remainder of the string is either a single multiplier |
| 226 | // character, or nothing to indicate that the value is in |
| 227 | // bytes. |
| 228 | char c = *s2++; |
| 229 | if (*s2 == '\0') { |
| 230 | size_t mul; |
| 231 | if (c == '\0') { |
| 232 | mul = 1; |
| 233 | } else if (c == 'k' || c == 'K') { |
| 234 | mul = KB; |
| 235 | } else if (c == 'm' || c == 'M') { |
| 236 | mul = MB; |
| 237 | } else if (c == 'g' || c == 'G') { |
| 238 | mul = GB; |
| 239 | } else { |
| 240 | // Unknown multiplier character. |
| 241 | return 0; |
| 242 | } |
| 243 | |
| 244 | if (val <= std::numeric_limits<size_t>::max() / mul) { |
| 245 | val *= mul; |
| 246 | } else { |
| 247 | // Clamp to a multiple of 1024. |
| 248 | val = std::numeric_limits<size_t>::max() & ~(1024-1); |
| 249 | } |
| 250 | } else { |
| 251 | // There's more than one character after the numeric part. |
| 252 | return 0; |
| 253 | } |
| 254 | } |
| 255 | // The man page says that a -Xm value must be a multiple of 1024. |
| 256 | if (val % div == 0) { |
| 257 | return val; |
| 258 | } |
| 259 | } |
| 260 | } |
| 261 | return 0; |
| 262 | } |
| 263 | |
| 264 | static const char* Name() { return Memory<Divisor>::Name(); } |
| 265 | }; |
| 266 | |
| 267 | template <> |
| 268 | struct CmdlineType<double> : CmdlineTypeParser<double> { |
| 269 | Result Parse(const std::string& str) { |
| 270 | char* end = nullptr; |
| 271 | errno = 0; |
| 272 | double value = strtod(str.c_str(), &end); |
| 273 | |
| 274 | if (*end != '\0') { |
| 275 | return Result::Failure("Failed to parse double from " + str); |
| 276 | } |
| 277 | if (errno == ERANGE) { |
| 278 | return Result::OutOfRange( |
| 279 | "Failed to parse double from " + str + "; overflow/underflow occurred"); |
| 280 | } |
| 281 | |
| 282 | return Result::Success(value); |
| 283 | } |
| 284 | |
| 285 | static const char* Name() { return "double"; } |
| 286 | }; |
| 287 | |
| 288 | template <> |
| 289 | struct CmdlineType<unsigned int> : CmdlineTypeParser<unsigned int> { |
| 290 | Result Parse(const std::string& str) { |
| 291 | const char* begin = str.c_str(); |
| 292 | char* end; |
| 293 | |
| 294 | // Parse into a larger type (long long) because we can't use strtoul |
| 295 | // since it silently converts negative values into unsigned long and doesn't set errno. |
| 296 | errno = 0; |
| 297 | long long int result = strtoll(begin, &end, 10); // NOLINT [runtime/int] [4] |
| 298 | if (begin == end || *end != '\0' || errno == EINVAL) { |
| 299 | return Result::Failure("Failed to parse integer from " + str); |
| 300 | } else if ((errno == ERANGE) || // NOLINT [runtime/int] [4] |
| 301 | result < std::numeric_limits<int>::min() |
| 302 | || result > std::numeric_limits<unsigned int>::max() || result < 0) { |
| 303 | return Result::OutOfRange( |
| 304 | "Failed to parse integer from " + str + "; out of unsigned int range"); |
| 305 | } |
| 306 | |
| 307 | return Result::Success(static_cast<unsigned int>(result)); |
| 308 | } |
| 309 | |
| 310 | static const char* Name() { return "unsigned integer"; } |
| 311 | }; |
| 312 | |
| 313 | // Lightweight nanosecond value type. Allows parser to convert user-input from milliseconds |
| 314 | // to nanoseconds automatically after parsing. |
| 315 | // |
| 316 | // All implicit conversion from uint64_t uses nanoseconds. |
| 317 | struct MillisecondsToNanoseconds { |
| 318 | // Create from nanoseconds. |
| 319 | MillisecondsToNanoseconds(uint64_t nanoseconds) : nanoseconds_(nanoseconds) { // NOLINT [runtime/explicit] [5] |
| 320 | } |
| 321 | |
| 322 | // Create from milliseconds. |
| 323 | static MillisecondsToNanoseconds FromMilliseconds(unsigned int milliseconds) { |
| 324 | return MillisecondsToNanoseconds(MsToNs(milliseconds)); |
| 325 | } |
| 326 | |
| 327 | // Get the underlying nanoseconds value. |
| 328 | uint64_t GetNanoseconds() const { |
| 329 | return nanoseconds_; |
| 330 | } |
| 331 | |
| 332 | // Get the milliseconds value [via a conversion]. Loss of precision will occur. |
| 333 | uint64_t GetMilliseconds() const { |
| 334 | return NsToMs(nanoseconds_); |
| 335 | } |
| 336 | |
| 337 | // Get the underlying nanoseconds value. |
| 338 | operator uint64_t() const { |
| 339 | return GetNanoseconds(); |
| 340 | } |
| 341 | |
| 342 | // Default constructors/copy-constructors. |
| 343 | MillisecondsToNanoseconds() : nanoseconds_(0ul) {} |
Andreas Gampe | c801f0d | 2015-02-24 20:55:16 -0800 | [diff] [blame] | 344 | MillisecondsToNanoseconds(const MillisecondsToNanoseconds&) = default; |
| 345 | MillisecondsToNanoseconds(MillisecondsToNanoseconds&&) = default; |
Igor Murashkin | aaebaa0 | 2015-01-26 10:55:53 -0800 | [diff] [blame] | 346 | |
| 347 | private: |
| 348 | uint64_t nanoseconds_; |
| 349 | }; |
| 350 | |
| 351 | template <> |
| 352 | struct CmdlineType<MillisecondsToNanoseconds> : CmdlineTypeParser<MillisecondsToNanoseconds> { |
| 353 | Result Parse(const std::string& str) { |
| 354 | CmdlineType<unsigned int> uint_parser; |
| 355 | CmdlineParseResult<unsigned int> res = uint_parser.Parse(str); |
| 356 | |
| 357 | if (res.IsSuccess()) { |
| 358 | return Result::Success(MillisecondsToNanoseconds::FromMilliseconds(res.GetValue())); |
| 359 | } else { |
| 360 | return Result::CastError(res); |
| 361 | } |
| 362 | } |
| 363 | |
| 364 | static const char* Name() { return "MillisecondsToNanoseconds"; } |
| 365 | }; |
| 366 | |
| 367 | template <> |
| 368 | struct CmdlineType<std::string> : CmdlineTypeParser<std::string> { |
| 369 | Result Parse(const std::string& args) { |
| 370 | return Result::Success(args); |
| 371 | } |
| 372 | |
| 373 | Result ParseAndAppend(const std::string& args, |
| 374 | std::string& existing_value) { |
| 375 | if (existing_value.empty()) { |
| 376 | existing_value = args; |
| 377 | } else { |
| 378 | existing_value += ' '; |
| 379 | existing_value += args; |
| 380 | } |
| 381 | return Result::SuccessNoValue(); |
| 382 | } |
| 383 | }; |
| 384 | |
| 385 | template <> |
Alex Light | 185d134 | 2016-08-11 10:48:03 -0700 | [diff] [blame] | 386 | struct CmdlineType<std::vector<Plugin>> : CmdlineTypeParser<std::vector<Plugin>> { |
| 387 | Result Parse(const std::string& args) { |
| 388 | assert(false && "Use AppendValues() for a Plugin vector type"); |
| 389 | return Result::Failure("Unconditional failure: Plugin vector must be appended: " + args); |
| 390 | } |
| 391 | |
| 392 | Result ParseAndAppend(const std::string& args, |
| 393 | std::vector<Plugin>& existing_value) { |
| 394 | existing_value.push_back(Plugin::Create(args)); |
| 395 | return Result::SuccessNoValue(); |
| 396 | } |
| 397 | |
| 398 | static const char* Name() { return "std::vector<Plugin>"; } |
| 399 | }; |
| 400 | |
| 401 | template <> |
Alex Light | 7233c7e | 2016-07-28 10:07:45 -0700 | [diff] [blame] | 402 | struct CmdlineType<std::vector<ti::Agent>> : CmdlineTypeParser<std::vector<ti::Agent>> { |
| 403 | Result Parse(const std::string& args) { |
| 404 | assert(false && "Use AppendValues() for an Agent vector type"); |
| 405 | return Result::Failure("Unconditional failure: Agent vector must be appended: " + args); |
| 406 | } |
| 407 | |
| 408 | Result ParseAndAppend(const std::string& args, |
| 409 | std::vector<ti::Agent>& existing_value) { |
Leonard Mosescu | eb84221 | 2016-10-06 17:26:36 -0700 | [diff] [blame] | 410 | existing_value.emplace_back(args); |
Alex Light | 7233c7e | 2016-07-28 10:07:45 -0700 | [diff] [blame] | 411 | return Result::SuccessNoValue(); |
| 412 | } |
| 413 | |
| 414 | static const char* Name() { return "std::vector<ti::Agent>"; } |
| 415 | }; |
| 416 | |
| 417 | template <> |
Igor Murashkin | aaebaa0 | 2015-01-26 10:55:53 -0800 | [diff] [blame] | 418 | struct CmdlineType<std::vector<std::string>> : CmdlineTypeParser<std::vector<std::string>> { |
| 419 | Result Parse(const std::string& args) { |
| 420 | assert(false && "Use AppendValues() for a string vector type"); |
| 421 | return Result::Failure("Unconditional failure: string vector must be appended: " + args); |
| 422 | } |
| 423 | |
| 424 | Result ParseAndAppend(const std::string& args, |
| 425 | std::vector<std::string>& existing_value) { |
| 426 | existing_value.push_back(args); |
| 427 | return Result::SuccessNoValue(); |
| 428 | } |
| 429 | |
| 430 | static const char* Name() { return "std::vector<std::string>"; } |
| 431 | }; |
| 432 | |
| 433 | template <char Separator> |
| 434 | struct ParseStringList { |
| 435 | explicit ParseStringList(std::vector<std::string>&& list) : list_(list) {} |
| 436 | |
| 437 | operator std::vector<std::string>() const { |
| 438 | return list_; |
| 439 | } |
| 440 | |
| 441 | operator std::vector<std::string>&&() && { |
| 442 | return std::move(list_); |
| 443 | } |
| 444 | |
| 445 | size_t Size() const { |
| 446 | return list_.size(); |
| 447 | } |
| 448 | |
| 449 | std::string Join() const { |
| 450 | return art::Join(list_, Separator); |
| 451 | } |
| 452 | |
| 453 | static ParseStringList<Separator> Split(const std::string& str) { |
| 454 | std::vector<std::string> list; |
| 455 | art::Split(str, Separator, &list); |
| 456 | return ParseStringList<Separator>(std::move(list)); |
| 457 | } |
| 458 | |
| 459 | ParseStringList() = default; |
Andreas Gampe | c801f0d | 2015-02-24 20:55:16 -0800 | [diff] [blame] | 460 | ParseStringList(const ParseStringList&) = default; |
| 461 | ParseStringList(ParseStringList&&) = default; |
Igor Murashkin | aaebaa0 | 2015-01-26 10:55:53 -0800 | [diff] [blame] | 462 | |
| 463 | private: |
| 464 | std::vector<std::string> list_; |
| 465 | }; |
| 466 | |
| 467 | template <char Separator> |
| 468 | struct CmdlineType<ParseStringList<Separator>> : CmdlineTypeParser<ParseStringList<Separator>> { |
| 469 | using Result = CmdlineParseResult<ParseStringList<Separator>>; |
| 470 | |
| 471 | Result Parse(const std::string& args) { |
| 472 | return Result::Success(ParseStringList<Separator>::Split(args)); |
| 473 | } |
| 474 | |
| 475 | static const char* Name() { return "ParseStringList<Separator>"; } |
| 476 | }; |
| 477 | |
| 478 | static gc::CollectorType ParseCollectorType(const std::string& option) { |
| 479 | if (option == "MS" || option == "nonconcurrent") { |
| 480 | return gc::kCollectorTypeMS; |
| 481 | } else if (option == "CMS" || option == "concurrent") { |
| 482 | return gc::kCollectorTypeCMS; |
| 483 | } else if (option == "SS") { |
| 484 | return gc::kCollectorTypeSS; |
| 485 | } else if (option == "GSS") { |
| 486 | return gc::kCollectorTypeGSS; |
| 487 | } else if (option == "CC") { |
| 488 | return gc::kCollectorTypeCC; |
| 489 | } else if (option == "MC") { |
| 490 | return gc::kCollectorTypeMC; |
| 491 | } else { |
| 492 | return gc::kCollectorTypeNone; |
| 493 | } |
| 494 | } |
| 495 | |
| 496 | struct XGcOption { |
| 497 | // These defaults are used when the command line arguments for -Xgc: |
| 498 | // are either omitted completely or partially. |
Hiroshi Yamauchi | 1b0adbf | 2016-11-14 17:35:12 -0800 | [diff] [blame] | 499 | gc::CollectorType collector_type_ = gc::kCollectorTypeDefault; |
Igor Murashkin | aaebaa0 | 2015-01-26 10:55:53 -0800 | [diff] [blame] | 500 | bool verify_pre_gc_heap_ = false; |
| 501 | bool verify_pre_sweeping_heap_ = kIsDebugBuild; |
| 502 | bool verify_post_gc_heap_ = false; |
| 503 | bool verify_pre_gc_rosalloc_ = kIsDebugBuild; |
| 504 | bool verify_pre_sweeping_rosalloc_ = false; |
| 505 | bool verify_post_gc_rosalloc_ = false; |
Hiroshi Yamauchi | a9b296c | 2016-10-07 17:07:03 -0700 | [diff] [blame] | 506 | // Do no measurements for kUseTableLookupReadBarrier to avoid test timeouts. b/31679493 |
| 507 | bool measure_ = kIsDebugBuild && !kUseTableLookupReadBarrier; |
Mathieu Chartier | 3100080 | 2015-06-14 14:14:37 -0700 | [diff] [blame] | 508 | bool gcstress_ = false; |
Igor Murashkin | aaebaa0 | 2015-01-26 10:55:53 -0800 | [diff] [blame] | 509 | }; |
| 510 | |
| 511 | template <> |
| 512 | struct CmdlineType<XGcOption> : CmdlineTypeParser<XGcOption> { |
| 513 | Result Parse(const std::string& option) { // -Xgc: already stripped |
| 514 | XGcOption xgc{}; // NOLINT [readability/braces] [4] |
| 515 | |
| 516 | std::vector<std::string> gc_options; |
| 517 | Split(option, ',', &gc_options); |
| 518 | for (const std::string& gc_option : gc_options) { |
| 519 | gc::CollectorType collector_type = ParseCollectorType(gc_option); |
| 520 | if (collector_type != gc::kCollectorTypeNone) { |
| 521 | xgc.collector_type_ = collector_type; |
| 522 | } else if (gc_option == "preverify") { |
| 523 | xgc.verify_pre_gc_heap_ = true; |
| 524 | } else if (gc_option == "nopreverify") { |
| 525 | xgc.verify_pre_gc_heap_ = false; |
| 526 | } else if (gc_option == "presweepingverify") { |
| 527 | xgc.verify_pre_sweeping_heap_ = true; |
| 528 | } else if (gc_option == "nopresweepingverify") { |
| 529 | xgc.verify_pre_sweeping_heap_ = false; |
| 530 | } else if (gc_option == "postverify") { |
| 531 | xgc.verify_post_gc_heap_ = true; |
| 532 | } else if (gc_option == "nopostverify") { |
| 533 | xgc.verify_post_gc_heap_ = false; |
| 534 | } else if (gc_option == "preverify_rosalloc") { |
| 535 | xgc.verify_pre_gc_rosalloc_ = true; |
| 536 | } else if (gc_option == "nopreverify_rosalloc") { |
| 537 | xgc.verify_pre_gc_rosalloc_ = false; |
| 538 | } else if (gc_option == "presweepingverify_rosalloc") { |
| 539 | xgc.verify_pre_sweeping_rosalloc_ = true; |
| 540 | } else if (gc_option == "nopresweepingverify_rosalloc") { |
| 541 | xgc.verify_pre_sweeping_rosalloc_ = false; |
| 542 | } else if (gc_option == "postverify_rosalloc") { |
| 543 | xgc.verify_post_gc_rosalloc_ = true; |
| 544 | } else if (gc_option == "nopostverify_rosalloc") { |
| 545 | xgc.verify_post_gc_rosalloc_ = false; |
Mathieu Chartier | 3100080 | 2015-06-14 14:14:37 -0700 | [diff] [blame] | 546 | } else if (gc_option == "gcstress") { |
| 547 | xgc.gcstress_ = true; |
| 548 | } else if (gc_option == "nogcstress") { |
| 549 | xgc.gcstress_ = false; |
Mathieu Chartier | 56fe258 | 2016-07-14 13:30:03 -0700 | [diff] [blame] | 550 | } else if (gc_option == "measure") { |
| 551 | xgc.measure_ = true; |
Igor Murashkin | aaebaa0 | 2015-01-26 10:55:53 -0800 | [diff] [blame] | 552 | } else if ((gc_option == "precise") || |
| 553 | (gc_option == "noprecise") || |
| 554 | (gc_option == "verifycardtable") || |
| 555 | (gc_option == "noverifycardtable")) { |
| 556 | // Ignored for backwards compatibility. |
| 557 | } else { |
| 558 | return Result::Usage(std::string("Unknown -Xgc option ") + gc_option); |
| 559 | } |
| 560 | } |
| 561 | |
| 562 | return Result::Success(std::move(xgc)); |
| 563 | } |
| 564 | |
| 565 | static const char* Name() { return "XgcOption"; } |
| 566 | }; |
| 567 | |
| 568 | struct BackgroundGcOption { |
| 569 | // If background_collector_type_ is kCollectorTypeNone, it defaults to the |
| 570 | // XGcOption::collector_type_ after parsing options. If you set this to |
| 571 | // kCollectorTypeHSpaceCompact then we will do an hspace compaction when |
| 572 | // we transition to background instead of a normal collector transition. |
| 573 | gc::CollectorType background_collector_type_; |
| 574 | |
| 575 | BackgroundGcOption(gc::CollectorType background_collector_type) // NOLINT [runtime/explicit] [5] |
| 576 | : background_collector_type_(background_collector_type) {} |
| 577 | BackgroundGcOption() |
| 578 | : background_collector_type_(gc::kCollectorTypeNone) { |
Igor Murashkin | aaebaa0 | 2015-01-26 10:55:53 -0800 | [diff] [blame] | 579 | } |
| 580 | |
| 581 | operator gc::CollectorType() const { return background_collector_type_; } |
| 582 | }; |
| 583 | |
| 584 | template<> |
| 585 | struct CmdlineType<BackgroundGcOption> |
| 586 | : CmdlineTypeParser<BackgroundGcOption>, private BackgroundGcOption { |
| 587 | Result Parse(const std::string& substring) { |
| 588 | // Special handling for HSpaceCompact since this is only valid as a background GC type. |
| 589 | if (substring == "HSpaceCompact") { |
| 590 | background_collector_type_ = gc::kCollectorTypeHomogeneousSpaceCompact; |
| 591 | } else { |
| 592 | gc::CollectorType collector_type = ParseCollectorType(substring); |
| 593 | if (collector_type != gc::kCollectorTypeNone) { |
| 594 | background_collector_type_ = collector_type; |
| 595 | } else { |
| 596 | return Result::Failure(); |
| 597 | } |
| 598 | } |
| 599 | |
| 600 | BackgroundGcOption res = *this; |
| 601 | return Result::Success(res); |
| 602 | } |
| 603 | |
| 604 | static const char* Name() { return "BackgroundGcOption"; } |
| 605 | }; |
| 606 | |
| 607 | template <> |
| 608 | struct CmdlineType<LogVerbosity> : CmdlineTypeParser<LogVerbosity> { |
| 609 | Result Parse(const std::string& options) { |
| 610 | LogVerbosity log_verbosity = LogVerbosity(); |
| 611 | |
| 612 | std::vector<std::string> verbose_options; |
| 613 | Split(options, ',', &verbose_options); |
| 614 | for (size_t j = 0; j < verbose_options.size(); ++j) { |
| 615 | if (verbose_options[j] == "class") { |
| 616 | log_verbosity.class_linker = true; |
Mathieu Chartier | 66a5539 | 2016-02-19 10:25:39 -0800 | [diff] [blame] | 617 | } else if (verbose_options[j] == "collector") { |
| 618 | log_verbosity.collector = true; |
Igor Murashkin | aaebaa0 | 2015-01-26 10:55:53 -0800 | [diff] [blame] | 619 | } else if (verbose_options[j] == "compiler") { |
| 620 | log_verbosity.compiler = true; |
Andreas Gampe | f3d1f94 | 2015-05-18 21:41:13 -0700 | [diff] [blame] | 621 | } else if (verbose_options[j] == "deopt") { |
| 622 | log_verbosity.deopt = true; |
Igor Murashkin | aaebaa0 | 2015-01-26 10:55:53 -0800 | [diff] [blame] | 623 | } else if (verbose_options[j] == "gc") { |
| 624 | log_verbosity.gc = true; |
| 625 | } else if (verbose_options[j] == "heap") { |
| 626 | log_verbosity.heap = true; |
| 627 | } else if (verbose_options[j] == "jdwp") { |
| 628 | log_verbosity.jdwp = true; |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 629 | } else if (verbose_options[j] == "jit") { |
| 630 | log_verbosity.jit = true; |
Igor Murashkin | aaebaa0 | 2015-01-26 10:55:53 -0800 | [diff] [blame] | 631 | } else if (verbose_options[j] == "jni") { |
| 632 | log_verbosity.jni = true; |
| 633 | } else if (verbose_options[j] == "monitor") { |
| 634 | log_verbosity.monitor = true; |
Richard Uhler | 66d874d | 2015-01-15 09:37:19 -0800 | [diff] [blame] | 635 | } else if (verbose_options[j] == "oat") { |
| 636 | log_verbosity.oat = true; |
Igor Murashkin | aaebaa0 | 2015-01-26 10:55:53 -0800 | [diff] [blame] | 637 | } else if (verbose_options[j] == "profiler") { |
| 638 | log_verbosity.profiler = true; |
| 639 | } else if (verbose_options[j] == "signals") { |
| 640 | log_verbosity.signals = true; |
Phil Wang | 751beff | 2015-08-28 15:17:15 +0800 | [diff] [blame] | 641 | } else if (verbose_options[j] == "simulator") { |
| 642 | log_verbosity.simulator = true; |
Igor Murashkin | aaebaa0 | 2015-01-26 10:55:53 -0800 | [diff] [blame] | 643 | } else if (verbose_options[j] == "startup") { |
| 644 | log_verbosity.startup = true; |
| 645 | } else if (verbose_options[j] == "third-party-jni") { |
| 646 | log_verbosity.third_party_jni = true; |
| 647 | } else if (verbose_options[j] == "threads") { |
| 648 | log_verbosity.threads = true; |
| 649 | } else if (verbose_options[j] == "verifier") { |
| 650 | log_verbosity.verifier = true; |
Mathieu Chartier | fbc3108 | 2016-01-24 11:59:56 -0800 | [diff] [blame] | 651 | } else if (verbose_options[j] == "image") { |
| 652 | log_verbosity.image = true; |
Andreas Gampe | c7ed09b | 2016-04-25 20:08:55 -0700 | [diff] [blame] | 653 | } else if (verbose_options[j] == "systrace-locks") { |
| 654 | log_verbosity.systrace_lock_logging = true; |
Alex Light | 7233c7e | 2016-07-28 10:07:45 -0700 | [diff] [blame] | 655 | } else if (verbose_options[j] == "agents") { |
| 656 | log_verbosity.agents = true; |
Igor Murashkin | aaebaa0 | 2015-01-26 10:55:53 -0800 | [diff] [blame] | 657 | } else { |
| 658 | return Result::Usage(std::string("Unknown -verbose option ") + verbose_options[j]); |
| 659 | } |
| 660 | } |
| 661 | |
| 662 | return Result::Success(log_verbosity); |
| 663 | } |
| 664 | |
| 665 | static const char* Name() { return "LogVerbosity"; } |
| 666 | }; |
| 667 | |
Igor Murashkin | aaebaa0 | 2015-01-26 10:55:53 -0800 | [diff] [blame] | 668 | template <> |
Calin Juravle | 138dbff | 2016-06-28 19:36:58 +0100 | [diff] [blame] | 669 | struct CmdlineType<ProfileSaverOptions> : CmdlineTypeParser<ProfileSaverOptions> { |
| 670 | using Result = CmdlineParseResult<ProfileSaverOptions>; |
Igor Murashkin | aaebaa0 | 2015-01-26 10:55:53 -0800 | [diff] [blame] | 671 | |
| 672 | private: |
| 673 | using StringResult = CmdlineParseResult<std::string>; |
| 674 | using DoubleResult = CmdlineParseResult<double>; |
| 675 | |
| 676 | template <typename T> |
Calin Juravle | 138dbff | 2016-06-28 19:36:58 +0100 | [diff] [blame] | 677 | static Result ParseInto(ProfileSaverOptions& options, |
| 678 | T ProfileSaverOptions::*pField, |
Igor Murashkin | aaebaa0 | 2015-01-26 10:55:53 -0800 | [diff] [blame] | 679 | CmdlineParseResult<T>&& result) { |
| 680 | assert(pField != nullptr); |
| 681 | |
| 682 | if (result.IsSuccess()) { |
| 683 | options.*pField = result.ReleaseValue(); |
| 684 | return Result::SuccessNoValue(); |
| 685 | } |
| 686 | |
| 687 | return Result::CastError(result); |
| 688 | } |
| 689 | |
Igor Murashkin | aaebaa0 | 2015-01-26 10:55:53 -0800 | [diff] [blame] | 690 | static std::string RemovePrefix(const std::string& source) { |
Andreas Gampe | ca620d7 | 2016-11-08 08:09:33 -0800 | [diff] [blame] | 691 | size_t prefix_idx = source.find(':'); |
Igor Murashkin | aaebaa0 | 2015-01-26 10:55:53 -0800 | [diff] [blame] | 692 | |
| 693 | if (prefix_idx == std::string::npos) { |
| 694 | return ""; |
| 695 | } |
| 696 | |
| 697 | return source.substr(prefix_idx + 1); |
| 698 | } |
| 699 | |
| 700 | public: |
Calin Juravle | 138dbff | 2016-06-28 19:36:58 +0100 | [diff] [blame] | 701 | Result ParseAndAppend(const std::string& option, ProfileSaverOptions& existing) { |
Igor Murashkin | aaebaa0 | 2015-01-26 10:55:53 -0800 | [diff] [blame] | 702 | // Special case which doesn't include a wildcard argument definition. |
| 703 | // We pass-it through as-is. |
Calin Juravle | 138dbff | 2016-06-28 19:36:58 +0100 | [diff] [blame] | 704 | if (option == "-Xjitsaveprofilinginfo") { |
Igor Murashkin | aaebaa0 | 2015-01-26 10:55:53 -0800 | [diff] [blame] | 705 | existing.enabled_ = true; |
| 706 | return Result::SuccessNoValue(); |
| 707 | } |
| 708 | |
Calin Juravle | 138dbff | 2016-06-28 19:36:58 +0100 | [diff] [blame] | 709 | // The rest of these options are always the wildcard from '-Xps-*' |
Igor Murashkin | aaebaa0 | 2015-01-26 10:55:53 -0800 | [diff] [blame] | 710 | std::string suffix = RemovePrefix(option); |
| 711 | |
Calin Juravle | 138dbff | 2016-06-28 19:36:58 +0100 | [diff] [blame] | 712 | if (StartsWith(option, "min-save-period-ms:")) { |
Igor Murashkin | aaebaa0 | 2015-01-26 10:55:53 -0800 | [diff] [blame] | 713 | CmdlineType<unsigned int> type_parser; |
Igor Murashkin | aaebaa0 | 2015-01-26 10:55:53 -0800 | [diff] [blame] | 714 | return ParseInto(existing, |
Calin Juravle | 138dbff | 2016-06-28 19:36:58 +0100 | [diff] [blame] | 715 | &ProfileSaverOptions::min_save_period_ms_, |
| 716 | type_parser.Parse(suffix)); |
| 717 | } |
| 718 | if (StartsWith(option, "save-resolved-classes-delay-ms:")) { |
Igor Murashkin | aaebaa0 | 2015-01-26 10:55:53 -0800 | [diff] [blame] | 719 | CmdlineType<unsigned int> type_parser; |
Igor Murashkin | aaebaa0 | 2015-01-26 10:55:53 -0800 | [diff] [blame] | 720 | return ParseInto(existing, |
Calin Juravle | 138dbff | 2016-06-28 19:36:58 +0100 | [diff] [blame] | 721 | &ProfileSaverOptions::save_resolved_classes_delay_ms_, |
| 722 | type_parser.Parse(suffix)); |
| 723 | } |
| 724 | if (StartsWith(option, "startup-method-samples:")) { |
Igor Murashkin | aaebaa0 | 2015-01-26 10:55:53 -0800 | [diff] [blame] | 725 | CmdlineType<unsigned int> type_parser; |
Igor Murashkin | aaebaa0 | 2015-01-26 10:55:53 -0800 | [diff] [blame] | 726 | return ParseInto(existing, |
Calin Juravle | 138dbff | 2016-06-28 19:36:58 +0100 | [diff] [blame] | 727 | &ProfileSaverOptions::startup_method_samples_, |
| 728 | type_parser.Parse(suffix)); |
| 729 | } |
| 730 | if (StartsWith(option, "min-methods-to-save:")) { |
Igor Murashkin | aaebaa0 | 2015-01-26 10:55:53 -0800 | [diff] [blame] | 731 | CmdlineType<unsigned int> type_parser; |
Igor Murashkin | aaebaa0 | 2015-01-26 10:55:53 -0800 | [diff] [blame] | 732 | return ParseInto(existing, |
Calin Juravle | 138dbff | 2016-06-28 19:36:58 +0100 | [diff] [blame] | 733 | &ProfileSaverOptions::min_methods_to_save_, |
| 734 | type_parser.Parse(suffix)); |
| 735 | } |
| 736 | if (StartsWith(option, "min-classes-to-save:")) { |
| 737 | CmdlineType<unsigned int> type_parser; |
| 738 | return ParseInto(existing, |
| 739 | &ProfileSaverOptions::min_classes_to_save_, |
| 740 | type_parser.Parse(suffix)); |
| 741 | } |
| 742 | if (StartsWith(option, "min-notification-before-wake:")) { |
| 743 | CmdlineType<unsigned int> type_parser; |
| 744 | return ParseInto(existing, |
| 745 | &ProfileSaverOptions::min_notification_before_wake_, |
| 746 | type_parser.Parse(suffix)); |
| 747 | } |
| 748 | if (StartsWith(option, "max-notification-before-wake:")) { |
| 749 | CmdlineType<unsigned int> type_parser; |
| 750 | return ParseInto(existing, |
| 751 | &ProfileSaverOptions::max_notification_before_wake_, |
| 752 | type_parser.Parse(suffix)); |
Igor Murashkin | aaebaa0 | 2015-01-26 10:55:53 -0800 | [diff] [blame] | 753 | } else { |
| 754 | return Result::Failure(std::string("Invalid suboption '") + option + "'"); |
| 755 | } |
| 756 | } |
| 757 | |
Calin Juravle | 138dbff | 2016-06-28 19:36:58 +0100 | [diff] [blame] | 758 | static const char* Name() { return "ProfileSaverOptions"; } |
Igor Murashkin | aaebaa0 | 2015-01-26 10:55:53 -0800 | [diff] [blame] | 759 | static constexpr bool kCanParseBlankless = true; |
| 760 | }; |
| 761 | |
Alex Light | eb7c144 | 2015-08-31 13:17:42 -0700 | [diff] [blame] | 762 | template<> |
| 763 | struct CmdlineType<ExperimentalFlags> : CmdlineTypeParser<ExperimentalFlags> { |
| 764 | Result ParseAndAppend(const std::string& option, ExperimentalFlags& existing) { |
| 765 | if (option == "none") { |
Neil Fuller | 9724c63 | 2016-01-07 15:42:47 +0000 | [diff] [blame] | 766 | existing = ExperimentalFlags::kNone; |
Alex Light | 7233c7e | 2016-07-28 10:07:45 -0700 | [diff] [blame] | 767 | } else if (option == "agents") { |
| 768 | existing = existing | ExperimentalFlags::kAgents; |
Alex Light | 185d134 | 2016-08-11 10:48:03 -0700 | [diff] [blame] | 769 | } else if (option == "runtime-plugins") { |
| 770 | existing = existing | ExperimentalFlags::kRuntimePlugins; |
Narayan Kamath | 25352fc | 2016-08-03 12:46:58 +0100 | [diff] [blame] | 771 | } else if (option == "method-handles") { |
| 772 | existing = existing | ExperimentalFlags::kMethodHandles; |
Alex Light | eb7c144 | 2015-08-31 13:17:42 -0700 | [diff] [blame] | 773 | } else { |
| 774 | return Result::Failure(std::string("Unknown option '") + option + "'"); |
| 775 | } |
| 776 | return Result::SuccessNoValue(); |
| 777 | } |
| 778 | |
| 779 | static const char* Name() { return "ExperimentalFlags"; } |
| 780 | }; |
Igor Murashkin | aaebaa0 | 2015-01-26 10:55:53 -0800 | [diff] [blame] | 781 | |
| 782 | } // namespace art |
| 783 | #endif // ART_CMDLINE_CMDLINE_TYPES_H_ |