Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(128)

Side by Side Diff: src/ast.h

Issue 7535004: Merge bleeding edge up to 8774 into the GC branch. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/gc/
Patch Set: Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/assembler.cc ('k') | src/ast.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 #define DECLARE_TYPE_ENUM(type) k##type, 127 #define DECLARE_TYPE_ENUM(type) k##type,
128 enum Type { 128 enum Type {
129 AST_NODE_LIST(DECLARE_TYPE_ENUM) 129 AST_NODE_LIST(DECLARE_TYPE_ENUM)
130 kInvalid = -1 130 kInvalid = -1
131 }; 131 };
132 #undef DECLARE_TYPE_ENUM 132 #undef DECLARE_TYPE_ENUM
133 133
134 static const int kNoNumber = -1; 134 static const int kNoNumber = -1;
135 static const int kFunctionEntryId = 2; // Using 0 could disguise errors. 135 static const int kFunctionEntryId = 2; // Using 0 could disguise errors.
136 136
137 AstNode() { 137 // Override ZoneObject's new to count allocated AST nodes.
138 Isolate* isolate = Isolate::Current(); 138 void* operator new(size_t size, Zone* zone) {
139 Isolate* isolate = zone->isolate();
139 isolate->set_ast_node_count(isolate->ast_node_count() + 1); 140 isolate->set_ast_node_count(isolate->ast_node_count() + 1);
141 return zone->New(static_cast<int>(size));
140 } 142 }
141 143
144 AstNode() {}
145
142 virtual ~AstNode() { } 146 virtual ~AstNode() { }
143 147
144 virtual void Accept(AstVisitor* v) = 0; 148 virtual void Accept(AstVisitor* v) = 0;
145 virtual Type node_type() const { return kInvalid; } 149 virtual Type node_type() const { return kInvalid; }
146 150
147 // Type testing & conversion functions overridden by concrete subclasses. 151 // Type testing & conversion functions overridden by concrete subclasses.
148 #define DECLARE_NODE_FUNCTIONS(type) \ 152 #define DECLARE_NODE_FUNCTIONS(type) \
149 virtual type* As##type() { return NULL; } 153 virtual type* As##type() { return NULL; }
150 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) 154 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS)
151 #undef DECLARE_NODE_FUNCTIONS 155 #undef DECLARE_NODE_FUNCTIONS
152 156
153 virtual Statement* AsStatement() { return NULL; } 157 virtual Statement* AsStatement() { return NULL; }
154 virtual Expression* AsExpression() { return NULL; } 158 virtual Expression* AsExpression() { return NULL; }
155 virtual TargetCollector* AsTargetCollector() { return NULL; } 159 virtual TargetCollector* AsTargetCollector() { return NULL; }
156 virtual BreakableStatement* AsBreakableStatement() { return NULL; } 160 virtual BreakableStatement* AsBreakableStatement() { return NULL; }
157 virtual IterationStatement* AsIterationStatement() { return NULL; } 161 virtual IterationStatement* AsIterationStatement() { return NULL; }
158 virtual MaterializedLiteral* AsMaterializedLiteral() { return NULL; } 162 virtual MaterializedLiteral* AsMaterializedLiteral() { return NULL; }
159 virtual Slot* AsSlot() { return NULL; } 163 virtual Slot* AsSlot() { return NULL; }
160 164
161 // True if the node is simple enough for us to inline calls containing it. 165 // True if the node is simple enough for us to inline calls containing it.
162 virtual bool IsInlineable() const = 0; 166 virtual bool IsInlineable() const = 0;
163 167
164 static int Count() { return Isolate::Current()->ast_node_count(); } 168 static int Count() { return Isolate::Current()->ast_node_count(); }
165 static void ResetIds() { Isolate::Current()->set_ast_node_id(0); } 169 static void ResetIds() { Isolate::Current()->set_ast_node_id(0); }
166 170
167 protected: 171 protected:
168 static unsigned GetNextId() { return ReserveIdRange(1); } 172 static unsigned GetNextId(Isolate* isolate) {
169 static unsigned ReserveIdRange(int n) { 173 return ReserveIdRange(isolate, 1);
170 Isolate* isolate = Isolate::Current(); 174 }
175
176 static unsigned ReserveIdRange(Isolate* isolate, int n) {
171 unsigned tmp = isolate->ast_node_id(); 177 unsigned tmp = isolate->ast_node_id();
172 isolate->set_ast_node_id(tmp + n); 178 isolate->set_ast_node_id(tmp + n);
173 return tmp; 179 return tmp;
174 } 180 }
175 181
182 private:
183 // Hidden to prevent accidental usage. It would have to load the
184 // current zone from the TLS.
185 void* operator new(size_t size);
186
176 friend class CaseClause; // Generates AST IDs. 187 friend class CaseClause; // Generates AST IDs.
177 }; 188 };
178 189
179 190
180 class Statement: public AstNode { 191 class Statement: public AstNode {
181 public: 192 public:
182 Statement() : statement_pos_(RelocInfo::kNoPosition) {} 193 Statement() : statement_pos_(RelocInfo::kNoPosition) {}
183 194
184 virtual Statement* AsStatement() { return this; } 195 virtual Statement* AsStatement() { return this; }
185 196
(...skipping 17 matching lines...) Expand all
203 // code generation. 214 // code generation.
204 kUninitialized, 215 kUninitialized,
205 // Evaluated for its side effects. 216 // Evaluated for its side effects.
206 kEffect, 217 kEffect,
207 // Evaluated for its value (and side effects). 218 // Evaluated for its value (and side effects).
208 kValue, 219 kValue,
209 // Evaluated for control flow (and side effects). 220 // Evaluated for control flow (and side effects).
210 kTest 221 kTest
211 }; 222 };
212 223
213 Expression() : id_(GetNextId()), test_id_(GetNextId()) {} 224 explicit Expression(Isolate* isolate)
225 : id_(GetNextId(isolate)),
226 test_id_(GetNextId(isolate)) {}
214 227
215 virtual int position() const { 228 virtual int position() const {
216 UNREACHABLE(); 229 UNREACHABLE();
217 return 0; 230 return 0;
218 } 231 }
219 232
220 virtual Expression* AsExpression() { return this; } 233 virtual Expression* AsExpression() { return this; }
221 234
222 virtual bool IsTrivial() { return false; } 235 virtual bool IsTrivial() { return false; }
223 virtual bool IsValidLeftHandSide() { return false; } 236 virtual bool IsValidLeftHandSide() { return false; }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 }; 283 };
271 284
272 285
273 /** 286 /**
274 * A sentinel used during pre parsing that represents some expression 287 * A sentinel used during pre parsing that represents some expression
275 * that is a valid left hand side without having to actually build 288 * that is a valid left hand side without having to actually build
276 * the expression. 289 * the expression.
277 */ 290 */
278 class ValidLeftHandSideSentinel: public Expression { 291 class ValidLeftHandSideSentinel: public Expression {
279 public: 292 public:
293 explicit ValidLeftHandSideSentinel(Isolate* isolate) : Expression(isolate) {}
280 virtual bool IsValidLeftHandSide() { return true; } 294 virtual bool IsValidLeftHandSide() { return true; }
281 virtual void Accept(AstVisitor* v) { UNREACHABLE(); } 295 virtual void Accept(AstVisitor* v) { UNREACHABLE(); }
282 virtual bool IsInlineable() const; 296 virtual bool IsInlineable() const;
283 }; 297 };
284 298
285 299
286 class BreakableStatement: public Statement { 300 class BreakableStatement: public Statement {
287 public: 301 public:
288 enum Type { 302 enum Type {
289 TARGET_FOR_ANONYMOUS, 303 TARGET_FOR_ANONYMOUS,
(...skipping 11 matching lines...) Expand all
301 Label* break_target() { return &break_target_; } 315 Label* break_target() { return &break_target_; }
302 316
303 // Testers. 317 // Testers.
304 bool is_target_for_anonymous() const { return type_ == TARGET_FOR_ANONYMOUS; } 318 bool is_target_for_anonymous() const { return type_ == TARGET_FOR_ANONYMOUS; }
305 319
306 // Bailout support. 320 // Bailout support.
307 int EntryId() const { return entry_id_; } 321 int EntryId() const { return entry_id_; }
308 int ExitId() const { return exit_id_; } 322 int ExitId() const { return exit_id_; }
309 323
310 protected: 324 protected:
311 inline BreakableStatement(ZoneStringList* labels, Type type); 325 BreakableStatement(Isolate* isolate, ZoneStringList* labels, Type type);
312 326
313 private: 327 private:
314 ZoneStringList* labels_; 328 ZoneStringList* labels_;
315 Type type_; 329 Type type_;
316 Label break_target_; 330 Label break_target_;
317 int entry_id_; 331 int entry_id_;
318 int exit_id_; 332 int exit_id_;
319 }; 333 };
320 334
321 335
322 class Block: public BreakableStatement { 336 class Block: public BreakableStatement {
323 public: 337 public:
324 inline Block(ZoneStringList* labels, int capacity, bool is_initializer_block); 338 inline Block(Isolate* isolate,
339 ZoneStringList* labels,
340 int capacity,
341 bool is_initializer_block);
325 342
326 DECLARE_NODE_TYPE(Block) 343 DECLARE_NODE_TYPE(Block)
327 344
328 virtual Assignment* StatementAsSimpleAssignment() { 345 virtual Assignment* StatementAsSimpleAssignment() {
329 if (statements_.length() != 1) return NULL; 346 if (statements_.length() != 1) return NULL;
330 return statements_[0]->StatementAsSimpleAssignment(); 347 return statements_[0]->StatementAsSimpleAssignment();
331 } 348 }
332 349
333 virtual CountOperation* StatementAsCountOperation() { 350 virtual CountOperation* StatementAsCountOperation() {
334 if (statements_.length() != 1) return NULL; 351 if (statements_.length() != 1) return NULL;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 399
383 // Bailout support. 400 // Bailout support.
384 int OsrEntryId() const { return osr_entry_id_; } 401 int OsrEntryId() const { return osr_entry_id_; }
385 virtual int ContinueId() const = 0; 402 virtual int ContinueId() const = 0;
386 virtual int StackCheckId() const = 0; 403 virtual int StackCheckId() const = 0;
387 404
388 // Code generation 405 // Code generation
389 Label* continue_target() { return &continue_target_; } 406 Label* continue_target() { return &continue_target_; }
390 407
391 protected: 408 protected:
392 explicit inline IterationStatement(ZoneStringList* labels); 409 inline IterationStatement(Isolate* isolate, ZoneStringList* labels);
393 410
394 void Initialize(Statement* body) { 411 void Initialize(Statement* body) {
395 body_ = body; 412 body_ = body;
396 } 413 }
397 414
398 private: 415 private:
399 Statement* body_; 416 Statement* body_;
400 Label continue_target_; 417 Label continue_target_;
401 int osr_entry_id_; 418 int osr_entry_id_;
402 }; 419 };
403 420
404 421
405 class DoWhileStatement: public IterationStatement { 422 class DoWhileStatement: public IterationStatement {
406 public: 423 public:
407 explicit inline DoWhileStatement(ZoneStringList* labels); 424 inline DoWhileStatement(Isolate* isolate, ZoneStringList* labels);
408 425
409 DECLARE_NODE_TYPE(DoWhileStatement) 426 DECLARE_NODE_TYPE(DoWhileStatement)
410 427
411 void Initialize(Expression* cond, Statement* body) { 428 void Initialize(Expression* cond, Statement* body) {
412 IterationStatement::Initialize(body); 429 IterationStatement::Initialize(body);
413 cond_ = cond; 430 cond_ = cond;
414 } 431 }
415 432
416 Expression* cond() const { return cond_; } 433 Expression* cond() const { return cond_; }
417 434
(...skipping 12 matching lines...) Expand all
430 private: 447 private:
431 Expression* cond_; 448 Expression* cond_;
432 int condition_position_; 449 int condition_position_;
433 int continue_id_; 450 int continue_id_;
434 int back_edge_id_; 451 int back_edge_id_;
435 }; 452 };
436 453
437 454
438 class WhileStatement: public IterationStatement { 455 class WhileStatement: public IterationStatement {
439 public: 456 public:
440 explicit inline WhileStatement(ZoneStringList* labels); 457 inline WhileStatement(Isolate* isolate, ZoneStringList* labels);
441 458
442 DECLARE_NODE_TYPE(WhileStatement) 459 DECLARE_NODE_TYPE(WhileStatement)
443 460
444 void Initialize(Expression* cond, Statement* body) { 461 void Initialize(Expression* cond, Statement* body) {
445 IterationStatement::Initialize(body); 462 IterationStatement::Initialize(body);
446 cond_ = cond; 463 cond_ = cond;
447 } 464 }
448 465
449 Expression* cond() const { return cond_; } 466 Expression* cond() const { return cond_; }
450 bool may_have_function_literal() const { 467 bool may_have_function_literal() const {
(...skipping 12 matching lines...) Expand all
463 private: 480 private:
464 Expression* cond_; 481 Expression* cond_;
465 // True if there is a function literal subexpression in the condition. 482 // True if there is a function literal subexpression in the condition.
466 bool may_have_function_literal_; 483 bool may_have_function_literal_;
467 int body_id_; 484 int body_id_;
468 }; 485 };
469 486
470 487
471 class ForStatement: public IterationStatement { 488 class ForStatement: public IterationStatement {
472 public: 489 public:
473 explicit inline ForStatement(ZoneStringList* labels); 490 inline ForStatement(Isolate* isolate, ZoneStringList* labels);
474 491
475 DECLARE_NODE_TYPE(ForStatement) 492 DECLARE_NODE_TYPE(ForStatement)
476 493
477 void Initialize(Statement* init, 494 void Initialize(Statement* init,
478 Expression* cond, 495 Expression* cond,
479 Statement* next, 496 Statement* next,
480 Statement* body) { 497 Statement* body) {
481 IterationStatement::Initialize(body); 498 IterationStatement::Initialize(body);
482 init_ = init; 499 init_ = init;
483 cond_ = cond; 500 cond_ = cond;
(...skipping 28 matching lines...) Expand all
512 // True if there is a function literal subexpression in the condition. 529 // True if there is a function literal subexpression in the condition.
513 bool may_have_function_literal_; 530 bool may_have_function_literal_;
514 Variable* loop_variable_; 531 Variable* loop_variable_;
515 int continue_id_; 532 int continue_id_;
516 int body_id_; 533 int body_id_;
517 }; 534 };
518 535
519 536
520 class ForInStatement: public IterationStatement { 537 class ForInStatement: public IterationStatement {
521 public: 538 public:
522 explicit inline ForInStatement(ZoneStringList* labels); 539 inline ForInStatement(Isolate* isolate, ZoneStringList* labels);
523 540
524 DECLARE_NODE_TYPE(ForInStatement) 541 DECLARE_NODE_TYPE(ForInStatement)
525 542
526 void Initialize(Expression* each, Expression* enumerable, Statement* body) { 543 void Initialize(Expression* each, Expression* enumerable, Statement* body) {
527 IterationStatement::Initialize(body); 544 IterationStatement::Initialize(body);
528 each_ = each; 545 each_ = each;
529 enumerable_ = enumerable; 546 enumerable_ = enumerable;
530 } 547 }
531 548
532 Expression* each() const { return each_; } 549 Expression* each() const { return each_; }
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 class ExitContextStatement: public Statement { 646 class ExitContextStatement: public Statement {
630 public: 647 public:
631 virtual bool IsInlineable() const; 648 virtual bool IsInlineable() const;
632 649
633 DECLARE_NODE_TYPE(ExitContextStatement) 650 DECLARE_NODE_TYPE(ExitContextStatement)
634 }; 651 };
635 652
636 653
637 class CaseClause: public ZoneObject { 654 class CaseClause: public ZoneObject {
638 public: 655 public:
639 CaseClause(Expression* label, ZoneList<Statement*>* statements, int pos); 656 CaseClause(Isolate* isolate,
657 Expression* label,
658 ZoneList<Statement*>* statements,
659 int pos);
640 660
641 bool is_default() const { return label_ == NULL; } 661 bool is_default() const { return label_ == NULL; }
642 Expression* label() const { 662 Expression* label() const {
643 CHECK(!is_default()); 663 CHECK(!is_default());
644 return label_; 664 return label_;
645 } 665 }
646 Label* body_target() { return &body_target_; } 666 Label* body_target() { return &body_target_; }
647 ZoneList<Statement*>* statements() const { return statements_; } 667 ZoneList<Statement*>* statements() const { return statements_; }
648 668
649 int position() const { return position_; } 669 int position() const { return position_; }
(...skipping 14 matching lines...) Expand all
664 int position_; 684 int position_;
665 enum CompareTypeFeedback { NONE, SMI_ONLY, OBJECT_ONLY }; 685 enum CompareTypeFeedback { NONE, SMI_ONLY, OBJECT_ONLY };
666 CompareTypeFeedback compare_type_; 686 CompareTypeFeedback compare_type_;
667 int compare_id_; 687 int compare_id_;
668 int entry_id_; 688 int entry_id_;
669 }; 689 };
670 690
671 691
672 class SwitchStatement: public BreakableStatement { 692 class SwitchStatement: public BreakableStatement {
673 public: 693 public:
674 explicit inline SwitchStatement(ZoneStringList* labels); 694 inline SwitchStatement(Isolate* isolate, ZoneStringList* labels);
675 695
676 DECLARE_NODE_TYPE(SwitchStatement) 696 DECLARE_NODE_TYPE(SwitchStatement)
677 697
678 void Initialize(Expression* tag, ZoneList<CaseClause*>* cases) { 698 void Initialize(Expression* tag, ZoneList<CaseClause*>* cases) {
679 tag_ = tag; 699 tag_ = tag;
680 cases_ = cases; 700 cases_ = cases;
681 } 701 }
682 702
683 Expression* tag() const { return tag_; } 703 Expression* tag() const { return tag_; }
684 ZoneList<CaseClause*>* cases() const { return cases_; } 704 ZoneList<CaseClause*>* cases() const { return cases_; }
685 virtual bool IsInlineable() const; 705 virtual bool IsInlineable() const;
686 706
687 private: 707 private:
688 Expression* tag_; 708 Expression* tag_;
689 ZoneList<CaseClause*>* cases_; 709 ZoneList<CaseClause*>* cases_;
690 }; 710 };
691 711
692 712
693 // If-statements always have non-null references to their then- and 713 // If-statements always have non-null references to their then- and
694 // else-parts. When parsing if-statements with no explicit else-part, 714 // else-parts. When parsing if-statements with no explicit else-part,
695 // the parser implicitly creates an empty statement. Use the 715 // the parser implicitly creates an empty statement. Use the
696 // HasThenStatement() and HasElseStatement() functions to check if a 716 // HasThenStatement() and HasElseStatement() functions to check if a
697 // given if-statement has a then- or an else-part containing code. 717 // given if-statement has a then- or an else-part containing code.
698 class IfStatement: public Statement { 718 class IfStatement: public Statement {
699 public: 719 public:
700 IfStatement(Expression* condition, 720 IfStatement(Isolate* isolate,
721 Expression* condition,
701 Statement* then_statement, 722 Statement* then_statement,
702 Statement* else_statement) 723 Statement* else_statement)
703 : condition_(condition), 724 : condition_(condition),
704 then_statement_(then_statement), 725 then_statement_(then_statement),
705 else_statement_(else_statement), 726 else_statement_(else_statement),
706 if_id_(GetNextId()), 727 if_id_(GetNextId(isolate)),
707 then_id_(GetNextId()), 728 then_id_(GetNextId(isolate)),
708 else_id_(GetNextId()) { 729 else_id_(GetNextId(isolate)) {
709 } 730 }
710 731
711 DECLARE_NODE_TYPE(IfStatement) 732 DECLARE_NODE_TYPE(IfStatement)
712 733
713 virtual bool IsInlineable() const; 734 virtual bool IsInlineable() const;
714 735
715 bool HasThenStatement() const { return !then_statement()->IsEmpty(); } 736 bool HasThenStatement() const { return !then_statement()->IsEmpty(); }
716 bool HasElseStatement() const { return !else_statement()->IsEmpty(); } 737 bool HasElseStatement() const { return !else_statement()->IsEmpty(); }
717 738
718 Expression* condition() const { return condition_; } 739 Expression* condition() const { return condition_; }
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
827 class EmptyStatement: public Statement { 848 class EmptyStatement: public Statement {
828 public: 849 public:
829 DECLARE_NODE_TYPE(EmptyStatement) 850 DECLARE_NODE_TYPE(EmptyStatement)
830 851
831 virtual bool IsInlineable() const; 852 virtual bool IsInlineable() const;
832 }; 853 };
833 854
834 855
835 class Literal: public Expression { 856 class Literal: public Expression {
836 public: 857 public:
837 explicit Literal(Handle<Object> handle) : handle_(handle) { } 858 Literal(Isolate* isolate, Handle<Object> handle)
859 : Expression(isolate), handle_(handle) { }
838 860
839 DECLARE_NODE_TYPE(Literal) 861 DECLARE_NODE_TYPE(Literal)
840 862
841 virtual bool IsTrivial() { return true; } 863 virtual bool IsTrivial() { return true; }
842 virtual bool IsSmiLiteral() { return handle_->IsSmi(); } 864 virtual bool IsSmiLiteral() { return handle_->IsSmi(); }
843 865
844 // Check if this literal is identical to the other literal. 866 // Check if this literal is identical to the other literal.
845 bool IsIdenticalTo(const Literal* other) const { 867 bool IsIdenticalTo(const Literal* other) const {
846 return handle_.is_identical_to(other->handle_); 868 return handle_.is_identical_to(other->handle_);
847 } 869 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
880 virtual bool IsInlineable() const; 902 virtual bool IsInlineable() const;
881 903
882 private: 904 private:
883 Handle<Object> handle_; 905 Handle<Object> handle_;
884 }; 906 };
885 907
886 908
887 // Base class for literals that needs space in the corresponding JSFunction. 909 // Base class for literals that needs space in the corresponding JSFunction.
888 class MaterializedLiteral: public Expression { 910 class MaterializedLiteral: public Expression {
889 public: 911 public:
890 explicit MaterializedLiteral(int literal_index, bool is_simple, int depth) 912 MaterializedLiteral(Isolate* isolate,
891 : literal_index_(literal_index), is_simple_(is_simple), depth_(depth) {} 913 int literal_index,
914 bool is_simple,
915 int depth)
916 : Expression(isolate),
917 literal_index_(literal_index),
918 is_simple_(is_simple),
919 depth_(depth) {}
892 920
893 virtual MaterializedLiteral* AsMaterializedLiteral() { return this; } 921 virtual MaterializedLiteral* AsMaterializedLiteral() { return this; }
894 922
895 int literal_index() { return literal_index_; } 923 int literal_index() { return literal_index_; }
896 924
897 // A materialized literal is simple if the values consist of only 925 // A materialized literal is simple if the values consist of only
898 // constants and simple object and array literals. 926 // constants and simple object and array literals.
899 bool is_simple() const { return is_simple_; } 927 bool is_simple() const { return is_simple_; }
900 928
901 int depth() const { return depth_; } 929 int depth() const { return depth_; }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
937 void set_emit_store(bool emit_store); 965 void set_emit_store(bool emit_store);
938 bool emit_store(); 966 bool emit_store();
939 967
940 private: 968 private:
941 Literal* key_; 969 Literal* key_;
942 Expression* value_; 970 Expression* value_;
943 Kind kind_; 971 Kind kind_;
944 bool emit_store_; 972 bool emit_store_;
945 }; 973 };
946 974
947 ObjectLiteral(Handle<FixedArray> constant_properties, 975 ObjectLiteral(Isolate* isolate,
976 Handle<FixedArray> constant_properties,
948 ZoneList<Property*>* properties, 977 ZoneList<Property*>* properties,
949 int literal_index, 978 int literal_index,
950 bool is_simple, 979 bool is_simple,
951 bool fast_elements, 980 bool fast_elements,
952 int depth, 981 int depth,
953 bool has_function) 982 bool has_function)
954 : MaterializedLiteral(literal_index, is_simple, depth), 983 : MaterializedLiteral(isolate, literal_index, is_simple, depth),
955 constant_properties_(constant_properties), 984 constant_properties_(constant_properties),
956 properties_(properties), 985 properties_(properties),
957 fast_elements_(fast_elements), 986 fast_elements_(fast_elements),
958 has_function_(has_function) {} 987 has_function_(has_function) {}
959 988
960 DECLARE_NODE_TYPE(ObjectLiteral) 989 DECLARE_NODE_TYPE(ObjectLiteral)
961 990
962 Handle<FixedArray> constant_properties() const { 991 Handle<FixedArray> constant_properties() const {
963 return constant_properties_; 992 return constant_properties_;
964 } 993 }
(...skipping 18 matching lines...) Expand all
983 Handle<FixedArray> constant_properties_; 1012 Handle<FixedArray> constant_properties_;
984 ZoneList<Property*>* properties_; 1013 ZoneList<Property*>* properties_;
985 bool fast_elements_; 1014 bool fast_elements_;
986 bool has_function_; 1015 bool has_function_;
987 }; 1016 };
988 1017
989 1018
990 // Node for capturing a regexp literal. 1019 // Node for capturing a regexp literal.
991 class RegExpLiteral: public MaterializedLiteral { 1020 class RegExpLiteral: public MaterializedLiteral {
992 public: 1021 public:
993 RegExpLiteral(Handle<String> pattern, 1022 RegExpLiteral(Isolate* isolate,
1023 Handle<String> pattern,
994 Handle<String> flags, 1024 Handle<String> flags,
995 int literal_index) 1025 int literal_index)
996 : MaterializedLiteral(literal_index, false, 1), 1026 : MaterializedLiteral(isolate, literal_index, false, 1),
997 pattern_(pattern), 1027 pattern_(pattern),
998 flags_(flags) {} 1028 flags_(flags) {}
999 1029
1000 DECLARE_NODE_TYPE(RegExpLiteral) 1030 DECLARE_NODE_TYPE(RegExpLiteral)
1001 1031
1002 Handle<String> pattern() const { return pattern_; } 1032 Handle<String> pattern() const { return pattern_; }
1003 Handle<String> flags() const { return flags_; } 1033 Handle<String> flags() const { return flags_; }
1004 1034
1005 private: 1035 private:
1006 Handle<String> pattern_; 1036 Handle<String> pattern_;
1007 Handle<String> flags_; 1037 Handle<String> flags_;
1008 }; 1038 };
1009 1039
1010 // An array literal has a literals object that is used 1040 // An array literal has a literals object that is used
1011 // for minimizing the work when constructing it at runtime. 1041 // for minimizing the work when constructing it at runtime.
1012 class ArrayLiteral: public MaterializedLiteral { 1042 class ArrayLiteral: public MaterializedLiteral {
1013 public: 1043 public:
1014 ArrayLiteral(Handle<FixedArray> constant_elements, 1044 ArrayLiteral(Isolate* isolate,
1045 Handle<FixedArray> constant_elements,
1015 ZoneList<Expression*>* values, 1046 ZoneList<Expression*>* values,
1016 int literal_index, 1047 int literal_index,
1017 bool is_simple, 1048 bool is_simple,
1018 int depth) 1049 int depth)
1019 : MaterializedLiteral(literal_index, is_simple, depth), 1050 : MaterializedLiteral(isolate, literal_index, is_simple, depth),
1020 constant_elements_(constant_elements), 1051 constant_elements_(constant_elements),
1021 values_(values), 1052 values_(values),
1022 first_element_id_(ReserveIdRange(values->length())) {} 1053 first_element_id_(ReserveIdRange(isolate, values->length())) {}
1023 1054
1024 DECLARE_NODE_TYPE(ArrayLiteral) 1055 DECLARE_NODE_TYPE(ArrayLiteral)
1025 1056
1026 Handle<FixedArray> constant_elements() const { return constant_elements_; } 1057 Handle<FixedArray> constant_elements() const { return constant_elements_; }
1027 ZoneList<Expression*>* values() const { return values_; } 1058 ZoneList<Expression*>* values() const { return values_; }
1028 1059
1029 // Return an AST id for an element that is used in simulate instructions. 1060 // Return an AST id for an element that is used in simulate instructions.
1030 int GetIdForElement(int i) { return first_element_id_ + i; } 1061 int GetIdForElement(int i) { return first_element_id_ + i; }
1031 1062
1032 private: 1063 private:
1033 Handle<FixedArray> constant_elements_; 1064 Handle<FixedArray> constant_elements_;
1034 ZoneList<Expression*>* values_; 1065 ZoneList<Expression*>* values_;
1035 int first_element_id_; 1066 int first_element_id_;
1036 }; 1067 };
1037 1068
1038 1069
1039 class VariableProxy: public Expression { 1070 class VariableProxy: public Expression {
1040 public: 1071 public:
1041 explicit VariableProxy(Variable* var); 1072 VariableProxy(Isolate* isolate, Variable* var);
1042 1073
1043 DECLARE_NODE_TYPE(VariableProxy) 1074 DECLARE_NODE_TYPE(VariableProxy)
1044 1075
1045 // Type testing & conversion 1076 // Type testing & conversion
1046 Variable* AsVariable() { return (this == NULL) ? NULL : var_; } 1077 Variable* AsVariable() { return (this == NULL) ? NULL : var_; }
1047 1078
1048 virtual bool IsValidLeftHandSide() { 1079 virtual bool IsValidLeftHandSide() {
1049 return var_ == NULL ? true : var_->IsValidLeftHandSide(); 1080 return var_ == NULL ? true : var_->IsValidLeftHandSide();
1050 } 1081 }
1051 1082
(...skipping 26 matching lines...) Expand all
1078 void BindTo(Variable* var); 1109 void BindTo(Variable* var);
1079 1110
1080 protected: 1111 protected:
1081 Handle<String> name_; 1112 Handle<String> name_;
1082 Variable* var_; // resolved variable, or NULL 1113 Variable* var_; // resolved variable, or NULL
1083 bool is_this_; 1114 bool is_this_;
1084 bool inside_with_; 1115 bool inside_with_;
1085 bool is_trivial_; 1116 bool is_trivial_;
1086 int position_; 1117 int position_;
1087 1118
1088 VariableProxy(Handle<String> name, 1119 VariableProxy(Isolate* isolate,
1120 Handle<String> name,
1089 bool is_this, 1121 bool is_this,
1090 bool inside_with, 1122 bool inside_with,
1091 int position = RelocInfo::kNoPosition); 1123 int position = RelocInfo::kNoPosition);
1092 explicit VariableProxy(bool is_this); 1124 VariableProxy(Isolate* isolate, bool is_this);
1093 1125
1094 friend class Scope; 1126 friend class Scope;
1095 }; 1127 };
1096 1128
1097 1129
1098 class VariableProxySentinel: public VariableProxy { 1130 class VariableProxySentinel: public VariableProxy {
1099 public: 1131 public:
1100 virtual bool IsValidLeftHandSide() { return !is_this(); } 1132 virtual bool IsValidLeftHandSide() { return !is_this(); }
1101 1133
1102 private: 1134 private:
1103 explicit VariableProxySentinel(bool is_this) : VariableProxy(is_this) { } 1135 VariableProxySentinel(Isolate* isolate, bool is_this)
1136 : VariableProxy(isolate, is_this) { }
1104 1137
1105 friend class AstSentinels; 1138 friend class AstSentinels;
1106 }; 1139 };
1107 1140
1108 1141
1109 class Slot: public Expression { 1142 class Slot: public Expression {
1110 public: 1143 public:
1111 enum Type { 1144 enum Type {
1112 // A slot in the parameter section on the stack. index() is 1145 // A slot in the parameter section on the stack. index() is
1113 // the parameter index, counting left-to-right, starting at 0. 1146 // the parameter index, counting left-to-right, starting at 0.
1114 PARAMETER, 1147 PARAMETER,
1115 1148
1116 // A slot in the local section on the stack. index() is 1149 // A slot in the local section on the stack. index() is
1117 // the variable index in the stack frame, starting at 0. 1150 // the variable index in the stack frame, starting at 0.
1118 LOCAL, 1151 LOCAL,
1119 1152
1120 // An indexed slot in a heap context. index() is the 1153 // An indexed slot in a heap context. index() is the
1121 // variable index in the context object on the heap, 1154 // variable index in the context object on the heap,
1122 // starting at 0. var()->scope() is the corresponding 1155 // starting at 0. var()->scope() is the corresponding
1123 // scope. 1156 // scope.
1124 CONTEXT, 1157 CONTEXT,
1125 1158
1126 // A named slot in a heap context. var()->name() is the 1159 // A named slot in a heap context. var()->name() is the
1127 // variable name in the context object on the heap, 1160 // variable name in the context object on the heap,
1128 // with lookup starting at the current context. index() 1161 // with lookup starting at the current context. index()
1129 // is invalid. 1162 // is invalid.
1130 LOOKUP 1163 LOOKUP
1131 }; 1164 };
1132 1165
1133 Slot(Variable* var, Type type, int index) 1166 Slot(Isolate* isolate, Variable* var, Type type, int index)
1134 : var_(var), type_(type), index_(index) { 1167 : Expression(isolate), var_(var), type_(type), index_(index) {
1135 ASSERT(var != NULL); 1168 ASSERT(var != NULL);
1136 } 1169 }
1137 1170
1138 virtual void Accept(AstVisitor* v); 1171 virtual void Accept(AstVisitor* v);
1139 1172
1140 virtual Slot* AsSlot() { return this; } 1173 virtual Slot* AsSlot() { return this; }
1141 1174
1142 bool IsStackAllocated() { return type_ == PARAMETER || type_ == LOCAL; } 1175 bool IsStackAllocated() { return type_ == PARAMETER || type_ == LOCAL; }
1143 1176
1144 // Accessors 1177 // Accessors
(...skipping 10 matching lines...) Expand all
1155 }; 1188 };
1156 1189
1157 1190
1158 class Property: public Expression { 1191 class Property: public Expression {
1159 public: 1192 public:
1160 // Synthetic properties are property lookups introduced by the system, 1193 // Synthetic properties are property lookups introduced by the system,
1161 // to objects that aren't visible to the user. Function calls to synthetic 1194 // to objects that aren't visible to the user. Function calls to synthetic
1162 // properties should use the global object as receiver, not the base object 1195 // properties should use the global object as receiver, not the base object
1163 // of the resolved Reference. 1196 // of the resolved Reference.
1164 enum Type { NORMAL, SYNTHETIC }; 1197 enum Type { NORMAL, SYNTHETIC };
1165 Property(Expression* obj, Expression* key, int pos, Type type = NORMAL) 1198 Property(Isolate* isolate,
1166 : obj_(obj), 1199 Expression* obj,
1200 Expression* key,
1201 int pos,
1202 Type type = NORMAL)
1203 : Expression(isolate),
1204 obj_(obj),
1167 key_(key), 1205 key_(key),
1168 pos_(pos), 1206 pos_(pos),
1169 type_(type), 1207 type_(type),
1170 receiver_types_(NULL), 1208 receiver_types_(NULL),
1171 is_monomorphic_(false), 1209 is_monomorphic_(false),
1172 is_array_length_(false), 1210 is_array_length_(false),
1173 is_string_length_(false), 1211 is_string_length_(false),
1174 is_string_access_(false), 1212 is_string_access_(false),
1175 is_function_prototype_(false) { } 1213 is_function_prototype_(false) { }
1176 1214
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1208 bool is_array_length_ : 1; 1246 bool is_array_length_ : 1;
1209 bool is_string_length_ : 1; 1247 bool is_string_length_ : 1;
1210 bool is_string_access_ : 1; 1248 bool is_string_access_ : 1;
1211 bool is_function_prototype_ : 1; 1249 bool is_function_prototype_ : 1;
1212 Handle<Map> monomorphic_receiver_type_; 1250 Handle<Map> monomorphic_receiver_type_;
1213 }; 1251 };
1214 1252
1215 1253
1216 class Call: public Expression { 1254 class Call: public Expression {
1217 public: 1255 public:
1218 Call(Expression* expression, ZoneList<Expression*>* arguments, int pos) 1256 Call(Isolate* isolate,
1219 : expression_(expression), 1257 Expression* expression,
1258 ZoneList<Expression*>* arguments,
1259 int pos)
1260 : Expression(isolate),
1261 expression_(expression),
1220 arguments_(arguments), 1262 arguments_(arguments),
1221 pos_(pos), 1263 pos_(pos),
1222 is_monomorphic_(false), 1264 is_monomorphic_(false),
1223 check_type_(RECEIVER_MAP_CHECK), 1265 check_type_(RECEIVER_MAP_CHECK),
1224 receiver_types_(NULL), 1266 receiver_types_(NULL),
1225 return_id_(GetNextId()) { 1267 return_id_(GetNextId(isolate)) {
1226 } 1268 }
1227 1269
1228 DECLARE_NODE_TYPE(Call) 1270 DECLARE_NODE_TYPE(Call)
1229 1271
1230 virtual bool IsInlineable() const; 1272 virtual bool IsInlineable() const;
1231 1273
1232 Expression* expression() const { return expression_; } 1274 Expression* expression() const { return expression_; }
1233 ZoneList<Expression*>* arguments() const { return arguments_; } 1275 ZoneList<Expression*>* arguments() const { return arguments_; }
1234 virtual int position() const { return pos_; } 1276 virtual int position() const { return pos_; }
1235 1277
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1294 EmptyStatement empty_statement_; 1336 EmptyStatement empty_statement_;
1295 1337
1296 friend class Isolate; 1338 friend class Isolate;
1297 1339
1298 DISALLOW_COPY_AND_ASSIGN(AstSentinels); 1340 DISALLOW_COPY_AND_ASSIGN(AstSentinels);
1299 }; 1341 };
1300 1342
1301 1343
1302 class CallNew: public Expression { 1344 class CallNew: public Expression {
1303 public: 1345 public:
1304 CallNew(Expression* expression, ZoneList<Expression*>* arguments, int pos) 1346 CallNew(Isolate* isolate,
1305 : expression_(expression), arguments_(arguments), pos_(pos) { } 1347 Expression* expression,
1348 ZoneList<Expression*>* arguments,
1349 int pos)
1350 : Expression(isolate),
1351 expression_(expression),
1352 arguments_(arguments),
1353 pos_(pos) { }
1306 1354
1307 DECLARE_NODE_TYPE(CallNew) 1355 DECLARE_NODE_TYPE(CallNew)
1308 1356
1309 virtual bool IsInlineable() const; 1357 virtual bool IsInlineable() const;
1310 1358
1311 Expression* expression() const { return expression_; } 1359 Expression* expression() const { return expression_; }
1312 ZoneList<Expression*>* arguments() const { return arguments_; } 1360 ZoneList<Expression*>* arguments() const { return arguments_; }
1313 virtual int position() const { return pos_; } 1361 virtual int position() const { return pos_; }
1314 1362
1315 private: 1363 private:
1316 Expression* expression_; 1364 Expression* expression_;
1317 ZoneList<Expression*>* arguments_; 1365 ZoneList<Expression*>* arguments_;
1318 int pos_; 1366 int pos_;
1319 }; 1367 };
1320 1368
1321 1369
1322 // The CallRuntime class does not represent any official JavaScript 1370 // The CallRuntime class does not represent any official JavaScript
1323 // language construct. Instead it is used to call a C or JS function 1371 // language construct. Instead it is used to call a C or JS function
1324 // with a set of arguments. This is used from the builtins that are 1372 // with a set of arguments. This is used from the builtins that are
1325 // implemented in JavaScript (see "v8natives.js"). 1373 // implemented in JavaScript (see "v8natives.js").
1326 class CallRuntime: public Expression { 1374 class CallRuntime: public Expression {
1327 public: 1375 public:
1328 CallRuntime(Handle<String> name, 1376 CallRuntime(Isolate* isolate,
1377 Handle<String> name,
1329 const Runtime::Function* function, 1378 const Runtime::Function* function,
1330 ZoneList<Expression*>* arguments) 1379 ZoneList<Expression*>* arguments)
1331 : name_(name), function_(function), arguments_(arguments) { } 1380 : Expression(isolate),
1381 name_(name),
1382 function_(function),
1383 arguments_(arguments) { }
1332 1384
1333 DECLARE_NODE_TYPE(CallRuntime) 1385 DECLARE_NODE_TYPE(CallRuntime)
1334 1386
1335 virtual bool IsInlineable() const; 1387 virtual bool IsInlineable() const;
1336 1388
1337 Handle<String> name() const { return name_; } 1389 Handle<String> name() const { return name_; }
1338 const Runtime::Function* function() const { return function_; } 1390 const Runtime::Function* function() const { return function_; }
1339 ZoneList<Expression*>* arguments() const { return arguments_; } 1391 ZoneList<Expression*>* arguments() const { return arguments_; }
1340 bool is_jsruntime() const { return function_ == NULL; } 1392 bool is_jsruntime() const { return function_ == NULL; }
1341 1393
1342 private: 1394 private:
1343 Handle<String> name_; 1395 Handle<String> name_;
1344 const Runtime::Function* function_; 1396 const Runtime::Function* function_;
1345 ZoneList<Expression*>* arguments_; 1397 ZoneList<Expression*>* arguments_;
1346 }; 1398 };
1347 1399
1348 1400
1349 class UnaryOperation: public Expression { 1401 class UnaryOperation: public Expression {
1350 public: 1402 public:
1351 UnaryOperation(Token::Value op, Expression* expression, int pos) 1403 UnaryOperation(Isolate* isolate,
1352 : op_(op), expression_(expression), pos_(pos) { 1404 Token::Value op,
1405 Expression* expression,
1406 int pos)
1407 : Expression(isolate), op_(op), expression_(expression), pos_(pos) {
1353 ASSERT(Token::IsUnaryOp(op)); 1408 ASSERT(Token::IsUnaryOp(op));
1354 } 1409 }
1355 1410
1356 DECLARE_NODE_TYPE(UnaryOperation) 1411 DECLARE_NODE_TYPE(UnaryOperation)
1357 1412
1358 virtual bool IsInlineable() const; 1413 virtual bool IsInlineable() const;
1359 1414
1360 virtual bool ResultOverwriteAllowed(); 1415 virtual bool ResultOverwriteAllowed();
1361 1416
1362 Token::Value op() const { return op_; } 1417 Token::Value op() const { return op_; }
1363 Expression* expression() const { return expression_; } 1418 Expression* expression() const { return expression_; }
1364 virtual int position() const { return pos_; } 1419 virtual int position() const { return pos_; }
1365 1420
1366 private: 1421 private:
1367 Token::Value op_; 1422 Token::Value op_;
1368 Expression* expression_; 1423 Expression* expression_;
1369 int pos_; 1424 int pos_;
1370 }; 1425 };
1371 1426
1372 1427
1373 class BinaryOperation: public Expression { 1428 class BinaryOperation: public Expression {
1374 public: 1429 public:
1375 BinaryOperation(Token::Value op, 1430 BinaryOperation(Isolate* isolate,
1431 Token::Value op,
1376 Expression* left, 1432 Expression* left,
1377 Expression* right, 1433 Expression* right,
1378 int pos) 1434 int pos)
1379 : op_(op), left_(left), right_(right), pos_(pos) { 1435 : Expression(isolate), op_(op), left_(left), right_(right), pos_(pos) {
1380 ASSERT(Token::IsBinaryOp(op)); 1436 ASSERT(Token::IsBinaryOp(op));
1381 right_id_ = (op == Token::AND || op == Token::OR) 1437 right_id_ = (op == Token::AND || op == Token::OR)
1382 ? static_cast<int>(GetNextId()) 1438 ? static_cast<int>(GetNextId(isolate))
1383 : AstNode::kNoNumber; 1439 : AstNode::kNoNumber;
1384 } 1440 }
1385 1441
1386 DECLARE_NODE_TYPE(BinaryOperation) 1442 DECLARE_NODE_TYPE(BinaryOperation)
1387 1443
1388 virtual bool IsInlineable() const; 1444 virtual bool IsInlineable() const;
1389 1445
1390 virtual bool ResultOverwriteAllowed(); 1446 virtual bool ResultOverwriteAllowed();
1391 1447
1392 Token::Value op() const { return op_; } 1448 Token::Value op() const { return op_; }
(...skipping 10 matching lines...) Expand all
1403 Expression* right_; 1459 Expression* right_;
1404 int pos_; 1460 int pos_;
1405 // The short-circuit logical operations have an AST ID for their 1461 // The short-circuit logical operations have an AST ID for their
1406 // right-hand subexpression. 1462 // right-hand subexpression.
1407 int right_id_; 1463 int right_id_;
1408 }; 1464 };
1409 1465
1410 1466
1411 class CountOperation: public Expression { 1467 class CountOperation: public Expression {
1412 public: 1468 public:
1413 CountOperation(Token::Value op, bool is_prefix, Expression* expr, int pos) 1469 CountOperation(Isolate* isolate,
1414 : op_(op), 1470 Token::Value op,
1471 bool is_prefix,
1472 Expression* expr,
1473 int pos)
1474 : Expression(isolate),
1475 op_(op),
1415 is_prefix_(is_prefix), 1476 is_prefix_(is_prefix),
1416 expression_(expr), 1477 expression_(expr),
1417 pos_(pos), 1478 pos_(pos),
1418 assignment_id_(GetNextId()), 1479 assignment_id_(GetNextId(isolate)),
1419 count_id_(GetNextId()), 1480 count_id_(GetNextId(isolate)),
1420 receiver_types_(NULL) { } 1481 receiver_types_(NULL) { }
1421 1482
1422 DECLARE_NODE_TYPE(CountOperation) 1483 DECLARE_NODE_TYPE(CountOperation)
1423 1484
1424 bool is_prefix() const { return is_prefix_; } 1485 bool is_prefix() const { return is_prefix_; }
1425 bool is_postfix() const { return !is_prefix_; } 1486 bool is_postfix() const { return !is_prefix_; }
1426 1487
1427 Token::Value op() const { return op_; } 1488 Token::Value op() const { return op_; }
1428 Token::Value binary_op() { 1489 Token::Value binary_op() {
1429 return (op() == Token::INC) ? Token::ADD : Token::SUB; 1490 return (op() == Token::INC) ? Token::ADD : Token::SUB;
(...skipping 25 matching lines...) Expand all
1455 int pos_; 1516 int pos_;
1456 int assignment_id_; 1517 int assignment_id_;
1457 int count_id_; 1518 int count_id_;
1458 Handle<Map> monomorphic_receiver_type_; 1519 Handle<Map> monomorphic_receiver_type_;
1459 ZoneMapList* receiver_types_; 1520 ZoneMapList* receiver_types_;
1460 }; 1521 };
1461 1522
1462 1523
1463 class CompareOperation: public Expression { 1524 class CompareOperation: public Expression {
1464 public: 1525 public:
1465 CompareOperation(Token::Value op, 1526 CompareOperation(Isolate* isolate,
1527 Token::Value op,
1466 Expression* left, 1528 Expression* left,
1467 Expression* right, 1529 Expression* right,
1468 int pos) 1530 int pos)
1469 : op_(op), left_(left), right_(right), pos_(pos), compare_type_(NONE) { 1531 : Expression(isolate),
1532 op_(op),
1533 left_(left),
1534 right_(right),
1535 pos_(pos),
1536 compare_type_(NONE) {
1470 ASSERT(Token::IsCompareOp(op)); 1537 ASSERT(Token::IsCompareOp(op));
1471 } 1538 }
1472 1539
1473 DECLARE_NODE_TYPE(CompareOperation) 1540 DECLARE_NODE_TYPE(CompareOperation)
1474 1541
1475 Token::Value op() const { return op_; } 1542 Token::Value op() const { return op_; }
1476 Expression* left() const { return left_; } 1543 Expression* left() const { return left_; }
1477 Expression* right() const { return right_; } 1544 Expression* right() const { return right_; }
1478 virtual int position() const { return pos_; } 1545 virtual int position() const { return pos_; }
1479 1546
(...skipping 14 matching lines...) Expand all
1494 Expression* right_; 1561 Expression* right_;
1495 int pos_; 1562 int pos_;
1496 1563
1497 enum CompareTypeFeedback { NONE, SMI_ONLY, OBJECT_ONLY }; 1564 enum CompareTypeFeedback { NONE, SMI_ONLY, OBJECT_ONLY };
1498 CompareTypeFeedback compare_type_; 1565 CompareTypeFeedback compare_type_;
1499 }; 1566 };
1500 1567
1501 1568
1502 class CompareToNull: public Expression { 1569 class CompareToNull: public Expression {
1503 public: 1570 public:
1504 CompareToNull(bool is_strict, Expression* expression) 1571 CompareToNull(Isolate* isolate, bool is_strict, Expression* expression)
1505 : is_strict_(is_strict), expression_(expression) { } 1572 : Expression(isolate), is_strict_(is_strict), expression_(expression) { }
1506 1573
1507 DECLARE_NODE_TYPE(CompareToNull) 1574 DECLARE_NODE_TYPE(CompareToNull)
1508 1575
1509 virtual bool IsInlineable() const; 1576 virtual bool IsInlineable() const;
1510 1577
1511 bool is_strict() const { return is_strict_; } 1578 bool is_strict() const { return is_strict_; }
1512 Token::Value op() const { return is_strict_ ? Token::EQ_STRICT : Token::EQ; } 1579 Token::Value op() const { return is_strict_ ? Token::EQ_STRICT : Token::EQ; }
1513 Expression* expression() const { return expression_; } 1580 Expression* expression() const { return expression_; }
1514 1581
1515 private: 1582 private:
1516 bool is_strict_; 1583 bool is_strict_;
1517 Expression* expression_; 1584 Expression* expression_;
1518 }; 1585 };
1519 1586
1520 1587
1521 class Conditional: public Expression { 1588 class Conditional: public Expression {
1522 public: 1589 public:
1523 Conditional(Expression* condition, 1590 Conditional(Isolate* isolate,
1591 Expression* condition,
1524 Expression* then_expression, 1592 Expression* then_expression,
1525 Expression* else_expression, 1593 Expression* else_expression,
1526 int then_expression_position, 1594 int then_expression_position,
1527 int else_expression_position) 1595 int else_expression_position)
1528 : condition_(condition), 1596 : Expression(isolate),
1597 condition_(condition),
1529 then_expression_(then_expression), 1598 then_expression_(then_expression),
1530 else_expression_(else_expression), 1599 else_expression_(else_expression),
1531 then_expression_position_(then_expression_position), 1600 then_expression_position_(then_expression_position),
1532 else_expression_position_(else_expression_position), 1601 else_expression_position_(else_expression_position),
1533 then_id_(GetNextId()), 1602 then_id_(GetNextId(isolate)),
1534 else_id_(GetNextId()) { 1603 else_id_(GetNextId(isolate)) {
1535 } 1604 }
1536 1605
1537 DECLARE_NODE_TYPE(Conditional) 1606 DECLARE_NODE_TYPE(Conditional)
1538 1607
1539 virtual bool IsInlineable() const; 1608 virtual bool IsInlineable() const;
1540 1609
1541 Expression* condition() const { return condition_; } 1610 Expression* condition() const { return condition_; }
1542 Expression* then_expression() const { return then_expression_; } 1611 Expression* then_expression() const { return then_expression_; }
1543 Expression* else_expression() const { return else_expression_; } 1612 Expression* else_expression() const { return else_expression_; }
1544 1613
1545 int then_expression_position() const { return then_expression_position_; } 1614 int then_expression_position() const { return then_expression_position_; }
1546 int else_expression_position() const { return else_expression_position_; } 1615 int else_expression_position() const { return else_expression_position_; }
1547 1616
1548 int ThenId() const { return then_id_; } 1617 int ThenId() const { return then_id_; }
1549 int ElseId() const { return else_id_; } 1618 int ElseId() const { return else_id_; }
1550 1619
1551 private: 1620 private:
1552 Expression* condition_; 1621 Expression* condition_;
1553 Expression* then_expression_; 1622 Expression* then_expression_;
1554 Expression* else_expression_; 1623 Expression* else_expression_;
1555 int then_expression_position_; 1624 int then_expression_position_;
1556 int else_expression_position_; 1625 int else_expression_position_;
1557 int then_id_; 1626 int then_id_;
1558 int else_id_; 1627 int else_id_;
1559 }; 1628 };
1560 1629
1561 1630
1562 class Assignment: public Expression { 1631 class Assignment: public Expression {
1563 public: 1632 public:
1564 Assignment(Token::Value op, Expression* target, Expression* value, int pos); 1633 Assignment(Isolate* isolate,
1634 Token::Value op,
1635 Expression* target,
1636 Expression* value,
1637 int pos);
1565 1638
1566 DECLARE_NODE_TYPE(Assignment) 1639 DECLARE_NODE_TYPE(Assignment)
1567 1640
1568 virtual bool IsInlineable() const; 1641 virtual bool IsInlineable() const;
1569 1642
1570 Assignment* AsSimpleAssignment() { return !is_compound() ? this : NULL; } 1643 Assignment* AsSimpleAssignment() { return !is_compound() ? this : NULL; }
1571 1644
1572 Token::Value binary_op() const; 1645 Token::Value binary_op() const;
1573 1646
1574 Token::Value op() const { return op_; } 1647 Token::Value op() const { return op_; }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1614 bool block_end_; 1687 bool block_end_;
1615 1688
1616 bool is_monomorphic_; 1689 bool is_monomorphic_;
1617 ZoneMapList* receiver_types_; 1690 ZoneMapList* receiver_types_;
1618 Handle<Map> monomorphic_receiver_type_; 1691 Handle<Map> monomorphic_receiver_type_;
1619 }; 1692 };
1620 1693
1621 1694
1622 class Throw: public Expression { 1695 class Throw: public Expression {
1623 public: 1696 public:
1624 Throw(Expression* exception, int pos) 1697 Throw(Isolate* isolate, Expression* exception, int pos)
1625 : exception_(exception), pos_(pos) {} 1698 : Expression(isolate), exception_(exception), pos_(pos) {}
1626 1699
1627 DECLARE_NODE_TYPE(Throw) 1700 DECLARE_NODE_TYPE(Throw)
1628 1701
1629 Expression* exception() const { return exception_; } 1702 Expression* exception() const { return exception_; }
1630 virtual int position() const { return pos_; } 1703 virtual int position() const { return pos_; }
1631 virtual bool IsInlineable() const; 1704 virtual bool IsInlineable() const;
1632 1705
1633 private: 1706 private:
1634 Expression* exception_; 1707 Expression* exception_;
1635 int pos_; 1708 int pos_;
1636 }; 1709 };
1637 1710
1638 1711
1639 class FunctionLiteral: public Expression { 1712 class FunctionLiteral: public Expression {
1640 public: 1713 public:
1641 FunctionLiteral(Handle<String> name, 1714 FunctionLiteral(Isolate* isolate,
1715 Handle<String> name,
1642 Scope* scope, 1716 Scope* scope,
1643 ZoneList<Statement*>* body, 1717 ZoneList<Statement*>* body,
1644 int materialized_literal_count, 1718 int materialized_literal_count,
1645 int expected_property_count, 1719 int expected_property_count,
1646 bool has_only_simple_this_property_assignments, 1720 bool has_only_simple_this_property_assignments,
1647 Handle<FixedArray> this_property_assignments, 1721 Handle<FixedArray> this_property_assignments,
1648 int num_parameters, 1722 int num_parameters,
1649 int start_position, 1723 int start_position,
1650 int end_position, 1724 int end_position,
1651 bool is_expression, 1725 bool is_expression,
1652 bool has_duplicate_parameters) 1726 bool has_duplicate_parameters)
1653 : name_(name), 1727 : Expression(isolate),
1728 name_(name),
1654 scope_(scope), 1729 scope_(scope),
1655 body_(body), 1730 body_(body),
1656 materialized_literal_count_(materialized_literal_count), 1731 materialized_literal_count_(materialized_literal_count),
1657 expected_property_count_(expected_property_count), 1732 expected_property_count_(expected_property_count),
1658 has_only_simple_this_property_assignments_( 1733 has_only_simple_this_property_assignments_(
1659 has_only_simple_this_property_assignments), 1734 has_only_simple_this_property_assignments),
1660 this_property_assignments_(this_property_assignments), 1735 this_property_assignments_(this_property_assignments),
1661 num_parameters_(num_parameters), 1736 num_parameters_(num_parameters),
1662 start_position_(start_position), 1737 start_position_(start_position),
1663 end_position_(end_position), 1738 end_position_(end_position),
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1722 int function_token_position_; 1797 int function_token_position_;
1723 Handle<String> inferred_name_; 1798 Handle<String> inferred_name_;
1724 bool is_expression_; 1799 bool is_expression_;
1725 bool pretenure_; 1800 bool pretenure_;
1726 bool has_duplicate_parameters_; 1801 bool has_duplicate_parameters_;
1727 }; 1802 };
1728 1803
1729 1804
1730 class SharedFunctionInfoLiteral: public Expression { 1805 class SharedFunctionInfoLiteral: public Expression {
1731 public: 1806 public:
1732 explicit SharedFunctionInfoLiteral( 1807 SharedFunctionInfoLiteral(
1808 Isolate* isolate,
1733 Handle<SharedFunctionInfo> shared_function_info) 1809 Handle<SharedFunctionInfo> shared_function_info)
1734 : shared_function_info_(shared_function_info) { } 1810 : Expression(isolate), shared_function_info_(shared_function_info) { }
1735 1811
1736 DECLARE_NODE_TYPE(SharedFunctionInfoLiteral) 1812 DECLARE_NODE_TYPE(SharedFunctionInfoLiteral)
1737 1813
1738 Handle<SharedFunctionInfo> shared_function_info() const { 1814 Handle<SharedFunctionInfo> shared_function_info() const {
1739 return shared_function_info_; 1815 return shared_function_info_;
1740 } 1816 }
1741 virtual bool IsInlineable() const; 1817 virtual bool IsInlineable() const;
1742 1818
1743 private: 1819 private:
1744 Handle<SharedFunctionInfo> shared_function_info_; 1820 Handle<SharedFunctionInfo> shared_function_info_;
1745 }; 1821 };
1746 1822
1747 1823
1748 class ThisFunction: public Expression { 1824 class ThisFunction: public Expression {
1749 public: 1825 public:
1826 explicit ThisFunction(Isolate* isolate) : Expression(isolate) {}
1750 DECLARE_NODE_TYPE(ThisFunction) 1827 DECLARE_NODE_TYPE(ThisFunction)
1751 virtual bool IsInlineable() const; 1828 virtual bool IsInlineable() const;
1752 }; 1829 };
1753 1830
1754 1831
1755 // ---------------------------------------------------------------------------- 1832 // ----------------------------------------------------------------------------
1756 // Regular expressions 1833 // Regular expressions
1757 1834
1758 1835
1759 class RegExpVisitor BASE_EMBEDDED { 1836 class RegExpVisitor BASE_EMBEDDED {
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
2150 2227
2151 private: 2228 private:
2152 Isolate* isolate_; 2229 Isolate* isolate_;
2153 bool stack_overflow_; 2230 bool stack_overflow_;
2154 }; 2231 };
2155 2232
2156 2233
2157 } } // namespace v8::internal 2234 } } // namespace v8::internal
2158 2235
2159 #endif // V8_AST_H_ 2236 #endif // V8_AST_H_
OLDNEW
« no previous file with comments | « src/assembler.cc ('k') | src/ast.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698