42 #define FLAG_MODE_DEFINE
46 #define FLAG_MODE_DEFINE_DEFAULTS
66 const char*
name()
const {
return name_; }
68 const char*
comment()
const {
return cmt_; }
71 ASSERT(type_ == TYPE_BOOL);
72 return reinterpret_cast<bool*
>(valptr_);
77 return reinterpret_cast<int*
>(valptr_);
81 ASSERT(type_ == TYPE_FLOAT);
82 return reinterpret_cast<double*
>(valptr_);
86 ASSERT(type_ == TYPE_STRING);
87 return *
reinterpret_cast<const char**
>(valptr_);
91 ASSERT(type_ == TYPE_STRING);
92 const char** ptr =
reinterpret_cast<const char**
>(valptr_);
99 ASSERT(type_ == TYPE_ARGS);
104 ASSERT(type_ == TYPE_BOOL);
105 return *
reinterpret_cast<const bool*
>(defptr_);
109 ASSERT(type_ == TYPE_INT);
110 return *
reinterpret_cast<const int*
>(defptr_);
114 ASSERT(type_ == TYPE_FLOAT);
115 return *
reinterpret_cast<const double*
>(defptr_);
119 ASSERT(type_ == TYPE_STRING);
120 return *
reinterpret_cast<const char*
const *
>(defptr_);
124 ASSERT(type_ == TYPE_ARGS);
125 return *
reinterpret_cast<const JSArguments*
>(defptr_);
132 return *bool_variable() == bool_default();
134 return *int_variable() == int_default();
136 return *float_variable() == float_default();
138 const char* str1 = string_value();
139 const char* str2 = string_default();
140 if (str2 ==
NULL)
return str1 ==
NULL;
142 return strcmp(str1, str2) == 0;
145 return args_variable()->argc() == 0;
155 *bool_variable() = bool_default();
158 *int_variable() = int_default();
161 *float_variable() = float_default();
164 set_string_value(string_default(),
false);
167 *args_variable() = args_default();
174 #define FLAG_MODE_META
183 static const char* Type2String(Flag::FlagType type) {
185 case Flag::TYPE_BOOL:
return "bool";
186 case Flag::TYPE_INT:
return "int";
187 case Flag::TYPE_FLOAT:
return "float";
188 case Flag::TYPE_STRING:
return "string";
189 case Flag::TYPE_ARGS:
return "arguments";
196 static SmartArrayPointer<const char> ToString(Flag*
flag) {
197 HeapStringAllocator string_allocator;
198 StringStream buffer(&string_allocator);
199 switch (flag->type()) {
200 case Flag::TYPE_BOOL:
201 buffer.Add(
"%s", (*flag->bool_variable() ?
"true" :
"false"));
204 buffer.Add(
"%d", *flag->int_variable());
206 case Flag::TYPE_FLOAT:
207 buffer.Add(
"%f", FmtElm(*flag->float_variable()));
209 case Flag::TYPE_STRING: {
210 const char* str = flag->string_value();
211 buffer.Add(
"%s", str ? str :
"NULL");
214 case Flag::TYPE_ARGS: {
215 JSArguments args = *flag->args_variable();
216 if (args.argc() > 0) {
217 buffer.Add(
"%s", args[0]);
218 for (
int i = 1; i < args.argc(); i++) {
219 buffer.Add(
" %s", args[i]);
225 return buffer.ToCString();
232 Flag* args_flag =
NULL;
235 if (!f->IsDefault()) {
236 if (f->type() == Flag::TYPE_ARGS) {
243 if (f->type() != Flag::TYPE_BOOL || *(f->bool_variable())) {
244 buffer.
Add(
"--%s", f->name());
246 buffer.
Add(
"--no%s", f->name());
249 if (f->type() != Flag::TYPE_BOOL) {
250 args->
Add(ToString(f).Detach());
254 if (args_flag !=
NULL) {
257 buffer.
Add(
"--%s", args_flag->name());
260 for (
int j = 0; j < jsargs.
argc(); j++) {
272 static void SplitArgument(
const char* arg,
282 if (arg !=
NULL && *arg ==
'-') {
287 if (arg[0] ==
'\0') {
288 const char* kJSArgumentsFlagName =
"js_arguments";
289 *name = kJSArgumentsFlagName;
293 if (arg[0] ==
'n' && arg[1] ==
'o') {
300 while (*arg !=
'\0' && *arg !=
'=')
306 size_t n = arg - *name;
307 CHECK(n < static_cast<size_t>(buffer_size));
308 memcpy(buffer, *name, n);
319 return ch ==
'_' ?
'-' : ch;
323 static bool EqualNames(
const char* a,
const char* b) {
333 static Flag* FindFlag(
const char* name) {
335 if (EqualNames(name, flags[i].name()))
348 for (
int i = 1; i < *argc;) {
350 const char* arg = argv[i++];
357 SplitArgument(arg, buffer,
sizeof buffer, &name, &value, &is_bool);
361 Flag* flag = FindFlag(name);
370 fprintf(stderr,
"Error: unrecognized flag %s\n"
371 "Try --help for options\n", arg);
378 if (flag->type() != Flag::TYPE_BOOL &&
379 flag->type() != Flag::TYPE_ARGS &&
384 fprintf(stderr,
"Error: missing value for flag %s of type %s\n"
385 "Try --help for options\n",
386 arg, Type2String(flag->type()));
393 char* endp =
const_cast<char*
>(
"");
394 switch (flag->type()) {
395 case Flag::TYPE_BOOL:
396 *flag->bool_variable() = !is_bool;
399 *flag->int_variable() = strtol(value, &endp, 10);
401 case Flag::TYPE_FLOAT:
402 *flag->float_variable() = strtod(value, &endp);
404 case Flag::TYPE_STRING:
405 flag->set_string_value(value ?
StrDup(value) :
NULL,
true);
407 case Flag::TYPE_ARGS: {
408 int start_pos = (value ==
NULL) ? i : i - 1;
409 int js_argc = *argc - start_pos;
410 const char** js_argv = NewArray<const char*>(js_argc);
412 js_argv[0] =
StrDup(value);
414 for (
int k = i; k < *argc; k++) {
415 js_argv[k - start_pos] =
StrDup(argv[k]);
424 if ((flag->type() == Flag::TYPE_BOOL && value !=
NULL) ||
425 (flag->type() != Flag::TYPE_BOOL && is_bool) ||
427 fprintf(stderr,
"Error: illegal value for flag %s of type %s\n"
428 "Try --help for options\n",
429 arg, Type2String(flag->type()));
446 for (
int i = 1; i < *argc; i++) {
462 static char* SkipWhiteSpace(
char* p) {
463 while (*p !=
'\0' && isspace(*p) != 0) p++;
468 static char* SkipBlackSpace(
char* p) {
469 while (*p !=
'\0' && isspace(*p) == 0) p++;
478 memcpy(copy0.
start(), str, len);
482 char* copy = SkipWhiteSpace(copy0.start());
486 for (
char* p = copy; *p !=
'\0'; argc++) {
487 p = SkipBlackSpace(p);
488 p = SkipWhiteSpace(p);
496 for (
char* p = copy; *p !=
'\0'; argc++) {
498 p = SkipBlackSpace(p);
499 if (*p !=
'\0') *p++ =
'\0';
500 p = SkipWhiteSpace(p);
521 printf(
" shell [options] -e string\n");
522 printf(
" execute string in V8\n");
523 printf(
" shell [options] file1 file2 ... filek\n");
524 printf(
" run JavaScript scripts in file1, file2, ..., filek\n");
525 printf(
" shell [options]\n");
526 printf(
" shell [options] --shell [file1 file2 ... filek]\n");
527 printf(
" run an interactive JavaScript shell\n");
528 printf(
" d8 [options] file1 file2 ... filek\n");
529 printf(
" d8 [options]\n");
530 printf(
" d8 [options] --shell [file1 file2 ... filek]\n");
531 printf(
" run the new debugging shell\n\n");
532 printf(
"Options:\n");
536 printf(
" --%s (%s)\n type: %s default: %s\n",
537 f->name(), f->comment(), Type2String(f->type()), *value);
543 #define FLAG_MODE_DEFINE_IMPLICATIONS
JSArguments * args_variable() const
static void ResetAllFlags()
#define ASSERT(condition)
char NormalizeChar(char ch)
int * int_variable() const
static void EnforceFlagImplications()
double float_default() const
void Add(Vector< const char > format, Vector< FmtElm > elms)
double * float_variable() const
const char * string_value() const
static JSArguments Create(int argc, const char **argv)
JSArguments args_default() const
const char * name() const
bool bool_default() const
static int SetFlagsFromString(const char *str, int len)
const char * comment() const
void Add(const T &element, AllocationPolicy allocator=AllocationPolicy())
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination use dead code elimination trace on stack replacement optimize closures cache optimized code for closures functions with arguments object loop weight for representation inference allow uint32 values on optimize frames if they are used only in safe operations track parallel recompilation enable all profiler experiments number of stack frames inspected by the profiler call recompile stub directly when self optimizing trigger profiler ticks based on counting instead of timing weight back edges by jump distance for interrupt triggering percentage of ICs that must have type info to allow optimization watch_ic_patching retry_self_opt interrupt_at_exit extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of SAHF instruction if enable use of VFP3 instructions if available this implies enabling ARMv7 and VFP2 enable use of VFP2 instructions if available enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of MIPS FPU instructions if NULL
const char * string_default() const
void set_string_value(const char *value, bool owns_ptr)
char * StrDup(const char *str)
SmartArrayPointer< const char > ToCString() const
void DeleteArray(T *array)
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination use dead code elimination trace on stack replacement optimize closures cache optimized code for closures functions with arguments object loop weight for representation inference allow uint32 values on optimize frames if they are used only in safe operations track parallel recompilation enable all profiler experiments number of stack frames inspected by the profiler call recompile stub directly when self optimizing trigger profiler ticks based on counting instead of timing weight back edges by jump distance for interrupt triggering percentage of ICs that must have type info to allow optimization watch_ic_patching retry_self_opt interrupt_at_exit extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of SAHF instruction if enable use of VFP3 instructions if available this implies enabling ARMv7 and VFP2 enable use of VFP2 instructions if available enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of MIPS FPU instructions if expose natives in global object expose gc extension number of stack frames to capture disable builtin natives files print a stack trace if an assertion failure occurs use random jit cookie to mask large constants trace lazy optimization use adaptive optimizations prepare for turning on always opt minimum length for automatic enable preparsing maximum number of optimization attempts before giving up cache prototype transitions automatically set the debug break flag when debugger commands are in the queue always cause a debug break before aborting maximum length of function source code printed in a stack trace max size of the new max size of the old max size of executable always perform global GCs print one trace line following each garbage collection do not print trace line after scavenger collection print more details following each garbage collection print amount of external allocated memory after each time it is adjusted flush code that we expect not to use again before full gc do incremental marking steps track object counts and memory usage use caching Perform compaction on every full GC Never perform compaction on full GC testing only Compact code space on full incremental collections Default seed for initializing random allows verbose printing trace parsing and preparsing Check icache flushes in ARM and MIPS simulator Stack alingment in bytes in print stack trace when throwing exceptions randomize hashes to avoid predictable hash Fixed seed to use to hash property activate a timer that switches between V8 threads testing_bool_flag float flag Seed used for threading test randomness A filename with extra code to be included in the Print usage including flags
static List< const char * > * argv()
static int SetFlagsFromCommandLine(int *argc, char **argv, bool remove_flags)
bool * bool_variable() const
kPropertyAccessorsOffset kNamedPropertyHandlerOffset kInstanceTemplateOffset kAccessCheckInfoOffset kEvalFrominstructionsOffsetOffset kInstanceClassNameOffset flag