v8  3.11.10(node0.8.26)
V8 is Google's open source JavaScript engine
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
parser.h
Go to the documentation of this file.
1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 
28 #ifndef V8_PARSER_H_
29 #define V8_PARSER_H_
30 
31 #include "allocation.h"
32 #include "ast.h"
33 #include "preparse-data-format.h"
34 #include "preparse-data.h"
35 #include "scopes.h"
36 #include "preparser.h"
37 
38 namespace v8 {
39 namespace internal {
40 
41 class CompilationInfo;
42 class FuncNameInferrer;
43 class ParserLog;
44 class PositionStack;
45 class Target;
46 
47 template <typename T> class ZoneListWrapper;
48 
49 
50 class ParserMessage : public Malloced {
51  public:
54  : loc_(loc),
55  message_(message),
56  args_(args) { }
58  Scanner::Location location() { return loc_; }
59  const char* message() { return message_; }
60  Vector<const char*> args() { return args_; }
61  private:
62  Scanner::Location loc_;
63  const char* message_;
64  Vector<const char*> args_;
65 };
66 
67 
68 class FunctionEntry BASE_EMBEDDED {
69  public:
70  enum {
76  kSize
77  };
78 
79  explicit FunctionEntry(Vector<unsigned> backing)
80  : backing_(backing) { }
81 
82  FunctionEntry() : backing_() { }
83 
84  int start_pos() { return backing_[kStartPositionIndex]; }
85  int end_pos() { return backing_[kEndPositionIndex]; }
86  int literal_count() { return backing_[kLiteralCountIndex]; }
87  int property_count() { return backing_[kPropertyCountIndex]; }
89  ASSERT(backing_[kLanguageModeIndex] == CLASSIC_MODE ||
90  backing_[kLanguageModeIndex] == STRICT_MODE ||
91  backing_[kLanguageModeIndex] == EXTENDED_MODE);
92  return static_cast<LanguageMode>(backing_[kLanguageModeIndex]);
93  }
94 
95  bool is_valid() { return !backing_.is_empty(); }
96 
97  private:
98  Vector<unsigned> backing_;
99  bool owns_data_;
100 };
101 
102 
103 class ScriptDataImpl : public ScriptData {
104  public:
106  : store_(store),
107  owns_store_(true) { }
108 
109  // Create an empty ScriptDataImpl that is guaranteed to not satisfy
110  // a SanityCheck.
111  ScriptDataImpl() : owns_store_(false) { }
112 
113  virtual ~ScriptDataImpl();
114  virtual int Length();
115  virtual const char* Data();
116  virtual bool HasError();
117 
118  void Initialize();
119  void ReadNextSymbolPosition();
120 
121  FunctionEntry GetFunctionEntry(int start);
122  int GetSymbolIdentifier();
123  bool SanityCheck();
124 
126  const char* BuildMessage();
128 
129  int symbol_count() {
130  return (store_.length() > PreparseDataConstants::kHeaderSize)
132  : 0;
133  }
134  // The following functions should only be called if SanityCheck has
135  // returned true.
137  unsigned magic() { return store_[PreparseDataConstants::kMagicOffset]; }
138  unsigned version() { return store_[PreparseDataConstants::kVersionOffset]; }
139 
140  private:
141  Vector<unsigned> store_;
142  unsigned char* symbol_data_;
143  unsigned char* symbol_data_end_;
144  int function_index_;
145  bool owns_store_;
146 
147  unsigned Read(int position);
148  unsigned* ReadAddress(int position);
149  // Reads a number from the current symbols
150  int ReadNumber(byte** source);
151 
152  ScriptDataImpl(const char* backing_store, int length)
153  : store_(reinterpret_cast<unsigned*>(const_cast<char*>(backing_store)),
154  length / static_cast<int>(sizeof(unsigned))),
155  owns_store_(false) {
156  ASSERT_EQ(0, static_cast<int>(
157  reinterpret_cast<intptr_t>(backing_store) % sizeof(unsigned)));
158  }
159 
160  // Read strings written by ParserRecorder::WriteString.
161  static const char* ReadString(unsigned* start, int* chars);
162 
163  friend class ScriptData;
164 };
165 
166 
167 class ParserApi {
168  public:
169  // Parses the source code represented by the compilation info and sets its
170  // function literal. Returns false (and deallocates any allocated AST
171  // nodes) if parsing failed.
172  static bool Parse(CompilationInfo* info, int flags);
173 
174  // Generic preparser generating full preparse data.
176  v8::Extension* extension,
177  int flags);
178 
179  // Preparser that only does preprocessing that makes sense if only used
180  // immediately after.
182  v8::Extension* extension,
183  int flags);
184 };
185 
186 // ----------------------------------------------------------------------------
187 // REGEXP PARSING
188 
189 // A BufferedZoneList is an automatically growing list, just like (and backed
190 // by) a ZoneList, that is optimized for the case of adding and removing
191 // a single element. The last element added is stored outside the backing list,
192 // and if no more than one element is ever added, the ZoneList isn't even
193 // allocated.
194 // Elements must not be NULL pointers.
195 template <typename T, int initial_size>
197  public:
198  BufferedZoneList() : list_(NULL), last_(NULL) {}
199 
200  // Adds element at end of list. This element is buffered and can
201  // be read using last() or removed using RemoveLast until a new Add or until
202  // RemoveLast or GetList has been called.
203  void Add(T* value, Zone* zone) {
204  if (last_ != NULL) {
205  if (list_ == NULL) {
206  list_ = new(zone) ZoneList<T*>(initial_size, zone);
207  }
208  list_->Add(last_, zone);
209  }
210  last_ = value;
211  }
212 
213  T* last() {
214  ASSERT(last_ != NULL);
215  return last_;
216  }
217 
219  ASSERT(last_ != NULL);
220  T* result = last_;
221  if ((list_ != NULL) && (list_->length() > 0))
222  last_ = list_->RemoveLast();
223  else
224  last_ = NULL;
225  return result;
226  }
227 
228  T* Get(int i) {
229  ASSERT((0 <= i) && (i < length()));
230  if (list_ == NULL) {
231  ASSERT_EQ(0, i);
232  return last_;
233  } else {
234  if (i == list_->length()) {
235  ASSERT(last_ != NULL);
236  return last_;
237  } else {
238  return list_->at(i);
239  }
240  }
241  }
242 
243  void Clear() {
244  list_ = NULL;
245  last_ = NULL;
246  }
247 
248  int length() {
249  int length = (list_ == NULL) ? 0 : list_->length();
250  return length + ((last_ == NULL) ? 0 : 1);
251  }
252 
254  if (list_ == NULL) {
255  list_ = new(zone) ZoneList<T*>(initial_size, zone);
256  }
257  if (last_ != NULL) {
258  list_->Add(last_, zone);
259  last_ = NULL;
260  }
261  return list_;
262  }
263 
264  private:
265  ZoneList<T*>* list_;
266  T* last_;
267 };
268 
269 
270 // Accumulates RegExp atoms and assertions into lists of terms and alternatives.
271 class RegExpBuilder: public ZoneObject {
272  public:
273  explicit RegExpBuilder(Zone* zone);
274  void AddCharacter(uc16 character);
275  // "Adds" an empty expression. Does nothing except consume a
276  // following quantifier
277  void AddEmpty();
278  void AddAtom(RegExpTree* tree);
279  void AddAssertion(RegExpTree* tree);
280  void NewAlternative(); // '|'
281  void AddQuantifierToAtom(int min, int max, RegExpQuantifier::Type type);
282  RegExpTree* ToRegExp();
283 
284  private:
285  void FlushCharacters();
286  void FlushText();
287  void FlushTerms();
288  Zone* zone() const { return zone_; }
289 
290  Zone* zone_;
291  bool pending_empty_;
292  ZoneList<uc16>* characters_;
295  BufferedZoneList<RegExpTree, 2> alternatives_;
296 #ifdef DEBUG
297  enum {ADD_NONE, ADD_CHAR, ADD_TERM, ADD_ASSERT, ADD_ATOM} last_added_;
298 #define LAST(x) last_added_ = x;
299 #else
300 #define LAST(x)
301 #endif
302 };
303 
304 
306  public:
308  Handle<String>* error,
309  bool multiline_mode);
310 
311  static bool ParseRegExp(FlatStringReader* input,
312  bool multiline,
313  RegExpCompileData* result);
314 
319 
320  // Parses a {...,...} quantifier and stores the range in the given
321  // out parameters.
322  bool ParseIntervalQuantifier(int* min_out, int* max_out);
323 
324  // Parses and returns a single escaped character. The character
325  // must not be 'b' or 'B' since they are usually handle specially.
327 
328  // Checks whether the following is a length-digit hexadecimal number,
329  // and sets the value if it is.
330  bool ParseHexEscape(int length, uc32* value);
331 
333 
334  // Tries to parse the input as a back reference. If successful it
335  // stores the result in the output parameter and returns true. If
336  // it fails it will push back the characters read so the same characters
337  // can be reparsed.
338  bool ParseBackReferenceIndex(int* index_out);
339 
340  CharacterRange ParseClassAtom(uc16* char_class);
342  void Advance();
343  void Advance(int dist);
344  void Reset(int pos);
345 
346  // Reports whether the pattern might be used as a literal search string.
347  // Only use if the result of the parse is a single atom node.
348  bool simple();
349  bool contains_anchor() { return contains_anchor_; }
350  void set_contains_anchor() { contains_anchor_ = true; }
351  int captures_started() { return captures_ == NULL ? 0 : captures_->length(); }
352  int position() { return next_pos_ - 1; }
353  bool failed() { return failed_; }
354 
355  static const int kMaxCaptures = 1 << 16;
356  static const uc32 kEndMarker = (1 << 21);
357 
358  private:
359  enum SubexpressionType {
360  INITIAL,
361  CAPTURE, // All positive values represent captures.
362  POSITIVE_LOOKAHEAD,
363  NEGATIVE_LOOKAHEAD,
364  GROUPING
365  };
366 
367  class RegExpParserState : public ZoneObject {
368  public:
369  RegExpParserState(RegExpParserState* previous_state,
370  SubexpressionType group_type,
371  int disjunction_capture_index,
372  Zone* zone)
373  : previous_state_(previous_state),
374  builder_(new(zone) RegExpBuilder(zone)),
375  group_type_(group_type),
376  disjunction_capture_index_(disjunction_capture_index) {}
377  // Parser state of containing expression, if any.
378  RegExpParserState* previous_state() { return previous_state_; }
379  bool IsSubexpression() { return previous_state_ != NULL; }
380  // RegExpBuilder building this regexp's AST.
381  RegExpBuilder* builder() { return builder_; }
382  // Type of regexp being parsed (parenthesized group or entire regexp).
383  SubexpressionType group_type() { return group_type_; }
384  // Index in captures array of first capture in this sub-expression, if any.
385  // Also the capture index of this sub-expression itself, if group_type
386  // is CAPTURE.
387  int capture_index() { return disjunction_capture_index_; }
388 
389  private:
390  // Linked list implementation of stack of states.
391  RegExpParserState* previous_state_;
392  // Builder for the stored disjunction.
393  RegExpBuilder* builder_;
394  // Stored disjunction type (capture, look-ahead or grouping), if any.
395  SubexpressionType group_type_;
396  // Stored disjunction's capture index (if any).
397  int disjunction_capture_index_;
398  };
399 
400  Isolate* isolate() { return isolate_; }
401  Zone* zone() const { return isolate_->zone(); }
402 
403  uc32 current() { return current_; }
404  bool has_more() { return has_more_; }
405  bool has_next() { return next_pos_ < in()->length(); }
406  uc32 Next();
407  FlatStringReader* in() { return in_; }
408  void ScanForCaptures();
409 
410  Isolate* isolate_;
411  Handle<String>* error_;
412  ZoneList<RegExpCapture*>* captures_;
413  FlatStringReader* in_;
414  uc32 current_;
415  int next_pos_;
416  // The capture count is only valid after we have scanned for captures.
417  int capture_count_;
418  bool has_more_;
419  bool multiline_;
420  bool simple_;
421  bool contains_anchor_;
422  bool is_scanned_for_captures_;
423  bool failed_;
424 };
425 
426 // ----------------------------------------------------------------------------
427 // JAVASCRIPT PARSING
428 
429 // Forward declaration.
430 class SingletonLogger;
431 
432 class Parser {
433  public:
434  Parser(Handle<Script> script,
435  int parsing_flags, // Combination of ParsingFlags
436  v8::Extension* extension,
437  ScriptDataImpl* pre_data,
438  Zone* zone);
439  virtual ~Parser() {
440  delete reusable_preparser_;
441  reusable_preparser_ = NULL;
442  }
443 
444  // Returns NULL if parsing failed.
445  FunctionLiteral* ParseProgram(CompilationInfo* info);
446  FunctionLiteral* ParseLazy(CompilationInfo* info);
447 
449  const char* message,
450  Vector<const char*> args);
452  const char* message,
453  Vector<Handle<String> > args);
454 
455  private:
456  // Limit on number of function parameters is chosen arbitrarily.
457  // Code::Flags uses only the low 17 bits of num-parameters to
458  // construct a hashable id, so if more than 2^17 are allowed, this
459  // should be checked.
460  static const int kMaxNumFunctionParameters = 32766;
461  static const int kMaxNumFunctionLocals = 32767;
462 
463  enum Mode {
464  PARSE_LAZILY,
465  PARSE_EAGERLY
466  };
467 
468  enum VariableDeclarationContext {
469  kModuleElement,
470  kBlockElement,
471  kStatement,
472  kForStatement
473  };
474 
475  // If a list of variable declarations includes any initializers.
476  enum VariableDeclarationProperties {
477  kHasInitializers,
478  kHasNoInitializers
479  };
480 
481  class BlockState;
482 
484  public:
485  FunctionState(Parser* parser,
486  Scope* scope,
487  Isolate* isolate);
488  ~FunctionState();
489 
490  int NextMaterializedLiteralIndex() {
491  return next_materialized_literal_index_++;
492  }
493  int materialized_literal_count() {
494  return next_materialized_literal_index_ - JSFunction::kLiteralsPrefixSize;
495  }
496 
497  int NextHandlerIndex() { return next_handler_index_++; }
498  int handler_count() { return next_handler_index_; }
499 
500  void SetThisPropertyAssignmentInfo(
501  bool only_simple_this_property_assignments,
502  Handle<FixedArray> this_property_assignments) {
503  only_simple_this_property_assignments_ =
504  only_simple_this_property_assignments;
505  this_property_assignments_ = this_property_assignments;
506  }
507  bool only_simple_this_property_assignments() {
508  return only_simple_this_property_assignments_;
509  }
510  Handle<FixedArray> this_property_assignments() {
511  return this_property_assignments_;
512  }
513 
514  void AddProperty() { expected_property_count_++; }
515  int expected_property_count() { return expected_property_count_; }
516 
517  AstNodeFactory<AstConstructionVisitor>* factory() { return &factory_; }
518 
519  private:
520  // Used to assign an index to each literal that needs materialization in
521  // the function. Includes regexp literals, and boilerplate for object and
522  // array literals.
523  int next_materialized_literal_index_;
524 
525  // Used to assign a per-function index to try and catch handlers.
526  int next_handler_index_;
527 
528  // Properties count estimation.
529  int expected_property_count_;
530 
531  // Keeps track of assignments to properties of this. Used for
532  // optimizing constructors.
533  bool only_simple_this_property_assignments_;
534  Handle<FixedArray> this_property_assignments_;
535 
536  Parser* parser_;
537  FunctionState* outer_function_state_;
538  Scope* outer_scope_;
539  int saved_ast_node_id_;
540  AstNodeFactory<AstConstructionVisitor> factory_;
541  };
542 
543 
544 
545 
546  FunctionLiteral* ParseLazy(CompilationInfo* info,
547  Utf16CharacterStream* source,
548  ZoneScope* zone_scope);
549 
550  Isolate* isolate() { return isolate_; }
551  Zone* zone() const { return zone_; }
552 
553  // Called by ParseProgram after setting up the scanner.
554  FunctionLiteral* DoParseProgram(CompilationInfo* info,
555  Handle<String> source,
556  ZoneScope* zone_scope);
557 
558  // Report syntax error
559  void ReportUnexpectedToken(Token::Value token);
560  void ReportInvalidPreparseData(Handle<String> name, bool* ok);
561  void ReportMessage(const char* message, Vector<const char*> args);
562  void ReportMessage(const char* message, Vector<Handle<String> > args);
563 
564  bool inside_with() const { return top_scope_->inside_with(); }
565  Scanner& scanner() { return scanner_; }
566  Mode mode() const { return mode_; }
567  ScriptDataImpl* pre_data() const { return pre_data_; }
568  bool is_extended_mode() {
569  ASSERT(top_scope_ != NULL);
570  return top_scope_->is_extended_mode();
571  }
572  Scope* DeclarationScope(VariableMode mode) {
573  return (mode == LET || mode == CONST_HARMONY)
574  ? top_scope_ : top_scope_->DeclarationScope();
575  }
576 
577  // Check if the given string is 'eval' or 'arguments'.
578  bool IsEvalOrArguments(Handle<String> string);
579 
580  // All ParseXXX functions take as the last argument an *ok parameter
581  // which is set to false if parsing failed; it is unchanged otherwise.
582  // By making the 'exception handling' explicit, we are forced to check
583  // for failure at the call sites.
584  void* ParseSourceElements(ZoneList<Statement*>* processor,
585  int end_token, bool is_eval, bool* ok);
586  Statement* ParseModuleElement(ZoneStringList* labels, bool* ok);
587  Block* ParseModuleDeclaration(ZoneStringList* names, bool* ok);
588  Module* ParseModule(bool* ok);
589  Module* ParseModuleLiteral(bool* ok);
590  Module* ParseModulePath(bool* ok);
591  Module* ParseModuleVariable(bool* ok);
592  Module* ParseModuleUrl(bool* ok);
593  Module* ParseModuleSpecifier(bool* ok);
594  Block* ParseImportDeclaration(bool* ok);
595  Statement* ParseExportDeclaration(bool* ok);
596  Statement* ParseBlockElement(ZoneStringList* labels, bool* ok);
597  Statement* ParseStatement(ZoneStringList* labels, bool* ok);
598  Statement* ParseFunctionDeclaration(ZoneStringList* names, bool* ok);
599  Statement* ParseNativeDeclaration(bool* ok);
600  Block* ParseBlock(ZoneStringList* labels, bool* ok);
601  Block* ParseVariableStatement(VariableDeclarationContext var_context,
602  ZoneStringList* names,
603  bool* ok);
604  Block* ParseVariableDeclarations(VariableDeclarationContext var_context,
605  VariableDeclarationProperties* decl_props,
606  ZoneStringList* names,
607  Handle<String>* out,
608  bool* ok);
609  Statement* ParseExpressionOrLabelledStatement(ZoneStringList* labels,
610  bool* ok);
611  IfStatement* ParseIfStatement(ZoneStringList* labels, bool* ok);
612  Statement* ParseContinueStatement(bool* ok);
613  Statement* ParseBreakStatement(ZoneStringList* labels, bool* ok);
614  Statement* ParseReturnStatement(bool* ok);
615  Statement* ParseWithStatement(ZoneStringList* labels, bool* ok);
616  CaseClause* ParseCaseClause(bool* default_seen_ptr, bool* ok);
617  SwitchStatement* ParseSwitchStatement(ZoneStringList* labels, bool* ok);
618  DoWhileStatement* ParseDoWhileStatement(ZoneStringList* labels, bool* ok);
619  WhileStatement* ParseWhileStatement(ZoneStringList* labels, bool* ok);
620  Statement* ParseForStatement(ZoneStringList* labels, bool* ok);
621  Statement* ParseThrowStatement(bool* ok);
622  Expression* MakeCatchContext(Handle<String> id, VariableProxy* value);
623  TryStatement* ParseTryStatement(bool* ok);
624  DebuggerStatement* ParseDebuggerStatement(bool* ok);
625 
626  // Support for hamony block scoped bindings.
627  Block* ParseScopedBlock(ZoneStringList* labels, bool* ok);
628 
629  Expression* ParseExpression(bool accept_IN, bool* ok);
630  Expression* ParseAssignmentExpression(bool accept_IN, bool* ok);
631  Expression* ParseConditionalExpression(bool accept_IN, bool* ok);
632  Expression* ParseBinaryExpression(int prec, bool accept_IN, bool* ok);
633  Expression* ParseUnaryExpression(bool* ok);
634  Expression* ParsePostfixExpression(bool* ok);
635  Expression* ParseLeftHandSideExpression(bool* ok);
636  Expression* ParseNewExpression(bool* ok);
637  Expression* ParseMemberExpression(bool* ok);
638  Expression* ParseNewPrefix(PositionStack* stack, bool* ok);
639  Expression* ParseMemberWithNewPrefixesExpression(PositionStack* stack,
640  bool* ok);
641  Expression* ParsePrimaryExpression(bool* ok);
642  Expression* ParseArrayLiteral(bool* ok);
643  Expression* ParseObjectLiteral(bool* ok);
644  ObjectLiteral::Property* ParseObjectLiteralGetSet(bool is_getter, bool* ok);
645  Expression* ParseRegExpLiteral(bool seen_equal, bool* ok);
646 
647  // Populate the constant properties fixed array for a materialized object
648  // literal.
649  void BuildObjectLiteralConstantProperties(
650  ZoneList<ObjectLiteral::Property*>* properties,
651  Handle<FixedArray> constants,
652  bool* is_simple,
653  bool* fast_elements,
654  int* depth);
655 
656  // Populate the literals fixed array for a materialized array literal.
657  void BuildArrayLiteralBoilerplateLiterals(ZoneList<Expression*>* properties,
658  Handle<FixedArray> constants,
659  bool* is_simple,
660  int* depth);
661 
662  // Decide if a property should be in the object boilerplate.
663  bool IsBoilerplateProperty(ObjectLiteral::Property* property);
664  // If the expression is a literal, return the literal value;
665  // if the expression is a materialized literal and is simple return a
666  // compile time value as encoded by CompileTimeValue::GetValue().
667  // Otherwise, return undefined literal as the placeholder
668  // in the object literal boilerplate.
669  Handle<Object> GetBoilerplateValue(Expression* expression);
670 
671  ZoneList<Expression*>* ParseArguments(bool* ok);
672  FunctionLiteral* ParseFunctionLiteral(Handle<String> var_name,
673  bool name_is_reserved,
674  int function_token_position,
676  bool* ok);
677 
678 
679  // Magical syntax support.
680  Expression* ParseV8Intrinsic(bool* ok);
681 
682  INLINE(Token::Value peek()) {
683  if (stack_overflow_) return Token::ILLEGAL;
684  return scanner().peek();
685  }
686 
687  INLINE(Token::Value Next()) {
688  // BUG 1215673: Find a thread safe way to set a stack limit in
689  // pre-parse mode. Otherwise, we cannot safely pre-parse from other
690  // threads.
691  if (stack_overflow_) {
692  return Token::ILLEGAL;
693  }
694  if (StackLimitCheck(isolate()).HasOverflowed()) {
695  // Any further calls to Next or peek will return the illegal token.
696  // The current call must return the next token, which might already
697  // have been peek'ed.
698  stack_overflow_ = true;
699  }
700  return scanner().Next();
701  }
702 
703  bool peek_any_identifier();
704 
705  INLINE(void Consume(Token::Value token));
706  void Expect(Token::Value token, bool* ok);
707  bool Check(Token::Value token);
708  void ExpectSemicolon(bool* ok);
709  void ExpectContextualKeyword(const char* keyword, bool* ok);
710 
711  Handle<String> LiteralString(PretenureFlag tenured) {
712  if (scanner().is_literal_ascii()) {
713  return isolate_->factory()->NewStringFromAscii(
714  scanner().literal_ascii_string(), tenured);
715  } else {
716  return isolate_->factory()->NewStringFromTwoByte(
717  scanner().literal_utf16_string(), tenured);
718  }
719  }
720 
721  Handle<String> NextLiteralString(PretenureFlag tenured) {
722  if (scanner().is_next_literal_ascii()) {
723  return isolate_->factory()->NewStringFromAscii(
724  scanner().next_literal_ascii_string(), tenured);
725  } else {
726  return isolate_->factory()->NewStringFromTwoByte(
727  scanner().next_literal_utf16_string(), tenured);
728  }
729  }
730 
731  Handle<String> GetSymbol(bool* ok);
732 
733  // Get odd-ball literals.
734  Literal* GetLiteralUndefined();
735  Literal* GetLiteralTheHole();
736 
737  Handle<String> ParseIdentifier(bool* ok);
738  Handle<String> ParseIdentifierOrStrictReservedWord(
739  bool* is_strict_reserved, bool* ok);
740  Handle<String> ParseIdentifierName(bool* ok);
741  Handle<String> ParseIdentifierNameOrGetOrSet(bool* is_get,
742  bool* is_set,
743  bool* ok);
744 
745  // Determine if the expression is a variable proxy and mark it as being used
746  // in an assignment or with a increment/decrement operator. This is currently
747  // used on for the statically checking assignments to harmony const bindings.
748  void MarkAsLValue(Expression* expression);
749 
750  // Strict mode validation of LValue expressions
751  void CheckStrictModeLValue(Expression* expression,
752  const char* error,
753  bool* ok);
754 
755  // Strict mode octal literal validation.
756  void CheckOctalLiteral(int beg_pos, int end_pos, bool* ok);
757 
758  // For harmony block scoping mode: Check if the scope has conflicting var/let
759  // declarations from different scopes. It covers for example
760  //
761  // function f() { { { var x; } let x; } }
762  // function g() { { var x; let x; } }
763  //
764  // The var declarations are hoisted to the function scope, but originate from
765  // a scope where the name has also been let bound or the var declaration is
766  // hoisted over such a scope.
767  void CheckConflictingVarDeclarations(Scope* scope, bool* ok);
768 
769  // Parser support
770  VariableProxy* NewUnresolved(Handle<String> name,
771  VariableMode mode,
772  Interface* interface = Interface::NewValue());
773  void Declare(Declaration* declaration, bool resolve, bool* ok);
774 
775  bool TargetStackContainsLabel(Handle<String> label);
776  BreakableStatement* LookupBreakTarget(Handle<String> label, bool* ok);
777  IterationStatement* LookupContinueTarget(Handle<String> label, bool* ok);
778 
779  void RegisterTargetUse(Label* target, Target* stop);
780 
781  // Factory methods.
782 
783  Scope* NewScope(Scope* parent, ScopeType type);
784 
785  Handle<String> LookupSymbol(int symbol_id);
786 
787  Handle<String> LookupCachedSymbol(int symbol_id);
788 
789  // Generate AST node that throw a ReferenceError with the given type.
790  Expression* NewThrowReferenceError(Handle<String> type);
791 
792  // Generate AST node that throw a SyntaxError with the given
793  // type. The first argument may be null (in the handle sense) in
794  // which case no arguments are passed to the constructor.
795  Expression* NewThrowSyntaxError(Handle<String> type, Handle<Object> first);
796 
797  // Generate AST node that throw a TypeError with the given
798  // type. Both arguments must be non-null (in the handle sense).
799  Expression* NewThrowTypeError(Handle<String> type,
800  Handle<Object> first,
801  Handle<Object> second);
802 
803  // Generic AST generator for throwing errors from compiled code.
804  Expression* NewThrowError(Handle<String> constructor,
805  Handle<String> type,
806  Vector< Handle<Object> > arguments);
807 
808  preparser::PreParser::PreParseResult LazyParseFunctionLiteral(
809  SingletonLogger* logger);
810 
811  AstNodeFactory<AstConstructionVisitor>* factory() {
812  return current_function_state_->factory();
813  }
814 
815  Isolate* isolate_;
816  ZoneList<Handle<String> > symbol_cache_;
817 
818  Handle<Script> script_;
819  Scanner scanner_;
820  preparser::PreParser* reusable_preparser_;
821  Scope* top_scope_;
822  FunctionState* current_function_state_;
823  Target* target_stack_; // for break, continue statements
824  v8::Extension* extension_;
825  ScriptDataImpl* pre_data_;
826  FuncNameInferrer* fni_;
827 
828  Mode mode_;
829  bool allow_natives_syntax_;
830  bool allow_lazy_;
831  bool allow_modules_;
832  bool stack_overflow_;
833  // If true, the next (and immediately following) function literal is
834  // preceded by a parenthesis.
835  // Heuristically that means that the function will be called immediately,
836  // so never lazily compile it.
837  bool parenthesized_function_;
838 
839  Zone* zone_;
840  friend class BlockState;
841  friend class FunctionState;
842 };
843 
844 
845 // Support for handling complex values (array and object literals) that
846 // can be fully handled at compile time.
848  public:
849  enum Type {
853  };
854 
855  static bool IsCompileTimeValue(Expression* expression);
856 
858 
859  // Get the value as a compile time value.
860  static Handle<FixedArray> GetValue(Expression* expression);
861 
862  // Get the type of a compile time value returned by GetValue().
863  static Type GetType(Handle<FixedArray> value);
864 
865  // Get the elements array of a compile time value returned by GetValue().
867 
868  private:
869  static const int kTypeSlot = 0;
870  static const int kElementsSlot = 1;
871 
872  DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue);
873 };
874 
875 } } // namespace v8::internal
876 
877 #endif // V8_PARSER_H_
static bool ParseRegExp(FlatStringReader *input, bool multiline, RegExpCompileData *result)
Definition: parser.cc:6004
static ScriptDataImpl * PartialPreParse(Handle< String > source, v8::Extension *extension, int flags)
Definition: parser.cc:5969
const char * message()
Definition: parser.h:59
RegExpTree * ToRegExp()
Definition: parser.cc:189
Scope * DeclarationScope()
Definition: scopes.cc:699
static ScriptDataImpl * PreParse(Utf16CharacterStream *source, v8::Extension *extension, int flags)
Definition: parser.cc:5992
Vector< const char * > BuildArgs()
Definition: parser.cc:384
friend class BlockState
Definition: parser.h:840
static const uc32 kEndMarker
Definition: parser.h:356
RegExpTree * ReportError(Vector< const char > message)
Definition: parser.cc:5133
bool ParseHexEscape(int length, uc32 *value)
Definition: parser.cc:5667
value format" "after each garbage collection") DEFINE_bool(print_cumulative_gc_stat, false, "print cumulative GC statistics in name=value format on exit") DEFINE_bool(trace_gc_verbose, false, "print more details following each garbage collection") DEFINE_bool(trace_fragmentation, false, "report fragmentation for old pointer and data pages") DEFINE_bool(collect_maps, true, "garbage collect maps from which no objects can be reached") DEFINE_bool(flush_code, true, "flush code that we expect not to use again before full gc") DEFINE_bool(incremental_marking, true, "use incremental marking") DEFINE_bool(incremental_marking_steps, true, "do incremental marking steps") DEFINE_bool(trace_incremental_marking, false, "trace progress of the incremental marking") DEFINE_bool(use_idle_notification, true, "Use idle notification to reduce memory footprint.") DEFINE_bool(send_idle_notification, false, "Send idle notifcation between stress runs.") DEFINE_bool(use_ic, true, "use inline caching") DEFINE_bool(native_code_counters, false, "generate extra code for manipulating stats counters") DEFINE_bool(always_compact, false, "Perform compaction on every full GC") DEFINE_bool(lazy_sweeping, true, "Use lazy sweeping for old pointer and data spaces") DEFINE_bool(never_compact, false, "Never perform compaction on full GC-testing only") DEFINE_bool(compact_code_space, true, "Compact code space on full non-incremental collections") DEFINE_bool(cleanup_code_caches_at_gc, true, "Flush inline caches prior to mark compact collection and" "flush code caches in maps during mark compact cycle.") DEFINE_int(random_seed, 0, "Default seed for initializing random generator" "(0, the default, means to use system random).") DEFINE_bool(use_verbose_printer, true, "allows verbose printing") DEFINE_bool(allow_natives_syntax, false, "allow natives syntax") DEFINE_bool(trace_sim, false, "Trace simulator execution") DEFINE_bool(check_icache, false, "Check icache flushes in ARM and MIPS simulator") DEFINE_int(stop_sim_at, 0, "Simulator stop after x number of instructions") DEFINE_int(sim_stack_alignment, 8, "Stack alingment in bytes in simulator(4 or 8, 8 is default)") DEFINE_bool(trace_exception, false, "print stack trace when throwing exceptions") DEFINE_bool(preallocate_message_memory, false, "preallocate some memory to build stack traces.") DEFINE_bool(randomize_hashes, true, "randomize hashes to avoid predictable hash collisions" "(with snapshots this option cannot override the baked-in seed)") DEFINE_int(hash_seed, 0, "Fixed seed to use to hash property keys(0 means random)" "(with snapshots this option cannot override the baked-in seed)") DEFINE_bool(preemption, false, "activate a 100ms timer that switches between V8 threads") DEFINE_bool(regexp_optimization, true, "generate optimized regexp code") DEFINE_bool(testing_bool_flag, true, "testing_bool_flag") DEFINE_int(testing_int_flag, 13, "testing_int_flag") DEFINE_float(testing_float_flag, 2.5, "float-flag") DEFINE_string(testing_string_flag, "Hello, world!", "string-flag") DEFINE_int(testing_prng_seed, 42, "Seed used for threading test randomness") DEFINE_string(testing_serialization_file, "/tmp/serdes", "file in which to serialize heap") DEFINE_bool(help, false, "Print usage message, including flags, on console") DEFINE_bool(dump_counters, false, "Dump counters on exit") DEFINE_string(map_counters, "", "Map counters to a file") DEFINE_args(js_arguments, JSARGUMENTS_INIT, "Pass all remaining arguments to the script.Alias for\"--\".") DEFINE_bool(debug_compile_events, true,"Enable debugger compile events") DEFINE_bool(debug_script_collected_events, true,"Enable debugger script collected events") DEFINE_bool(gdbjit, false,"enable GDBJIT interface (disables compacting GC)") DEFINE_bool(gdbjit_full, false,"enable GDBJIT interface for all code objects") DEFINE_bool(gdbjit_dump, false,"dump elf objects with debug info to disk") DEFINE_string(gdbjit_dump_filter,"","dump only objects containing this substring") DEFINE_bool(force_marking_deque_overflows, false,"force overflows of marking deque by reducing it's size ""to 64 words") DEFINE_bool(stress_compaction, false,"stress the GC compactor to flush out bugs (implies ""--force_marking_deque_overflows)")#define FLAG DEFINE_bool(enable_slow_asserts, false,"enable asserts that are slow to execute") DEFINE_bool(trace_codegen, false,"print name of functions for which code is generated") DEFINE_bool(print_source, false,"pretty print source code") DEFINE_bool(print_builtin_source, false,"pretty print source code for builtins") DEFINE_bool(print_ast, false,"print source AST") DEFINE_bool(print_builtin_ast, false,"print source AST for builtins") DEFINE_string(stop_at,"","function name where to insert a breakpoint") DEFINE_bool(print_builtin_scopes, false,"print scopes for builtins") DEFINE_bool(print_scopes, false,"print scopes") DEFINE_bool(trace_contexts, false,"trace contexts operations") DEFINE_bool(gc_greedy, false,"perform GC prior to some allocations") DEFINE_bool(gc_verbose, false,"print stuff during garbage collection") DEFINE_bool(heap_stats, false,"report heap statistics before and after GC") DEFINE_bool(code_stats, false,"report code statistics after GC") DEFINE_bool(verify_heap, false,"verify heap pointers before and after GC") DEFINE_bool(print_handles, false,"report handles after GC") DEFINE_bool(print_global_handles, false,"report global handles after GC") DEFINE_bool(trace_ic, false,"trace inline cache state transitions") DEFINE_bool(print_interfaces, false,"print interfaces") DEFINE_bool(print_interface_details, false,"print interface inference details") DEFINE_int(print_interface_depth, 5,"depth for printing interfaces") DEFINE_bool(trace_normalization, false,"prints when objects are turned into dictionaries.") DEFINE_bool(trace_lazy, false,"trace lazy compilation") DEFINE_bool(collect_heap_spill_statistics, false,"report heap spill statistics along with heap_stats ""(requires heap_stats)") DEFINE_bool(trace_isolates, false,"trace isolate state changes") DEFINE_bool(log_state_changes, false,"Log state changes.") DEFINE_bool(regexp_possessive_quantifier, false,"enable possessive quantifier syntax for testing") DEFINE_bool(trace_regexp_bytecodes, false,"trace regexp bytecode execution") DEFINE_bool(trace_regexp_assembler, false,"trace regexp macro assembler calls.")#define FLAG DEFINE_bool(log, false,"Minimal logging (no API, code, GC, suspect, or handles samples).") DEFINE_bool(log_all, false,"Log all events to the log file.") DEFINE_bool(log_runtime, false,"Activate runtime system %Log call.") DEFINE_bool(log_api, false,"Log API events to the log file.") DEFINE_bool(log_code, false,"Log code events to the log file without profiling.") DEFINE_bool(log_gc, false,"Log heap samples on garbage collection for the hp2ps tool.") DEFINE_bool(log_handles, false,"Log global handle events.") DEFINE_bool(log_snapshot_positions, false,"log positions of (de)serialized objects in the snapshot.") DEFINE_bool(log_suspect, false,"Log suspect operations.") DEFINE_bool(prof, false,"Log statistical profiling information (implies --log-code).") DEFINE_bool(prof_auto, true,"Used with --prof, starts profiling automatically") DEFINE_bool(prof_lazy, false,"Used with --prof, only does sampling and logging"" when profiler is active (implies --noprof_auto).") DEFINE_bool(prof_browser_mode, true,"Used with --prof, turns on browser-compatible mode for profiling.") DEFINE_bool(log_regexp, false,"Log regular expression execution.") DEFINE_bool(sliding_state_window, false,"Update sliding state window counters.") DEFINE_string(logfile,"v8.log","Specify the name of the log file.") DEFINE_bool(ll_prof, false,"Enable low-level linux profiler.")#define FLAG DEFINE_bool(trace_elements_transitions, false,"trace elements transitions") DEFINE_bool(print_code_stubs, false,"print code stubs") DEFINE_bool(test_secondary_stub_cache, false,"test secondary stub cache by disabling the primary one") DEFINE_bool(test_primary_stub_cache, false,"test primary stub cache by disabling the secondary one") DEFINE_bool(print_code, false,"print generated code") DEFINE_bool(print_opt_code, false,"print optimized code") DEFINE_bool(print_unopt_code, false,"print unoptimized code before ""printing optimized code based on it") DEFINE_bool(print_code_verbose, false,"print more information for code") DEFINE_bool(print_builtin_code, false,"print generated code for builtins")#43"/Users/thlorenz/dev/dx/v8-perf/build/v8/src/flags.cc"2#define FLAG_MODE_DEFINE_DEFAULTS#1"/Users/thlorenz/dev/dx/v8-perf/build/v8/src/flag-definitions.h"1#define FLAG_FULL(ftype, ctype, nam, def, cmt)#define FLAG_READONLY(ftype, ctype, nam, def, cmt)#define DEFINE_implication(whenflag, thenflag)#define DEFINE_bool(nam, def, cmt)#define DEFINE_int(nam, def, cmt)#define DEFINE_float(nam, def, cmt)#define DEFINE_string(nam, def, cmt)#define DEFINE_args(nam, def, cmt)#define FLAG DEFINE_bool(use_strict, false,"enforce strict mode") DEFINE_bool(es5_readonly, false,"activate correct semantics for inheriting readonliness") DEFINE_bool(es52_globals, false,"activate new semantics for global var declarations") DEFINE_bool(harmony_typeof, false,"enable harmony semantics for typeof") DEFINE_bool(harmony_scoping, false,"enable harmony block scoping") DEFINE_bool(harmony_modules, false,"enable harmony modules (implies block scoping)") DEFINE_bool(harmony_proxies, false,"enable harmony proxies") DEFINE_bool(harmony_collections, false,"enable harmony collections (sets, maps, and weak maps)") DEFINE_bool(harmony, false,"enable all harmony features (except typeof)") DEFINE_implication(harmony, harmony_scoping) DEFINE_implication(harmony, harmony_modules) DEFINE_implication(harmony, harmony_proxies) DEFINE_implication(harmony, harmony_collections) DEFINE_implication(harmony_modules, harmony_scoping) DEFINE_bool(packed_arrays, false,"optimizes arrays that have no holes") DEFINE_bool(smi_only_arrays, true,"tracks arrays with only smi values") DEFINE_bool(clever_optimizations, true,"Optimize object size, Array shift, DOM strings and string +") DEFINE_bool(unbox_double_arrays, true,"automatically unbox arrays of doubles") DEFINE_bool(string_slices, true,"use string slices") DEFINE_bool(crankshaft, true,"use crankshaft") DEFINE_string(hydrogen_filter,"","optimization filter") DEFINE_bool(use_range, true,"use hydrogen range analysis") DEFINE_bool(eliminate_dead_phis, true,"eliminate dead phis") DEFINE_bool(use_gvn, true,"use hydrogen global value numbering") DEFINE_bool(use_canonicalizing, true,"use hydrogen instruction canonicalizing") DEFINE_bool(use_inlining, true,"use function inlining") DEFINE_int(max_inlined_source_size, 600,"maximum source size in bytes considered for a single inlining") DEFINE_int(max_inlined_nodes, 196,"maximum number of AST nodes considered for a single inlining") DEFINE_int(max_inlined_nodes_cumulative, 196,"maximum cumulative number of AST nodes considered for inlining") DEFINE_bool(loop_invariant_code_motion, true,"loop invariant code motion") DEFINE_bool(collect_megamorphic_maps_from_stub_cache, true,"crankshaft harvests type feedback from stub cache") DEFINE_bool(hydrogen_stats, false,"print statistics for hydrogen") DEFINE_bool(trace_hydrogen, false,"trace generated hydrogen to file") DEFINE_string(trace_phase,"Z","trace generated IR for specified phases") DEFINE_bool(trace_inlining, false,"trace inlining decisions") DEFINE_bool(trace_alloc, false,"trace register allocator") DEFINE_bool(trace_all_uses, false,"trace all use positions") DEFINE_bool(trace_range, false,"trace range analysis") DEFINE_bool(trace_gvn, false,"trace global value numbering") DEFINE_bool(trace_representation, false,"trace representation types") DEFINE_bool(stress_pointer_maps, false,"pointer map for every instruction") DEFINE_bool(stress_environments, false,"environment for every instruction") DEFINE_int(deopt_every_n_times, 0,"deoptimize every n times a deopt point is passed") DEFINE_bool(trap_on_deopt, false,"put a break point before deoptimizing") DEFINE_bool(deoptimize_uncommon_cases, true,"deoptimize uncommon cases") DEFINE_bool(polymorphic_inlining, true,"polymorphic inlining") DEFINE_bool(use_osr, true,"use on-stack replacement") DEFINE_bool(array_bounds_checks_elimination, false,"perform array bounds checks elimination") DEFINE_bool(array_index_dehoisting, false,"perform array index dehoisting") DEFINE_bool(trace_osr, false,"trace on-stack replacement") DEFINE_int(stress_runs, 0,"number of stress runs") DEFINE_bool(optimize_closures, true,"optimize closures") DEFINE_bool(inline_construct, true,"inline constructor calls") DEFINE_bool(inline_arguments, true,"inline functions with arguments object") DEFINE_int(loop_weight, 1,"loop weight for representation inference") DEFINE_bool(optimize_for_in, true,"optimize functions containing for-in loops") DEFINE_bool(experimental_profiler, true,"enable all profiler experiments") DEFINE_bool(watch_ic_patching, false,"profiler considers IC stability") DEFINE_int(frame_count, 1,"number of stack frames inspected by the profiler") DEFINE_bool(self_optimization, false,"primitive functions trigger their own optimization") DEFINE_bool(direct_self_opt, false,"call recompile stub directly when self-optimizing") DEFINE_bool(retry_self_opt, false,"re-try self-optimization if it failed") DEFINE_bool(count_based_interrupts, false,"trigger profiler ticks based on counting instead of timing") DEFINE_bool(interrupt_at_exit, false,"insert an interrupt check at function exit") DEFINE_bool(weighted_back_edges, false,"weight back edges by jump distance for interrupt triggering") DEFINE_int(interrupt_budget, 5900,"execution budget before interrupt is triggered") DEFINE_int(type_info_threshold, 15,"percentage of ICs that must have type info to allow optimization") DEFINE_int(self_opt_count, 130,"call count before self-optimization") DEFINE_implication(experimental_profiler, watch_ic_patching) DEFINE_implication(experimental_profiler, self_optimization) DEFINE_implication(experimental_profiler, retry_self_opt) DEFINE_implication(experimental_profiler, count_based_interrupts) DEFINE_implication(experimental_profiler, interrupt_at_exit) DEFINE_implication(experimental_profiler, weighted_back_edges) DEFINE_bool(trace_opt_verbose, false,"extra verbose compilation tracing") DEFINE_implication(trace_opt_verbose, trace_opt) DEFINE_bool(debug_code, false,"generate extra code (assertions) for debugging") DEFINE_bool(code_comments, false,"emit comments in code disassembly") DEFINE_bool(enable_sse2, true,"enable use of SSE2 instructions if available") DEFINE_bool(enable_sse3, true,"enable use of SSE3 instructions if available") DEFINE_bool(enable_sse4_1, true,"enable use of SSE4.1 instructions if available") DEFINE_bool(enable_cmov, true,"enable use of CMOV instruction if available") DEFINE_bool(enable_rdtsc, true,"enable use of RDTSC instruction if available") DEFINE_bool(enable_sahf, true,"enable use of SAHF instruction if available (X64 only)") DEFINE_bool(enable_vfp3, true,"enable use of VFP3 instructions if available - this implies ""enabling ARMv7 instructions (ARM only)") DEFINE_bool(enable_armv7, true,"enable use of ARMv7 instructions if available (ARM only)") DEFINE_bool(enable_fpu, true,"enable use of MIPS FPU instructions if available (MIPS only)") DEFINE_string(expose_natives_as, NULL,"expose natives in global object") DEFINE_string(expose_debug_as, NULL,"expose debug in global object") DEFINE_bool(expose_gc, false,"expose gc extension") DEFINE_bool(expose_externalize_string, false,"expose externalize string extension") DEFINE_int(stack_trace_limit, 10,"number of stack frames to capture") DEFINE_bool(builtins_in_stack_traces, false,"show built-in functions in stack traces") DEFINE_bool(disable_native_files, false,"disable builtin natives files") DEFINE_bool(inline_new, true,"use fast inline allocation") DEFINE_bool(stack_trace_on_abort, true,"print a stack trace if an assertion failure occurs") DEFINE_bool(trace, false,"trace function calls") DEFINE_bool(mask_constants_with_cookie, true,"use random jit cookie to mask large constants") DEFINE_bool(lazy, true,"use lazy compilation") DEFINE_bool(trace_opt, false,"trace lazy optimization") DEFINE_bool(trace_opt_stats, false,"trace lazy optimization statistics") DEFINE_bool(opt, true,"use adaptive optimizations") DEFINE_bool(always_opt, false,"always try to optimize functions") DEFINE_bool(prepare_always_opt, false,"prepare for turning on always opt") DEFINE_bool(trace_deopt, false,"trace deoptimization") DEFINE_int(min_preparse_length, 1024,"minimum length for automatic enable preparsing") DEFINE_bool(always_full_compiler, false,"try to use the dedicated run-once backend for all code") DEFINE_bool(trace_bailout, false,"print reasons for falling back to using the classic V8 backend") DEFINE_bool(compilation_cache, true,"enable compilation cache") DEFINE_bool(cache_prototype_transitions, true,"cache prototype transitions") DEFINE_bool(trace_debug_json, false,"trace debugging JSON request/response") DEFINE_bool(debugger_auto_break, true,"automatically set the debug break flag when debugger commands are ""in the queue") DEFINE_bool(enable_liveedit, true,"enable liveedit experimental feature") DEFINE_bool(break_on_abort, true,"always cause a debug break before aborting") DEFINE_int(stack_size, kPointerSize *123,"default size of stack region v8 is allowed to use (in kBytes)") DEFINE_int(max_stack_trace_source_length, 300,"maximum length of function source code printed in a stack trace.") DEFINE_bool(always_inline_smi_code, false,"always inline smi code in non-opt code") DEFINE_int(max_new_space_size, 0,"max size of the new generation (in kBytes)") DEFINE_int(max_old_space_size, 0,"max size of the old generation (in Mbytes)") DEFINE_int(max_executable_size, 0,"max size of executable memory (in Mbytes)") DEFINE_bool(gc_global, false,"always perform global GCs") DEFINE_int(gc_interval,-1,"garbage collect after <n> allocations") DEFINE_bool(trace_gc, false,"print one trace line following each garbage collection") DEFINE_bool(trace_gc_nvp, false,"print one detailed trace line in name=value format ""after each garbage collection") DEFINE_bool(print_cumulative_gc_stat, false,"print cumulative GC statistics in name=value format on exit") DEFINE_bool(trace_gc_verbose, false,"print more details following each garbage collection") DEFINE_bool(trace_fragmentation, false,"report fragmentation for old pointer and data pages") DEFINE_bool(collect_maps, true,"garbage collect maps from which no objects can be reached") DEFINE_bool(flush_code, true,"flush code that we expect not to use again before full gc") DEFINE_bool(incremental_marking, true,"use incremental marking") DEFINE_bool(incremental_marking_steps, true,"do incremental marking steps") DEFINE_bool(trace_incremental_marking, false,"trace progress of the incremental marking") DEFINE_bool(use_idle_notification, true,"Use idle notification to reduce memory footprint.") DEFINE_bool(send_idle_notification, false,"Send idle notifcation between stress runs.") DEFINE_bool(use_ic, true,"use inline caching") DEFINE_bool(native_code_counters, false,"generate extra code for manipulating stats counters") DEFINE_bool(always_compact, false,"Perform compaction on every full GC") DEFINE_bool(lazy_sweeping, true,"Use lazy sweeping for old pointer and data spaces") DEFINE_bool(never_compact, false,"Never perform compaction on full GC - testing only") DEFINE_bool(compact_code_space, true,"Compact code space on full non-incremental collections") DEFINE_bool(cleanup_code_caches_at_gc, true,"Flush inline caches prior to mark compact collection and ""flush code caches in maps during mark compact cycle.") DEFINE_int(random_seed, 0,"Default seed for initializing random generator ""(0, the default, means to use system random).") DEFINE_bool(use_verbose_printer, true,"allows verbose printing") DEFINE_bool(allow_natives_syntax, false,"allow natives syntax") DEFINE_bool(trace_sim, false,"Trace simulator execution") DEFINE_bool(check_icache, false,"Check icache flushes in ARM and MIPS simulator") DEFINE_int(stop_sim_at, 0,"Simulator stop after x number of instructions") DEFINE_int(sim_stack_alignment, 8,"Stack alingment in bytes in simulator (4 or 8, 8 is default)") DEFINE_bool(trace_exception, false,"print stack trace when throwing exceptions") DEFINE_bool(preallocate_message_memory, false,"preallocate some memory to build stack traces.") DEFINE_bool(randomize_hashes, true,"randomize hashes to avoid predictable hash collisions ""(with snapshots this option cannot override the baked-in seed)") DEFINE_int(hash_seed, 0,"Fixed seed to use to hash property keys (0 means random)""(with snapshots this option cannot override the baked-in seed)") DEFINE_bool(preemption, false,"activate a 100ms timer that switches between V8 threads") DEFINE_bool(regexp_optimization, true,"generate optimized regexp code") DEFINE_bool(testing_bool_flag, true,"testing_bool_flag") DEFINE_int(testing_int_flag, 13,"testing_int_flag") DEFINE_float(testing_float_flag, 2.5,"float-flag") DEFINE_string(testing_string_flag,"Hello, world!","string-flag") DEFINE_int(testing_prng_seed, 42,"Seed used for threading test randomness") DEFINE_string(testing_serialization_file,"/tmp/serdes","file in which to serialize heap") DEFINE_bool(help, false,"Print usage message, including flags, on console") DEFINE_bool(dump_counters, false,"Dump counters on exit") DEFINE_string(map_counters,"","Map counters to a file") DEFINE_args(js_arguments, JSARGUMENTS_INIT,"Pass all remaining arguments to the script. Alias for \"--\".") DEFINE_bool(debug_compile_events, true,"Enable debugger compile events") DEFINE_bool(debug_script_collected_events, true,"Enable debugger script collected events") DEFINE_bool(gdbjit, false,"enable GDBJIT interface (disables compacting GC)") DEFINE_bool(gdbjit_full, false,"enable GDBJIT interface for all code objects") DEFINE_bool(gdbjit_dump, false,"dump elf objects with debug info to disk") DEFINE_string(gdbjit_dump_filter,"","dump only objects containing this substring") DEFINE_bool(force_marking_deque_overflows, false,"force overflows of marking deque by reducing it's size ""to 64 words") DEFINE_bool(stress_compaction, false,"stress the GC compactor to flush out bugs (implies ""--force_marking_deque_overflows)")#define FLAG DEFINE_bool(enable_slow_asserts, false,"enable asserts that are slow to execute") DEFINE_bool(trace_codegen, false,"print name of functions for which code is generated") DEFINE_bool(print_source, false,"pretty print source code") DEFINE_bool(print_builtin_source, false,"pretty print source code for builtins") DEFINE_bool(print_ast, false,"print source AST") DEFINE_bool(print_builtin_ast, false,"print source AST for builtins") DEFINE_string(stop_at,"","function name where to insert a breakpoint") DEFINE_bool(print_builtin_scopes, false,"print scopes for builtins") DEFINE_bool(print_scopes, false,"print scopes") DEFINE_bool(trace_contexts, false,"trace contexts operations") DEFINE_bool(gc_greedy, false,"perform GC prior to some allocations") DEFINE_bool(gc_verbose, false,"print stuff during garbage collection") DEFINE_bool(heap_stats, false,"report heap statistics before and after GC") DEFINE_bool(code_stats, false,"report code statistics after GC") DEFINE_bool(verify_heap, false,"verify heap pointers before and after GC") DEFINE_bool(print_handles, false,"report handles after GC") DEFINE_bool(print_global_handles, false,"report global handles after GC") DEFINE_bool(trace_ic, false,"trace inline cache state transitions") DEFINE_bool(print_interfaces, false,"print interfaces") DEFINE_bool(print_interface_details, false,"print interface inference details") DEFINE_int(print_interface_depth, 5,"depth for printing interfaces") DEFINE_bool(trace_normalization, false,"prints when objects are turned into dictionaries.") DEFINE_bool(trace_lazy, false,"trace lazy compilation") DEFINE_bool(collect_heap_spill_statistics, false,"report heap spill statistics along with heap_stats ""(requires heap_stats)") DEFINE_bool(trace_isolates, false,"trace isolate state changes") DEFINE_bool(log_state_changes, false,"Log state changes.") DEFINE_bool(regexp_possessive_quantifier, false,"enable possessive quantifier syntax for testing") DEFINE_bool(trace_regexp_bytecodes, false,"trace regexp bytecode execution") DEFINE_bool(trace_regexp_assembler, false,"trace regexp macro assembler calls.")#define FLAG DEFINE_bool(log, false,"Minimal logging (no API, code, GC, suspect, or handles samples).") DEFINE_bool(log_all, false,"Log all events to the log file.") DEFINE_bool(log_runtime, false,"Activate runtime system %Log call.") DEFINE_bool(log_api, false,"Log API events to the log file.") DEFINE_bool(log_code, false,"Log code events to the log file without profiling.") DEFINE_bool(log_gc, false,"Log heap samples on garbage collection for the hp2ps tool.") DEFINE_bool(log_handles, false,"Log global handle events.") DEFINE_bool(log_snapshot_positions, false,"log positions of (de)serialized objects in the snapshot.") DEFINE_bool(log_suspect, false,"Log suspect operations.") DEFINE_bool(prof, false,"Log statistical profiling information (implies --log-code).") DEFINE_bool(prof_auto, true,"Used with --prof, starts profiling automatically") DEFINE_bool(prof_lazy, false,"Used with --prof, only does sampling and logging"" when profiler is active (implies --noprof_auto).") DEFINE_bool(prof_browser_mode, true,"Used with --prof, turns on browser-compatible mode for profiling.") DEFINE_bool(log_regexp, false,"Log regular expression execution.") DEFINE_bool(sliding_state_window, false,"Update sliding state window counters.") DEFINE_string(logfile,"v8.log","Specify the name of the log file.") DEFINE_bool(ll_prof, false,"Enable low-level linux profiler.")#define FLAG DEFINE_bool(trace_elements_transitions, false,"trace elements transitions") DEFINE_bool(print_code_stubs, false,"print code stubs") DEFINE_bool(test_secondary_stub_cache, false,"test secondary stub cache by disabling the primary one") DEFINE_bool(test_primary_stub_cache, false,"test primary stub cache by disabling the secondary one") DEFINE_bool(print_code, false,"print generated code") DEFINE_bool(print_opt_code, false,"print optimized code") DEFINE_bool(print_unopt_code, false,"print unoptimized code before ""printing optimized code based on it") DEFINE_bool(print_code_verbose, false,"print more information for code") DEFINE_bool(print_builtin_code, false,"print generated code for builtins")#47"/Users/thlorenz/dev/dx/v8-perf/build/v8/src/flags.cc"2 namespace{struct Flag{enum FlagType{TYPE_BOOL, TYPE_INT, TYPE_FLOAT, TYPE_STRING, TYPE_ARGS} name
Definition: flags.cc:1349
Scanner::Location location()
Definition: parser.h:58
static Handle< FixedArray > GetElements(Handle< FixedArray > value)
Definition: parser.cc:3949
int32_t uc32
Definition: globals.h:274
T & at(int i) const
Definition: list.h:85
Flag flags[]
Definition: flags.cc:1467
FunctionLiteral * ParseProgram(CompilationInfo *info)
Definition: parser.cc:567
RegExpTree * ParseCharacterClass()
Definition: parser.cc:5810
void AddAtom(RegExpTree *tree)
Definition: parser.cc:144
#define ASSERT(condition)
Definition: checks.h:270
static bool IsCompileTimeValue(Expression *expression)
Definition: parser.cc:3902
static Type GetType(Handle< FixedArray > value)
Definition: parser.cc:3943
Vector< const char * > args()
Definition: parser.h:60
Factory * factory()
Definition: isolate.h:977
bool ParseBackReferenceIndex(int *index_out)
Definition: parser.cc:5545
virtual ~Parser()
Definition: parser.h:439
RegExpTree * ParsePattern()
Definition: parser.cc:5145
static bool Parse(CompilationInfo *info, int flags)
Definition: parser.cc:6026
FunctionEntry GetFunctionEntry(int start)
Definition: parser.cc:292
uint8_t byte
Definition: globals.h:171
static Interface * NewValue()
Definition: interface.h:51
void AddQuantifierToAtom(int min, int max, RegExpQuantifier::Type type)
Definition: parser.cc:202
RegExpTree * ParseDisjunction()
Definition: parser.cc:5167
kPropertyAccessorsOffset kNamedPropertyHandlerOffset kInstanceTemplateOffset kAccessCheckInfoOffset kEvalFrominstructionsOffsetOffset this_property_assignments
Definition: objects-inl.h:3674
void AddAssertion(RegExpTree *tree)
Definition: parser.cc:160
RegExpParser(FlatStringReader *in, Handle< String > *error, bool multiline_mode)
Definition: parser.cc:5070
friend class FunctionState
Definition: parser.h:841
void Add(T *value, Zone *zone)
Definition: parser.h:203
ZoneList< T * > * GetList(Zone *zone)
Definition: parser.h:253
CharacterRange ParseClassAtom(uc16 *char_class)
Definition: parser.cc:5770
Handle< String > NewStringFromTwoByte(Vector< const uc16 > str, PretenureFlag pretenure=NOT_TENURED)
Definition: factory.cc:216
int length() const
Definition: utils.h:383
FunctionLiteral * ParseLazy(CompilationInfo *info)
Definition: parser.cc:665
#define BASE_EMBEDDED
Definition: allocation.h:68
#define T(name, string, precedence)
Definition: token.cc:48
static Handle< FixedArray > GetValue(Expression *expression)
Definition: parser.cc:3921
const char * BuildMessage()
Definition: parser.cc:378
ParserMessage(Scanner::Location loc, const char *message, Vector< const char * > args)
Definition: parser.h:52
Handle< String > NewStringFromAscii(Vector< const char > str, PretenureFlag pretenure=NOT_TENURED)
Definition: factory.cc:199
void ReportMessageAt(Scanner::Location loc, const char *message, Vector< const char * > args)
Definition: parser.cc:774
LanguageMode language_mode()
Definition: parser.h:88
virtual const char * Data()
Definition: parser.cc:5886
void AddCharacter(uc16 character)
Definition: parser.cc:129
uint16_t uc16
Definition: globals.h:273
Scanner::Location MessageLocation()
Definition: parser.cc:371
#define ASSERT_EQ(v1, v2)
Definition: checks.h:271
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 trace on stack replacement optimize closures functions with arguments object optimize functions containing for in loops profiler considers IC stability primitive functions trigger their own optimization re try self optimization if it failed insert an interrupt check at function exit execution budget before interrupt is triggered call count before self optimization self_optimization count_based_interrupts weighted_back_edges trace_opt 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 enable use of ARMv7 instructions if enable use of MIPS FPU instructions if NULL
Definition: flags.cc:274
bool inside_with() const
Definition: scopes.h:305
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 true
Definition: flags.cc:157
Token::Value peek() const
Definition: scanner.h:367
Parser(Handle< Script > script, int parsing_flags, v8::Extension *extension, ScriptDataImpl *pre_data, Zone *zone)
Definition: parser.cc:535
void Add(const T &element, AllocationPolicy allocator=AllocationPolicy())
Definition: list-inl.h:38
static const int kMaxCaptures
Definition: parser.h:355
ZoneList< Handle< String > > ZoneStringList
Definition: ast.h:155
Token::Value Next()
Definition: scanner.cc:224
bool ParseIntervalQuantifier(int *min_out, int *max_out)
Definition: parser.cc:5589
FunctionEntry(Vector< unsigned > backing)
Definition: parser.h:79
ScriptDataImpl(Vector< unsigned > store)
Definition: parser.h:105
RegExpBuilder(Zone *zone)
Definition: parser.cc:89
bool is_extended_mode() const
Definition: scopes.h:288
virtual bool HasError()
Definition: parser.cc:5891
FlagType type() const
Definition: flags.cc:1358
static bool ArrayLiteralElementNeedsInitialization(Expression *value)
Definition: parser.cc:3909
static const int kLiteralsPrefixSize
Definition: objects.h:5993