Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1 | // Copyright 2006-2008 the V8 project authors. All rights reserved. |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 5 | #ifndef V8_FLAGS_H_ |
| 6 | #define V8_FLAGS_H_ |
| 7 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 8 | #include "src/globals.h" |
| 9 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 10 | namespace v8 { |
| 11 | namespace internal { |
| 12 | |
| 13 | // Declare all of our flags. |
| 14 | #define FLAG_MODE_DECLARE |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 15 | #include "src/flag-definitions.h" // NOLINT |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 16 | |
| 17 | // The global list of all flags. |
| 18 | class FlagList { |
| 19 | public: |
| 20 | // The list of all flags with a value different from the default |
| 21 | // and their values. The format of the list is like the format of the |
| 22 | // argv array passed to the main function, e.g. |
| 23 | // ("--prof", "--log-file", "v8.prof", "--nolazy"). |
| 24 | // |
| 25 | // The caller is responsible for disposing the list, as well |
| 26 | // as every element of it. |
| 27 | static List<const char*>* argv(); |
| 28 | |
| 29 | // Set the flag values by parsing the command line. If remove_flags is |
| 30 | // set, the flags and associated values are removed from (argc, |
| 31 | // argv). Returns 0 if no error occurred. Otherwise, returns the argv |
| 32 | // index > 0 for the argument where an error occurred. In that case, |
| 33 | // (argc, argv) will remain unchanged independent of the remove_flags |
| 34 | // value, and no assumptions about flag settings should be made. |
| 35 | // |
| 36 | // The following syntax for flags is accepted (both '-' and '--' are ok): |
| 37 | // |
| 38 | // --flag (bool flags only) |
| 39 | // --noflag (bool flags only) |
| 40 | // --flag=value (non-bool flags only, no spaces around '=') |
| 41 | // --flag value (non-bool flags only) |
| 42 | // -- (equivalent to --js_arguments, captures all remaining args) |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 43 | static int SetFlagsFromCommandLine(int* argc, |
| 44 | char** argv, |
| 45 | bool remove_flags); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 46 | |
| 47 | // Set the flag values by parsing the string str. Splits string into argc |
| 48 | // substrings argv[], each of which consisting of non-white-space chars, |
| 49 | // and then calls SetFlagsFromCommandLine() and returns its result. |
| 50 | static int SetFlagsFromString(const char* str, int len); |
| 51 | |
| 52 | // Reset all flags to their default value. |
| 53 | static void ResetAllFlags(); |
| 54 | |
| 55 | // Print help to stdout with flags, types, and default values. |
| 56 | static void PrintHelp(); |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 57 | |
| 58 | // Set flags as consequence of being implied by another flag. |
| 59 | static void EnforceFlagImplications(); |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 60 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 61 | // Hash of flags (to quickly determine mismatching flag expectations). |
| 62 | // This hash is calculated during V8::Initialize and cached. |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 63 | static uint32_t Hash(); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 64 | }; |
| 65 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 66 | } // namespace internal |
| 67 | } // namespace v8 |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 68 | |
| 69 | #endif // V8_FLAGS_H_ |