V8 Project
ast.h
Go to the documentation of this file.
1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef V8_AST_H_
6 #define V8_AST_H_
7 
8 #include "src/v8.h"
9 
10 #include "src/assembler.h"
11 #include "src/ast-value-factory.h"
12 #include "src/bailout-reason.h"
13 #include "src/factory.h"
14 #include "src/feedback-slots.h"
15 #include "src/interface.h"
16 #include "src/isolate.h"
17 #include "src/jsregexp.h"
18 #include "src/list-inl.h"
19 #include "src/runtime/runtime.h"
20 #include "src/small-pointer-list.h"
21 #include "src/smart-pointers.h"
22 #include "src/token.h"
23 #include "src/types.h"
24 #include "src/utils.h"
25 #include "src/variables.h"
26 #include "src/zone-inl.h"
27 
28 namespace v8 {
29 namespace internal {
30 
31 // The abstract syntax tree is an intermediate, light-weight
32 // representation of the parsed JavaScript code suitable for
33 // compilation to native code.
34 
35 // Nodes are allocated in a separate zone, which allows faster
36 // allocation and constant-time deallocation of the entire syntax
37 // tree.
38 
39 
40 // ----------------------------------------------------------------------------
41 // Nodes of the abstract syntax tree. Only concrete classes are
42 // enumerated here.
43 
44 #define DECLARATION_NODE_LIST(V) \
45  V(VariableDeclaration) \
46  V(FunctionDeclaration) \
47  V(ModuleDeclaration) \
48  V(ImportDeclaration) \
49  V(ExportDeclaration)
50 
51 #define MODULE_NODE_LIST(V) \
52  V(ModuleLiteral) \
53  V(ModuleVariable) \
54  V(ModulePath) \
55  V(ModuleUrl)
56 
57 #define STATEMENT_NODE_LIST(V) \
58  V(Block) \
59  V(ModuleStatement) \
60  V(ExpressionStatement) \
61  V(EmptyStatement) \
62  V(IfStatement) \
63  V(ContinueStatement) \
64  V(BreakStatement) \
65  V(ReturnStatement) \
66  V(WithStatement) \
67  V(SwitchStatement) \
68  V(DoWhileStatement) \
69  V(WhileStatement) \
70  V(ForStatement) \
71  V(ForInStatement) \
72  V(ForOfStatement) \
73  V(TryCatchStatement) \
74  V(TryFinallyStatement) \
75  V(DebuggerStatement)
76 
77 #define EXPRESSION_NODE_LIST(V) \
78  V(FunctionLiteral) \
79  V(ClassLiteral) \
80  V(NativeFunctionLiteral) \
81  V(Conditional) \
82  V(VariableProxy) \
83  V(Literal) \
84  V(RegExpLiteral) \
85  V(ObjectLiteral) \
86  V(ArrayLiteral) \
87  V(Assignment) \
88  V(Yield) \
89  V(Throw) \
90  V(Property) \
91  V(Call) \
92  V(CallNew) \
93  V(CallRuntime) \
94  V(UnaryOperation) \
95  V(CountOperation) \
96  V(BinaryOperation) \
97  V(CompareOperation) \
98  V(ThisFunction) \
99  V(SuperReference) \
100  V(CaseClause)
101 
102 #define AST_NODE_LIST(V) \
103  DECLARATION_NODE_LIST(V) \
104  MODULE_NODE_LIST(V) \
105  STATEMENT_NODE_LIST(V) \
106  EXPRESSION_NODE_LIST(V)
107 
108 // Forward declarations
109 class AstConstructionVisitor;
110 template<class> class AstNodeFactory;
111 class AstVisitor;
112 class Declaration;
113 class Module;
114 class BreakableStatement;
115 class Expression;
116 class IterationStatement;
117 class MaterializedLiteral;
118 class OStream;
119 class Statement;
120 class TargetCollector;
121 class TypeFeedbackOracle;
122 
123 class RegExpAlternative;
124 class RegExpAssertion;
125 class RegExpAtom;
126 class RegExpBackReference;
127 class RegExpCapture;
128 class RegExpCharacterClass;
129 class RegExpCompiler;
130 class RegExpDisjunction;
131 class RegExpEmpty;
132 class RegExpLookahead;
133 class RegExpQuantifier;
134 class RegExpText;
135 
136 #define DEF_FORWARD_DECLARATION(type) class type;
138 #undef DEF_FORWARD_DECLARATION
139 
140 
141 // Typedef only introduced to avoid unreadable code.
142 // Please do appreciate the required space in "> >".
145 
146 
147 #define DECLARE_NODE_TYPE(type) \
148  virtual void Accept(AstVisitor* v) OVERRIDE; \
149  virtual AstNode::NodeType node_type() const FINAL OVERRIDE { \
150  return AstNode::k##type; \
151  } \
152  template<class> friend class AstNodeFactory;
153 
154 
158  kDontCache
159 };
160 
161 
162 class AstProperties FINAL BASE_EMBEDDED {
163  public:
164  class Flags : public EnumSet<AstPropertiesFlag, int> {};
165 
166 AstProperties() : node_count_(0), feedback_slots_(0) {}
167 
168  Flags* flags() { return &flags_; }
169  int node_count() { return node_count_; }
170  void add_node_count(int count) { node_count_ += count; }
171 
172  int feedback_slots() const { return feedback_slots_; }
173  void increase_feedback_slots(int count) {
174  feedback_slots_ += count;
175  }
176 
177  private:
181 };
182 
183 
184 class AstNode: public ZoneObject {
185  public:
186  // For generating IDs for AstNodes.
187  class IdGen {
188  public:
189  explicit IdGen(int id = 0) : id_(id) {}
190 
191  int GetNextId() { return ReserveIdRange(1); }
192  int ReserveIdRange(int n) {
193  int tmp = id_;
194  id_ += n;
195  return tmp;
196  }
197 
198  private:
199  int id_;
200  };
201 
202 #define DECLARE_TYPE_ENUM(type) k##type,
203  enum NodeType {
205  kInvalid = -1
206  };
207 #undef DECLARE_TYPE_ENUM
208 
209  void* operator new(size_t size, Zone* zone) {
210  return zone->New(static_cast<int>(size));
211  }
212 
213  explicit AstNode(int position): position_(position) {}
214  virtual ~AstNode() {}
215 
216  virtual void Accept(AstVisitor* v) = 0;
217  virtual NodeType node_type() const = 0;
218  int position() const { return position_; }
219 
220  // Type testing & conversion functions overridden by concrete subclasses.
221 #define DECLARE_NODE_FUNCTIONS(type) \
222  bool Is##type() const { return node_type() == AstNode::k##type; } \
223  type* As##type() { \
224  return Is##type() ? reinterpret_cast<type*>(this) : NULL; \
225  } \
226  const type* As##type() const { \
227  return Is##type() ? reinterpret_cast<const type*>(this) : NULL; \
228  }
230 #undef DECLARE_NODE_FUNCTIONS
231 
232  virtual TargetCollector* AsTargetCollector() { return NULL; }
236 
237  protected:
238  // Some nodes re-use bailout IDs for type feedback.
240  return TypeFeedbackId(id.ToInt());
241  }
242 
243 
244  private:
245  // Hidden to prevent accidental usage. It would have to load the
246  // current zone from the TLS.
247  void* operator new(size_t size);
248 
249  friend class CaseClause; // Generates AST IDs.
250 
252 };
253 
254 
255 class Statement : public AstNode {
256  public:
257  explicit Statement(Zone* zone, int position) : AstNode(position) {}
258 
259  bool IsEmpty() { return AsEmptyStatement() != NULL; }
260  virtual bool IsJump() const { return false; }
261 };
262 
263 
264 class SmallMapList FINAL {
265  public:
267  SmallMapList(int capacity, Zone* zone) : list_(capacity, zone) {}
268 
269  void Reserve(int capacity, Zone* zone) { list_.Reserve(capacity, zone); }
270  void Clear() { list_.Clear(); }
271  void Sort() { list_.Sort(); }
272 
273  bool is_empty() const { return list_.is_empty(); }
274  int length() const { return list_.length(); }
275 
277  if (!Map::TryUpdate(map).ToHandle(&map)) return;
278  for (int i = 0; i < length(); ++i) {
279  if (at(i).is_identical_to(map)) return;
280  }
281  Add(map, zone);
282  }
283 
285  for (int i = list_.length() - 1; i >= 0; i--) {
286  if (at(i)->FindRootMap() != root_map) {
287  list_.RemoveElement(list_.at(i));
288  }
289  }
290  }
291 
292  void Add(Handle<Map> handle, Zone* zone) {
293  list_.Add(handle.location(), zone);
294  }
295 
296  Handle<Map> at(int i) const {
297  return Handle<Map>(list_.at(i));
298  }
299 
300  Handle<Map> first() const { return at(0); }
301  Handle<Map> last() const { return at(length() - 1); }
302 
303  private:
304  // The list stores pointers to Map*, that is Map**, so it's GC safe.
306 
308 };
309 
310 
311 class Expression : public AstNode {
312  public:
313  enum Context {
314  // Not assigned a context yet, or else will not be visited during
315  // code generation.
317  // Evaluated for its side effects.
319  // Evaluated for its value (and side effects).
321  // Evaluated for control flow (and side effects).
322  kTest
323  };
324 
325  virtual bool IsValidReferenceExpression() const { return false; }
326 
327  // Helpers for ToBoolean conversion.
328  virtual bool ToBooleanIsTrue() const { return false; }
329  virtual bool ToBooleanIsFalse() const { return false; }
330 
331  // Symbols that cannot be parsed as array indices are considered property
332  // names. We do not treat symbols that can be array indexes as property
333  // names because [] for string objects is handled only by keyed ICs.
334  virtual bool IsPropertyName() const { return false; }
335 
336  // True iff the result can be safely overwritten (to avoid allocation).
337  // False for operations that can return one of their operands.
338  virtual bool ResultOverwriteAllowed() const { return false; }
339 
340  // True iff the expression is a literal represented as a smi.
341  bool IsSmiLiteral() const;
342 
343  // True iff the expression is a string literal.
344  bool IsStringLiteral() const;
345 
346  // True iff the expression is the null literal.
347  bool IsNullLiteral() const;
348 
349  // True if we can prove that the expression is the undefined literal.
350  bool IsUndefinedLiteral(Isolate* isolate) const;
351 
352  // Expression type bounds
353  Bounds bounds() const { return bounds_; }
355 
356  // Whether the expression is parenthesized
357  unsigned parenthesization_level() const { return parenthesization_level_; }
358  bool is_parenthesized() const { return parenthesization_level_ > 0; }
360 
361  // Type feedback information for assignments and properties.
362  virtual bool IsMonomorphic() {
363  UNREACHABLE();
364  return false;
365  }
366  virtual SmallMapList* GetReceiverTypes() {
367  UNREACHABLE();
368  return NULL;
369  }
371  UNREACHABLE();
372  return STANDARD_STORE;
373  }
374 
375  // TODO(rossberg): this should move to its own AST node eventually.
376  virtual void RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle);
377  byte to_boolean_types() const { return to_boolean_types_; }
378 
379  BailoutId id() const { return id_; }
380  TypeFeedbackId test_id() const { return test_id_; }
381 
382  protected:
383  Expression(Zone* zone, int pos, IdGen* id_gen)
384  : AstNode(pos),
385  bounds_(Bounds::Unbounded(zone)),
387  id_(id_gen->GetNextId()),
388  test_id_(id_gen->GetNextId()) {}
389  void set_to_boolean_types(byte types) { to_boolean_types_ = types; }
390 
391  private:
395 
396  const BailoutId id_;
398 };
399 
400 
402  public:
406  };
407 
408  // The labels associated with this statement. May be NULL;
409  // if it is != NULL, guaranteed to contain at least one entry.
411 
412  // Type testing & conversion.
414  return this;
415  }
416 
417  // Code generation
418  Label* break_target() { return &break_target_; }
419 
420  // Testers.
421  bool is_target_for_anonymous() const {
423  }
424 
425  BailoutId EntryId() const { return entry_id_; }
426  BailoutId ExitId() const { return exit_id_; }
427 
428  protected:
430  BreakableType breakable_type, int position, IdGen* id_gen)
431  : Statement(zone, position),
432  labels_(labels),
433  breakable_type_(breakable_type),
434  entry_id_(id_gen->GetNextId()),
435  exit_id_(id_gen->GetNextId()) {
436  DCHECK(labels == NULL || labels->length() > 0);
437  }
438 
439 
440  private:
446 };
447 
448 
449 class Block FINAL : public BreakableStatement {
450  public:
451  DECLARE_NODE_TYPE(Block)
452 
453  void AddStatement(Statement* statement, Zone* zone) {
454  statements_.Add(statement, zone);
455  }
456 
457  ZoneList<Statement*>* statements() { return &statements_; }
458  bool is_initializer_block() const { return is_initializer_block_; }
459 
460  BailoutId DeclsId() const { return decls_id_; }
461 
462  virtual bool IsJump() const OVERRIDE {
463  return !statements_.is_empty() && statements_.last()->IsJump()
464  && labels() == NULL; // Good enough as an approximation...
465  }
466 
467  Scope* scope() const { return scope_; }
468  void set_scope(Scope* scope) { scope_ = scope; }
469 
470  protected:
471  Block(Zone* zone, ZoneList<const AstRawString*>* labels, int capacity,
472  bool is_initializer_block, int pos, IdGen* id_gen)
473  : BreakableStatement(zone, labels, TARGET_FOR_NAMED_ONLY, pos, id_gen),
474  statements_(capacity, zone),
475  is_initializer_block_(is_initializer_block),
476  decls_id_(id_gen->GetNextId()),
477  scope_(NULL) {}
478 
479  private:
484 };
485 
486 
487 class Declaration : public AstNode {
488  public:
489  VariableProxy* proxy() const { return proxy_; }
490  VariableMode mode() const { return mode_; }
491  Scope* scope() const { return scope_; }
492  virtual InitializationFlag initialization() const = 0;
493  virtual bool IsInlineable() const;
494 
495  protected:
497  VariableProxy* proxy,
499  Scope* scope,
500  int pos)
501  : AstNode(pos),
502  proxy_(proxy),
503  mode_(mode),
504  scope_(scope) {
506  }
507 
508  private:
509  VariableProxy* proxy_;
511 
512  // Nested scope from which the declaration originated.
514 };
515 
516 
517 class VariableDeclaration FINAL : public Declaration {
518  public:
519  DECLARE_NODE_TYPE(VariableDeclaration)
520 
521  virtual InitializationFlag initialization() const OVERRIDE {
523  }
524 
525  protected:
527  VariableProxy* proxy,
529  Scope* scope,
530  int pos)
531  : Declaration(zone, proxy, mode, scope, pos) {
532  }
533 };
534 
535 
536 class FunctionDeclaration FINAL : public Declaration {
537  public:
538  DECLARE_NODE_TYPE(FunctionDeclaration)
539 
540  FunctionLiteral* fun() const { return fun_; }
542  return kCreatedInitialized;
543  }
544  virtual bool IsInlineable() const OVERRIDE;
545 
546  protected:
547  FunctionDeclaration(Zone* zone,
548  VariableProxy* proxy,
550  FunctionLiteral* fun,
551  Scope* scope,
552  int pos)
553  : Declaration(zone, proxy, mode, scope, pos),
554  fun_(fun) {
555  // At the moment there are no "const functions" in JavaScript...
556  DCHECK(mode == VAR || mode == LET);
557  DCHECK(fun != NULL);
558  }
559 
560  private:
561  FunctionLiteral* fun_;
562 };
563 
564 
565 class ModuleDeclaration FINAL : public Declaration {
566  public:
567  DECLARE_NODE_TYPE(ModuleDeclaration)
568 
569  Module* module() const { return module_; }
571  return kCreatedInitialized;
572  }
573 
574  protected:
576  VariableProxy* proxy,
577  Module* module,
578  Scope* scope,
579  int pos)
580  : Declaration(zone, proxy, MODULE, scope, pos),
581  module_(module) {
582  }
583 
584  private:
586 };
587 
588 
589 class ImportDeclaration FINAL : public Declaration {
590  public:
591  DECLARE_NODE_TYPE(ImportDeclaration)
592 
593  Module* module() const { return module_; }
595  return kCreatedInitialized;
596  }
597 
598  protected:
600  VariableProxy* proxy,
601  Module* module,
602  Scope* scope,
603  int pos)
604  : Declaration(zone, proxy, LET, scope, pos),
605  module_(module) {
606  }
607 
608  private:
609  Module* module_;
610 };
611 
612 
613 class ExportDeclaration FINAL : public Declaration {
614  public:
615  DECLARE_NODE_TYPE(ExportDeclaration)
616 
617  virtual InitializationFlag initialization() const OVERRIDE {
618  return kCreatedInitialized;
619  }
620 
621  protected:
622  ExportDeclaration(Zone* zone, VariableProxy* proxy, Scope* scope, int pos)
623  : Declaration(zone, proxy, LET, scope, pos) {}
624 };
625 
626 
627 class Module : public AstNode {
628  public:
629  Interface* interface() const { return interface_; }
630  Block* body() const { return body_; }
631 
632  protected:
633  Module(Zone* zone, int pos)
634  : AstNode(pos),
635  interface_(Interface::NewModule(zone)),
636  body_(NULL) {}
637  Module(Zone* zone, Interface* interface, int pos, Block* body = NULL)
638  : AstNode(pos),
640  body_(body) {}
641 
642  private:
644  Block* body_;
645 };
646 
647 
648 class ModuleLiteral FINAL : public Module {
649  public:
650  DECLARE_NODE_TYPE(ModuleLiteral)
651 
652  protected:
653  ModuleLiteral(Zone* zone, Block* body, Interface* interface, int pos)
654  : Module(zone, interface, pos, body) {}
655 };
656 
657 
658 class ModuleVariable FINAL : public Module {
659  public:
660  DECLARE_NODE_TYPE(ModuleVariable)
661 
662  VariableProxy* proxy() const { return proxy_; }
663 
664  protected:
665  inline ModuleVariable(Zone* zone, VariableProxy* proxy, int pos);
666 
667  private:
668  VariableProxy* proxy_;
669 };
670 
671 
672 class ModulePath FINAL : public Module {
673  public:
674  DECLARE_NODE_TYPE(ModulePath)
675 
676  Module* module() const { return module_; }
677  Handle<String> name() const { return name_->string(); }
678 
679  protected:
680  ModulePath(Zone* zone, Module* module, const AstRawString* name, int pos)
681  : Module(zone, pos), module_(module), name_(name) {}
682 
683  private:
684  Module* module_;
686 };
687 
688 
689 class ModuleUrl FINAL : public Module {
690  public:
691  DECLARE_NODE_TYPE(ModuleUrl)
692 
693  Handle<String> url() const { return url_; }
694 
695  protected:
696  ModuleUrl(Zone* zone, Handle<String> url, int pos)
697  : Module(zone, pos), url_(url) {
698  }
699 
700  private:
702 };
703 
704 
705 class ModuleStatement FINAL : public Statement {
706  public:
707  DECLARE_NODE_TYPE(ModuleStatement)
708 
709  VariableProxy* proxy() const { return proxy_; }
710  Block* body() const { return body_; }
711 
712  protected:
713  ModuleStatement(Zone* zone, VariableProxy* proxy, Block* body, int pos)
714  : Statement(zone, pos),
715  proxy_(proxy),
716  body_(body) {
717  }
718 
719  private:
720  VariableProxy* proxy_;
721  Block* body_;
722 };
723 
724 
726  public:
727  // Type testing & conversion.
729  return this;
730  }
731 
732  Statement* body() const { return body_; }
733 
734  BailoutId OsrEntryId() const { return osr_entry_id_; }
735  virtual BailoutId ContinueId() const = 0;
736  virtual BailoutId StackCheckId() const = 0;
737 
738  // Code generation
739  Label* continue_target() { return &continue_target_; }
740 
741  protected:
743  IdGen* id_gen)
744  : BreakableStatement(zone, labels, TARGET_FOR_ANONYMOUS, pos, id_gen),
745  body_(NULL),
746  osr_entry_id_(id_gen->GetNextId()) {}
747 
749  body_ = body;
750  }
751 
752  private:
755 
757 };
758 
759 
760 class DoWhileStatement FINAL : public IterationStatement {
761  public:
762  DECLARE_NODE_TYPE(DoWhileStatement)
763 
764  void Initialize(Expression* cond, Statement* body) {
766  cond_ = cond;
767  }
768 
769  Expression* cond() const { return cond_; }
770 
771  virtual BailoutId ContinueId() const OVERRIDE { return continue_id_; }
772  virtual BailoutId StackCheckId() const OVERRIDE { return back_edge_id_; }
773  BailoutId BackEdgeId() const { return back_edge_id_; }
774 
775  protected:
777  IdGen* id_gen)
778  : IterationStatement(zone, labels, pos, id_gen),
779  cond_(NULL),
780  continue_id_(id_gen->GetNextId()),
781  back_edge_id_(id_gen->GetNextId()) {}
782 
783  private:
785 
788 };
789 
790 
791 class WhileStatement FINAL : public IterationStatement {
792  public:
793  DECLARE_NODE_TYPE(WhileStatement)
794 
795  void Initialize(Expression* cond, Statement* body) {
797  cond_ = cond;
798  }
799 
800  Expression* cond() const { return cond_; }
802  return may_have_function_literal_;
803  }
804  void set_may_have_function_literal(bool value) {
805  may_have_function_literal_ = value;
806  }
807 
808  virtual BailoutId ContinueId() const OVERRIDE { return EntryId(); }
809  virtual BailoutId StackCheckId() const OVERRIDE { return body_id_; }
810  BailoutId BodyId() const { return body_id_; }
811 
812  protected:
814  IdGen* id_gen)
815  : IterationStatement(zone, labels, pos, id_gen),
816  cond_(NULL),
817  may_have_function_literal_(true),
818  body_id_(id_gen->GetNextId()) {}
819 
820  private:
821  Expression* cond_;
822 
823  // True if there is a function literal subexpression in the condition.
825 
827 };
828 
829 
830 class ForStatement FINAL : public IterationStatement {
831  public:
832  DECLARE_NODE_TYPE(ForStatement)
833 
834  void Initialize(Statement* init,
835  Expression* cond,
836  Statement* next,
837  Statement* body) {
839  init_ = init;
840  cond_ = cond;
841  next_ = next;
842  }
843 
844  Statement* init() const { return init_; }
845  Expression* cond() const { return cond_; }
846  Statement* next() const { return next_; }
847 
849  return may_have_function_literal_;
850  }
851  void set_may_have_function_literal(bool value) {
852  may_have_function_literal_ = value;
853  }
854 
855  virtual BailoutId ContinueId() const OVERRIDE { return continue_id_; }
856  virtual BailoutId StackCheckId() const OVERRIDE { return body_id_; }
857  BailoutId BodyId() const { return body_id_; }
858 
859  bool is_fast_smi_loop() { return loop_variable_ != NULL; }
860  Variable* loop_variable() { return loop_variable_; }
861  void set_loop_variable(Variable* var) { loop_variable_ = var; }
862 
863  protected:
865  IdGen* id_gen)
866  : IterationStatement(zone, labels, pos, id_gen),
867  init_(NULL),
868  cond_(NULL),
869  next_(NULL),
870  may_have_function_literal_(true),
871  loop_variable_(NULL),
872  continue_id_(id_gen->GetNextId()),
873  body_id_(id_gen->GetNextId()) {}
874 
875  private:
877  Expression* cond_;
879 
880  // True if there is a function literal subexpression in the condition.
881  bool may_have_function_literal_;
883 
884  const BailoutId continue_id_;
885  const BailoutId body_id_;
886 };
887 
888 
890  public:
891  enum VisitMode {
892  ENUMERATE, // for (each in subject) body;
893  ITERATE // for (each of subject) body;
894  };
895 
898  each_ = each;
899  subject_ = subject;
900  }
901 
902  Expression* each() const { return each_; }
903  Expression* subject() const { return subject_; }
904 
905  protected:
907  IdGen* id_gen)
908  : IterationStatement(zone, labels, pos, id_gen),
909  each_(NULL),
910  subject_(NULL) {}
911 
912  private:
915 };
916 
917 
918 class ForInStatement FINAL : public ForEachStatement,
919  public FeedbackSlotInterface {
920  public:
921  DECLARE_NODE_TYPE(ForInStatement)
922 
923  Expression* enumerable() const {
924  return subject();
925  }
926 
927  // Type feedback information.
928  virtual int ComputeFeedbackSlotCount() { return 1; }
929  virtual void SetFirstFeedbackSlot(int slot) { for_in_feedback_slot_ = slot; }
930 
932  DCHECK(for_in_feedback_slot_ != kInvalidFeedbackSlot);
933  return for_in_feedback_slot_;
934  }
935 
936  enum ForInType { FAST_FOR_IN, SLOW_FOR_IN };
937  ForInType for_in_type() const { return for_in_type_; }
938  void set_for_in_type(ForInType type) { for_in_type_ = type; }
939 
940  BailoutId BodyId() const { return body_id_; }
941  BailoutId PrepareId() const { return prepare_id_; }
942  virtual BailoutId ContinueId() const OVERRIDE { return EntryId(); }
943  virtual BailoutId StackCheckId() const OVERRIDE { return body_id_; }
944 
945  protected:
947  IdGen* id_gen)
948  : ForEachStatement(zone, labels, pos, id_gen),
949  for_in_type_(SLOW_FOR_IN),
950  for_in_feedback_slot_(kInvalidFeedbackSlot),
951  body_id_(id_gen->GetNextId()),
952  prepare_id_(id_gen->GetNextId()) {}
953 
956  const BailoutId body_id_;
958 };
959 
960 
961 class ForOfStatement FINAL : public ForEachStatement {
962  public:
963  DECLARE_NODE_TYPE(ForOfStatement)
964 
965  void Initialize(Expression* each,
966  Expression* subject,
967  Statement* body,
968  Expression* assign_iterator,
969  Expression* next_result,
970  Expression* result_done,
971  Expression* assign_each) {
972  ForEachStatement::Initialize(each, subject, body);
973  assign_iterator_ = assign_iterator;
974  next_result_ = next_result;
975  result_done_ = result_done;
976  assign_each_ = assign_each;
977  }
978 
979  Expression* iterable() const {
980  return subject();
981  }
982 
983  // var iterator = subject[Symbol.iterator]();
985  return assign_iterator_;
986  }
987 
988  // var result = iterator.next();
990  return next_result_;
991  }
992 
993  // result.done
995  return result_done_;
996  }
997 
998  // each = result.value
1000  return assign_each_;
1001  }
1002 
1003  virtual BailoutId ContinueId() const OVERRIDE { return EntryId(); }
1004  virtual BailoutId StackCheckId() const OVERRIDE { return BackEdgeId(); }
1005 
1006  BailoutId BackEdgeId() const { return back_edge_id_; }
1007 
1008  protected:
1010  IdGen* id_gen)
1011  : ForEachStatement(zone, labels, pos, id_gen),
1012  assign_iterator_(NULL),
1013  next_result_(NULL),
1014  result_done_(NULL),
1015  assign_each_(NULL),
1016  back_edge_id_(id_gen->GetNextId()) {}
1017 
1022  const BailoutId back_edge_id_;
1023 };
1024 
1025 
1026 class ExpressionStatement FINAL : public Statement {
1027  public:
1028  DECLARE_NODE_TYPE(ExpressionStatement)
1029 
1030  void set_expression(Expression* e) { expression_ = e; }
1031  Expression* expression() const { return expression_; }
1032  virtual bool IsJump() const OVERRIDE { return expression_->IsThrow(); }
1033 
1034  protected:
1035  ExpressionStatement(Zone* zone, Expression* expression, int pos)
1036  : Statement(zone, pos), expression_(expression) { }
1037 
1038  private:
1040 };
1041 
1042 
1043 class JumpStatement : public Statement {
1044  public:
1045  virtual bool IsJump() const FINAL OVERRIDE { return true; }
1046 
1047  protected:
1048  explicit JumpStatement(Zone* zone, int pos) : Statement(zone, pos) {}
1049 };
1050 
1051 
1052 class ContinueStatement FINAL : public JumpStatement {
1053  public:
1054  DECLARE_NODE_TYPE(ContinueStatement)
1055 
1056  IterationStatement* target() const { return target_; }
1057 
1058  protected:
1059  explicit ContinueStatement(Zone* zone, IterationStatement* target, int pos)
1060  : JumpStatement(zone, pos), target_(target) { }
1061 
1062  private:
1064 };
1065 
1066 
1067 class BreakStatement FINAL : public JumpStatement {
1068  public:
1069  DECLARE_NODE_TYPE(BreakStatement)
1070 
1071  BreakableStatement* target() const { return target_; }
1072 
1073  protected:
1074  explicit BreakStatement(Zone* zone, BreakableStatement* target, int pos)
1075  : JumpStatement(zone, pos), target_(target) { }
1076 
1077  private:
1079 };
1080 
1081 
1082 class ReturnStatement FINAL : public JumpStatement {
1083  public:
1084  DECLARE_NODE_TYPE(ReturnStatement)
1085 
1086  Expression* expression() const { return expression_; }
1087 
1088  protected:
1089  explicit ReturnStatement(Zone* zone, Expression* expression, int pos)
1090  : JumpStatement(zone, pos), expression_(expression) { }
1091 
1092  private:
1093  Expression* expression_;
1094 };
1095 
1096 
1097 class WithStatement FINAL : public Statement {
1098  public:
1099  DECLARE_NODE_TYPE(WithStatement)
1100 
1101  Scope* scope() { return scope_; }
1102  Expression* expression() const { return expression_; }
1103  Statement* statement() const { return statement_; }
1104 
1105  protected:
1107  Zone* zone, Scope* scope,
1108  Expression* expression, Statement* statement, int pos)
1109  : Statement(zone, pos),
1110  scope_(scope),
1111  expression_(expression),
1112  statement_(statement) { }
1113 
1114  private:
1115  Scope* scope_;
1116  Expression* expression_;
1118 };
1119 
1120 
1121 class CaseClause FINAL : public Expression {
1122  public:
1123  DECLARE_NODE_TYPE(CaseClause)
1124 
1125  bool is_default() const { return label_ == NULL; }
1126  Expression* label() const {
1127  CHECK(!is_default());
1128  return label_;
1129  }
1130  Label* body_target() { return &body_target_; }
1131  ZoneList<Statement*>* statements() const { return statements_; }
1132 
1133  BailoutId EntryId() const { return entry_id_; }
1134 
1135  // Type feedback information.
1136  TypeFeedbackId CompareId() { return compare_id_; }
1137  Type* compare_type() { return compare_type_; }
1138  void set_compare_type(Type* type) { compare_type_ = type; }
1139 
1140  private:
1141  CaseClause(Zone* zone, Expression* label, ZoneList<Statement*>* statements,
1142  int pos, IdGen* id_gen);
1143 
1148 
1151 };
1152 
1153 
1154 class SwitchStatement FINAL : public BreakableStatement {
1155  public:
1156  DECLARE_NODE_TYPE(SwitchStatement)
1157 
1158  void Initialize(Expression* tag, ZoneList<CaseClause*>* cases) {
1159  tag_ = tag;
1160  cases_ = cases;
1161  }
1162 
1163  Expression* tag() const { return tag_; }
1164  ZoneList<CaseClause*>* cases() const { return cases_; }
1165 
1166  protected:
1168  IdGen* id_gen)
1169  : BreakableStatement(zone, labels, TARGET_FOR_ANONYMOUS, pos, id_gen),
1170  tag_(NULL),
1171  cases_(NULL) {}
1172 
1173  private:
1176 };
1177 
1178 
1179 // If-statements always have non-null references to their then- and
1180 // else-parts. When parsing if-statements with no explicit else-part,
1181 // the parser implicitly creates an empty statement. Use the
1182 // HasThenStatement() and HasElseStatement() functions to check if a
1183 // given if-statement has a then- or an else-part containing code.
1184 class IfStatement FINAL : public Statement {
1185  public:
1186  DECLARE_NODE_TYPE(IfStatement)
1187 
1188  bool HasThenStatement() const { return !then_statement()->IsEmpty(); }
1189  bool HasElseStatement() const { return !else_statement()->IsEmpty(); }
1190 
1191  Expression* condition() const { return condition_; }
1192  Statement* then_statement() const { return then_statement_; }
1193  Statement* else_statement() const { return else_statement_; }
1194 
1195  virtual bool IsJump() const OVERRIDE {
1196  return HasThenStatement() && then_statement()->IsJump()
1197  && HasElseStatement() && else_statement()->IsJump();
1198  }
1199 
1200  BailoutId IfId() const { return if_id_; }
1201  BailoutId ThenId() const { return then_id_; }
1202  BailoutId ElseId() const { return else_id_; }
1203 
1204  protected:
1205  IfStatement(Zone* zone, Expression* condition, Statement* then_statement,
1206  Statement* else_statement, int pos, IdGen* id_gen)
1207  : Statement(zone, pos),
1208  condition_(condition),
1209  then_statement_(then_statement),
1210  else_statement_(else_statement),
1211  if_id_(id_gen->GetNextId()),
1212  then_id_(id_gen->GetNextId()),
1213  else_id_(id_gen->GetNextId()) {}
1214 
1215  private:
1222 };
1223 
1224 
1225 // NOTE: TargetCollectors are represented as nodes to fit in the target
1226 // stack in the compiler; this should probably be reworked.
1227 class TargetCollector FINAL : public AstNode {
1228  public:
1229  explicit TargetCollector(Zone* zone)
1230  : AstNode(RelocInfo::kNoPosition), targets_(0, zone) { }
1231 
1232  // Adds a jump target to the collector. The collector stores a pointer not
1233  // a copy of the target to make binding work, so make sure not to pass in
1234  // references to something on the stack.
1235  void AddTarget(Label* target, Zone* zone);
1236 
1237  // Virtual behaviour. TargetCollectors are never part of the AST.
1238  virtual void Accept(AstVisitor* v) OVERRIDE { UNREACHABLE(); }
1239  virtual NodeType node_type() const OVERRIDE { return kInvalid; }
1240  virtual TargetCollector* AsTargetCollector() OVERRIDE { return this; }
1241 
1242  ZoneList<Label*>* targets() { return &targets_; }
1243 
1244  private:
1246 };
1247 
1248 
1249 class TryStatement : public Statement {
1250  public:
1252  escaping_targets_ = targets;
1253  }
1254 
1255  int index() const { return index_; }
1256  Block* try_block() const { return try_block_; }
1258 
1259  protected:
1260  TryStatement(Zone* zone, int index, Block* try_block, int pos)
1261  : Statement(zone, pos),
1262  index_(index),
1264  escaping_targets_(NULL) { }
1265 
1266  private:
1267  // Unique (per-function) index of this handler. This is not an AST ID.
1268  int index_;
1269 
1270  Block* try_block_;
1272 };
1273 
1274 
1275 class TryCatchStatement FINAL : public TryStatement {
1276  public:
1277  DECLARE_NODE_TYPE(TryCatchStatement)
1278 
1279  Scope* scope() { return scope_; }
1280  Variable* variable() { return variable_; }
1281  Block* catch_block() const { return catch_block_; }
1282 
1283  protected:
1285  int index,
1286  Block* try_block,
1287  Scope* scope,
1288  Variable* variable,
1289  Block* catch_block,
1290  int pos)
1291  : TryStatement(zone, index, try_block, pos),
1292  scope_(scope),
1293  variable_(variable),
1294  catch_block_(catch_block) {
1295  }
1296 
1297  private:
1298  Scope* scope_;
1301 };
1302 
1303 
1304 class TryFinallyStatement FINAL : public TryStatement {
1305  public:
1306  DECLARE_NODE_TYPE(TryFinallyStatement)
1307 
1308  Block* finally_block() const { return finally_block_; }
1309 
1310  protected:
1312  Zone* zone, int index, Block* try_block, Block* finally_block, int pos)
1313  : TryStatement(zone, index, try_block, pos),
1314  finally_block_(finally_block) { }
1315 
1316  private:
1318 };
1319 
1320 
1321 class DebuggerStatement FINAL : public Statement {
1322  public:
1323  DECLARE_NODE_TYPE(DebuggerStatement)
1324 
1325  BailoutId DebugBreakId() const { return debugger_id_; }
1326 
1327  protected:
1328  explicit DebuggerStatement(Zone* zone, int pos, IdGen* id_gen)
1329  : Statement(zone, pos), debugger_id_(id_gen->GetNextId()) {}
1330 
1331  private:
1333 };
1334 
1335 
1336 class EmptyStatement FINAL : public Statement {
1337  public:
1338  DECLARE_NODE_TYPE(EmptyStatement)
1339 
1340  protected:
1341  explicit EmptyStatement(Zone* zone, int pos): Statement(zone, pos) {}
1342 };
1343 
1344 
1345 class Literal FINAL : public Expression {
1346  public:
1347  DECLARE_NODE_TYPE(Literal)
1348 
1349  virtual bool IsPropertyName() const OVERRIDE {
1350  return value_->IsPropertyName();
1351  }
1352 
1354  DCHECK(IsPropertyName());
1355  return Handle<String>::cast(value());
1356  }
1357 
1359  DCHECK(IsPropertyName());
1360  return value_->AsString();
1361  }
1362 
1363  virtual bool ToBooleanIsTrue() const OVERRIDE {
1364  return value()->BooleanValue();
1365  }
1366  virtual bool ToBooleanIsFalse() const OVERRIDE {
1367  return !value()->BooleanValue();
1368  }
1369 
1370  Handle<Object> value() const { return value_->value(); }
1371  const AstValue* raw_value() const { return value_; }
1372 
1373  // Support for using Literal as a HashMap key. NOTE: Currently, this works
1374  // only for string and number literals!
1375  uint32_t Hash() { return ToString()->Hash(); }
1376 
1377  static bool Match(void* literal1, void* literal2) {
1378  Handle<String> s1 = static_cast<Literal*>(literal1)->ToString();
1379  Handle<String> s2 = static_cast<Literal*>(literal2)->ToString();
1380  return String::Equals(s1, s2);
1381  }
1382 
1383  TypeFeedbackId LiteralFeedbackId() const { return reuse(id()); }
1384 
1385  protected:
1386  Literal(Zone* zone, const AstValue* value, int position, IdGen* id_gen)
1387  : Expression(zone, position, id_gen),
1388  value_(value),
1389  isolate_(zone->isolate()) {}
1390 
1391  private:
1393 
1395  // TODO(dcarney): remove. this is only needed for Match and Hash.
1397 };
1398 
1399 
1400 // Base class for literals that needs space in the corresponding JSFunction.
1402  public:
1403  virtual MaterializedLiteral* AsMaterializedLiteral() { return this; }
1404 
1405  int literal_index() { return literal_index_; }
1406 
1407  int depth() const {
1408  // only callable after initialization.
1409  DCHECK(depth_ >= 1);
1410  return depth_;
1411  }
1412 
1413  protected:
1414  MaterializedLiteral(Zone* zone, int literal_index, int pos, IdGen* id_gen)
1415  : Expression(zone, pos, id_gen),
1417  is_simple_(false),
1418  depth_(0) {}
1419 
1420  // A materialized literal is simple if the values consist of only
1421  // constants and simple object and array literals.
1422  bool is_simple() const { return is_simple_; }
1424  friend class CompileTimeValue;
1425 
1426  void set_depth(int depth) {
1427  DCHECK(depth >= 1);
1428  depth_ = depth;
1429  }
1430 
1431  // Populate the constant properties/elements fixed array.
1432  void BuildConstants(Isolate* isolate);
1433  friend class ArrayLiteral;
1434  friend class ObjectLiteral;
1435 
1436  // If the expression is a literal, return the literal value;
1437  // if the expression is a materialized literal and is simple return a
1438  // compile time value as encoded by CompileTimeValue::GetValue().
1439  // Otherwise, return undefined literal as the placeholder
1440  // in the object literal boilerplate.
1441  Handle<Object> GetBoilerplateValue(Expression* expression, Isolate* isolate);
1442 
1443  private:
1446  int depth_;
1447 };
1448 
1449 
1450 // Property is used for passing information
1451 // about an object literal's properties from the parser
1452 // to the code generator.
1453 class ObjectLiteralProperty FINAL : public ZoneObject {
1454  public:
1455  enum Kind {
1456  CONSTANT, // Property with constant value (compile time).
1457  COMPUTED, // Property with computed value (execution time).
1458  MATERIALIZED_LITERAL, // Property value is a materialized literal.
1459  GETTER, SETTER, // Property is an accessor function.
1460  PROTOTYPE // Property is __proto__.
1461  };
1462 
1463  ObjectLiteralProperty(Zone* zone, AstValueFactory* ast_value_factory,
1464  Literal* key, Expression* value, bool is_static);
1465 
1466  Literal* key() { return key_; }
1467  Expression* value() { return value_; }
1468  Kind kind() { return kind_; }
1469 
1470  // Type feedback information.
1472  bool IsMonomorphic() { return !receiver_type_.is_null(); }
1473  Handle<Map> GetReceiverType() { return receiver_type_; }
1474 
1476 
1477  void set_emit_store(bool emit_store);
1478  bool emit_store();
1479 
1480  protected:
1481  template<class> friend class AstNodeFactory;
1482 
1483  ObjectLiteralProperty(Zone* zone, bool is_getter, FunctionLiteral* value,
1484  bool is_static);
1485  void set_key(Literal* key) { key_ = key; }
1486 
1487  private:
1488  Literal* key_;
1494 };
1495 
1496 
1497 // An object literal has a boilerplate object that is used
1498 // for minimizing the work when constructing it at runtime.
1499 class ObjectLiteral FINAL : public MaterializedLiteral {
1500  public:
1501  typedef ObjectLiteralProperty Property;
1502 
1503  DECLARE_NODE_TYPE(ObjectLiteral)
1504 
1505  Handle<FixedArray> constant_properties() const {
1506  return constant_properties_;
1507  }
1508  ZoneList<Property*>* properties() const { return properties_; }
1509  bool fast_elements() const { return fast_elements_; }
1510  bool may_store_doubles() const { return may_store_doubles_; }
1511  bool has_function() const { return has_function_; }
1512 
1513  // Decide if a property should be in the object boilerplate.
1514  static bool IsBoilerplateProperty(Property* property);
1515 
1516  // Populate the constant properties fixed array.
1518 
1519  // Mark all computed expressions that are bound to a key that
1520  // is shadowed by a later occurrence of the same key. For the
1521  // marked expressions, no store code is emitted.
1523 
1524  // Assemble bitfield of flags for the CreateObjectLiteral helper.
1525  int ComputeFlags() const {
1526  int flags = fast_elements() ? kFastElements : kNoFlags;
1527  flags |= has_function() ? kHasFunction : kNoFlags;
1528  return flags;
1529  }
1530 
1531  enum Flags {
1532  kNoFlags = 0,
1533  kFastElements = 1,
1534  kHasFunction = 1 << 1
1535  };
1536 
1537  struct Accessors: public ZoneObject {
1538  Accessors() : getter(NULL), setter(NULL) { }
1541  };
1542 
1543  protected:
1544  ObjectLiteral(Zone* zone, ZoneList<Property*>* properties, int literal_index,
1545  int boilerplate_properties, bool has_function, int pos,
1546  IdGen* id_gen)
1547  : MaterializedLiteral(zone, literal_index, pos, id_gen),
1548  properties_(properties),
1549  boilerplate_properties_(boilerplate_properties),
1550  fast_elements_(false),
1551  may_store_doubles_(false),
1552  has_function_(has_function) {}
1553 
1554  private:
1561 };
1562 
1563 
1564 // Node for capturing a regexp literal.
1565 class RegExpLiteral FINAL : public MaterializedLiteral {
1566  public:
1567  DECLARE_NODE_TYPE(RegExpLiteral)
1568 
1569  Handle<String> pattern() const { return pattern_->string(); }
1570  Handle<String> flags() const { return flags_->string(); }
1571 
1572  protected:
1573  RegExpLiteral(Zone* zone, const AstRawString* pattern,
1574  const AstRawString* flags, int literal_index, int pos,
1575  IdGen* id_gen)
1576  : MaterializedLiteral(zone, literal_index, pos, id_gen),
1577  pattern_(pattern),
1578  flags_(flags) {
1579  set_depth(1);
1580  }
1581 
1582  private:
1585 };
1586 
1587 
1588 // An array literal has a literals object that is used
1589 // for minimizing the work when constructing it at runtime.
1590 class ArrayLiteral FINAL : public MaterializedLiteral {
1591  public:
1592  DECLARE_NODE_TYPE(ArrayLiteral)
1593 
1594  Handle<FixedArray> constant_elements() const { return constant_elements_; }
1595  ZoneList<Expression*>* values() const { return values_; }
1596 
1597  // Return an AST id for an element that is used in simulate instructions.
1599  return BailoutId(first_element_id_.ToInt() + i);
1600  }
1601 
1602  // Populate the constant elements fixed array.
1604 
1605  // Assemble bitfield of flags for the CreateArrayLiteral helper.
1606  int ComputeFlags() const {
1607  int flags = depth() == 1 ? kShallowElements : kNoFlags;
1608  flags |= ArrayLiteral::kDisableMementos;
1609  return flags;
1610  }
1611 
1612  enum Flags {
1613  kNoFlags = 0,
1614  kShallowElements = 1,
1615  kDisableMementos = 1 << 1
1616  };
1617 
1618  protected:
1619  ArrayLiteral(Zone* zone, ZoneList<Expression*>* values, int literal_index,
1620  int pos, IdGen* id_gen)
1621  : MaterializedLiteral(zone, literal_index, pos, id_gen),
1622  values_(values),
1623  first_element_id_(id_gen->ReserveIdRange(values->length())) {}
1624 
1625  private:
1629 };
1630 
1631 
1632 class VariableProxy FINAL : public Expression, public FeedbackSlotInterface {
1633  public:
1634  DECLARE_NODE_TYPE(VariableProxy)
1635 
1636  virtual bool IsValidReferenceExpression() const OVERRIDE {
1637  return var_ == NULL ? true : var_->IsValidReference();
1638  }
1639 
1640  bool IsArguments() const { return var_ != NULL && var_->is_arguments(); }
1641 
1642  Handle<String> name() const { return name_->string(); }
1643  const AstRawString* raw_name() const { return name_; }
1644  Variable* var() const { return var_; }
1645  bool is_this() const { return is_this_; }
1646  Interface* interface() const { return interface_; }
1647 
1648  bool is_assigned() const { return is_assigned_; }
1649  void set_is_assigned() { is_assigned_ = true; }
1650 
1651  // Bind this proxy to the variable var. Interfaces must match.
1652  void BindTo(Variable* var);
1653 
1654  virtual int ComputeFeedbackSlotCount() { return FLAG_vector_ics ? 1 : 0; }
1655  virtual void SetFirstFeedbackSlot(int slot) {
1656  variable_feedback_slot_ = slot;
1657  }
1658 
1659  int VariableFeedbackSlot() { return variable_feedback_slot_; }
1660 
1661  protected:
1662  VariableProxy(Zone* zone, Variable* var, int position, IdGen* id_gen);
1663 
1664  VariableProxy(Zone* zone, const AstRawString* name, bool is_this,
1665  Interface* interface, int position, IdGen* id_gen);
1666 
1667  const AstRawString* name_;
1668  Variable* var_; // resolved variable, or NULL
1669  bool is_this_;
1673 };
1674 
1675 
1676 class Property FINAL : public Expression, public FeedbackSlotInterface {
1677  public:
1678  DECLARE_NODE_TYPE(Property)
1679 
1680  virtual bool IsValidReferenceExpression() const OVERRIDE { return true; }
1681 
1682  Expression* obj() const { return obj_; }
1683  Expression* key() const { return key_; }
1684 
1685  BailoutId LoadId() const { return load_id_; }
1686 
1687  bool IsStringAccess() const { return is_string_access_; }
1688 
1689  // Type feedback information.
1690  virtual bool IsMonomorphic() OVERRIDE {
1691  return receiver_types_.length() == 1;
1692  }
1693  virtual SmallMapList* GetReceiverTypes() OVERRIDE {
1694  return &receiver_types_;
1695  }
1697  return STANDARD_STORE;
1698  }
1699  bool IsUninitialized() { return !is_for_call_ && is_uninitialized_; }
1701  return is_uninitialized_;
1702  }
1703  void set_is_uninitialized(bool b) { is_uninitialized_ = b; }
1704  void set_is_string_access(bool b) { is_string_access_ = b; }
1705  void mark_for_call() { is_for_call_ = true; }
1706  bool IsForCall() { return is_for_call_; }
1707 
1708  bool IsSuperAccess() {
1709  return obj()->IsSuperReference();
1710  }
1711 
1712  TypeFeedbackId PropertyFeedbackId() { return reuse(id()); }
1713 
1714  virtual int ComputeFeedbackSlotCount() { return FLAG_vector_ics ? 1 : 0; }
1715  virtual void SetFirstFeedbackSlot(int slot) {
1716  property_feedback_slot_ = slot;
1717  }
1718 
1719  int PropertyFeedbackSlot() const { return property_feedback_slot_; }
1720 
1721  protected:
1722  Property(Zone* zone, Expression* obj, Expression* key, int pos, IdGen* id_gen)
1723  : Expression(zone, pos, id_gen),
1724  obj_(obj),
1725  key_(key),
1726  load_id_(id_gen->GetNextId()),
1727  property_feedback_slot_(kInvalidFeedbackSlot),
1728  is_for_call_(false),
1729  is_uninitialized_(false),
1730  is_string_access_(false) {}
1731 
1732  private:
1737 
1738  SmallMapList receiver_types_;
1739  bool is_for_call_ : 1;
1742 };
1743 
1744 
1745 class Call FINAL : public Expression, public FeedbackSlotInterface {
1746  public:
1747  DECLARE_NODE_TYPE(Call)
1748 
1749  Expression* expression() const { return expression_; }
1750  ZoneList<Expression*>* arguments() const { return arguments_; }
1751 
1752  // Type feedback information.
1753  virtual int ComputeFeedbackSlotCount() { return 1; }
1754  virtual void SetFirstFeedbackSlot(int slot) {
1755  call_feedback_slot_ = slot;
1756  }
1757 
1758  bool HasCallFeedbackSlot() const {
1759  return call_feedback_slot_ != kInvalidFeedbackSlot;
1760  }
1761  int CallFeedbackSlot() const { return call_feedback_slot_; }
1762 
1763  virtual SmallMapList* GetReceiverTypes() OVERRIDE {
1764  if (expression()->IsProperty()) {
1765  return expression()->AsProperty()->GetReceiverTypes();
1766  }
1767  return NULL;
1768  }
1769 
1770  virtual bool IsMonomorphic() OVERRIDE {
1771  if (expression()->IsProperty()) {
1772  return expression()->AsProperty()->IsMonomorphic();
1773  }
1774  return !target_.is_null();
1775  }
1776 
1777  bool global_call() const {
1778  VariableProxy* proxy = expression_->AsVariableProxy();
1779  return proxy != NULL && proxy->var()->IsUnallocated();
1780  }
1781 
1782  bool known_global_function() const {
1783  return global_call() && !target_.is_null();
1784  }
1785 
1786  Handle<JSFunction> target() { return target_; }
1787 
1788  Handle<Cell> cell() { return cell_; }
1789 
1790  Handle<AllocationSite> allocation_site() { return allocation_site_; }
1791 
1792  void set_target(Handle<JSFunction> target) { target_ = target; }
1794  allocation_site_ = site;
1795  }
1796  bool ComputeGlobalTarget(Handle<GlobalObject> global, LookupIterator* it);
1797 
1798  BailoutId ReturnId() const { return return_id_; }
1799 
1800  enum CallType {
1805  OTHER_CALL
1806  };
1807 
1808  // Helpers to determine how to handle the call.
1809  CallType GetCallType(Isolate* isolate) const;
1810  bool IsUsingCallFeedbackSlot(Isolate* isolate) const;
1811 
1812 #ifdef DEBUG
1813  // Used to assert that the FullCodeGenerator records the return site.
1814  bool return_is_recorded_;
1815 #endif
1816 
1817  protected:
1818  Call(Zone* zone, Expression* expression, ZoneList<Expression*>* arguments,
1819  int pos, IdGen* id_gen)
1820  : Expression(zone, pos, id_gen),
1821  expression_(expression),
1822  arguments_(arguments),
1823  call_feedback_slot_(kInvalidFeedbackSlot),
1824  return_id_(id_gen->GetNextId()) {
1825  if (expression->IsProperty()) {
1826  expression->AsProperty()->mark_for_call();
1827  }
1828  }
1829 
1830  private:
1831  Expression* expression_;
1833 
1838 
1840 };
1841 
1842 
1843 class CallNew FINAL : public Expression, public FeedbackSlotInterface {
1844  public:
1845  DECLARE_NODE_TYPE(CallNew)
1846 
1847  Expression* expression() const { return expression_; }
1848  ZoneList<Expression*>* arguments() const { return arguments_; }
1849 
1850  // Type feedback information.
1852  return FLAG_pretenuring_call_new ? 2 : 1;
1853  }
1854  virtual void SetFirstFeedbackSlot(int slot) {
1855  callnew_feedback_slot_ = slot;
1856  }
1857 
1859  DCHECK(callnew_feedback_slot_ != kInvalidFeedbackSlot);
1860  return callnew_feedback_slot_;
1861  }
1863  DCHECK(callnew_feedback_slot_ != kInvalidFeedbackSlot);
1864  DCHECK(FLAG_pretenuring_call_new);
1865  return callnew_feedback_slot_ + 1;
1866  }
1867 
1869  virtual bool IsMonomorphic() OVERRIDE { return is_monomorphic_; }
1870  Handle<JSFunction> target() const { return target_; }
1872  return allocation_site_;
1873  }
1874 
1875  static int feedback_slots() { return 1; }
1876 
1877  BailoutId ReturnId() const { return return_id_; }
1878 
1879  protected:
1880  CallNew(Zone* zone, Expression* expression, ZoneList<Expression*>* arguments,
1881  int pos, IdGen* id_gen)
1882  : Expression(zone, pos, id_gen),
1883  expression_(expression),
1884  arguments_(arguments),
1885  is_monomorphic_(false),
1886  callnew_feedback_slot_(kInvalidFeedbackSlot),
1887  return_id_(id_gen->GetNextId()) {}
1888 
1889  private:
1890  Expression* expression_;
1891  ZoneList<Expression*>* arguments_;
1892 
1894  Handle<JSFunction> target_;
1895  Handle<AllocationSite> allocation_site_;
1897 
1898  const BailoutId return_id_;
1899 };
1900 
1901 
1902 // The CallRuntime class does not represent any official JavaScript
1903 // language construct. Instead it is used to call a C or JS function
1904 // with a set of arguments. This is used from the builtins that are
1905 // implemented in JavaScript (see "v8natives.js").
1906 class CallRuntime FINAL : public Expression, public FeedbackSlotInterface {
1907  public:
1908  DECLARE_NODE_TYPE(CallRuntime)
1909 
1910  Handle<String> name() const { return raw_name_->string(); }
1911  const AstRawString* raw_name() const { return raw_name_; }
1912  const Runtime::Function* function() const { return function_; }
1913  ZoneList<Expression*>* arguments() const { return arguments_; }
1914  bool is_jsruntime() const { return function_ == NULL; }
1915 
1916  // Type feedback information.
1918  return (FLAG_vector_ics && is_jsruntime()) ? 1 : 0;
1919  }
1920  virtual void SetFirstFeedbackSlot(int slot) {
1921  callruntime_feedback_slot_ = slot;
1922  }
1923 
1925  DCHECK(!is_jsruntime() ||
1926  callruntime_feedback_slot_ != kInvalidFeedbackSlot);
1927  return callruntime_feedback_slot_;
1928  }
1929 
1930  TypeFeedbackId CallRuntimeFeedbackId() const { return reuse(id()); }
1931 
1932  protected:
1934  const Runtime::Function* function,
1935  ZoneList<Expression*>* arguments, int pos, IdGen* id_gen)
1936  : Expression(zone, pos, id_gen),
1937  raw_name_(name),
1938  function_(function),
1939  arguments_(arguments) {}
1940 
1941  private:
1944  ZoneList<Expression*>* arguments_;
1946 };
1947 
1948 
1949 class UnaryOperation FINAL : public Expression {
1950  public:
1951  DECLARE_NODE_TYPE(UnaryOperation)
1952 
1953  Token::Value op() const { return op_; }
1954  Expression* expression() const { return expression_; }
1955 
1956  BailoutId MaterializeTrueId() { return materialize_true_id_; }
1957  BailoutId MaterializeFalseId() { return materialize_false_id_; }
1958 
1960  TypeFeedbackOracle* oracle) OVERRIDE;
1961 
1962  protected:
1963  UnaryOperation(Zone* zone, Token::Value op, Expression* expression, int pos,
1964  IdGen* id_gen)
1965  : Expression(zone, pos, id_gen),
1966  op_(op),
1967  expression_(expression),
1968  materialize_true_id_(id_gen->GetNextId()),
1969  materialize_false_id_(id_gen->GetNextId()) {
1970  DCHECK(Token::IsUnaryOp(op));
1971  }
1972 
1973  private:
1974  Token::Value op_;
1975  Expression* expression_;
1976 
1977  // For unary not (Token::NOT), the AST ids where true and false will
1978  // actually be materialized, respectively.
1981 };
1982 
1983 
1984 class BinaryOperation FINAL : public Expression {
1985  public:
1986  DECLARE_NODE_TYPE(BinaryOperation)
1987 
1988  virtual bool ResultOverwriteAllowed() const OVERRIDE;
1989 
1990  Token::Value op() const { return op_; }
1991  Expression* left() const { return left_; }
1992  Expression* right() const { return right_; }
1993  Handle<AllocationSite> allocation_site() const { return allocation_site_; }
1995  allocation_site_ = allocation_site;
1996  }
1997 
1998  BailoutId RightId() const { return right_id_; }
1999 
2000  TypeFeedbackId BinaryOperationFeedbackId() const { return reuse(id()); }
2001  Maybe<int> fixed_right_arg() const { return fixed_right_arg_; }
2002  void set_fixed_right_arg(Maybe<int> arg) { fixed_right_arg_ = arg; }
2003 
2005  TypeFeedbackOracle* oracle) OVERRIDE;
2006 
2007  protected:
2009  Expression* right, int pos, IdGen* id_gen)
2010  : Expression(zone, pos, id_gen),
2011  op_(op),
2012  left_(left),
2013  right_(right),
2014  right_id_(id_gen->GetNextId()) {
2016  }
2017 
2018  private:
2019  Token::Value op_;
2022  Handle<AllocationSite> allocation_site_;
2023 
2024  // TODO(rossberg): the fixed arg should probably be represented as a Constant
2025  // type for the RHS.
2027 
2028  // The short-circuit logical operations need an AST ID for their
2029  // right-hand subexpression.
2031 };
2032 
2033 
2034 class CountOperation FINAL : public Expression {
2035  public:
2036  DECLARE_NODE_TYPE(CountOperation)
2037 
2038  bool is_prefix() const { return is_prefix_; }
2039  bool is_postfix() const { return !is_prefix_; }
2040 
2041  Token::Value op() const { return op_; }
2043  return (op() == Token::INC) ? Token::ADD : Token::SUB;
2044  }
2045 
2046  Expression* expression() const { return expression_; }
2047 
2048  virtual bool IsMonomorphic() OVERRIDE {
2049  return receiver_types_.length() == 1;
2050  }
2051  virtual SmallMapList* GetReceiverTypes() OVERRIDE {
2052  return &receiver_types_;
2053  }
2055  return store_mode_;
2056  }
2057  Type* type() const { return type_; }
2059  void set_type(Type* type) { type_ = type; }
2060 
2061  BailoutId AssignmentId() const { return assignment_id_; }
2062 
2063  TypeFeedbackId CountBinOpFeedbackId() const { return count_id_; }
2064  TypeFeedbackId CountStoreFeedbackId() const { return reuse(id()); }
2065 
2066  protected:
2067  CountOperation(Zone* zone, Token::Value op, bool is_prefix, Expression* expr,
2068  int pos, IdGen* id_gen)
2069  : Expression(zone, pos, id_gen),
2070  op_(op),
2071  is_prefix_(is_prefix),
2072  store_mode_(STANDARD_STORE),
2073  expression_(expr),
2074  assignment_id_(id_gen->GetNextId()),
2075  count_id_(id_gen->GetNextId()) {}
2076 
2077  private:
2078  Token::Value op_;
2079  bool is_prefix_ : 1;
2080  KeyedAccessStoreMode store_mode_ : 5; // Windows treats as signed,
2081  // must have extra bit.
2083 
2084  Expression* expression_;
2087  SmallMapList receiver_types_;
2088 };
2089 
2090 
2091 class CompareOperation FINAL : public Expression {
2092  public:
2093  DECLARE_NODE_TYPE(CompareOperation)
2094 
2095  Token::Value op() const { return op_; }
2096  Expression* left() const { return left_; }
2097  Expression* right() const { return right_; }
2098 
2099  // Type feedback information.
2100  TypeFeedbackId CompareOperationFeedbackId() const { return reuse(id()); }
2101  Type* combined_type() const { return combined_type_; }
2102  void set_combined_type(Type* type) { combined_type_ = type; }
2103 
2104  // Match special cases.
2108 
2109  protected:
2111  Expression* right, int pos, IdGen* id_gen)
2112  : Expression(zone, pos, id_gen),
2113  op_(op),
2114  left_(left),
2115  right_(right),
2116  combined_type_(Type::None(zone)) {
2118  }
2119 
2120  private:
2121  Token::Value op_;
2122  Expression* left_;
2123  Expression* right_;
2124 
2126 };
2127 
2128 
2129 class Conditional FINAL : public Expression {
2130  public:
2131  DECLARE_NODE_TYPE(Conditional)
2132 
2133  Expression* condition() const { return condition_; }
2134  Expression* then_expression() const { return then_expression_; }
2135  Expression* else_expression() const { return else_expression_; }
2136 
2137  BailoutId ThenId() const { return then_id_; }
2138  BailoutId ElseId() const { return else_id_; }
2139 
2140  protected:
2141  Conditional(Zone* zone, Expression* condition, Expression* then_expression,
2142  Expression* else_expression, int position, IdGen* id_gen)
2143  : Expression(zone, position, id_gen),
2144  condition_(condition),
2145  then_expression_(then_expression),
2146  else_expression_(else_expression),
2147  then_id_(id_gen->GetNextId()),
2148  else_id_(id_gen->GetNextId()) {}
2149 
2150  private:
2151  Expression* condition_;
2154  const BailoutId then_id_;
2155  const BailoutId else_id_;
2156 };
2157 
2158 
2159 class Assignment FINAL : public Expression {
2160  public:
2161  DECLARE_NODE_TYPE(Assignment)
2162 
2163  Assignment* AsSimpleAssignment() { return !is_compound() ? this : NULL; }
2164 
2166 
2167  Token::Value op() const { return op_; }
2168  Expression* target() const { return target_; }
2169  Expression* value() const { return value_; }
2170  BinaryOperation* binary_operation() const { return binary_operation_; }
2171 
2172  // This check relies on the definition order of token in token.h.
2173  bool is_compound() const { return op() > Token::ASSIGN; }
2174 
2175  BailoutId AssignmentId() const { return assignment_id_; }
2176 
2177  // Type feedback information.
2178  TypeFeedbackId AssignmentFeedbackId() { return reuse(id()); }
2179  virtual bool IsMonomorphic() OVERRIDE {
2180  return receiver_types_.length() == 1;
2181  }
2182  bool IsUninitialized() { return is_uninitialized_; }
2184  return is_uninitialized_;
2185  }
2186  virtual SmallMapList* GetReceiverTypes() OVERRIDE {
2187  return &receiver_types_;
2188  }
2190  return store_mode_;
2191  }
2192  void set_is_uninitialized(bool b) { is_uninitialized_ = b; }
2194 
2195  protected:
2196  Assignment(Zone* zone, Token::Value op, Expression* target, Expression* value,
2197  int pos, IdGen* id_gen);
2198 
2199  template<class Visitor>
2200  void Init(Zone* zone, AstNodeFactory<Visitor>* factory) {
2202  if (is_compound()) {
2203  binary_operation_ = factory->NewBinaryOperation(
2204  binary_op(), target_, value_, position() + 1);
2205  }
2206  }
2207 
2208  private:
2209  Token::Value op_;
2211  Expression* value_;
2212  BinaryOperation* binary_operation_;
2213  const BailoutId assignment_id_;
2214 
2215  bool is_uninitialized_ : 1;
2216  KeyedAccessStoreMode store_mode_ : 5; // Windows treats as signed,
2217  // must have extra bit.
2218  SmallMapList receiver_types_;
2219 };
2220 
2221 
2222 class Yield FINAL : public Expression, public FeedbackSlotInterface {
2223  public:
2224  DECLARE_NODE_TYPE(Yield)
2225 
2226  enum Kind {
2227  kInitial, // The initial yield that returns the unboxed generator object.
2228  kSuspend, // A normal yield: { value: EXPRESSION, done: false }
2229  kDelegating, // A yield*.
2230  kFinal // A return: { value: EXPRESSION, done: true }
2231  };
2232 
2233  Expression* generator_object() const { return generator_object_; }
2234  Expression* expression() const { return expression_; }
2235  Kind yield_kind() const { return yield_kind_; }
2236 
2237  // Delegating yield surrounds the "yield" in a "try/catch". This index
2238  // locates the catch handler in the handler table, and is equivalent to
2239  // TryCatchStatement::index().
2240  int index() const {
2241  DCHECK_EQ(kDelegating, yield_kind());
2242  return index_;
2243  }
2244  void set_index(int index) {
2245  DCHECK_EQ(kDelegating, yield_kind());
2246  index_ = index;
2247  }
2248 
2249  // Type feedback information.
2251  return (FLAG_vector_ics && yield_kind() == kDelegating) ? 3 : 0;
2252  }
2253  virtual void SetFirstFeedbackSlot(int slot) {
2254  yield_first_feedback_slot_ = slot;
2255  }
2256 
2258  DCHECK(yield_first_feedback_slot_ != kInvalidFeedbackSlot);
2259  return yield_first_feedback_slot_;
2260  }
2261 
2263  DCHECK(yield_first_feedback_slot_ != kInvalidFeedbackSlot);
2264  return yield_first_feedback_slot_ + 1;
2265  }
2266 
2268  DCHECK(yield_first_feedback_slot_ != kInvalidFeedbackSlot);
2269  return yield_first_feedback_slot_ + 2;
2270  }
2271 
2272  protected:
2273  Yield(Zone* zone, Expression* generator_object, Expression* expression,
2274  Kind yield_kind, int pos, IdGen* id_gen)
2275  : Expression(zone, pos, id_gen),
2276  generator_object_(generator_object),
2277  expression_(expression),
2278  yield_kind_(yield_kind),
2279  index_(-1),
2280  yield_first_feedback_slot_(kInvalidFeedbackSlot) {}
2281 
2282  private:
2284  Expression* expression_;
2286  int index_;
2288 };
2289 
2290 
2291 class Throw FINAL : public Expression {
2292  public:
2294 
2295  Expression* exception() const { return exception_; }
2296 
2297  protected:
2298  Throw(Zone* zone, Expression* exception, int pos, IdGen* id_gen)
2299  : Expression(zone, pos, id_gen), exception_(exception) {}
2300 
2301  private:
2303 };
2304 
2305 
2306 class FunctionLiteral FINAL : public Expression {
2307  public:
2311  DECLARATION
2312  };
2313 
2315  kNoDuplicateParameters = 0,
2316  kHasDuplicateParameters = 1
2317  };
2318 
2321  kIsFunction
2322  };
2323 
2326  kNotParenthesized
2327  };
2328 
2332  SETTER_ARITY
2333  };
2334 
2335  DECLARE_NODE_TYPE(FunctionLiteral)
2336 
2337  Handle<String> name() const { return raw_name_->string(); }
2338  const AstRawString* raw_name() const { return raw_name_; }
2339  Scope* scope() const { return scope_; }
2340  ZoneList<Statement*>* body() const { return body_; }
2341  void set_function_token_position(int pos) { function_token_position_ = pos; }
2342  int function_token_position() const { return function_token_position_; }
2343  int start_position() const;
2344  int end_position() const;
2345  int SourceSize() const { return end_position() - start_position(); }
2346  bool is_expression() const { return IsExpression::decode(bitfield_); }
2347  bool is_anonymous() const { return IsAnonymous::decode(bitfield_); }
2349 
2350  int materialized_literal_count() { return materialized_literal_count_; }
2351  int expected_property_count() { return expected_property_count_; }
2352  int handler_count() { return handler_count_; }
2353  int parameter_count() { return parameter_count_; }
2354 
2357 
2359 
2361  if (raw_name_ != NULL && !raw_name_->IsEmpty()) {
2362  return raw_name_->string();
2363  }
2364  return inferred_name();
2365  }
2366 
2368  if (!inferred_name_.is_null()) {
2369  DCHECK(raw_inferred_name_ == NULL);
2370  return inferred_name_;
2371  }
2372  if (raw_inferred_name_ != NULL) {
2373  return raw_inferred_name_->string();
2374  }
2375  UNREACHABLE();
2376  return Handle<String>();
2377  }
2378 
2379  // Only one of {set_inferred_name, set_raw_inferred_name} should be called.
2380  void set_inferred_name(Handle<String> inferred_name) {
2381  DCHECK(!inferred_name.is_null());
2382  inferred_name_ = inferred_name;
2383  DCHECK(raw_inferred_name_== NULL || raw_inferred_name_->IsEmpty());
2384  raw_inferred_name_ = NULL;
2385  }
2386 
2387  void set_raw_inferred_name(const AstString* raw_inferred_name) {
2388  DCHECK(raw_inferred_name != NULL);
2389  raw_inferred_name_ = raw_inferred_name;
2390  DCHECK(inferred_name_.is_null());
2391  inferred_name_ = Handle<String>();
2392  }
2393 
2394  // shared_info may be null if it's not cached in full code.
2395  Handle<SharedFunctionInfo> shared_info() { return shared_info_; }
2396 
2397  bool pretenure() { return Pretenure::decode(bitfield_); }
2398  void set_pretenure() { bitfield_ |= Pretenure::encode(true); }
2399 
2401  return HasDuplicateParameters::decode(bitfield_);
2402  }
2403 
2404  bool is_function() { return IsFunction::decode(bitfield_) == kIsFunction; }
2405 
2406  // This is used as a heuristic on when to eagerly compile a function
2407  // literal. We consider the following constructs as hints that the
2408  // function will be called immediately:
2409  // - (function() { ... })();
2410  // - var x = function() { ... }();
2412  return IsParenthesized::decode(bitfield_) == kIsParenthesized;
2413  }
2415  bitfield_ = IsParenthesized::update(bitfield_, kIsParenthesized);
2416  }
2417 
2418  FunctionKind kind() { return FunctionKindBits::decode(bitfield_); }
2419  bool is_arrow() {
2420  return IsArrowFunction(FunctionKindBits::decode(bitfield_));
2421  }
2422  bool is_generator() {
2423  return IsGeneratorFunction(FunctionKindBits::decode(bitfield_));
2424  }
2426  return IsConciseMethod(FunctionKindBits::decode(bitfield_));
2427  }
2428 
2429  int ast_node_count() { return ast_properties_.node_count(); }
2430  AstProperties::Flags* flags() { return ast_properties_.flags(); }
2431  void set_ast_properties(AstProperties* ast_properties) {
2432  ast_properties_ = *ast_properties;
2433  }
2434  int slot_count() {
2435  return ast_properties_.feedback_slots();
2436  }
2437  bool dont_optimize() { return dont_optimize_reason_ != kNoReason; }
2438  BailoutReason dont_optimize_reason() { return dont_optimize_reason_; }
2440  dont_optimize_reason_ = reason;
2441  }
2442 
2443  protected:
2445  AstValueFactory* ast_value_factory, Scope* scope,
2446  ZoneList<Statement*>* body, int materialized_literal_count,
2447  int expected_property_count, int handler_count,
2448  int parameter_count, FunctionType function_type,
2450  IsFunctionFlag is_function,
2451  IsParenthesizedFlag is_parenthesized, FunctionKind kind,
2452  int position, IdGen* id_gen)
2453  : Expression(zone, position, id_gen),
2454  raw_name_(name),
2455  scope_(scope),
2456  body_(body),
2457  raw_inferred_name_(ast_value_factory->empty_string()),
2458  dont_optimize_reason_(kNoReason),
2459  materialized_literal_count_(materialized_literal_count),
2460  expected_property_count_(expected_property_count),
2461  handler_count_(handler_count),
2462  parameter_count_(parameter_count),
2463  function_token_position_(RelocInfo::kNoPosition) {
2464  bitfield_ = IsExpression::encode(function_type != DECLARATION) |
2465  IsAnonymous::encode(function_type == ANONYMOUS_EXPRESSION) |
2466  Pretenure::encode(false) |
2467  HasDuplicateParameters::encode(has_duplicate_parameters) |
2468  IsFunction::encode(is_function) |
2469  IsParenthesized::encode(is_parenthesized) |
2470  FunctionKindBits::encode(kind);
2471  DCHECK(IsValidFunctionKind(kind));
2472  }
2473 
2474  private:
2475  const AstRawString* raw_name_;
2478  Scope* scope_;
2482  AstProperties ast_properties_;
2484 
2490 
2491  unsigned bitfield_;
2492  class IsExpression : public BitField<bool, 0, 1> {};
2493  class IsAnonymous : public BitField<bool, 1, 1> {};
2494  class Pretenure : public BitField<bool, 2, 1> {};
2495  class HasDuplicateParameters : public BitField<ParameterFlag, 3, 1> {};
2496  class IsFunction : public BitField<IsFunctionFlag, 4, 1> {};
2497  class IsParenthesized : public BitField<IsParenthesizedFlag, 5, 1> {};
2498  class FunctionKindBits : public BitField<FunctionKind, 6, 3> {};
2499 };
2500 
2501 
2502 class ClassLiteral FINAL : public Expression {
2503  public:
2504  typedef ObjectLiteralProperty Property;
2505 
2506  DECLARE_NODE_TYPE(ClassLiteral)
2507 
2508  Handle<String> name() const { return raw_name_->string(); }
2509  const AstRawString* raw_name() const { return raw_name_; }
2510  Expression* extends() const { return extends_; }
2511  Expression* constructor() const { return constructor_; }
2512  ZoneList<Property*>* properties() const { return properties_; }
2513 
2514  protected:
2515  ClassLiteral(Zone* zone, const AstRawString* name, Expression* extends,
2516  Expression* constructor, ZoneList<Property*>* properties,
2517  int position, IdGen* id_gen)
2518  : Expression(zone, position, id_gen),
2519  raw_name_(name),
2520  extends_(extends),
2521  constructor_(constructor),
2522  properties_(properties) {}
2523 
2524  private:
2525  const AstRawString* raw_name_;
2528  ZoneList<Property*>* properties_;
2529 };
2530 
2531 
2532 class NativeFunctionLiteral FINAL : public Expression {
2533  public:
2534  DECLARE_NODE_TYPE(NativeFunctionLiteral)
2535 
2536  Handle<String> name() const { return name_->string(); }
2537  v8::Extension* extension() const { return extension_; }
2538 
2539  protected:
2541  v8::Extension* extension, int pos, IdGen* id_gen)
2542  : Expression(zone, pos, id_gen), name_(name), extension_(extension) {}
2543 
2544  private:
2545  const AstRawString* name_;
2547 };
2548 
2549 
2550 class ThisFunction FINAL : public Expression {
2551  public:
2552  DECLARE_NODE_TYPE(ThisFunction)
2553 
2554  protected:
2555  ThisFunction(Zone* zone, int pos, IdGen* id_gen)
2556  : Expression(zone, pos, id_gen) {}
2557 };
2558 
2559 
2560 class SuperReference FINAL : public Expression {
2561  public:
2562  DECLARE_NODE_TYPE(SuperReference)
2563 
2564  VariableProxy* this_var() const { return this_var_; }
2565 
2566  TypeFeedbackId HomeObjectFeedbackId() { return reuse(id()); }
2567 
2568  protected:
2569  SuperReference(Zone* zone, VariableProxy* this_var, int pos, IdGen* id_gen)
2570  : Expression(zone, pos, id_gen), this_var_(this_var) {
2571  DCHECK(this_var->is_this());
2572  }
2573 
2574  VariableProxy* this_var_;
2575 };
2576 
2577 
2578 #undef DECLARE_NODE_TYPE
2579 
2580 
2581 // ----------------------------------------------------------------------------
2582 // Regular expressions
2583 
2584 
2586  public:
2587  virtual ~RegExpVisitor() { }
2588 #define MAKE_CASE(Name) \
2589  virtual void* Visit##Name(RegExp##Name*, void* data) = 0;
2591 #undef MAKE_CASE
2592 };
2593 
2594 
2595 class RegExpTree : public ZoneObject {
2596  public:
2597  static const int kInfinity = kMaxInt;
2598  virtual ~RegExpTree() {}
2599  virtual void* Accept(RegExpVisitor* visitor, void* data) = 0;
2600  virtual RegExpNode* ToNode(RegExpCompiler* compiler,
2601  RegExpNode* on_success) = 0;
2602  virtual bool IsTextElement() { return false; }
2603  virtual bool IsAnchoredAtStart() { return false; }
2604  virtual bool IsAnchoredAtEnd() { return false; }
2605  virtual int min_match() = 0;
2606  virtual int max_match() = 0;
2607  // Returns the interval of registers used for captures within this
2608  // expression.
2610  virtual void AppendToText(RegExpText* text, Zone* zone);
2611  OStream& Print(OStream& os, Zone* zone); // NOLINT
2612 #define MAKE_ASTYPE(Name) \
2613  virtual RegExp##Name* As##Name(); \
2614  virtual bool Is##Name();
2616 #undef MAKE_ASTYPE
2617 };
2618 
2619 
2620 class RegExpDisjunction FINAL : public RegExpTree {
2621  public:
2622  explicit RegExpDisjunction(ZoneList<RegExpTree*>* alternatives);
2623  virtual void* Accept(RegExpVisitor* visitor, void* data) OVERRIDE;
2624  virtual RegExpNode* ToNode(RegExpCompiler* compiler,
2625  RegExpNode* on_success) OVERRIDE;
2626  virtual RegExpDisjunction* AsDisjunction() OVERRIDE;
2627  virtual Interval CaptureRegisters() OVERRIDE;
2628  virtual bool IsDisjunction() OVERRIDE;
2629  virtual bool IsAnchoredAtStart() OVERRIDE;
2630  virtual bool IsAnchoredAtEnd() OVERRIDE;
2631  virtual int min_match() OVERRIDE { return min_match_; }
2632  virtual int max_match() OVERRIDE { return max_match_; }
2633  ZoneList<RegExpTree*>* alternatives() { return alternatives_; }
2634  private:
2638 };
2639 
2640 
2641 class RegExpAlternative FINAL : public RegExpTree {
2642  public:
2644  virtual void* Accept(RegExpVisitor* visitor, void* data) OVERRIDE;
2645  virtual RegExpNode* ToNode(RegExpCompiler* compiler,
2646  RegExpNode* on_success) OVERRIDE;
2647  virtual RegExpAlternative* AsAlternative() OVERRIDE;
2648  virtual Interval CaptureRegisters() OVERRIDE;
2649  virtual bool IsAlternative() OVERRIDE;
2650  virtual bool IsAnchoredAtStart() OVERRIDE;
2651  virtual bool IsAnchoredAtEnd() OVERRIDE;
2652  virtual int min_match() OVERRIDE { return min_match_; }
2653  virtual int max_match() OVERRIDE { return max_match_; }
2654  ZoneList<RegExpTree*>* nodes() { return nodes_; }
2655  private:
2657  int min_match_;
2658  int max_match_;
2659 };
2660 
2661 
2662 class RegExpAssertion FINAL : public RegExpTree {
2663  public:
2670  NON_BOUNDARY
2671  };
2672  explicit RegExpAssertion(AssertionType type) : assertion_type_(type) { }
2673  virtual void* Accept(RegExpVisitor* visitor, void* data) OVERRIDE;
2674  virtual RegExpNode* ToNode(RegExpCompiler* compiler,
2675  RegExpNode* on_success) OVERRIDE;
2676  virtual RegExpAssertion* AsAssertion() OVERRIDE;
2677  virtual bool IsAssertion() OVERRIDE;
2678  virtual bool IsAnchoredAtStart() OVERRIDE;
2679  virtual bool IsAnchoredAtEnd() OVERRIDE;
2680  virtual int min_match() OVERRIDE { return 0; }
2681  virtual int max_match() OVERRIDE { return 0; }
2682  AssertionType assertion_type() { return assertion_type_; }
2683  private:
2685 };
2686 
2687 
2688 class CharacterSet FINAL BASE_EMBEDDED {
2689  public:
2690  explicit CharacterSet(uc16 standard_set_type)
2691  : ranges_(NULL),
2692  standard_set_type_(standard_set_type) {}
2694  : ranges_(ranges),
2695  standard_set_type_(0) {}
2697  uc16 standard_set_type() { return standard_set_type_; }
2698  void set_standard_set_type(uc16 special_set_type) {
2699  standard_set_type_ = special_set_type;
2700  }
2701  bool is_standard() { return standard_set_type_ != 0; }
2703  private:
2705  // If non-zero, the value represents a standard set (e.g., all whitespace
2706  // characters) without having to expand the ranges.
2708 };
2709 
2710 
2711 class RegExpCharacterClass FINAL : public RegExpTree {
2712  public:
2714  : set_(ranges),
2715  is_negated_(is_negated) { }
2717  : set_(type),
2718  is_negated_(false) { }
2719  virtual void* Accept(RegExpVisitor* visitor, void* data) OVERRIDE;
2720  virtual RegExpNode* ToNode(RegExpCompiler* compiler,
2721  RegExpNode* on_success) OVERRIDE;
2722  virtual RegExpCharacterClass* AsCharacterClass() OVERRIDE;
2723  virtual bool IsCharacterClass() OVERRIDE;
2724  virtual bool IsTextElement() OVERRIDE { return true; }
2725  virtual int min_match() OVERRIDE { return 1; }
2726  virtual int max_match() OVERRIDE { return 1; }
2727  virtual void AppendToText(RegExpText* text, Zone* zone) OVERRIDE;
2728  CharacterSet character_set() { return set_; }
2729  // TODO(lrn): Remove need for complex version if is_standard that
2730  // recognizes a mangled standard set and just do { return set_.is_special(); }
2731  bool is_standard(Zone* zone);
2732  // Returns a value representing the standard character set if is_standard()
2733  // returns true.
2734  // Currently used values are:
2735  // s : unicode whitespace
2736  // S : unicode non-whitespace
2737  // w : ASCII word character (digit, letter, underscore)
2738  // W : non-ASCII word character
2739  // d : ASCII digit
2740  // D : non-ASCII digit
2741  // . : non-unicode non-newline
2742  // * : All characters
2743  uc16 standard_type() { return set_.standard_set_type(); }
2744  ZoneList<CharacterRange>* ranges(Zone* zone) { return set_.ranges(zone); }
2745  bool is_negated() { return is_negated_; }
2746 
2747  private:
2748  CharacterSet set_;
2750 };
2751 
2752 
2753 class RegExpAtom FINAL : public RegExpTree {
2754  public:
2755  explicit RegExpAtom(Vector<const uc16> data) : data_(data) { }
2756  virtual void* Accept(RegExpVisitor* visitor, void* data) OVERRIDE;
2757  virtual RegExpNode* ToNode(RegExpCompiler* compiler,
2758  RegExpNode* on_success) OVERRIDE;
2759  virtual RegExpAtom* AsAtom() OVERRIDE;
2760  virtual bool IsAtom() OVERRIDE;
2761  virtual bool IsTextElement() OVERRIDE { return true; }
2762  virtual int min_match() OVERRIDE { return data_.length(); }
2763  virtual int max_match() OVERRIDE { return data_.length(); }
2764  virtual void AppendToText(RegExpText* text, Zone* zone) OVERRIDE;
2765  Vector<const uc16> data() { return data_; }
2766  int length() { return data_.length(); }
2767  private:
2769 };
2770 
2771 
2772 class RegExpText FINAL : public RegExpTree {
2773  public:
2774  explicit RegExpText(Zone* zone) : elements_(2, zone), length_(0) {}
2775  virtual void* Accept(RegExpVisitor* visitor, void* data) OVERRIDE;
2776  virtual RegExpNode* ToNode(RegExpCompiler* compiler,
2777  RegExpNode* on_success) OVERRIDE;
2778  virtual RegExpText* AsText() OVERRIDE;
2779  virtual bool IsText() OVERRIDE;
2780  virtual bool IsTextElement() OVERRIDE { return true; }
2781  virtual int min_match() OVERRIDE { return length_; }
2782  virtual int max_match() OVERRIDE { return length_; }
2783  virtual void AppendToText(RegExpText* text, Zone* zone) OVERRIDE;
2784  void AddElement(TextElement elm, Zone* zone) {
2785  elements_.Add(elm, zone);
2786  length_ += elm.length();
2787  }
2788  ZoneList<TextElement>* elements() { return &elements_; }
2789  private:
2791  int length_;
2792 };
2793 
2794 
2795 class RegExpQuantifier FINAL : public RegExpTree {
2796  public:
2797  enum QuantifierType { GREEDY, NON_GREEDY, POSSESSIVE };
2798  RegExpQuantifier(int min, int max, QuantifierType type, RegExpTree* body)
2799  : body_(body),
2800  min_(min),
2801  max_(max),
2802  min_match_(min * body->min_match()),
2803  quantifier_type_(type) {
2804  if (max > 0 && body->max_match() > kInfinity / max) {
2805  max_match_ = kInfinity;
2806  } else {
2807  max_match_ = max * body->max_match();
2808  }
2809  }
2810  virtual void* Accept(RegExpVisitor* visitor, void* data) OVERRIDE;
2811  virtual RegExpNode* ToNode(RegExpCompiler* compiler,
2812  RegExpNode* on_success) OVERRIDE;
2813  static RegExpNode* ToNode(int min,
2814  int max,
2815  bool is_greedy,
2816  RegExpTree* body,
2817  RegExpCompiler* compiler,
2818  RegExpNode* on_success,
2819  bool not_at_start = false);
2820  virtual RegExpQuantifier* AsQuantifier() OVERRIDE;
2821  virtual Interval CaptureRegisters() OVERRIDE;
2822  virtual bool IsQuantifier() OVERRIDE;
2823  virtual int min_match() OVERRIDE { return min_match_; }
2824  virtual int max_match() OVERRIDE { return max_match_; }
2825  int min() { return min_; }
2826  int max() { return max_; }
2827  bool is_possessive() { return quantifier_type_ == POSSESSIVE; }
2828  bool is_non_greedy() { return quantifier_type_ == NON_GREEDY; }
2829  bool is_greedy() { return quantifier_type_ == GREEDY; }
2830  RegExpTree* body() { return body_; }
2831 
2832  private:
2834  int min_;
2835  int max_;
2836  int min_match_;
2837  int max_match_;
2839 };
2840 
2841 
2842 class RegExpCapture FINAL : public RegExpTree {
2843  public:
2844  explicit RegExpCapture(RegExpTree* body, int index)
2845  : body_(body), index_(index) { }
2846  virtual void* Accept(RegExpVisitor* visitor, void* data) OVERRIDE;
2847  virtual RegExpNode* ToNode(RegExpCompiler* compiler,
2848  RegExpNode* on_success) OVERRIDE;
2850  int index,
2851  RegExpCompiler* compiler,
2852  RegExpNode* on_success);
2853  virtual RegExpCapture* AsCapture() OVERRIDE;
2854  virtual bool IsAnchoredAtStart() OVERRIDE;
2855  virtual bool IsAnchoredAtEnd() OVERRIDE;
2856  virtual Interval CaptureRegisters() OVERRIDE;
2857  virtual bool IsCapture() OVERRIDE;
2858  virtual int min_match() OVERRIDE { return body_->min_match(); }
2859  virtual int max_match() OVERRIDE { return body_->max_match(); }
2860  RegExpTree* body() { return body_; }
2861  int index() { return index_; }
2862  static int StartRegister(int index) { return index * 2; }
2863  static int EndRegister(int index) { return index * 2 + 1; }
2864 
2865  private:
2866  RegExpTree* body_;
2867  int index_;
2868 };
2869 
2870 
2871 class RegExpLookahead FINAL : public RegExpTree {
2872  public:
2874  bool is_positive,
2875  int capture_count,
2876  int capture_from)
2877  : body_(body),
2878  is_positive_(is_positive),
2879  capture_count_(capture_count),
2880  capture_from_(capture_from) { }
2881 
2882  virtual void* Accept(RegExpVisitor* visitor, void* data) OVERRIDE;
2883  virtual RegExpNode* ToNode(RegExpCompiler* compiler,
2884  RegExpNode* on_success) OVERRIDE;
2885  virtual RegExpLookahead* AsLookahead() OVERRIDE;
2886  virtual Interval CaptureRegisters() OVERRIDE;
2887  virtual bool IsLookahead() OVERRIDE;
2888  virtual bool IsAnchoredAtStart() OVERRIDE;
2889  virtual int min_match() OVERRIDE { return 0; }
2890  virtual int max_match() OVERRIDE { return 0; }
2891  RegExpTree* body() { return body_; }
2892  bool is_positive() { return is_positive_; }
2893  int capture_count() { return capture_count_; }
2894  int capture_from() { return capture_from_; }
2895 
2896  private:
2897  RegExpTree* body_;
2901 };
2902 
2903 
2904 class RegExpBackReference FINAL : public RegExpTree {
2905  public:
2906  explicit RegExpBackReference(RegExpCapture* capture)
2907  : capture_(capture) { }
2908  virtual void* Accept(RegExpVisitor* visitor, void* data) OVERRIDE;
2909  virtual RegExpNode* ToNode(RegExpCompiler* compiler,
2910  RegExpNode* on_success) OVERRIDE;
2911  virtual RegExpBackReference* AsBackReference() OVERRIDE;
2912  virtual bool IsBackReference() OVERRIDE;
2913  virtual int min_match() OVERRIDE { return 0; }
2914  virtual int max_match() OVERRIDE { return capture_->max_match(); }
2915  int index() { return capture_->index(); }
2916  RegExpCapture* capture() { return capture_; }
2917  private:
2918  RegExpCapture* capture_;
2919 };
2920 
2921 
2922 class RegExpEmpty FINAL : public RegExpTree {
2923  public:
2925  virtual void* Accept(RegExpVisitor* visitor, void* data) OVERRIDE;
2926  virtual RegExpNode* ToNode(RegExpCompiler* compiler,
2927  RegExpNode* on_success) OVERRIDE;
2928  virtual RegExpEmpty* AsEmpty() OVERRIDE;
2929  virtual bool IsEmpty() OVERRIDE;
2930  virtual int min_match() OVERRIDE { return 0; }
2931  virtual int max_match() OVERRIDE { return 0; }
2932  static RegExpEmpty* GetInstance() {
2933  static RegExpEmpty* instance = ::new RegExpEmpty();
2934  return instance;
2935  }
2936 };
2937 
2938 
2939 // ----------------------------------------------------------------------------
2940 // Out-of-line inline constructors (to side-step cyclic dependencies).
2941 
2942 inline ModuleVariable::ModuleVariable(Zone* zone, VariableProxy* proxy, int pos)
2943  : Module(zone, proxy->interface(), pos),
2944  proxy_(proxy) {
2945 }
2946 
2947 
2948 // ----------------------------------------------------------------------------
2949 // Basic visitor
2950 // - leaf node visitors are abstract.
2951 
2952 class AstVisitor BASE_EMBEDDED {
2953  public:
2955  virtual ~AstVisitor() {}
2956 
2957  // Stack overflow check and dynamic dispatch.
2958  virtual void Visit(AstNode* node) = 0;
2959 
2960  // Iteration left-to-right.
2961  virtual void VisitDeclarations(ZoneList<Declaration*>* declarations);
2962  virtual void VisitStatements(ZoneList<Statement*>* statements);
2963  virtual void VisitExpressions(ZoneList<Expression*>* expressions);
2964 
2965  // Individual AST nodes.
2966 #define DEF_VISIT(type) \
2967  virtual void Visit##type(type* node) = 0;
2969 #undef DEF_VISIT
2970 };
2971 
2972 
2973 #define DEFINE_AST_VISITOR_SUBCLASS_MEMBERS() \
2974 public: \
2975  virtual void Visit(AstNode* node) FINAL OVERRIDE { \
2976  if (!CheckStackOverflow()) node->Accept(this); \
2977  } \
2978  \
2979  void SetStackOverflow() { stack_overflow_ = true; } \
2980  void ClearStackOverflow() { stack_overflow_ = false; } \
2981  bool HasStackOverflow() const { return stack_overflow_; } \
2982  \
2983  bool CheckStackOverflow() { \
2984  if (stack_overflow_) return true; \
2985  StackLimitCheck check(zone_->isolate()); \
2986  if (!check.HasOverflowed()) return false; \
2987  return (stack_overflow_ = true); \
2988  } \
2989  \
2990 private: \
2991  void InitializeAstVisitor(Zone* zone) { \
2992  zone_ = zone; \
2993  stack_overflow_ = false; \
2994  } \
2995  Zone* zone() { return zone_; } \
2996  Isolate* isolate() { return zone_->isolate(); } \
2997  \
2998  Zone* zone_; \
2999  bool stack_overflow_
3000 
3001 
3002 // ----------------------------------------------------------------------------
3003 // Construction time visitor.
3004 
3005 class AstConstructionVisitor BASE_EMBEDDED {
3006  public:
3008  : dont_crankshaft_reason_(kNoReason), dont_turbofan_reason_(kNoReason) {}
3009 
3010  AstProperties* ast_properties() { return &properties_; }
3012  if (dont_turbofan_reason_ != kNoReason) {
3013  return dont_turbofan_reason_;
3014  } else {
3015  return dont_crankshaft_reason_;
3016  }
3017  }
3018 
3019  private:
3020  template<class> friend class AstNodeFactory;
3021 
3022  // Node visitors.
3023 #define DEF_VISIT(type) \
3024  void Visit##type(type* node);
3026 #undef DEF_VISIT
3027 
3028  void increase_node_count() { properties_.add_node_count(1); }
3029  void add_flag(AstPropertiesFlag flag) { properties_.flags()->Add(flag); }
3031  dont_crankshaft_reason_ = reason;
3032  }
3034  dont_turbofan_reason_ = reason;
3035  }
3036 
3038  int count = slot_node->ComputeFeedbackSlotCount();
3039  if (count > 0) {
3040  slot_node->SetFirstFeedbackSlot(properties_.feedback_slots());
3041  properties_.increase_feedback_slots(count);
3042  }
3043  }
3044 
3045  AstProperties properties_;
3048 };
3049 
3050 
3051 class AstNullVisitor BASE_EMBEDDED {
3052  public:
3053  // Node visitors.
3054 #define DEF_VISIT(type) \
3055  void Visit##type(type* node) {}
3057 #undef DEF_VISIT
3058 };
3059 
3060 
3061 
3062 // ----------------------------------------------------------------------------
3063 // AstNode factory
3064 
3065 template<class Visitor>
3066 class AstNodeFactory FINAL BASE_EMBEDDED {
3067  public:
3068  AstNodeFactory(Zone* zone, AstValueFactory* ast_value_factory,
3069  AstNode::IdGen* id_gen)
3070  : zone_(zone), ast_value_factory_(ast_value_factory), id_gen_(id_gen) {}
3071 
3072  Visitor* visitor() { return &visitor_; }
3073 
3074 #define VISIT_AND_RETURN(NodeType, node) \
3075  visitor_.Visit##NodeType((node)); \
3076  return node;
3077 
3078  VariableDeclaration* NewVariableDeclaration(VariableProxy* proxy,
3080  Scope* scope,
3081  int pos) {
3082  VariableDeclaration* decl =
3083  new(zone_) VariableDeclaration(zone_, proxy, mode, scope, pos);
3084  VISIT_AND_RETURN(VariableDeclaration, decl)
3085  }
3086 
3087  FunctionDeclaration* NewFunctionDeclaration(VariableProxy* proxy,
3089  FunctionLiteral* fun,
3090  Scope* scope,
3091  int pos) {
3092  FunctionDeclaration* decl =
3093  new(zone_) FunctionDeclaration(zone_, proxy, mode, fun, scope, pos);
3094  VISIT_AND_RETURN(FunctionDeclaration, decl)
3095  }
3096 
3097  ModuleDeclaration* NewModuleDeclaration(VariableProxy* proxy,
3098  Module* module,
3099  Scope* scope,
3100  int pos) {
3101  ModuleDeclaration* decl =
3102  new(zone_) ModuleDeclaration(zone_, proxy, module, scope, pos);
3103  VISIT_AND_RETURN(ModuleDeclaration, decl)
3104  }
3105 
3106  ImportDeclaration* NewImportDeclaration(VariableProxy* proxy,
3107  Module* module,
3108  Scope* scope,
3109  int pos) {
3110  ImportDeclaration* decl =
3111  new(zone_) ImportDeclaration(zone_, proxy, module, scope, pos);
3112  VISIT_AND_RETURN(ImportDeclaration, decl)
3113  }
3114 
3115  ExportDeclaration* NewExportDeclaration(VariableProxy* proxy,
3116  Scope* scope,
3117  int pos) {
3118  ExportDeclaration* decl =
3119  new(zone_) ExportDeclaration(zone_, proxy, scope, pos);
3120  VISIT_AND_RETURN(ExportDeclaration, decl)
3121  }
3122 
3123  ModuleLiteral* NewModuleLiteral(Block* body, Interface* interface, int pos) {
3124  ModuleLiteral* module =
3125  new(zone_) ModuleLiteral(zone_, body, interface, pos);
3126  VISIT_AND_RETURN(ModuleLiteral, module)
3127  }
3128 
3129  ModuleVariable* NewModuleVariable(VariableProxy* proxy, int pos) {
3130  ModuleVariable* module = new(zone_) ModuleVariable(zone_, proxy, pos);
3131  VISIT_AND_RETURN(ModuleVariable, module)
3132  }
3133 
3134  ModulePath* NewModulePath(Module* origin, const AstRawString* name, int pos) {
3135  ModulePath* module = new (zone_) ModulePath(zone_, origin, name, pos);
3136  VISIT_AND_RETURN(ModulePath, module)
3137  }
3138 
3139  ModuleUrl* NewModuleUrl(Handle<String> url, int pos) {
3140  ModuleUrl* module = new(zone_) ModuleUrl(zone_, url, pos);
3141  VISIT_AND_RETURN(ModuleUrl, module)
3142  }
3143 
3145  int capacity,
3146  bool is_initializer_block,
3147  int pos) {
3148  Block* block = new (zone_)
3149  Block(zone_, labels, capacity, is_initializer_block, pos, id_gen_);
3150  VISIT_AND_RETURN(Block, block)
3151  }
3152 
3153 #define STATEMENT_WITH_LABELS(NodeType) \
3154  NodeType* New##NodeType(ZoneList<const AstRawString*>* labels, int pos) { \
3155  NodeType* stmt = new (zone_) NodeType(zone_, labels, pos, id_gen_); \
3156  VISIT_AND_RETURN(NodeType, stmt); \
3157  }
3158  STATEMENT_WITH_LABELS(DoWhileStatement)
3159  STATEMENT_WITH_LABELS(WhileStatement)
3160  STATEMENT_WITH_LABELS(ForStatement)
3161  STATEMENT_WITH_LABELS(SwitchStatement)
3162 #undef STATEMENT_WITH_LABELS
3163 
3166  int pos) {
3167  switch (visit_mode) {
3169  ForInStatement* stmt =
3170  new (zone_) ForInStatement(zone_, labels, pos, id_gen_);
3171  VISIT_AND_RETURN(ForInStatement, stmt);
3172  }
3174  ForOfStatement* stmt =
3175  new (zone_) ForOfStatement(zone_, labels, pos, id_gen_);
3176  VISIT_AND_RETURN(ForOfStatement, stmt);
3177  }
3178  }
3179  UNREACHABLE();
3180  return NULL;
3181  }
3182 
3183  ModuleStatement* NewModuleStatement(
3184  VariableProxy* proxy, Block* body, int pos) {
3185  ModuleStatement* stmt = new(zone_) ModuleStatement(zone_, proxy, body, pos);
3186  VISIT_AND_RETURN(ModuleStatement, stmt)
3187  }
3188 
3189  ExpressionStatement* NewExpressionStatement(Expression* expression, int pos) {
3190  ExpressionStatement* stmt =
3191  new(zone_) ExpressionStatement(zone_, expression, pos);
3192  VISIT_AND_RETURN(ExpressionStatement, stmt)
3193  }
3194 
3195  ContinueStatement* NewContinueStatement(IterationStatement* target, int pos) {
3196  ContinueStatement* stmt = new(zone_) ContinueStatement(zone_, target, pos);
3197  VISIT_AND_RETURN(ContinueStatement, stmt)
3198  }
3199 
3200  BreakStatement* NewBreakStatement(BreakableStatement* target, int pos) {
3201  BreakStatement* stmt = new(zone_) BreakStatement(zone_, target, pos);
3202  VISIT_AND_RETURN(BreakStatement, stmt)
3203  }
3204 
3205  ReturnStatement* NewReturnStatement(Expression* expression, int pos) {
3206  ReturnStatement* stmt = new(zone_) ReturnStatement(zone_, expression, pos);
3207  VISIT_AND_RETURN(ReturnStatement, stmt)
3208  }
3209 
3210  WithStatement* NewWithStatement(Scope* scope,
3211  Expression* expression,
3212  Statement* statement,
3213  int pos) {
3214  WithStatement* stmt = new(zone_) WithStatement(
3215  zone_, scope, expression, statement, pos);
3216  VISIT_AND_RETURN(WithStatement, stmt)
3217  }
3218 
3219  IfStatement* NewIfStatement(Expression* condition,
3220  Statement* then_statement,
3221  Statement* else_statement,
3222  int pos) {
3223  IfStatement* stmt = new (zone_) IfStatement(
3224  zone_, condition, then_statement, else_statement, pos, id_gen_);
3225  VISIT_AND_RETURN(IfStatement, stmt)
3226  }
3227 
3228  TryCatchStatement* NewTryCatchStatement(int index,
3229  Block* try_block,
3230  Scope* scope,
3231  Variable* variable,
3232  Block* catch_block,
3233  int pos) {
3234  TryCatchStatement* stmt = new(zone_) TryCatchStatement(
3235  zone_, index, try_block, scope, variable, catch_block, pos);
3236  VISIT_AND_RETURN(TryCatchStatement, stmt)
3237  }
3238 
3239  TryFinallyStatement* NewTryFinallyStatement(int index,
3240  Block* try_block,
3241  Block* finally_block,
3242  int pos) {
3243  TryFinallyStatement* stmt = new(zone_) TryFinallyStatement(
3244  zone_, index, try_block, finally_block, pos);
3245  VISIT_AND_RETURN(TryFinallyStatement, stmt)
3246  }
3247 
3248  DebuggerStatement* NewDebuggerStatement(int pos) {
3249  DebuggerStatement* stmt =
3250  new (zone_) DebuggerStatement(zone_, pos, id_gen_);
3251  VISIT_AND_RETURN(DebuggerStatement, stmt)
3252  }
3253 
3254  EmptyStatement* NewEmptyStatement(int pos) {
3255  return new(zone_) EmptyStatement(zone_, pos);
3256  }
3257 
3258  CaseClause* NewCaseClause(
3259  Expression* label, ZoneList<Statement*>* statements, int pos) {
3260  CaseClause* clause =
3261  new (zone_) CaseClause(zone_, label, statements, pos, id_gen_);
3262  VISIT_AND_RETURN(CaseClause, clause)
3263  }
3264 
3265  Literal* NewStringLiteral(const AstRawString* string, int pos) {
3266  Literal* lit = new (zone_)
3267  Literal(zone_, ast_value_factory_->NewString(string), pos, id_gen_);
3268  VISIT_AND_RETURN(Literal, lit)
3269  }
3270 
3271  // A JavaScript symbol (ECMA-262 edition 6).
3272  Literal* NewSymbolLiteral(const char* name, int pos) {
3273  Literal* lit = new (zone_)
3274  Literal(zone_, ast_value_factory_->NewSymbol(name), pos, id_gen_);
3275  VISIT_AND_RETURN(Literal, lit)
3276  }
3277 
3278  Literal* NewNumberLiteral(double number, int pos) {
3279  Literal* lit = new (zone_)
3280  Literal(zone_, ast_value_factory_->NewNumber(number), pos, id_gen_);
3281  VISIT_AND_RETURN(Literal, lit)
3282  }
3283 
3284  Literal* NewSmiLiteral(int number, int pos) {
3285  Literal* lit = new (zone_)
3286  Literal(zone_, ast_value_factory_->NewSmi(number), pos, id_gen_);
3287  VISIT_AND_RETURN(Literal, lit)
3288  }
3289 
3290  Literal* NewBooleanLiteral(bool b, int pos) {
3291  Literal* lit = new (zone_)
3292  Literal(zone_, ast_value_factory_->NewBoolean(b), pos, id_gen_);
3293  VISIT_AND_RETURN(Literal, lit)
3294  }
3295 
3297  int pos) {
3298  Literal* lit = new (zone_) Literal(
3299  zone_, ast_value_factory_->NewStringList(strings), pos, id_gen_);
3300  VISIT_AND_RETURN(Literal, lit)
3301  }
3302 
3303  Literal* NewNullLiteral(int pos) {
3304  Literal* lit =
3305  new (zone_) Literal(zone_, ast_value_factory_->NewNull(), pos, id_gen_);
3306  VISIT_AND_RETURN(Literal, lit)
3307  }
3308 
3309  Literal* NewUndefinedLiteral(int pos) {
3310  Literal* lit = new (zone_)
3311  Literal(zone_, ast_value_factory_->NewUndefined(), pos, id_gen_);
3312  VISIT_AND_RETURN(Literal, lit)
3313  }
3314 
3315  Literal* NewTheHoleLiteral(int pos) {
3316  Literal* lit = new (zone_)
3317  Literal(zone_, ast_value_factory_->NewTheHole(), pos, id_gen_);
3318  VISIT_AND_RETURN(Literal, lit)
3319  }
3320 
3321  ObjectLiteral* NewObjectLiteral(
3323  int literal_index,
3324  int boilerplate_properties,
3325  bool has_function,
3326  int pos) {
3327  ObjectLiteral* lit = new (zone_)
3328  ObjectLiteral(zone_, properties, literal_index, boilerplate_properties,
3329  has_function, pos, id_gen_);
3330  VISIT_AND_RETURN(ObjectLiteral, lit)
3331  }
3332 
3333  ObjectLiteral::Property* NewObjectLiteralProperty(Literal* key,
3334  Expression* value,
3335  bool is_static) {
3336  return new (zone_) ObjectLiteral::Property(zone_, ast_value_factory_, key,
3337  value, is_static);
3338  }
3339 
3340  ObjectLiteral::Property* NewObjectLiteralProperty(bool is_getter,
3341  FunctionLiteral* value,
3342  int pos, bool is_static) {
3343  ObjectLiteral::Property* prop =
3344  new (zone_) ObjectLiteral::Property(zone_, is_getter, value, is_static);
3345  prop->set_key(NewStringLiteral(value->raw_name(), pos));
3346  return prop; // Not an AST node, will not be visited.
3347  }
3348 
3349  RegExpLiteral* NewRegExpLiteral(const AstRawString* pattern,
3350  const AstRawString* flags,
3351  int literal_index,
3352  int pos) {
3353  RegExpLiteral* lit = new (zone_)
3354  RegExpLiteral(zone_, pattern, flags, literal_index, pos, id_gen_);
3355  VISIT_AND_RETURN(RegExpLiteral, lit);
3356  }
3357 
3359  int literal_index,
3360  int pos) {
3361  ArrayLiteral* lit =
3362  new (zone_) ArrayLiteral(zone_, values, literal_index, pos, id_gen_);
3363  VISIT_AND_RETURN(ArrayLiteral, lit)
3364  }
3365 
3366  VariableProxy* NewVariableProxy(Variable* var,
3367  int pos = RelocInfo::kNoPosition) {
3368  VariableProxy* proxy = new (zone_) VariableProxy(zone_, var, pos, id_gen_);
3369  VISIT_AND_RETURN(VariableProxy, proxy)
3370  }
3371 
3372  VariableProxy* NewVariableProxy(const AstRawString* name,
3373  bool is_this,
3374  Interface* interface = Interface::NewValue(),
3375  int position = RelocInfo::kNoPosition) {
3376  VariableProxy* proxy = new (zone_)
3377  VariableProxy(zone_, name, is_this, interface, position, id_gen_);
3378  VISIT_AND_RETURN(VariableProxy, proxy)
3379  }
3380 
3381  Property* NewProperty(Expression* obj, Expression* key, int pos) {
3382  Property* prop = new (zone_) Property(zone_, obj, key, pos, id_gen_);
3383  VISIT_AND_RETURN(Property, prop)
3384  }
3385 
3386  Call* NewCall(Expression* expression,
3387  ZoneList<Expression*>* arguments,
3388  int pos) {
3389  Call* call = new (zone_) Call(zone_, expression, arguments, pos, id_gen_);
3390  VISIT_AND_RETURN(Call, call)
3391  }
3392 
3393  CallNew* NewCallNew(Expression* expression,
3394  ZoneList<Expression*>* arguments,
3395  int pos) {
3396  CallNew* call =
3397  new (zone_) CallNew(zone_, expression, arguments, pos, id_gen_);
3398  VISIT_AND_RETURN(CallNew, call)
3399  }
3400 
3401  CallRuntime* NewCallRuntime(const AstRawString* name,
3402  const Runtime::Function* function,
3403  ZoneList<Expression*>* arguments,
3404  int pos) {
3405  CallRuntime* call =
3406  new (zone_) CallRuntime(zone_, name, function, arguments, pos, id_gen_);
3407  VISIT_AND_RETURN(CallRuntime, call)
3408  }
3409 
3410  UnaryOperation* NewUnaryOperation(Token::Value op,
3411  Expression* expression,
3412  int pos) {
3413  UnaryOperation* node =
3414  new (zone_) UnaryOperation(zone_, op, expression, pos, id_gen_);
3415  VISIT_AND_RETURN(UnaryOperation, node)
3416  }
3417 
3418  BinaryOperation* NewBinaryOperation(Token::Value op,
3419  Expression* left,
3420  Expression* right,
3421  int pos) {
3422  BinaryOperation* node =
3423  new (zone_) BinaryOperation(zone_, op, left, right, pos, id_gen_);
3424  VISIT_AND_RETURN(BinaryOperation, node)
3425  }
3426 
3427  CountOperation* NewCountOperation(Token::Value op,
3428  bool is_prefix,
3429  Expression* expr,
3430  int pos) {
3431  CountOperation* node =
3432  new (zone_) CountOperation(zone_, op, is_prefix, expr, pos, id_gen_);
3433  VISIT_AND_RETURN(CountOperation, node)
3434  }
3435 
3436  CompareOperation* NewCompareOperation(Token::Value op,
3437  Expression* left,
3438  Expression* right,
3439  int pos) {
3440  CompareOperation* node =
3441  new (zone_) CompareOperation(zone_, op, left, right, pos, id_gen_);
3442  VISIT_AND_RETURN(CompareOperation, node)
3443  }
3444 
3445  Conditional* NewConditional(Expression* condition,
3446  Expression* then_expression,
3447  Expression* else_expression,
3448  int position) {
3449  Conditional* cond = new (zone_) Conditional(
3450  zone_, condition, then_expression, else_expression, position, id_gen_);
3451  VISIT_AND_RETURN(Conditional, cond)
3452  }
3453 
3454  Assignment* NewAssignment(Token::Value op,
3455  Expression* target,
3456  Expression* value,
3457  int pos) {
3458  Assignment* assign =
3459  new (zone_) Assignment(zone_, op, target, value, pos, id_gen_);
3460  assign->Init(zone_, this);
3461  VISIT_AND_RETURN(Assignment, assign)
3462  }
3463 
3464  Yield* NewYield(Expression *generator_object,
3465  Expression* expression,
3466  Yield::Kind yield_kind,
3467  int pos) {
3468  if (!expression) expression = NewUndefinedLiteral(pos);
3469  Yield* yield = new (zone_)
3470  Yield(zone_, generator_object, expression, yield_kind, pos, id_gen_);
3471  VISIT_AND_RETURN(Yield, yield)
3472  }
3473 
3474  Throw* NewThrow(Expression* exception, int pos) {
3475  Throw* t = new (zone_) Throw(zone_, exception, pos, id_gen_);
3477  }
3478 
3479  FunctionLiteral* NewFunctionLiteral(
3480  const AstRawString* name, AstValueFactory* ast_value_factory,
3481  Scope* scope, ZoneList<Statement*>* body, int materialized_literal_count,
3482  int expected_property_count, int handler_count, int parameter_count,
3483  FunctionLiteral::ParameterFlag has_duplicate_parameters,
3484  FunctionLiteral::FunctionType function_type,
3485  FunctionLiteral::IsFunctionFlag is_function,
3486  FunctionLiteral::IsParenthesizedFlag is_parenthesized, FunctionKind kind,
3487  int position) {
3488  FunctionLiteral* lit = new (zone_) FunctionLiteral(
3489  zone_, name, ast_value_factory, scope, body, materialized_literal_count,
3490  expected_property_count, handler_count, parameter_count, function_type,
3491  has_duplicate_parameters, is_function, is_parenthesized, kind, position,
3492  id_gen_);
3493  // Top-level literal doesn't count for the AST's properties.
3494  if (is_function == FunctionLiteral::kIsFunction) {
3495  visitor_.VisitFunctionLiteral(lit);
3496  }
3497  return lit;
3498  }
3499 
3500  ClassLiteral* NewClassLiteral(const AstRawString* name, Expression* extends,
3501  Expression* constructor,
3503  int position) {
3504  ClassLiteral* lit = new (zone_) ClassLiteral(
3505  zone_, name, extends, constructor, properties, position, id_gen_);
3506  VISIT_AND_RETURN(ClassLiteral, lit)
3507  }
3508 
3509  NativeFunctionLiteral* NewNativeFunctionLiteral(const AstRawString* name,
3510  v8::Extension* extension,
3511  int pos) {
3512  NativeFunctionLiteral* lit =
3513  new (zone_) NativeFunctionLiteral(zone_, name, extension, pos, id_gen_);
3514  VISIT_AND_RETURN(NativeFunctionLiteral, lit)
3515  }
3516 
3517  ThisFunction* NewThisFunction(int pos) {
3518  ThisFunction* fun = new (zone_) ThisFunction(zone_, pos, id_gen_);
3519  VISIT_AND_RETURN(ThisFunction, fun)
3520  }
3521 
3522  SuperReference* NewSuperReference(VariableProxy* this_var, int pos) {
3523  SuperReference* super =
3524  new (zone_) SuperReference(zone_, this_var, pos, id_gen_);
3525  VISIT_AND_RETURN(SuperReference, super);
3526  }
3527 
3528 #undef VISIT_AND_RETURN
3529 
3530  private:
3532  Visitor visitor_;
3535 };
3536 
3537 
3538 } } // namespace v8::internal
3539 
3540 #endif // V8_AST_H_
#define BASE_EMBEDDED
Definition: allocation.h:45
#define DEF_FORWARD_DECLARATION(type)
Definition: ast.h:136
#define DECLARE_TYPE_ENUM(type)
Definition: ast.h:202
#define MAKE_CASE(Name)
Definition: ast.h:2588
#define AST_NODE_LIST(V)
Definition: ast.h:102
#define VISIT_AND_RETURN(NodeType, node)
Definition: ast.h:3074
#define STATEMENT_WITH_LABELS(NodeType)
Definition: ast.h:3153
#define DECLARE_NODE_TYPE(type)
Definition: ast.h:147
#define DEF_VISIT(type)
Definition: ast.h:3054
#define MAKE_ASTYPE(Name)
Definition: ast.h:2612
#define DECLARE_NODE_FUNCTIONS(type)
Definition: ast.h:221
Ignore.
Definition: v8.h:4008
The superclass of all JavaScript values and objects.
Definition: v8.h:1440
int ReserveIdRange(int n)
Definition: ast.h:192
virtual NodeType node_type() const =0
virtual TargetCollector * AsTargetCollector()
Definition: ast.h:232
static TypeFeedbackId reuse(BailoutId id)
Definition: ast.h:239
AstNode(int position)
Definition: ast.h:213
virtual MaterializedLiteral * AsMaterializedLiteral()
Definition: ast.h:235
virtual void Accept(AstVisitor *v)=0
friend class CaseClause
Definition: ast.h:249
int position() const
Definition: ast.h:218
virtual IterationStatement * AsIterationStatement()
Definition: ast.h:234
virtual BreakableStatement * AsBreakableStatement()
Definition: ast.h:233
virtual ~AstNode()
Definition: ast.h:214
Handle< String > string() const
NativeFunctionLiteral * NewNativeFunctionLiteral(const AstRawString *name, v8::Extension *extension, int pos)
Definition: ast.h:3509
ModuleUrl * NewModuleUrl(Handle< String > url, int pos)
Definition: ast.h:3139
BailoutReason dont_optimize_reason()
Definition: ast.h:3011
CountOperation * NewCountOperation(Token::Value op, bool is_prefix, Expression *expr, int pos)
Definition: ast.h:3427
Yield * NewYield(Expression *generator_object, Expression *expression, Yield::Kind yield_kind, int pos)
Definition: ast.h:3464
void set_dont_crankshaft_reason(BailoutReason reason)
Definition: ast.h:3030
virtual void VisitStatements(ZoneList< Statement * > *statements)
UnaryOperation * NewUnaryOperation(Token::Value op, Expression *expression, int pos)
Definition: ast.h:3410
CallNew * NewCallNew(Expression *expression, ZoneList< Expression * > *arguments, int pos)
Definition: ast.h:3393
AstProperties properties_
Definition: ast.h:3045
ModuleStatement * NewModuleStatement(VariableProxy *proxy, Block *body, int pos)
Definition: ast.h:3183
ArrayLiteral * NewArrayLiteral(ZoneList< Expression * > *values, int literal_index, int pos)
Definition: ast.h:3358
ZoneList< CharacterRange > * ranges_
Definition: ast.h:2704
ModuleDeclaration * NewModuleDeclaration(VariableProxy *proxy, Module *module, Scope *scope, int pos)
Definition: ast.h:3097
ModuleVariable * NewModuleVariable(VariableProxy *proxy, int pos)
Definition: ast.h:3129
virtual void VisitDeclarations(ZoneList< Declaration * > *declarations)
ObjectLiteral::Property * NewObjectLiteralProperty(bool is_getter, FunctionLiteral *value, int pos, bool is_static)
Definition: ast.h:3340
VariableProxy * NewVariableProxy(const AstRawString *name, bool is_this, Interface *interface=Interface::NewValue(), int position=RelocInfo::kNoPosition)
Definition: ast.h:3372
Literal * NewBooleanLiteral(bool b, int pos)
Definition: ast.h:3290
BailoutReason dont_turbofan_reason_
Definition: ast.h:3047
Literal * NewNullLiteral(int pos)
Definition: ast.h:3303
AstNode::IdGen * id_gen_
Definition: ast.h:3534
ZoneList< CharacterRange > * ranges(Zone *zone)
ContinueStatement * NewContinueStatement(IterationStatement *target, int pos)
Definition: ast.h:3195
TryCatchStatement * NewTryCatchStatement(int index, Block *try_block, Scope *scope, Variable *variable, Block *catch_block, int pos)
Definition: ast.h:3228
virtual ~RegExpVisitor()
Definition: ast.h:2587
ReturnStatement * NewReturnStatement(Expression *expression, int pos)
Definition: ast.h:3205
Conditional * NewConditional(Expression *condition, Expression *then_expression, Expression *else_expression, int position)
Definition: ast.h:3445
CharacterSet(uc16 standard_set_type)
Definition: ast.h:2690
Visitor * visitor()
Definition: ast.h:3072
VariableDeclaration * NewVariableDeclaration(VariableProxy *proxy, VariableMode mode, Scope *scope, int pos)
Definition: ast.h:3078
Literal * NewTheHoleLiteral(int pos)
Definition: ast.h:3315
Literal * NewNumberLiteral(double number, int pos)
Definition: ast.h:3278
AstValueFactory * ast_value_factory_
Definition: ast.h:3533
WithStatement * NewWithStatement(Scope *scope, Expression *expression, Statement *statement, int pos)
Definition: ast.h:3210
CompareOperation * NewCompareOperation(Token::Value op, Expression *left, Expression *right, int pos)
Definition: ast.h:3436
void add_flag(AstPropertiesFlag flag)
Definition: ast.h:3029
IfStatement * NewIfStatement(Expression *condition, Statement *then_statement, Statement *else_statement, int pos)
Definition: ast.h:3219
Literal * NewStringListLiteral(ZoneList< const AstRawString * > *strings, int pos)
Definition: ast.h:3296
ThisFunction * NewThisFunction(int pos)
Definition: ast.h:3517
Literal * NewSmiLiteral(int number, int pos)
Definition: ast.h:3284
VariableProxy * NewVariableProxy(Variable *var, int pos=RelocInfo::kNoPosition)
Definition: ast.h:3366
CaseClause * NewCaseClause(Expression *label, ZoneList< Statement * > *statements, int pos)
Definition: ast.h:3258
ExportDeclaration * NewExportDeclaration(VariableProxy *proxy, Scope *scope, int pos)
Definition: ast.h:3115
ModuleLiteral * NewModuleLiteral(Block *body, Interface *interface, int pos)
Definition: ast.h:3123
void set_standard_set_type(uc16 special_set_type)
Definition: ast.h:2698
Literal * NewUndefinedLiteral(int pos)
Definition: ast.h:3309
BailoutReason dont_crankshaft_reason_
Definition: ast.h:3046
Throw * NewThrow(Expression *exception, int pos)
Definition: ast.h:3474
ObjectLiteral * NewObjectLiteral(ZoneList< ObjectLiteral::Property * > *properties, int literal_index, int boilerplate_properties, bool has_function, int pos)
Definition: ast.h:3321
CharacterSet(ZoneList< CharacterRange > *ranges)
Definition: ast.h:2693
ImportDeclaration * NewImportDeclaration(VariableProxy *proxy, Module *module, Scope *scope, int pos)
Definition: ast.h:3106
RegExpLiteral * NewRegExpLiteral(const AstRawString *pattern, const AstRawString *flags, int literal_index, int pos)
Definition: ast.h:3349
ModulePath * NewModulePath(Module *origin, const AstRawString *name, int pos)
Definition: ast.h:3134
int feedback_slots() const
Definition: ast.h:172
Literal * NewStringLiteral(const AstRawString *string, int pos)
Definition: ast.h:3265
Assignment * NewAssignment(Token::Value op, Expression *target, Expression *value, int pos)
Definition: ast.h:3454
AstProperties * ast_properties()
Definition: ast.h:3010
AstNodeFactory(Zone *zone, AstValueFactory *ast_value_factory, AstNode::IdGen *id_gen)
Definition: ast.h:3068
EmptyStatement * NewEmptyStatement(int pos)
Definition: ast.h:3254
ClassLiteral * NewClassLiteral(const AstRawString *name, Expression *extends, Expression *constructor, ZoneList< ObjectLiteral::Property * > *properties, int position)
Definition: ast.h:3500
virtual void VisitExpressions(ZoneList< Expression * > *expressions)
Literal * NewSymbolLiteral(const char *name, int pos)
Definition: ast.h:3272
ExpressionStatement * NewExpressionStatement(Expression *expression, int pos)
Definition: ast.h:3189
BreakStatement * NewBreakStatement(BreakableStatement *target, int pos)
Definition: ast.h:3200
void increase_feedback_slots(int count)
Definition: ast.h:173
Block * NewBlock(ZoneList< const AstRawString * > *labels, int capacity, bool is_initializer_block, int pos)
Definition: ast.h:3144
virtual void Visit(AstNode *node)=0
ObjectLiteral::Property * NewObjectLiteralProperty(Literal *key, Expression *value, bool is_static)
Definition: ast.h:3333
ForEachStatement * NewForEachStatement(ForEachStatement::VisitMode visit_mode, ZoneList< const AstRawString * > *labels, int pos)
Definition: ast.h:3164
void set_dont_turbofan_reason(BailoutReason reason)
Definition: ast.h:3033
TryFinallyStatement * NewTryFinallyStatement(int index, Block *try_block, Block *finally_block, int pos)
Definition: ast.h:3239
Call * NewCall(Expression *expression, ZoneList< Expression * > *arguments, int pos)
Definition: ast.h:3386
FunctionDeclaration * NewFunctionDeclaration(VariableProxy *proxy, VariableMode mode, FunctionLiteral *fun, Scope *scope, int pos)
Definition: ast.h:3087
void add_slot_node(FeedbackSlotInterface *slot_node)
Definition: ast.h:3037
DebuggerStatement * NewDebuggerStatement(int pos)
Definition: ast.h:3248
CallRuntime * NewCallRuntime(const AstRawString *name, const Runtime::Function *function, ZoneList< Expression * > *arguments, int pos)
Definition: ast.h:3401
SuperReference * NewSuperReference(VariableProxy *this_var, int pos)
Definition: ast.h:3522
void add_node_count(int count)
Definition: ast.h:170
Property * NewProperty(Expression *obj, Expression *key, int pos)
Definition: ast.h:3381
FunctionLiteral * NewFunctionLiteral(const AstRawString *name, AstValueFactory *ast_value_factory, Scope *scope, ZoneList< Statement * > *body, int materialized_literal_count, int expected_property_count, int handler_count, int parameter_count, FunctionLiteral::ParameterFlag has_duplicate_parameters, FunctionLiteral::FunctionType function_type, FunctionLiteral::IsFunctionFlag is_function, FunctionLiteral::IsParenthesizedFlag is_parenthesized, FunctionKind kind, int position)
Definition: ast.h:3479
BinaryOperation * NewBinaryOperation(Token::Value op, Expression *left, Expression *right, int pos)
Definition: ast.h:3418
const BailoutId exit_id_
Definition: ast.h:445
BailoutId EntryId() const
Definition: ast.h:425
ZoneList< const AstRawString * > * labels_
Definition: ast.h:441
ZoneList< const AstRawString * > * labels() const
Definition: ast.h:410
BreakableStatement(Zone *zone, ZoneList< const AstRawString * > *labels, BreakableType breakable_type, int position, IdGen *id_gen)
Definition: ast.h:429
virtual BreakableStatement * AsBreakableStatement() FINAL OVERRIDE
Definition: ast.h:413
BailoutId ExitId() const
Definition: ast.h:426
BreakableType breakable_type_
Definition: ast.h:442
bool is_target_for_anonymous() const
Definition: ast.h:421
const BailoutId entry_id_
Definition: ast.h:444
Declaration(Zone *zone, VariableProxy *proxy, VariableMode mode, Scope *scope, int pos)
Definition: ast.h:496
VariableMode mode() const
Definition: ast.h:490
Scope * scope() const
Definition: ast.h:491
VariableProxy * proxy_
Definition: ast.h:509
VariableMode mode_
Definition: ast.h:510
virtual InitializationFlag initialization() const =0
VariableProxy * proxy() const
Definition: ast.h:489
virtual bool IsInlineable() const
Definition: ast.cc:547
bool IsUndefinedLiteral(Isolate *isolate) const
Definition: ast.cc:51
byte to_boolean_types() const
Definition: ast.h:377
virtual bool IsValidReferenceExpression() const
Definition: ast.h:325
bool is_parenthesized() const
Definition: ast.h:358
virtual void RecordToBooleanTypeFeedback(TypeFeedbackOracle *oracle)
Definition: ast.cc:562
void increase_parenthesization_level()
Definition: ast.h:359
Bounds bounds() const
Definition: ast.h:353
TypeFeedbackId test_id() const
Definition: ast.h:380
void set_to_boolean_types(byte types)
Definition: ast.h:389
BailoutId id() const
Definition: ast.h:379
unsigned parenthesization_level_
Definition: ast.h:394
virtual KeyedAccessStoreMode GetStoreMode()
Definition: ast.h:370
virtual bool ToBooleanIsFalse() const
Definition: ast.h:329
virtual bool ResultOverwriteAllowed() const
Definition: ast.h:338
const BailoutId id_
Definition: ast.h:396
void set_bounds(Bounds bounds)
Definition: ast.h:354
virtual bool IsMonomorphic()
Definition: ast.h:362
virtual bool IsPropertyName() const
Definition: ast.h:334
virtual SmallMapList * GetReceiverTypes()
Definition: ast.h:366
bool IsStringLiteral() const
Definition: ast.cc:41
const TypeFeedbackId test_id_
Definition: ast.h:397
unsigned parenthesization_level() const
Definition: ast.h:357
virtual bool ToBooleanIsTrue() const
Definition: ast.h:328
bool IsNullLiteral() const
Definition: ast.cc:46
bool IsSmiLiteral() const
Definition: ast.cc:36
Expression(Zone *zone, int pos, IdGen *id_gen)
Definition: ast.h:383
Source to read snapshot and builtins files from.
Definition: lithium-arm.h:372
Handle< SharedFunctionInfo > shared_info_
Definition: ast.h:2477
void set_function_token_position(int pos)
Definition: ast.h:2341
ZoneList< Statement * > * body_
Definition: ast.h:2479
int expected_property_count()
Definition: ast.h:2351
ArrayLiteral(Zone *zone, ZoneList< Expression * > *values, int literal_index, int pos, IdGen *id_gen)
Definition: ast.h:1619
Expression * tag() const
Definition: ast.h:1163
Handle< AllocationSite > allocation_site() const
Definition: ast.h:1871
bool is_positive()
Definition: ast.h:2892
const AstValue * raw_value() const
Definition: ast.h:1371
ClassLiteral(Zone *zone, const AstRawString *name, Expression *extends, Expression *constructor, ZoneList< Property * > *properties, int position, IdGen *id_gen)
Definition: ast.h:2515
ThisFunction(Zone *zone, int pos, IdGen *id_gen)
Definition: ast.h:2555
Handle< String > ToString()
Expression * value() const
Definition: ast.h:2169
void BindTo(Variable *var)
Handle< Map > GetReceiverType()
Definition: ast.h:1473
TypeFeedbackId CompareId()
Definition: ast.h:1136
void Clear()
Definition: ast.h:270
int parameter_count_
Definition: ast.h:2488
Variable * loop_variable_
Definition: ast.h:882
virtual int max_match() OVERRIDE
Definition: ast.h:2632
BailoutReason dont_optimize_reason_
Definition: ast.h:2483
static RegExpNode * ToNode(int min, int max, bool is_greedy, RegExpTree *body, RegExpCompiler *compiler, RegExpNode *on_success, bool not_at_start=false)
Block(Zone *zone, ZoneList< const AstRawString * > *labels, int capacity, bool is_initializer_block, int pos, IdGen *id_gen)
Definition: ast.h:471
int yield_first_feedback_slot_
Definition: ast.h:2287
Handle< JSFunction > target_
Definition: ast.h:1834
ImportDeclaration(Zone *zone, VariableProxy *proxy, Module *module, Scope *scope, int pos)
Definition: ast.h:599
int ForInFeedbackSlot()
Definition: ast.h:931
Expression * value_
Definition: ast.h:1489
bool has_duplicate_parameters()
Definition: ast.h:2400
Handle< AllocationSite > allocation_site()
Definition: ast.h:1790
bool is_expression() const
Definition: ast.h:2346
Expression * tag_
Definition: ast.h:1174
const BailoutId else_id_
Definition: ast.h:1221
Expression * left() const
Definition: ast.h:1991
RegExpCapture(RegExpTree *body, int index)
Definition: ast.h:2844
virtual bool ToBooleanIsFalse() const OVERRIDE
Definition: ast.h:1366
int PropertyFeedbackSlot() const
Definition: ast.h:1719
int call_feedback_slot_
Definition: ast.h:1837
RegExpQuantifier(int min, int max, QuantifierType type, RegExpTree *body)
Definition: ast.h:2798
bool is_possessive()
Definition: ast.h:2827
TypeFeedbackId LiteralFeedbackId() const
Definition: ast.h:1383
bool may_have_function_literal() const
Definition: ast.h:801
Expression * target_
Definition: ast.h:2210
TypeFeedbackId CallRuntimeFeedbackId() const
Definition: ast.h:1930
VariableDeclaration(Zone *zone, VariableProxy *proxy, VariableMode mode, Scope *scope, int pos)
Definition: ast.h:526
ObjectLiteralProperty(Zone *zone, bool is_getter, FunctionLiteral *value, bool is_static)
RegExpDisjunction(ZoneList< RegExpTree * > *alternatives)
Vector< const uc16 > data()
Definition: ast.h:2765
bool is_negated()
Definition: ast.h:2745
bool is_assigned() const
Definition: ast.h:1648
ContinueStatement(Zone *zone, IterationStatement *target, int pos)
Definition: ast.h:1059
Expression * condition() const
Definition: ast.h:1191
virtual RegExpCharacterClass * AsCharacterClass() OVERRIDE
Conditional(Zone *zone, Expression *condition, Expression *then_expression, Expression *else_expression, int position, IdGen *id_gen)
Definition: ast.h:2141
Expression * else_expression_
Definition: ast.h:2153
int length() const
The number of Latin-1 characters in the string.
Definition: ast.h:274
CaseClause(Zone *zone, Expression *label, ZoneList< Statement * > *statements, int pos, IdGen *id_gen)
bool is_this() const
Definition: ast.h:1645
ZoneList< CaseClause * > * cases() const
Definition: ast.h:1164
Expression * iterable() const
Definition: ast.h:979
bool is_initializer_block_
Definition: ast.h:481
bool is_generator()
Definition: ast.h:2422
void set_fixed_right_arg(Maybe< int > arg)
Definition: ast.h:2002
Expression * extends() const
Definition: ast.h:2510
ForOfStatement(Zone *zone, ZoneList< const AstRawString * > *labels, int pos, IdGen *id_gen)
Definition: ast.h:1009
uc16 standard_type()
Definition: ast.h:2743
bool is_fast_smi_loop()
Definition: ast.h:859
VariableProxy * proxy_
Definition: ast.h:668
void Sort()
Definition: ast.h:271
bool IsLiteralCompareUndefined(Expression **expr, Isolate *isolate)
v8::Extension * extension() const
Definition: ast.h:2537
static bool Match(void *literal1, void *literal2)
Definition: ast.h:1377
Handle< String > url_
Definition: ast.h:701
void set_may_have_function_literal(bool value)
Definition: ast.h:804
FunctionKind kind()
Definition: ast.h:2418
bool is_function()
Definition: ast.h:2404
AstProperties ast_properties_
Definition: ast.h:2482
void Reserve(int capacity, Zone *zone)
Definition: ast.h:269
int VariableFeedbackSlot()
Definition: ast.h:1659
Statement * else_statement_
Definition: ast.h:1218
const BailoutId prepare_id_
Definition: ast.h:957
virtual void RecordToBooleanTypeFeedback(TypeFeedbackOracle *oracle) OVERRIDE
CallRuntime(Zone *zone, const AstRawString *name, const Runtime::Function *function, ZoneList< Expression * > *arguments, int pos, IdGen *id_gen)
Definition: ast.h:1933
bool is_for_call_
Definition: ast.h:1739
const BailoutId body_id_
Definition: ast.h:826
const BailoutId debugger_id_
Definition: ast.h:1332
Variable * variable_
Definition: ast.h:1299
Literal * key()
Definition: ast.h:1466
bool may_have_function_literal_
Definition: ast.h:824
CallNew(Zone *zone, Expression *expression, ZoneList< Expression * > *arguments, int pos, IdGen *id_gen)
Definition: ast.h:1880
SmallPointerList< Map * > list_
Definition: ast.h:305
const AstRawString * AsRawPropertyName()
Definition: ast.h:1358
void AddElement(TextElement elm, Zone *zone)
Definition: ast.h:2784
Block * body() const
Definition: ast.h:710
int capture_count()
Definition: ast.h:2893
virtual TargetCollector * AsTargetCollector() OVERRIDE
Definition: ast.h:1240
BailoutId MaterializeFalseId()
Definition: ast.h:1957
ModuleStatement(Zone *zone, VariableProxy *proxy, Block *body, int pos)
Definition: ast.h:713
bool global_call() const
Definition: ast.h:1777
Type * compare_type_
Definition: ast.h:1147
Block * body_
Definition: ast.h:721
virtual RegExpCapture * AsCapture() OVERRIDE
bool AllowsLazyCompilationWithoutContext()
void set_inferred_name(Handle< String > inferred_name)
Definition: ast.h:2380
Module * module_
Definition: ast.h:585
CountOperation(Zone *zone, Token::Value op, bool is_prefix, Expression *expr, int pos, IdGen *id_gen)
Definition: ast.h:2067
Expression * condition_
Definition: ast.h:1216
ZoneList< RegExpTree * > * alternatives_
Definition: ast.h:2635
RegExpText(Zone *zone)
Definition: ast.h:2774
Statement * next() const
Definition: ast.h:846
Expression * then_expression() const
Definition: ast.h:2134
SmallMapList receiver_types_
Definition: ast.h:1738
Statement * then_statement_
Definition: ast.h:1217
ZoneList< Expression * > * arguments_
Definition: ast.h:1832
IterationStatement * target_
Definition: ast.h:1063
Handle< String > inferred_name_
Definition: ast.h:2481
BailoutId ElseId() const
Definition: ast.h:1202
Expression * assign_each() const
Definition: ast.h:999
bool is_non_greedy()
Definition: ast.h:2828
ZoneList< Expression * > * values() const
Definition: ast.h:1595
virtual InitializationFlag initialization() const OVERRIDE
Definition: ast.h:541
ZoneList< Statement * > * statements() const
Definition: ast.h:1131
virtual RegExpBackReference * AsBackReference() OVERRIDE
int expected_property_count_
Definition: ast.h:2486
const TypeFeedbackId count_id_
Definition: ast.h:2086
int KeyedLoadFeedbackSlot()
Definition: ast.h:2257
int CallRuntimeFeedbackSlot()
Definition: ast.h:1924
bool is_positive_
Definition: ast.h:2898
void set_ast_properties(AstProperties *ast_properties)
Definition: ast.h:2431
bool is_string_access_
Definition: ast.h:1741
TypeFeedbackId CountStoreFeedbackId() const
Definition: ast.h:2064
const BailoutId then_id_
Definition: ast.h:1220
BailoutId DeclsId() const
Definition: ast.h:460
Expression * key_
Definition: ast.h:1734
int capture_count_
Definition: ast.h:2899
bool is_postfix() const
Definition: ast.h:2039
TypeFeedbackId HomeObjectFeedbackId()
Definition: ast.h:2566
virtual RegExpAssertion * AsAssertion() OVERRIDE
RegExpCapture * capture()
Definition: ast.h:2916
BailoutId GetIdForElement(int i)
Definition: ast.h:1598
const BailoutId back_edge_id_
Definition: ast.h:787
bool is_jsruntime() const
Definition: ast.h:1914
TypeFeedbackId BinaryOperationFeedbackId() const
Definition: ast.h:2000
VariableProxy(Zone *zone, const AstRawString *name, bool is_this, Interface *interface, int position, IdGen *id_gen)
Variable * variable()
Definition: ast.h:1280
const AstRawString * flags_
Definition: ast.h:1584
virtual RegExpText * AsText() OVERRIDE
virtual bool IsInlineable() const OVERRIDE
virtual RegExpEmpty * AsEmpty() OVERRIDE
int callruntime_feedback_slot_
Definition: ast.h:1945
virtual void Accept(AstVisitor *v) OVERRIDE
Definition: ast.h:1238
static RegExpNode * ToNode(RegExpTree *body, int index, RegExpCompiler *compiler, RegExpNode *on_success)
Interface * interface_
Definition: ast.h:1671
int CallFeedbackSlot() const
Definition: ast.h:1761
int parameter_count()
Definition: ast.h:2353
bool HasCallFeedbackSlot() const
Definition: ast.h:1758
BinaryOperation(Zone *zone, Token::Value op, Expression *left, Expression *right, int pos, IdGen *id_gen)
Definition: ast.h:2008
WhileStatement(Zone *zone, ZoneList< const AstRawString * > *labels, int pos, IdGen *id_gen)
Definition: ast.h:813
BailoutId MaterializeTrueId()
Definition: ast.h:1956
Handle< AllocationSite > allocation_site_
Definition: ast.h:1836
ZoneList< Statement * > * statements()
Definition: ast.h:457
ZoneList< Property * > * properties_
Definition: ast.h:1556
Expression * result_done_
Definition: ast.h:1020
virtual NodeType node_type() const OVERRIDE
Definition: ast.h:1239
bool emit_store_
Definition: ast.h:1491
int AllocationSiteFeedbackSlot()
Definition: ast.h:1862
@ MATERIALIZED_LITERAL
Definition: ast.h:1458
int function_token_position() const
Definition: ast.h:2342
bool IsSuperAccess()
Definition: ast.h:1708
int materialized_literal_count_
Definition: ast.h:2485
bool has_function() const
Definition: ast.h:1511
Statement * next_
Definition: ast.h:878
Handle< Object > value() const
Definition: ast.h:1370
TryFinallyStatement(Zone *zone, int index, Block *try_block, Block *finally_block, int pos)
Definition: ast.h:1311
Handle< SharedFunctionInfo > shared_info()
Definition: ast.h:2395
const BailoutId materialize_false_id_
Definition: ast.h:1980
void set_is_string_access(bool b)
Definition: ast.h:1704
BailoutId RightId() const
Definition: ast.h:1998
BailoutId EntryId() const
Definition: ast.h:1133
Expression * constructor_
Definition: ast.h:2527
Scope * scope() const
Definition: ast.h:467
void Add(Handle< Map > handle, Zone *zone)
Definition: ast.h:292
Yield(Zone *zone, Expression *generator_object, Expression *expression, Kind yield_kind, int pos, IdGen *id_gen)
Definition: ast.h:2273
const TypeFeedbackId compare_id_
Definition: ast.h:1149
ForStatement(Zone *zone, ZoneList< const AstRawString * > *labels, int pos, IdGen *id_gen)
Definition: ast.h:864
Expression * cond() const
Definition: ast.h:769
RegExpBackReference(RegExpCapture *capture)
Definition: ast.h:2906
static int EndRegister(int index)
Definition: ast.h:2863
virtual void * Accept(RegExpVisitor *visitor, void *data) OVERRIDE
Handle< String > name_
Definition: ast.h:2476
Statement * init_
Definition: ast.h:876
bool is_arrow()
Definition: ast.h:2419
bool has_function_
Definition: ast.h:1560
virtual RegExpAlternative * AsAlternative() OVERRIDE
virtual RegExpNode * ToNode(RegExpCompiler *compiler, RegExpNode *on_success) OVERRIDE
Handle< Cell > cell_
Definition: ast.h:1835
Label body_target_
Definition: ast.h:1145
QuantifierType quantifier_type_
Definition: ast.h:2838
const BailoutId continue_id_
Definition: ast.h:786
Variable * var() const
Definition: ast.h:1644
TargetCollector(Zone *zone)
Definition: ast.h:1229
int property_feedback_slot_
Definition: ast.h:1736
Isolate * isolate_
Definition: ast.h:1396
CompareOperation(Zone *zone, Token::Value op, Expression *left, Expression *right, int pos, IdGen *id_gen)
Definition: ast.h:2110
bool IsUninitialized()
Definition: ast.h:1699
Handle< Map > last() const
Definition: ast.h:301
NativeFunctionLiteral(Zone *zone, const AstRawString *name, v8::Extension *extension, int pos, IdGen *id_gen)
Definition: ast.h:2540
ExportDeclaration(Zone *zone, VariableProxy *proxy, Scope *scope, int pos)
Definition: ast.h:622
void InitializeSharedInfo(Handle< Code > code)
bool is_monomorphic_
Definition: ast.h:1893
const BailoutId load_id_
Definition: ast.h:1735
virtual SmallMapList * GetReceiverTypes() OVERRIDE
Definition: ast.h:1693
BailoutReason dont_optimize_reason()
Definition: ast.h:2438
Expression * key() const
Definition: ast.h:1683
const BailoutId right_id_
Definition: ast.h:2030
void mark_for_call()
Definition: ast.h:1705
int CallNewFeedbackSlot()
Definition: ast.h:1858
const BailoutId if_id_
Definition: ast.h:1219
virtual bool ToBooleanIsTrue() const OVERRIDE
Definition: ast.h:1363
Throw(Zone *zone, Expression *exception, int pos, IdGen *id_gen)
Definition: ast.h:2298
BailoutId BackEdgeId() const
Definition: ast.h:773
v8::Extension * extension_
Definition: ast.h:2546
static bool IsBoilerplateProperty(Property *property)
const BailoutId assignment_id_
Definition: ast.h:2085
FunctionLiteral(Zone *zone, const AstRawString *name, AstValueFactory *ast_value_factory, Scope *scope, ZoneList< Statement * > *body, int materialized_literal_count, int expected_property_count, int handler_count, int parameter_count, FunctionType function_type, ParameterFlag has_duplicate_parameters, IsFunctionFlag is_function, IsParenthesizedFlag is_parenthesized, FunctionKind kind, int position, IdGen *id_gen)
Definition: ast.h:2444
RegExpTree * body()
Definition: ast.h:2830
Expression * assign_iterator() const
Definition: ast.h:984
virtual bool IsJump() const OVERRIDE
Definition: ast.h:462
Token::Value op() const
Definition: ast.h:2041
uint32_t Hash()
Definition: ast.h:1375
RegExpTree * body_
Definition: ast.h:2833
void set_type(Type *type)
Definition: ast.h:2059
ZoneList< Statement * > * body() const
Definition: ast.h:2340
int function_token_position_
Definition: ast.h:2489
Expression * next_result() const
Definition: ast.h:989
Expression * generator_object_
Definition: ast.h:2283
Vector< const uc16 > data_
Definition: ast.h:2768
Expression * cond_
Definition: ast.h:784
bool fast_elements_
Definition: ast.h:1558
virtual RegExpLookahead * AsLookahead() OVERRIDE
bool is_compound() const
Definition: ast.h:2173
int slot_count()
Definition: ast.h:2434
ObjectLiteralProperty(Zone *zone, AstValueFactory *ast_value_factory, Literal *key, Expression *value, bool is_static)
SmallMapList(int capacity, Zone *zone)
Definition: ast.h:267
Expression * then_expression_
Definition: ast.h:2152
RegExpCharacterClass(uc16 type)
Definition: ast.h:2716
RegExpAssertion(AssertionType type)
Definition: ast.h:2672
Expression * assign_iterator_
Definition: ast.h:1018
void Init(Zone *zone, AstNodeFactory< Visitor > *factory)
Definition: ast.h:2200
VariableProxy(Zone *zone, Variable *var, int position, IdGen *id_gen)
void set_allocation_site(Handle< AllocationSite > site)
Definition: ast.h:1793
Handle< String > name() const
Definition: ast.h:677
AssertionType assertion_type_
Definition: ast.h:2684
AstProperties::Flags * flags()
Definition: ast.h:2430
Expression * label_
Definition: ast.h:1144
void set_raw_inferred_name(const AstString *raw_inferred_name)
Definition: ast.h:2387
int start_position() const
void set_scope(Scope *scope)
Definition: ast.h:468
bool is_negated_
Definition: ast.h:2749
Handle< Cell > cell()
Definition: ast.h:1788
Expression * assign_each_
Definition: ast.h:1021
Label * body_target()
Definition: ast.h:1130
void set_parenthesized()
Definition: ast.h:2414
Statement * else_statement() const
Definition: ast.h:1193
ModuleUrl(Zone *zone, Handle< String > url, int pos)
Definition: ast.h:696
CharacterSet set_
Definition: ast.h:2748
RegExpLookahead(RegExpTree *body, bool is_positive, int capture_count, int capture_from)
Definition: ast.h:2873
@ ANONYMOUS_EXPRESSION
Definition: ast.h:2309
const AstRawString * raw_name() const
Definition: ast.h:1643
BreakableStatement * target_
Definition: ast.h:1078
TypeFeedbackId CountBinOpFeedbackId() const
Definition: ast.h:2063
bool dont_optimize()
Definition: ast.h:2437
Expression * obj_
Definition: ast.h:1733
const AstRawString * name_
Definition: ast.h:685
Expression * exception_
Definition: ast.h:2302
void set_key(Literal *key)
Definition: ast.h:1485
RegExpAtom(Vector< const uc16 > data)
Definition: ast.h:2755
Statement * statement_
Definition: ast.h:1117
ZoneList< CaseClause * > * cases_
Definition: ast.h:1175
bool is_uninitialized_
Definition: ast.h:1740
ModulePath(Zone *zone, Module *module, const AstRawString *name, int pos)
Definition: ast.h:680
AssertionType assertion_type()
Definition: ast.h:2682
Expression * extends_
Definition: ast.h:2526
ModuleVariable(Zone *zone, VariableProxy *proxy, int pos)
Expression * expression() const
Definition: ast.h:1031
ZoneList< Statement * > statements_
Definition: ast.h:480
Type * compare_type()
Definition: ast.h:1137
ModuleDeclaration(Zone *zone, VariableProxy *proxy, Module *module, Scope *scope, int pos)
Definition: ast.h:575
TypeFeedbackId PropertyFeedbackId()
Definition: ast.h:1712
Assignment(Zone *zone, Token::Value op, Expression *target, Expression *value, int pos, IdGen *id_gen)
void set_loop_variable(Variable *var)
Definition: ast.h:861
void set_compare_type(Type *type)
Definition: ast.h:1138
int DoneFeedbackSlot()
Definition: ast.h:2262
bool known_global_function() const
Definition: ast.h:1782
Type * type_
Definition: ast.h:2082
bool IsMonomorphic()
Definition: ast.h:1472
static int StartRegister(int index)
Definition: ast.h:2862
virtual bool IsMonomorphic() OVERRIDE
Definition: ast.h:1690
Interface * interface() const
Definition: ast.h:1646
virtual int min_match() OVERRIDE
Definition: ast.h:2725
SwitchStatement(Zone *zone, ZoneList< const AstRawString * > *labels, int pos, IdGen *id_gen)
Definition: ast.h:1167
int ValueFeedbackSlot()
Definition: ast.h:2267
Statement * statement() const
Definition: ast.h:1103
bool is_assigned_
Definition: ast.h:1670
void set_is_assigned()
Definition: ast.h:1649
Expression * left_
Definition: ast.h:2020
virtual KeyedAccessStoreMode GetStoreMode() OVERRIDE
Definition: ast.h:1696
BailoutId AssignmentId() const
Definition: ast.h:2061
CallType GetCallType(Isolate *isolate) const
BailoutId BodyId() const
Definition: ast.h:810
void set_pretenure()
Definition: ast.h:2398
Expression * obj() const
Definition: ast.h:1682
FunctionLiteral * fun_
Definition: ast.h:561
RegExpLiteral(Zone *zone, const AstRawString *pattern, const AstRawString *flags, int literal_index, int pos, IdGen *id_gen)
Definition: ast.h:1573
const BailoutId return_id_
Definition: ast.h:1839
virtual void AppendToText(RegExpText *text, Zone *zone) OVERRIDE
CharacterSet character_set()
Definition: ast.h:2728
bool may_store_doubles_
Definition: ast.h:1559
RegExpCapture * capture_
Definition: ast.h:2918
KeyedAccessStoreMode store_mode_
Definition: ast.h:2080
Block * catch_block_
Definition: ast.h:1300
RegExpCharacterClass(ZoneList< CharacterRange > *ranges, bool is_negated)
Definition: ast.h:2713
bool IsLiteralCompareNull(Expression **expr)
DISALLOW_COPY_AND_ASSIGN(SmallMapList)
ZoneList< Label * > targets_
Definition: ast.h:1245
Expression * label() const
Definition: ast.h:1126
ZoneList< Label * > * targets()
Definition: ast.h:1242
ForInType for_in_type_
Definition: ast.h:954
bool ComputeGlobalTarget(Handle< GlobalObject > global, LookupIterator *it)
ReturnStatement(Zone *zone, Expression *expression, int pos)
Definition: ast.h:1089
BailoutId LoadId() const
Definition: ast.h:1685
int ast_node_count()
Definition: ast.h:2429
int handler_count()
Definition: ast.h:2352
int handler_count_
Definition: ast.h:2487
void set_allocation_site(Handle< AllocationSite > allocation_site)
Definition: ast.h:1994
Handle< JSFunction > target() const
Definition: ast.h:1870
ZoneList< TextElement > elements_
Definition: ast.h:2790
Handle< String > inferred_name() const
Definition: ast.h:2367
Handle< String > debug_name() const
Definition: ast.h:2360
bool HasElseStatement() const
Definition: ast.h:1189
Expression * constructor() const
Definition: ast.h:2511
Expression * right_
Definition: ast.h:2021
int capture_from()
Definition: ast.h:2894
const BailoutId first_element_id_
Definition: ast.h:1628
bool is_empty() const
Definition: ast.h:273
bool is_concise_method()
Definition: ast.h:2425
virtual BailoutId StackCheckId() const OVERRIDE
Definition: ast.h:772
ZoneList< RegExpTree * > * nodes()
Definition: ast.h:2654
virtual RegExpAtom * AsAtom() OVERRIDE
BinaryOperation * binary_operation() const
Definition: ast.h:2170
static int feedback_slots()
Definition: ast.h:1875
void set_combined_type(Type *type)
Definition: ast.h:2102
void FilterForPossibleTransitions(Map *root_map)
Definition: ast.h:284
Call(Zone *zone, Expression *expression, ZoneList< Expression * > *arguments, int pos, IdGen *id_gen)
Definition: ast.h:1818
Maybe< int > fixed_right_arg() const
Definition: ast.h:2001
virtual RegExpQuantifier * AsQuantifier() OVERRIDE
bool HasNoTypeInformation()
Definition: ast.h:1700
DoWhileStatement(Zone *zone, ZoneList< const AstRawString * > *labels, int pos, IdGen *id_gen)
Definition: ast.h:776
void AddTarget(Label *target, Zone *zone)
WithStatement(Zone *zone, Scope *scope, Expression *expression, Statement *statement, int pos)
Definition: ast.h:1106
Statement * init() const
Definition: ast.h:844
Token::Value binary_op() const
ObjectLiteralProperty Property
Definition: ast.h:1501
const AstValue * value_
Definition: ast.h:1394
int materialized_literal_count()
Definition: ast.h:2350
bool is_anonymous() const
Definition: ast.h:2347
StrictMode strict_mode() const
Type * combined_type() const
Definition: ast.h:2101
const BailoutId decls_id_
Definition: ast.h:482
Expression * else_expression() const
Definition: ast.h:2135
bool is_greedy()
Definition: ast.h:2829
virtual RegExpDisjunction * AsDisjunction() OVERRIDE
void BuildConstantElements(Isolate *isolate)
bool is_standard(Zone *zone)
Kind yield_kind() const
Definition: ast.h:2235
IfStatement(Zone *zone, Expression *condition, Statement *then_statement, Statement *else_statement, int pos, IdGen *id_gen)
Definition: ast.h:1205
ZoneList< Statement * > * statements_
Definition: ast.h:1146
Type * type() const
Definition: ast.h:2057
BreakStatement(Zone *zone, BreakableStatement *target, int pos)
Definition: ast.h:1074
TypeFeedbackId AssignmentFeedbackId()
Definition: ast.h:2178
ZoneList< Expression * > * arguments() const
Definition: ast.h:1750
bool is_initializer_block() const
Definition: ast.h:458
bool may_store_doubles() const
Definition: ast.h:1510
ExpressionStatement(Zone *zone, Expression *expression, int pos)
Definition: ast.h:1035
int callnew_feedback_slot_
Definition: ast.h:1896
static RegExpEmpty * GetInstance()
Definition: ast.h:2932
Literal * key_
Definition: ast.h:1488
Literal(Zone *zone, const AstValue *value, int position, IdGen *id_gen)
Definition: ast.h:1386
Handle< String > AsPropertyName()
Definition: ast.h:1353
ForInType for_in_type() const
Definition: ast.h:937
const BailoutId materialize_true_id_
Definition: ast.h:1979
Handle< FixedArray > constant_elements_
Definition: ast.h:1626
VariableProxy * this_var_
Definition: ast.h:2574
BailoutId ThenId() const
Definition: ast.h:1201
void set_dont_optimize_reason(BailoutReason reason)
Definition: ast.h:2439
ZoneList< Expression * > * values_
Definition: ast.h:1627
Handle< FixedArray > constant_properties_
Definition: ast.h:1555
Maybe< int > fixed_right_arg_
Definition: ast.h:2026
ZoneList< CharacterRange > * ranges(Zone *zone)
Definition: ast.h:2744
virtual int ComputeFeedbackSlotCount()
Definition: ast.h:928
bool pretenure()
Definition: ast.h:2397
void set_emit_store(bool emit_store)
ZoneList< RegExpTree * > * alternatives()
Definition: ast.h:2633
TypeFeedbackId CompareOperationFeedbackId() const
Definition: ast.h:2100
ForInStatement(Zone *zone, ZoneList< const AstRawString * > *labels, int pos, IdGen *id_gen)
Definition: ast.h:946
int variable_feedback_slot_
Definition: ast.h:1672
void set_store_mode(KeyedAccessStoreMode mode)
Definition: ast.h:2058
SuperReference(Zone *zone, VariableProxy *this_var, int pos, IdGen *id_gen)
Definition: ast.h:2569
Handle< Map > first() const
Definition: ast.h:300
void RecordTypeFeedback(TypeFeedbackOracle *oracle)
ModuleLiteral(Zone *zone, Block *body, Interface *interface, int pos)
Definition: ast.h:653
Handle< Map > at(int i) const
Definition: ast.h:296
const BailoutId entry_id_
Definition: ast.h:1150
Expression * target() const
Definition: ast.h:2168
bool IsLiteralCompareTypeof(Expression **expr, Handle< String > *check)
bool IsArguments() const
Definition: ast.h:1640
DebuggerStatement(Zone *zone, int pos, IdGen *id_gen)
Definition: ast.h:1328
bool IsStringAccess() const
Definition: ast.h:1687
Handle< Map > receiver_type_
Definition: ast.h:1493
int ComputeFlags() const
Definition: ast.h:1525
ZoneList< Property * > * properties() const
Definition: ast.h:1508
Statement * then_statement() const
Definition: ast.h:1192
Variable * loop_variable()
Definition: ast.h:860
Scope * scope_
Definition: ast.h:483
BailoutId PrepareId() const
Definition: ast.h:941
Expression * right() const
Definition: ast.h:1992
BinaryOperation * binary_operation_
Definition: ast.h:2212
UnaryOperation(Zone *zone, Token::Value op, Expression *expression, int pos, IdGen *id_gen)
Definition: ast.h:1963
virtual void SetFirstFeedbackSlot(int slot)
Definition: ast.h:929
bool AllowsLazyCompilation()
Expression * next_result_
Definition: ast.h:1019
void AddMapIfMissing(Handle< Map > map, Zone *zone)
Definition: ast.h:276
int SourceSize() const
Definition: ast.h:2345
ZoneList< TextElement > * elements()
Definition: ast.h:2788
BailoutId IfId() const
Definition: ast.h:1200
const AstString * raw_inferred_name_
Definition: ast.h:2480
bool IsForCall()
Definition: ast.h:1706
Token::Value binary_op()
Definition: ast.h:2042
BailoutId ReturnId() const
Definition: ast.h:1798
Handle< String > flags() const
Definition: ast.h:1570
unsigned bitfield_
Definition: ast.h:2491
virtual BailoutId ContinueId() const OVERRIDE
Definition: ast.h:771
void BuildConstantProperties(Isolate *isolate)
int for_in_feedback_slot_
Definition: ast.h:955
int end_position() const
Variable * var_
Definition: ast.h:1668
ObjectLiteral(Zone *zone, ZoneList< Property * > *properties, int literal_index, int boilerplate_properties, bool has_function, int pos, IdGen *id_gen)
Definition: ast.h:1544
ZoneList< RegExpTree * > * nodes_
Definition: ast.h:2656
bool is_parenthesized()
Definition: ast.h:2411
void set_index(int index)
Definition: ast.h:2244
Block * finally_block_
Definition: ast.h:1317
Kind yield_kind_
Definition: ast.h:2285
TryCatchStatement(Zone *zone, int index, Block *try_block, Scope *scope, Variable *variable, Block *catch_block, int pos)
Definition: ast.h:1284
void CalculateEmitStore(Zone *zone)
const Runtime::Function * function_
Definition: ast.h:1943
int boilerplate_properties_
Definition: ast.h:1557
RegExpAlternative(ZoneList< RegExpTree * > *nodes)
Handle< JSFunction > target()
Definition: ast.h:1786
void set_target(Handle< JSFunction > target)
Definition: ast.h:1792
Expression * value()
Definition: ast.h:1467
bool IsUsingCallFeedbackSlot(Isolate *isolate) const
const AstRawString * raw_name_
Definition: ast.h:1942
int index() const
Definition: ast.h:2240
Property(Zone *zone, Expression *obj, Expression *key, int pos, IdGen *id_gen)
Definition: ast.h:1722
Expression * expression_
Definition: ast.h:1039
const AstRawString * pattern_
Definition: ast.h:1583
Expression * result_done() const
Definition: ast.h:994
Type * combined_type_
Definition: ast.h:2125
EmptyStatement(Zone *zone, int pos)
Definition: ast.h:1341
bool fast_elements() const
Definition: ast.h:1509
void set_is_uninitialized(bool b)
Definition: ast.h:1703
Expression * generator_object() const
Definition: ast.h:2233
Block * catch_block() const
Definition: ast.h:1281
void set_for_in_type(ForInType type)
Definition: ast.h:938
virtual void SetFirstFeedbackSlot(int slot)=0
void Initialize(Expression *each, Expression *subject, Statement *body)
Definition: ast.h:896
Expression * subject_
Definition: ast.h:914
Expression * each() const
Definition: ast.h:902
ForEachStatement(Zone *zone, ZoneList< const AstRawString * > *labels, int pos, IdGen *id_gen)
Definition: ast.h:906
Expression * subject() const
Definition: ast.h:903
static Handle< T > cast(Handle< S > that)
Definition: handles.h:116
bool is_null() const
Definition: handles.h:124
static Interface * NewValue()
Definition: interface.h:44
static Interval Empty()
Definition: jsregexp.h:715
virtual IterationStatement * AsIterationStatement() FINAL OVERRIDE
Definition: ast.h:728
IterationStatement(Zone *zone, ZoneList< const AstRawString * > *labels, int pos, IdGen *id_gen)
Definition: ast.h:742
void Initialize(Statement *body)
Definition: ast.h:748
BailoutId OsrEntryId() const
Definition: ast.h:734
virtual BailoutId ContinueId() const =0
const BailoutId osr_entry_id_
Definition: ast.h:756
Statement * body() const
Definition: ast.h:732
virtual BailoutId StackCheckId() const =0
virtual bool IsJump() const FINAL OVERRIDE
Definition: ast.h:1045
JumpStatement(Zone *zone, int pos)
Definition: ast.h:1048
static MaybeHandle< Map > TryUpdate(Handle< Map > map) WARN_UNUSED_RESULT
Definition: objects.cc:2691
void set_depth(int depth)
Definition: ast.h:1426
Handle< Object > GetBoilerplateValue(Expression *expression, Isolate *isolate)
Definition: ast.cc:384
virtual MaterializedLiteral * AsMaterializedLiteral()
Definition: ast.h:1403
void set_is_simple(bool is_simple)
Definition: ast.h:1423
void BuildConstants(Isolate *isolate)
Definition: ast.cc:396
MaterializedLiteral(Zone *zone, int literal_index, int pos, IdGen *id_gen)
Definition: ast.h:1414
Module(Zone *zone, int pos)
Definition: ast.h:633
Block * body() const
Definition: ast.h:630
Interface * interface() const
Definition: ast.h:629
Block * body_
Definition: ast.h:644
Interface * interface_
Definition: ast.h:643
Module(Zone *zone, Interface *interface, int pos, Block *body=NULL)
Definition: ast.h:637
OStream & Print(OStream &os, Zone *zone)
Definition: ast.cc:947
virtual void * Accept(RegExpVisitor *visitor, void *data)=0
virtual bool IsAnchoredAtStart()
Definition: ast.h:2603
virtual bool IsAnchoredAtEnd()
Definition: ast.h:2604
virtual int min_match()=0
virtual void AppendToText(RegExpText *text, Zone *zone)
Definition: jsregexp.cc:892
static const int kInfinity
Definition: ast.h:2597
virtual RegExpNode * ToNode(RegExpCompiler *compiler, RegExpNode *on_success)=0
virtual ~RegExpTree()
Definition: ast.h:2598
virtual Interval CaptureRegisters()
Definition: ast.h:2609
virtual int max_match()=0
virtual bool IsTextElement()
Definition: ast.h:2602
static const int kNoPosition
Definition: assembler.h:317
Statement(Zone *zone, int position)
Definition: ast.h:257
virtual bool IsJump() const
Definition: ast.h:260
bool Equals(String *other)
Definition: objects-inl.h:3336
static bool IsCompareOp(Value op)
Definition: token.h:202
static bool IsBinaryOp(Value op)
Definition: token.h:194
static bool IsUnaryOp(Value op)
Definition: token.h:261
static bool IsAssignmentOp(Value tok)
Definition: token.h:190
void set_escaping_targets(ZoneList< Label * > *targets)
Definition: ast.h:1251
int index() const
Definition: ast.h:1255
ZoneList< Label * > * escaping_targets_
Definition: ast.h:1271
ZoneList< Label * > * escaping_targets() const
Definition: ast.h:1257
TryStatement(Zone *zone, int index, Block *try_block, int pos)
Definition: ast.h:1260
Block * try_block() const
Definition: ast.h:1256
#define OVERRIDE
#define FINAL
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf map
enable harmony numeric enable harmony object literal extensions Optimize object size
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be expose gc extension under the specified name show built in functions in stack traces use random jit cookie to mask large constants minimum length for automatic enable preparsing CPU profiler sampling interval in microseconds trace out of bounds accesses to external arrays default size of stack region v8 is allowed to maximum length of function source code printed in a stack trace min size of a semi the new space consists of two semi spaces print one trace line following each garbage collection do not print trace line after scavenger collection print cumulative GC statistics in name
enable harmony numeric enable harmony object literal extensions true
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long mode(MIPS only)") DEFINE_BOOL(enable_always_align_csp
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be NULL
#define FOR_EACH_REG_EXP_TREE_TYPE(VISIT)
Definition: jsregexp.h:391
#define UNREACHABLE()
Definition: logging.h:30
#define CHECK(condition)
Definition: logging.h:36
#define DCHECK(condition)
Definition: logging.h:205
#define DCHECK_EQ(v1, v2)
Definition: logging.h:206
bool IsValidFunctionKind(FunctionKind kind)
Definition: globals.h:784
InitializationFlag
Definition: globals.h:751
@ kNeedsInitialization
Definition: globals.h:752
@ kCreatedInitialized
Definition: globals.h:753
bool IsArrowFunction(FunctionKind kind)
Definition: globals.h:793
kFeedbackVectorOffset kHiddenPrototypeBit kReadOnlyPrototypeBit kDoNotCacheBit kIsTopLevelBit kAllowLazyCompilationWithoutContext has_duplicate_parameters
Definition: objects-inl.h:5448
ZoneList< Handle< String > > ZoneStringList
Definition: ast.h:143
static int min(int a, int b)
Definition: liveedit.cc:273
bool IsDeclaredVariableMode(VariableMode mode)
Definition: globals.h:705
const SwVfpRegister s1
const SwVfpRegister s2
bool IsGeneratorFunction(FunctionKind kind)
Definition: globals.h:799
bool IsConciseMethod(FunctionKind kind)
Definition: globals.h:805
KeyedAccessStoreMode
Definition: objects.h:153
@ STANDARD_STORE
Definition: objects.h:154
const int kMaxInt
Definition: globals.h:109
Handle< T > handle(T *t, Isolate *isolate)
Definition: handles.h:146
ZoneList< Handle< Object > > ZoneObjectList
Definition: ast.h:144
AstPropertiesFlag
Definition: ast.h:155
@ kDontCache
Definition: ast.h:158
@ kDontSelfOptimize
Definition: ast.h:156
@ kDontSoftInline
Definition: ast.h:157
kFeedbackVectorOffset flag
Definition: objects-inl.h:5418
uint16_t uc16
Definition: globals.h:184
Debugger support for the V8 JavaScript engine.
Definition: accessors.cc:20
@ None
Definition: v8.h:2211
static Handle< Value > Throw(Isolate *isolate, const char *message)
Definition: d8.cc:72