| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_AST_H_ | 5 #ifndef V8_AST_H_ |
| 6 #define V8_AST_H_ | 6 #define V8_AST_H_ |
| 7 | 7 |
| 8 #include "src/v8.h" | 8 #include "src/v8.h" |
| 9 | 9 |
| 10 #include "src/assembler.h" | 10 #include "src/assembler.h" |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 typedef ZoneList<Handle<Object> > ZoneObjectList; | 142 typedef ZoneList<Handle<Object> > ZoneObjectList; |
| 143 | 143 |
| 144 | 144 |
| 145 #define DECLARE_NODE_TYPE(type) \ | 145 #define DECLARE_NODE_TYPE(type) \ |
| 146 virtual void Accept(AstVisitor* v) OVERRIDE; \ | 146 virtual void Accept(AstVisitor* v) OVERRIDE; \ |
| 147 virtual AstNode::NodeType node_type() const FINAL OVERRIDE { \ | 147 virtual AstNode::NodeType node_type() const FINAL OVERRIDE { \ |
| 148 return AstNode::k##type; \ | 148 return AstNode::k##type; \ |
| 149 } \ | 149 } \ |
| 150 template<class> friend class AstNodeFactory; | 150 template<class> friend class AstNodeFactory; |
| 151 | 151 |
| 152 #define RESERVE_ID_RANGE() \ |
| 153 id_gen->ReserveIdRange(kClassIdRange) |
| 154 |
| 155 #define NEXT_ID(SUPER) \ |
| 156 this->SUPER::NextId() |
| 157 |
| 158 #define NEXT_ID_FUNC(ID) \ |
| 159 int NextId() const { \ |
| 160 return ID.ToInt() + kClassIdRange; \ |
| 161 } |
| 162 |
| 163 #define NEXT_ID_FUNC_BASE(SUPER) \ |
| 164 int NextId() const { \ |
| 165 return this->SUPER::NextId() + kClassIdRange; \ |
| 166 } |
| 167 |
| 152 | 168 |
| 153 enum AstPropertiesFlag { | 169 enum AstPropertiesFlag { |
| 154 kDontSelfOptimize, | 170 kDontSelfOptimize, |
| 155 kDontSoftInline, | 171 kDontSoftInline, |
| 156 kDontCache | 172 kDontCache |
| 157 }; | 173 }; |
| 158 | 174 |
| 159 | 175 |
| 160 class AstProperties FINAL BASE_EMBEDDED { | 176 class AstProperties FINAL BASE_EMBEDDED { |
| 161 public: | 177 public: |
| (...skipping 17 matching lines...) Expand all Loading... |
| 179 }; | 195 }; |
| 180 | 196 |
| 181 | 197 |
| 182 class AstNode: public ZoneObject { | 198 class AstNode: public ZoneObject { |
| 183 public: | 199 public: |
| 184 // For generating IDs for AstNodes. | 200 // For generating IDs for AstNodes. |
| 185 class IdGen { | 201 class IdGen { |
| 186 public: | 202 public: |
| 187 explicit IdGen(int id = 0) : id_(id) {} | 203 explicit IdGen(int id = 0) : id_(id) {} |
| 188 | 204 |
| 189 int GetNextId() { return ReserveIdRange(1); } | |
| 190 int ReserveIdRange(int n) { | 205 int ReserveIdRange(int n) { |
| 191 int tmp = id_; | 206 int tmp = id_; |
| 192 id_ += n; | 207 id_ += n; |
| 193 return tmp; | 208 return tmp; |
| 194 } | 209 } |
| 195 | 210 |
| 196 private: | 211 private: |
| 197 int id_; | 212 int id_; |
| 198 }; | 213 }; |
| 199 | 214 |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 virtual KeyedAccessStoreMode GetStoreMode() { | 383 virtual KeyedAccessStoreMode GetStoreMode() { |
| 369 UNREACHABLE(); | 384 UNREACHABLE(); |
| 370 return STANDARD_STORE; | 385 return STANDARD_STORE; |
| 371 } | 386 } |
| 372 | 387 |
| 373 // TODO(rossberg): this should move to its own AST node eventually. | 388 // TODO(rossberg): this should move to its own AST node eventually. |
| 374 virtual void RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle); | 389 virtual void RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle); |
| 375 byte to_boolean_types() const { return to_boolean_types_; } | 390 byte to_boolean_types() const { return to_boolean_types_; } |
| 376 | 391 |
| 377 BailoutId id() const { return id_; } | 392 BailoutId id() const { return id_; } |
| 378 TypeFeedbackId test_id() const { return test_id_; } | 393 TypeFeedbackId test_id() const { return TypeFeedbackId(id_.ToInt() + 1); } |
| 379 | 394 |
| 380 protected: | 395 protected: |
| 381 Expression(Zone* zone, int pos, IdGen* id_gen) | 396 Expression(Zone* zone, int pos, IdGen* id_gen) |
| 382 : AstNode(pos), | 397 : AstNode(pos), |
| 383 bounds_(Bounds::Unbounded(zone)), | 398 bounds_(Bounds::Unbounded(zone)), |
| 384 parenthesization_level_(0), | 399 parenthesization_level_(0), |
| 385 id_(id_gen->GetNextId()), | 400 id_(RESERVE_ID_RANGE()) {} |
| 386 test_id_(id_gen->GetNextId()) {} | 401 |
| 387 void set_to_boolean_types(byte types) { to_boolean_types_ = types; } | 402 void set_to_boolean_types(byte types) { to_boolean_types_ = types; } |
| 388 | 403 |
| 404 NEXT_ID_FUNC(id_); |
| 405 |
| 389 private: | 406 private: |
| 390 Bounds bounds_; | 407 Bounds bounds_; |
| 391 byte to_boolean_types_; | 408 byte to_boolean_types_; |
| 392 unsigned parenthesization_level_; | 409 unsigned parenthesization_level_; |
| 393 | 410 |
| 394 const BailoutId id_; | 411 const BailoutId id_; |
| 395 const TypeFeedbackId test_id_; | 412 static const int kClassIdRange = 2; // id and test id |
| 396 }; | 413 }; |
| 397 | 414 |
| 398 | 415 |
| 399 class BreakableStatement : public Statement { | 416 class BreakableStatement : public Statement { |
| 400 public: | 417 public: |
| 401 enum BreakableType { | 418 enum BreakableType { |
| 402 TARGET_FOR_ANONYMOUS, | 419 TARGET_FOR_ANONYMOUS, |
| 403 TARGET_FOR_NAMED_ONLY | 420 TARGET_FOR_NAMED_ONLY |
| 404 }; | 421 }; |
| 405 | 422 |
| 406 // The labels associated with this statement. May be NULL; | 423 // The labels associated with this statement. May be NULL; |
| 407 // if it is != NULL, guaranteed to contain at least one entry. | 424 // if it is != NULL, guaranteed to contain at least one entry. |
| 408 ZoneList<const AstRawString*>* labels() const { return labels_; } | 425 ZoneList<const AstRawString*>* labels() const { return labels_; } |
| 409 | 426 |
| 410 // Type testing & conversion. | 427 // Type testing & conversion. |
| 411 virtual BreakableStatement* AsBreakableStatement() FINAL OVERRIDE { | 428 virtual BreakableStatement* AsBreakableStatement() FINAL OVERRIDE { |
| 412 return this; | 429 return this; |
| 413 } | 430 } |
| 414 | 431 |
| 415 // Code generation | 432 // Code generation |
| 416 Label* break_target() { return &break_target_; } | 433 Label* break_target() { return &break_target_; } |
| 417 | 434 |
| 418 // Testers. | 435 // Testers. |
| 419 bool is_target_for_anonymous() const { | 436 bool is_target_for_anonymous() const { |
| 420 return breakable_type_ == TARGET_FOR_ANONYMOUS; | 437 return breakable_type_ == TARGET_FOR_ANONYMOUS; |
| 421 } | 438 } |
| 422 | 439 |
| 423 BailoutId EntryId() const { return entry_id_; } | 440 BailoutId EntryId() const { return entry_id_; } |
| 424 BailoutId ExitId() const { return exit_id_; } | 441 BailoutId ExitId() const { return BailoutId(entry_id_.ToInt() + 1); } |
| 425 | 442 |
| 426 protected: | 443 protected: |
| 427 BreakableStatement(Zone* zone, ZoneList<const AstRawString*>* labels, | 444 BreakableStatement(Zone* zone, ZoneList<const AstRawString*>* labels, |
| 428 BreakableType breakable_type, int position, IdGen* id_gen) | 445 BreakableType breakable_type, int position, IdGen* id_gen) |
| 429 : Statement(zone, position), | 446 : Statement(zone, position), |
| 430 labels_(labels), | 447 labels_(labels), |
| 431 breakable_type_(breakable_type), | 448 breakable_type_(breakable_type), |
| 432 entry_id_(id_gen->GetNextId()), | 449 entry_id_(RESERVE_ID_RANGE()) { |
| 433 exit_id_(id_gen->GetNextId()) { | |
| 434 DCHECK(labels == NULL || labels->length() > 0); | 450 DCHECK(labels == NULL || labels->length() > 0); |
| 435 } | 451 } |
| 436 | 452 |
| 453 NEXT_ID_FUNC(entry_id_); |
| 437 | 454 |
| 438 private: | 455 private: |
| 439 ZoneList<const AstRawString*>* labels_; | 456 ZoneList<const AstRawString*>* labels_; |
| 440 BreakableType breakable_type_; | 457 BreakableType breakable_type_; |
| 441 Label break_target_; | 458 Label break_target_; |
| 459 |
| 442 const BailoutId entry_id_; | 460 const BailoutId entry_id_; |
| 443 const BailoutId exit_id_; | 461 static const int kClassIdRange = 2; // Entry and exit ids |
| 444 }; | 462 }; |
| 445 | 463 |
| 446 | 464 |
| 447 class Block FINAL : public BreakableStatement { | 465 class Block FINAL : public BreakableStatement { |
| 448 public: | 466 public: |
| 449 DECLARE_NODE_TYPE(Block) | 467 DECLARE_NODE_TYPE(Block) |
| 450 | 468 |
| 451 void AddStatement(Statement* statement, Zone* zone) { | 469 void AddStatement(Statement* statement, Zone* zone) { |
| 452 statements_.Add(statement, zone); | 470 statements_.Add(statement, zone); |
| 453 } | 471 } |
| 454 | 472 |
| 455 ZoneList<Statement*>* statements() { return &statements_; } | 473 ZoneList<Statement*>* statements() { return &statements_; } |
| 456 bool is_initializer_block() const { return is_initializer_block_; } | 474 bool is_initializer_block() const { return is_initializer_block_; } |
| 457 | 475 |
| 458 BailoutId DeclsId() const { return decls_id_; } | 476 BailoutId DeclsId() const { return BailoutId(NEXT_ID(BreakableStatement)); } |
| 459 | 477 |
| 460 virtual bool IsJump() const OVERRIDE { | 478 virtual bool IsJump() const OVERRIDE { |
| 461 return !statements_.is_empty() && statements_.last()->IsJump() | 479 return !statements_.is_empty() && statements_.last()->IsJump() |
| 462 && labels() == NULL; // Good enough as an approximation... | 480 && labels() == NULL; // Good enough as an approximation... |
| 463 } | 481 } |
| 464 | 482 |
| 465 Scope* scope() const { return scope_; } | 483 Scope* scope() const { return scope_; } |
| 466 void set_scope(Scope* scope) { scope_ = scope; } | 484 void set_scope(Scope* scope) { scope_ = scope; } |
| 467 | 485 |
| 468 protected: | 486 protected: |
| 469 Block(Zone* zone, ZoneList<const AstRawString*>* labels, int capacity, | 487 Block(Zone* zone, ZoneList<const AstRawString*>* labels, int capacity, |
| 470 bool is_initializer_block, int pos, IdGen* id_gen) | 488 bool is_initializer_block, int pos, IdGen* id_gen) |
| 471 : BreakableStatement(zone, labels, TARGET_FOR_NAMED_ONLY, pos, id_gen), | 489 : BreakableStatement(zone, labels, TARGET_FOR_NAMED_ONLY, pos, id_gen), |
| 472 statements_(capacity, zone), | 490 statements_(capacity, zone), |
| 473 is_initializer_block_(is_initializer_block), | 491 is_initializer_block_(is_initializer_block), |
| 474 decls_id_(id_gen->GetNextId()), | 492 scope_(NULL) { |
| 475 scope_(NULL) {} | 493 #ifdef DEBUG |
| 494 int decls_id = |
| 495 #endif |
| 496 RESERVE_ID_RANGE(); |
| 497 DCHECK(decls_id == DeclsId().ToInt()); |
| 498 } |
| 499 |
| 500 NEXT_ID_FUNC_BASE(BreakableStatement) |
| 476 | 501 |
| 477 private: | 502 private: |
| 478 ZoneList<Statement*> statements_; | 503 ZoneList<Statement*> statements_; |
| 479 bool is_initializer_block_; | 504 bool is_initializer_block_; |
| 480 const BailoutId decls_id_; | |
| 481 Scope* scope_; | 505 Scope* scope_; |
| 506 |
| 507 static const int kClassIdRange = 1; // decls id |
| 482 }; | 508 }; |
| 483 | 509 |
| 484 | 510 |
| 485 class Declaration : public AstNode { | 511 class Declaration : public AstNode { |
| 486 public: | 512 public: |
| 487 VariableProxy* proxy() const { return proxy_; } | 513 VariableProxy* proxy() const { return proxy_; } |
| 488 VariableMode mode() const { return mode_; } | 514 VariableMode mode() const { return mode_; } |
| 489 Scope* scope() const { return scope_; } | 515 Scope* scope() const { return scope_; } |
| 490 virtual InitializationFlag initialization() const = 0; | 516 virtual InitializationFlag initialization() const = 0; |
| 491 virtual bool IsInlineable() const; | 517 virtual bool IsInlineable() const; |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 722 | 748 |
| 723 class IterationStatement : public BreakableStatement { | 749 class IterationStatement : public BreakableStatement { |
| 724 public: | 750 public: |
| 725 // Type testing & conversion. | 751 // Type testing & conversion. |
| 726 virtual IterationStatement* AsIterationStatement() FINAL OVERRIDE { | 752 virtual IterationStatement* AsIterationStatement() FINAL OVERRIDE { |
| 727 return this; | 753 return this; |
| 728 } | 754 } |
| 729 | 755 |
| 730 Statement* body() const { return body_; } | 756 Statement* body() const { return body_; } |
| 731 | 757 |
| 732 BailoutId OsrEntryId() const { return osr_entry_id_; } | 758 BailoutId OsrEntryId() const { |
| 759 return BailoutId(NEXT_ID(BreakableStatement)); |
| 760 } |
| 733 virtual BailoutId ContinueId() const = 0; | 761 virtual BailoutId ContinueId() const = 0; |
| 734 virtual BailoutId StackCheckId() const = 0; | 762 virtual BailoutId StackCheckId() const = 0; |
| 735 | 763 |
| 736 // Code generation | 764 // Code generation |
| 737 Label* continue_target() { return &continue_target_; } | 765 Label* continue_target() { return &continue_target_; } |
| 738 | 766 |
| 739 protected: | 767 protected: |
| 740 IterationStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos, | 768 IterationStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos, |
| 741 IdGen* id_gen) | 769 IdGen* id_gen) |
| 742 : BreakableStatement(zone, labels, TARGET_FOR_ANONYMOUS, pos, id_gen), | 770 : BreakableStatement(zone, labels, TARGET_FOR_ANONYMOUS, pos, id_gen), |
| 743 body_(NULL), | 771 body_(NULL) { |
| 744 osr_entry_id_(id_gen->GetNextId()) {} | 772 #ifdef DEBUG |
| 773 int osr_entry_id = |
| 774 #endif |
| 775 RESERVE_ID_RANGE(); |
| 776 DCHECK(osr_entry_id == OsrEntryId().ToInt()); |
| 777 } |
| 745 | 778 |
| 746 void Initialize(Statement* body) { | 779 void Initialize(Statement* body) { |
| 747 body_ = body; | 780 body_ = body; |
| 748 } | 781 } |
| 749 | 782 |
| 783 NEXT_ID_FUNC_BASE(BreakableStatement); |
| 784 |
| 750 private: | 785 private: |
| 751 Statement* body_; | 786 Statement* body_; |
| 752 Label continue_target_; | 787 Label continue_target_; |
| 753 | 788 |
| 754 const BailoutId osr_entry_id_; | 789 static const int kClassIdRange = 1; // Osr entry id |
| 755 }; | 790 }; |
| 756 | 791 |
| 757 | 792 |
| 758 class DoWhileStatement FINAL : public IterationStatement { | 793 class DoWhileStatement FINAL : public IterationStatement { |
| 759 public: | 794 public: |
| 760 DECLARE_NODE_TYPE(DoWhileStatement) | 795 DECLARE_NODE_TYPE(DoWhileStatement) |
| 761 | 796 |
| 762 void Initialize(Expression* cond, Statement* body) { | 797 void Initialize(Expression* cond, Statement* body) { |
| 763 IterationStatement::Initialize(body); | 798 IterationStatement::Initialize(body); |
| 764 cond_ = cond; | 799 cond_ = cond; |
| 765 } | 800 } |
| 766 | 801 |
| 767 Expression* cond() const { return cond_; } | 802 Expression* cond() const { return cond_; } |
| 768 | 803 |
| 769 virtual BailoutId ContinueId() const OVERRIDE { return continue_id_; } | 804 virtual BailoutId ContinueId() const OVERRIDE { |
| 770 virtual BailoutId StackCheckId() const OVERRIDE { return back_edge_id_; } | 805 return BailoutId(NEXT_ID(IterationStatement)); |
| 771 BailoutId BackEdgeId() const { return back_edge_id_; } | 806 } |
| 807 virtual BailoutId StackCheckId() const OVERRIDE { |
| 808 return BailoutId(NEXT_ID(IterationStatement) + 1); |
| 809 } |
| 810 BailoutId BackEdgeId() const { |
| 811 return BailoutId(NEXT_ID(IterationStatement) + 1); |
| 812 } |
| 772 | 813 |
| 773 protected: | 814 protected: |
| 774 DoWhileStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos, | 815 DoWhileStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos, |
| 775 IdGen* id_gen) | 816 IdGen* id_gen) |
| 776 : IterationStatement(zone, labels, pos, id_gen), | 817 : IterationStatement(zone, labels, pos, id_gen), |
| 777 cond_(NULL), | 818 cond_(NULL) { |
| 778 continue_id_(id_gen->GetNextId()), | 819 #ifdef DEBUG |
| 779 back_edge_id_(id_gen->GetNextId()) {} | 820 int continue_id = |
| 821 #endif |
| 822 RESERVE_ID_RANGE(); |
| 823 DCHECK(continue_id == ContinueId().ToInt()); |
| 824 } |
| 780 | 825 |
| 781 private: | 826 private: |
| 782 Expression* cond_; | 827 Expression* cond_; |
| 783 | 828 |
| 784 const BailoutId continue_id_; | 829 static const int kClassIdRange = 2; // Continue and back edge ids |
| 785 const BailoutId back_edge_id_; | |
| 786 }; | 830 }; |
| 787 | 831 |
| 788 | 832 |
| 789 class WhileStatement FINAL : public IterationStatement { | 833 class WhileStatement FINAL : public IterationStatement { |
| 790 public: | 834 public: |
| 791 DECLARE_NODE_TYPE(WhileStatement) | 835 DECLARE_NODE_TYPE(WhileStatement) |
| 792 | 836 |
| 793 void Initialize(Expression* cond, Statement* body) { | 837 void Initialize(Expression* cond, Statement* body) { |
| 794 IterationStatement::Initialize(body); | 838 IterationStatement::Initialize(body); |
| 795 cond_ = cond; | 839 cond_ = cond; |
| 796 } | 840 } |
| 797 | 841 |
| 798 Expression* cond() const { return cond_; } | 842 Expression* cond() const { return cond_; } |
| 799 bool may_have_function_literal() const { | 843 bool may_have_function_literal() const { |
| 800 return may_have_function_literal_; | 844 return may_have_function_literal_; |
| 801 } | 845 } |
| 802 void set_may_have_function_literal(bool value) { | 846 void set_may_have_function_literal(bool value) { |
| 803 may_have_function_literal_ = value; | 847 may_have_function_literal_ = value; |
| 804 } | 848 } |
| 805 | 849 |
| 806 virtual BailoutId ContinueId() const OVERRIDE { return EntryId(); } | 850 virtual BailoutId ContinueId() const OVERRIDE { return EntryId(); } |
| 807 virtual BailoutId StackCheckId() const OVERRIDE { return body_id_; } | 851 virtual BailoutId StackCheckId() const OVERRIDE { |
| 808 BailoutId BodyId() const { return body_id_; } | 852 return BailoutId(NEXT_ID(IterationStatement)); |
| 853 } |
| 854 BailoutId BodyId() const { return BailoutId(NEXT_ID(IterationStatement)); } |
| 809 | 855 |
| 810 protected: | 856 protected: |
| 811 WhileStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos, | 857 WhileStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos, |
| 812 IdGen* id_gen) | 858 IdGen* id_gen) |
| 813 : IterationStatement(zone, labels, pos, id_gen), | 859 : IterationStatement(zone, labels, pos, id_gen), |
| 814 cond_(NULL), | 860 cond_(NULL), |
| 815 may_have_function_literal_(true), | 861 may_have_function_literal_(true) { |
| 816 body_id_(id_gen->GetNextId()) {} | 862 #ifdef DEBUG |
| 863 int body_id = |
| 864 #endif |
| 865 RESERVE_ID_RANGE(); |
| 866 DCHECK(body_id == BodyId().ToInt()); |
| 867 } |
| 817 | 868 |
| 818 private: | 869 private: |
| 819 Expression* cond_; | 870 Expression* cond_; |
| 820 | 871 |
| 821 // True if there is a function literal subexpression in the condition. | 872 // True if there is a function literal subexpression in the condition. |
| 822 bool may_have_function_literal_; | 873 bool may_have_function_literal_; |
| 823 | 874 |
| 824 const BailoutId body_id_; | 875 static const int kClassIdRange = 1; // Body id |
| 825 }; | 876 }; |
| 826 | 877 |
| 827 | 878 |
| 828 class ForStatement FINAL : public IterationStatement { | 879 class ForStatement FINAL : public IterationStatement { |
| 829 public: | 880 public: |
| 830 DECLARE_NODE_TYPE(ForStatement) | 881 DECLARE_NODE_TYPE(ForStatement) |
| 831 | 882 |
| 832 void Initialize(Statement* init, | 883 void Initialize(Statement* init, |
| 833 Expression* cond, | 884 Expression* cond, |
| 834 Statement* next, | 885 Statement* next, |
| 835 Statement* body) { | 886 Statement* body) { |
| 836 IterationStatement::Initialize(body); | 887 IterationStatement::Initialize(body); |
| 837 init_ = init; | 888 init_ = init; |
| 838 cond_ = cond; | 889 cond_ = cond; |
| 839 next_ = next; | 890 next_ = next; |
| 840 } | 891 } |
| 841 | 892 |
| 842 Statement* init() const { return init_; } | 893 Statement* init() const { return init_; } |
| 843 Expression* cond() const { return cond_; } | 894 Expression* cond() const { return cond_; } |
| 844 Statement* next() const { return next_; } | 895 Statement* next() const { return next_; } |
| 845 | 896 |
| 846 bool may_have_function_literal() const { | 897 bool may_have_function_literal() const { |
| 847 return may_have_function_literal_; | 898 return may_have_function_literal_; |
| 848 } | 899 } |
| 849 void set_may_have_function_literal(bool value) { | 900 void set_may_have_function_literal(bool value) { |
| 850 may_have_function_literal_ = value; | 901 may_have_function_literal_ = value; |
| 851 } | 902 } |
| 852 | 903 |
| 853 virtual BailoutId ContinueId() const OVERRIDE { return continue_id_; } | 904 virtual BailoutId ContinueId() const OVERRIDE { |
| 854 virtual BailoutId StackCheckId() const OVERRIDE { return body_id_; } | 905 return BailoutId(NEXT_ID(IterationStatement)); |
| 855 BailoutId BodyId() const { return body_id_; } | 906 } |
| 907 virtual BailoutId StackCheckId() const OVERRIDE { |
| 908 return BailoutId(NEXT_ID(IterationStatement) + 1); |
| 909 } |
| 910 BailoutId BodyId() const { |
| 911 return BailoutId(NEXT_ID(IterationStatement) + 1); |
| 912 } |
| 856 | 913 |
| 857 bool is_fast_smi_loop() { return loop_variable_ != NULL; } | 914 bool is_fast_smi_loop() { return loop_variable_ != NULL; } |
| 858 Variable* loop_variable() { return loop_variable_; } | 915 Variable* loop_variable() { return loop_variable_; } |
| 859 void set_loop_variable(Variable* var) { loop_variable_ = var; } | 916 void set_loop_variable(Variable* var) { loop_variable_ = var; } |
| 860 | 917 |
| 861 protected: | 918 protected: |
| 862 ForStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos, | 919 ForStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos, |
| 863 IdGen* id_gen) | 920 IdGen* id_gen) |
| 864 : IterationStatement(zone, labels, pos, id_gen), | 921 : IterationStatement(zone, labels, pos, id_gen), |
| 865 init_(NULL), | 922 init_(NULL), |
| 866 cond_(NULL), | 923 cond_(NULL), |
| 867 next_(NULL), | 924 next_(NULL), |
| 868 may_have_function_literal_(true), | 925 may_have_function_literal_(true), |
| 869 loop_variable_(NULL), | 926 loop_variable_(NULL) { |
| 870 continue_id_(id_gen->GetNextId()), | 927 #ifdef DEBUG |
| 871 body_id_(id_gen->GetNextId()) {} | 928 int continue_id = |
| 929 #endif |
| 930 RESERVE_ID_RANGE(); |
| 931 DCHECK(continue_id == ContinueId().ToInt()); |
| 932 } |
| 872 | 933 |
| 873 private: | 934 private: |
| 874 Statement* init_; | 935 Statement* init_; |
| 875 Expression* cond_; | 936 Expression* cond_; |
| 876 Statement* next_; | 937 Statement* next_; |
| 877 | 938 |
| 878 // True if there is a function literal subexpression in the condition. | 939 // True if there is a function literal subexpression in the condition. |
| 879 bool may_have_function_literal_; | 940 bool may_have_function_literal_; |
| 880 Variable* loop_variable_; | 941 Variable* loop_variable_; |
| 881 | 942 |
| 882 const BailoutId continue_id_; | 943 static const int kClassIdRange = 2; // Continue and body ids |
| 883 const BailoutId body_id_; | |
| 884 }; | 944 }; |
| 885 | 945 |
| 886 | 946 |
| 887 class ForEachStatement : public IterationStatement { | 947 class ForEachStatement : public IterationStatement { |
| 888 public: | 948 public: |
| 889 enum VisitMode { | 949 enum VisitMode { |
| 890 ENUMERATE, // for (each in subject) body; | 950 ENUMERATE, // for (each in subject) body; |
| 891 ITERATE // for (each of subject) body; | 951 ITERATE // for (each of subject) body; |
| 892 }; | 952 }; |
| 893 | 953 |
| 894 void Initialize(Expression* each, Expression* subject, Statement* body) { | 954 void Initialize(Expression* each, Expression* subject, Statement* body) { |
| 895 IterationStatement::Initialize(body); | 955 IterationStatement::Initialize(body); |
| 896 each_ = each; | 956 each_ = each; |
| 897 subject_ = subject; | 957 subject_ = subject; |
| 898 } | 958 } |
| 899 | 959 |
| 900 Expression* each() const { return each_; } | 960 Expression* each() const { return each_; } |
| 901 Expression* subject() const { return subject_; } | 961 Expression* subject() const { return subject_; } |
| 902 | 962 |
| 903 protected: | 963 protected: |
| 904 ForEachStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos, | 964 ForEachStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos, |
| 905 IdGen* id_gen) | 965 IdGen* id_gen) |
| 906 : IterationStatement(zone, labels, pos, id_gen), | 966 : IterationStatement(zone, labels, pos, id_gen), |
| 907 each_(NULL), | 967 each_(NULL), |
| 908 subject_(NULL) {} | 968 subject_(NULL) {} |
| 909 | 969 |
| 970 NEXT_ID_FUNC_BASE(IterationStatement) |
| 971 |
| 910 private: | 972 private: |
| 911 Expression* each_; | 973 Expression* each_; |
| 912 Expression* subject_; | 974 Expression* subject_; |
| 975 |
| 976 static const int kClassIdRange = 0; // No ids |
| 913 }; | 977 }; |
| 914 | 978 |
| 915 | 979 |
| 916 class ForInStatement FINAL : public ForEachStatement, | 980 class ForInStatement FINAL : public ForEachStatement, |
| 917 public FeedbackSlotInterface { | 981 public FeedbackSlotInterface { |
| 918 public: | 982 public: |
| 919 DECLARE_NODE_TYPE(ForInStatement) | 983 DECLARE_NODE_TYPE(ForInStatement) |
| 920 | 984 |
| 921 Expression* enumerable() const { | 985 Expression* enumerable() const { |
| 922 return subject(); | 986 return subject(); |
| 923 } | 987 } |
| 924 | 988 |
| 925 // Type feedback information. | 989 // Type feedback information. |
| 926 virtual int ComputeFeedbackSlotCount() { return 1; } | 990 virtual int ComputeFeedbackSlotCount() { return 1; } |
| 927 virtual void SetFirstFeedbackSlot(int slot) { for_in_feedback_slot_ = slot; } | 991 virtual void SetFirstFeedbackSlot(int slot) { for_in_feedback_slot_ = slot; } |
| 928 | 992 |
| 929 int ForInFeedbackSlot() { | 993 int ForInFeedbackSlot() { |
| 930 DCHECK(for_in_feedback_slot_ != kInvalidFeedbackSlot); | 994 DCHECK(for_in_feedback_slot_ != kInvalidFeedbackSlot); |
| 931 return for_in_feedback_slot_; | 995 return for_in_feedback_slot_; |
| 932 } | 996 } |
| 933 | 997 |
| 934 enum ForInType { FAST_FOR_IN, SLOW_FOR_IN }; | 998 enum ForInType { FAST_FOR_IN, SLOW_FOR_IN }; |
| 935 ForInType for_in_type() const { return for_in_type_; } | 999 ForInType for_in_type() const { return for_in_type_; } |
| 936 void set_for_in_type(ForInType type) { for_in_type_ = type; } | 1000 void set_for_in_type(ForInType type) { for_in_type_ = type; } |
| 937 | 1001 |
| 938 BailoutId BodyId() const { return body_id_; } | 1002 BailoutId BodyId() const { return BailoutId(NEXT_ID(ForEachStatement)); } |
| 939 BailoutId PrepareId() const { return prepare_id_; } | 1003 BailoutId PrepareId() const { |
| 1004 return BailoutId(NEXT_ID(ForEachStatement) + 1); |
| 1005 } |
| 940 virtual BailoutId ContinueId() const OVERRIDE { return EntryId(); } | 1006 virtual BailoutId ContinueId() const OVERRIDE { return EntryId(); } |
| 941 virtual BailoutId StackCheckId() const OVERRIDE { return body_id_; } | 1007 virtual BailoutId StackCheckId() const OVERRIDE { return BodyId(); } |
| 942 | 1008 |
| 943 protected: | 1009 protected: |
| 944 ForInStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos, | 1010 ForInStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos, |
| 945 IdGen* id_gen) | 1011 IdGen* id_gen) |
| 946 : ForEachStatement(zone, labels, pos, id_gen), | 1012 : ForEachStatement(zone, labels, pos, id_gen), |
| 947 for_in_type_(SLOW_FOR_IN), | 1013 for_in_type_(SLOW_FOR_IN), |
| 948 for_in_feedback_slot_(kInvalidFeedbackSlot), | 1014 for_in_feedback_slot_(kInvalidFeedbackSlot) { |
| 949 body_id_(id_gen->GetNextId()), | 1015 #ifdef DEBUG |
| 950 prepare_id_(id_gen->GetNextId()) {} | 1016 int body_id = |
| 1017 #endif |
| 1018 RESERVE_ID_RANGE(); |
| 1019 DCHECK(body_id == BodyId().ToInt()); |
| 1020 } |
| 951 | 1021 |
| 952 ForInType for_in_type_; | 1022 ForInType for_in_type_; |
| 953 int for_in_feedback_slot_; | 1023 int for_in_feedback_slot_; |
| 954 const BailoutId body_id_; | 1024 |
| 955 const BailoutId prepare_id_; | 1025 private: |
| 1026 static const int kClassIdRange = 2; // Body and prepare ids |
| 956 }; | 1027 }; |
| 957 | 1028 |
| 958 | 1029 |
| 959 class ForOfStatement FINAL : public ForEachStatement { | 1030 class ForOfStatement FINAL : public ForEachStatement { |
| 960 public: | 1031 public: |
| 961 DECLARE_NODE_TYPE(ForOfStatement) | 1032 DECLARE_NODE_TYPE(ForOfStatement) |
| 962 | 1033 |
| 963 void Initialize(Expression* each, | 1034 void Initialize(Expression* each, |
| 964 Expression* subject, | 1035 Expression* subject, |
| 965 Statement* body, | 1036 Statement* body, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 994 } | 1065 } |
| 995 | 1066 |
| 996 // each = result.value | 1067 // each = result.value |
| 997 Expression* assign_each() const { | 1068 Expression* assign_each() const { |
| 998 return assign_each_; | 1069 return assign_each_; |
| 999 } | 1070 } |
| 1000 | 1071 |
| 1001 virtual BailoutId ContinueId() const OVERRIDE { return EntryId(); } | 1072 virtual BailoutId ContinueId() const OVERRIDE { return EntryId(); } |
| 1002 virtual BailoutId StackCheckId() const OVERRIDE { return BackEdgeId(); } | 1073 virtual BailoutId StackCheckId() const OVERRIDE { return BackEdgeId(); } |
| 1003 | 1074 |
| 1004 BailoutId BackEdgeId() const { return back_edge_id_; } | 1075 BailoutId BackEdgeId() const { return BailoutId(NEXT_ID(ForEachStatement)); } |
| 1005 | 1076 |
| 1006 protected: | 1077 protected: |
| 1007 ForOfStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos, | 1078 ForOfStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos, |
| 1008 IdGen* id_gen) | 1079 IdGen* id_gen) |
| 1009 : ForEachStatement(zone, labels, pos, id_gen), | 1080 : ForEachStatement(zone, labels, pos, id_gen), |
| 1010 assign_iterator_(NULL), | 1081 assign_iterator_(NULL), |
| 1011 next_result_(NULL), | 1082 next_result_(NULL), |
| 1012 result_done_(NULL), | 1083 result_done_(NULL), |
| 1013 assign_each_(NULL), | 1084 assign_each_(NULL) { |
| 1014 back_edge_id_(id_gen->GetNextId()) {} | 1085 #ifdef DEBUG |
| 1086 int back_edge_id = |
| 1087 #endif |
| 1088 RESERVE_ID_RANGE(); |
| 1089 DCHECK(back_edge_id == BackEdgeId().ToInt()); |
| 1090 } |
| 1015 | 1091 |
| 1016 Expression* assign_iterator_; | 1092 Expression* assign_iterator_; |
| 1017 Expression* next_result_; | 1093 Expression* next_result_; |
| 1018 Expression* result_done_; | 1094 Expression* result_done_; |
| 1019 Expression* assign_each_; | 1095 Expression* assign_each_; |
| 1020 const BailoutId back_edge_id_; | 1096 |
| 1097 private: |
| 1098 static const int kClassIdRange = 1; // Back edge id |
| 1021 }; | 1099 }; |
| 1022 | 1100 |
| 1023 | 1101 |
| 1024 class ExpressionStatement FINAL : public Statement { | 1102 class ExpressionStatement FINAL : public Statement { |
| 1025 public: | 1103 public: |
| 1026 DECLARE_NODE_TYPE(ExpressionStatement) | 1104 DECLARE_NODE_TYPE(ExpressionStatement) |
| 1027 | 1105 |
| 1028 void set_expression(Expression* e) { expression_ = e; } | 1106 void set_expression(Expression* e) { expression_ = e; } |
| 1029 Expression* expression() const { return expression_; } | 1107 Expression* expression() const { return expression_; } |
| 1030 virtual bool IsJump() const OVERRIDE { return expression_->IsThrow(); } | 1108 virtual bool IsJump() const OVERRIDE { return expression_->IsThrow(); } |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1121 DECLARE_NODE_TYPE(CaseClause) | 1199 DECLARE_NODE_TYPE(CaseClause) |
| 1122 | 1200 |
| 1123 bool is_default() const { return label_ == NULL; } | 1201 bool is_default() const { return label_ == NULL; } |
| 1124 Expression* label() const { | 1202 Expression* label() const { |
| 1125 CHECK(!is_default()); | 1203 CHECK(!is_default()); |
| 1126 return label_; | 1204 return label_; |
| 1127 } | 1205 } |
| 1128 Label* body_target() { return &body_target_; } | 1206 Label* body_target() { return &body_target_; } |
| 1129 ZoneList<Statement*>* statements() const { return statements_; } | 1207 ZoneList<Statement*>* statements() const { return statements_; } |
| 1130 | 1208 |
| 1131 BailoutId EntryId() const { return entry_id_; } | 1209 BailoutId EntryId() const { return BailoutId(NEXT_ID(Expression) + 1); } |
| 1132 | 1210 |
| 1133 // Type feedback information. | 1211 // Type feedback information. |
| 1134 TypeFeedbackId CompareId() { return compare_id_; } | 1212 TypeFeedbackId CompareId() { return TypeFeedbackId(NEXT_ID(Expression)); } |
| 1135 Type* compare_type() { return compare_type_; } | 1213 Type* compare_type() { return compare_type_; } |
| 1136 void set_compare_type(Type* type) { compare_type_ = type; } | 1214 void set_compare_type(Type* type) { compare_type_ = type; } |
| 1137 | 1215 |
| 1138 private: | 1216 private: |
| 1139 CaseClause(Zone* zone, Expression* label, ZoneList<Statement*>* statements, | 1217 CaseClause(Zone* zone, Expression* label, ZoneList<Statement*>* statements, |
| 1140 int pos, IdGen* id_gen); | 1218 int pos, IdGen* id_gen); |
| 1141 | 1219 |
| 1142 Expression* label_; | 1220 Expression* label_; |
| 1143 Label body_target_; | 1221 Label body_target_; |
| 1144 ZoneList<Statement*>* statements_; | 1222 ZoneList<Statement*>* statements_; |
| 1145 Type* compare_type_; | 1223 Type* compare_type_; |
| 1146 | 1224 |
| 1147 const TypeFeedbackId compare_id_; | 1225 static const int kClassIdRange = 2; // Compare and entry ids |
| 1148 const BailoutId entry_id_; | |
| 1149 }; | 1226 }; |
| 1150 | 1227 |
| 1151 | 1228 |
| 1152 class SwitchStatement FINAL : public BreakableStatement { | 1229 class SwitchStatement FINAL : public BreakableStatement { |
| 1153 public: | 1230 public: |
| 1154 DECLARE_NODE_TYPE(SwitchStatement) | 1231 DECLARE_NODE_TYPE(SwitchStatement) |
| 1155 | 1232 |
| 1156 void Initialize(Expression* tag, ZoneList<CaseClause*>* cases) { | 1233 void Initialize(Expression* tag, ZoneList<CaseClause*>* cases) { |
| 1157 tag_ = tag; | 1234 tag_ = tag; |
| 1158 cases_ = cases; | 1235 cases_ = cases; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1189 Expression* condition() const { return condition_; } | 1266 Expression* condition() const { return condition_; } |
| 1190 Statement* then_statement() const { return then_statement_; } | 1267 Statement* then_statement() const { return then_statement_; } |
| 1191 Statement* else_statement() const { return else_statement_; } | 1268 Statement* else_statement() const { return else_statement_; } |
| 1192 | 1269 |
| 1193 virtual bool IsJump() const OVERRIDE { | 1270 virtual bool IsJump() const OVERRIDE { |
| 1194 return HasThenStatement() && then_statement()->IsJump() | 1271 return HasThenStatement() && then_statement()->IsJump() |
| 1195 && HasElseStatement() && else_statement()->IsJump(); | 1272 && HasElseStatement() && else_statement()->IsJump(); |
| 1196 } | 1273 } |
| 1197 | 1274 |
| 1198 BailoutId IfId() const { return if_id_; } | 1275 BailoutId IfId() const { return if_id_; } |
| 1199 BailoutId ThenId() const { return then_id_; } | 1276 BailoutId ThenId() const { return BailoutId(if_id_.ToInt() + 1); } |
| 1200 BailoutId ElseId() const { return else_id_; } | 1277 BailoutId ElseId() const { return BailoutId(if_id_.ToInt() + 2); } |
| 1201 | 1278 |
| 1202 protected: | 1279 protected: |
| 1203 IfStatement(Zone* zone, Expression* condition, Statement* then_statement, | 1280 IfStatement(Zone* zone, Expression* condition, Statement* then_statement, |
| 1204 Statement* else_statement, int pos, IdGen* id_gen) | 1281 Statement* else_statement, int pos, IdGen* id_gen) |
| 1205 : Statement(zone, pos), | 1282 : Statement(zone, pos), |
| 1206 condition_(condition), | 1283 condition_(condition), |
| 1207 then_statement_(then_statement), | 1284 then_statement_(then_statement), |
| 1208 else_statement_(else_statement), | 1285 else_statement_(else_statement), |
| 1209 if_id_(id_gen->GetNextId()), | 1286 if_id_(RESERVE_ID_RANGE()) {} |
| 1210 then_id_(id_gen->GetNextId()), | |
| 1211 else_id_(id_gen->GetNextId()) {} | |
| 1212 | 1287 |
| 1213 private: | 1288 private: |
| 1214 Expression* condition_; | 1289 Expression* condition_; |
| 1215 Statement* then_statement_; | 1290 Statement* then_statement_; |
| 1216 Statement* else_statement_; | 1291 Statement* else_statement_; |
| 1217 const BailoutId if_id_; | 1292 const BailoutId if_id_; |
| 1218 const BailoutId then_id_; | 1293 |
| 1219 const BailoutId else_id_; | 1294 static const int kClassIdRange = 3; // If, then, else ids |
| 1220 }; | 1295 }; |
| 1221 | 1296 |
| 1222 | 1297 |
| 1223 // NOTE: TargetCollectors are represented as nodes to fit in the target | 1298 // NOTE: TargetCollectors are represented as nodes to fit in the target |
| 1224 // stack in the compiler; this should probably be reworked. | 1299 // stack in the compiler; this should probably be reworked. |
| 1225 class TargetCollector FINAL : public AstNode { | 1300 class TargetCollector FINAL : public AstNode { |
| 1226 public: | 1301 public: |
| 1227 explicit TargetCollector(Zone* zone) | 1302 explicit TargetCollector(Zone* zone) |
| 1228 : AstNode(RelocInfo::kNoPosition), targets_(0, zone) { } | 1303 : AstNode(RelocInfo::kNoPosition), targets_(0, zone) { } |
| 1229 | 1304 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1317 | 1392 |
| 1318 | 1393 |
| 1319 class DebuggerStatement FINAL : public Statement { | 1394 class DebuggerStatement FINAL : public Statement { |
| 1320 public: | 1395 public: |
| 1321 DECLARE_NODE_TYPE(DebuggerStatement) | 1396 DECLARE_NODE_TYPE(DebuggerStatement) |
| 1322 | 1397 |
| 1323 BailoutId DebugBreakId() const { return debugger_id_; } | 1398 BailoutId DebugBreakId() const { return debugger_id_; } |
| 1324 | 1399 |
| 1325 protected: | 1400 protected: |
| 1326 explicit DebuggerStatement(Zone* zone, int pos, IdGen* id_gen) | 1401 explicit DebuggerStatement(Zone* zone, int pos, IdGen* id_gen) |
| 1327 : Statement(zone, pos), debugger_id_(id_gen->GetNextId()) {} | 1402 : Statement(zone, pos), debugger_id_(id_gen->ReserveIdRange(1)) {} |
| 1328 | 1403 |
| 1329 private: | 1404 private: |
| 1330 const BailoutId debugger_id_; | 1405 const BailoutId debugger_id_; |
| 1331 }; | 1406 }; |
| 1332 | 1407 |
| 1333 | 1408 |
| 1334 class EmptyStatement FINAL : public Statement { | 1409 class EmptyStatement FINAL : public Statement { |
| 1335 public: | 1410 public: |
| 1336 DECLARE_NODE_TYPE(EmptyStatement) | 1411 DECLARE_NODE_TYPE(EmptyStatement) |
| 1337 | 1412 |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1671 | 1746 |
| 1672 class Property FINAL : public Expression, public FeedbackSlotInterface { | 1747 class Property FINAL : public Expression, public FeedbackSlotInterface { |
| 1673 public: | 1748 public: |
| 1674 DECLARE_NODE_TYPE(Property) | 1749 DECLARE_NODE_TYPE(Property) |
| 1675 | 1750 |
| 1676 virtual bool IsValidReferenceExpression() const OVERRIDE { return true; } | 1751 virtual bool IsValidReferenceExpression() const OVERRIDE { return true; } |
| 1677 | 1752 |
| 1678 Expression* obj() const { return obj_; } | 1753 Expression* obj() const { return obj_; } |
| 1679 Expression* key() const { return key_; } | 1754 Expression* key() const { return key_; } |
| 1680 | 1755 |
| 1681 BailoutId LoadId() const { return load_id_; } | 1756 BailoutId LoadId() const { return BailoutId(NEXT_ID(Expression)); } |
| 1682 | 1757 |
| 1683 bool IsStringAccess() const { return is_string_access_; } | 1758 bool IsStringAccess() const { return is_string_access_; } |
| 1684 | 1759 |
| 1685 // Type feedback information. | 1760 // Type feedback information. |
| 1686 virtual bool IsMonomorphic() OVERRIDE { | 1761 virtual bool IsMonomorphic() OVERRIDE { |
| 1687 return receiver_types_.length() == 1; | 1762 return receiver_types_.length() == 1; |
| 1688 } | 1763 } |
| 1689 virtual SmallMapList* GetReceiverTypes() OVERRIDE { | 1764 virtual SmallMapList* GetReceiverTypes() OVERRIDE { |
| 1690 return &receiver_types_; | 1765 return &receiver_types_; |
| 1691 } | 1766 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1712 property_feedback_slot_ = slot; | 1787 property_feedback_slot_ = slot; |
| 1713 } | 1788 } |
| 1714 | 1789 |
| 1715 int PropertyFeedbackSlot() const { return property_feedback_slot_; } | 1790 int PropertyFeedbackSlot() const { return property_feedback_slot_; } |
| 1716 | 1791 |
| 1717 protected: | 1792 protected: |
| 1718 Property(Zone* zone, Expression* obj, Expression* key, int pos, IdGen* id_gen) | 1793 Property(Zone* zone, Expression* obj, Expression* key, int pos, IdGen* id_gen) |
| 1719 : Expression(zone, pos, id_gen), | 1794 : Expression(zone, pos, id_gen), |
| 1720 obj_(obj), | 1795 obj_(obj), |
| 1721 key_(key), | 1796 key_(key), |
| 1722 load_id_(id_gen->GetNextId()), | |
| 1723 property_feedback_slot_(kInvalidFeedbackSlot), | 1797 property_feedback_slot_(kInvalidFeedbackSlot), |
| 1724 is_for_call_(false), | 1798 is_for_call_(false), |
| 1725 is_uninitialized_(false), | 1799 is_uninitialized_(false), |
| 1726 is_string_access_(false) {} | 1800 is_string_access_(false) { |
| 1801 #ifdef DEBUG |
| 1802 int load_id = |
| 1803 #endif |
| 1804 RESERVE_ID_RANGE(); |
| 1805 DCHECK(load_id == LoadId().ToInt()); |
| 1806 } |
| 1727 | 1807 |
| 1728 private: | 1808 private: |
| 1729 Expression* obj_; | 1809 Expression* obj_; |
| 1730 Expression* key_; | 1810 Expression* key_; |
| 1731 const BailoutId load_id_; | |
| 1732 int property_feedback_slot_; | 1811 int property_feedback_slot_; |
| 1733 | 1812 |
| 1734 SmallMapList receiver_types_; | 1813 SmallMapList receiver_types_; |
| 1735 bool is_for_call_ : 1; | 1814 bool is_for_call_ : 1; |
| 1736 bool is_uninitialized_ : 1; | 1815 bool is_uninitialized_ : 1; |
| 1737 bool is_string_access_ : 1; | 1816 bool is_string_access_ : 1; |
| 1817 |
| 1818 static const int kClassIdRange = 1; // Load id |
| 1738 }; | 1819 }; |
| 1739 | 1820 |
| 1740 | 1821 |
| 1741 class Call FINAL : public Expression, public FeedbackSlotInterface { | 1822 class Call FINAL : public Expression, public FeedbackSlotInterface { |
| 1742 public: | 1823 public: |
| 1743 DECLARE_NODE_TYPE(Call) | 1824 DECLARE_NODE_TYPE(Call) |
| 1744 | 1825 |
| 1745 Expression* expression() const { return expression_; } | 1826 Expression* expression() const { return expression_; } |
| 1746 ZoneList<Expression*>* arguments() const { return arguments_; } | 1827 ZoneList<Expression*>* arguments() const { return arguments_; } |
| 1747 | 1828 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1784 Handle<Cell> cell() { return cell_; } | 1865 Handle<Cell> cell() { return cell_; } |
| 1785 | 1866 |
| 1786 Handle<AllocationSite> allocation_site() { return allocation_site_; } | 1867 Handle<AllocationSite> allocation_site() { return allocation_site_; } |
| 1787 | 1868 |
| 1788 void set_target(Handle<JSFunction> target) { target_ = target; } | 1869 void set_target(Handle<JSFunction> target) { target_ = target; } |
| 1789 void set_allocation_site(Handle<AllocationSite> site) { | 1870 void set_allocation_site(Handle<AllocationSite> site) { |
| 1790 allocation_site_ = site; | 1871 allocation_site_ = site; |
| 1791 } | 1872 } |
| 1792 bool ComputeGlobalTarget(Handle<GlobalObject> global, LookupIterator* it); | 1873 bool ComputeGlobalTarget(Handle<GlobalObject> global, LookupIterator* it); |
| 1793 | 1874 |
| 1794 BailoutId ReturnId() const { return return_id_; } | 1875 BailoutId ReturnId() const { return BailoutId(NEXT_ID(Expression)); } |
| 1795 | 1876 |
| 1796 enum CallType { | 1877 enum CallType { |
| 1797 POSSIBLY_EVAL_CALL, | 1878 POSSIBLY_EVAL_CALL, |
| 1798 GLOBAL_CALL, | 1879 GLOBAL_CALL, |
| 1799 LOOKUP_SLOT_CALL, | 1880 LOOKUP_SLOT_CALL, |
| 1800 PROPERTY_CALL, | 1881 PROPERTY_CALL, |
| 1801 OTHER_CALL | 1882 OTHER_CALL |
| 1802 }; | 1883 }; |
| 1803 | 1884 |
| 1804 // Helpers to determine how to handle the call. | 1885 // Helpers to determine how to handle the call. |
| 1805 CallType GetCallType(Isolate* isolate) const; | 1886 CallType GetCallType(Isolate* isolate) const; |
| 1806 bool IsUsingCallFeedbackSlot(Isolate* isolate) const; | 1887 bool IsUsingCallFeedbackSlot(Isolate* isolate) const; |
| 1807 | 1888 |
| 1808 #ifdef DEBUG | 1889 #ifdef DEBUG |
| 1809 // Used to assert that the FullCodeGenerator records the return site. | 1890 // Used to assert that the FullCodeGenerator records the return site. |
| 1810 bool return_is_recorded_; | 1891 bool return_is_recorded_; |
| 1811 #endif | 1892 #endif |
| 1812 | 1893 |
| 1813 protected: | 1894 protected: |
| 1814 Call(Zone* zone, Expression* expression, ZoneList<Expression*>* arguments, | 1895 Call(Zone* zone, Expression* expression, ZoneList<Expression*>* arguments, |
| 1815 int pos, IdGen* id_gen) | 1896 int pos, IdGen* id_gen) |
| 1816 : Expression(zone, pos, id_gen), | 1897 : Expression(zone, pos, id_gen), |
| 1817 expression_(expression), | 1898 expression_(expression), |
| 1818 arguments_(arguments), | 1899 arguments_(arguments), |
| 1819 call_feedback_slot_(kInvalidFeedbackSlot), | 1900 call_feedback_slot_(kInvalidFeedbackSlot) { |
| 1820 return_id_(id_gen->GetNextId()) { | 1901 #ifdef DEBUG |
| 1902 int return_id = |
| 1903 #endif |
| 1904 RESERVE_ID_RANGE(); |
| 1905 DCHECK(return_id == ReturnId().ToInt()); |
| 1821 if (expression->IsProperty()) { | 1906 if (expression->IsProperty()) { |
| 1822 expression->AsProperty()->mark_for_call(); | 1907 expression->AsProperty()->mark_for_call(); |
| 1823 } | 1908 } |
| 1824 } | 1909 } |
| 1825 | 1910 |
| 1826 private: | 1911 private: |
| 1827 Expression* expression_; | 1912 Expression* expression_; |
| 1828 ZoneList<Expression*>* arguments_; | 1913 ZoneList<Expression*>* arguments_; |
| 1829 | 1914 |
| 1830 Handle<JSFunction> target_; | 1915 Handle<JSFunction> target_; |
| 1831 Handle<Cell> cell_; | 1916 Handle<Cell> cell_; |
| 1832 Handle<AllocationSite> allocation_site_; | 1917 Handle<AllocationSite> allocation_site_; |
| 1833 int call_feedback_slot_; | 1918 int call_feedback_slot_; |
| 1834 | 1919 |
| 1835 const BailoutId return_id_; | 1920 static const int kClassIdRange = 1; // Return id |
| 1836 }; | 1921 }; |
| 1837 | 1922 |
| 1838 | 1923 |
| 1839 class CallNew FINAL : public Expression, public FeedbackSlotInterface { | 1924 class CallNew FINAL : public Expression, public FeedbackSlotInterface { |
| 1840 public: | 1925 public: |
| 1841 DECLARE_NODE_TYPE(CallNew) | 1926 DECLARE_NODE_TYPE(CallNew) |
| 1842 | 1927 |
| 1843 Expression* expression() const { return expression_; } | 1928 Expression* expression() const { return expression_; } |
| 1844 ZoneList<Expression*>* arguments() const { return arguments_; } | 1929 ZoneList<Expression*>* arguments() const { return arguments_; } |
| 1845 | 1930 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1864 void RecordTypeFeedback(TypeFeedbackOracle* oracle); | 1949 void RecordTypeFeedback(TypeFeedbackOracle* oracle); |
| 1865 virtual bool IsMonomorphic() OVERRIDE { return is_monomorphic_; } | 1950 virtual bool IsMonomorphic() OVERRIDE { return is_monomorphic_; } |
| 1866 Handle<JSFunction> target() const { return target_; } | 1951 Handle<JSFunction> target() const { return target_; } |
| 1867 ElementsKind elements_kind() const { return elements_kind_; } | 1952 ElementsKind elements_kind() const { return elements_kind_; } |
| 1868 Handle<AllocationSite> allocation_site() const { | 1953 Handle<AllocationSite> allocation_site() const { |
| 1869 return allocation_site_; | 1954 return allocation_site_; |
| 1870 } | 1955 } |
| 1871 | 1956 |
| 1872 static int feedback_slots() { return 1; } | 1957 static int feedback_slots() { return 1; } |
| 1873 | 1958 |
| 1874 BailoutId ReturnId() const { return return_id_; } | 1959 BailoutId ReturnId() const { return BailoutId(NEXT_ID(Expression)); } |
| 1875 | 1960 |
| 1876 protected: | 1961 protected: |
| 1877 CallNew(Zone* zone, Expression* expression, ZoneList<Expression*>* arguments, | 1962 CallNew(Zone* zone, Expression* expression, ZoneList<Expression*>* arguments, |
| 1878 int pos, IdGen* id_gen) | 1963 int pos, IdGen* id_gen) |
| 1879 : Expression(zone, pos, id_gen), | 1964 : Expression(zone, pos, id_gen), |
| 1880 expression_(expression), | 1965 expression_(expression), |
| 1881 arguments_(arguments), | 1966 arguments_(arguments), |
| 1882 is_monomorphic_(false), | 1967 is_monomorphic_(false), |
| 1883 elements_kind_(GetInitialFastElementsKind()), | 1968 elements_kind_(GetInitialFastElementsKind()), |
| 1884 callnew_feedback_slot_(kInvalidFeedbackSlot), | 1969 callnew_feedback_slot_(kInvalidFeedbackSlot) { |
| 1885 return_id_(id_gen->GetNextId()) {} | 1970 #ifdef DEBUG |
| 1971 int return_id = |
| 1972 #endif |
| 1973 RESERVE_ID_RANGE(); |
| 1974 DCHECK(return_id = ReturnId().ToInt()); |
| 1975 } |
| 1886 | 1976 |
| 1887 private: | 1977 private: |
| 1888 Expression* expression_; | 1978 Expression* expression_; |
| 1889 ZoneList<Expression*>* arguments_; | 1979 ZoneList<Expression*>* arguments_; |
| 1890 | 1980 |
| 1891 bool is_monomorphic_; | 1981 bool is_monomorphic_; |
| 1892 Handle<JSFunction> target_; | 1982 Handle<JSFunction> target_; |
| 1893 ElementsKind elements_kind_; | 1983 ElementsKind elements_kind_; |
| 1894 Handle<AllocationSite> allocation_site_; | 1984 Handle<AllocationSite> allocation_site_; |
| 1895 int callnew_feedback_slot_; | 1985 int callnew_feedback_slot_; |
| 1896 | 1986 |
| 1897 const BailoutId return_id_; | 1987 static const int kClassIdRange = 1; // Return id |
| 1898 }; | 1988 }; |
| 1899 | 1989 |
| 1900 | 1990 |
| 1901 // The CallRuntime class does not represent any official JavaScript | 1991 // The CallRuntime class does not represent any official JavaScript |
| 1902 // language construct. Instead it is used to call a C or JS function | 1992 // language construct. Instead it is used to call a C or JS function |
| 1903 // with a set of arguments. This is used from the builtins that are | 1993 // with a set of arguments. This is used from the builtins that are |
| 1904 // implemented in JavaScript (see "v8natives.js"). | 1994 // implemented in JavaScript (see "v8natives.js"). |
| 1905 class CallRuntime FINAL : public Expression, public FeedbackSlotInterface { | 1995 class CallRuntime FINAL : public Expression, public FeedbackSlotInterface { |
| 1906 public: | 1996 public: |
| 1907 DECLARE_NODE_TYPE(CallRuntime) | 1997 DECLARE_NODE_TYPE(CallRuntime) |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1945 }; | 2035 }; |
| 1946 | 2036 |
| 1947 | 2037 |
| 1948 class UnaryOperation FINAL : public Expression { | 2038 class UnaryOperation FINAL : public Expression { |
| 1949 public: | 2039 public: |
| 1950 DECLARE_NODE_TYPE(UnaryOperation) | 2040 DECLARE_NODE_TYPE(UnaryOperation) |
| 1951 | 2041 |
| 1952 Token::Value op() const { return op_; } | 2042 Token::Value op() const { return op_; } |
| 1953 Expression* expression() const { return expression_; } | 2043 Expression* expression() const { return expression_; } |
| 1954 | 2044 |
| 1955 BailoutId MaterializeTrueId() { return materialize_true_id_; } | 2045 // For unary not (Token::NOT), the AST ids where true and false will |
| 1956 BailoutId MaterializeFalseId() { return materialize_false_id_; } | 2046 // actually be materialized, respectively. |
| 2047 BailoutId MaterializeTrueId() { return BailoutId(NEXT_ID(Expression)); } |
| 2048 BailoutId MaterializeFalseId() { return BailoutId(NEXT_ID(Expression) + 1); } |
| 1957 | 2049 |
| 1958 virtual void RecordToBooleanTypeFeedback( | 2050 virtual void RecordToBooleanTypeFeedback( |
| 1959 TypeFeedbackOracle* oracle) OVERRIDE; | 2051 TypeFeedbackOracle* oracle) OVERRIDE; |
| 1960 | 2052 |
| 1961 protected: | 2053 protected: |
| 1962 UnaryOperation(Zone* zone, Token::Value op, Expression* expression, int pos, | 2054 UnaryOperation(Zone* zone, Token::Value op, Expression* expression, int pos, |
| 1963 IdGen* id_gen) | 2055 IdGen* id_gen) |
| 1964 : Expression(zone, pos, id_gen), | 2056 : Expression(zone, pos, id_gen), |
| 1965 op_(op), | 2057 op_(op), |
| 1966 expression_(expression), | 2058 expression_(expression) { |
| 1967 materialize_true_id_(id_gen->GetNextId()), | 2059 #ifdef DEBUG |
| 1968 materialize_false_id_(id_gen->GetNextId()) { | 2060 int materialize_true_id = |
| 2061 #endif |
| 2062 RESERVE_ID_RANGE(); |
| 2063 DCHECK(materialize_true_id == MaterializeTrueId().ToInt()); |
| 1969 DCHECK(Token::IsUnaryOp(op)); | 2064 DCHECK(Token::IsUnaryOp(op)); |
| 1970 } | 2065 } |
| 1971 | 2066 |
| 1972 private: | 2067 private: |
| 1973 Token::Value op_; | 2068 Token::Value op_; |
| 1974 Expression* expression_; | 2069 Expression* expression_; |
| 1975 | 2070 |
| 1976 // For unary not (Token::NOT), the AST ids where true and false will | 2071 static const int kClassIdRange = 2; // Materialize true and false ids |
| 1977 // actually be materialized, respectively. | |
| 1978 const BailoutId materialize_true_id_; | |
| 1979 const BailoutId materialize_false_id_; | |
| 1980 }; | 2072 }; |
| 1981 | 2073 |
| 1982 | 2074 |
| 1983 class BinaryOperation FINAL : public Expression { | 2075 class BinaryOperation FINAL : public Expression { |
| 1984 public: | 2076 public: |
| 1985 DECLARE_NODE_TYPE(BinaryOperation) | 2077 DECLARE_NODE_TYPE(BinaryOperation) |
| 1986 | 2078 |
| 1987 virtual bool ResultOverwriteAllowed() const OVERRIDE; | 2079 virtual bool ResultOverwriteAllowed() const OVERRIDE; |
| 1988 | 2080 |
| 1989 Token::Value op() const { return op_; } | 2081 Token::Value op() const { return op_; } |
| 1990 Expression* left() const { return left_; } | 2082 Expression* left() const { return left_; } |
| 1991 Expression* right() const { return right_; } | 2083 Expression* right() const { return right_; } |
| 1992 Handle<AllocationSite> allocation_site() const { return allocation_site_; } | 2084 Handle<AllocationSite> allocation_site() const { return allocation_site_; } |
| 1993 void set_allocation_site(Handle<AllocationSite> allocation_site) { | 2085 void set_allocation_site(Handle<AllocationSite> allocation_site) { |
| 1994 allocation_site_ = allocation_site; | 2086 allocation_site_ = allocation_site; |
| 1995 } | 2087 } |
| 1996 | 2088 |
| 1997 BailoutId RightId() const { return right_id_; } | 2089 // The short-circuit logical operations need an AST ID for their |
| 2090 // right-hand subexpression. |
| 2091 BailoutId RightId() const { return BailoutId(NEXT_ID(Expression)); } |
| 1998 | 2092 |
| 1999 TypeFeedbackId BinaryOperationFeedbackId() const { return reuse(id()); } | 2093 TypeFeedbackId BinaryOperationFeedbackId() const { return reuse(id()); } |
| 2000 Maybe<int> fixed_right_arg() const { return fixed_right_arg_; } | 2094 Maybe<int> fixed_right_arg() const { return fixed_right_arg_; } |
| 2001 void set_fixed_right_arg(Maybe<int> arg) { fixed_right_arg_ = arg; } | 2095 void set_fixed_right_arg(Maybe<int> arg) { fixed_right_arg_ = arg; } |
| 2002 | 2096 |
| 2003 virtual void RecordToBooleanTypeFeedback( | 2097 virtual void RecordToBooleanTypeFeedback( |
| 2004 TypeFeedbackOracle* oracle) OVERRIDE; | 2098 TypeFeedbackOracle* oracle) OVERRIDE; |
| 2005 | 2099 |
| 2006 protected: | 2100 protected: |
| 2007 BinaryOperation(Zone* zone, Token::Value op, Expression* left, | 2101 BinaryOperation(Zone* zone, Token::Value op, Expression* left, |
| 2008 Expression* right, int pos, IdGen* id_gen) | 2102 Expression* right, int pos, IdGen* id_gen) |
| 2009 : Expression(zone, pos, id_gen), | 2103 : Expression(zone, pos, id_gen), |
| 2010 op_(op), | 2104 op_(op), |
| 2011 left_(left), | 2105 left_(left), |
| 2012 right_(right), | 2106 right_(right) { |
| 2013 right_id_(id_gen->GetNextId()) { | 2107 #ifdef DEBUG |
| 2108 int right_id = |
| 2109 #endif |
| 2110 RESERVE_ID_RANGE(); |
| 2111 DCHECK(right_id == RightId().ToInt()); |
| 2014 DCHECK(Token::IsBinaryOp(op)); | 2112 DCHECK(Token::IsBinaryOp(op)); |
| 2015 } | 2113 } |
| 2016 | 2114 |
| 2017 private: | 2115 private: |
| 2018 Token::Value op_; | 2116 Token::Value op_; |
| 2019 Expression* left_; | 2117 Expression* left_; |
| 2020 Expression* right_; | 2118 Expression* right_; |
| 2021 Handle<AllocationSite> allocation_site_; | 2119 Handle<AllocationSite> allocation_site_; |
| 2022 | 2120 |
| 2023 // TODO(rossberg): the fixed arg should probably be represented as a Constant | 2121 // TODO(rossberg): the fixed arg should probably be represented as a Constant |
| 2024 // type for the RHS. | 2122 // type for the RHS. |
| 2025 Maybe<int> fixed_right_arg_; | 2123 Maybe<int> fixed_right_arg_; |
| 2026 | 2124 |
| 2027 // The short-circuit logical operations need an AST ID for their | 2125 static const int kClassIdRange = 1; // Right id |
| 2028 // right-hand subexpression. | |
| 2029 const BailoutId right_id_; | |
| 2030 }; | 2126 }; |
| 2031 | 2127 |
| 2032 | 2128 |
| 2033 class CountOperation FINAL : public Expression { | 2129 class CountOperation FINAL : public Expression { |
| 2034 public: | 2130 public: |
| 2035 DECLARE_NODE_TYPE(CountOperation) | 2131 DECLARE_NODE_TYPE(CountOperation) |
| 2036 | 2132 |
| 2037 bool is_prefix() const { return is_prefix_; } | 2133 bool is_prefix() const { return is_prefix_; } |
| 2038 bool is_postfix() const { return !is_prefix_; } | 2134 bool is_postfix() const { return !is_prefix_; } |
| 2039 | 2135 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 2050 virtual SmallMapList* GetReceiverTypes() OVERRIDE { | 2146 virtual SmallMapList* GetReceiverTypes() OVERRIDE { |
| 2051 return &receiver_types_; | 2147 return &receiver_types_; |
| 2052 } | 2148 } |
| 2053 virtual KeyedAccessStoreMode GetStoreMode() OVERRIDE { | 2149 virtual KeyedAccessStoreMode GetStoreMode() OVERRIDE { |
| 2054 return store_mode_; | 2150 return store_mode_; |
| 2055 } | 2151 } |
| 2056 Type* type() const { return type_; } | 2152 Type* type() const { return type_; } |
| 2057 void set_store_mode(KeyedAccessStoreMode mode) { store_mode_ = mode; } | 2153 void set_store_mode(KeyedAccessStoreMode mode) { store_mode_ = mode; } |
| 2058 void set_type(Type* type) { type_ = type; } | 2154 void set_type(Type* type) { type_ = type; } |
| 2059 | 2155 |
| 2060 BailoutId AssignmentId() const { return assignment_id_; } | 2156 BailoutId AssignmentId() const { return BailoutId(NEXT_ID(Expression)); } |
| 2061 | 2157 |
| 2062 TypeFeedbackId CountBinOpFeedbackId() const { return count_id_; } | 2158 TypeFeedbackId CountBinOpFeedbackId() const { |
| 2159 return TypeFeedbackId(NEXT_ID(Expression) + 1); |
| 2160 } |
| 2063 TypeFeedbackId CountStoreFeedbackId() const { return reuse(id()); } | 2161 TypeFeedbackId CountStoreFeedbackId() const { return reuse(id()); } |
| 2064 | 2162 |
| 2065 protected: | 2163 protected: |
| 2066 CountOperation(Zone* zone, Token::Value op, bool is_prefix, Expression* expr, | 2164 CountOperation(Zone* zone, Token::Value op, bool is_prefix, Expression* expr, |
| 2067 int pos, IdGen* id_gen) | 2165 int pos, IdGen* id_gen) |
| 2068 : Expression(zone, pos, id_gen), | 2166 : Expression(zone, pos, id_gen), |
| 2069 op_(op), | 2167 op_(op), |
| 2070 is_prefix_(is_prefix), | 2168 is_prefix_(is_prefix), |
| 2071 store_mode_(STANDARD_STORE), | 2169 store_mode_(STANDARD_STORE), |
| 2072 expression_(expr), | 2170 expression_(expr) { |
| 2073 assignment_id_(id_gen->GetNextId()), | 2171 #ifdef DEBUG |
| 2074 count_id_(id_gen->GetNextId()) {} | 2172 int assignment_id = |
| 2173 #endif |
| 2174 RESERVE_ID_RANGE(); |
| 2175 DCHECK(assignment_id == AssignmentId().ToInt()); |
| 2176 } |
| 2075 | 2177 |
| 2076 private: | 2178 private: |
| 2077 Token::Value op_; | 2179 Token::Value op_; |
| 2078 bool is_prefix_ : 1; | 2180 bool is_prefix_ : 1; |
| 2079 KeyedAccessStoreMode store_mode_ : 5; // Windows treats as signed, | 2181 KeyedAccessStoreMode store_mode_ : 5; // Windows treats as signed, |
| 2080 // must have extra bit. | 2182 // must have extra bit. |
| 2081 Type* type_; | 2183 Type* type_; |
| 2082 | 2184 |
| 2083 Expression* expression_; | 2185 Expression* expression_; |
| 2084 const BailoutId assignment_id_; | |
| 2085 const TypeFeedbackId count_id_; | |
| 2086 SmallMapList receiver_types_; | 2186 SmallMapList receiver_types_; |
| 2187 |
| 2188 static const int kClassIdRange = 2; // Assignment and count ids |
| 2087 }; | 2189 }; |
| 2088 | 2190 |
| 2089 | 2191 |
| 2090 class CompareOperation FINAL : public Expression { | 2192 class CompareOperation FINAL : public Expression { |
| 2091 public: | 2193 public: |
| 2092 DECLARE_NODE_TYPE(CompareOperation) | 2194 DECLARE_NODE_TYPE(CompareOperation) |
| 2093 | 2195 |
| 2094 Token::Value op() const { return op_; } | 2196 Token::Value op() const { return op_; } |
| 2095 Expression* left() const { return left_; } | 2197 Expression* left() const { return left_; } |
| 2096 Expression* right() const { return right_; } | 2198 Expression* right() const { return right_; } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 2126 | 2228 |
| 2127 | 2229 |
| 2128 class Conditional FINAL : public Expression { | 2230 class Conditional FINAL : public Expression { |
| 2129 public: | 2231 public: |
| 2130 DECLARE_NODE_TYPE(Conditional) | 2232 DECLARE_NODE_TYPE(Conditional) |
| 2131 | 2233 |
| 2132 Expression* condition() const { return condition_; } | 2234 Expression* condition() const { return condition_; } |
| 2133 Expression* then_expression() const { return then_expression_; } | 2235 Expression* then_expression() const { return then_expression_; } |
| 2134 Expression* else_expression() const { return else_expression_; } | 2236 Expression* else_expression() const { return else_expression_; } |
| 2135 | 2237 |
| 2136 BailoutId ThenId() const { return then_id_; } | 2238 BailoutId ThenId() const { return BailoutId(NEXT_ID(Expression)); } |
| 2137 BailoutId ElseId() const { return else_id_; } | 2239 BailoutId ElseId() const { return BailoutId(NEXT_ID(Expression) + 1); } |
| 2138 | 2240 |
| 2139 protected: | 2241 protected: |
| 2140 Conditional(Zone* zone, Expression* condition, Expression* then_expression, | 2242 Conditional(Zone* zone, Expression* condition, Expression* then_expression, |
| 2141 Expression* else_expression, int position, IdGen* id_gen) | 2243 Expression* else_expression, int position, IdGen* id_gen) |
| 2142 : Expression(zone, position, id_gen), | 2244 : Expression(zone, position, id_gen), |
| 2143 condition_(condition), | 2245 condition_(condition), |
| 2144 then_expression_(then_expression), | 2246 then_expression_(then_expression), |
| 2145 else_expression_(else_expression), | 2247 else_expression_(else_expression) { |
| 2146 then_id_(id_gen->GetNextId()), | 2248 #ifdef DEBUG |
| 2147 else_id_(id_gen->GetNextId()) {} | 2249 int then_id = |
| 2250 #endif |
| 2251 RESERVE_ID_RANGE(); |
| 2252 DCHECK(then_id == ThenId().ToInt()); |
| 2253 } |
| 2148 | 2254 |
| 2149 private: | 2255 private: |
| 2150 Expression* condition_; | 2256 Expression* condition_; |
| 2151 Expression* then_expression_; | 2257 Expression* then_expression_; |
| 2152 Expression* else_expression_; | 2258 Expression* else_expression_; |
| 2153 const BailoutId then_id_; | 2259 |
| 2154 const BailoutId else_id_; | 2260 static const int kClassIdRange = 2; // Then and else ids |
| 2155 }; | 2261 }; |
| 2156 | 2262 |
| 2157 | 2263 |
| 2158 class Assignment FINAL : public Expression { | 2264 class Assignment FINAL : public Expression { |
| 2159 public: | 2265 public: |
| 2160 DECLARE_NODE_TYPE(Assignment) | 2266 DECLARE_NODE_TYPE(Assignment) |
| 2161 | 2267 |
| 2162 Assignment* AsSimpleAssignment() { return !is_compound() ? this : NULL; } | 2268 Assignment* AsSimpleAssignment() { return !is_compound() ? this : NULL; } |
| 2163 | 2269 |
| 2164 Token::Value binary_op() const; | 2270 Token::Value binary_op() const; |
| 2165 | 2271 |
| 2166 Token::Value op() const { return op_; } | 2272 Token::Value op() const { return op_; } |
| 2167 Expression* target() const { return target_; } | 2273 Expression* target() const { return target_; } |
| 2168 Expression* value() const { return value_; } | 2274 Expression* value() const { return value_; } |
| 2169 BinaryOperation* binary_operation() const { return binary_operation_; } | 2275 BinaryOperation* binary_operation() const { return binary_operation_; } |
| 2170 | 2276 |
| 2171 // This check relies on the definition order of token in token.h. | 2277 // This check relies on the definition order of token in token.h. |
| 2172 bool is_compound() const { return op() > Token::ASSIGN; } | 2278 bool is_compound() const { return op() > Token::ASSIGN; } |
| 2173 | 2279 |
| 2174 BailoutId AssignmentId() const { return assignment_id_; } | 2280 BailoutId AssignmentId() const { return BailoutId(NEXT_ID(Expression)); } |
| 2175 | 2281 |
| 2176 // Type feedback information. | 2282 // Type feedback information. |
| 2177 TypeFeedbackId AssignmentFeedbackId() { return reuse(id()); } | 2283 TypeFeedbackId AssignmentFeedbackId() { return reuse(id()); } |
| 2178 virtual bool IsMonomorphic() OVERRIDE { | 2284 virtual bool IsMonomorphic() OVERRIDE { |
| 2179 return receiver_types_.length() == 1; | 2285 return receiver_types_.length() == 1; |
| 2180 } | 2286 } |
| 2181 bool IsUninitialized() { return is_uninitialized_; } | 2287 bool IsUninitialized() { return is_uninitialized_; } |
| 2182 bool HasNoTypeInformation() { | 2288 bool HasNoTypeInformation() { |
| 2183 return is_uninitialized_; | 2289 return is_uninitialized_; |
| 2184 } | 2290 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 2202 binary_operation_ = factory->NewBinaryOperation( | 2308 binary_operation_ = factory->NewBinaryOperation( |
| 2203 binary_op(), target_, value_, position() + 1); | 2309 binary_op(), target_, value_, position() + 1); |
| 2204 } | 2310 } |
| 2205 } | 2311 } |
| 2206 | 2312 |
| 2207 private: | 2313 private: |
| 2208 Token::Value op_; | 2314 Token::Value op_; |
| 2209 Expression* target_; | 2315 Expression* target_; |
| 2210 Expression* value_; | 2316 Expression* value_; |
| 2211 BinaryOperation* binary_operation_; | 2317 BinaryOperation* binary_operation_; |
| 2212 const BailoutId assignment_id_; | |
| 2213 | 2318 |
| 2214 bool is_uninitialized_ : 1; | 2319 bool is_uninitialized_ : 1; |
| 2215 KeyedAccessStoreMode store_mode_ : 5; // Windows treats as signed, | 2320 KeyedAccessStoreMode store_mode_ : 5; // Windows treats as signed, |
| 2216 // must have extra bit. | 2321 // must have extra bit. |
| 2217 SmallMapList receiver_types_; | 2322 SmallMapList receiver_types_; |
| 2323 |
| 2324 static const int kClassIdRange = 1; // Assignment id |
| 2218 }; | 2325 }; |
| 2219 | 2326 |
| 2220 | 2327 |
| 2221 class Yield FINAL : public Expression, public FeedbackSlotInterface { | 2328 class Yield FINAL : public Expression, public FeedbackSlotInterface { |
| 2222 public: | 2329 public: |
| 2223 DECLARE_NODE_TYPE(Yield) | 2330 DECLARE_NODE_TYPE(Yield) |
| 2224 | 2331 |
| 2225 enum Kind { | 2332 enum Kind { |
| 2226 kInitial, // The initial yield that returns the unboxed generator object. | 2333 kInitial, // The initial yield that returns the unboxed generator object. |
| 2227 kSuspend, // A normal yield: { value: EXPRESSION, done: false } | 2334 kSuspend, // A normal yield: { value: EXPRESSION, done: false } |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2538 SuperReference(Zone* zone, VariableProxy* this_var, int pos, IdGen* id_gen) | 2645 SuperReference(Zone* zone, VariableProxy* this_var, int pos, IdGen* id_gen) |
| 2539 : Expression(zone, pos, id_gen), this_var_(this_var) { | 2646 : Expression(zone, pos, id_gen), this_var_(this_var) { |
| 2540 DCHECK(this_var->is_this()); | 2647 DCHECK(this_var->is_this()); |
| 2541 } | 2648 } |
| 2542 | 2649 |
| 2543 VariableProxy* this_var_; | 2650 VariableProxy* this_var_; |
| 2544 }; | 2651 }; |
| 2545 | 2652 |
| 2546 | 2653 |
| 2547 #undef DECLARE_NODE_TYPE | 2654 #undef DECLARE_NODE_TYPE |
| 2655 #undef RESERVE_ID_RANGE |
| 2656 #undef NEXT_ID |
| 2657 #undef NEXT_ID_FUNC |
| 2658 #undef NEXT_ID_FUNC_BASE |
| 2548 | 2659 |
| 2549 | 2660 |
| 2550 // ---------------------------------------------------------------------------- | 2661 // ---------------------------------------------------------------------------- |
| 2551 // Regular expressions | 2662 // Regular expressions |
| 2552 | 2663 |
| 2553 | 2664 |
| 2554 class RegExpVisitor BASE_EMBEDDED { | 2665 class RegExpVisitor BASE_EMBEDDED { |
| 2555 public: | 2666 public: |
| 2556 virtual ~RegExpVisitor() { } | 2667 virtual ~RegExpVisitor() { } |
| 2557 #define MAKE_CASE(Name) \ | 2668 #define MAKE_CASE(Name) \ |
| (...skipping 921 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3479 Zone* zone_; | 3590 Zone* zone_; |
| 3480 Visitor visitor_; | 3591 Visitor visitor_; |
| 3481 AstValueFactory* ast_value_factory_; | 3592 AstValueFactory* ast_value_factory_; |
| 3482 AstNode::IdGen* id_gen_; | 3593 AstNode::IdGen* id_gen_; |
| 3483 }; | 3594 }; |
| 3484 | 3595 |
| 3485 | 3596 |
| 3486 } } // namespace v8::internal | 3597 } } // namespace v8::internal |
| 3487 | 3598 |
| 3488 #endif // V8_AST_H_ | 3599 #endif // V8_AST_H_ |
| OLD | NEW |