18 #define FLAG_MODE_DEFINE
22 #define FLAG_MODE_DEFINE_DEFAULTS
31 enum FlagType { TYPE_BOOL, TYPE_MAYBE_BOOL, TYPE_INT, TYPE_FLOAT,
32 TYPE_STRING, TYPE_ARGS };
43 const char*
name()
const {
return name_; }
45 const char*
comment()
const {
return cmt_; }
48 DCHECK(type_ == TYPE_BOOL);
49 return reinterpret_cast<bool*
>(valptr_);
53 DCHECK(type_ == TYPE_MAYBE_BOOL);
54 return reinterpret_cast<MaybeBoolFlag*
>(valptr_);
59 return reinterpret_cast<int*
>(valptr_);
63 DCHECK(type_ == TYPE_FLOAT);
64 return reinterpret_cast<double*
>(valptr_);
68 DCHECK(type_ == TYPE_STRING);
69 return *
reinterpret_cast<const char**
>(valptr_);
73 DCHECK(type_ == TYPE_STRING);
74 const char** ptr =
reinterpret_cast<const char**
>(valptr_);
81 DCHECK(type_ == TYPE_ARGS);
82 return reinterpret_cast<JSArguments*
>(valptr_);
86 DCHECK(type_ == TYPE_BOOL);
87 return *
reinterpret_cast<const bool*
>(defptr_);
92 return *
reinterpret_cast<const int*
>(defptr_);
96 DCHECK(type_ == TYPE_FLOAT);
97 return *
reinterpret_cast<const double*
>(defptr_);
101 DCHECK(type_ == TYPE_STRING);
102 return *
reinterpret_cast<const char*
const *
>(defptr_);
106 DCHECK(type_ == TYPE_ARGS);
107 return *
reinterpret_cast<const JSArguments*
>(defptr_);
114 return *bool_variable() == bool_default();
115 case TYPE_MAYBE_BOOL:
116 return maybe_bool_variable()->has_value ==
false;
118 return *int_variable() == int_default();
120 return *float_variable() == float_default();
122 const char* str1 = string_value();
123 const char* str2 = string_default();
124 if (str2 ==
NULL)
return str1 ==
NULL;
125 if (str1 ==
NULL)
return str2 ==
NULL;
126 return strcmp(str1, str2) == 0;
129 return args_variable()->argc == 0;
139 *bool_variable() = bool_default();
141 case TYPE_MAYBE_BOOL:
142 *maybe_bool_variable() = MaybeBoolFlag::Create(
false,
false);
145 *int_variable() = int_default();
148 *float_variable() = float_default();
151 set_string_value(string_default(),
false);
154 *args_variable() = args_default();
161 #define FLAG_MODE_META
172 case Flag::TYPE_BOOL:
return "bool";
173 case Flag::TYPE_MAYBE_BOOL:
return "maybe_bool";
174 case Flag::TYPE_INT:
return "int";
175 case Flag::TYPE_FLOAT:
return "float";
176 case Flag::TYPE_STRING:
return "string";
177 case Flag::TYPE_ARGS:
return "arguments";
185 switch (
flag.type()) {
186 case Flag::TYPE_BOOL:
187 os << (*
flag.bool_variable() ?
"true" :
"false");
189 case Flag::TYPE_MAYBE_BOOL:
190 os << (
flag.maybe_bool_variable()->has_value
191 ? (
flag.maybe_bool_variable()->value ?
"true" :
"false")
195 os << *
flag.int_variable();
197 case Flag::TYPE_FLOAT:
198 os << *
flag.float_variable();
200 case Flag::TYPE_STRING: {
201 const char* str =
flag.string_value();
202 os << (str ? str :
"NULL");
205 case Flag::TYPE_ARGS: {
206 JSArguments args = *
flag.args_variable();
209 for (
int i = 1;
i < args.argc;
i++) {
223 Flag* args_flag =
NULL;
226 if (!f->IsDefault()) {
227 if (f->type() == Flag::TYPE_ARGS) {
233 bool disabled = f->type() == Flag::TYPE_BOOL && !*f->bool_variable();
235 os << (disabled ?
"--no" :
"--") << f->name();
238 if (f->type() != Flag::TYPE_BOOL) {
245 if (args_flag !=
NULL) {
247 os <<
"--" << args_flag->name();
249 JSArguments jsargs = *args_flag->args_variable();
250 for (
int j = 0; j < jsargs.argc; j++) {
259 return ch ==
'_' ?
'-' : ch;
277 if (arg !=
NULL && *arg ==
'-') {
282 if (arg[0] ==
'\0') {
283 const char* kJSArgumentsFlagName =
"js_arguments";
284 *
name = kJSArgumentsFlagName;
288 if (arg[0] ==
'n' && arg[1] ==
'o') {
296 while (*arg !=
'\0' && *arg !=
'=')
302 size_t n = arg - *
name;
303 CHECK(n <
static_cast<size_t>(buffer_size));
339 for (
int i = 1;
i < *argc;) {
341 const char* arg =
argv[
i++];
361 PrintF(stderr,
"Error: unrecognized flag %s\n"
362 "Try --help for options\n", arg);
369 if (
flag->type() != Flag::TYPE_BOOL &&
370 flag->type() != Flag::TYPE_MAYBE_BOOL &&
371 flag->type() != Flag::TYPE_ARGS &&
377 PrintF(stderr,
"Error: missing value for flag %s of type %s\n"
378 "Try --help for options\n",
386 char* endp =
const_cast<char*
>(
"");
387 switch (
flag->type()) {
388 case Flag::TYPE_BOOL:
389 *
flag->bool_variable() = !is_bool;
391 case Flag::TYPE_MAYBE_BOOL:
392 *
flag->maybe_bool_variable() = MaybeBoolFlag::Create(
true, !is_bool);
395 *
flag->int_variable() = strtol(value, &endp, 10);
397 case Flag::TYPE_FLOAT:
398 *
flag->float_variable() = strtod(value, &endp);
400 case Flag::TYPE_STRING:
403 case Flag::TYPE_ARGS: {
404 int start_pos = (value ==
NULL) ?
i :
i - 1;
405 int js_argc = *argc - start_pos;
406 const char** js_argv = NewArray<const char*>(js_argc);
408 js_argv[0] =
StrDup(value);
410 for (
int k =
i; k < *argc; k++) {
413 *
flag->args_variable() = JSArguments::Create(js_argc, js_argv);
420 bool is_bool_type =
flag->type() == Flag::TYPE_BOOL ||
421 flag->type() == Flag::TYPE_MAYBE_BOOL;
422 if ((is_bool_type && value !=
NULL) || (!is_bool_type && is_bool) ||
424 PrintF(stderr,
"Error: illegal value for flag %s of type %s\n"
425 "Try --help for options\n",
443 for (
int i = 1;
i < *argc;
i++) {
460 while (*p !=
'\0' && isspace(*p) != 0) p++;
466 while (*p !=
'\0' && isspace(*p) == 0) p++;
483 for (
char* p = copy; *p !=
'\0'; argc++) {
493 for (
char* p = copy; *p !=
'\0'; argc++) {
496 if (*p !=
'\0') *p++ =
'\0';
523 <<
" shell [options] -e string\n"
524 <<
" execute string in V8\n"
525 <<
" shell [options] file1 file2 ... filek\n"
526 <<
" run JavaScript scripts in file1, file2, ..., filek\n"
527 <<
" shell [options]\n"
528 <<
" shell [options] --shell [file1 file2 ... filek]\n"
529 <<
" run an interactive JavaScript shell\n"
530 <<
" d8 [options] file1 file2 ... filek\n"
532 <<
" d8 [options] --shell [file1 file2 ... filek]\n"
533 <<
" run the new debugging shell\n\n"
537 os <<
" --" << f->name() <<
" (" << f->comment() <<
")\n"
538 <<
" type: " <<
Type2String(f->type()) <<
" default: " << *f
546 #define FLAG_MODE_DEFINE_IMPLICATIONS
548 #undef FLAG_MODE_DEFINE_IMPLICATIONS
static void Probe(bool cross_compile)
static void PrintFeatures()
static void PrintTarget()
static int SetFlagsFromCommandLine(int *argc, char **argv, bool remove_flags)
static void EnforceFlagImplications()
static void ResetAllFlags()
static int SetFlagsFromString(const char *str, int len)
static List< const char * > * argv()
void Add(const T &element, AllocationPolicy allocator=AllocationPolicy())
const char * c_str() const
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be expose gc extension under the specified name show built in functions in stack traces use random jit cookie to mask large constants minimum length for automatic enable preparsing CPU profiler sampling interval in microseconds trace out of bounds accesses to external arrays default size of stack region v8 is allowed to maximum length of function source code printed in a stack trace min size of a semi the new space consists of two semi spaces print one trace line following each garbage collection do not print trace line after scavenger collection print cumulative GC statistics in name
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be NULL
#define DCHECK(condition)
void DeleteArray(T *array)
static char * SkipWhiteSpace(char *p)
static Flag * FindFlag(const char *name)
static char * SkipBlackSpace(char *p)
OStream & operator<<(OStream &os, const BasicBlockProfiler &p)
char NormalizeChar(char ch)
void PrintF(const char *format,...)
kFeedbackVectorOffset flag
static void SplitArgument(const char *arg, char *buffer, int buffer_size, const char **name, const char **value, bool *is_bool)
static const char * Type2String(Flag::FlagType type)
void MemCopy(void *dest, const void *src, size_t size)
static bool EqualNames(const char *a, const char *b)
char * StrDup(const char *str)
Debugger support for the V8 JavaScript engine.
bool bool_default() const
JSArguments * args_variable() const
int * int_variable() const
const char * string_value() const
bool * bool_variable() const
const char * name() const
double * float_variable() const
const char * comment() const
double float_default() const
MaybeBoolFlag * maybe_bool_variable() const
void set_string_value(const char *value, bool owns_ptr)
const char * string_default() const
JSArguments args_default() const