V8 Project
v8::internal::FlagList Class Reference

#include <flags.h>

+ Collaboration diagram for v8::internal::FlagList:

Static Public Member Functions

static List< const char * > * argv ()
 
static int SetFlagsFromCommandLine (int *argc, char **argv, bool remove_flags)
 
static int SetFlagsFromString (const char *str, int len)
 
static void ResetAllFlags ()
 
static void PrintHelp ()
 
static void EnforceFlagImplications ()
 

Detailed Description

Definition at line 18 of file flags.h.

Member Function Documentation

◆ argv()

List< const char * > * v8::internal::FlagList::argv ( )
static

Definition at line 221 of file flags.cc.

221  {
222  List<const char*>* args = new List<const char*>(8);
223  Flag* args_flag = NULL;
224  for (size_t i = 0; i < num_flags; ++i) {
225  Flag* f = &flags[i];
226  if (!f->IsDefault()) {
227  if (f->type() == Flag::TYPE_ARGS) {
228  DCHECK(args_flag == NULL);
229  args_flag = f; // Must be last in arguments.
230  continue;
231  }
232  {
233  bool disabled = f->type() == Flag::TYPE_BOOL && !*f->bool_variable();
234  OStringStream os;
235  os << (disabled ? "--no" : "--") << f->name();
236  args->Add(StrDup(os.c_str()));
237  }
238  if (f->type() != Flag::TYPE_BOOL) {
239  OStringStream os;
240  os << *f;
241  args->Add(StrDup(os.c_str()));
242  }
243  }
244  }
245  if (args_flag != NULL) {
246  OStringStream os;
247  os << "--" << args_flag->name();
248  args->Add(StrDup(os.c_str()));
249  JSArguments jsargs = *args_flag->args_variable();
250  for (int j = 0; j < jsargs.argc; j++) {
251  args->Add(StrDup(jsargs[j]));
252  }
253  }
254  return args;
255 }
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)
Definition: logging.h:205
char * StrDup(const char *str)
Definition: allocation.cc:67

References v8::internal::List< T, AllocationPolicy >::Add(), v8::internal::OStringStream::c_str(), DCHECK, v8::internal::anonymous_namespace{flags.cc}::flags, NULL, v8::internal::anonymous_namespace{flags.cc}::num_flags, and v8::internal::StrDup().

Referenced by SetFlagsFromCommandLine(), and SetFlagsFromString().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ EnforceFlagImplications()

void v8::internal::FlagList::EnforceFlagImplications ( )
static

Definition at line 545 of file flags.cc.

545  {
546 #define FLAG_MODE_DEFINE_IMPLICATIONS
547 #include "src/flag-definitions.h"
548 #undef FLAG_MODE_DEFINE_IMPLICATIONS
549 }

Referenced by v8::internal::V8::InitializeOncePerProcessImpl().

+ Here is the caller graph for this function:

◆ PrintHelp()

void v8::internal::FlagList::PrintHelp ( )
static

Definition at line 516 of file flags.cc.

516  {
517  CpuFeatures::Probe(false);
520 
521  OFStream os(stdout);
522  os << "Usage:\n"
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"
531  << " d8 [options]\n"
532  << " d8 [options] --shell [file1 file2 ... filek]\n"
533  << " run the new debugging shell\n\n"
534  << "Options:\n";
535  for (size_t i = 0; i < num_flags; ++i) {
536  Flag* f = &flags[i];
537  os << " --" << f->name() << " (" << f->comment() << ")\n"
538  << " type: " << Type2String(f->type()) << " default: " << *f
539  << "\n";
540  }
541 }
static void Probe(bool cross_compile)
Definition: assembler.h:172
static void PrintFeatures()
static const char * Type2String(Flag::FlagType type)
Definition: flags.cc:170

References v8::internal::anonymous_namespace{flags.cc}::flags, v8::internal::anonymous_namespace{flags.cc}::num_flags, v8::internal::CpuFeatures::PrintFeatures(), v8::internal::CpuFeatures::PrintTarget(), v8::internal::CpuFeatures::Probe(), and v8::internal::Type2String().

Referenced by main(), and SetFlagsFromCommandLine().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ResetAllFlags()

void v8::internal::FlagList::ResetAllFlags ( )
static

Definition at line 508 of file flags.cc.

508  {
509  for (size_t i = 0; i < num_flags; ++i) {
510  flags[i].Reset();
511  }
512 }

References v8::internal::anonymous_namespace{flags.cc}::flags, v8::internal::anonymous_namespace{flags.cc}::num_flags, and v8::internal::anonymous_namespace{flags.cc}::Flag::Reset().

Referenced by v8::internal::V8::TearDown().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SetFlagsFromCommandLine()

int v8::internal::FlagList::SetFlagsFromCommandLine ( int argc,
char **  argv,
bool  remove_flags 
)
static

Definition at line 334 of file flags.cc.

