37 #if V8_TARGET_ARCH_ARM
45 #define FLAG_MODE_DEFINE
49 #define FLAG_MODE_DEFINE_DEFAULTS
58 enum FlagType { TYPE_BOOL, TYPE_MAYBE_BOOL, TYPE_INT, TYPE_FLOAT,
59 TYPE_STRING, TYPE_ARGS };
68 FlagType type()
const {
return type_; }
70 const char*
name()
const {
return name_; }
72 const char* comment()
const {
return cmt_; }
74 bool* bool_variable()
const {
75 ASSERT(type_ == TYPE_BOOL);
76 return reinterpret_cast<bool*
>(valptr_);
79 MaybeBoolFlag* maybe_bool_variable()
const {
80 ASSERT(type_ == TYPE_MAYBE_BOOL);
81 return reinterpret_cast<MaybeBoolFlag*
>(valptr_);
84 int* int_variable()
const {
86 return reinterpret_cast<int*
>(valptr_);
89 double* float_variable()
const {
90 ASSERT(type_ == TYPE_FLOAT);
91 return reinterpret_cast<double*
>(valptr_);
94 const char* string_value()
const {
95 ASSERT(type_ == TYPE_STRING);
96 return *
reinterpret_cast<const char**
>(valptr_);
99 void set_string_value(
const char* value,
bool owns_ptr) {
100 ASSERT(type_ == TYPE_STRING);
101 const char** ptr =
reinterpret_cast<const char**
>(valptr_);
104 owns_ptr_ = owns_ptr;
107 JSArguments* args_variable()
const {
108 ASSERT(type_ == TYPE_ARGS);
109 return reinterpret_cast<JSArguments*
>(valptr_);
112 bool bool_default()
const {
113 ASSERT(type_ == TYPE_BOOL);
114 return *
reinterpret_cast<const bool*
>(defptr_);
117 int int_default()
const {
118 ASSERT(type_ == TYPE_INT);
119 return *
reinterpret_cast<const int*
>(defptr_);
122 double float_default()
const {
123 ASSERT(type_ == TYPE_FLOAT);
124 return *
reinterpret_cast<const double*
>(defptr_);
127 const char* string_default()
const {
128 ASSERT(type_ == TYPE_STRING);
129 return *
reinterpret_cast<const char*
const *
>(defptr_);
132 JSArguments args_default()
const {
133 ASSERT(type_ == TYPE_ARGS);
134 return *
reinterpret_cast<const JSArguments*
>(defptr_);
138 bool IsDefault()
const {
141 return *bool_variable() == bool_default();
142 case TYPE_MAYBE_BOOL:
143 return maybe_bool_variable()->has_value ==
false;
145 return *int_variable() == int_default();
147 return *float_variable() == float_default();
149 const char* str1 = string_value();
150 const char* str2 = string_default();
151 if (str2 ==
NULL)
return str1 ==
NULL;
152 if (str1 ==
NULL)
return str2 ==
NULL;
153 return strcmp(str1, str2) == 0;
156 return args_variable()->argc == 0;
166 *bool_variable() = bool_default();
168 case TYPE_MAYBE_BOOL:
172 *int_variable() = int_default();
175 *float_variable() = float_default();
178 set_string_value(string_default(),
false);
181 *args_variable() = args_default();
188 #define FLAG_MODE_META
192 const size_t num_flags =
sizeof(
flags) /
sizeof(*flags);
197 static const char* Type2String(Flag::FlagType type) {
199 case Flag::TYPE_BOOL:
return "bool";
200 case Flag::TYPE_MAYBE_BOOL:
return "maybe_bool";
201 case Flag::TYPE_INT:
return "int";
202 case Flag::TYPE_FLOAT:
return "float";
203 case Flag::TYPE_STRING:
return "string";
204 case Flag::TYPE_ARGS:
return "arguments";
214 switch (flag->type()) {
215 case Flag::TYPE_BOOL:
216 buffer.
Add(
"%s", (*flag->bool_variable() ?
"true" :
"false"));
218 case Flag::TYPE_MAYBE_BOOL:
219 buffer.
Add(
"%s", flag->maybe_bool_variable()->has_value
220 ? (flag->maybe_bool_variable()->value ?
"true" :
"false")
224 buffer.
Add(
"%d", *flag->int_variable());
226 case Flag::TYPE_FLOAT:
227 buffer.
Add(
"%f",
FmtElm(*flag->float_variable()));
229 case Flag::TYPE_STRING: {
230 const char* str = flag->string_value();
231 buffer.
Add(
"%s", str ? str :
"NULL");
234 case Flag::TYPE_ARGS: {
237 buffer.
Add(
"%s", args[0]);
238 for (
int i = 1; i < args.
argc; i++) {
239 buffer.
Add(
" %s", args[i]);
250 List<const char*>* FlagList::argv() {
251 List<const char*>* args =
new List<const char*>(8);
252 Flag* args_flag =
NULL;
253 for (
size_t i = 0; i < num_flags; ++i) {
255 if (!f->IsDefault()) {
256 if (f->type() == Flag::TYPE_ARGS) {
261 HeapStringAllocator string_allocator;
262 StringStream buffer(&string_allocator);
263 if (f->type() != Flag::TYPE_BOOL || *(f->bool_variable())) {
264 buffer.Add(
"--%s", f->name());
266 buffer.Add(
"--no%s", f->name());
268 args->Add(buffer.ToCString().Detach());
269 if (f->type() != Flag::TYPE_BOOL) {
270 args->Add(ToString(f).Detach());
274 if (args_flag !=
NULL) {
275 HeapStringAllocator string_allocator;
276 StringStream buffer(&string_allocator);
277 buffer.Add(
"--%s", args_flag->name());
278 args->Add(buffer.ToCString().Detach());
279 JSArguments jsargs = *args_flag->args_variable();
280 for (
int j = 0; j < jsargs.argc; j++) {
281 args->Add(
StrDup(jsargs[j]));
289 return ch ==
'_' ?
'-' : ch;
297 static void SplitArgument(
const char* arg,
307 if (arg !=
NULL && *arg ==
'-') {
312 if (arg[0] ==
'\0') {
313 const char* kJSArgumentsFlagName =
"js_arguments";
314 *name = kJSArgumentsFlagName;
318 if (arg[0] ==
'n' && arg[1] ==
'o') {
326 while (*arg !=
'\0' && *arg !=
'=')
332 size_t n = arg - *
name;
333 CHECK(n < static_cast<size_t>(buffer_size));
344 static bool EqualNames(
const char* a,
const char* b) {
354 static Flag* FindFlag(
const char* name) {
355 for (
size_t i = 0; i < num_flags; ++i) {
356 if (EqualNames(name, flags[i].
name()))
364 int FlagList::SetFlagsFromCommandLine(
int* argc,
369 for (
int i = 1; i < *argc;) {
371 const char* arg = argv[i++];
378 SplitArgument(arg, buffer,
sizeof buffer, &name, &value, &is_bool);
382 Flag*
flag = FindFlag(name);
391 PrintF(stderr,
"Error: unrecognized flag %s\n"
392 "Try --help for options\n", arg);
399 if (flag->type() != Flag::TYPE_BOOL &&
400 flag->type() != Flag::TYPE_MAYBE_BOOL &&
401 flag->type() != Flag::TYPE_ARGS &&
406 PrintF(stderr,
"Error: missing value for flag %s of type %s\n"
407 "Try --help for options\n",
408 arg, Type2String(flag->type()));
415 char* endp =
const_cast<char*
>(
"");
416 switch (flag->type()) {
417 case Flag::TYPE_BOOL:
418 *flag->bool_variable() = !is_bool;
420 case Flag::TYPE_MAYBE_BOOL:
424 *flag->int_variable() = strtol(value, &endp, 10);
426 case Flag::TYPE_FLOAT:
427 *flag->float_variable() = strtod(value, &endp);
429 case Flag::TYPE_STRING:
430 flag->set_string_value(value ?
StrDup(value) :
NULL,
true);
432 case Flag::TYPE_ARGS: {
433 int start_pos = (value ==
NULL) ? i : i - 1;
434 int js_argc = *argc - start_pos;
435 const char** js_argv = NewArray<const char*>(js_argc);
437 js_argv[0] =
StrDup(value);
439 for (
int k = i; k < *argc; k++) {
440 js_argv[k - start_pos] =
StrDup(argv[k]);
449 bool is_bool_type = flag->type() == Flag::TYPE_BOOL ||
450 flag->type() == Flag::TYPE_MAYBE_BOOL;
451 if ((is_bool_type && value != NULL) || (!is_bool_type && is_bool) ||
453 PrintF(stderr,
"Error: illegal value for flag %s of type %s\n"
454 "Try --help for options\n",
455 arg, Type2String(flag->type()));
472 for (
int i = 1; i < *argc; i++) {
488 static char* SkipWhiteSpace(
char* p) {
489 while (*p !=
'\0' && isspace(*p) != 0) p++;
494 static char* SkipBlackSpace(
char* p) {
495 while (*p !=
'\0' && isspace(*p) == 0) p++;
501 int FlagList::SetFlagsFromString(
const char* str,
int len) {
503 ScopedVector<char> copy0(len + 1);
508 char* copy = SkipWhiteSpace(copy0.start());
512 for (
char* p = copy; *p !=
'\0'; argc++) {
513 p = SkipBlackSpace(p);
514 p = SkipWhiteSpace(p);
518 ScopedVector<char*> argv(argc);
522 for (
char* p = copy; *p !=
'\0'; argc++) {
524 p = SkipBlackSpace(p);
525 if (*p !=
'\0') *p++ =
'\0';
526 p = SkipWhiteSpace(p);
530 int result = SetFlagsFromCommandLine(&argc, argv.start(),
false);
537 void FlagList::ResetAllFlags() {
538 for (
size_t i = 0; i < num_flags; ++i) {
545 void FlagList::PrintHelp() {
546 #if V8_TARGET_ARCH_ARM
550 #endif // V8_TARGET_ARCH_ARM
553 printf(
" shell [options] -e string\n");
554 printf(
" execute string in V8\n");
555 printf(
" shell [options] file1 file2 ... filek\n");
556 printf(
" run JavaScript scripts in file1, file2, ..., filek\n");
557 printf(
" shell [options]\n");
558 printf(
" shell [options] --shell [file1 file2 ... filek]\n");
559 printf(
" run an interactive JavaScript shell\n");
560 printf(
" d8 [options] file1 file2 ... filek\n");
561 printf(
" d8 [options]\n");
562 printf(
" d8 [options] --shell [file1 file2 ... filek]\n");
563 printf(
" run the new debugging shell\n\n");
564 printf(
"Options:\n");
565 for (
size_t i = 0; i < num_flags; ++i) {
567 SmartArrayPointer<const char> value = ToString(f);
568 printf(
" --%s (%s)\n type: %s default: %s\n",
569 f->name(), f->comment(), Type2String(f->type()), value.get());
575 void FlagList::EnforceFlagImplications() {
576 #define FLAG_MODE_DEFINE_IMPLICATIONS
578 #undef FLAG_MODE_DEFINE_IMPLICATIONS
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter NULL
void PrintF(const char *format,...)
static void PrintFeatures()
#define ASSERT(condition)
char NormalizeChar(char ch)
kInstanceClassNameOffset flag
void Add(Vector< const char > format, Vector< FmtElm > elms)
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes number of stack frames inspected by the profiler percentage of ICs that must have type info to allow optimization 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 VFP3 instructions if available enable use of NEON instructions if 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 d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long expose natives in global object expose freeBuffer extension expose gc extension under the specified name expose externalize string extension number of stack frames to capture disable builtin natives files print name of functions for which code is generated use random jit cookie to mask large constants trace lazy optimization use adaptive optimizations always try to OSR functions trace optimize function deoptimization minimum length for automatic enable preparsing maximum number of optimization attempts before giving up cache prototype transitions trace debugging JSON request response trace out of bounds accesses to external arrays trace_js_array_abuse automatically set the debug break flag when debugger commands are in the queue abort by crashing 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 statistics of the maximum memory committed for the heap in only print modified registers Don t break for ASM_UNIMPLEMENTED_BREAK macros print stack trace when an illegal exception is thrown randomize hashes to avoid predictable hash Fixed seed to use to hash property Print the time it takes to deserialize the snapshot testing_bool_flag testing_int_flag string flag tmp file in which to serialize heap Print the time it takes to lazily compile hydrogen code stubs concurrent_recompilation concurrent_sweeping Print usage including flags
static void MemCopy(void *dest, const void *src, size_t size)
static JSArguments Create(int argc, const char **argv)
static void PrintTarget()
static MaybeBoolFlag Create(bool has_value, bool value)
char * StrDup(const char *str)
SmartArrayPointer< const char > ToCString() const
void DeleteArray(T *array)
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes number of stack frames inspected by the profiler percentage of ICs that must have type info to allow optimization 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 VFP3 instructions if available enable use of NEON instructions if 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 d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long expose natives in global object expose freeBuffer extension expose gc extension under the specified name expose externalize string extension number of stack frames to capture disable builtin natives files print name of functions for which code is generated use random jit cookie to mask large constants trace lazy optimization use adaptive optimizations always try to OSR functions trace optimize function deoptimization minimum length for automatic enable preparsing maximum number of optimization attempts before giving up cache prototype transitions trace debugging JSON request response trace out of bounds accesses to external arrays trace_js_array_abuse automatically set the debug break flag when debugger commands are in the queue abort by crashing 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 statistics of the maximum memory committed for the heap in name