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