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
ast.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_AST_H_
29 #define V8_AST_H_
30 
31 #include "v8.h"
32 
33 #include "assembler.h"
34 #include "factory.h"
35 #include "isolate.h"
36 #include "jsregexp.h"
37 #include "list-inl.h"
38 #include "runtime.h"
39 #include "small-pointer-list.h"
40 #include "smart-array-pointer.h"
41 #include "token.h"
42 #include "utils.h"
43 #include "variables.h"
44 #include "interface.h"
45 #include "zone-inl.h"
46 
47 namespace v8 {
48 namespace internal {
49 
50 // The abstract syntax tree is an intermediate, light-weight
51 // representation of the parsed JavaScript code suitable for
52 // compilation to native code.
53 
54 // Nodes are allocated in a separate zone, which allows faster
55 // allocation and constant-time deallocation of the entire syntax
56 // tree.
57 
58 
59 // ----------------------------------------------------------------------------
60 // Nodes of the abstract syntax tree. Only concrete classes are
61 // enumerated here.
62 
63 #define DECLARATION_NODE_LIST(V) \
64  V(VariableDeclaration) \
65  V(FunctionDeclaration) \
66  V(ModuleDeclaration) \
67  V(ImportDeclaration) \
68  V(ExportDeclaration) \
69 
70 #define MODULE_NODE_LIST(V) \
71  V(ModuleLiteral) \
72  V(ModuleVariable) \
73  V(ModulePath) \
74  V(ModuleUrl)
75 
76 #define STATEMENT_NODE_LIST(V) \
77  V(Block) \
78  V(ExpressionStatement) \
79  V(EmptyStatement) \
80  V(IfStatement) \
81  V(ContinueStatement) \
82  V(BreakStatement) \
83  V(ReturnStatement) \
84  V(WithStatement) \
85  V(SwitchStatement) \
86  V(DoWhileStatement) \
87  V(WhileStatement) \
88  V(ForStatement) \
89  V(ForInStatement) \
90  V(TryCatchStatement) \
91  V(TryFinallyStatement) \
92  V(DebuggerStatement)
93 
94 #define EXPRESSION_NODE_LIST(V) \
95  V(FunctionLiteral) \
96  V(SharedFunctionInfoLiteral) \
97  V(Conditional) \
98  V(VariableProxy) \
99  V(Literal) \
100  V(RegExpLiteral) \
101  V(ObjectLiteral) \
102  V(ArrayLiteral) \
103  V(Assignment) \
104  V(Throw) \
105  V(Property) \
106  V(Call) \
107  V(CallNew) \
108  V(CallRuntime) \
109  V(UnaryOperation) \
110  V(CountOperation) \
111  V(BinaryOperation) \
112  V(CompareOperation) \
113  V(ThisFunction)
114 
115 #define AST_NODE_LIST(V) \
116  DECLARATION_NODE_LIST(V) \
117  MODULE_NODE_LIST(V) \
118  STATEMENT_NODE_LIST(V) \
119  EXPRESSION_NODE_LIST(V)
120 
121 // Forward declarations
122 class AstConstructionVisitor;
123 template<class> class AstNodeFactory;
124 class AstVisitor;
125 class Declaration;
126 class Module;
127 class BreakableStatement;
128 class Expression;
129 class IterationStatement;
130 class MaterializedLiteral;
131 class Statement;
132 class TargetCollector;
133 class TypeFeedbackOracle;
134 
135 class RegExpAlternative;
136 class RegExpAssertion;
137 class RegExpAtom;
138 class RegExpBackReference;
139 class RegExpCapture;
141 class RegExpCompiler;
142 class RegExpDisjunction;
143 class RegExpEmpty;
144 class RegExpLookahead;
145 class RegExpQuantifier;
146 class RegExpText;
147 
148 #define DEF_FORWARD_DECLARATION(type) class type;
150 #undef DEF_FORWARD_DECLARATION
151 
152 
153 // Typedef only introduced to avoid unreadable code.
154 // Please do appreciate the required space in "> >".
157 
158 
159 #define DECLARE_NODE_TYPE(type) \
160  virtual void Accept(AstVisitor* v); \
161  virtual AstNode::Type node_type() const { return AstNode::k##type; }
162 
163 
169 };
170 
171 
172 class AstProperties BASE_EMBEDDED {
173  public:
174  class Flags : public EnumSet<AstPropertiesFlag, int> {};
175 
176  AstProperties() : node_count_(0) { }
177 
178  Flags* flags() { return &flags_; }
179  int node_count() { return node_count_; }
180  void add_node_count(int count) { node_count_ += count; }
181 
182  private:
183  Flags flags_;
184  int node_count_;
185 };
186 
187 
188 class AstNode: public ZoneObject {
189  public:
190 #define DECLARE_TYPE_ENUM(type) k##type,
191  enum Type {
193  kInvalid = -1
194  };
195 #undef DECLARE_TYPE_ENUM
196 
197  static const int kNoNumber = -1;
198  static const int kFunctionEntryId = 2; // Using 0 could disguise errors.
199  // This AST id identifies the point after the declarations have been
200  // visited. We need it to capture the environment effects of declarations
201  // that emit code (function declarations).
202  static const int kDeclarationsId = 3;
203 
204  void* operator new(size_t size, Zone* zone) {
205  return zone->New(static_cast<int>(size));
206  }
207 
208  AstNode() { }
209 
210  virtual ~AstNode() { }
211 
212  virtual void Accept(AstVisitor* v) = 0;
213  virtual Type node_type() const { return kInvalid; }
214 
215  // Type testing & conversion functions overridden by concrete subclasses.
216 #define DECLARE_NODE_FUNCTIONS(type) \
217  bool Is##type() { return node_type() == AstNode::k##type; } \
218  type* As##type() { return Is##type() ? reinterpret_cast<type*>(this) : NULL; }
220 #undef DECLARE_NODE_FUNCTIONS
221 
222  virtual Declaration* AsDeclaration() { return NULL; }
223  virtual Statement* AsStatement() { return NULL; }
224  virtual Expression* AsExpression() { return NULL; }
225  virtual TargetCollector* AsTargetCollector() { return NULL; }
229 
230  protected:
231  static int GetNextId(Isolate* isolate) {
232  return ReserveIdRange(isolate, 1);
233  }
234 
235  static int ReserveIdRange(Isolate* isolate, int n) {
236  int tmp = isolate->ast_node_id();
237  isolate->set_ast_node_id(tmp + n);
238  return tmp;
239  }
240 
241  private:
242  // Hidden to prevent accidental usage. It would have to load the
243  // current zone from the TLS.
244  void* operator new(size_t size);
245 
246  friend class CaseClause; // Generates AST IDs.
247 };
248 
249 
250 class Statement: public AstNode {
251  public:
252  Statement() : statement_pos_(RelocInfo::kNoPosition) {}
253 
254  virtual Statement* AsStatement() { return this; }
255 
256  bool IsEmpty() { return AsEmptyStatement() != NULL; }
257 
258  void set_statement_pos(int statement_pos) { statement_pos_ = statement_pos; }
259  int statement_pos() const { return statement_pos_; }
260 
261  private:
262  int statement_pos_;
263 };
264 
265 
267  public:
269  SmallMapList(int capacity, Zone* zone) : list_(capacity, zone) {}
270 
271  void Reserve(int capacity, Zone* zone) { list_.Reserve(capacity, zone); }
272  void Clear() { list_.Clear(); }
273  void Sort() { list_.Sort(); }
274 
275  bool is_empty() const { return list_.is_empty(); }
276  int length() const { return list_.length(); }
277 
278  void Add(Handle<Map> handle, Zone* zone) {
279  list_.Add(handle.location(), zone);
280  }
281 
282  Handle<Map> at(int i) const {
283  return Handle<Map>(list_.at(i));
284  }
285 
286  Handle<Map> first() const { return at(0); }
287  Handle<Map> last() const { return at(length() - 1); }
288 
289  private:
290  // The list stores pointers to Map*, that is Map**, so it's GC safe.
292 
294 };
295 
296 
297 class Expression: public AstNode {
298  public:
299  enum Context {
300  // Not assigned a context yet, or else will not be visited during
301  // code generation.
303  // Evaluated for its side effects.
305  // Evaluated for its value (and side effects).
307  // Evaluated for control flow (and side effects).
308  kTest
309  };
310 
311  virtual int position() const {
312  UNREACHABLE();
313  return 0;
314  }
315 
316  virtual Expression* AsExpression() { return this; }
317 
318  virtual bool IsValidLeftHandSide() { return false; }
319 
320  // Helpers for ToBoolean conversion.
321  virtual bool ToBooleanIsTrue() { return false; }
322  virtual bool ToBooleanIsFalse() { return false; }
323 
324  // Symbols that cannot be parsed as array indices are considered property
325  // names. We do not treat symbols that can be array indexes as property
326  // names because [] for string objects is handled only by keyed ICs.
327  virtual bool IsPropertyName() { return false; }
328 
329  // True iff the result can be safely overwritten (to avoid allocation).
330  // False for operations that can return one of their operands.
331  virtual bool ResultOverwriteAllowed() { return false; }
332 
333  // True iff the expression is a literal represented as a smi.
334  bool IsSmiLiteral();
335 
336  // True iff the expression is a string literal.
337  bool IsStringLiteral();
338 
339  // True iff the expression is the null literal.
340  bool IsNullLiteral();
341 
342  // Type feedback information for assignments and properties.
343  virtual bool IsMonomorphic() {
344  UNREACHABLE();
345  return false;
346  }
348  UNREACHABLE();
349  return NULL;
350  }
352  ASSERT(IsMonomorphic());
353  SmallMapList* types = GetReceiverTypes();
354  ASSERT(types != NULL && types->length() == 1);
355  return types->at(0);
356  }
357 
358  unsigned id() const { return id_; }
359  unsigned test_id() const { return test_id_; }
360 
361  protected:
362  explicit Expression(Isolate* isolate)
363  : id_(GetNextId(isolate)),
364  test_id_(GetNextId(isolate)) {}
365 
366  private:
367  int id_;
368  int test_id_;
369 };
370 
371 
373  public:
374  enum Type {
376  TARGET_FOR_NAMED_ONLY
377  };
378 
379  // The labels associated with this statement. May be NULL;
380  // if it is != NULL, guaranteed to contain at least one entry.
381  ZoneStringList* labels() const { return labels_; }
382 
383  // Type testing & conversion.
384  virtual BreakableStatement* AsBreakableStatement() { return this; }
385 
386  // Code generation
387  Label* break_target() { return &break_target_; }
388 
389  // Testers.
390  bool is_target_for_anonymous() const { return type_ == TARGET_FOR_ANONYMOUS; }
391 
392  // Bailout support.
393  int EntryId() const { return entry_id_; }
394  int ExitId() const { return exit_id_; }
395 
396  protected:
398  : labels_(labels),
399  type_(type),
400  entry_id_(GetNextId(isolate)),
401  exit_id_(GetNextId(isolate)) {
402  ASSERT(labels == NULL || labels->length() > 0);
403  }
404 
405 
406  private:
407  ZoneStringList* labels_;
408  Type type_;
409  Label break_target_;
410  int entry_id_;
411  int exit_id_;
412 };
413 
414 
415 class Block: public BreakableStatement {
416  public:
418 
419  void AddStatement(Statement* statement, Zone* zone) {
420  statements_.Add(statement, zone);
421  }
422 
423  ZoneList<Statement*>* statements() { return &statements_; }
424  bool is_initializer_block() const { return is_initializer_block_; }
425 
426  Scope* scope() const { return scope_; }
427  void set_scope(Scope* scope) { scope_ = scope; }
428 
429  protected:
430  template<class> friend class AstNodeFactory;
431 
432  Block(Isolate* isolate,
433  ZoneStringList* labels,
434  int capacity,
435  bool is_initializer_block,
436  Zone* zone)
437  : BreakableStatement(isolate, labels, TARGET_FOR_NAMED_ONLY),
438  statements_(capacity, zone),
439  is_initializer_block_(is_initializer_block),
440  scope_(NULL) {
441  }
442 
443  private:
444  ZoneList<Statement*> statements_;
445  bool is_initializer_block_;
446  Scope* scope_;
447 };
448 
449 
450 class Declaration: public AstNode {
451  public:
452  VariableProxy* proxy() const { return proxy_; }
453  VariableMode mode() const { return mode_; }
454  Scope* scope() const { return scope_; }
455  virtual InitializationFlag initialization() const = 0;
456  virtual bool IsInlineable() const;
457 
458  virtual Declaration* AsDeclaration() { return this; }
459 
460  protected:
462  VariableMode mode,
463  Scope* scope)
464  : proxy_(proxy),
465  mode_(mode),
466  scope_(scope) {
467  ASSERT(mode == VAR ||
468  mode == CONST ||
469  mode == CONST_HARMONY ||
470  mode == LET);
471  }
472 
473  private:
474  VariableProxy* proxy_;
475  VariableMode mode_;
476 
477  // Nested scope from which the declaration originated.
478  Scope* scope_;
479 };
480 
481 
483  public:
485 
486  virtual InitializationFlag initialization() const {
487  return mode() == VAR ? kCreatedInitialized : kNeedsInitialization;
488  }
489 
490  protected:
491  template<class> friend class AstNodeFactory;
492 
494  VariableMode mode,
495  Scope* scope)
496  : Declaration(proxy, mode, scope) {
497  }
498 };
499 
500 
502  public:
504 
505  FunctionLiteral* fun() const { return fun_; }
507  return kCreatedInitialized;
508  }
509  virtual bool IsInlineable() const;
510 
511  protected:
512  template<class> friend class AstNodeFactory;
513 
515  VariableMode mode,
516  FunctionLiteral* fun,
517  Scope* scope)
518  : Declaration(proxy, mode, scope),
519  fun_(fun) {
520  // At the moment there are no "const functions" in JavaScript...
521  ASSERT(mode == VAR || mode == LET);
522  ASSERT(fun != NULL);
523  }
524 
525  private:
526  FunctionLiteral* fun_;
527 };
528 
529 
531  public:
533 
534  Module* module() const { return module_; }
536  return kCreatedInitialized;
537  }
538 
539  protected:
540  template<class> friend class AstNodeFactory;
541 
543  Module* module,
544  Scope* scope)
545  : Declaration(proxy, LET, scope),
546  module_(module) {
547  }
548 
549  private:
550  Module* module_;
551 };
552 
553 
555  public:
557 
558  Module* module() const { return module_; }
560  return kCreatedInitialized;
561  }
562 
563  protected:
564  template<class> friend class AstNodeFactory;
565 
567  Module* module,
568  Scope* scope)
569  : Declaration(proxy, LET, scope),
570  module_(module) {
571  }
572 
573  private:
574  Module* module_;
575 };
576 
577 
579  public:
581 
582  virtual InitializationFlag initialization() const {
583  return kCreatedInitialized;
584  }
585 
586  protected:
587  template<class> friend class AstNodeFactory;
588 
590  Scope* scope)
591  : Declaration(proxy, LET, scope) {
592  }
593 };
594 
595 
596 class Module: public AstNode {
597  public:
598  Interface* interface() const { return interface_; }
599 
600  protected:
601  explicit Module(Zone* zone) : interface_(Interface::NewModule(zone)) {}
602  explicit Module(Interface* interface) : interface_(interface) {}
603 
604  private:
605  Interface* interface_;
606 };
607 
608 
609 class ModuleLiteral: public Module {
610  public:
612 
613  Block* body() const { return body_; }
614  Handle<Context> context() const { return context_; }
615 
616  protected:
617  template<class> friend class AstNodeFactory;
618 
619  ModuleLiteral(Block* body, Interface* interface)
620  : Module(interface),
621  body_(body) {
622  }
623 
624  private:
625  Block* body_;
626  Handle<Context> context_;
627 };
628 
629 
630 class ModuleVariable: public Module {
631  public:
633 
634  VariableProxy* proxy() const { return proxy_; }
635 
636  protected:
637  template<class> friend class AstNodeFactory;
638 
639  inline explicit ModuleVariable(VariableProxy* proxy);
640 
641  private:
642  VariableProxy* proxy_;
643 };
644 
645 
646 class ModulePath: public Module {
647  public:
649 
650  Module* module() const { return module_; }
651  Handle<String> name() const { return name_; }
652 
653  protected:
654  template<class> friend class AstNodeFactory;
655 
657  : Module(zone),
658  module_(module),
659  name_(name) {
660  }
661 
662  private:
663  Module* module_;
665 };
666 
667 
668 class ModuleUrl: public Module {
669  public:
671 
672  Handle<String> url() const { return url_; }
673 
674  protected:
675  template<class> friend class AstNodeFactory;
676 
678  : Module(zone), url_(url) {
679  }
680 
681  private:
682  Handle<String> url_;
683 };
684 
685 
687  public:
688  // Type testing & conversion.
689  virtual IterationStatement* AsIterationStatement() { return this; }
690 
691  Statement* body() const { return body_; }
692 
693  // Bailout support.
694  int OsrEntryId() const { return osr_entry_id_; }
695  virtual int ContinueId() const = 0;
696  virtual int StackCheckId() const = 0;
697 
698  // Code generation
699  Label* continue_target() { return &continue_target_; }
700 
701  protected:
703  : BreakableStatement(isolate, labels, TARGET_FOR_ANONYMOUS),
704  body_(NULL),
705  osr_entry_id_(GetNextId(isolate)) {
706  }
707 
708  void Initialize(Statement* body) {
709  body_ = body;
710  }
711 
712  private:
713  Statement* body_;
714  Label continue_target_;
715  int osr_entry_id_;
716 };
717 
718 
720  public:
722 
723  void Initialize(Expression* cond, Statement* body) {
725  cond_ = cond;
726  }
727 
728  Expression* cond() const { return cond_; }
729 
730  // Position where condition expression starts. We need it to make
731  // the loop's condition a breakable location.
732  int condition_position() { return condition_position_; }
733  void set_condition_position(int pos) { condition_position_ = pos; }
734 
735  // Bailout support.
736  virtual int ContinueId() const { return continue_id_; }
737  virtual int StackCheckId() const { return back_edge_id_; }
738  int BackEdgeId() const { return back_edge_id_; }
739 
740  protected:
741  template<class> friend class AstNodeFactory;
742 
744  : IterationStatement(isolate, labels),
745  cond_(NULL),
746  condition_position_(-1),
747  continue_id_(GetNextId(isolate)),
748  back_edge_id_(GetNextId(isolate)) {
749  }
750 
751  private:
752  Expression* cond_;
753  int condition_position_;
754  int continue_id_;
755  int back_edge_id_;
756 };
757 
758 
760  public:
762 
763  void Initialize(Expression* cond, Statement* body) {
765  cond_ = cond;
766  }
767 
768  Expression* cond() const { return cond_; }
770  return may_have_function_literal_;
771  }
772  void set_may_have_function_literal(bool value) {
773  may_have_function_literal_ = value;
774  }
775 
776  // Bailout support.
777  virtual int ContinueId() const { return EntryId(); }
778  virtual int StackCheckId() const { return body_id_; }
779  int BodyId() const { return body_id_; }
780 
781  protected:
782  template<class> friend class AstNodeFactory;
783 
785  : IterationStatement(isolate, labels),
786  cond_(NULL),
787  may_have_function_literal_(true),
788  body_id_(GetNextId(isolate)) {
789  }
790 
791  private:
792  Expression* cond_;
793  // True if there is a function literal subexpression in the condition.
794  bool may_have_function_literal_;
795  int body_id_;
796 };
797 
798 
800  public:
802 
803  void Initialize(Statement* init,
804  Expression* cond,
805  Statement* next,
806  Statement* body) {
808  init_ = init;
809  cond_ = cond;
810  next_ = next;
811  }
812 
813  Statement* init() const { return init_; }
814  Expression* cond() const { return cond_; }
815  Statement* next() const { return next_; }
816 
818  return may_have_function_literal_;
819  }
820  void set_may_have_function_literal(bool value) {
821  may_have_function_literal_ = value;
822  }
823 
824  // Bailout support.
825  virtual int ContinueId() const { return continue_id_; }
826  virtual int StackCheckId() const { return body_id_; }
827  int BodyId() const { return body_id_; }
828 
829  bool is_fast_smi_loop() { return loop_variable_ != NULL; }
830  Variable* loop_variable() { return loop_variable_; }
831  void set_loop_variable(Variable* var) { loop_variable_ = var; }
832 
833  protected:
834  template<class> friend class AstNodeFactory;
835 
837  : IterationStatement(isolate, labels),
838  init_(NULL),
839  cond_(NULL),
840  next_(NULL),
841  may_have_function_literal_(true),
842  loop_variable_(NULL),
843  continue_id_(GetNextId(isolate)),
844  body_id_(GetNextId(isolate)) {
845  }
846 
847  private:
848  Statement* init_;
849  Expression* cond_;
850  Statement* next_;
851  // True if there is a function literal subexpression in the condition.
852  bool may_have_function_literal_;
853  Variable* loop_variable_;
854  int continue_id_;
855  int body_id_;
856 };
857 
858 
860  public:
862 
863  void Initialize(Expression* each, Expression* enumerable, Statement* body) {
865  each_ = each;
866  enumerable_ = enumerable;
867  }
868 
869  Expression* each() const { return each_; }
870  Expression* enumerable() const { return enumerable_; }
871 
872  virtual int ContinueId() const { return EntryId(); }
873  virtual int StackCheckId() const { return body_id_; }
874  int BodyId() const { return body_id_; }
875  int PrepareId() const { return prepare_id_; }
876 
877  protected:
878  template<class> friend class AstNodeFactory;
879 
881  : IterationStatement(isolate, labels),
882  each_(NULL),
883  enumerable_(NULL),
884  body_id_(GetNextId(isolate)),
885  prepare_id_(GetNextId(isolate)) {
886  }
887 
888  private:
889  Expression* each_;
890  Expression* enumerable_;
891  int body_id_;
892  int prepare_id_;
893 };
894 
895 
897  public:
899 
900  void set_expression(Expression* e) { expression_ = e; }
901  Expression* expression() const { return expression_; }
902 
903  protected:
904  template<class> friend class AstNodeFactory;
905 
906  explicit ExpressionStatement(Expression* expression)
907  : expression_(expression) { }
908 
909  private:
910  Expression* expression_;
911 };
912 
913 
915  public:
917 
918  IterationStatement* target() const { return target_; }
919 
920  protected:
921  template<class> friend class AstNodeFactory;
922 
924  : target_(target) { }
925 
926  private:
927  IterationStatement* target_;
928 };
929 
930 
931 class BreakStatement: public Statement {
932  public:
934 
935  BreakableStatement* target() const { return target_; }
936 
937  protected:
938  template<class> friend class AstNodeFactory;
939 
941  : target_(target) { }
942 
943  private:
944  BreakableStatement* target_;
945 };
946 
947 
948 class ReturnStatement: public Statement {
949  public:
951 
952  Expression* expression() const { return expression_; }
953 
954  protected:
955  template<class> friend class AstNodeFactory;
956 
957  explicit ReturnStatement(Expression* expression)
958  : expression_(expression) { }
959 
960  private:
961  Expression* expression_;
962 };
963 
964 
965 class WithStatement: public Statement {
966  public:
968 
969  Expression* expression() const { return expression_; }
970  Statement* statement() const { return statement_; }
971 
972  protected:
973  template<class> friend class AstNodeFactory;
974 
975  WithStatement(Expression* expression, Statement* statement)
976  : expression_(expression),
977  statement_(statement) { }
978 
979  private:
980  Expression* expression_;
981  Statement* statement_;
982 };
983 
984 
985 class CaseClause: public ZoneObject {
986  public:
987  CaseClause(Isolate* isolate,
988  Expression* label,
989  ZoneList<Statement*>* statements,
990  int pos);
991 
992  bool is_default() const { return label_ == NULL; }
993  Expression* label() const {
994  CHECK(!is_default());
995  return label_;
996  }
997  Label* body_target() { return &body_target_; }
998  ZoneList<Statement*>* statements() const { return statements_; }
999 
1000  int position() const { return position_; }
1001  void set_position(int pos) { position_ = pos; }
1002 
1003  int EntryId() { return entry_id_; }
1004  int CompareId() { return compare_id_; }
1005 
1006  // Type feedback information.
1007  void RecordTypeFeedback(TypeFeedbackOracle* oracle);
1008  bool IsSmiCompare() { return compare_type_ == SMI_ONLY; }
1009  bool IsSymbolCompare() { return compare_type_ == SYMBOL_ONLY; }
1010  bool IsStringCompare() { return compare_type_ == STRING_ONLY; }
1011  bool IsObjectCompare() { return compare_type_ == OBJECT_ONLY; }
1012 
1013  private:
1014  Expression* label_;
1015  Label body_target_;
1016  ZoneList<Statement*>* statements_;
1017  int position_;
1018  enum CompareTypeFeedback {
1019  NONE,
1020  SMI_ONLY,
1021  SYMBOL_ONLY,
1022  STRING_ONLY,
1023  OBJECT_ONLY
1024  };
1025  CompareTypeFeedback compare_type_;
1026  int compare_id_;
1027  int entry_id_;
1028 };
1029 
1030 
1032  public:
1034 
1035  void Initialize(Expression* tag, ZoneList<CaseClause*>* cases) {
1036  tag_ = tag;
1037  cases_ = cases;
1038  }
1039 
1040  Expression* tag() const { return tag_; }
1041  ZoneList<CaseClause*>* cases() const { return cases_; }
1042 
1043  protected:
1044  template<class> friend class AstNodeFactory;
1045 
1047  : BreakableStatement(isolate, labels, TARGET_FOR_ANONYMOUS),
1048  tag_(NULL),
1049  cases_(NULL) { }
1050 
1051  private:
1052  Expression* tag_;
1053  ZoneList<CaseClause*>* cases_;
1054 };
1055 
1056 
1057 // If-statements always have non-null references to their then- and
1058 // else-parts. When parsing if-statements with no explicit else-part,
1059 // the parser implicitly creates an empty statement. Use the
1060 // HasThenStatement() and HasElseStatement() functions to check if a
1061 // given if-statement has a then- or an else-part containing code.
1062 class IfStatement: public Statement {
1063  public:
1065 
1066  bool HasThenStatement() const { return !then_statement()->IsEmpty(); }
1067  bool HasElseStatement() const { return !else_statement()->IsEmpty(); }
1068 
1069  Expression* condition() const { return condition_; }
1070  Statement* then_statement() const { return then_statement_; }
1071  Statement* else_statement() const { return else_statement_; }
1072 
1073  int IfId() const { return if_id_; }
1074  int ThenId() const { return then_id_; }
1075  int ElseId() const { return else_id_; }
1076 
1077  protected:
1078  template<class> friend class AstNodeFactory;
1079 
1081  Expression* condition,
1082  Statement* then_statement,
1083  Statement* else_statement)
1084  : condition_(condition),
1085  then_statement_(then_statement),
1086  else_statement_(else_statement),
1087  if_id_(GetNextId(isolate)),
1088  then_id_(GetNextId(isolate)),
1089  else_id_(GetNextId(isolate)) {
1090  }
1091 
1092  private:
1093  Expression* condition_;
1094  Statement* then_statement_;
1095  Statement* else_statement_;
1096  int if_id_;
1097  int then_id_;
1098  int else_id_;
1099 };
1100 
1101 
1102 // NOTE: TargetCollectors are represented as nodes to fit in the target
1103 // stack in the compiler; this should probably be reworked.
1104 class TargetCollector: public AstNode {
1105  public:
1106  explicit TargetCollector(Zone* zone) : targets_(0, zone) { }
1107 
1108  // Adds a jump target to the collector. The collector stores a pointer not
1109  // a copy of the target to make binding work, so make sure not to pass in
1110  // references to something on the stack.
1111  void AddTarget(Label* target, Zone* zone);
1112 
1113  // Virtual behaviour. TargetCollectors are never part of the AST.
1114  virtual void Accept(AstVisitor* v) { UNREACHABLE(); }
1115  virtual TargetCollector* AsTargetCollector() { return this; }
1116 
1117  ZoneList<Label*>* targets() { return &targets_; }
1118 
1119  private:
1120  ZoneList<Label*> targets_;
1121 };
1122 
1123 
1124 class TryStatement: public Statement {
1125  public:
1127  escaping_targets_ = targets;
1128  }
1129 
1130  int index() const { return index_; }
1131  Block* try_block() const { return try_block_; }
1132  ZoneList<Label*>* escaping_targets() const { return escaping_targets_; }
1133 
1134  protected:
1135  TryStatement(int index, Block* try_block)
1136  : index_(index),
1137  try_block_(try_block),
1138  escaping_targets_(NULL) { }
1139 
1140  private:
1141  // Unique (per-function) index of this handler. This is not an AST ID.
1142  int index_;
1143 
1144  Block* try_block_;
1145  ZoneList<Label*>* escaping_targets_;
1146 };
1147 
1148 
1150  public:
1152 
1153  Scope* scope() { return scope_; }
1154  Variable* variable() { return variable_; }
1155  Block* catch_block() const { return catch_block_; }
1156 
1157  protected:
1158  template<class> friend class AstNodeFactory;
1159 
1161  Block* try_block,
1162  Scope* scope,
1163  Variable* variable,
1164  Block* catch_block)
1165  : TryStatement(index, try_block),
1166  scope_(scope),
1167  variable_(variable),
1168  catch_block_(catch_block) {
1169  }
1170 
1171  private:
1172  Scope* scope_;
1173  Variable* variable_;
1174  Block* catch_block_;
1175 };
1176 
1177 
1179  public:
1181 
1182  Block* finally_block() const { return finally_block_; }
1183 
1184  protected:
1185  template<class> friend class AstNodeFactory;
1186 
1187  TryFinallyStatement(int index, Block* try_block, Block* finally_block)
1188  : TryStatement(index, try_block),
1189  finally_block_(finally_block) { }
1190 
1191  private:
1192  Block* finally_block_;
1193 };
1194 
1195 
1197  public:
1199 
1200  protected:
1201  template<class> friend class AstNodeFactory;
1202 
1204 };
1205 
1206 
1207 class EmptyStatement: public Statement {
1208  public:
1210 
1211  protected:
1212  template<class> friend class AstNodeFactory;
1213 
1215 };
1216 
1217 
1218 class Literal: public Expression {
1219  public:
1221 
1222  virtual bool IsPropertyName() {
1223  if (handle_->IsSymbol()) {
1224  uint32_t ignored;
1225  return !String::cast(*handle_)->AsArrayIndex(&ignored);
1226  }
1227  return false;
1228  }
1229 
1231  ASSERT(IsPropertyName());
1232  return Handle<String>::cast(handle_);
1233  }
1234 
1235  virtual bool ToBooleanIsTrue() { return handle_->ToBoolean()->IsTrue(); }
1236  virtual bool ToBooleanIsFalse() { return handle_->ToBoolean()->IsFalse(); }
1237 
1238  // Identity testers.
1239  bool IsNull() const {
1240  ASSERT(!handle_.is_null());
1241  return handle_->IsNull();
1242  }
1243  bool IsTrue() const {
1244  ASSERT(!handle_.is_null());
1245  return handle_->IsTrue();
1246  }
1247  bool IsFalse() const {
1248  ASSERT(!handle_.is_null());
1249  return handle_->IsFalse();
1250  }
1251 
1252  Handle<Object> handle() const { return handle_; }
1253 
1254  // Support for using Literal as a HashMap key. NOTE: Currently, this works
1255  // only for string and number literals!
1256  uint32_t Hash() { return ToString()->Hash(); }
1257 
1258  static bool Match(void* literal1, void* literal2) {
1259  Handle<String> s1 = static_cast<Literal*>(literal1)->ToString();
1260  Handle<String> s2 = static_cast<Literal*>(literal2)->ToString();
1261  return s1->Equals(*s2);
1262  }
1263 
1264  protected:
1265  template<class> friend class AstNodeFactory;
1266 
1267  Literal(Isolate* isolate, Handle<Object> handle)
1268  : Expression(isolate),
1269  handle_(handle) { }
1270 
1271  private:
1272  Handle<String> ToString();
1273 
1274  Handle<Object> handle_;
1275 };
1276 
1277 
1278 // Base class for literals that needs space in the corresponding JSFunction.
1280  public:
1281  virtual MaterializedLiteral* AsMaterializedLiteral() { return this; }
1282 
1283  int literal_index() { return literal_index_; }
1284 
1285  // A materialized literal is simple if the values consist of only
1286  // constants and simple object and array literals.
1287  bool is_simple() const { return is_simple_; }
1288 
1289  int depth() const { return depth_; }
1290 
1291  protected:
1293  int literal_index,
1294  bool is_simple,
1295  int depth)
1296  : Expression(isolate),
1297  literal_index_(literal_index),
1298  is_simple_(is_simple),
1299  depth_(depth) {}
1300 
1301  private:
1302  int literal_index_;
1303  bool is_simple_;
1304  int depth_;
1305 };
1306 
1307 
1308 // An object literal has a boilerplate object that is used
1309 // for minimizing the work when constructing it at runtime.
1311  public:
1312  // Property is used for passing information
1313  // about an object literal's properties from the parser
1314  // to the code generator.
1315  class Property: public ZoneObject {
1316  public:
1317  enum Kind {
1318  CONSTANT, // Property with constant value (compile time).
1319  COMPUTED, // Property with computed value (execution time).
1320  MATERIALIZED_LITERAL, // Property value is a materialized literal.
1321  GETTER, SETTER, // Property is an accessor function.
1322  PROTOTYPE // Property is __proto__.
1323  };
1324 
1325  Property(Literal* key, Expression* value, Isolate* isolate);
1326 
1327  Literal* key() { return key_; }
1328  Expression* value() { return value_; }
1329  Kind kind() { return kind_; }
1330 
1331  // Type feedback information.
1332  void RecordTypeFeedback(TypeFeedbackOracle* oracle);
1333  bool IsMonomorphic() { return !receiver_type_.is_null(); }
1334  Handle<Map> GetReceiverType() { return receiver_type_; }
1335 
1336  bool IsCompileTimeValue();
1337 
1338  void set_emit_store(bool emit_store);
1339  bool emit_store();
1340 
1341  protected:
1342  template<class> friend class AstNodeFactory;
1343 
1344  Property(bool is_getter, FunctionLiteral* value);
1345  void set_key(Literal* key) { key_ = key; }
1346 
1347  private:
1348  Literal* key_;
1349  Expression* value_;
1350  Kind kind_;
1351  bool emit_store_;
1352  Handle<Map> receiver_type_;
1353  };
1354 
1356 
1357  Handle<FixedArray> constant_properties() const {
1358  return constant_properties_;
1359  }
1360  ZoneList<Property*>* properties() const { return properties_; }
1361 
1362  bool fast_elements() const { return fast_elements_; }
1363 
1364  bool has_function() { return has_function_; }
1365 
1366  // Mark all computed expressions that are bound to a key that
1367  // is shadowed by a later occurrence of the same key. For the
1368  // marked expressions, no store code is emitted.
1369  void CalculateEmitStore(Zone* zone);
1370 
1371  enum Flags {
1372  kNoFlags = 0,
1373  kFastElements = 1,
1374  kHasFunction = 1 << 1
1375  };
1376 
1377  struct Accessors: public ZoneObject {
1378  Accessors() : getter(NULL), setter(NULL) { }
1381  };
1382 
1383  protected:
1384  template<class> friend class AstNodeFactory;
1385 
1387  Handle<FixedArray> constant_properties,
1388  ZoneList<Property*>* properties,
1389  int literal_index,
1390  bool is_simple,
1391  bool fast_elements,
1392  int depth,
1393  bool has_function)
1394  : MaterializedLiteral(isolate, literal_index, is_simple, depth),
1395  constant_properties_(constant_properties),
1396  properties_(properties),
1397  fast_elements_(fast_elements),
1398  has_function_(has_function) {}
1399 
1400  private:
1401  Handle<FixedArray> constant_properties_;
1402  ZoneList<Property*>* properties_;
1403  bool fast_elements_;
1404  bool has_function_;
1405 };
1406 
1407 
1408 // Node for capturing a regexp literal.
1410  public:
1412 
1413  Handle<String> pattern() const { return pattern_; }
1414  Handle<String> flags() const { return flags_; }
1415 
1416  protected:
1417  template<class> friend class AstNodeFactory;
1418 
1420  Handle<String> pattern,
1422  int literal_index)
1423  : MaterializedLiteral(isolate, literal_index, false, 1),
1424  pattern_(pattern),
1425  flags_(flags) {}
1426 
1427  private:
1428  Handle<String> pattern_;
1429  Handle<String> flags_;
1430 };
1431 
1432 // An array literal has a literals object that is used
1433 // for minimizing the work when constructing it at runtime.
1435  public:
1437 
1438  Handle<FixedArray> constant_elements() const { return constant_elements_; }
1439  ZoneList<Expression*>* values() const { return values_; }
1440 
1441  // Return an AST id for an element that is used in simulate instructions.
1442  int GetIdForElement(int i) { return first_element_id_ + i; }
1443 
1444  protected:
1445  template<class> friend class AstNodeFactory;
1446 
1448  Handle<FixedArray> constant_elements,
1449  ZoneList<Expression*>* values,
1450  int literal_index,
1451  bool is_simple,
1452  int depth)
1453  : MaterializedLiteral(isolate, literal_index, is_simple, depth),
1454  constant_elements_(constant_elements),
1455  values_(values),
1456  first_element_id_(ReserveIdRange(isolate, values->length())) {}
1457 
1458  private:
1459  Handle<FixedArray> constant_elements_;
1460  ZoneList<Expression*>* values_;
1461  int first_element_id_;
1462 };
1463 
1464 
1465 class VariableProxy: public Expression {
1466  public:
1468 
1469  virtual bool IsValidLeftHandSide() {
1470  return var_ == NULL ? true : var_->IsValidLeftHandSide();
1471  }
1472 
1474  return !is_this() && name().is_identical_to(n);
1475  }
1476 
1477  bool IsArguments() { return var_ != NULL && var_->is_arguments(); }
1478 
1479  bool IsLValue() {
1480  return is_lvalue_;
1481  }
1482 
1483  Handle<String> name() const { return name_; }
1484  Variable* var() const { return var_; }
1485  bool is_this() const { return is_this_; }
1486  int position() const { return position_; }
1487  Interface* interface() const { return interface_; }
1488 
1489 
1490  void MarkAsTrivial() { is_trivial_ = true; }
1491  void MarkAsLValue() { is_lvalue_ = true; }
1492 
1493  // Bind this proxy to the variable var.
1494  void BindTo(Variable* var);
1495 
1496  protected:
1497  template<class> friend class AstNodeFactory;
1498 
1499  VariableProxy(Isolate* isolate, Variable* var);
1500 
1501  VariableProxy(Isolate* isolate,
1503  bool is_this,
1504  int position,
1505  Interface* interface);
1506 
1508  Variable* var_; // resolved variable, or NULL
1509  bool is_this_;
1511  // True if this variable proxy is being used in an assignment
1512  // or with a increment/decrement operator.
1516 };
1517 
1518 
1519 class Property: public Expression {
1520  public:
1522 
1523  virtual bool IsValidLeftHandSide() { return true; }
1524 
1525  Expression* obj() const { return obj_; }
1526  Expression* key() const { return key_; }
1527  virtual int position() const { return pos_; }
1528 
1529  bool IsStringLength() const { return is_string_length_; }
1530  bool IsStringAccess() const { return is_string_access_; }
1531  bool IsFunctionPrototype() const { return is_function_prototype_; }
1532 
1533  // Type feedback information.
1534  void RecordTypeFeedback(TypeFeedbackOracle* oracle, Zone* zone);
1535  virtual bool IsMonomorphic() { return is_monomorphic_; }
1536  virtual SmallMapList* GetReceiverTypes() { return &receiver_types_; }
1537  bool IsArrayLength() { return is_array_length_; }
1538  bool IsUninitialized() { return is_uninitialized_; }
1539 
1540  protected:
1541  template<class> friend class AstNodeFactory;
1542 
1543  Property(Isolate* isolate,
1544  Expression* obj,
1545  Expression* key,
1546  int pos)
1547  : Expression(isolate),
1548  obj_(obj),
1549  key_(key),
1550  pos_(pos),
1551  is_monomorphic_(false),
1552  is_uninitialized_(false),
1553  is_array_length_(false),
1554  is_string_length_(false),
1555  is_string_access_(false),
1556  is_function_prototype_(false) { }
1557 
1558  private:
1559  Expression* obj_;
1560  Expression* key_;
1561  int pos_;
1562 
1563  SmallMapList receiver_types_;
1564  bool is_monomorphic_ : 1;
1565  bool is_uninitialized_ : 1;
1566  bool is_array_length_ : 1;
1567  bool is_string_length_ : 1;
1568  bool is_string_access_ : 1;
1569  bool is_function_prototype_ : 1;
1570 };
1571 
1572 
1573 class Call: public Expression {
1574  public:
1576 
1577  Expression* expression() const { return expression_; }
1578  ZoneList<Expression*>* arguments() const { return arguments_; }
1579  virtual int position() const { return pos_; }
1580 
1581  void RecordTypeFeedback(TypeFeedbackOracle* oracle,
1582  CallKind call_kind);
1583  virtual SmallMapList* GetReceiverTypes() { return &receiver_types_; }
1584  virtual bool IsMonomorphic() { return is_monomorphic_; }
1585  CheckType check_type() const { return check_type_; }
1586  Handle<JSFunction> target() { return target_; }
1587  Handle<JSObject> holder() { return holder_; }
1589 
1590  bool ComputeTarget(Handle<Map> type, Handle<String> name);
1591  bool ComputeGlobalTarget(Handle<GlobalObject> global, LookupResult* lookup);
1592 
1593  // Bailout support.
1594  int ReturnId() const { return return_id_; }
1595 
1596 #ifdef DEBUG
1597  // Used to assert that the FullCodeGenerator records the return site.
1598  bool return_is_recorded_;
1599 #endif
1600 
1601  protected:
1602  template<class> friend class AstNodeFactory;
1603 
1604  Call(Isolate* isolate,
1605  Expression* expression,
1606  ZoneList<Expression*>* arguments,
1607  int pos)
1608  : Expression(isolate),
1609  expression_(expression),
1610  arguments_(arguments),
1611  pos_(pos),
1612  is_monomorphic_(false),
1613  check_type_(RECEIVER_MAP_CHECK),
1614  return_id_(GetNextId(isolate)) { }
1615 
1616  private:
1617  Expression* expression_;
1618  ZoneList<Expression*>* arguments_;
1619  int pos_;
1620 
1621  bool is_monomorphic_;
1622  CheckType check_type_;
1623  SmallMapList receiver_types_;
1624  Handle<JSFunction> target_;
1625  Handle<JSObject> holder_;
1627 
1628  int return_id_;
1629 };
1630 
1631 
1632 class CallNew: public Expression {
1633  public:
1635 
1636  Expression* expression() const { return expression_; }
1637  ZoneList<Expression*>* arguments() const { return arguments_; }
1638  virtual int position() const { return pos_; }
1639 
1640  void RecordTypeFeedback(TypeFeedbackOracle* oracle);
1641  virtual bool IsMonomorphic() { return is_monomorphic_; }
1642  Handle<JSFunction> target() { return target_; }
1643 
1644  // Bailout support.
1645  int ReturnId() const { return return_id_; }
1646 
1647  protected:
1648  template<class> friend class AstNodeFactory;
1649 
1650  CallNew(Isolate* isolate,
1651  Expression* expression,
1652  ZoneList<Expression*>* arguments,
1653  int pos)
1654  : Expression(isolate),
1655  expression_(expression),
1656  arguments_(arguments),
1657  pos_(pos),
1658  is_monomorphic_(false),
1659  return_id_(GetNextId(isolate)) { }
1660 
1661  private:
1662  Expression* expression_;
1663  ZoneList<Expression*>* arguments_;
1664  int pos_;
1665 
1666  bool is_monomorphic_;
1667  Handle<JSFunction> target_;
1668 
1669  int return_id_;
1670 };
1671 
1672 
1673 // The CallRuntime class does not represent any official JavaScript
1674 // language construct. Instead it is used to call a C or JS function
1675 // with a set of arguments. This is used from the builtins that are
1676 // implemented in JavaScript (see "v8natives.js").
1677 class CallRuntime: public Expression {
1678  public:
1680 
1681  Handle<String> name() const { return name_; }
1682  const Runtime::Function* function() const { return function_; }
1683  ZoneList<Expression*>* arguments() const { return arguments_; }
1684  bool is_jsruntime() const { return function_ == NULL; }
1685 
1686  protected:
1687  template<class> friend class AstNodeFactory;
1688 
1691  const Runtime::Function* function,
1692  ZoneList<Expression*>* arguments)
1693  : Expression(isolate),
1694  name_(name),
1695  function_(function),
1696  arguments_(arguments) { }
1697 
1698  private:
1700  const Runtime::Function* function_;
1701  ZoneList<Expression*>* arguments_;
1702 };
1703 
1704 
1706  public:
1708 
1709  virtual bool ResultOverwriteAllowed();
1710 
1711  Token::Value op() const { return op_; }
1712  Expression* expression() const { return expression_; }
1713  virtual int position() const { return pos_; }
1714 
1715  int MaterializeTrueId() { return materialize_true_id_; }
1716  int MaterializeFalseId() { return materialize_false_id_; }
1717 
1718  protected:
1719  template<class> friend class AstNodeFactory;
1720 
1722  Token::Value op,
1723  Expression* expression,
1724  int pos)
1725  : Expression(isolate),
1726  op_(op),
1727  expression_(expression),
1728  pos_(pos),
1729  materialize_true_id_(AstNode::kNoNumber),
1730  materialize_false_id_(AstNode::kNoNumber) {
1731  ASSERT(Token::IsUnaryOp(op));
1732  if (op == Token::NOT) {
1733  materialize_true_id_ = GetNextId(isolate);
1734  materialize_false_id_ = GetNextId(isolate);
1735  }
1736  }
1737 
1738  private:
1739  Token::Value op_;
1740  Expression* expression_;
1741  int pos_;
1742 
1743  // For unary not (Token::NOT), the AST ids where true and false will
1744  // actually be materialized, respectively.
1745  int materialize_true_id_;
1746  int materialize_false_id_;
1747 };
1748 
1749 
1751  public:
1753 
1754  virtual bool ResultOverwriteAllowed();
1755 
1756  Token::Value op() const { return op_; }
1757  Expression* left() const { return left_; }
1758  Expression* right() const { return right_; }
1759  virtual int position() const { return pos_; }
1760 
1761  // Bailout support.
1762  int RightId() const { return right_id_; }
1763 
1764  protected:
1765  template<class> friend class AstNodeFactory;
1766 
1768  Token::Value op,
1769  Expression* left,
1770  Expression* right,
1771  int pos)
1772  : Expression(isolate), op_(op), left_(left), right_(right), pos_(pos) {
1774  right_id_ = (op == Token::AND || op == Token::OR)
1775  ? GetNextId(isolate)
1777  }
1778 
1779  private:
1780  Token::Value op_;
1781  Expression* left_;
1782  Expression* right_;
1783  int pos_;
1784  // The short-circuit logical operations have an AST ID for their
1785  // right-hand subexpression.
1786  int right_id_;
1787 };
1788 
1789 
1791  public:
1793 
1794  bool is_prefix() const { return is_prefix_; }
1795  bool is_postfix() const { return !is_prefix_; }
1796 
1797  Token::Value op() const { return op_; }
1799  return (op() == Token::INC) ? Token::ADD : Token::SUB;
1800  }
1801 
1802  Expression* expression() const { return expression_; }
1803  virtual int position() const { return pos_; }
1804 
1805  virtual void MarkAsStatement() { is_prefix_ = true; }
1806 
1807  void RecordTypeFeedback(TypeFeedbackOracle* oracle, Zone* znoe);
1808  virtual bool IsMonomorphic() { return is_monomorphic_; }
1809  virtual SmallMapList* GetReceiverTypes() { return &receiver_types_; }
1810 
1811  // Bailout support.
1812  int AssignmentId() const { return assignment_id_; }
1813  int CountId() const { return count_id_; }
1814 
1815  protected:
1816  template<class> friend class AstNodeFactory;
1817 
1819  Token::Value op,
1820  bool is_prefix,
1821  Expression* expr,
1822  int pos)
1823  : Expression(isolate),
1824  op_(op),
1825  is_prefix_(is_prefix),
1826  expression_(expr),
1827  pos_(pos),
1828  assignment_id_(GetNextId(isolate)),
1829  count_id_(GetNextId(isolate)) {}
1830 
1831  private:
1832  Token::Value op_;
1833  bool is_prefix_;
1834  bool is_monomorphic_;
1835  Expression* expression_;
1836  int pos_;
1837  int assignment_id_;
1838  int count_id_;
1839  SmallMapList receiver_types_;
1840 };
1841 
1842 
1844  public:
1846 
1847  Token::Value op() const { return op_; }
1848  Expression* left() const { return left_; }
1849  Expression* right() const { return right_; }
1850  virtual int position() const { return pos_; }
1851 
1852  // Type feedback information.
1853  void RecordTypeFeedback(TypeFeedbackOracle* oracle);
1854  bool IsSmiCompare() { return compare_type_ == SMI_ONLY; }
1855  bool IsObjectCompare() { return compare_type_ == OBJECT_ONLY; }
1856 
1857  // Match special cases.
1858  bool IsLiteralCompareTypeof(Expression** expr, Handle<String>* check);
1859  bool IsLiteralCompareUndefined(Expression** expr);
1860  bool IsLiteralCompareNull(Expression** expr);
1861 
1862  protected:
1863  template<class> friend class AstNodeFactory;
1864 
1866  Token::Value op,
1867  Expression* left,
1868  Expression* right,
1869  int pos)
1870  : Expression(isolate),
1871  op_(op),
1872  left_(left),
1873  right_(right),
1874  pos_(pos),
1875  compare_type_(NONE) {
1877  }
1878 
1879  private:
1880  Token::Value op_;
1881  Expression* left_;
1882  Expression* right_;
1883  int pos_;
1884 
1885  enum CompareTypeFeedback { NONE, SMI_ONLY, OBJECT_ONLY };
1886  CompareTypeFeedback compare_type_;
1887 };
1888 
1889 
1890 class Conditional: public Expression {
1891  public:
1893 
1894  Expression* condition() const { return condition_; }
1895  Expression* then_expression() const { return then_expression_; }
1896  Expression* else_expression() const { return else_expression_; }
1897 
1898  int then_expression_position() const { return then_expression_position_; }
1899  int else_expression_position() const { return else_expression_position_; }
1900 
1901  int ThenId() const { return then_id_; }
1902  int ElseId() const { return else_id_; }
1903 
1904  protected:
1905  template<class> friend class AstNodeFactory;
1906 
1908  Expression* condition,
1909  Expression* then_expression,
1910  Expression* else_expression,
1911  int then_expression_position,
1912  int else_expression_position)
1913  : Expression(isolate),
1914  condition_(condition),
1915  then_expression_(then_expression),
1916  else_expression_(else_expression),
1917  then_expression_position_(then_expression_position),
1918  else_expression_position_(else_expression_position),
1919  then_id_(GetNextId(isolate)),
1920  else_id_(GetNextId(isolate)) { }
1921 
1922  private:
1923  Expression* condition_;
1924  Expression* then_expression_;
1925  Expression* else_expression_;
1926  int then_expression_position_;
1927  int else_expression_position_;
1928  int then_id_;
1929  int else_id_;
1930 };
1931 
1932 
1933 class Assignment: public Expression {
1934  public:
1936 
1937  Assignment* AsSimpleAssignment() { return !is_compound() ? this : NULL; }
1938 
1939  Token::Value binary_op() const;
1940 
1941  Token::Value op() const { return op_; }
1942  Expression* target() const { return target_; }
1943  Expression* value() const { return value_; }
1944  virtual int position() const { return pos_; }
1945  BinaryOperation* binary_operation() const { return binary_operation_; }
1946 
1947  // This check relies on the definition order of token in token.h.
1948  bool is_compound() const { return op() > Token::ASSIGN; }
1949 
1950  // An initialization block is a series of statments of the form
1951  // x.y.z.a = ...; x.y.z.b = ...; etc. The parser marks the beginning and
1952  // ending of these blocks to allow for optimizations of initialization
1953  // blocks.
1954  bool starts_initialization_block() { return block_start_; }
1955  bool ends_initialization_block() { return block_end_; }
1956  void mark_block_start() { block_start_ = true; }
1957  void mark_block_end() { block_end_ = true; }
1958 
1959  // Type feedback information.
1960  void RecordTypeFeedback(TypeFeedbackOracle* oracle, Zone* zone);
1961  virtual bool IsMonomorphic() { return is_monomorphic_; }
1962  virtual SmallMapList* GetReceiverTypes() { return &receiver_types_; }
1963 
1964  // Bailout support.
1965  int CompoundLoadId() const { return compound_load_id_; }
1966  int AssignmentId() const { return assignment_id_; }
1967 
1968  protected:
1969  template<class> friend class AstNodeFactory;
1970 
1971  Assignment(Isolate* isolate,
1972  Token::Value op,
1973  Expression* target,
1974  Expression* value,
1975  int pos);
1976 
1977  template<class Visitor>
1978  void Init(Isolate* isolate, AstNodeFactory<Visitor>* factory) {
1980  if (is_compound()) {
1981  binary_operation_ =
1982  factory->NewBinaryOperation(binary_op(), target_, value_, pos_ + 1);
1983  compound_load_id_ = GetNextId(isolate);
1984  }
1985  }
1986 
1987  private:
1988  Token::Value op_;
1989  Expression* target_;
1990  Expression* value_;
1991  int pos_;
1992  BinaryOperation* binary_operation_;
1993  int compound_load_id_;
1994  int assignment_id_;
1995 
1996  bool block_start_;
1997  bool block_end_;
1998 
1999  bool is_monomorphic_;
2000  SmallMapList receiver_types_;
2001 };
2002 
2003 
2004 class Throw: public Expression {
2005  public:
2007 
2008  Expression* exception() const { return exception_; }
2009  virtual int position() const { return pos_; }
2010 
2011  protected:
2012  template<class> friend class AstNodeFactory;
2013 
2014  Throw(Isolate* isolate, Expression* exception, int pos)
2015  : Expression(isolate), exception_(exception), pos_(pos) {}
2016 
2017  private:
2018  Expression* exception_;
2019  int pos_;
2020 };
2021 
2022 
2024  public:
2025  enum Type {
2028  DECLARATION
2029  };
2030 
2032  kNoDuplicateParameters = 0,
2033  kHasDuplicateParameters = 1
2034  };
2035 
2038  kIsFunction
2039  };
2040 
2042 
2043  Handle<String> name() const { return name_; }
2044  Scope* scope() const { return scope_; }
2045  ZoneList<Statement*>* body() const { return body_; }
2046  void set_function_token_position(int pos) { function_token_position_ = pos; }
2047  int function_token_position() const { return function_token_position_; }
2048  int start_position() const;
2049  int end_position() const;
2050  int SourceSize() const { return end_position() - start_position(); }
2051  bool is_expression() const { return IsExpression::decode(bitfield_); }
2052  bool is_anonymous() const { return IsAnonymous::decode(bitfield_); }
2053  bool is_classic_mode() const { return language_mode() == CLASSIC_MODE; }
2054  LanguageMode language_mode() const;
2055 
2056  int materialized_literal_count() { return materialized_literal_count_; }
2057  int expected_property_count() { return expected_property_count_; }
2058  int handler_count() { return handler_count_; }
2060  return HasOnlySimpleThisPropertyAssignments::decode(bitfield_);
2061  }
2063  return this_property_assignments_;
2064  }
2065  int parameter_count() { return parameter_count_; }
2066 
2067  bool AllowsLazyCompilation();
2068 
2070  if (name_->length() > 0) return name_;
2071  return inferred_name();
2072  }
2073 
2074  Handle<String> inferred_name() const { return inferred_name_; }
2075  void set_inferred_name(Handle<String> inferred_name) {
2076  inferred_name_ = inferred_name;
2077  }
2078 
2079  bool pretenure() { return Pretenure::decode(bitfield_); }
2080  void set_pretenure() { bitfield_ |= Pretenure::encode(true); }
2081 
2083  return HasDuplicateParameters::decode(bitfield_);
2084  }
2085 
2086  bool is_function() { return IsFunction::decode(bitfield_) == kIsFunction; }
2087 
2088  int ast_node_count() { return ast_properties_.node_count(); }
2089  AstProperties::Flags* flags() { return ast_properties_.flags(); }
2090  void set_ast_properties(AstProperties* ast_properties) {
2091  ast_properties_ = *ast_properties;
2092  }
2093 
2094  protected:
2095  template<class> friend class AstNodeFactory;
2096 
2099  Scope* scope,
2100  ZoneList<Statement*>* body,
2101  int materialized_literal_count,
2102  int expected_property_count,
2103  int handler_count,
2106  int parameter_count,
2107  Type type,
2108  ParameterFlag has_duplicate_parameters,
2109  IsFunctionFlag is_function)
2110  : Expression(isolate),
2111  name_(name),
2112  scope_(scope),
2113  body_(body),
2114  this_property_assignments_(this_property_assignments),
2115  inferred_name_(isolate->factory()->empty_string()),
2116  materialized_literal_count_(materialized_literal_count),
2117  expected_property_count_(expected_property_count),
2118  handler_count_(handler_count),
2119  parameter_count_(parameter_count),
2120  function_token_position_(RelocInfo::kNoPosition) {
2121  bitfield_ =
2122  HasOnlySimpleThisPropertyAssignments::encode(
2123  has_only_simple_this_property_assignments) |
2124  IsExpression::encode(type != DECLARATION) |
2125  IsAnonymous::encode(type == ANONYMOUS_EXPRESSION) |
2126  Pretenure::encode(false) |
2127  HasDuplicateParameters::encode(has_duplicate_parameters) |
2128  IsFunction::encode(is_function);
2129  }
2130 
2131  private:
2133  Scope* scope_;
2134  ZoneList<Statement*>* body_;
2135  Handle<FixedArray> this_property_assignments_;
2136  Handle<String> inferred_name_;
2137  AstProperties ast_properties_;
2138 
2139  int materialized_literal_count_;
2140  int expected_property_count_;
2141  int handler_count_;
2142  int parameter_count_;
2143  int function_token_position_;
2144 
2145  unsigned bitfield_;
2146  class HasOnlySimpleThisPropertyAssignments: public BitField<bool, 0, 1> {};
2147  class IsExpression: public BitField<bool, 1, 1> {};
2148  class IsAnonymous: public BitField<bool, 2, 1> {};
2149  class Pretenure: public BitField<bool, 3, 1> {};
2150  class HasDuplicateParameters: public BitField<ParameterFlag, 4, 1> {};
2151  class IsFunction: public BitField<IsFunctionFlag, 5, 1> {};
2152 };
2153 
2154 
2156  public:
2158 
2159  Handle<SharedFunctionInfo> shared_function_info() const {
2160  return shared_function_info_;
2161  }
2162 
2163  protected:
2164  template<class> friend class AstNodeFactory;
2165 
2167  Isolate* isolate,
2168  Handle<SharedFunctionInfo> shared_function_info)
2169  : Expression(isolate),
2170  shared_function_info_(shared_function_info) { }
2171 
2172  private:
2173  Handle<SharedFunctionInfo> shared_function_info_;
2174 };
2175 
2176 
2177 class ThisFunction: public Expression {
2178  public:
2180 
2181  protected:
2182  template<class> friend class AstNodeFactory;
2183 
2184  explicit ThisFunction(Isolate* isolate): Expression(isolate) {}
2185 };
2186 
2187 #undef DECLARE_NODE_TYPE
2188 
2189 
2190 // ----------------------------------------------------------------------------
2191 // Regular expressions
2192 
2193 
2194 class RegExpVisitor BASE_EMBEDDED {
2195  public:
2196  virtual ~RegExpVisitor() { }
2197 #define MAKE_CASE(Name) \
2198  virtual void* Visit##Name(RegExp##Name*, void* data) = 0;
2200 #undef MAKE_CASE
2201 };
2202 
2203 
2204 class RegExpTree: public ZoneObject {
2205  public:
2206  static const int kInfinity = kMaxInt;
2207  virtual ~RegExpTree() { }
2208  virtual void* Accept(RegExpVisitor* visitor, void* data) = 0;
2209  virtual RegExpNode* ToNode(RegExpCompiler* compiler,
2210  RegExpNode* on_success) = 0;
2211  virtual bool IsTextElement() { return false; }
2212  virtual bool IsAnchoredAtStart() { return false; }
2213  virtual bool IsAnchoredAtEnd() { return false; }
2214  virtual int min_match() = 0;
2215  virtual int max_match() = 0;
2216  // Returns the interval of registers used for captures within this
2217  // expression.
2219  virtual void AppendToText(RegExpText* text, Zone* zone);
2220  SmartArrayPointer<const char> ToString(Zone* zone);
2221 #define MAKE_ASTYPE(Name) \
2222  virtual RegExp##Name* As##Name(); \
2223  virtual bool Is##Name();
2225 #undef MAKE_ASTYPE
2226 };
2227 
2228 
2230  public:
2231  explicit RegExpDisjunction(ZoneList<RegExpTree*>* alternatives);
2232  virtual void* Accept(RegExpVisitor* visitor, void* data);
2233  virtual RegExpNode* ToNode(RegExpCompiler* compiler,
2234  RegExpNode* on_success);
2235  virtual RegExpDisjunction* AsDisjunction();
2236  virtual Interval CaptureRegisters();
2237  virtual bool IsDisjunction();
2238  virtual bool IsAnchoredAtStart();
2239  virtual bool IsAnchoredAtEnd();
2240  virtual int min_match() { return min_match_; }
2241  virtual int max_match() { return max_match_; }
2242  ZoneList<RegExpTree*>* alternatives() { return alternatives_; }
2243  private:
2244  ZoneList<RegExpTree*>* alternatives_;
2245  int min_match_;
2246  int max_match_;
2247 };
2248 
2249 
2251  public:
2252  explicit RegExpAlternative(ZoneList<RegExpTree*>* nodes);
2253  virtual void* Accept(RegExpVisitor* visitor, void* data);
2254  virtual RegExpNode* ToNode(RegExpCompiler* compiler,
2255  RegExpNode* on_success);
2256  virtual RegExpAlternative* AsAlternative();
2257  virtual Interval CaptureRegisters();
2258  virtual bool IsAlternative();
2259  virtual bool IsAnchoredAtStart();
2260  virtual bool IsAnchoredAtEnd();
2261  virtual int min_match() { return min_match_; }
2262  virtual int max_match() { return max_match_; }
2263  ZoneList<RegExpTree*>* nodes() { return nodes_; }
2264  private:
2265  ZoneList<RegExpTree*>* nodes_;
2266  int min_match_;
2267  int max_match_;
2268 };
2269 
2270 
2272  public:
2273  enum Type {
2279  NON_BOUNDARY
2280  };
2281  explicit RegExpAssertion(Type type) : type_(type) { }
2282  virtual void* Accept(RegExpVisitor* visitor, void* data);
2283  virtual RegExpNode* ToNode(RegExpCompiler* compiler,
2284  RegExpNode* on_success);
2285  virtual RegExpAssertion* AsAssertion();
2286  virtual bool IsAssertion();
2287  virtual bool IsAnchoredAtStart();
2288  virtual bool IsAnchoredAtEnd();
2289  virtual int min_match() { return 0; }
2290  virtual int max_match() { return 0; }
2291  Type type() { return type_; }
2292  private:
2293  Type type_;
2294 };
2295 
2296 
2297 class CharacterSet BASE_EMBEDDED {
2298  public:
2299  explicit CharacterSet(uc16 standard_set_type)
2300  : ranges_(NULL),
2301  standard_set_type_(standard_set_type) {}
2303  : ranges_(ranges),
2304  standard_set_type_(0) {}
2305  ZoneList<CharacterRange>* ranges(Zone* zone);
2306  uc16 standard_set_type() { return standard_set_type_; }
2307  void set_standard_set_type(uc16 special_set_type) {
2308  standard_set_type_ = special_set_type;
2309  }
2310  bool is_standard() { return standard_set_type_ != 0; }
2311  void Canonicalize();
2312  private:
2313  ZoneList<CharacterRange>* ranges_;
2314  // If non-zero, the value represents a standard set (e.g., all whitespace
2315  // characters) without having to expand the ranges.
2316  uc16 standard_set_type_;
2317 };
2318 
2319 
2321  public:
2323  : set_(ranges),
2324  is_negated_(is_negated) { }
2326  : set_(type),
2327  is_negated_(false) { }
2328  virtual void* Accept(RegExpVisitor* visitor, void* data);
2329  virtual RegExpNode* ToNode(RegExpCompiler* compiler,
2330  RegExpNode* on_success);
2331  virtual RegExpCharacterClass* AsCharacterClass();
2332  virtual bool IsCharacterClass();
2333  virtual bool IsTextElement() { return true; }
2334  virtual int min_match() { return 1; }
2335  virtual int max_match() { return 1; }
2336  virtual void AppendToText(RegExpText* text, Zone* zone);
2337  CharacterSet character_set() { return set_; }
2338  // TODO(lrn): Remove need for complex version if is_standard that
2339  // recognizes a mangled standard set and just do { return set_.is_special(); }
2340  bool is_standard(Zone* zone);
2341  // Returns a value representing the standard character set if is_standard()
2342  // returns true.
2343  // Currently used values are:
2344  // s : unicode whitespace
2345  // S : unicode non-whitespace
2346  // w : ASCII word character (digit, letter, underscore)
2347  // W : non-ASCII word character
2348  // d : ASCII digit
2349  // D : non-ASCII digit
2350  // . : non-unicode non-newline
2351  // * : All characters
2352  uc16 standard_type() { return set_.standard_set_type(); }
2353  ZoneList<CharacterRange>* ranges(Zone* zone) { return set_.ranges(zone); }
2354  bool is_negated() { return is_negated_; }
2355 
2356  private:
2357  CharacterSet set_;
2358  bool is_negated_;
2359 };
2360 
2361 
2362 class RegExpAtom: public RegExpTree {
2363  public:
2364  explicit RegExpAtom(Vector<const uc16> data) : data_(data) { }
2365  virtual void* Accept(RegExpVisitor* visitor, void* data);
2366  virtual RegExpNode* ToNode(RegExpCompiler* compiler,
2367  RegExpNode* on_success);
2368  virtual RegExpAtom* AsAtom();
2369  virtual bool IsAtom();
2370  virtual bool IsTextElement() { return true; }
2371  virtual int min_match() { return data_.length(); }
2372  virtual int max_match() { return data_.length(); }
2373  virtual void AppendToText(RegExpText* text, Zone* zone);
2374  Vector<const uc16> data() { return data_; }
2375  int length() { return data_.length(); }
2376  private:
2377  Vector<const uc16> data_;
2378 };
2379 
2380 
2381 class RegExpText: public RegExpTree {
2382  public:
2383  explicit RegExpText(Zone* zone) : elements_(2, zone), length_(0) {}
2384  virtual void* Accept(RegExpVisitor* visitor, void* data);
2385  virtual RegExpNode* ToNode(RegExpCompiler* compiler,
2386  RegExpNode* on_success);
2387  virtual RegExpText* AsText();
2388  virtual bool IsText();
2389  virtual bool IsTextElement() { return true; }
2390  virtual int min_match() { return length_; }
2391  virtual int max_match() { return length_; }
2392  virtual void AppendToText(RegExpText* text, Zone* zone);
2393  void AddElement(TextElement elm, Zone* zone) {
2394  elements_.Add(elm, zone);
2395  length_ += elm.length();
2396  }
2397  ZoneList<TextElement>* elements() { return &elements_; }
2398  private:
2399  ZoneList<TextElement> elements_;
2400  int length_;
2401 };
2402 
2403 
2405  public:
2406  enum Type { GREEDY, NON_GREEDY, POSSESSIVE };
2407  RegExpQuantifier(int min, int max, Type type, RegExpTree* body)
2408  : body_(body),
2409  min_(min),
2410  max_(max),
2411  min_match_(min * body->min_match()),
2412  type_(type) {
2413  if (max > 0 && body->max_match() > kInfinity / max) {
2414  max_match_ = kInfinity;
2415  } else {
2416  max_match_ = max * body->max_match();
2417  }
2418  }
2419  virtual void* Accept(RegExpVisitor* visitor, void* data);
2420  virtual RegExpNode* ToNode(RegExpCompiler* compiler,
2421  RegExpNode* on_success);
2422  static RegExpNode* ToNode(int min,
2423  int max,
2424  bool is_greedy,
2425  RegExpTree* body,
2426  RegExpCompiler* compiler,
2427  RegExpNode* on_success,
2428  bool not_at_start = false);
2429  virtual RegExpQuantifier* AsQuantifier();
2430  virtual Interval CaptureRegisters();
2431  virtual bool IsQuantifier();
2432  virtual int min_match() { return min_match_; }
2433  virtual int max_match() { return max_match_; }
2434  int min() { return min_; }
2435  int max() { return max_; }
2436  bool is_possessive() { return type_ == POSSESSIVE; }
2437  bool is_non_greedy() { return type_ == NON_GREEDY; }
2438  bool is_greedy() { return type_ == GREEDY; }
2439  RegExpTree* body() { return body_; }
2440 
2441  private:
2442  RegExpTree* body_;
2443  int min_;
2444  int max_;
2445  int min_match_;
2446  int max_match_;
2447  Type type_;
2448 };
2449 
2450 
2451 class RegExpCapture: public RegExpTree {
2452  public:
2453  explicit RegExpCapture(RegExpTree* body, int index)
2454  : body_(body), index_(index) { }
2455  virtual void* Accept(RegExpVisitor* visitor, void* data);
2456  virtual RegExpNode* ToNode(RegExpCompiler* compiler,
2457  RegExpNode* on_success);
2458  static RegExpNode* ToNode(RegExpTree* body,
2459  int index,
2460  RegExpCompiler* compiler,
2461  RegExpNode* on_success);
2462  virtual RegExpCapture* AsCapture();
2463  virtual bool IsAnchoredAtStart();
2464  virtual bool IsAnchoredAtEnd();
2465  virtual Interval CaptureRegisters();
2466  virtual bool IsCapture();
2467  virtual int min_match() { return body_->min_match(); }
2468  virtual int max_match() { return body_->max_match(); }
2469  RegExpTree* body() { return body_; }
2470  int index() { return index_; }
2471  static int StartRegister(int index) { return index * 2; }
2472  static int EndRegister(int index) { return index * 2 + 1; }
2473 
2474  private:
2475  RegExpTree* body_;
2476  int index_;
2477 };
2478 
2479 
2481  public:
2483  bool is_positive,
2484  int capture_count,
2485  int capture_from)
2486  : body_(body),
2487  is_positive_(is_positive),
2488  capture_count_(capture_count),
2489  capture_from_(capture_from) { }
2490 
2491  virtual void* Accept(RegExpVisitor* visitor, void* data);
2492  virtual RegExpNode* ToNode(RegExpCompiler* compiler,
2493  RegExpNode* on_success);
2494  virtual RegExpLookahead* AsLookahead();
2495  virtual Interval CaptureRegisters();
2496  virtual bool IsLookahead();
2497  virtual bool IsAnchoredAtStart();
2498  virtual int min_match() { return 0; }
2499  virtual int max_match() { return 0; }
2500  RegExpTree* body() { return body_; }
2501  bool is_positive() { return is_positive_; }
2502  int capture_count() { return capture_count_; }
2503  int capture_from() { return capture_from_; }
2504 
2505  private:
2506  RegExpTree* body_;
2507  bool is_positive_;
2508  int capture_count_;
2509  int capture_from_;
2510 };
2511 
2512 
2514  public:
2516  : capture_(capture) { }
2517  virtual void* Accept(RegExpVisitor* visitor, void* data);
2518  virtual RegExpNode* ToNode(RegExpCompiler* compiler,
2519  RegExpNode* on_success);
2520  virtual RegExpBackReference* AsBackReference();
2521  virtual bool IsBackReference();
2522  virtual int min_match() { return 0; }
2523  virtual int max_match() { return capture_->max_match(); }
2524  int index() { return capture_->index(); }
2525  RegExpCapture* capture() { return capture_; }
2526  private:
2527  RegExpCapture* capture_;
2528 };
2529 
2530 
2531 class RegExpEmpty: public RegExpTree {
2532  public:
2534  virtual void* Accept(RegExpVisitor* visitor, void* data);
2535  virtual RegExpNode* ToNode(RegExpCompiler* compiler,
2536  RegExpNode* on_success);
2537  virtual RegExpEmpty* AsEmpty();
2538  virtual bool IsEmpty();
2539  virtual int min_match() { return 0; }
2540  virtual int max_match() { return 0; }
2542  static RegExpEmpty* instance = ::new RegExpEmpty();
2543  return instance;
2544  }
2545 };
2546 
2547 
2548 // ----------------------------------------------------------------------------
2549 // Out-of-line inline constructors (to side-step cyclic dependencies).
2550 
2552  : Module(proxy->interface()),
2553  proxy_(proxy) {
2554 }
2555 
2556 
2557 // ----------------------------------------------------------------------------
2558 // Basic visitor
2559 // - leaf node visitors are abstract.
2560 
2561 class AstVisitor BASE_EMBEDDED {
2562  public:
2563  AstVisitor() : isolate_(Isolate::Current()), stack_overflow_(false) { }
2564  virtual ~AstVisitor() { }
2565 
2566  // Stack overflow check and dynamic dispatch.
2567  void Visit(AstNode* node) { if (!CheckStackOverflow()) node->Accept(this); }
2568 
2569  // Iteration left-to-right.
2570  virtual void VisitDeclarations(ZoneList<Declaration*>* declarations);
2571  virtual void VisitStatements(ZoneList<Statement*>* statements);
2572  virtual void VisitExpressions(ZoneList<Expression*>* expressions);
2573 
2574  // Stack overflow tracking support.
2575  bool HasStackOverflow() const { return stack_overflow_; }
2576  bool CheckStackOverflow();
2577 
2578  // If a stack-overflow exception is encountered when visiting a
2579  // node, calling SetStackOverflow will make sure that the visitor
2580  // bails out without visiting more nodes.
2581  void SetStackOverflow() { stack_overflow_ = true; }
2582  void ClearStackOverflow() { stack_overflow_ = false; }
2583 
2584  // Individual AST nodes.
2585 #define DEF_VISIT(type) \
2586  virtual void Visit##type(type* node) = 0;
2588 #undef DEF_VISIT
2589 
2590  protected:
2591  Isolate* isolate() { return isolate_; }
2592 
2593  private:
2594  Isolate* isolate_;
2595  bool stack_overflow_;
2596 };
2597 
2598 
2599 // ----------------------------------------------------------------------------
2600 // Construction time visitor.
2601 
2602 class AstConstructionVisitor BASE_EMBEDDED {
2603  public:
2605 
2606  AstProperties* ast_properties() { return &properties_; }
2607 
2608  private:
2609  template<class> friend class AstNodeFactory;
2610 
2611  // Node visitors.
2612 #define DEF_VISIT(type) \
2613  void Visit##type(type* node);
2615 #undef DEF_VISIT
2616 
2617  void increase_node_count() { properties_.add_node_count(1); }
2618  void add_flag(AstPropertiesFlag flag) { properties_.flags()->Add(flag); }
2619 
2620  AstProperties properties_;
2621 };
2622 
2623 
2624 class AstNullVisitor BASE_EMBEDDED {
2625  public:
2626  // Node visitors.
2627 #define DEF_VISIT(type) \
2628  void Visit##type(type* node) {}
2630 #undef DEF_VISIT
2631 };
2632 
2633 
2634 
2635 // ----------------------------------------------------------------------------
2636 // AstNode factory
2637 
2638 template<class Visitor>
2639 class AstNodeFactory BASE_EMBEDDED {
2640  public:
2641  explicit AstNodeFactory(Isolate* isolate)
2642  : isolate_(isolate),
2643  zone_(isolate_->zone()) { }
2644 
2645  Visitor* visitor() { return &visitor_; }
2646 
2647 #define VISIT_AND_RETURN(NodeType, node) \
2648  visitor_.Visit##NodeType((node)); \
2649  return node;
2650 
2652  VariableMode mode,
2653  Scope* scope) {
2654  VariableDeclaration* decl =
2655  new(zone_) VariableDeclaration(proxy, mode, scope);
2657  }
2658 
2660  VariableMode mode,
2661  FunctionLiteral* fun,
2662  Scope* scope) {
2663  FunctionDeclaration* decl =
2664  new(zone_) FunctionDeclaration(proxy, mode, fun, scope);
2666  }
2667 
2669  Module* module,
2670  Scope* scope) {
2671  ModuleDeclaration* decl =
2672  new(zone_) ModuleDeclaration(proxy, module, scope);
2674  }
2675 
2677  Module* module,
2678  Scope* scope) {
2679  ImportDeclaration* decl =
2680  new(zone_) ImportDeclaration(proxy, module, scope);
2682  }
2683 
2685  Scope* scope) {
2686  ExportDeclaration* decl =
2687  new(zone_) ExportDeclaration(proxy, scope);
2689  }
2690 
2692  ModuleLiteral* module = new(zone_) ModuleLiteral(body, interface);
2694  }
2695 
2697  ModuleVariable* module = new(zone_) ModuleVariable(proxy);
2699  }
2700 
2702  ModulePath* module = new(zone_) ModulePath(origin, name, zone_);
2703  VISIT_AND_RETURN(ModulePath, module)
2704  }
2705 
2707  ModuleUrl* module = new(zone_) ModuleUrl(url, zone_);
2708  VISIT_AND_RETURN(ModuleUrl, module)
2709  }
2710 
2712  int capacity,
2713  bool is_initializer_block,
2714  Zone* zone) {
2715  Block* block = new(zone_) Block(
2716  isolate_, labels, capacity, is_initializer_block, zone);
2717  VISIT_AND_RETURN(Block, block)
2718  }
2719 
2720 #define STATEMENT_WITH_LABELS(NodeType) \
2721  NodeType* New##NodeType(ZoneStringList* labels) { \
2722  NodeType* stmt = new(zone_) NodeType(isolate_, labels); \
2723  VISIT_AND_RETURN(NodeType, stmt); \
2724  }
2725  STATEMENT_WITH_LABELS(DoWhileStatement)
2726  STATEMENT_WITH_LABELS(WhileStatement)
2727  STATEMENT_WITH_LABELS(ForStatement)
2728  STATEMENT_WITH_LABELS(ForInStatement)
2729  STATEMENT_WITH_LABELS(SwitchStatement)
2730 #undef STATEMENT_WITH_LABELS
2731 
2733  ExpressionStatement* stmt = new(zone_) ExpressionStatement(expression);
2735  }
2736 
2738  ContinueStatement* stmt = new(zone_) ContinueStatement(target);
2740  }
2741 
2743  BreakStatement* stmt = new(zone_) BreakStatement(target);
2745  }
2746 
2748  ReturnStatement* stmt = new(zone_) ReturnStatement(expression);
2750  }
2751 
2753  Statement* statement) {
2754  WithStatement* stmt = new(zone_) WithStatement(expression, statement);
2756  }
2757 
2759  Statement* then_statement,
2760  Statement* else_statement) {
2761  IfStatement* stmt = new(zone_) IfStatement(
2762  isolate_, condition, then_statement, else_statement);
2764  }
2765 
2767  Block* try_block,
2768  Scope* scope,
2769  Variable* variable,
2770  Block* catch_block) {
2771  TryCatchStatement* stmt = new(zone_) TryCatchStatement(
2772  index, try_block, scope, variable, catch_block);
2774  }
2775 
2777  Block* try_block,
2778  Block* finally_block) {
2779  TryFinallyStatement* stmt =
2780  new(zone_) TryFinallyStatement(index, try_block, finally_block);
2782  }
2783 
2785  DebuggerStatement* stmt = new(zone_) DebuggerStatement();
2787  }
2788 
2790  return new(zone_) EmptyStatement();
2791  }
2792 
2794  Literal* lit = new(zone_) Literal(isolate_, handle);
2796  }
2797 
2798  Literal* NewNumberLiteral(double number) {
2799  return NewLiteral(isolate_->factory()->NewNumber(number, TENURED));
2800  }
2801 
2803  Handle<FixedArray> constant_properties,
2805  int literal_index,
2806  bool is_simple,
2807  bool fast_elements,
2808  int depth,
2809  bool has_function) {
2810  ObjectLiteral* lit = new(zone_) ObjectLiteral(
2811  isolate_, constant_properties, properties, literal_index,
2812  is_simple, fast_elements, depth, has_function);
2814  }
2815 
2817  FunctionLiteral* value) {
2818  ObjectLiteral::Property* prop =
2819  new(zone_) ObjectLiteral::Property(is_getter, value);
2820  prop->set_key(NewLiteral(value->name()));
2821  return prop; // Not an AST node, will not be visited.
2822  }
2823 
2826  int literal_index) {
2827  RegExpLiteral* lit =
2828  new(zone_) RegExpLiteral(isolate_, pattern, flags, literal_index);
2830  }
2831 
2833  ZoneList<Expression*>* values,
2834  int literal_index,
2835  bool is_simple,
2836  int depth) {
2837  ArrayLiteral* lit = new(zone_) ArrayLiteral(
2838  isolate_, constant_elements, values, literal_index, is_simple, depth);
2840  }
2841 
2843  VariableProxy* proxy = new(zone_) VariableProxy(isolate_, var);
2845  }
2846 
2848  bool is_this,
2849  int position = RelocInfo::kNoPosition,
2850  Interface* interface =
2851  Interface::NewValue()) {
2852  VariableProxy* proxy =
2853  new(zone_) VariableProxy(isolate_, name, is_this, position, interface);
2855  }
2856 
2857  Property* NewProperty(Expression* obj, Expression* key, int pos) {
2858  Property* prop = new(zone_) Property(isolate_, obj, key, pos);
2859  VISIT_AND_RETURN(Property, prop)
2860  }
2861 
2862  Call* NewCall(Expression* expression,
2863  ZoneList<Expression*>* arguments,
2864  int pos) {
2865  Call* call = new(zone_) Call(isolate_, expression, arguments, pos);
2866  VISIT_AND_RETURN(Call, call)
2867  }
2868 
2870  ZoneList<Expression*>* arguments,
2871  int pos) {
2872  CallNew* call = new(zone_) CallNew(isolate_, expression, arguments, pos);
2873  VISIT_AND_RETURN(CallNew, call)
2874  }
2875 
2877  const Runtime::Function* function,
2878  ZoneList<Expression*>* arguments) {
2879  CallRuntime* call =
2880  new(zone_) CallRuntime(isolate_, name, function, arguments);
2882  }
2883 
2885  Expression* expression,
2886  int pos) {
2887  UnaryOperation* node =
2888  new(zone_) UnaryOperation(isolate_, op, expression, pos);
2890  }
2891 
2893  Expression* left,
2894  Expression* right,
2895  int pos) {
2896  BinaryOperation* node =
2897  new(zone_) BinaryOperation(isolate_, op, left, right, pos);
2899  }
2900 
2902  bool is_prefix,
2903  Expression* expr,
2904  int pos) {
2905  CountOperation* node =
2906  new(zone_) CountOperation(isolate_, op, is_prefix, expr, pos);
2908  }
2909 
2911  Expression* left,
2912  Expression* right,
2913  int pos) {
2914  CompareOperation* node =
2915  new(zone_) CompareOperation(isolate_, op, left, right, pos);
2917  }
2918 
2920  Expression* then_expression,
2921  Expression* else_expression,
2922  int then_expression_position,
2923  int else_expression_position) {
2924  Conditional* cond = new(zone_) Conditional(
2925  isolate_, condition, then_expression, else_expression,
2926  then_expression_position, else_expression_position);
2928  }
2929 
2931  Expression* target,
2932  Expression* value,
2933  int pos) {
2934  Assignment* assign =
2935  new(zone_) Assignment(isolate_, op, target, value, pos);
2936  assign->Init(isolate_, this);
2937  VISIT_AND_RETURN(Assignment, assign)
2938  }
2939 
2940  Throw* NewThrow(Expression* exception, int pos) {
2941  Throw* t = new(zone_) Throw(isolate_, exception, pos);
2943  }
2944 
2946  Handle<String> name,
2947  Scope* scope,
2948  ZoneList<Statement*>* body,
2949  int materialized_literal_count,
2950  int expected_property_count,
2951  int handler_count,
2954  int parameter_count,
2955  FunctionLiteral::ParameterFlag has_duplicate_parameters,
2957  FunctionLiteral::IsFunctionFlag is_function) {
2958  FunctionLiteral* lit = new(zone_) FunctionLiteral(
2959  isolate_, name, scope, body,
2960  materialized_literal_count, expected_property_count, handler_count,
2961  has_only_simple_this_property_assignments, this_property_assignments,
2962  parameter_count, type, has_duplicate_parameters, is_function);
2963  // Top-level literal doesn't count for the AST's properties.
2964  if (is_function == FunctionLiteral::kIsFunction) {
2965  visitor_.VisitFunctionLiteral(lit);
2966  }
2967  return lit;
2968  }
2969 
2971  Handle<SharedFunctionInfo> shared_function_info) {
2973  new(zone_) SharedFunctionInfoLiteral(isolate_, shared_function_info);
2975  }
2976 
2978  ThisFunction* fun = new(zone_) ThisFunction(isolate_);
2980  }
2981 
2982 #undef VISIT_AND_RETURN
2983 
2984  private:
2985  Isolate* isolate_;
2986  Zone* zone_;
2987  Visitor visitor_;
2988 };
2989 
2990 
2991 } } // namespace v8::internal
2992 
2993 #endif // V8_AST_H_
ZoneList< TextElement > * elements()
Definition: ast.h:2397
Block(Isolate *isolate, ZoneStringList *labels, int capacity, bool is_initializer_block, Zone *zone)
Definition: ast.h:432
virtual int max_match()
Definition: ast.h:2262
FunctionDeclaration * NewFunctionDeclaration(VariableProxy *proxy, VariableMode mode, FunctionLiteral *fun, Scope *scope)
Definition: ast.h:2659
const SwVfpRegister s2
Visitor * visitor()
Definition: ast.h:2645
Module(Interface *interface)
Definition: ast.h:602
RegExpLiteral(Isolate *isolate, Handle< String > pattern, Handle< String > flags, int literal_index)
Definition: ast.h:1419
bool IsFalse() const
Definition: ast.h:1247
virtual bool IsMonomorphic()
Definition: ast.h:1535
void set_condition_position(int pos)
Definition: ast.h:733
virtual int position() const
Definition: ast.h:1944
void set_may_have_function_literal(bool value)
Definition: ast.h:772
Handle< JSGlobalPropertyCell > cell()
Definition: ast.h:1588
Handle< FixedArray > this_property_assignments()
Definition: ast.h:2062
ModuleVariable(VariableProxy *proxy)
Definition: ast.h:2551
virtual int min_match()
Definition: ast.h:2289
#define FOR_EACH_REG_EXP_TREE_TYPE(VISIT)
Definition: jsregexp.h:394
Handle< Map > at(int i) const
Definition: ast.h:282
RegExpText(Zone *zone)
Definition: ast.h:2383
Property(Isolate *isolate, Expression *obj, Expression *key, int pos)
Definition: ast.h:1543
virtual bool IsTextElement()
Definition: ast.h:2211
TryFinallyStatement(int index, Block *try_block, Block *finally_block)
Definition: ast.h:1187
Expression * right() const
Definition: ast.h:1849
VariableProxy * NewVariableProxy(Handle< String > name, bool is_this, int position=RelocInfo::kNoPosition, Interface *interface=Interface::NewValue())
Definition: ast.h:2847
virtual Expression * AsExpression()
Definition: ast.h:224
virtual int position() const
Definition: ast.h:1850
Expression * obj() const
Definition: ast.h:1525
AstNodeFactory(Isolate *isolate)
Definition: ast.h:2641
ModulePath(Module *module, Handle< String > name, Zone *zone)
Definition: ast.h:656
bool is_default() const
Definition: ast.h:992
Expression * condition() const
Definition: ast.h:1069
Expression * left() const
Definition: ast.h:1757
Expression * cond() const
Definition: ast.h:814
Block * try_block() const
Definition: ast.h:1131
virtual int position() const
Definition: ast.h:1527
void set_escaping_targets(ZoneList< Label * > *targets)
Definition: ast.h:1126
Handle< Map > GetMonomorphicReceiverType()
Definition: ast.h:351
virtual int position() const
Definition: ast.h:311
Call(Isolate *isolate, Expression *expression, ZoneList< Expression * > *arguments, int pos)
Definition: ast.h:1604
static String * cast(Object *obj)
virtual void MarkAsStatement()
Definition: ast.h:1805
ModuleLiteral * NewModuleLiteral(Block *body, Interface *interface)
Definition: ast.h:2691
Handle< JSFunction > target()
Definition: ast.h:1586
Definition: v8.h:863
RegExpLiteral * NewRegExpLiteral(Handle< String > pattern, Handle< String > flags, int literal_index)
Definition: ast.h:2824
int CompoundLoadId() const
Definition: ast.h:1965
static const int kDeclarationsId
Definition: ast.h:202
Expression * expression() const
Definition: ast.h:1802
virtual bool IsMonomorphic()
Definition: ast.h:1584
FunctionLiteral(Isolate *isolate, Handle< String > name, Scope *scope, ZoneList< Statement * > *body, int materialized_literal_count, int expected_property_count, int handler_count, bool has_only_simple_this_property_assignments, Handle< FixedArray > this_property_assignments, int parameter_count, Type type, ParameterFlag has_duplicate_parameters, IsFunctionFlag is_function)
Definition: ast.h:2097
CharacterSet character_set()
Definition: ast.h:2337
ZoneList< CharacterRange > * ranges(Zone *zone)
Definition: ast.h:2353
ForInStatement(Isolate *isolate, ZoneStringList *labels)
Definition: ast.h:880
Block * NewBlock(ZoneStringList *labels, int capacity, bool is_initializer_block, Zone *zone)
Definition: ast.h:2711
CallRuntime(Isolate *isolate, Handle< String > name, const Runtime::Function *function, ZoneList< Expression * > *arguments)
Definition: ast.h:1689
Handle< String > AsPropertyName()
Definition: ast.h:1230
ZoneList< Expression * > * arguments() const
Definition: ast.h:1578
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
virtual InitializationFlag initialization() const
Definition: ast.h:506
virtual Statement * AsStatement()
Definition: ast.h:254
static bool IsCompareOp(Value op)
Definition: token.h:214
static Handle< T > cast(Handle< S > that)
Definition: handles.h:81
BreakStatement(BreakableStatement *target)
Definition: ast.h:940
ExportDeclaration(VariableProxy *proxy, Scope *scope)
Definition: ast.h:589
Expression * target() const
Definition: ast.h:1942
RegExpTree * body()
Definition: ast.h:2500
virtual int ContinueId() const
Definition: ast.h:736
ExpressionStatement * NewExpressionStatement(Expression *expression)
Definition: ast.h:2732
static bool IsUnaryOp(Value op)
Definition: token.h:260
virtual Declaration * AsDeclaration()
Definition: ast.h:222
Handle< JSObject > holder()
Definition: ast.h:1587
int GetIdForElement(int i)
Definition: ast.h:1442
ThisFunction(Isolate *isolate)
Definition: ast.h:2184
VariableDeclaration * NewVariableDeclaration(VariableProxy *proxy, VariableMode mode, Scope *scope)
Definition: ast.h:2651
void set_standard_set_type(uc16 special_set_type)
Definition: ast.h:2307
int IfId() const
Definition: ast.h:1073
Statement * init() const
Definition: ast.h:813
uint32_t Hash()
Definition: ast.h:1256
bool is_expression() const
Definition: ast.h:2051
virtual Declaration * AsDeclaration()
Definition: ast.h:458
void mark_block_start()
Definition: ast.h:1956
Flag flags[]
Definition: flags.cc:1467
static const int kNoNumber
Definition: ast.h:197
bool is_classic_mode() const
Definition: ast.h:2053
bool IsVariable(Handle< String > n)
Definition: ast.h:1473
virtual bool IsMonomorphic()
Definition: ast.h:343
Statement * next() const
Definition: ast.h:815
virtual bool IsTextElement()
Definition: ast.h:2389
virtual ~RegExpTree()
Definition: ast.h:2207
virtual void Accept(AstVisitor *v)
Definition: ast.h:1114
ZoneList< Expression * > * arguments() const
Definition: ast.h:1683
ModuleUrl * NewModuleUrl(Handle< String > url)
Definition: ast.h:2706
const int kMaxInt
Definition: globals.h:224
virtual bool ResultOverwriteAllowed()
Definition: ast.h:331
SmallMapList(int capacity, Zone *zone)
Definition: ast.h:269
virtual bool IsAnchoredAtEnd()
Definition: ast.h:2213
virtual int StackCheckId() const
Definition: ast.h:737
bool IsFunctionPrototype() const
Definition: ast.h:1531
FlagType type_
Definition: flags.cc:1351
unibrow::Mapping< unibrow::Ecma262Canonicalize > Canonicalize
VariableProxy * NewVariableProxy(Variable *var)
Definition: ast.h:2842
int ThenId() const
Definition: ast.h:1901
#define ASSERT(condition)
Definition: checks.h:270
ZoneList< Label * > * escaping_targets() const
Definition: ast.h:1132
ForStatement(Isolate *isolate, ZoneStringList *labels)
Definition: ast.h:836
ModuleDeclaration * NewModuleDeclaration(VariableProxy *proxy, Module *module, Scope *scope)
Definition: ast.h:2668
virtual int position() const
Definition: ast.h:1759
void Init(Isolate *isolate, AstNodeFactory< Visitor > *factory)
Definition: ast.h:1978
Interface * interface() const
Definition: ast.h:598
TryStatement(int index, Block *try_block)
Definition: ast.h:1135
bool has_only_simple_this_property_assignments()
Definition: ast.h:2059
int ThenId() const
Definition: ast.h:1074
Expression(Isolate *isolate)
Definition: ast.h:362
ObjectLiteral(Isolate *isolate, Handle< FixedArray > constant_properties, ZoneList< Property * > *properties, int literal_index, bool is_simple, bool fast_elements, int depth, bool has_function)
Definition: ast.h:1386
TryCatchStatement(int index, Block *try_block, Scope *scope, Variable *variable, Block *catch_block)
Definition: ast.h:1160
virtual MaterializedLiteral * AsMaterializedLiteral()
Definition: ast.h:228
bool HasElseStatement() const
Definition: ast.h:1067
int ElseId() const
Definition: ast.h:1075
Expression * enumerable() const
Definition: ast.h:870
ZoneList< Statement * > * body() const
Definition: ast.h:2045
#define CHECK(condition)
Definition: checks.h:56
virtual int min_match()
Definition: ast.h:2390
void Initialize(Statement *body)
Definition: ast.h:708
bool may_have_function_literal() const
Definition: ast.h:817
virtual bool IsValidLeftHandSide()
Definition: ast.h:318
void Reserve(int capacity, Zone *zone)
Definition: ast.h:271
Handle< String > debug_name() const
Definition: ast.h:2069
Handle< Context > context() const
Definition: ast.h:614
void set_loop_variable(Variable *var)
Definition: ast.h:831
Handle< String > name() const
Definition: ast.h:1483
virtual int ContinueId() const
Definition: ast.h:825
ArrayLiteral * NewArrayLiteral(Handle< FixedArray > constant_elements, ZoneList< Expression * > *values, int literal_index, bool is_simple, int depth)
Definition: ast.h:2832
ZoneList< Expression * > * values() const
Definition: ast.h:1439
int RightId() const
Definition: ast.h:1762
BreakableStatement(Isolate *isolate, ZoneStringList *labels, Type type)
Definition: ast.h:397
static Interval Empty()
Definition: jsregexp.h:695
static const int kFunctionEntryId
Definition: ast.h:198
int BodyId() const
Definition: ast.h:779
bool is_this() const
Definition: ast.h:1485
bool AsArrayIndex(uint32_t *index)
Definition: objects-inl.h:4748
int position() const
Definition: ast.h:1000
virtual bool ToBooleanIsTrue()
Definition: ast.h:1235
#define VISIT_AND_RETURN(NodeType, node)
Definition: ast.h:2647
Conditional(Isolate *isolate, Expression *condition, Expression *then_expression, Expression *else_expression, int then_expression_position, int else_expression_position)
Definition: ast.h:1907
int BodyId() const
Definition: ast.h:874
CompareOperation * NewCompareOperation(Token::Value op, Expression *left, Expression *right, int pos)
Definition: ast.h:2910
#define DECLARE_TYPE_ENUM(type)
Definition: ast.h:190
virtual SmallMapList * GetReceiverTypes()
Definition: ast.h:1809
RegExpCharacterClass(ZoneList< CharacterRange > *ranges, bool is_negated)
Definition: ast.h:2322
WhileStatement(Isolate *isolate, ZoneStringList *labels)
Definition: ast.h:784
CharacterSet(uc16 standard_set_type)
Definition: ast.h:2299
Variable * loop_variable()
Definition: ast.h:830
virtual bool IsTextElement()
Definition: ast.h:2333
CallNew(Isolate *isolate, Expression *expression, ZoneList< Expression * > *arguments, int pos)
Definition: ast.h:1650
virtual SmallMapList * GetReceiverTypes()
Definition: ast.h:1536
bool is_jsruntime() const
Definition: ast.h:1684
Assignment * NewAssignment(Token::Value op, Expression *target, Expression *value, int pos)
Definition: ast.h:2930
ReturnStatement(Expression *expression)
Definition: ast.h:957
ZoneList< Statement * > * statements() const
Definition: ast.h:998
Token::Value op() const
Definition: ast.h:1797
friend class CaseClause
Definition: ast.h:246
virtual ~AstNode()
Definition: ast.h:210
bool IsStringLength() const
Definition: ast.h:1529
static RegExpEmpty * GetInstance()
Definition: ast.h:2541
bool IsStringAccess() const
Definition: ast.h:1530
static Interface * NewValue()
Definition: interface.h:51
Scope * scope() const
Definition: ast.h:426
kPropertyAccessorsOffset kNamedPropertyHandlerOffset kInstanceTemplateOffset kAccessCheckInfoOffset kEvalFrominstructionsOffsetOffset this_property_assignments
Definition: objects-inl.h:3674
virtual Interval CaptureRegisters()
Definition: ast.h:2218
virtual BreakableStatement * AsBreakableStatement()
Definition: ast.h:226
int BackEdgeId() const
Definition: ast.h:738
T ** location() const
Definition: handles.h:75
kPropertyAccessorsOffset kNamedPropertyHandlerOffset kInstanceTemplateOffset kAccessCheckInfoOffset kEvalFrominstructionsOffsetOffset kThisPropertyAssignmentsOffset kNeedsAccessCheckBit kIsExpressionBit has_only_simple_this_property_assignments
Definition: objects-inl.h:3691
Expression * cond() const
Definition: ast.h:728
MaterializedLiteral(Isolate *isolate, int literal_index, bool is_simple, int depth)
Definition: ast.h:1292
CheckType check_type() const
Definition: ast.h:1585
CharacterSet(ZoneList< CharacterRange > *ranges)
Definition: ast.h:2302
bool ends_initialization_block()
Definition: ast.h:1955
Variable * var() const
Definition: ast.h:1484
#define UNREACHABLE()
Definition: checks.h:50
int AssignmentId() const
Definition: ast.h:1966
VariableProxy * proxy() const
Definition: ast.h:452
IterationStatement(Isolate *isolate, ZoneStringList *labels)
Definition: ast.h:702
ZoneList< Label * > * targets()
Definition: ast.h:1117
bool IsUninitialized()
Definition: ast.h:1538
Throw * NewThrow(Expression *exception, int pos)
Definition: ast.h:2940
virtual MaterializedLiteral * AsMaterializedLiteral()
Definition: ast.h:1281
Interface * interface_
Definition: ast.h:1515
ObjectLiteral * NewObjectLiteral(Handle< FixedArray > constant_properties, ZoneList< ObjectLiteral::Property * > *properties, int literal_index, bool is_simple, bool fast_elements, int depth, bool has_function)
Definition: ast.h:2802
bool IsNull() const
Definition: ast.h:1239
virtual BreakableStatement * AsBreakableStatement()
Definition: ast.h:384
bool IsSymbolCompare()
Definition: ast.h:1009
virtual ~RegExpVisitor()
Definition: ast.h:2196
virtual SmallMapList * GetReceiverTypes()
Definition: ast.h:1583
virtual bool IsTextElement()
Definition: ast.h:2370
Module(Zone *zone)
Definition: ast.h:601
ModuleVariable * NewModuleVariable(VariableProxy *proxy)
Definition: ast.h:2696
bool IsStringCompare()
Definition: ast.h:1010
FunctionDeclaration(VariableProxy *proxy, VariableMode mode, FunctionLiteral *fun, Scope *scope)
Definition: ast.h:514
virtual int min_match()
Definition: ast.h:2498
int length() const
Definition: ast.h:276
RegExpTree * body()
Definition: ast.h:2469
int function_token_position() const
Definition: ast.h:2047
BinaryOperation * binary_operation() const
Definition: ast.h:1945
int AssignmentId() const
Definition: ast.h:1812
static int StartRegister(int index)
Definition: ast.h:2471
static bool IsAssignmentOp(Value tok)
Definition: token.h:206
void set_scope(Scope *scope)
Definition: ast.h:427
virtual Expression * AsExpression()
Definition: ast.h:316
bool IsTrue() const
Definition: ast.h:1243
RegExpLookahead(RegExpTree *body, bool is_positive, int capture_count, int capture_from)
Definition: ast.h:2482
Handle< String > flags() const
Definition: ast.h:1414
ZoneList< RegExpTree * > * alternatives()
Definition: ast.h:2242
virtual int max_match()
Definition: ast.h:2372
void set_position(int pos)
Definition: ast.h:1001
bool starts_initialization_block()
Definition: ast.h:1954
UnaryOperation * NewUnaryOperation(Token::Value op, Expression *expression, int pos)
Definition: ast.h:2884
Handle< String > name_
Definition: ast.h:1507
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition: globals.h:321
Handle< String > inferred_name() const
Definition: ast.h:2074
virtual InitializationFlag initialization() const
Definition: ast.h:559
ZoneList< Property * > * properties() const
Definition: ast.h:1360
BinaryOperation(Isolate *isolate, Token::Value op, Expression *left, Expression *right, int pos)
Definition: ast.h:1767
virtual TargetCollector * AsTargetCollector()
Definition: ast.h:225
#define MAKE_ASTYPE(Name)
Definition: ast.h:2221
Handle< String > name() const
Definition: ast.h:651
#define STATEMENT_WITH_LABELS(NodeType)
Definition: ast.h:2720
Statement * then_statement() const
Definition: ast.h:1070
Token::Value binary_op()
Definition: ast.h:1798
Expression * expression() const
Definition: ast.h:901
Call * NewCall(Expression *expression, ZoneList< Expression * > *arguments, int pos)
Definition: ast.h:2862
virtual int position() const
Definition: ast.h:1713
ZoneList< Statement * > * statements()
Definition: ast.h:423
virtual int min_match()
Definition: ast.h:2371
UnaryOperation(Isolate *isolate, Token::Value op, Expression *expression, int pos)
Definition: ast.h:1721
EmptyStatement * NewEmptyStatement()
Definition: ast.h:2789
Token::Value op() const
Definition: ast.h:1711
int CountId() const
Definition: ast.h:1813
Expression * label() const
Definition: ast.h:993
int then_expression_position() const
Definition: ast.h:1898
CallNew * NewCallNew(Expression *expression, ZoneList< Expression * > *arguments, int pos)
Definition: ast.h:2869
Expression * key() const
Definition: ast.h:1526
virtual int min_match()
Definition: ast.h:2432
WithStatement * NewWithStatement(Expression *expression, Statement *statement)
Definition: ast.h:2752
RegExpCapture(RegExpTree *body, int index)
Definition: ast.h:2453
#define DECLARE_NODE_TYPE(type)
Definition: ast.h:159
static int GetNextId(Isolate *isolate)
Definition: ast.h:231
CompareOperation(Isolate *isolate, Token::Value op, Expression *left, Expression *right, int pos)
Definition: ast.h:1865
#define BASE_EMBEDDED
Definition: allocation.h:68
ReturnStatement * NewReturnStatement(Expression *expression)
Definition: ast.h:2747
virtual Type node_type() const
Definition: ast.h:213
Expression * cond() const
Definition: ast.h:768
virtual bool IsPropertyName()
Definition: ast.h:327
virtual int position() const
Definition: ast.h:2009
Handle< Object > handle() const
Definition: ast.h:1252
#define MAKE_CASE(Name)
Definition: ast.h:2197
AstProperties * ast_properties()
Definition: ast.h:2606
#define AST_NODE_LIST(V)
Definition: ast.h:115
int statement_pos() const
Definition: ast.h:259
virtual int position() const
Definition: ast.h:1579
bool is_anonymous() const
Definition: ast.h:2052
int SourceSize() const
Definition: ast.h:2050
ModuleUrl(Handle< String > url, Zone *zone)
Definition: ast.h:677
RegExpQuantifier(int min, int max, Type type, RegExpTree *body)
Definition: ast.h:2407
const SwVfpRegister s1
SharedFunctionInfoLiteral * NewSharedFunctionInfoLiteral(Handle< SharedFunctionInfo > shared_function_info)
Definition: ast.h:2970
Scope * scope() const
Definition: ast.h:2044
static int ReserveIdRange(Isolate *isolate, int n)
Definition: ast.h:235
Statement * else_statement() const
Definition: ast.h:1071
Expression * left() const
Definition: ast.h:1848
virtual int max_match()
Definition: ast.h:2468
ExpressionStatement(Expression *expression)
Definition: ast.h:906
bool IsObjectCompare()
Definition: ast.h:1011
RegExpBackReference(RegExpCapture *capture)
Definition: ast.h:2515
virtual SmallMapList * GetReceiverTypes()
Definition: ast.h:347
SwitchStatement(Isolate *isolate, ZoneStringList *labels)
Definition: ast.h:1046
Literal(Isolate *isolate, Handle< Object > handle)
Definition: ast.h:1267
static bool IsBinaryOp(Value op)
Definition: token.h:210
ModuleDeclaration(VariableProxy *proxy, Module *module, Scope *scope)
Definition: ast.h:542
Conditional * NewConditional(Expression *condition, Expression *then_expression, Expression *else_expression, int then_expression_position, int else_expression_position)
Definition: ast.h:2919
Label * body_target()
Definition: ast.h:997
bool is_target_for_anonymous() const
Definition: ast.h:390
Scope * scope() const
Definition: ast.h:454
Handle< Map > GetReceiverType()
Definition: ast.h:1334
#define DEF_FORWARD_DECLARATION(type)
Definition: ast.h:148
void set_statement_pos(int statement_pos)
Definition: ast.h:258
int position() const
Definition: ast.h:1486
Handle< Map > last() const
Definition: ast.h:287
ThisFunction * NewThisFunction()
Definition: ast.h:2977
ObjectLiteral::Property * NewObjectLiteralProperty(bool is_getter, FunctionLiteral *value)
Definition: ast.h:2816
DoWhileStatement(Isolate *isolate, ZoneStringList *labels)
Definition: ast.h:743
bool IsArrayLength()
Definition: ast.h:1537
RegExpCapture * capture()
Definition: ast.h:2525
Statement * statement() const
Definition: ast.h:970
Expression * value() const
Definition: ast.h:1943
uint16_t uc16
Definition: globals.h:273
int BodyId() const
Definition: ast.h:827
virtual int max_match()
Definition: ast.h:2540
unsigned test_id() const
Definition: ast.h:359
Expression * right() const
Definition: ast.h:1758
virtual bool IsAnchoredAtStart()
Definition: ast.h:2212
Expression * then_expression() const
Definition: ast.h:1895
Token::Value op() const
Definition: ast.h:1941
ModulePath * NewModulePath(Module *origin, Handle< String > name)
Definition: ast.h:2701
virtual bool ToBooleanIsFalse()
Definition: ast.h:1236
virtual bool IsMonomorphic()
Definition: ast.h:1808
bool HasStackOverflow() const
Definition: ast.h:2575
Declaration(VariableProxy *proxy, VariableMode mode, Scope *scope)
Definition: ast.h:461
bool is_empty() const
Definition: ast.h:275
kPropertyAccessorsOffset kNamedPropertyHandlerOffset kInstanceTemplateOffset kAccessCheckInfoOffset kEvalFrominstructionsOffsetOffset kThisPropertyAssignmentsOffset flag
Definition: objects-inl.h:3682
bool fast_elements() const
Definition: ast.h:1362
Vector< const uc16 > data()
Definition: ast.h:2374
Isolate * isolate()
Definition: ast.h:2591
bool is_compound() const
Definition: ast.h:1948
virtual int min_match()
Definition: ast.h:2240
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
ZoneList< Handle< Object > > ZoneObjectList
Definition: ast.h:156
ArrayLiteral(Isolate *isolate, Handle< FixedArray > constant_elements, ZoneList< Expression * > *values, int literal_index, bool is_simple, int depth)
Definition: ast.h:1447
virtual int min_match()
Definition: ast.h:2539
void set_ast_properties(AstProperties *ast_properties)
Definition: ast.h:2090
CountOperation * NewCountOperation(Token::Value op, bool is_prefix, Expression *expr, int pos)
Definition: ast.h:2901
Literal * NewLiteral(Handle< Object > handle)
Definition: ast.h:2793
Handle< String > name() const
Definition: ast.h:2043
int ElseId() const
Definition: ast.h:1902
virtual bool ToBooleanIsFalse()
Definition: ast.h:322
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
int else_expression_position() const
Definition: ast.h:1899
AstProperties::Flags * flags()
Definition: ast.h:2089
ZoneStringList * labels() const
Definition: ast.h:381
RegExpAtom(Vector< const uc16 > data)
Definition: ast.h:2364
virtual int ContinueId() const
Definition: ast.h:777
virtual Statement * AsStatement()
Definition: ast.h:223
#define DECLARE_NODE_FUNCTIONS(type)
Definition: ast.h:216
Expression * else_expression() const
Definition: ast.h:1896
Interface * interface() const
Definition: ast.h:1487
virtual TargetCollector * AsTargetCollector()
Definition: ast.h:1115
virtual int ContinueId() const
Definition: ast.h:872
virtual int position() const
Definition: ast.h:1638
FunctionLiteral * NewFunctionLiteral(Handle< String > name, Scope *scope, ZoneList< Statement * > *body, int materialized_literal_count, int expected_property_count, int handler_count, bool has_only_simple_this_property_assignments, Handle< FixedArray > this_property_assignments, int parameter_count, FunctionLiteral::ParameterFlag has_duplicate_parameters, FunctionLiteral::Type type, FunctionLiteral::IsFunctionFlag is_function)
Definition: ast.h:2945
CountOperation(Isolate *isolate, Token::Value op, bool is_prefix, Expression *expr, int pos)
Definition: ast.h:1818
bool is_initializer_block() const
Definition: ast.h:424
ZoneList< Handle< String > > ZoneStringList
Definition: ast.h:155
void add_node_count(int count)
Definition: ast.h:180
Expression * expression() const
Definition: ast.h:1712
CallRuntime * NewCallRuntime(Handle< String > name, const Runtime::Function *function, ZoneList< Expression * > *arguments)
Definition: ast.h:2876
ImportDeclaration(VariableProxy *proxy, Module *module, Scope *scope)
Definition: ast.h:566
const char * name_
Definition: flags.cc:1352
virtual int position() const
Definition: ast.h:1803
virtual int max_match()
Definition: ast.h:2499
Token::Value op() const
Definition: ast.h:1756
virtual int StackCheckId() const
Definition: ast.h:873
int ReturnId() const
Definition: ast.h:1645
static bool Match(void *literal1, void *literal2)
Definition: ast.h:1258
ZoneList< CaseClause * > * cases() const
Definition: ast.h:1041
TryFinallyStatement * NewTryFinallyStatement(int index, Block *try_block, Block *finally_block)
Definition: ast.h:2776
Block * catch_block() const
Definition: ast.h:1155
TargetCollector(Zone *zone)
Definition: ast.h:1106
virtual int StackCheckId() const
Definition: ast.h:826
unsigned id() const
Definition: ast.h:358
virtual bool ToBooleanIsTrue()
Definition: ast.h:321
DebuggerStatement * NewDebuggerStatement()
Definition: ast.h:2784
virtual int max_match()
Definition: ast.h:2241
BreakStatement * NewBreakStatement(BreakableStatement *target)
Definition: ast.h:2742
virtual int max_match()
Definition: ast.h:2290
#define DEF_VISIT(type)
Definition: ast.h:2627
Throw(Isolate *isolate, Expression *exception, int pos)
Definition: ast.h:2014
virtual int min_match()
Definition: ast.h:2467
virtual int max_match()
Definition: ast.h:2433
virtual IterationStatement * AsIterationStatement()
Definition: ast.h:227
ContinueStatement * NewContinueStatement(IterationStatement *target)
Definition: ast.h:2737
void set_key(Literal *key)
Definition: ast.h:1345
static int EndRegister(int index)
Definition: ast.h:2472
SharedFunctionInfoLiteral(Isolate *isolate, Handle< SharedFunctionInfo > shared_function_info)
Definition: ast.h:2166
TryCatchStatement * NewTryCatchStatement(int index, Block *try_block, Scope *scope, Variable *variable, Block *catch_block)
Definition: ast.h:2766
VariableDeclaration(VariableProxy *proxy, VariableMode mode, Scope *scope)
Definition: ast.h:493
Expression * tag() const
Definition: ast.h:1040
void set_function_token_position(int pos)
Definition: ast.h:2046
virtual void Accept(AstVisitor *v)=0
virtual int StackCheckId() const
Definition: ast.h:778
void Add(Handle< Map > handle, Zone *zone)
Definition: ast.h:278
int PrepareId() const
Definition: ast.h:875
Handle< Map > first() const
Definition: ast.h:286
virtual bool IsMonomorphic()
Definition: ast.h:1641
Handle< JSFunction > target()
Definition: ast.h:1642
VariableMode mode() const
Definition: ast.h:453
bool may_have_function_literal() const
Definition: ast.h:769
virtual int max_match()=0
bool is_postfix() const
Definition: ast.h:1795
RegExpAssertion(Type type)
Definition: ast.h:2281
ZoneList< RegExpTree * > * nodes()
Definition: ast.h:2263
Statement * body() const
Definition: ast.h:691
Literal * NewNumberLiteral(double number)
Definition: ast.h:2798
ContinueStatement(IterationStatement *target)
Definition: ast.h:923
void check(i::Vector< const char > string)
Expression * each() const
Definition: ast.h:869
RegExpTree * body()
Definition: ast.h:2439
IfStatement * NewIfStatement(Expression *condition, Statement *then_statement, Statement *else_statement)
Definition: ast.h:2758
AstPropertiesFlag
Definition: ast.h:164
int index() const
Definition: ast.h:1130
virtual bool IsMonomorphic()
Definition: ast.h:1961
ZoneList< Expression * > * arguments() const
Definition: ast.h:1637
ImportDeclaration * NewImportDeclaration(VariableProxy *proxy, Module *module, Scope *scope)
Definition: ast.h:2676
IfStatement(Isolate *isolate, Expression *condition, Statement *then_statement, Statement *else_statement)
Definition: ast.h:1080
FlagType type() const
Definition: flags.cc:1358
void Visit(AstNode *node)
Definition: ast.h:2567
virtual SmallMapList * GetReceiverTypes()
Definition: ast.h:1962
int ReturnId() const
Definition: ast.h:1594
void AddElement(TextElement elm, Zone *zone)
Definition: ast.h:2393
virtual int min_match()
Definition: ast.h:2261
BinaryOperation * NewBinaryOperation(Token::Value op, Expression *left, Expression *right, int pos)
Definition: ast.h:2892
WithStatement(Expression *expression, Statement *statement)
Definition: ast.h:975
virtual IterationStatement * AsIterationStatement()
Definition: ast.h:689
virtual int max_match()
Definition: ast.h:2391
ExportDeclaration * NewExportDeclaration(VariableProxy *proxy, Scope *scope)
Definition: ast.h:2684
void set_inferred_name(Handle< String > inferred_name)
Definition: ast.h:2075
Property * NewProperty(Expression *obj, Expression *key, int pos)
Definition: ast.h:2857
ModuleLiteral(Block *body, Interface *interface)
Definition: ast.h:619
virtual InitializationFlag initialization() const
Definition: ast.h:535
void set_may_have_function_literal(bool value)
Definition: ast.h:820