336  {
337  int return_code = 0;
338  // parse arguments
339  for (int i = 1; i < *argc;) {
340  int j = i; // j > 0
341  const char* arg = argv[i++];
342 
343  // split arg into flag components
344  char buffer[1*KB];
345  const char* name;
346  const char* value;
347  bool is_bool;
348  SplitArgument(arg, buffer, sizeof buffer, &name, &value, &is_bool);
349 
350  if (name != NULL) {
351  // lookup the flag
352  Flag* flag = FindFlag(name);
353  if (flag == NULL) {
354  if (remove_flags) {
355  // We don't recognize this flag but since we're removing
356  // the flags we recognize we assume that the remaining flags
357  // will be processed somewhere else so this flag might make
358  // sense there.
359  continue;
360  } else {
361  PrintF(stderr, "Error: unrecognized flag %s\n"
362  "Try --help for options\n", arg);
363  return_code = j;
364  break;
365  }
366  }
367 
368  // if we still need a flag value, use the next argument if available
369  if (flag->type() != Flag::TYPE_BOOL &&
370  flag->type() != Flag::TYPE_MAYBE_BOOL &&
371  flag->type() != Flag::TYPE_ARGS &&
372  value == NULL) {
373  if (i < *argc) {
374  value = argv[i++];
375  }
376  if (!value) {
377  PrintF(stderr, "Error: missing value for flag %s of type %s\n"
378  "Try --help for options\n",
379  arg, Type2String(flag->type()));
380  return_code = j;
381  break;
382  }
383  }
384 
385  // set the flag
386  char* endp = const_cast<char*>(""); // *endp is only read
387  switch (flag->type()) {
388  case Flag::TYPE_BOOL:
389  *flag->bool_variable() = !is_bool;
390  break;
391  case Flag::TYPE_MAYBE_BOOL:
392  *flag->maybe_bool_variable() = MaybeBoolFlag::Create(true, !is_bool);
393  break;
394  case Flag::TYPE_INT:
395  *flag->int_variable() = strtol(value, &endp, 10); // NOLINT
396  break;
397  case Flag::TYPE_FLOAT:
398  *flag->float_variable() = strtod(value, &endp);
399  break;
400  case Flag::TYPE_STRING:
401  flag->set_string_value(value ? StrDup(value) : NULL, true);
402  break;
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);
407  if (value != NULL) {
408  js_argv[0] = StrDup(value);
409  }
410  for (int k = i; k < *argc; k++) {
411  js_argv[k - start_pos] = StrDup(argv[k]);
412  }
413  *flag->args_variable() = JSArguments::Create(js_argc, js_argv);
414  i = *argc; // Consume all arguments
415  break;
416  }
417  }
418 
419  // handle errors
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) ||
423  *endp != '\0') {
424  PrintF(stderr, "Error: illegal value for flag %s of type %s\n"
425  "Try --help for options\n",
426  arg, Type2String(flag->type()));
427  return_code = j;
428  break;
429  }
430 
431  // remove the flag & value from the command
432  if (remove_flags) {
433  while (j < i) {
434  argv[j++] = NULL;
435  }
436  }
437  }
438  }
439 
440  // shrink the argument list
441  if (remove_flags) {
442  int j = 1;
443  for (int i = 1; i < *argc; i++) {
444  if (argv[i] != NULL)
445  argv[j++] = argv[i];
446  }
447  *argc = j;
448  }
449 
450  if (FLAG_help) {
451  PrintHelp();
452  exit(0);
453  }
454  // parsed all flags successfully
455  return return_code;
456 }
static void PrintHelp()
Definition: flags.cc:516
static List< const char * > * argv()
Definition: flags.cc:221
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
const int KB
Definition: globals.h:106
static Flag * FindFlag(const char *name)
Definition: flags.cc:324
void PrintF(const char *format,...)
Definition: utils.cc:80
kFeedbackVectorOffset flag
Definition: objects-inl.h:5418
static void SplitArgument(const char *arg, char *buffer, int buffer_size, const char **name, const char **value, bool *is_bool)
Definition: flags.cc:267

References argv(), v8::internal::FindFlag(), v8::internal::flag, v8::internal::KB, name, NULL, v8::internal::PrintF(), PrintHelp(), v8::internal::SplitArgument(), v8::internal::StrDup(), and v8::internal::Type2String().

Referenced by main(), v8::V8::SetFlagsFromCommandLine(), and SetFlagsFromString().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SetFlagsFromString()

int v8::internal::FlagList::SetFlagsFromString ( const char *  str,
int  len 
)
static

Definition at line 472 of file flags.cc.

472  {
473  // make a 0-terminated copy of str
474  ScopedVector<char> copy0(len + 1);
475  MemCopy(copy0.start(), str, len);
476  copy0[len] = '\0';
477 
478  // strip leading white space
479  char* copy = SkipWhiteSpace(copy0.start());
480 
481  // count the number of 'arguments'
482  int argc = 1; // be compatible with SetFlagsFromCommandLine()
483  for (char* p = copy; *p != '\0'; argc++) {
484  p = SkipBlackSpace(p);
485  p = SkipWhiteSpace(p);
486  }
487 
488  // allocate argument array
489  ScopedVector<char*> argv(argc);
490 
491  // split the flags string into arguments
492  argc = 1; // be compatible with SetFlagsFromCommandLine()
493  for (char* p = copy; *p != '\0'; argc++) {
494  argv[argc] = p;
495  p = SkipBlackSpace(p);
496  if (*p != '\0') *p++ = '\0'; // 0-terminate argument
497  p = SkipWhiteSpace(p);
498  }
499 
500  // set the flags
501  int result = SetFlagsFromCommandLine(&argc, argv.start(), false);
502 
503  return result;
504 }
static int SetFlagsFromCommandLine(int *argc, char **argv, bool remove_flags)
Definition: flags.cc:334
static char * SkipWhiteSpace(char *p)
Definition: flags.cc:459
static char * SkipBlackSpace(char *p)
Definition: flags.cc:465
void MemCopy(void *dest, const void *src, size_t size)
Definition: utils.h:350

References argv(), v8::internal::MemCopy(), SetFlagsFromCommandLine(), v8::internal::SkipBlackSpace(), v8::internal::SkipWhiteSpace(), and v8::internal::Vector< T >::start().

Referenced by v8::internal::RUNTIME_FUNCTION(), and v8::V8::SetFlagsFromString().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

The documentation for this class was generated from the following files: