blob: 7bf515100c6a47f7c2ff8e081ca4e8f4e83ed6dd [file] [log] [blame]
Steve Blocka7e24c12009-10-30 11:49:00 +00001// Copyright 2006-2008 the V8 project authors. All rights reserved.
Ben Murdochb8a8cc12014-11-26 15:28:44 +00002// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
Steve Blocka7e24c12009-10-30 11:49:00 +00005#ifndef V8_FLAGS_H_
6#define V8_FLAGS_H_
7
Ben Murdochb8a8cc12014-11-26 15:28:44 +00008#include "src/globals.h"
9
Steve Blocka7e24c12009-10-30 11:49:00 +000010namespace v8 {
11namespace internal {
12
13// Declare all of our flags.
14#define FLAG_MODE_DECLARE
Ben Murdochb8a8cc12014-11-26 15:28:44 +000015#include "src/flag-definitions.h" // NOLINT
Steve Blocka7e24c12009-10-30 11:49:00 +000016
17// The global list of all flags.
18class 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 Murdochb8a8cc12014-11-26 15:28:44 +000043 static int SetFlagsFromCommandLine(int* argc,
44 char** argv,
45 bool remove_flags);
Steve Blocka7e24c12009-10-30 11:49:00 +000046
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 Murdoch3ef787d2012-04-12 10:51:47 +010057
58 // Set flags as consequence of being implied by another flag.
59 static void EnforceFlagImplications();
Emily Bernierd0a1eb72015-03-24 16:35:39 -040060
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000061 // Hash of flags (to quickly determine mismatching flag expectations).
62 // This hash is calculated during V8::Initialize and cached.
Emily Bernierd0a1eb72015-03-24 16:35:39 -040063 static uint32_t Hash();
Steve Blocka7e24c12009-10-30 11:49:00 +000064};
65
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000066} // namespace internal
67} // namespace v8
Steve Blocka7e24c12009-10-30 11:49:00 +000068
69#endif // V8_FLAGS_H_