Chromium Code Reviews| 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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 174 | 174 |
| 175 private: | 175 private: |
| 176 Flags flags_; | 176 Flags flags_; |
| 177 int node_count_; | 177 int node_count_; |
| 178 int feedback_slots_; | 178 int feedback_slots_; |
| 179 }; | 179 }; |
| 180 | 180 |
| 181 | 181 |
| 182 class AstNode: public ZoneObject { | 182 class AstNode: public ZoneObject { |
| 183 public: | 183 public: |
| 184 // For generating IDs for AstNodes. | |
| 185 class IdGen { | |
| 186 public: | |
| 187 IdGen() : id_(BailoutId::FirstUsable().ToInt()) {} | |
| 188 | |
| 189 int ReserveIdRange(int n) { | |
| 190 int tmp = id_; | |
| 191 id_ += n; | |
| 192 return tmp; | |
| 193 } | |
| 194 | |
| 195 private: | |
| 196 int id_; | |
| 197 | |
| 198 DISALLOW_COPY_AND_ASSIGN(IdGen); | |
| 199 }; | |
| 200 | |
| 201 #define DECLARE_TYPE_ENUM(type) k##type, | 184 #define DECLARE_TYPE_ENUM(type) k##type, |
| 202 enum NodeType { | 185 enum NodeType { |
| 203 AST_NODE_LIST(DECLARE_TYPE_ENUM) | 186 AST_NODE_LIST(DECLARE_TYPE_ENUM) |
| 204 kInvalid = -1 | 187 kInvalid = -1 |
| 205 }; | 188 }; |
| 206 #undef DECLARE_TYPE_ENUM | 189 #undef DECLARE_TYPE_ENUM |
| 207 | 190 |
| 208 void* operator new(size_t size, Zone* zone) { | 191 void* operator new(size_t size, Zone* zone) { |
| 209 return zone->New(static_cast<int>(size)); | 192 return zone->New(static_cast<int>(size)); |
| 210 } | 193 } |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 375 } | 358 } |
| 376 virtual KeyedAccessStoreMode GetStoreMode() { | 359 virtual KeyedAccessStoreMode GetStoreMode() { |
| 377 UNREACHABLE(); | 360 UNREACHABLE(); |
| 378 return STANDARD_STORE; | 361 return STANDARD_STORE; |
| 379 } | 362 } |
| 380 | 363 |
| 381 // TODO(rossberg): this should move to its own AST node eventually. | 364 // TODO(rossberg): this should move to its own AST node eventually. |
| 382 virtual void RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle); | 365 virtual void RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle); |
| 383 byte to_boolean_types() const { return to_boolean_types_; } | 366 byte to_boolean_types() const { return to_boolean_types_; } |
| 384 | 367 |
| 385 BailoutId id() const { return BailoutId(base_id() + 0); } | 368 void set_base_id(int id) { base_id_ = id; } |
| 386 TypeFeedbackId test_id() const { return TypeFeedbackId(base_id() + 1); } | 369 static int num_ids() { return parent_num_ids() + 2; } |
| 370 BailoutId id() const { return BailoutId(local_id(0)); } | |
| 371 TypeFeedbackId test_id() const { return TypeFeedbackId(local_id(1)); } | |
| 387 | 372 |
| 388 protected: | 373 protected: |
| 389 Expression(Zone* zone, int pos, int num_ids_needed_by_subclass, IdGen* id_gen) | 374 Expression(Zone* zone, int pos) |
| 390 : AstNode(pos), | 375 : AstNode(pos), |
| 391 is_parenthesized_(false), | 376 is_parenthesized_(false), |
| 392 is_multi_parenthesized_(false), | 377 is_multi_parenthesized_(false), |
| 393 bounds_(Bounds::Unbounded(zone)), | 378 bounds_(Bounds::Unbounded(zone)), |
| 394 base_id_( | 379 base_id_(INT_MIN) {} |
|
Sven Panne
2014/10/15 07:41:56
Hmmm, INT_MIN is a bit ugly, I think just using -1
wingo
2014/10/15 13:53:19
Done. I kept the initialization as the check help
| |
| 395 id_gen->ReserveIdRange(num_ids_needed_by_subclass + num_ids())) {} | 380 static int parent_num_ids() { return 0; } |
| 396 void set_to_boolean_types(byte types) { to_boolean_types_ = types; } | 381 void set_to_boolean_types(byte types) { to_boolean_types_ = types; } |
| 397 | 382 |
| 398 static int num_ids() { return 2; } | 383 int base_id() const { |
| 399 int base_id() const { return base_id_; } | 384 DCHECK(base_id_ >= 0); |
| 385 return base_id_; | |
| 386 } | |
| 400 | 387 |
| 401 private: | 388 private: |
| 389 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | |
| 390 | |
| 402 byte to_boolean_types_; | 391 byte to_boolean_types_; |
| 403 bool is_parenthesized_ : 1; | 392 bool is_parenthesized_ : 1; |
| 404 bool is_multi_parenthesized_ : 1; | 393 bool is_multi_parenthesized_ : 1; |
| 405 Bounds bounds_; | 394 Bounds bounds_; |
| 406 const int base_id_; | 395 int base_id_; |
| 407 }; | 396 }; |
| 408 | 397 |
| 409 | 398 |
| 410 class BreakableStatement : public Statement { | 399 class BreakableStatement : public Statement { |
| 411 public: | 400 public: |
| 412 enum BreakableType { | 401 enum BreakableType { |
| 413 TARGET_FOR_ANONYMOUS, | 402 TARGET_FOR_ANONYMOUS, |
| 414 TARGET_FOR_NAMED_ONLY | 403 TARGET_FOR_NAMED_ONLY |
| 415 }; | 404 }; |
| 416 | 405 |
| 417 // The labels associated with this statement. May be NULL; | 406 // The labels associated with this statement. May be NULL; |
| 418 // if it is != NULL, guaranteed to contain at least one entry. | 407 // if it is != NULL, guaranteed to contain at least one entry. |
| 419 ZoneList<const AstRawString*>* labels() const { return labels_; } | 408 ZoneList<const AstRawString*>* labels() const { return labels_; } |
| 420 | 409 |
| 421 // Type testing & conversion. | 410 // Type testing & conversion. |
| 422 virtual BreakableStatement* AsBreakableStatement() FINAL OVERRIDE { | 411 virtual BreakableStatement* AsBreakableStatement() FINAL OVERRIDE { |
| 423 return this; | 412 return this; |
| 424 } | 413 } |
| 425 | 414 |
| 426 // Code generation | 415 // Code generation |
| 427 Label* break_target() { return &break_target_; } | 416 Label* break_target() { return &break_target_; } |
| 428 | 417 |
| 429 // Testers. | 418 // Testers. |
| 430 bool is_target_for_anonymous() const { | 419 bool is_target_for_anonymous() const { |
| 431 return breakable_type_ == TARGET_FOR_ANONYMOUS; | 420 return breakable_type_ == TARGET_FOR_ANONYMOUS; |
| 432 } | 421 } |
| 433 | 422 |
| 434 BailoutId EntryId() const { return BailoutId(base_id() + 0); } | 423 void set_base_id(int id) { base_id_ = id; } |
| 435 BailoutId ExitId() const { return BailoutId(base_id() + 1); } | 424 static int num_ids() { return parent_num_ids() + 2; } |
| 425 BailoutId EntryId() const { return BailoutId(local_id(0)); } | |
| 426 BailoutId ExitId() const { return BailoutId(local_id(1)); } | |
| 436 | 427 |
| 437 protected: | 428 protected: |
| 438 BreakableStatement(Zone* zone, ZoneList<const AstRawString*>* labels, | 429 BreakableStatement(Zone* zone, ZoneList<const AstRawString*>* labels, |
| 439 BreakableType breakable_type, int position, | 430 BreakableType breakable_type, int position) |
| 440 int num_ids_needed_by_subclass, IdGen* id_gen) | |
| 441 : Statement(zone, position), | 431 : Statement(zone, position), |
| 442 labels_(labels), | 432 labels_(labels), |
| 443 breakable_type_(breakable_type), | 433 breakable_type_(breakable_type), |
| 444 base_id_( | 434 base_id_(INT_MIN) { |
| 445 id_gen->ReserveIdRange(num_ids_needed_by_subclass + num_ids())) { | |
| 446 DCHECK(labels == NULL || labels->length() > 0); | 435 DCHECK(labels == NULL || labels->length() > 0); |
| 447 } | 436 } |
| 437 static int parent_num_ids() { return 0; } | |
| 448 | 438 |
| 449 static int num_ids() { return 2; } | 439 int base_id() const { |
| 450 int base_id() const { return base_id_; } | 440 DCHECK(base_id_ >= 0); |
| 441 return base_id_; | |
| 442 } | |
| 451 | 443 |
| 452 private: | 444 private: |
| 445 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | |
| 446 | |
| 453 ZoneList<const AstRawString*>* labels_; | 447 ZoneList<const AstRawString*>* labels_; |
| 454 BreakableType breakable_type_; | 448 BreakableType breakable_type_; |
| 455 Label break_target_; | 449 Label break_target_; |
| 456 const int base_id_; | 450 int base_id_; |
| 457 }; | 451 }; |
| 458 | 452 |
| 459 | 453 |
| 460 class Block FINAL : public BreakableStatement { | 454 class Block FINAL : public BreakableStatement { |
| 461 public: | 455 public: |
| 462 DECLARE_NODE_TYPE(Block) | 456 DECLARE_NODE_TYPE(Block) |
| 463 | 457 |
| 464 void AddStatement(Statement* statement, Zone* zone) { | 458 void AddStatement(Statement* statement, Zone* zone) { |
| 465 statements_.Add(statement, zone); | 459 statements_.Add(statement, zone); |
| 466 } | 460 } |
| 467 | 461 |
| 468 ZoneList<Statement*>* statements() { return &statements_; } | 462 ZoneList<Statement*>* statements() { return &statements_; } |
| 469 bool is_initializer_block() const { return is_initializer_block_; } | 463 bool is_initializer_block() const { return is_initializer_block_; } |
| 470 | 464 |
| 471 BailoutId DeclsId() const { return BailoutId(base_id() + 0); } | 465 static int num_ids() { return parent_num_ids() + 1; } |
| 466 BailoutId DeclsId() const { return BailoutId(local_id(0)); } | |
| 472 | 467 |
| 473 virtual bool IsJump() const OVERRIDE { | 468 virtual bool IsJump() const OVERRIDE { |
| 474 return !statements_.is_empty() && statements_.last()->IsJump() | 469 return !statements_.is_empty() && statements_.last()->IsJump() |
| 475 && labels() == NULL; // Good enough as an approximation... | 470 && labels() == NULL; // Good enough as an approximation... |
| 476 } | 471 } |
| 477 | 472 |
| 478 Scope* scope() const { return scope_; } | 473 Scope* scope() const { return scope_; } |
| 479 void set_scope(Scope* scope) { scope_ = scope; } | 474 void set_scope(Scope* scope) { scope_ = scope; } |
| 480 | 475 |
| 481 protected: | 476 protected: |
| 482 Block(Zone* zone, ZoneList<const AstRawString*>* labels, int capacity, | 477 Block(Zone* zone, ZoneList<const AstRawString*>* labels, int capacity, |
| 483 bool is_initializer_block, int pos, IdGen* id_gen) | 478 bool is_initializer_block, int pos) |
| 484 : BreakableStatement(zone, labels, TARGET_FOR_NAMED_ONLY, pos, num_ids(), | 479 : BreakableStatement(zone, labels, TARGET_FOR_NAMED_ONLY, pos), |
| 485 id_gen), | |
| 486 statements_(capacity, zone), | 480 statements_(capacity, zone), |
| 487 is_initializer_block_(is_initializer_block), | 481 is_initializer_block_(is_initializer_block), |
| 488 scope_(NULL) {} | 482 scope_(NULL) {} |
| 489 | 483 static int parent_num_ids() { return BreakableStatement::num_ids(); } |
| 490 static int num_ids() { return 1; } | |
| 491 int base_id() const { | |
| 492 return BreakableStatement::base_id() + BreakableStatement::num_ids(); | |
| 493 } | |
| 494 | 484 |
| 495 private: | 485 private: |
| 486 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | |
| 487 | |
| 496 ZoneList<Statement*> statements_; | 488 ZoneList<Statement*> statements_; |
| 497 bool is_initializer_block_; | 489 bool is_initializer_block_; |
| 498 Scope* scope_; | 490 Scope* scope_; |
| 499 }; | 491 }; |
| 500 | 492 |
| 501 | 493 |
| 502 class Declaration : public AstNode { | 494 class Declaration : public AstNode { |
| 503 public: | 495 public: |
| 504 VariableProxy* proxy() const { return proxy_; } | 496 VariableProxy* proxy() const { return proxy_; } |
| 505 VariableMode mode() const { return mode_; } | 497 VariableMode mode() const { return mode_; } |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 739 | 731 |
| 740 class IterationStatement : public BreakableStatement { | 732 class IterationStatement : public BreakableStatement { |
| 741 public: | 733 public: |
| 742 // Type testing & conversion. | 734 // Type testing & conversion. |
| 743 virtual IterationStatement* AsIterationStatement() FINAL OVERRIDE { | 735 virtual IterationStatement* AsIterationStatement() FINAL OVERRIDE { |
| 744 return this; | 736 return this; |
| 745 } | 737 } |
| 746 | 738 |
| 747 Statement* body() const { return body_; } | 739 Statement* body() const { return body_; } |
| 748 | 740 |
| 749 BailoutId OsrEntryId() const { return BailoutId(base_id() + 0); } | 741 static int num_ids() { return parent_num_ids() + 1; } |
| 742 BailoutId OsrEntryId() const { return BailoutId(local_id(0)); } | |
| 750 virtual BailoutId ContinueId() const = 0; | 743 virtual BailoutId ContinueId() const = 0; |
| 751 virtual BailoutId StackCheckId() const = 0; | 744 virtual BailoutId StackCheckId() const = 0; |
| 752 | 745 |
| 753 // Code generation | 746 // Code generation |
| 754 Label* continue_target() { return &continue_target_; } | 747 Label* continue_target() { return &continue_target_; } |
| 755 | 748 |
| 756 protected: | 749 protected: |
| 757 IterationStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos, | 750 IterationStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) |
| 758 int num_ids_needed_by_subclass, IdGen* id_gen) | 751 : BreakableStatement(zone, labels, TARGET_FOR_ANONYMOUS, pos), |
| 759 : BreakableStatement(zone, labels, TARGET_FOR_ANONYMOUS, pos, | |
| 760 num_ids_needed_by_subclass + num_ids(), id_gen), | |
| 761 body_(NULL) {} | 752 body_(NULL) {} |
| 762 | 753 static int parent_num_ids() { return BreakableStatement::num_ids(); } |
| 763 void Initialize(Statement* body) { | 754 void Initialize(Statement* body) { body_ = body; } |
| 764 body_ = body; | |
| 765 } | |
| 766 | |
| 767 static int num_ids() { return 1; } | |
| 768 int base_id() const { | |
| 769 return BreakableStatement::base_id() + BreakableStatement::num_ids(); | |
| 770 } | |
| 771 | 755 |
| 772 private: | 756 private: |
| 757 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | |
| 758 | |
| 773 Statement* body_; | 759 Statement* body_; |
| 774 Label continue_target_; | 760 Label continue_target_; |
| 775 }; | 761 }; |
| 776 | 762 |
| 777 | 763 |
| 778 class DoWhileStatement FINAL : public IterationStatement { | 764 class DoWhileStatement FINAL : public IterationStatement { |
| 779 public: | 765 public: |
| 780 DECLARE_NODE_TYPE(DoWhileStatement) | 766 DECLARE_NODE_TYPE(DoWhileStatement) |
| 781 | 767 |
| 782 void Initialize(Expression* cond, Statement* body) { | 768 void Initialize(Expression* cond, Statement* body) { |
| 783 IterationStatement::Initialize(body); | 769 IterationStatement::Initialize(body); |
| 784 cond_ = cond; | 770 cond_ = cond; |
| 785 } | 771 } |
| 786 | 772 |
| 787 Expression* cond() const { return cond_; } | 773 Expression* cond() const { return cond_; } |
| 788 | 774 |
| 775 static int num_ids() { return parent_num_ids() + 2; } | |
| 789 virtual BailoutId ContinueId() const OVERRIDE { | 776 virtual BailoutId ContinueId() const OVERRIDE { |
| 790 return BailoutId(base_id() + 0); | 777 return BailoutId(local_id(0)); |
| 791 } | 778 } |
| 792 virtual BailoutId StackCheckId() const OVERRIDE { return BackEdgeId(); } | 779 virtual BailoutId StackCheckId() const OVERRIDE { return BackEdgeId(); } |
| 793 BailoutId BackEdgeId() const { return BailoutId(base_id() + 1); } | 780 BailoutId BackEdgeId() const { return BailoutId(local_id(1)); } |
| 794 | 781 |
| 795 protected: | 782 protected: |
| 796 DoWhileStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos, | 783 DoWhileStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) |
| 797 IdGen* id_gen) | 784 : IterationStatement(zone, labels, pos), cond_(NULL) {} |
| 798 : IterationStatement(zone, labels, pos, num_ids(), id_gen), cond_(NULL) {} | 785 static int parent_num_ids() { return IterationStatement::num_ids(); } |
| 799 | |
| 800 static int num_ids() { return 2; } | |
| 801 int base_id() const { | |
| 802 return IterationStatement::base_id() + IterationStatement::num_ids(); | |
| 803 } | |
| 804 | 786 |
| 805 private: | 787 private: |
| 788 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | |
| 789 | |
| 806 Expression* cond_; | 790 Expression* cond_; |
| 807 }; | 791 }; |
| 808 | 792 |
| 809 | 793 |
| 810 class WhileStatement FINAL : public IterationStatement { | 794 class WhileStatement FINAL : public IterationStatement { |
| 811 public: | 795 public: |
| 812 DECLARE_NODE_TYPE(WhileStatement) | 796 DECLARE_NODE_TYPE(WhileStatement) |
| 813 | 797 |
| 814 void Initialize(Expression* cond, Statement* body) { | 798 void Initialize(Expression* cond, Statement* body) { |
| 815 IterationStatement::Initialize(body); | 799 IterationStatement::Initialize(body); |
| 816 cond_ = cond; | 800 cond_ = cond; |
| 817 } | 801 } |
| 818 | 802 |
| 819 Expression* cond() const { return cond_; } | 803 Expression* cond() const { return cond_; } |
| 820 bool may_have_function_literal() const { | 804 bool may_have_function_literal() const { |
| 821 return may_have_function_literal_; | 805 return may_have_function_literal_; |
| 822 } | 806 } |
| 823 void set_may_have_function_literal(bool value) { | 807 void set_may_have_function_literal(bool value) { |
| 824 may_have_function_literal_ = value; | 808 may_have_function_literal_ = value; |
| 825 } | 809 } |
| 826 | 810 |
| 811 static int num_ids() { return parent_num_ids() + 1; } | |
| 827 virtual BailoutId ContinueId() const OVERRIDE { return EntryId(); } | 812 virtual BailoutId ContinueId() const OVERRIDE { return EntryId(); } |
| 828 virtual BailoutId StackCheckId() const OVERRIDE { return BodyId(); } | 813 virtual BailoutId StackCheckId() const OVERRIDE { return BodyId(); } |
| 829 BailoutId BodyId() const { return BailoutId(base_id() + 0); } | 814 BailoutId BodyId() const { return BailoutId(local_id(0)); } |
| 830 | 815 |
| 831 protected: | 816 protected: |
| 832 WhileStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos, | 817 WhileStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) |
| 833 IdGen* id_gen) | 818 : IterationStatement(zone, labels, pos), |
| 834 : IterationStatement(zone, labels, pos, num_ids(), id_gen), | |
| 835 cond_(NULL), | 819 cond_(NULL), |
| 836 may_have_function_literal_(true) {} | 820 may_have_function_literal_(true) {} |
| 837 | 821 static int parent_num_ids() { return IterationStatement::num_ids(); } |
| 838 static int num_ids() { return 1; } | |
| 839 int base_id() const { | |
| 840 return IterationStatement::base_id() + IterationStatement::num_ids(); | |
| 841 } | |
| 842 | 822 |
| 843 private: | 823 private: |
| 824 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | |
| 825 | |
| 844 Expression* cond_; | 826 Expression* cond_; |
| 845 | 827 |
| 846 // True if there is a function literal subexpression in the condition. | 828 // True if there is a function literal subexpression in the condition. |
| 847 bool may_have_function_literal_; | 829 bool may_have_function_literal_; |
| 848 }; | 830 }; |
| 849 | 831 |
| 850 | 832 |
| 851 class ForStatement FINAL : public IterationStatement { | 833 class ForStatement FINAL : public IterationStatement { |
| 852 public: | 834 public: |
| 853 DECLARE_NODE_TYPE(ForStatement) | 835 DECLARE_NODE_TYPE(ForStatement) |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 866 Expression* cond() const { return cond_; } | 848 Expression* cond() const { return cond_; } |
| 867 Statement* next() const { return next_; } | 849 Statement* next() const { return next_; } |
| 868 | 850 |
| 869 bool may_have_function_literal() const { | 851 bool may_have_function_literal() const { |
| 870 return may_have_function_literal_; | 852 return may_have_function_literal_; |
| 871 } | 853 } |
| 872 void set_may_have_function_literal(bool value) { | 854 void set_may_have_function_literal(bool value) { |
| 873 may_have_function_literal_ = value; | 855 may_have_function_literal_ = value; |
| 874 } | 856 } |
| 875 | 857 |
| 858 static int num_ids() { return parent_num_ids() + 2; } | |
| 876 virtual BailoutId ContinueId() const OVERRIDE { | 859 virtual BailoutId ContinueId() const OVERRIDE { |
| 877 return BailoutId(base_id() + 0); | 860 return BailoutId(local_id(0)); |
| 878 } | 861 } |
| 879 virtual BailoutId StackCheckId() const OVERRIDE { return BodyId(); } | 862 virtual BailoutId StackCheckId() const OVERRIDE { return BodyId(); } |
| 880 BailoutId BodyId() const { return BailoutId(base_id() + 1); } | 863 BailoutId BodyId() const { return BailoutId(local_id(1)); } |
| 881 | 864 |
| 882 bool is_fast_smi_loop() { return loop_variable_ != NULL; } | 865 bool is_fast_smi_loop() { return loop_variable_ != NULL; } |
| 883 Variable* loop_variable() { return loop_variable_; } | 866 Variable* loop_variable() { return loop_variable_; } |
| 884 void set_loop_variable(Variable* var) { loop_variable_ = var; } | 867 void set_loop_variable(Variable* var) { loop_variable_ = var; } |
| 885 | 868 |
| 886 protected: | 869 protected: |
| 887 ForStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos, | 870 ForStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) |
| 888 IdGen* id_gen) | 871 : IterationStatement(zone, labels, pos), |
| 889 : IterationStatement(zone, labels, pos, num_ids(), id_gen), | |
| 890 init_(NULL), | 872 init_(NULL), |
| 891 cond_(NULL), | 873 cond_(NULL), |
| 892 next_(NULL), | 874 next_(NULL), |
| 893 may_have_function_literal_(true), | 875 may_have_function_literal_(true), |
| 894 loop_variable_(NULL) {} | 876 loop_variable_(NULL) {} |
| 895 | 877 static int parent_num_ids() { return IterationStatement::num_ids(); } |
| 896 static int num_ids() { return 2; } | |
| 897 int base_id() const { | |
| 898 return IterationStatement::base_id() + IterationStatement::num_ids(); | |
| 899 } | |
| 900 | 878 |
| 901 private: | 879 private: |
| 880 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | |
| 881 | |
| 902 Statement* init_; | 882 Statement* init_; |
| 903 Expression* cond_; | 883 Expression* cond_; |
| 904 Statement* next_; | 884 Statement* next_; |
| 905 | 885 |
| 906 // True if there is a function literal subexpression in the condition. | 886 // True if there is a function literal subexpression in the condition. |
| 907 bool may_have_function_literal_; | 887 bool may_have_function_literal_; |
| 908 Variable* loop_variable_; | 888 Variable* loop_variable_; |
| 909 }; | 889 }; |
| 910 | 890 |
| 911 | 891 |
| 912 class ForEachStatement : public IterationStatement { | 892 class ForEachStatement : public IterationStatement { |
| 913 public: | 893 public: |
| 914 enum VisitMode { | 894 enum VisitMode { |
| 915 ENUMERATE, // for (each in subject) body; | 895 ENUMERATE, // for (each in subject) body; |
| 916 ITERATE // for (each of subject) body; | 896 ITERATE // for (each of subject) body; |
| 917 }; | 897 }; |
| 918 | 898 |
| 919 void Initialize(Expression* each, Expression* subject, Statement* body) { | 899 void Initialize(Expression* each, Expression* subject, Statement* body) { |
| 920 IterationStatement::Initialize(body); | 900 IterationStatement::Initialize(body); |
| 921 each_ = each; | 901 each_ = each; |
| 922 subject_ = subject; | 902 subject_ = subject; |
| 923 } | 903 } |
| 924 | 904 |
| 925 Expression* each() const { return each_; } | 905 Expression* each() const { return each_; } |
| 926 Expression* subject() const { return subject_; } | 906 Expression* subject() const { return subject_; } |
| 927 | 907 |
| 928 protected: | 908 protected: |
| 929 ForEachStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos, | 909 ForEachStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) |
| 930 int num_ids_needed_by_subclass, IdGen* id_gen) | 910 : IterationStatement(zone, labels, pos), each_(NULL), subject_(NULL) {} |
| 931 : IterationStatement(zone, labels, pos, num_ids_needed_by_subclass, | |
| 932 id_gen), | |
| 933 each_(NULL), | |
| 934 subject_(NULL) {} | |
| 935 | 911 |
| 936 private: | 912 private: |
| 937 Expression* each_; | 913 Expression* each_; |
| 938 Expression* subject_; | 914 Expression* subject_; |
| 939 }; | 915 }; |
| 940 | 916 |
| 941 | 917 |
| 942 class ForInStatement FINAL : public ForEachStatement { | 918 class ForInStatement FINAL : public ForEachStatement { |
| 943 public: | 919 public: |
| 944 DECLARE_NODE_TYPE(ForInStatement) | 920 DECLARE_NODE_TYPE(ForInStatement) |
| 945 | 921 |
| 946 Expression* enumerable() const { | 922 Expression* enumerable() const { |
| 947 return subject(); | 923 return subject(); |
| 948 } | 924 } |
| 949 | 925 |
| 950 // Type feedback information. | 926 // Type feedback information. |
| 951 virtual int ComputeFeedbackSlotCount() { return 1; } | 927 virtual int ComputeFeedbackSlotCount() { return 1; } |
| 952 virtual void SetFirstFeedbackSlot(int slot) { for_in_feedback_slot_ = slot; } | 928 virtual void SetFirstFeedbackSlot(int slot) { for_in_feedback_slot_ = slot; } |
| 953 | 929 |
| 954 int ForInFeedbackSlot() { | 930 int ForInFeedbackSlot() { |
| 955 DCHECK(for_in_feedback_slot_ != kInvalidFeedbackSlot); | 931 DCHECK(for_in_feedback_slot_ != kInvalidFeedbackSlot); |
| 956 return for_in_feedback_slot_; | 932 return for_in_feedback_slot_; |
| 957 } | 933 } |
| 958 | 934 |
| 959 enum ForInType { FAST_FOR_IN, SLOW_FOR_IN }; | 935 enum ForInType { FAST_FOR_IN, SLOW_FOR_IN }; |
| 960 ForInType for_in_type() const { return for_in_type_; } | 936 ForInType for_in_type() const { return for_in_type_; } |
| 961 void set_for_in_type(ForInType type) { for_in_type_ = type; } | 937 void set_for_in_type(ForInType type) { for_in_type_ = type; } |
| 962 | 938 |
| 963 BailoutId BodyId() const { return BailoutId(base_id() + 0); } | 939 static int num_ids() { return parent_num_ids() + 2; } |
| 964 BailoutId PrepareId() const { return BailoutId(base_id() + 1); } | 940 BailoutId BodyId() const { return BailoutId(local_id(0)); } |
| 941 BailoutId PrepareId() const { return BailoutId(local_id(1)); } | |
| 965 virtual BailoutId ContinueId() const OVERRIDE { return EntryId(); } | 942 virtual BailoutId ContinueId() const OVERRIDE { return EntryId(); } |
| 966 virtual BailoutId StackCheckId() const OVERRIDE { return BodyId(); } | 943 virtual BailoutId StackCheckId() const OVERRIDE { return BodyId(); } |
| 967 | 944 |
| 968 protected: | 945 protected: |
| 969 ForInStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos, | 946 ForInStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) |
| 970 IdGen* id_gen) | 947 : ForEachStatement(zone, labels, pos), |
| 971 : ForEachStatement(zone, labels, pos, num_ids(), id_gen), | |
| 972 for_in_type_(SLOW_FOR_IN), | 948 for_in_type_(SLOW_FOR_IN), |
| 973 for_in_feedback_slot_(kInvalidFeedbackSlot) {} | 949 for_in_feedback_slot_(kInvalidFeedbackSlot) {} |
| 974 | 950 static int parent_num_ids() { return ForEachStatement::num_ids(); } |
| 975 static int num_ids() { return 2; } | |
| 976 int base_id() const { | |
| 977 return ForEachStatement::base_id() + ForEachStatement::num_ids(); | |
| 978 } | |
| 979 | 951 |
| 980 private: | 952 private: |
| 953 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | |
| 954 | |
| 981 ForInType for_in_type_; | 955 ForInType for_in_type_; |
| 982 int for_in_feedback_slot_; | 956 int for_in_feedback_slot_; |
| 983 }; | 957 }; |
| 984 | 958 |
| 985 | 959 |
| 986 class ForOfStatement FINAL : public ForEachStatement { | 960 class ForOfStatement FINAL : public ForEachStatement { |
| 987 public: | 961 public: |
| 988 DECLARE_NODE_TYPE(ForOfStatement) | 962 DECLARE_NODE_TYPE(ForOfStatement) |
| 989 | 963 |
| 990 void Initialize(Expression* each, | 964 void Initialize(Expression* each, |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 1021 } | 995 } |
| 1022 | 996 |
| 1023 // each = result.value | 997 // each = result.value |
| 1024 Expression* assign_each() const { | 998 Expression* assign_each() const { |
| 1025 return assign_each_; | 999 return assign_each_; |
| 1026 } | 1000 } |
| 1027 | 1001 |
| 1028 virtual BailoutId ContinueId() const OVERRIDE { return EntryId(); } | 1002 virtual BailoutId ContinueId() const OVERRIDE { return EntryId(); } |
| 1029 virtual BailoutId StackCheckId() const OVERRIDE { return BackEdgeId(); } | 1003 virtual BailoutId StackCheckId() const OVERRIDE { return BackEdgeId(); } |
| 1030 | 1004 |
| 1031 BailoutId BackEdgeId() const { return BailoutId(base_id() + 0); } | 1005 static int num_ids() { return parent_num_ids() + 1; } |
| 1006 BailoutId BackEdgeId() const { return BailoutId(local_id(0)); } | |
| 1032 | 1007 |
| 1033 protected: | 1008 protected: |
| 1034 ForOfStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos, | 1009 ForOfStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) |
| 1035 IdGen* id_gen) | 1010 : ForEachStatement(zone, labels, pos), |
| 1036 : ForEachStatement(zone, labels, pos, num_ids(), id_gen), | |
| 1037 assign_iterator_(NULL), | 1011 assign_iterator_(NULL), |
| 1038 next_result_(NULL), | 1012 next_result_(NULL), |
| 1039 result_done_(NULL), | 1013 result_done_(NULL), |
| 1040 assign_each_(NULL) {} | 1014 assign_each_(NULL) {} |
| 1041 | 1015 static int parent_num_ids() { return ForEachStatement::num_ids(); } |
| 1042 static int num_ids() { return 1; } | |
| 1043 int base_id() const { | |
| 1044 return ForEachStatement::base_id() + ForEachStatement::num_ids(); | |
| 1045 } | |
| 1046 | 1016 |
| 1047 private: | 1017 private: |
| 1018 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | |
| 1019 | |
| 1048 Expression* assign_iterator_; | 1020 Expression* assign_iterator_; |
| 1049 Expression* next_result_; | 1021 Expression* next_result_; |
| 1050 Expression* result_done_; | 1022 Expression* result_done_; |
| 1051 Expression* assign_each_; | 1023 Expression* assign_each_; |
| 1052 }; | 1024 }; |
| 1053 | 1025 |
| 1054 | 1026 |
| 1055 class ExpressionStatement FINAL : public Statement { | 1027 class ExpressionStatement FINAL : public Statement { |
| 1056 public: | 1028 public: |
| 1057 DECLARE_NODE_TYPE(ExpressionStatement) | 1029 DECLARE_NODE_TYPE(ExpressionStatement) |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1152 DECLARE_NODE_TYPE(CaseClause) | 1124 DECLARE_NODE_TYPE(CaseClause) |
| 1153 | 1125 |
| 1154 bool is_default() const { return label_ == NULL; } | 1126 bool is_default() const { return label_ == NULL; } |
| 1155 Expression* label() const { | 1127 Expression* label() const { |
| 1156 CHECK(!is_default()); | 1128 CHECK(!is_default()); |
| 1157 return label_; | 1129 return label_; |
| 1158 } | 1130 } |
| 1159 Label* body_target() { return &body_target_; } | 1131 Label* body_target() { return &body_target_; } |
| 1160 ZoneList<Statement*>* statements() const { return statements_; } | 1132 ZoneList<Statement*>* statements() const { return statements_; } |
| 1161 | 1133 |
| 1162 BailoutId EntryId() const { return BailoutId(base_id() + 0); } | 1134 static int num_ids() { return parent_num_ids() + 2; } |
| 1163 TypeFeedbackId CompareId() { return TypeFeedbackId(base_id() + 1); } | 1135 BailoutId EntryId() const { return BailoutId(local_id(0)); } |
| 1136 TypeFeedbackId CompareId() { return TypeFeedbackId(local_id(1)); } | |
| 1164 | 1137 |
| 1165 Type* compare_type() { return compare_type_; } | 1138 Type* compare_type() { return compare_type_; } |
| 1166 void set_compare_type(Type* type) { compare_type_ = type; } | 1139 void set_compare_type(Type* type) { compare_type_ = type; } |
| 1167 | 1140 |
| 1141 protected: | |
| 1142 static int parent_num_ids() { return Expression::num_ids(); } | |
| 1143 | |
| 1168 private: | 1144 private: |
| 1169 CaseClause(Zone* zone, Expression* label, ZoneList<Statement*>* statements, | 1145 CaseClause(Zone* zone, Expression* label, ZoneList<Statement*>* statements, |
| 1170 int pos, IdGen* id_gen); | 1146 int pos); |
| 1171 | 1147 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
| 1172 static int num_ids() { return 2; } | |
| 1173 int base_id() const { return Expression::base_id() + Expression::num_ids(); } | |
| 1174 | 1148 |
| 1175 Expression* label_; | 1149 Expression* label_; |
| 1176 Label body_target_; | 1150 Label body_target_; |
| 1177 ZoneList<Statement*>* statements_; | 1151 ZoneList<Statement*>* statements_; |
| 1178 Type* compare_type_; | 1152 Type* compare_type_; |
| 1179 }; | 1153 }; |
| 1180 | 1154 |
| 1181 | 1155 |
| 1182 class SwitchStatement FINAL : public BreakableStatement { | 1156 class SwitchStatement FINAL : public BreakableStatement { |
| 1183 public: | 1157 public: |
| 1184 DECLARE_NODE_TYPE(SwitchStatement) | 1158 DECLARE_NODE_TYPE(SwitchStatement) |
| 1185 | 1159 |
| 1186 void Initialize(Expression* tag, ZoneList<CaseClause*>* cases) { | 1160 void Initialize(Expression* tag, ZoneList<CaseClause*>* cases) { |
| 1187 tag_ = tag; | 1161 tag_ = tag; |
| 1188 cases_ = cases; | 1162 cases_ = cases; |
| 1189 } | 1163 } |
| 1190 | 1164 |
| 1191 Expression* tag() const { return tag_; } | 1165 Expression* tag() const { return tag_; } |
| 1192 ZoneList<CaseClause*>* cases() const { return cases_; } | 1166 ZoneList<CaseClause*>* cases() const { return cases_; } |
| 1193 | 1167 |
| 1194 protected: | 1168 protected: |
| 1195 SwitchStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos, | 1169 SwitchStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) |
| 1196 IdGen* id_gen) | 1170 : BreakableStatement(zone, labels, TARGET_FOR_ANONYMOUS, pos), |
| 1197 : BreakableStatement(zone, labels, TARGET_FOR_ANONYMOUS, pos, 0, id_gen), | |
| 1198 tag_(NULL), | 1171 tag_(NULL), |
| 1199 cases_(NULL) {} | 1172 cases_(NULL) {} |
| 1200 | 1173 |
| 1201 private: | 1174 private: |
| 1202 Expression* tag_; | 1175 Expression* tag_; |
| 1203 ZoneList<CaseClause*>* cases_; | 1176 ZoneList<CaseClause*>* cases_; |
| 1204 }; | 1177 }; |
| 1205 | 1178 |
| 1206 | 1179 |
| 1207 // If-statements always have non-null references to their then- and | 1180 // If-statements always have non-null references to their then- and |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 1218 | 1191 |
| 1219 Expression* condition() const { return condition_; } | 1192 Expression* condition() const { return condition_; } |
| 1220 Statement* then_statement() const { return then_statement_; } | 1193 Statement* then_statement() const { return then_statement_; } |
| 1221 Statement* else_statement() const { return else_statement_; } | 1194 Statement* else_statement() const { return else_statement_; } |
| 1222 | 1195 |
| 1223 virtual bool IsJump() const OVERRIDE { | 1196 virtual bool IsJump() const OVERRIDE { |
| 1224 return HasThenStatement() && then_statement()->IsJump() | 1197 return HasThenStatement() && then_statement()->IsJump() |
| 1225 && HasElseStatement() && else_statement()->IsJump(); | 1198 && HasElseStatement() && else_statement()->IsJump(); |
| 1226 } | 1199 } |
| 1227 | 1200 |
| 1228 BailoutId IfId() const { return BailoutId(base_id() + 0); } | 1201 void set_base_id(int id) { base_id_ = id; } |
| 1229 BailoutId ThenId() const { return BailoutId(base_id() + 1); } | 1202 static int num_ids() { return parent_num_ids() + 3; } |
| 1230 BailoutId ElseId() const { return BailoutId(base_id() + 2); } | 1203 BailoutId IfId() const { return BailoutId(local_id(0)); } |
| 1204 BailoutId ThenId() const { return BailoutId(local_id(1)); } | |
| 1205 BailoutId ElseId() const { return BailoutId(local_id(2)); } | |
| 1231 | 1206 |
| 1232 protected: | 1207 protected: |
| 1233 IfStatement(Zone* zone, Expression* condition, Statement* then_statement, | 1208 IfStatement(Zone* zone, Expression* condition, Statement* then_statement, |
| 1234 Statement* else_statement, int pos, IdGen* id_gen) | 1209 Statement* else_statement, int pos) |
| 1235 : Statement(zone, pos), | 1210 : Statement(zone, pos), |
| 1236 condition_(condition), | 1211 condition_(condition), |
| 1237 then_statement_(then_statement), | 1212 then_statement_(then_statement), |
| 1238 else_statement_(else_statement), | 1213 else_statement_(else_statement), |
| 1239 base_id_(id_gen->ReserveIdRange(num_ids())) {} | 1214 base_id_(INT_MIN) {} |
| 1215 static int parent_num_ids() { return 0; } | |
| 1240 | 1216 |
| 1241 static int num_ids() { return 3; } | 1217 int base_id() const { |
| 1242 int base_id() const { return base_id_; } | 1218 DCHECK(base_id_ >= 0); |
| 1219 return base_id_; | |
| 1220 } | |
| 1243 | 1221 |
| 1244 private: | 1222 private: |
| 1223 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | |
| 1224 | |
| 1245 Expression* condition_; | 1225 Expression* condition_; |
| 1246 Statement* then_statement_; | 1226 Statement* then_statement_; |
| 1247 Statement* else_statement_; | 1227 Statement* else_statement_; |
| 1248 const int base_id_; | 1228 int base_id_; |
| 1249 }; | 1229 }; |
| 1250 | 1230 |
| 1251 | 1231 |
| 1252 // NOTE: TargetCollectors are represented as nodes to fit in the target | 1232 // NOTE: TargetCollectors are represented as nodes to fit in the target |
| 1253 // stack in the compiler; this should probably be reworked. | 1233 // stack in the compiler; this should probably be reworked. |
| 1254 class TargetCollector FINAL : public AstNode { | 1234 class TargetCollector FINAL : public AstNode { |
| 1255 public: | 1235 public: |
| 1256 explicit TargetCollector(Zone* zone) | 1236 explicit TargetCollector(Zone* zone) |
| 1257 : AstNode(RelocInfo::kNoPosition), targets_(0, zone) { } | 1237 : AstNode(RelocInfo::kNoPosition), targets_(0, zone) { } |
| 1258 | 1238 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1342 | 1322 |
| 1343 private: | 1323 private: |
| 1344 Block* finally_block_; | 1324 Block* finally_block_; |
| 1345 }; | 1325 }; |
| 1346 | 1326 |
| 1347 | 1327 |
| 1348 class DebuggerStatement FINAL : public Statement { | 1328 class DebuggerStatement FINAL : public Statement { |
| 1349 public: | 1329 public: |
| 1350 DECLARE_NODE_TYPE(DebuggerStatement) | 1330 DECLARE_NODE_TYPE(DebuggerStatement) |
| 1351 | 1331 |
| 1352 BailoutId DebugBreakId() const { return BailoutId(base_id() + 0); } | 1332 void set_base_id(int id) { base_id_ = id; } |
| 1333 static int num_ids() { return parent_num_ids() + 1; } | |
| 1334 BailoutId DebugBreakId() const { return BailoutId(local_id(0)); } | |
| 1353 | 1335 |
| 1354 protected: | 1336 protected: |
| 1355 explicit DebuggerStatement(Zone* zone, int pos, IdGen* id_gen) | 1337 explicit DebuggerStatement(Zone* zone, int pos) |
| 1356 : Statement(zone, pos), base_id_(id_gen->ReserveIdRange(num_ids())) {} | 1338 : Statement(zone, pos), base_id_(INT_MIN) {} |
| 1339 static int parent_num_ids() { return 0; } | |
| 1357 | 1340 |
| 1358 static int num_ids() { return 1; } | 1341 int base_id() const { |
| 1359 int base_id() const { return base_id_; } | 1342 DCHECK(base_id_ >= 0); |
| 1343 return base_id_; | |
| 1344 } | |
| 1360 | 1345 |
| 1361 private: | 1346 private: |
| 1362 const int base_id_; | 1347 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
| 1348 | |
| 1349 int base_id_; | |
| 1363 }; | 1350 }; |
| 1364 | 1351 |
| 1365 | 1352 |
| 1366 class EmptyStatement FINAL : public Statement { | 1353 class EmptyStatement FINAL : public Statement { |
| 1367 public: | 1354 public: |
| 1368 DECLARE_NODE_TYPE(EmptyStatement) | 1355 DECLARE_NODE_TYPE(EmptyStatement) |
| 1369 | 1356 |
| 1370 protected: | 1357 protected: |
| 1371 explicit EmptyStatement(Zone* zone, int pos): Statement(zone, pos) {} | 1358 explicit EmptyStatement(Zone* zone, int pos): Statement(zone, pos) {} |
| 1372 }; | 1359 }; |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 1398 } | 1385 } |
| 1399 | 1386 |
| 1400 Handle<Object> value() const { return value_->value(); } | 1387 Handle<Object> value() const { return value_->value(); } |
| 1401 const AstValue* raw_value() const { return value_; } | 1388 const AstValue* raw_value() const { return value_; } |
| 1402 | 1389 |
| 1403 // Support for using Literal as a HashMap key. NOTE: Currently, this works | 1390 // Support for using Literal as a HashMap key. NOTE: Currently, this works |
| 1404 // only for string and number literals! | 1391 // only for string and number literals! |
| 1405 uint32_t Hash(); | 1392 uint32_t Hash(); |
| 1406 static bool Match(void* literal1, void* literal2); | 1393 static bool Match(void* literal1, void* literal2); |
| 1407 | 1394 |
| 1395 static int num_ids() { return parent_num_ids() + 1; } | |
| 1408 TypeFeedbackId LiteralFeedbackId() const { | 1396 TypeFeedbackId LiteralFeedbackId() const { |
| 1409 return TypeFeedbackId(base_id() + 0); | 1397 return TypeFeedbackId(local_id(0)); |
| 1410 } | 1398 } |
| 1411 | 1399 |
| 1412 protected: | 1400 protected: |
| 1413 Literal(Zone* zone, const AstValue* value, int position, IdGen* id_gen) | 1401 Literal(Zone* zone, const AstValue* value, int position) |
| 1414 : Expression(zone, position, num_ids(), id_gen), value_(value) {} | 1402 : Expression(zone, position), value_(value) {} |
| 1415 | 1403 static int parent_num_ids() { return Expression::num_ids(); } |
| 1416 static int num_ids() { return 1; } | |
| 1417 int base_id() const { return Expression::base_id() + Expression::num_ids(); } | |
| 1418 | 1404 |
| 1419 private: | 1405 private: |
| 1406 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | |
| 1407 | |
| 1420 const AstValue* value_; | 1408 const AstValue* value_; |
| 1421 }; | 1409 }; |
| 1422 | 1410 |
| 1423 | 1411 |
| 1424 // Base class for literals that needs space in the corresponding JSFunction. | 1412 // Base class for literals that needs space in the corresponding JSFunction. |
| 1425 class MaterializedLiteral : public Expression { | 1413 class MaterializedLiteral : public Expression { |
| 1426 public: | 1414 public: |
| 1427 virtual MaterializedLiteral* AsMaterializedLiteral() { return this; } | 1415 virtual MaterializedLiteral* AsMaterializedLiteral() { return this; } |
| 1428 | 1416 |
| 1429 int literal_index() { return literal_index_; } | 1417 int literal_index() { return literal_index_; } |
| 1430 | 1418 |
| 1431 int depth() const { | 1419 int depth() const { |
| 1432 // only callable after initialization. | 1420 // only callable after initialization. |
| 1433 DCHECK(depth_ >= 1); | 1421 DCHECK(depth_ >= 1); |
| 1434 return depth_; | 1422 return depth_; |
| 1435 } | 1423 } |
| 1436 | 1424 |
| 1437 protected: | 1425 protected: |
| 1438 MaterializedLiteral(Zone* zone, int literal_index, int pos, | 1426 MaterializedLiteral(Zone* zone, int literal_index, int pos) |
| 1439 int num_ids_needed_by_subclass, IdGen* id_gen) | 1427 : Expression(zone, pos), |
| 1440 : Expression(zone, pos, num_ids_needed_by_subclass, id_gen), | |
| 1441 literal_index_(literal_index), | 1428 literal_index_(literal_index), |
| 1442 is_simple_(false), | 1429 is_simple_(false), |
| 1443 depth_(0) {} | 1430 depth_(0) {} |
| 1444 | 1431 |
| 1445 // A materialized literal is simple if the values consist of only | 1432 // A materialized literal is simple if the values consist of only |
| 1446 // constants and simple object and array literals. | 1433 // constants and simple object and array literals. |
| 1447 bool is_simple() const { return is_simple_; } | 1434 bool is_simple() const { return is_simple_; } |
| 1448 void set_is_simple(bool is_simple) { is_simple_ = is_simple; } | 1435 void set_is_simple(bool is_simple) { is_simple_ = is_simple; } |
| 1449 friend class CompileTimeValue; | 1436 friend class CompileTimeValue; |
| 1450 | 1437 |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1560 }; | 1547 }; |
| 1561 | 1548 |
| 1562 struct Accessors: public ZoneObject { | 1549 struct Accessors: public ZoneObject { |
| 1563 Accessors() : getter(NULL), setter(NULL) { } | 1550 Accessors() : getter(NULL), setter(NULL) { } |
| 1564 Expression* getter; | 1551 Expression* getter; |
| 1565 Expression* setter; | 1552 Expression* setter; |
| 1566 }; | 1553 }; |
| 1567 | 1554 |
| 1568 protected: | 1555 protected: |
| 1569 ObjectLiteral(Zone* zone, ZoneList<Property*>* properties, int literal_index, | 1556 ObjectLiteral(Zone* zone, ZoneList<Property*>* properties, int literal_index, |
| 1570 int boilerplate_properties, bool has_function, int pos, | 1557 int boilerplate_properties, bool has_function, int pos) |
| 1571 IdGen* id_gen) | 1558 : MaterializedLiteral(zone, literal_index, pos), |
| 1572 : MaterializedLiteral(zone, literal_index, pos, 0, id_gen), | |
| 1573 properties_(properties), | 1559 properties_(properties), |
| 1574 boilerplate_properties_(boilerplate_properties), | 1560 boilerplate_properties_(boilerplate_properties), |
| 1575 fast_elements_(false), | 1561 fast_elements_(false), |
| 1576 may_store_doubles_(false), | 1562 may_store_doubles_(false), |
| 1577 has_function_(has_function) {} | 1563 has_function_(has_function) {} |
| 1578 | 1564 |
| 1579 private: | 1565 private: |
| 1580 Handle<FixedArray> constant_properties_; | 1566 Handle<FixedArray> constant_properties_; |
| 1581 ZoneList<Property*>* properties_; | 1567 ZoneList<Property*>* properties_; |
| 1582 int boilerplate_properties_; | 1568 int boilerplate_properties_; |
| 1583 bool fast_elements_; | 1569 bool fast_elements_; |
| 1584 bool may_store_doubles_; | 1570 bool may_store_doubles_; |
| 1585 bool has_function_; | 1571 bool has_function_; |
| 1586 }; | 1572 }; |
| 1587 | 1573 |
| 1588 | 1574 |
| 1589 // Node for capturing a regexp literal. | 1575 // Node for capturing a regexp literal. |
| 1590 class RegExpLiteral FINAL : public MaterializedLiteral { | 1576 class RegExpLiteral FINAL : public MaterializedLiteral { |
| 1591 public: | 1577 public: |
| 1592 DECLARE_NODE_TYPE(RegExpLiteral) | 1578 DECLARE_NODE_TYPE(RegExpLiteral) |
| 1593 | 1579 |
| 1594 Handle<String> pattern() const { return pattern_->string(); } | 1580 Handle<String> pattern() const { return pattern_->string(); } |
| 1595 Handle<String> flags() const { return flags_->string(); } | 1581 Handle<String> flags() const { return flags_->string(); } |
| 1596 | 1582 |
| 1597 protected: | 1583 protected: |
| 1598 RegExpLiteral(Zone* zone, const AstRawString* pattern, | 1584 RegExpLiteral(Zone* zone, const AstRawString* pattern, |
| 1599 const AstRawString* flags, int literal_index, int pos, | 1585 const AstRawString* flags, int literal_index, int pos) |
| 1600 IdGen* id_gen) | 1586 : MaterializedLiteral(zone, literal_index, pos), |
| 1601 : MaterializedLiteral(zone, literal_index, pos, 0, id_gen), | |
| 1602 pattern_(pattern), | 1587 pattern_(pattern), |
| 1603 flags_(flags) { | 1588 flags_(flags) { |
| 1604 set_depth(1); | 1589 set_depth(1); |
| 1605 } | 1590 } |
| 1606 | 1591 |
| 1607 private: | 1592 private: |
| 1608 const AstRawString* pattern_; | 1593 const AstRawString* pattern_; |
| 1609 const AstRawString* flags_; | 1594 const AstRawString* flags_; |
| 1610 }; | 1595 }; |
| 1611 | 1596 |
| 1612 | 1597 |
| 1613 // An array literal has a literals object that is used | 1598 // An array literal has a literals object that is used |
| 1614 // for minimizing the work when constructing it at runtime. | 1599 // for minimizing the work when constructing it at runtime. |
| 1615 class ArrayLiteral FINAL : public MaterializedLiteral { | 1600 class ArrayLiteral FINAL : public MaterializedLiteral { |
| 1616 public: | 1601 public: |
| 1617 DECLARE_NODE_TYPE(ArrayLiteral) | 1602 DECLARE_NODE_TYPE(ArrayLiteral) |
| 1618 | 1603 |
| 1619 Handle<FixedArray> constant_elements() const { return constant_elements_; } | 1604 Handle<FixedArray> constant_elements() const { return constant_elements_; } |
| 1620 ZoneList<Expression*>* values() const { return values_; } | 1605 ZoneList<Expression*>* values() const { return values_; } |
| 1621 | 1606 |
| 1607 // Unlike other AST nodes, this number of bailout IDs allocated for an | |
| 1608 // ArrayLiteral can vary, so num_ids() is not a static method. | |
| 1609 int num_ids() const { return parent_num_ids() + values()->length(); } | |
| 1610 | |
| 1622 // Return an AST id for an element that is used in simulate instructions. | 1611 // Return an AST id for an element that is used in simulate instructions. |
| 1623 BailoutId GetIdForElement(int i) { return BailoutId(base_id() + i); } | 1612 BailoutId GetIdForElement(int i) { return BailoutId(local_id(i)); } |
| 1624 | 1613 |
| 1625 // Populate the constant elements fixed array. | 1614 // Populate the constant elements fixed array. |
| 1626 void BuildConstantElements(Isolate* isolate); | 1615 void BuildConstantElements(Isolate* isolate); |
| 1627 | 1616 |
| 1628 // Assemble bitfield of flags for the CreateArrayLiteral helper. | 1617 // Assemble bitfield of flags for the CreateArrayLiteral helper. |
| 1629 int ComputeFlags() const { | 1618 int ComputeFlags() const { |
| 1630 int flags = depth() == 1 ? kShallowElements : kNoFlags; | 1619 int flags = depth() == 1 ? kShallowElements : kNoFlags; |
| 1631 flags |= ArrayLiteral::kDisableMementos; | 1620 flags |= ArrayLiteral::kDisableMementos; |
| 1632 return flags; | 1621 return flags; |
| 1633 } | 1622 } |
| 1634 | 1623 |
| 1635 enum Flags { | 1624 enum Flags { |
| 1636 kNoFlags = 0, | 1625 kNoFlags = 0, |
| 1637 kShallowElements = 1, | 1626 kShallowElements = 1, |
| 1638 kDisableMementos = 1 << 1 | 1627 kDisableMementos = 1 << 1 |
| 1639 }; | 1628 }; |
| 1640 | 1629 |
| 1641 protected: | 1630 protected: |
| 1642 ArrayLiteral(Zone* zone, ZoneList<Expression*>* values, int literal_index, | 1631 ArrayLiteral(Zone* zone, ZoneList<Expression*>* values, int literal_index, |
| 1643 int pos, IdGen* id_gen) | 1632 int pos) |
| 1644 : MaterializedLiteral(zone, literal_index, pos, num_ids(values), id_gen), | 1633 : MaterializedLiteral(zone, literal_index, pos), values_(values) {} |
| 1645 values_(values) {} | 1634 static int parent_num_ids() { return MaterializedLiteral::num_ids(); } |
| 1646 | |
| 1647 static int num_ids(ZoneList<Expression*>* values) { return values->length(); } | |
| 1648 int base_id() const { | |
| 1649 return MaterializedLiteral::base_id() + MaterializedLiteral::num_ids(); | |
| 1650 } | |
| 1651 | 1635 |
| 1652 private: | 1636 private: |
| 1637 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | |
| 1638 | |
| 1653 Handle<FixedArray> constant_elements_; | 1639 Handle<FixedArray> constant_elements_; |
| 1654 ZoneList<Expression*>* values_; | 1640 ZoneList<Expression*>* values_; |
| 1655 }; | 1641 }; |
| 1656 | 1642 |
| 1657 | 1643 |
| 1658 class VariableProxy FINAL : public Expression { | 1644 class VariableProxy FINAL : public Expression { |
| 1659 public: | 1645 public: |
| 1660 DECLARE_NODE_TYPE(VariableProxy) | 1646 DECLARE_NODE_TYPE(VariableProxy) |
| 1661 | 1647 |
| 1662 virtual bool IsValidReferenceExpression() const OVERRIDE { | 1648 virtual bool IsValidReferenceExpression() const OVERRIDE { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1694 void BindTo(Variable* var); | 1680 void BindTo(Variable* var); |
| 1695 | 1681 |
| 1696 virtual int ComputeFeedbackSlotCount() { return FLAG_vector_ics ? 1 : 0; } | 1682 virtual int ComputeFeedbackSlotCount() { return FLAG_vector_ics ? 1 : 0; } |
| 1697 virtual void SetFirstFeedbackSlot(int slot) { | 1683 virtual void SetFirstFeedbackSlot(int slot) { |
| 1698 variable_feedback_slot_ = slot; | 1684 variable_feedback_slot_ = slot; |
| 1699 } | 1685 } |
| 1700 | 1686 |
| 1701 int VariableFeedbackSlot() { return variable_feedback_slot_; } | 1687 int VariableFeedbackSlot() { return variable_feedback_slot_; } |
| 1702 | 1688 |
| 1703 protected: | 1689 protected: |
| 1704 VariableProxy(Zone* zone, Variable* var, int position, IdGen* id_gen); | 1690 VariableProxy(Zone* zone, Variable* var, int position); |
| 1705 | 1691 |
| 1706 VariableProxy(Zone* zone, const AstRawString* name, bool is_this, | 1692 VariableProxy(Zone* zone, const AstRawString* name, bool is_this, |
| 1707 Interface* interface, int position, IdGen* id_gen); | 1693 Interface* interface, int position); |
| 1708 | 1694 |
| 1709 union { | 1695 union { |
| 1710 const AstRawString* raw_name_; // if !is_resolved_ | 1696 const AstRawString* raw_name_; // if !is_resolved_ |
| 1711 Variable* var_; // if is_resolved_ | 1697 Variable* var_; // if is_resolved_ |
| 1712 }; | 1698 }; |
| 1713 Interface* interface_; | 1699 Interface* interface_; |
| 1714 int variable_feedback_slot_; | 1700 int variable_feedback_slot_; |
| 1715 bool is_this_ : 1; | 1701 bool is_this_ : 1; |
| 1716 bool is_assigned_ : 1; | 1702 bool is_assigned_ : 1; |
| 1717 bool is_resolved_ : 1; | 1703 bool is_resolved_ : 1; |
| 1718 }; | 1704 }; |
| 1719 | 1705 |
| 1720 | 1706 |
| 1721 class Property FINAL : public Expression { | 1707 class Property FINAL : public Expression { |
| 1722 public: | 1708 public: |
| 1723 DECLARE_NODE_TYPE(Property) | 1709 DECLARE_NODE_TYPE(Property) |
| 1724 | 1710 |
| 1725 virtual bool IsValidReferenceExpression() const OVERRIDE { return true; } | 1711 virtual bool IsValidReferenceExpression() const OVERRIDE { return true; } |
| 1726 | 1712 |
| 1727 Expression* obj() const { return obj_; } | 1713 Expression* obj() const { return obj_; } |
| 1728 Expression* key() const { return key_; } | 1714 Expression* key() const { return key_; } |
| 1729 | 1715 |
| 1730 BailoutId LoadId() const { return BailoutId(base_id() + 0); } | 1716 static int num_ids() { return parent_num_ids() + 2; } |
| 1731 TypeFeedbackId PropertyFeedbackId() { return TypeFeedbackId(base_id() + 1); } | 1717 BailoutId LoadId() const { return BailoutId(local_id(0)); } |
| 1732 | 1718 TypeFeedbackId PropertyFeedbackId() { return TypeFeedbackId(local_id(1)); } |
| 1733 | 1719 |
| 1734 bool IsStringAccess() const { return is_string_access_; } | 1720 bool IsStringAccess() const { return is_string_access_; } |
| 1735 | 1721 |
| 1736 // Type feedback information. | 1722 // Type feedback information. |
| 1737 virtual bool IsMonomorphic() OVERRIDE { | 1723 virtual bool IsMonomorphic() OVERRIDE { |
| 1738 return receiver_types_.length() == 1; | 1724 return receiver_types_.length() == 1; |
| 1739 } | 1725 } |
| 1740 virtual SmallMapList* GetReceiverTypes() OVERRIDE { | 1726 virtual SmallMapList* GetReceiverTypes() OVERRIDE { |
| 1741 return &receiver_types_; | 1727 return &receiver_types_; |
| 1742 } | 1728 } |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 1757 } | 1743 } |
| 1758 | 1744 |
| 1759 virtual int ComputeFeedbackSlotCount() { return FLAG_vector_ics ? 1 : 0; } | 1745 virtual int ComputeFeedbackSlotCount() { return FLAG_vector_ics ? 1 : 0; } |
| 1760 virtual void SetFirstFeedbackSlot(int slot) { | 1746 virtual void SetFirstFeedbackSlot(int slot) { |
| 1761 property_feedback_slot_ = slot; | 1747 property_feedback_slot_ = slot; |
| 1762 } | 1748 } |
| 1763 | 1749 |
| 1764 int PropertyFeedbackSlot() const { return property_feedback_slot_; } | 1750 int PropertyFeedbackSlot() const { return property_feedback_slot_; } |
| 1765 | 1751 |
| 1766 protected: | 1752 protected: |
| 1767 Property(Zone* zone, Expression* obj, Expression* key, int pos, IdGen* id_gen) | 1753 Property(Zone* zone, Expression* obj, Expression* key, int pos) |
| 1768 : Expression(zone, pos, num_ids(), id_gen), | 1754 : Expression(zone, pos), |
| 1769 obj_(obj), | 1755 obj_(obj), |
| 1770 key_(key), | 1756 key_(key), |
| 1771 property_feedback_slot_(kInvalidFeedbackSlot), | 1757 property_feedback_slot_(kInvalidFeedbackSlot), |
| 1772 is_for_call_(false), | 1758 is_for_call_(false), |
| 1773 is_uninitialized_(false), | 1759 is_uninitialized_(false), |
| 1774 is_string_access_(false) {} | 1760 is_string_access_(false) {} |
| 1775 | 1761 static int parent_num_ids() { return Expression::num_ids(); } |
| 1776 static int num_ids() { return 2; } | |
| 1777 int base_id() const { return Expression::base_id() + Expression::num_ids(); } | |
| 1778 | 1762 |
| 1779 private: | 1763 private: |
| 1764 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | |
| 1765 | |
| 1780 Expression* obj_; | 1766 Expression* obj_; |
| 1781 Expression* key_; | 1767 Expression* key_; |
| 1782 int property_feedback_slot_; | 1768 int property_feedback_slot_; |
| 1783 | 1769 |
| 1784 SmallMapList receiver_types_; | 1770 SmallMapList receiver_types_; |
| 1785 bool is_for_call_ : 1; | 1771 bool is_for_call_ : 1; |
| 1786 bool is_uninitialized_ : 1; | 1772 bool is_uninitialized_ : 1; |
| 1787 bool is_string_access_ : 1; | 1773 bool is_string_access_ : 1; |
| 1788 }; | 1774 }; |
| 1789 | 1775 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1834 Handle<Cell> cell() { return cell_; } | 1820 Handle<Cell> cell() { return cell_; } |
| 1835 | 1821 |
| 1836 Handle<AllocationSite> allocation_site() { return allocation_site_; } | 1822 Handle<AllocationSite> allocation_site() { return allocation_site_; } |
| 1837 | 1823 |
| 1838 void set_target(Handle<JSFunction> target) { target_ = target; } | 1824 void set_target(Handle<JSFunction> target) { target_ = target; } |
| 1839 void set_allocation_site(Handle<AllocationSite> site) { | 1825 void set_allocation_site(Handle<AllocationSite> site) { |
| 1840 allocation_site_ = site; | 1826 allocation_site_ = site; |
| 1841 } | 1827 } |
| 1842 bool ComputeGlobalTarget(Handle<GlobalObject> global, LookupIterator* it); | 1828 bool ComputeGlobalTarget(Handle<GlobalObject> global, LookupIterator* it); |
| 1843 | 1829 |
| 1844 BailoutId ReturnId() const { return BailoutId(base_id() + 0); } | 1830 static int num_ids() { return parent_num_ids() + 2; } |
| 1845 BailoutId EvalOrLookupId() const { return BailoutId(base_id() + 1); } | 1831 BailoutId ReturnId() const { return BailoutId(local_id(0)); } |
| 1832 BailoutId EvalOrLookupId() const { return BailoutId(local_id(1)); } | |
| 1846 | 1833 |
| 1847 enum CallType { | 1834 enum CallType { |
| 1848 POSSIBLY_EVAL_CALL, | 1835 POSSIBLY_EVAL_CALL, |
| 1849 GLOBAL_CALL, | 1836 GLOBAL_CALL, |
| 1850 LOOKUP_SLOT_CALL, | 1837 LOOKUP_SLOT_CALL, |
| 1851 PROPERTY_CALL, | 1838 PROPERTY_CALL, |
| 1852 OTHER_CALL | 1839 OTHER_CALL |
| 1853 }; | 1840 }; |
| 1854 | 1841 |
| 1855 // Helpers to determine how to handle the call. | 1842 // Helpers to determine how to handle the call. |
| 1856 CallType GetCallType(Isolate* isolate) const; | 1843 CallType GetCallType(Isolate* isolate) const; |
| 1857 bool IsUsingCallFeedbackSlot(Isolate* isolate) const; | 1844 bool IsUsingCallFeedbackSlot(Isolate* isolate) const; |
| 1858 | 1845 |
| 1859 #ifdef DEBUG | 1846 #ifdef DEBUG |
| 1860 // Used to assert that the FullCodeGenerator records the return site. | 1847 // Used to assert that the FullCodeGenerator records the return site. |
| 1861 bool return_is_recorded_; | 1848 bool return_is_recorded_; |
| 1862 #endif | 1849 #endif |
| 1863 | 1850 |
| 1864 protected: | 1851 protected: |
| 1865 Call(Zone* zone, Expression* expression, ZoneList<Expression*>* arguments, | 1852 Call(Zone* zone, Expression* expression, ZoneList<Expression*>* arguments, |
| 1866 int pos, IdGen* id_gen) | 1853 int pos) |
| 1867 : Expression(zone, pos, num_ids(), id_gen), | 1854 : Expression(zone, pos), |
| 1868 expression_(expression), | 1855 expression_(expression), |
| 1869 arguments_(arguments), | 1856 arguments_(arguments), |
| 1870 call_feedback_slot_(kInvalidFeedbackSlot) { | 1857 call_feedback_slot_(kInvalidFeedbackSlot) { |
| 1871 if (expression->IsProperty()) { | 1858 if (expression->IsProperty()) { |
| 1872 expression->AsProperty()->mark_for_call(); | 1859 expression->AsProperty()->mark_for_call(); |
| 1873 } | 1860 } |
| 1874 } | 1861 } |
| 1875 | 1862 static int parent_num_ids() { return Expression::num_ids(); } |
| 1876 static int num_ids() { return 2; } | |
| 1877 int base_id() const { return Expression::base_id() + Expression::num_ids(); } | |
| 1878 | 1863 |
| 1879 private: | 1864 private: |
| 1865 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | |
| 1866 | |
| 1880 Expression* expression_; | 1867 Expression* expression_; |
| 1881 ZoneList<Expression*>* arguments_; | 1868 ZoneList<Expression*>* arguments_; |
| 1882 Handle<JSFunction> target_; | 1869 Handle<JSFunction> target_; |
| 1883 Handle<Cell> cell_; | 1870 Handle<Cell> cell_; |
| 1884 Handle<AllocationSite> allocation_site_; | 1871 Handle<AllocationSite> allocation_site_; |
| 1885 int call_feedback_slot_; | 1872 int call_feedback_slot_; |
| 1886 }; | 1873 }; |
| 1887 | 1874 |
| 1888 | 1875 |
| 1889 class CallNew FINAL : public Expression { | 1876 class CallNew FINAL : public Expression { |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 1911 return callnew_feedback_slot_ + 1; | 1898 return callnew_feedback_slot_ + 1; |
| 1912 } | 1899 } |
| 1913 | 1900 |
| 1914 void RecordTypeFeedback(TypeFeedbackOracle* oracle); | 1901 void RecordTypeFeedback(TypeFeedbackOracle* oracle); |
| 1915 virtual bool IsMonomorphic() OVERRIDE { return is_monomorphic_; } | 1902 virtual bool IsMonomorphic() OVERRIDE { return is_monomorphic_; } |
| 1916 Handle<JSFunction> target() const { return target_; } | 1903 Handle<JSFunction> target() const { return target_; } |
| 1917 Handle<AllocationSite> allocation_site() const { | 1904 Handle<AllocationSite> allocation_site() const { |
| 1918 return allocation_site_; | 1905 return allocation_site_; |
| 1919 } | 1906 } |
| 1920 | 1907 |
| 1908 static int num_ids() { return parent_num_ids() + 1; } | |
| 1921 static int feedback_slots() { return 1; } | 1909 static int feedback_slots() { return 1; } |
| 1922 | 1910 BailoutId ReturnId() const { return BailoutId(local_id(0)); } |
| 1923 BailoutId ReturnId() const { return BailoutId(base_id() + 0); } | |
| 1924 | 1911 |
| 1925 protected: | 1912 protected: |
| 1926 CallNew(Zone* zone, Expression* expression, ZoneList<Expression*>* arguments, | 1913 CallNew(Zone* zone, Expression* expression, ZoneList<Expression*>* arguments, |
| 1927 int pos, IdGen* id_gen) | 1914 int pos) |
| 1928 : Expression(zone, pos, num_ids(), id_gen), | 1915 : Expression(zone, pos), |
| 1929 expression_(expression), | 1916 expression_(expression), |
| 1930 arguments_(arguments), | 1917 arguments_(arguments), |
| 1931 is_monomorphic_(false), | 1918 is_monomorphic_(false), |
| 1932 callnew_feedback_slot_(kInvalidFeedbackSlot) {} | 1919 callnew_feedback_slot_(kInvalidFeedbackSlot) {} |
| 1933 | 1920 static int parent_num_ids() { return Expression::num_ids(); } |
| 1934 static int num_ids() { return 1; } | |
| 1935 int base_id() const { return Expression::base_id() + Expression::num_ids(); } | |
| 1936 | 1921 |
| 1937 private: | 1922 private: |
| 1923 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | |
| 1924 | |
| 1938 Expression* expression_; | 1925 Expression* expression_; |
| 1939 ZoneList<Expression*>* arguments_; | 1926 ZoneList<Expression*>* arguments_; |
| 1940 bool is_monomorphic_; | 1927 bool is_monomorphic_; |
| 1941 Handle<JSFunction> target_; | 1928 Handle<JSFunction> target_; |
| 1942 Handle<AllocationSite> allocation_site_; | 1929 Handle<AllocationSite> allocation_site_; |
| 1943 int callnew_feedback_slot_; | 1930 int callnew_feedback_slot_; |
| 1944 }; | 1931 }; |
| 1945 | 1932 |
| 1946 | 1933 |
| 1947 // The CallRuntime class does not represent any official JavaScript | 1934 // The CallRuntime class does not represent any official JavaScript |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 1965 virtual void SetFirstFeedbackSlot(int slot) { | 1952 virtual void SetFirstFeedbackSlot(int slot) { |
| 1966 callruntime_feedback_slot_ = slot; | 1953 callruntime_feedback_slot_ = slot; |
| 1967 } | 1954 } |
| 1968 | 1955 |
| 1969 int CallRuntimeFeedbackSlot() { | 1956 int CallRuntimeFeedbackSlot() { |
| 1970 DCHECK(!is_jsruntime() || | 1957 DCHECK(!is_jsruntime() || |
| 1971 callruntime_feedback_slot_ != kInvalidFeedbackSlot); | 1958 callruntime_feedback_slot_ != kInvalidFeedbackSlot); |
| 1972 return callruntime_feedback_slot_; | 1959 return callruntime_feedback_slot_; |
| 1973 } | 1960 } |
| 1974 | 1961 |
| 1962 static int num_ids() { return parent_num_ids() + 1; } | |
| 1975 TypeFeedbackId CallRuntimeFeedbackId() const { | 1963 TypeFeedbackId CallRuntimeFeedbackId() const { |
| 1976 return TypeFeedbackId(base_id() + 0); | 1964 return TypeFeedbackId(local_id(0)); |
| 1977 } | 1965 } |
| 1978 | 1966 |
| 1979 protected: | 1967 protected: |
| 1980 CallRuntime(Zone* zone, const AstRawString* name, | 1968 CallRuntime(Zone* zone, const AstRawString* name, |
| 1981 const Runtime::Function* function, | 1969 const Runtime::Function* function, |
| 1982 ZoneList<Expression*>* arguments, int pos, IdGen* id_gen) | 1970 ZoneList<Expression*>* arguments, int pos) |
| 1983 : Expression(zone, pos, num_ids(), id_gen), | 1971 : Expression(zone, pos), |
| 1984 raw_name_(name), | 1972 raw_name_(name), |
| 1985 function_(function), | 1973 function_(function), |
| 1986 arguments_(arguments) {} | 1974 arguments_(arguments) {} |
| 1987 | 1975 static int parent_num_ids() { return Expression::num_ids(); } |
| 1988 static int num_ids() { return 1; } | |
| 1989 int base_id() const { return Expression::base_id() + Expression::num_ids(); } | |
| 1990 | 1976 |
| 1991 private: | 1977 private: |
| 1978 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | |
| 1979 | |
| 1992 const AstRawString* raw_name_; | 1980 const AstRawString* raw_name_; |
| 1993 const Runtime::Function* function_; | 1981 const Runtime::Function* function_; |
| 1994 ZoneList<Expression*>* arguments_; | 1982 ZoneList<Expression*>* arguments_; |
| 1995 int callruntime_feedback_slot_; | 1983 int callruntime_feedback_slot_; |
| 1996 }; | 1984 }; |
| 1997 | 1985 |
| 1998 | 1986 |
| 1999 class UnaryOperation FINAL : public Expression { | 1987 class UnaryOperation FINAL : public Expression { |
| 2000 public: | 1988 public: |
| 2001 DECLARE_NODE_TYPE(UnaryOperation) | 1989 DECLARE_NODE_TYPE(UnaryOperation) |
| 2002 | 1990 |
| 2003 Token::Value op() const { return op_; } | 1991 Token::Value op() const { return op_; } |
| 2004 Expression* expression() const { return expression_; } | 1992 Expression* expression() const { return expression_; } |
| 2005 | 1993 |
| 2006 // For unary not (Token::NOT), the AST ids where true and false will | 1994 // For unary not (Token::NOT), the AST ids where true and false will |
| 2007 // actually be materialized, respectively. | 1995 // actually be materialized, respectively. |
| 2008 BailoutId MaterializeTrueId() const { return BailoutId(base_id() + 0); } | 1996 static int num_ids() { return parent_num_ids() + 2; } |
| 2009 BailoutId MaterializeFalseId() const { return BailoutId(base_id() + 1); } | 1997 BailoutId MaterializeTrueId() const { return BailoutId(local_id(0)); } |
| 1998 BailoutId MaterializeFalseId() const { return BailoutId(local_id(1)); } | |
| 2010 | 1999 |
| 2011 virtual void RecordToBooleanTypeFeedback( | 2000 virtual void RecordToBooleanTypeFeedback( |
| 2012 TypeFeedbackOracle* oracle) OVERRIDE; | 2001 TypeFeedbackOracle* oracle) OVERRIDE; |
| 2013 | 2002 |
| 2014 protected: | 2003 protected: |
| 2015 UnaryOperation(Zone* zone, Token::Value op, Expression* expression, int pos, | 2004 UnaryOperation(Zone* zone, Token::Value op, Expression* expression, int pos) |
| 2016 IdGen* id_gen) | 2005 : Expression(zone, pos), op_(op), expression_(expression) { |
| 2017 : Expression(zone, pos, num_ids(), id_gen), | |
| 2018 op_(op), | |
| 2019 expression_(expression) { | |
| 2020 DCHECK(Token::IsUnaryOp(op)); | 2006 DCHECK(Token::IsUnaryOp(op)); |
| 2021 } | 2007 } |
| 2022 | 2008 static int parent_num_ids() { return Expression::num_ids(); } |
| 2023 static int num_ids() { return 2; } | |
| 2024 int base_id() const { return Expression::base_id() + Expression::num_ids(); } | |
| 2025 | 2009 |
| 2026 private: | 2010 private: |
| 2011 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | |
| 2012 | |
| 2027 Token::Value op_; | 2013 Token::Value op_; |
| 2028 Expression* expression_; | 2014 Expression* expression_; |
| 2029 }; | 2015 }; |
| 2030 | 2016 |
| 2031 | 2017 |
| 2032 class BinaryOperation FINAL : public Expression { | 2018 class BinaryOperation FINAL : public Expression { |
| 2033 public: | 2019 public: |
| 2034 DECLARE_NODE_TYPE(BinaryOperation) | 2020 DECLARE_NODE_TYPE(BinaryOperation) |
| 2035 | 2021 |
| 2036 virtual bool ResultOverwriteAllowed() const OVERRIDE; | 2022 virtual bool ResultOverwriteAllowed() const OVERRIDE; |
| 2037 | 2023 |
| 2038 Token::Value op() const { return op_; } | 2024 Token::Value op() const { return op_; } |
| 2039 Expression* left() const { return left_; } | 2025 Expression* left() const { return left_; } |
| 2040 Expression* right() const { return right_; } | 2026 Expression* right() const { return right_; } |
| 2041 Handle<AllocationSite> allocation_site() const { return allocation_site_; } | 2027 Handle<AllocationSite> allocation_site() const { return allocation_site_; } |
| 2042 void set_allocation_site(Handle<AllocationSite> allocation_site) { | 2028 void set_allocation_site(Handle<AllocationSite> allocation_site) { |
| 2043 allocation_site_ = allocation_site; | 2029 allocation_site_ = allocation_site; |
| 2044 } | 2030 } |
| 2045 | 2031 |
| 2046 // The short-circuit logical operations need an AST ID for their | 2032 // The short-circuit logical operations need an AST ID for their |
| 2047 // right-hand subexpression. | 2033 // right-hand subexpression. |
| 2048 BailoutId RightId() const { return BailoutId(base_id() + 0); } | 2034 static int num_ids() { return parent_num_ids() + 2; } |
| 2035 BailoutId RightId() const { return BailoutId(local_id(0)); } | |
| 2049 | 2036 |
| 2050 TypeFeedbackId BinaryOperationFeedbackId() const { | 2037 TypeFeedbackId BinaryOperationFeedbackId() const { |
| 2051 return TypeFeedbackId(base_id() + 1); | 2038 return TypeFeedbackId(local_id(1)); |
| 2052 } | 2039 } |
| 2053 Maybe<int> fixed_right_arg() const { return fixed_right_arg_; } | 2040 Maybe<int> fixed_right_arg() const { return fixed_right_arg_; } |
| 2054 void set_fixed_right_arg(Maybe<int> arg) { fixed_right_arg_ = arg; } | 2041 void set_fixed_right_arg(Maybe<int> arg) { fixed_right_arg_ = arg; } |
| 2055 | 2042 |
| 2056 virtual void RecordToBooleanTypeFeedback( | 2043 virtual void RecordToBooleanTypeFeedback( |
| 2057 TypeFeedbackOracle* oracle) OVERRIDE; | 2044 TypeFeedbackOracle* oracle) OVERRIDE; |
| 2058 | 2045 |
| 2059 protected: | 2046 protected: |
| 2060 BinaryOperation(Zone* zone, Token::Value op, Expression* left, | 2047 BinaryOperation(Zone* zone, Token::Value op, Expression* left, |
| 2061 Expression* right, int pos, IdGen* id_gen) | 2048 Expression* right, int pos) |
| 2062 : Expression(zone, pos, num_ids(), id_gen), | 2049 : Expression(zone, pos), op_(op), left_(left), right_(right) { |
| 2063 op_(op), | |
| 2064 left_(left), | |
| 2065 right_(right) { | |
| 2066 DCHECK(Token::IsBinaryOp(op)); | 2050 DCHECK(Token::IsBinaryOp(op)); |
| 2067 } | 2051 } |
| 2068 | 2052 static int parent_num_ids() { return Expression::num_ids(); } |
| 2069 static int num_ids() { return 2; } | |
| 2070 int base_id() const { return Expression::base_id() + Expression::num_ids(); } | |
| 2071 | 2053 |
| 2072 private: | 2054 private: |
| 2055 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | |
| 2056 | |
| 2073 Token::Value op_; | 2057 Token::Value op_; |
| 2074 Expression* left_; | 2058 Expression* left_; |
| 2075 Expression* right_; | 2059 Expression* right_; |
| 2076 Handle<AllocationSite> allocation_site_; | 2060 Handle<AllocationSite> allocation_site_; |
| 2077 | 2061 |
| 2078 // TODO(rossberg): the fixed arg should probably be represented as a Constant | 2062 // TODO(rossberg): the fixed arg should probably be represented as a Constant |
| 2079 // type for the RHS. | 2063 // type for the RHS. |
| 2080 Maybe<int> fixed_right_arg_; | 2064 Maybe<int> fixed_right_arg_; |
| 2081 }; | 2065 }; |
| 2082 | 2066 |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 2101 virtual SmallMapList* GetReceiverTypes() OVERRIDE { | 2085 virtual SmallMapList* GetReceiverTypes() OVERRIDE { |
| 2102 return &receiver_types_; | 2086 return &receiver_types_; |
| 2103 } | 2087 } |
| 2104 virtual KeyedAccessStoreMode GetStoreMode() OVERRIDE { | 2088 virtual KeyedAccessStoreMode GetStoreMode() OVERRIDE { |
| 2105 return store_mode_; | 2089 return store_mode_; |
| 2106 } | 2090 } |
| 2107 Type* type() const { return type_; } | 2091 Type* type() const { return type_; } |
| 2108 void set_store_mode(KeyedAccessStoreMode mode) { store_mode_ = mode; } | 2092 void set_store_mode(KeyedAccessStoreMode mode) { store_mode_ = mode; } |
| 2109 void set_type(Type* type) { type_ = type; } | 2093 void set_type(Type* type) { type_ = type; } |
| 2110 | 2094 |
| 2111 BailoutId AssignmentId() const { return BailoutId(base_id() + 0); } | 2095 static int num_ids() { return parent_num_ids() + 3; } |
| 2096 BailoutId AssignmentId() const { return BailoutId(local_id(0)); } | |
| 2112 TypeFeedbackId CountBinOpFeedbackId() const { | 2097 TypeFeedbackId CountBinOpFeedbackId() const { |
| 2113 return TypeFeedbackId(base_id() + 1); | 2098 return TypeFeedbackId(local_id(1)); |
| 2114 } | 2099 } |
| 2115 TypeFeedbackId CountStoreFeedbackId() const { | 2100 TypeFeedbackId CountStoreFeedbackId() const { |
| 2116 return TypeFeedbackId(base_id() + 2); | 2101 return TypeFeedbackId(local_id(2)); |
| 2117 } | 2102 } |
| 2118 | 2103 |
| 2119 protected: | 2104 protected: |
| 2120 CountOperation(Zone* zone, Token::Value op, bool is_prefix, Expression* expr, | 2105 CountOperation(Zone* zone, Token::Value op, bool is_prefix, Expression* expr, |
| 2121 int pos, IdGen* id_gen) | 2106 int pos) |
| 2122 : Expression(zone, pos, num_ids(), id_gen), | 2107 : Expression(zone, pos), |
| 2123 op_(op), | 2108 op_(op), |
| 2124 is_prefix_(is_prefix), | 2109 is_prefix_(is_prefix), |
| 2125 store_mode_(STANDARD_STORE), | 2110 store_mode_(STANDARD_STORE), |
| 2126 expression_(expr) {} | 2111 expression_(expr) {} |
| 2127 | 2112 static int parent_num_ids() { return Expression::num_ids(); } |
| 2128 static int num_ids() { return 3; } | |
| 2129 int base_id() const { return Expression::base_id() + Expression::num_ids(); } | |
| 2130 | 2113 |
| 2131 private: | 2114 private: |
| 2115 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | |
| 2116 | |
| 2132 Token::Value op_; | 2117 Token::Value op_; |
| 2133 bool is_prefix_ : 1; | 2118 bool is_prefix_ : 1; |
| 2134 KeyedAccessStoreMode store_mode_ : 5; // Windows treats as signed, | 2119 KeyedAccessStoreMode store_mode_ : 5; // Windows treats as signed, |
| 2135 // must have extra bit. | 2120 // must have extra bit. |
| 2136 Type* type_; | 2121 Type* type_; |
| 2137 Expression* expression_; | 2122 Expression* expression_; |
| 2138 SmallMapList receiver_types_; | 2123 SmallMapList receiver_types_; |
| 2139 }; | 2124 }; |
| 2140 | 2125 |
| 2141 | 2126 |
| 2142 class CompareOperation FINAL : public Expression { | 2127 class CompareOperation FINAL : public Expression { |
| 2143 public: | 2128 public: |
| 2144 DECLARE_NODE_TYPE(CompareOperation) | 2129 DECLARE_NODE_TYPE(CompareOperation) |
| 2145 | 2130 |
| 2146 Token::Value op() const { return op_; } | 2131 Token::Value op() const { return op_; } |
| 2147 Expression* left() const { return left_; } | 2132 Expression* left() const { return left_; } |
| 2148 Expression* right() const { return right_; } | 2133 Expression* right() const { return right_; } |
| 2149 | 2134 |
| 2150 // Type feedback information. | 2135 // Type feedback information. |
| 2136 static int num_ids() { return parent_num_ids() + 1; } | |
| 2151 TypeFeedbackId CompareOperationFeedbackId() const { | 2137 TypeFeedbackId CompareOperationFeedbackId() const { |
| 2152 return TypeFeedbackId(base_id() + 0); | 2138 return TypeFeedbackId(local_id(0)); |
| 2153 } | 2139 } |
| 2154 Type* combined_type() const { return combined_type_; } | 2140 Type* combined_type() const { return combined_type_; } |
| 2155 void set_combined_type(Type* type) { combined_type_ = type; } | 2141 void set_combined_type(Type* type) { combined_type_ = type; } |
| 2156 | 2142 |
| 2157 // Match special cases. | 2143 // Match special cases. |
| 2158 bool IsLiteralCompareTypeof(Expression** expr, Handle<String>* check); | 2144 bool IsLiteralCompareTypeof(Expression** expr, Handle<String>* check); |
| 2159 bool IsLiteralCompareUndefined(Expression** expr, Isolate* isolate); | 2145 bool IsLiteralCompareUndefined(Expression** expr, Isolate* isolate); |
| 2160 bool IsLiteralCompareNull(Expression** expr); | 2146 bool IsLiteralCompareNull(Expression** expr); |
| 2161 | 2147 |
| 2162 protected: | 2148 protected: |
| 2163 CompareOperation(Zone* zone, Token::Value op, Expression* left, | 2149 CompareOperation(Zone* zone, Token::Value op, Expression* left, |
| 2164 Expression* right, int pos, IdGen* id_gen) | 2150 Expression* right, int pos) |
| 2165 : Expression(zone, pos, num_ids(), id_gen), | 2151 : Expression(zone, pos), |
| 2166 op_(op), | 2152 op_(op), |
| 2167 left_(left), | 2153 left_(left), |
| 2168 right_(right), | 2154 right_(right), |
| 2169 combined_type_(Type::None(zone)) { | 2155 combined_type_(Type::None(zone)) { |
| 2170 DCHECK(Token::IsCompareOp(op)); | 2156 DCHECK(Token::IsCompareOp(op)); |
| 2171 } | 2157 } |
| 2172 | 2158 static int parent_num_ids() { return Expression::num_ids(); } |
| 2173 static int num_ids() { return 1; } | |
| 2174 int base_id() const { return Expression::base_id() + Expression::num_ids(); } | |
| 2175 | 2159 |
| 2176 private: | 2160 private: |
| 2161 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | |
| 2162 | |
| 2177 Token::Value op_; | 2163 Token::Value op_; |
| 2178 Expression* left_; | 2164 Expression* left_; |
| 2179 Expression* right_; | 2165 Expression* right_; |
| 2180 | 2166 |
| 2181 Type* combined_type_; | 2167 Type* combined_type_; |
| 2182 }; | 2168 }; |
| 2183 | 2169 |
| 2184 | 2170 |
| 2185 class Conditional FINAL : public Expression { | 2171 class Conditional FINAL : public Expression { |
| 2186 public: | 2172 public: |
| 2187 DECLARE_NODE_TYPE(Conditional) | 2173 DECLARE_NODE_TYPE(Conditional) |
| 2188 | 2174 |
| 2189 Expression* condition() const { return condition_; } | 2175 Expression* condition() const { return condition_; } |
| 2190 Expression* then_expression() const { return then_expression_; } | 2176 Expression* then_expression() const { return then_expression_; } |
| 2191 Expression* else_expression() const { return else_expression_; } | 2177 Expression* else_expression() const { return else_expression_; } |
| 2192 | 2178 |
| 2193 BailoutId ThenId() const { return BailoutId(base_id() + 0); } | 2179 static int num_ids() { return parent_num_ids() + 2; } |
| 2194 BailoutId ElseId() const { return BailoutId(base_id() + 1); } | 2180 BailoutId ThenId() const { return BailoutId(local_id(0)); } |
| 2181 BailoutId ElseId() const { return BailoutId(local_id(1)); } | |
| 2195 | 2182 |
| 2196 protected: | 2183 protected: |
| 2197 Conditional(Zone* zone, Expression* condition, Expression* then_expression, | 2184 Conditional(Zone* zone, Expression* condition, Expression* then_expression, |
| 2198 Expression* else_expression, int position, IdGen* id_gen) | 2185 Expression* else_expression, int position) |
| 2199 : Expression(zone, position, num_ids(), id_gen), | 2186 : Expression(zone, position), |
| 2200 condition_(condition), | 2187 condition_(condition), |
| 2201 then_expression_(then_expression), | 2188 then_expression_(then_expression), |
| 2202 else_expression_(else_expression) {} | 2189 else_expression_(else_expression) {} |
| 2203 | 2190 static int parent_num_ids() { return Expression::num_ids(); } |
| 2204 static int num_ids() { return 2; } | |
| 2205 int base_id() const { return Expression::base_id() + Expression::num_ids(); } | |
| 2206 | 2191 |
| 2207 private: | 2192 private: |
| 2193 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | |
| 2194 | |
| 2208 Expression* condition_; | 2195 Expression* condition_; |
| 2209 Expression* then_expression_; | 2196 Expression* then_expression_; |
| 2210 Expression* else_expression_; | 2197 Expression* else_expression_; |
| 2211 }; | 2198 }; |
| 2212 | 2199 |
| 2213 | 2200 |
| 2214 class Assignment FINAL : public Expression { | 2201 class Assignment FINAL : public Expression { |
| 2215 public: | 2202 public: |
| 2216 DECLARE_NODE_TYPE(Assignment) | 2203 DECLARE_NODE_TYPE(Assignment) |
| 2217 | 2204 |
| 2218 Assignment* AsSimpleAssignment() { return !is_compound() ? this : NULL; } | 2205 Assignment* AsSimpleAssignment() { return !is_compound() ? this : NULL; } |
| 2219 | 2206 |
| 2220 Token::Value binary_op() const; | 2207 Token::Value binary_op() const; |
| 2221 | 2208 |
| 2222 Token::Value op() const { return op_; } | 2209 Token::Value op() const { return op_; } |
| 2223 Expression* target() const { return target_; } | 2210 Expression* target() const { return target_; } |
| 2224 Expression* value() const { return value_; } | 2211 Expression* value() const { return value_; } |
| 2225 BinaryOperation* binary_operation() const { return binary_operation_; } | 2212 BinaryOperation* binary_operation() const { return binary_operation_; } |
| 2226 | 2213 |
| 2227 // This check relies on the definition order of token in token.h. | 2214 // This check relies on the definition order of token in token.h. |
| 2228 bool is_compound() const { return op() > Token::ASSIGN; } | 2215 bool is_compound() const { return op() > Token::ASSIGN; } |
| 2229 | 2216 |
| 2230 BailoutId AssignmentId() const { return BailoutId(base_id() + 0); } | 2217 static int num_ids() { return parent_num_ids() + 2; } |
| 2218 BailoutId AssignmentId() const { return BailoutId(local_id(0)); } | |
| 2231 | 2219 |
| 2232 // Type feedback information. | 2220 // Type feedback information. |
| 2233 TypeFeedbackId AssignmentFeedbackId() { | 2221 TypeFeedbackId AssignmentFeedbackId() { return TypeFeedbackId(local_id(1)); } |
| 2234 return TypeFeedbackId(base_id() + 1); | |
| 2235 } | |
| 2236 virtual bool IsMonomorphic() OVERRIDE { | 2222 virtual bool IsMonomorphic() OVERRIDE { |
| 2237 return receiver_types_.length() == 1; | 2223 return receiver_types_.length() == 1; |
| 2238 } | 2224 } |
| 2239 bool IsUninitialized() { return is_uninitialized_; } | 2225 bool IsUninitialized() { return is_uninitialized_; } |
| 2240 bool HasNoTypeInformation() { | 2226 bool HasNoTypeInformation() { |
| 2241 return is_uninitialized_; | 2227 return is_uninitialized_; |
| 2242 } | 2228 } |
| 2243 virtual SmallMapList* GetReceiverTypes() OVERRIDE { | 2229 virtual SmallMapList* GetReceiverTypes() OVERRIDE { |
| 2244 return &receiver_types_; | 2230 return &receiver_types_; |
| 2245 } | 2231 } |
| 2246 virtual KeyedAccessStoreMode GetStoreMode() OVERRIDE { | 2232 virtual KeyedAccessStoreMode GetStoreMode() OVERRIDE { |
| 2247 return store_mode_; | 2233 return store_mode_; |
| 2248 } | 2234 } |
| 2249 void set_is_uninitialized(bool b) { is_uninitialized_ = b; } | 2235 void set_is_uninitialized(bool b) { is_uninitialized_ = b; } |
| 2250 void set_store_mode(KeyedAccessStoreMode mode) { store_mode_ = mode; } | 2236 void set_store_mode(KeyedAccessStoreMode mode) { store_mode_ = mode; } |
| 2251 | 2237 |
| 2252 protected: | 2238 protected: |
| 2253 Assignment(Zone* zone, Token::Value op, Expression* target, Expression* value, | 2239 Assignment(Zone* zone, Token::Value op, Expression* target, Expression* value, |
| 2254 int pos, IdGen* id_gen); | 2240 int pos); |
| 2255 | 2241 static int parent_num_ids() { return Expression::num_ids(); } |
| 2256 static int num_ids() { return 2; } | |
| 2257 int base_id() const { return Expression::base_id() + Expression::num_ids(); } | |
| 2258 | 2242 |
| 2259 template<class Visitor> | 2243 template<class Visitor> |
| 2260 void Init(Zone* zone, AstNodeFactory<Visitor>* factory) { | 2244 void Init(Zone* zone, AstNodeFactory<Visitor>* factory) { |
| 2261 DCHECK(Token::IsAssignmentOp(op_)); | 2245 DCHECK(Token::IsAssignmentOp(op_)); |
| 2262 if (is_compound()) { | 2246 if (is_compound()) { |
| 2263 binary_operation_ = factory->NewBinaryOperation( | 2247 binary_operation_ = factory->NewBinaryOperation( |
| 2264 binary_op(), target_, value_, position() + 1); | 2248 binary_op(), target_, value_, position() + 1); |
| 2265 } | 2249 } |
| 2266 } | 2250 } |
| 2267 | 2251 |
| 2268 private: | 2252 private: |
| 2253 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | |
| 2254 | |
| 2269 Token::Value op_; | 2255 Token::Value op_; |
| 2270 Expression* target_; | 2256 Expression* target_; |
| 2271 Expression* value_; | 2257 Expression* value_; |
| 2272 BinaryOperation* binary_operation_; | 2258 BinaryOperation* binary_operation_; |
| 2273 bool is_uninitialized_ : 1; | 2259 bool is_uninitialized_ : 1; |
| 2274 KeyedAccessStoreMode store_mode_ : 5; // Windows treats as signed, | 2260 KeyedAccessStoreMode store_mode_ : 5; // Windows treats as signed, |
| 2275 // must have extra bit. | 2261 // must have extra bit. |
| 2276 SmallMapList receiver_types_; | 2262 SmallMapList receiver_types_; |
| 2277 }; | 2263 }; |
| 2278 | 2264 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2322 return yield_first_feedback_slot_ + 1; | 2308 return yield_first_feedback_slot_ + 1; |
| 2323 } | 2309 } |
| 2324 | 2310 |
| 2325 int ValueFeedbackSlot() { | 2311 int ValueFeedbackSlot() { |
| 2326 DCHECK(yield_first_feedback_slot_ != kInvalidFeedbackSlot); | 2312 DCHECK(yield_first_feedback_slot_ != kInvalidFeedbackSlot); |
| 2327 return yield_first_feedback_slot_ + 2; | 2313 return yield_first_feedback_slot_ + 2; |
| 2328 } | 2314 } |
| 2329 | 2315 |
| 2330 protected: | 2316 protected: |
| 2331 Yield(Zone* zone, Expression* generator_object, Expression* expression, | 2317 Yield(Zone* zone, Expression* generator_object, Expression* expression, |
| 2332 Kind yield_kind, int pos, IdGen* id_gen) | 2318 Kind yield_kind, int pos) |
| 2333 : Expression(zone, pos, 0, id_gen), | 2319 : Expression(zone, pos), |
| 2334 generator_object_(generator_object), | 2320 generator_object_(generator_object), |
| 2335 expression_(expression), | 2321 expression_(expression), |
| 2336 yield_kind_(yield_kind), | 2322 yield_kind_(yield_kind), |
| 2337 index_(-1), | 2323 index_(-1), |
| 2338 yield_first_feedback_slot_(kInvalidFeedbackSlot) {} | 2324 yield_first_feedback_slot_(kInvalidFeedbackSlot) {} |
| 2339 | 2325 |
| 2340 private: | 2326 private: |
| 2341 Expression* generator_object_; | 2327 Expression* generator_object_; |
| 2342 Expression* expression_; | 2328 Expression* expression_; |
| 2343 Kind yield_kind_; | 2329 Kind yield_kind_; |
| 2344 int index_; | 2330 int index_; |
| 2345 int yield_first_feedback_slot_; | 2331 int yield_first_feedback_slot_; |
| 2346 }; | 2332 }; |
| 2347 | 2333 |
| 2348 | 2334 |
| 2349 class Throw FINAL : public Expression { | 2335 class Throw FINAL : public Expression { |
| 2350 public: | 2336 public: |
| 2351 DECLARE_NODE_TYPE(Throw) | 2337 DECLARE_NODE_TYPE(Throw) |
| 2352 | 2338 |
| 2353 Expression* exception() const { return exception_; } | 2339 Expression* exception() const { return exception_; } |
| 2354 | 2340 |
| 2355 protected: | 2341 protected: |
| 2356 Throw(Zone* zone, Expression* exception, int pos, IdGen* id_gen) | 2342 Throw(Zone* zone, Expression* exception, int pos) |
| 2357 : Expression(zone, pos, 0, id_gen), exception_(exception) {} | 2343 : Expression(zone, pos), exception_(exception) {} |
| 2358 | 2344 |
| 2359 private: | 2345 private: |
| 2360 Expression* exception_; | 2346 Expression* exception_; |
| 2361 }; | 2347 }; |
| 2362 | 2348 |
| 2363 | 2349 |
| 2364 class FunctionLiteral FINAL : public Expression { | 2350 class FunctionLiteral FINAL : public Expression { |
| 2365 public: | 2351 public: |
| 2366 enum FunctionType { | 2352 enum FunctionType { |
| 2367 ANONYMOUS_EXPRESSION, | 2353 ANONYMOUS_EXPRESSION, |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2500 | 2486 |
| 2501 protected: | 2487 protected: |
| 2502 FunctionLiteral(Zone* zone, const AstRawString* name, | 2488 FunctionLiteral(Zone* zone, const AstRawString* name, |
| 2503 AstValueFactory* ast_value_factory, Scope* scope, | 2489 AstValueFactory* ast_value_factory, Scope* scope, |
| 2504 ZoneList<Statement*>* body, int materialized_literal_count, | 2490 ZoneList<Statement*>* body, int materialized_literal_count, |
| 2505 int expected_property_count, int handler_count, | 2491 int expected_property_count, int handler_count, |
| 2506 int parameter_count, FunctionType function_type, | 2492 int parameter_count, FunctionType function_type, |
| 2507 ParameterFlag has_duplicate_parameters, | 2493 ParameterFlag has_duplicate_parameters, |
| 2508 IsFunctionFlag is_function, | 2494 IsFunctionFlag is_function, |
| 2509 IsParenthesizedFlag is_parenthesized, FunctionKind kind, | 2495 IsParenthesizedFlag is_parenthesized, FunctionKind kind, |
| 2510 int position, IdGen* id_gen) | 2496 int position) |
| 2511 : Expression(zone, position, 0, id_gen), | 2497 : Expression(zone, position), |
| 2512 raw_name_(name), | 2498 raw_name_(name), |
| 2513 scope_(scope), | 2499 scope_(scope), |
| 2514 body_(body), | 2500 body_(body), |
| 2515 raw_inferred_name_(ast_value_factory->empty_string()), | 2501 raw_inferred_name_(ast_value_factory->empty_string()), |
| 2516 dont_optimize_reason_(kNoReason), | 2502 dont_optimize_reason_(kNoReason), |
| 2517 materialized_literal_count_(materialized_literal_count), | 2503 materialized_literal_count_(materialized_literal_count), |
| 2518 expected_property_count_(expected_property_count), | 2504 expected_property_count_(expected_property_count), |
| 2519 handler_count_(handler_count), | 2505 handler_count_(handler_count), |
| 2520 parameter_count_(parameter_count), | 2506 parameter_count_(parameter_count), |
| 2521 function_token_position_(RelocInfo::kNoPosition) { | 2507 function_token_position_(RelocInfo::kNoPosition) { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2567 const AstRawString* raw_name() const { return raw_name_; } | 2553 const AstRawString* raw_name() const { return raw_name_; } |
| 2568 Expression* extends() const { return extends_; } | 2554 Expression* extends() const { return extends_; } |
| 2569 Expression* constructor() const { return constructor_; } | 2555 Expression* constructor() const { return constructor_; } |
| 2570 ZoneList<Property*>* properties() const { return properties_; } | 2556 ZoneList<Property*>* properties() const { return properties_; } |
| 2571 int start_position() const { return position(); } | 2557 int start_position() const { return position(); } |
| 2572 int end_position() const { return end_position_; } | 2558 int end_position() const { return end_position_; } |
| 2573 | 2559 |
| 2574 protected: | 2560 protected: |
| 2575 ClassLiteral(Zone* zone, const AstRawString* name, Expression* extends, | 2561 ClassLiteral(Zone* zone, const AstRawString* name, Expression* extends, |
| 2576 Expression* constructor, ZoneList<Property*>* properties, | 2562 Expression* constructor, ZoneList<Property*>* properties, |
| 2577 int start_position, int end_position, IdGen* id_gen) | 2563 int start_position, int end_position) |
| 2578 : Expression(zone, start_position, 0, id_gen), | 2564 : Expression(zone, start_position), |
| 2579 raw_name_(name), | 2565 raw_name_(name), |
| 2580 extends_(extends), | 2566 extends_(extends), |
| 2581 constructor_(constructor), | 2567 constructor_(constructor), |
| 2582 properties_(properties), | 2568 properties_(properties), |
| 2583 end_position_(end_position) {} | 2569 end_position_(end_position) {} |
| 2584 | 2570 |
| 2585 private: | 2571 private: |
| 2586 const AstRawString* raw_name_; | 2572 const AstRawString* raw_name_; |
| 2587 Expression* extends_; | 2573 Expression* extends_; |
| 2588 Expression* constructor_; | 2574 Expression* constructor_; |
| 2589 ZoneList<Property*>* properties_; | 2575 ZoneList<Property*>* properties_; |
| 2590 int end_position_; | 2576 int end_position_; |
| 2591 }; | 2577 }; |
| 2592 | 2578 |
| 2593 | 2579 |
| 2594 class NativeFunctionLiteral FINAL : public Expression { | 2580 class NativeFunctionLiteral FINAL : public Expression { |
| 2595 public: | 2581 public: |
| 2596 DECLARE_NODE_TYPE(NativeFunctionLiteral) | 2582 DECLARE_NODE_TYPE(NativeFunctionLiteral) |
| 2597 | 2583 |
| 2598 Handle<String> name() const { return name_->string(); } | 2584 Handle<String> name() const { return name_->string(); } |
| 2599 v8::Extension* extension() const { return extension_; } | 2585 v8::Extension* extension() const { return extension_; } |
| 2600 | 2586 |
| 2601 protected: | 2587 protected: |
| 2602 NativeFunctionLiteral(Zone* zone, const AstRawString* name, | 2588 NativeFunctionLiteral(Zone* zone, const AstRawString* name, |
| 2603 v8::Extension* extension, int pos, IdGen* id_gen) | 2589 v8::Extension* extension, int pos) |
| 2604 : Expression(zone, pos, 0, id_gen), name_(name), extension_(extension) {} | 2590 : Expression(zone, pos), name_(name), extension_(extension) {} |
| 2605 | 2591 |
| 2606 private: | 2592 private: |
| 2607 const AstRawString* name_; | 2593 const AstRawString* name_; |
| 2608 v8::Extension* extension_; | 2594 v8::Extension* extension_; |
| 2609 }; | 2595 }; |
| 2610 | 2596 |
| 2611 | 2597 |
| 2612 class ThisFunction FINAL : public Expression { | 2598 class ThisFunction FINAL : public Expression { |
| 2613 public: | 2599 public: |
| 2614 DECLARE_NODE_TYPE(ThisFunction) | 2600 DECLARE_NODE_TYPE(ThisFunction) |
| 2615 | 2601 |
| 2616 protected: | 2602 protected: |
| 2617 ThisFunction(Zone* zone, int pos, IdGen* id_gen) | 2603 ThisFunction(Zone* zone, int pos) : Expression(zone, pos) {} |
| 2618 : Expression(zone, pos, 0, id_gen) {} | |
| 2619 }; | 2604 }; |
| 2620 | 2605 |
| 2621 | 2606 |
| 2622 class SuperReference FINAL : public Expression { | 2607 class SuperReference FINAL : public Expression { |
| 2623 public: | 2608 public: |
| 2624 DECLARE_NODE_TYPE(SuperReference) | 2609 DECLARE_NODE_TYPE(SuperReference) |
| 2625 | 2610 |
| 2626 VariableProxy* this_var() const { return this_var_; } | 2611 VariableProxy* this_var() const { return this_var_; } |
| 2627 | 2612 |
| 2628 TypeFeedbackId HomeObjectFeedbackId() { | 2613 static int num_ids() { return parent_num_ids() + 1; } |
| 2629 return TypeFeedbackId(base_id() + 0); | 2614 TypeFeedbackId HomeObjectFeedbackId() { return TypeFeedbackId(local_id(0)); } |
| 2630 } | |
| 2631 | 2615 |
| 2632 // Type feedback information. | 2616 // Type feedback information. |
| 2633 virtual int ComputeFeedbackSlotCount() { return FLAG_vector_ics ? 1 : 0; } | 2617 virtual int ComputeFeedbackSlotCount() { return FLAG_vector_ics ? 1 : 0; } |
| 2634 virtual void SetFirstFeedbackSlot(int slot) { | 2618 virtual void SetFirstFeedbackSlot(int slot) { |
| 2635 homeobject_feedback_slot_ = slot; | 2619 homeobject_feedback_slot_ = slot; |
| 2636 } | 2620 } |
| 2637 | 2621 |
| 2638 int HomeObjectFeedbackSlot() { | 2622 int HomeObjectFeedbackSlot() { |
| 2639 DCHECK(!FLAG_vector_ics || | 2623 DCHECK(!FLAG_vector_ics || |
| 2640 homeobject_feedback_slot_ != kInvalidFeedbackSlot); | 2624 homeobject_feedback_slot_ != kInvalidFeedbackSlot); |
| 2641 return homeobject_feedback_slot_; | 2625 return homeobject_feedback_slot_; |
| 2642 } | 2626 } |
| 2643 | 2627 |
| 2644 protected: | 2628 protected: |
| 2645 SuperReference(Zone* zone, VariableProxy* this_var, int pos, IdGen* id_gen) | 2629 SuperReference(Zone* zone, VariableProxy* this_var, int pos) |
| 2646 : Expression(zone, pos, num_ids(), id_gen), | 2630 : Expression(zone, pos), |
| 2647 this_var_(this_var), | 2631 this_var_(this_var), |
| 2648 homeobject_feedback_slot_(kInvalidFeedbackSlot) { | 2632 homeobject_feedback_slot_(kInvalidFeedbackSlot) { |
| 2649 DCHECK(this_var->is_this()); | 2633 DCHECK(this_var->is_this()); |
| 2650 } | 2634 } |
| 2651 | 2635 static int parent_num_ids() { return Expression::num_ids(); } |
| 2652 static int num_ids() { return 1; } | |
| 2653 int base_id() const { return Expression::base_id() + Expression::num_ids(); } | |
| 2654 | 2636 |
| 2655 private: | 2637 private: |
| 2638 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | |
| 2639 | |
| 2656 VariableProxy* this_var_; | 2640 VariableProxy* this_var_; |
| 2657 int homeobject_feedback_slot_; | 2641 int homeobject_feedback_slot_; |
| 2658 }; | 2642 }; |
| 2659 | 2643 |
| 2660 | 2644 |
| 2661 #undef DECLARE_NODE_TYPE | 2645 #undef DECLARE_NODE_TYPE |
| 2662 | 2646 |
| 2663 | 2647 |
| 2664 // ---------------------------------------------------------------------------- | 2648 // ---------------------------------------------------------------------------- |
| 2665 // Regular expressions | 2649 // Regular expressions |
| (...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3141 }; | 3125 }; |
| 3142 | 3126 |
| 3143 | 3127 |
| 3144 | 3128 |
| 3145 // ---------------------------------------------------------------------------- | 3129 // ---------------------------------------------------------------------------- |
| 3146 // AstNode factory | 3130 // AstNode factory |
| 3147 | 3131 |
| 3148 template<class Visitor> | 3132 template<class Visitor> |
| 3149 class AstNodeFactory FINAL BASE_EMBEDDED { | 3133 class AstNodeFactory FINAL BASE_EMBEDDED { |
| 3150 public: | 3134 public: |
| 3151 AstNodeFactory(Zone* zone, AstValueFactory* ast_value_factory, | 3135 AstNodeFactory(Zone* zone, AstValueFactory* ast_value_factory) |
| 3152 AstNode::IdGen* id_gen) | 3136 : zone_(zone), ast_value_factory_(ast_value_factory) {} |
| 3153 : zone_(zone), ast_value_factory_(ast_value_factory), id_gen_(id_gen) {} | |
| 3154 | 3137 |
| 3155 Visitor* visitor() { return &visitor_; } | 3138 Visitor* visitor() { return &visitor_; } |
| 3156 | 3139 |
| 3157 #define VISIT_AND_RETURN(NodeType, node) \ | 3140 #define VISIT_AND_RETURN(NodeType, node) \ |
| 3158 visitor_.Visit##NodeType((node)); \ | 3141 visitor_.Visit##NodeType((node)); \ |
| 3159 return node; | 3142 return node; |
| 3160 | 3143 |
| 3161 VariableDeclaration* NewVariableDeclaration(VariableProxy* proxy, | 3144 VariableDeclaration* NewVariableDeclaration(VariableProxy* proxy, |
| 3162 VariableMode mode, | 3145 VariableMode mode, |
| 3163 Scope* scope, | 3146 Scope* scope, |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3221 | 3204 |
| 3222 ModuleUrl* NewModuleUrl(Handle<String> url, int pos) { | 3205 ModuleUrl* NewModuleUrl(Handle<String> url, int pos) { |
| 3223 ModuleUrl* module = new(zone_) ModuleUrl(zone_, url, pos); | 3206 ModuleUrl* module = new(zone_) ModuleUrl(zone_, url, pos); |
| 3224 VISIT_AND_RETURN(ModuleUrl, module) | 3207 VISIT_AND_RETURN(ModuleUrl, module) |
| 3225 } | 3208 } |
| 3226 | 3209 |
| 3227 Block* NewBlock(ZoneList<const AstRawString*>* labels, | 3210 Block* NewBlock(ZoneList<const AstRawString*>* labels, |
| 3228 int capacity, | 3211 int capacity, |
| 3229 bool is_initializer_block, | 3212 bool is_initializer_block, |
| 3230 int pos) { | 3213 int pos) { |
| 3231 Block* block = new (zone_) | 3214 Block* block = |
| 3232 Block(zone_, labels, capacity, is_initializer_block, pos, id_gen_); | 3215 new (zone_) Block(zone_, labels, capacity, is_initializer_block, pos); |
| 3233 VISIT_AND_RETURN(Block, block) | 3216 VISIT_AND_RETURN(Block, block) |
| 3234 } | 3217 } |
| 3235 | 3218 |
| 3236 #define STATEMENT_WITH_LABELS(NodeType) \ | 3219 #define STATEMENT_WITH_LABELS(NodeType) \ |
| 3237 NodeType* New##NodeType(ZoneList<const AstRawString*>* labels, int pos) { \ | 3220 NodeType* New##NodeType(ZoneList<const AstRawString*>* labels, int pos) { \ |
| 3238 NodeType* stmt = new (zone_) NodeType(zone_, labels, pos, id_gen_); \ | 3221 NodeType* stmt = new (zone_) NodeType(zone_, labels, pos); \ |
| 3239 VISIT_AND_RETURN(NodeType, stmt); \ | 3222 VISIT_AND_RETURN(NodeType, stmt); \ |
| 3240 } | 3223 } |
| 3241 STATEMENT_WITH_LABELS(DoWhileStatement) | 3224 STATEMENT_WITH_LABELS(DoWhileStatement) |
| 3242 STATEMENT_WITH_LABELS(WhileStatement) | 3225 STATEMENT_WITH_LABELS(WhileStatement) |
| 3243 STATEMENT_WITH_LABELS(ForStatement) | 3226 STATEMENT_WITH_LABELS(ForStatement) |
| 3244 STATEMENT_WITH_LABELS(SwitchStatement) | 3227 STATEMENT_WITH_LABELS(SwitchStatement) |
| 3245 #undef STATEMENT_WITH_LABELS | 3228 #undef STATEMENT_WITH_LABELS |
| 3246 | 3229 |
| 3247 ForEachStatement* NewForEachStatement(ForEachStatement::VisitMode visit_mode, | 3230 ForEachStatement* NewForEachStatement(ForEachStatement::VisitMode visit_mode, |
| 3248 ZoneList<const AstRawString*>* labels, | 3231 ZoneList<const AstRawString*>* labels, |
| 3249 int pos) { | 3232 int pos) { |
| 3250 switch (visit_mode) { | 3233 switch (visit_mode) { |
| 3251 case ForEachStatement::ENUMERATE: { | 3234 case ForEachStatement::ENUMERATE: { |
| 3252 ForInStatement* stmt = | 3235 ForInStatement* stmt = new (zone_) ForInStatement(zone_, labels, pos); |
| 3253 new (zone_) ForInStatement(zone_, labels, pos, id_gen_); | |
| 3254 VISIT_AND_RETURN(ForInStatement, stmt); | 3236 VISIT_AND_RETURN(ForInStatement, stmt); |
| 3255 } | 3237 } |
| 3256 case ForEachStatement::ITERATE: { | 3238 case ForEachStatement::ITERATE: { |
| 3257 ForOfStatement* stmt = | 3239 ForOfStatement* stmt = new (zone_) ForOfStatement(zone_, labels, pos); |
| 3258 new (zone_) ForOfStatement(zone_, labels, pos, id_gen_); | |
| 3259 VISIT_AND_RETURN(ForOfStatement, stmt); | 3240 VISIT_AND_RETURN(ForOfStatement, stmt); |
| 3260 } | 3241 } |
| 3261 } | 3242 } |
| 3262 UNREACHABLE(); | 3243 UNREACHABLE(); |
| 3263 return NULL; | 3244 return NULL; |
| 3264 } | 3245 } |
| 3265 | 3246 |
| 3266 ModuleStatement* NewModuleStatement( | 3247 ModuleStatement* NewModuleStatement( |
| 3267 VariableProxy* proxy, Block* body, int pos) { | 3248 VariableProxy* proxy, Block* body, int pos) { |
| 3268 ModuleStatement* stmt = new(zone_) ModuleStatement(zone_, proxy, body, pos); | 3249 ModuleStatement* stmt = new(zone_) ModuleStatement(zone_, proxy, body, pos); |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 3296 int pos) { | 3277 int pos) { |
| 3297 WithStatement* stmt = new(zone_) WithStatement( | 3278 WithStatement* stmt = new(zone_) WithStatement( |
| 3298 zone_, scope, expression, statement, pos); | 3279 zone_, scope, expression, statement, pos); |
| 3299 VISIT_AND_RETURN(WithStatement, stmt) | 3280 VISIT_AND_RETURN(WithStatement, stmt) |
| 3300 } | 3281 } |
| 3301 | 3282 |
| 3302 IfStatement* NewIfStatement(Expression* condition, | 3283 IfStatement* NewIfStatement(Expression* condition, |
| 3303 Statement* then_statement, | 3284 Statement* then_statement, |
| 3304 Statement* else_statement, | 3285 Statement* else_statement, |
| 3305 int pos) { | 3286 int pos) { |
| 3306 IfStatement* stmt = new (zone_) IfStatement( | 3287 IfStatement* stmt = new (zone_) |
| 3307 zone_, condition, then_statement, else_statement, pos, id_gen_); | 3288 IfStatement(zone_, condition, then_statement, else_statement, pos); |
| 3308 VISIT_AND_RETURN(IfStatement, stmt) | 3289 VISIT_AND_RETURN(IfStatement, stmt) |
| 3309 } | 3290 } |
| 3310 | 3291 |
| 3311 TryCatchStatement* NewTryCatchStatement(int index, | 3292 TryCatchStatement* NewTryCatchStatement(int index, |
| 3312 Block* try_block, | 3293 Block* try_block, |
| 3313 Scope* scope, | 3294 Scope* scope, |
| 3314 Variable* variable, | 3295 Variable* variable, |
| 3315 Block* catch_block, | 3296 Block* catch_block, |
| 3316 int pos) { | 3297 int pos) { |
| 3317 TryCatchStatement* stmt = new(zone_) TryCatchStatement( | 3298 TryCatchStatement* stmt = new(zone_) TryCatchStatement( |
| 3318 zone_, index, try_block, scope, variable, catch_block, pos); | 3299 zone_, index, try_block, scope, variable, catch_block, pos); |
| 3319 VISIT_AND_RETURN(TryCatchStatement, stmt) | 3300 VISIT_AND_RETURN(TryCatchStatement, stmt) |
| 3320 } | 3301 } |
| 3321 | 3302 |
| 3322 TryFinallyStatement* NewTryFinallyStatement(int index, | 3303 TryFinallyStatement* NewTryFinallyStatement(int index, |
| 3323 Block* try_block, | 3304 Block* try_block, |
| 3324 Block* finally_block, | 3305 Block* finally_block, |
| 3325 int pos) { | 3306 int pos) { |
| 3326 TryFinallyStatement* stmt = new(zone_) TryFinallyStatement( | 3307 TryFinallyStatement* stmt = new(zone_) TryFinallyStatement( |
| 3327 zone_, index, try_block, finally_block, pos); | 3308 zone_, index, try_block, finally_block, pos); |
| 3328 VISIT_AND_RETURN(TryFinallyStatement, stmt) | 3309 VISIT_AND_RETURN(TryFinallyStatement, stmt) |
| 3329 } | 3310 } |
| 3330 | 3311 |
| 3331 DebuggerStatement* NewDebuggerStatement(int pos) { | 3312 DebuggerStatement* NewDebuggerStatement(int pos) { |
| 3332 DebuggerStatement* stmt = | 3313 DebuggerStatement* stmt = new (zone_) DebuggerStatement(zone_, pos); |
| 3333 new (zone_) DebuggerStatement(zone_, pos, id_gen_); | |
| 3334 VISIT_AND_RETURN(DebuggerStatement, stmt) | 3314 VISIT_AND_RETURN(DebuggerStatement, stmt) |
| 3335 } | 3315 } |
| 3336 | 3316 |
| 3337 EmptyStatement* NewEmptyStatement(int pos) { | 3317 EmptyStatement* NewEmptyStatement(int pos) { |
| 3338 return new(zone_) EmptyStatement(zone_, pos); | 3318 return new(zone_) EmptyStatement(zone_, pos); |
| 3339 } | 3319 } |
| 3340 | 3320 |
| 3341 CaseClause* NewCaseClause( | 3321 CaseClause* NewCaseClause( |
| 3342 Expression* label, ZoneList<Statement*>* statements, int pos) { | 3322 Expression* label, ZoneList<Statement*>* statements, int pos) { |
| 3343 CaseClause* clause = | 3323 CaseClause* clause = new (zone_) CaseClause(zone_, label, statements, pos); |
| 3344 new (zone_) CaseClause(zone_, label, statements, pos, id_gen_); | |
| 3345 VISIT_AND_RETURN(CaseClause, clause) | 3324 VISIT_AND_RETURN(CaseClause, clause) |
| 3346 } | 3325 } |
| 3347 | 3326 |
| 3348 Literal* NewStringLiteral(const AstRawString* string, int pos) { | 3327 Literal* NewStringLiteral(const AstRawString* string, int pos) { |
| 3349 Literal* lit = new (zone_) | 3328 Literal* lit = |
| 3350 Literal(zone_, ast_value_factory_->NewString(string), pos, id_gen_); | 3329 new (zone_) Literal(zone_, ast_value_factory_->NewString(string), pos); |
| 3351 VISIT_AND_RETURN(Literal, lit) | 3330 VISIT_AND_RETURN(Literal, lit) |
| 3352 } | 3331 } |
| 3353 | 3332 |
| 3354 // A JavaScript symbol (ECMA-262 edition 6). | 3333 // A JavaScript symbol (ECMA-262 edition 6). |
| 3355 Literal* NewSymbolLiteral(const char* name, int pos) { | 3334 Literal* NewSymbolLiteral(const char* name, int pos) { |
| 3356 Literal* lit = new (zone_) | 3335 Literal* lit = |
| 3357 Literal(zone_, ast_value_factory_->NewSymbol(name), pos, id_gen_); | 3336 new (zone_) Literal(zone_, ast_value_factory_->NewSymbol(name), pos); |
| 3358 VISIT_AND_RETURN(Literal, lit) | 3337 VISIT_AND_RETURN(Literal, lit) |
| 3359 } | 3338 } |
| 3360 | 3339 |
| 3361 Literal* NewNumberLiteral(double number, int pos) { | 3340 Literal* NewNumberLiteral(double number, int pos) { |
| 3362 Literal* lit = new (zone_) | 3341 Literal* lit = |
| 3363 Literal(zone_, ast_value_factory_->NewNumber(number), pos, id_gen_); | 3342 new (zone_) Literal(zone_, ast_value_factory_->NewNumber(number), pos); |
| 3364 VISIT_AND_RETURN(Literal, lit) | 3343 VISIT_AND_RETURN(Literal, lit) |
| 3365 } | 3344 } |
| 3366 | 3345 |
| 3367 Literal* NewSmiLiteral(int number, int pos) { | 3346 Literal* NewSmiLiteral(int number, int pos) { |
| 3368 Literal* lit = new (zone_) | 3347 Literal* lit = |
| 3369 Literal(zone_, ast_value_factory_->NewSmi(number), pos, id_gen_); | 3348 new (zone_) Literal(zone_, ast_value_factory_->NewSmi(number), pos); |
| 3370 VISIT_AND_RETURN(Literal, lit) | 3349 VISIT_AND_RETURN(Literal, lit) |
| 3371 } | 3350 } |
| 3372 | 3351 |
| 3373 Literal* NewBooleanLiteral(bool b, int pos) { | 3352 Literal* NewBooleanLiteral(bool b, int pos) { |
| 3374 Literal* lit = new (zone_) | 3353 Literal* lit = |
| 3375 Literal(zone_, ast_value_factory_->NewBoolean(b), pos, id_gen_); | 3354 new (zone_) Literal(zone_, ast_value_factory_->NewBoolean(b), pos); |
| 3376 VISIT_AND_RETURN(Literal, lit) | 3355 VISIT_AND_RETURN(Literal, lit) |
| 3377 } | 3356 } |
| 3378 | 3357 |
| 3379 Literal* NewStringListLiteral(ZoneList<const AstRawString*>* strings, | 3358 Literal* NewStringListLiteral(ZoneList<const AstRawString*>* strings, |
| 3380 int pos) { | 3359 int pos) { |
| 3381 Literal* lit = new (zone_) Literal( | 3360 Literal* lit = new (zone_) |
| 3382 zone_, ast_value_factory_->NewStringList(strings), pos, id_gen_); | 3361 Literal(zone_, ast_value_factory_->NewStringList(strings), pos); |
| 3383 VISIT_AND_RETURN(Literal, lit) | 3362 VISIT_AND_RETURN(Literal, lit) |
| 3384 } | 3363 } |
| 3385 | 3364 |
| 3386 Literal* NewNullLiteral(int pos) { | 3365 Literal* NewNullLiteral(int pos) { |
| 3387 Literal* lit = | 3366 Literal* lit = |
| 3388 new (zone_) Literal(zone_, ast_value_factory_->NewNull(), pos, id_gen_); | 3367 new (zone_) Literal(zone_, ast_value_factory_->NewNull(), pos); |
| 3389 VISIT_AND_RETURN(Literal, lit) | 3368 VISIT_AND_RETURN(Literal, lit) |
| 3390 } | 3369 } |
| 3391 | 3370 |
| 3392 Literal* NewUndefinedLiteral(int pos) { | 3371 Literal* NewUndefinedLiteral(int pos) { |
| 3393 Literal* lit = new (zone_) | 3372 Literal* lit = |
| 3394 Literal(zone_, ast_value_factory_->NewUndefined(), pos, id_gen_); | 3373 new (zone_) Literal(zone_, ast_value_factory_->NewUndefined(), pos); |
| 3395 VISIT_AND_RETURN(Literal, lit) | 3374 VISIT_AND_RETURN(Literal, lit) |
| 3396 } | 3375 } |
| 3397 | 3376 |
| 3398 Literal* NewTheHoleLiteral(int pos) { | 3377 Literal* NewTheHoleLiteral(int pos) { |
| 3399 Literal* lit = new (zone_) | 3378 Literal* lit = |
| 3400 Literal(zone_, ast_value_factory_->NewTheHole(), pos, id_gen_); | 3379 new (zone_) Literal(zone_, ast_value_factory_->NewTheHole(), pos); |
| 3401 VISIT_AND_RETURN(Literal, lit) | 3380 VISIT_AND_RETURN(Literal, lit) |
| 3402 } | 3381 } |
| 3403 | 3382 |
| 3404 ObjectLiteral* NewObjectLiteral( | 3383 ObjectLiteral* NewObjectLiteral( |
| 3405 ZoneList<ObjectLiteral::Property*>* properties, | 3384 ZoneList<ObjectLiteral::Property*>* properties, |
| 3406 int literal_index, | 3385 int literal_index, |
| 3407 int boilerplate_properties, | 3386 int boilerplate_properties, |
| 3408 bool has_function, | 3387 bool has_function, |
| 3409 int pos) { | 3388 int pos) { |
| 3410 ObjectLiteral* lit = new (zone_) | 3389 ObjectLiteral* lit = |
| 3411 ObjectLiteral(zone_, properties, literal_index, boilerplate_properties, | 3390 new (zone_) ObjectLiteral(zone_, properties, literal_index, |
| 3412 has_function, pos, id_gen_); | 3391 boilerplate_properties, has_function, pos); |
| 3413 VISIT_AND_RETURN(ObjectLiteral, lit) | 3392 VISIT_AND_RETURN(ObjectLiteral, lit) |
| 3414 } | 3393 } |
| 3415 | 3394 |
| 3416 ObjectLiteral::Property* NewObjectLiteralProperty(Literal* key, | 3395 ObjectLiteral::Property* NewObjectLiteralProperty(Literal* key, |
| 3417 Expression* value, | 3396 Expression* value, |
| 3418 bool is_static) { | 3397 bool is_static) { |
| 3419 return new (zone_) ObjectLiteral::Property(zone_, ast_value_factory_, key, | 3398 return new (zone_) ObjectLiteral::Property(zone_, ast_value_factory_, key, |
| 3420 value, is_static); | 3399 value, is_static); |
| 3421 } | 3400 } |
| 3422 | 3401 |
| 3423 ObjectLiteral::Property* NewObjectLiteralProperty(bool is_getter, | 3402 ObjectLiteral::Property* NewObjectLiteralProperty(bool is_getter, |
| 3424 FunctionLiteral* value, | 3403 FunctionLiteral* value, |
| 3425 int pos, bool is_static) { | 3404 int pos, bool is_static) { |
| 3426 ObjectLiteral::Property* prop = | 3405 ObjectLiteral::Property* prop = |
| 3427 new (zone_) ObjectLiteral::Property(zone_, is_getter, value, is_static); | 3406 new (zone_) ObjectLiteral::Property(zone_, is_getter, value, is_static); |
| 3428 prop->set_key(NewStringLiteral(value->raw_name(), pos)); | 3407 prop->set_key(NewStringLiteral(value->raw_name(), pos)); |
| 3429 return prop; // Not an AST node, will not be visited. | 3408 return prop; // Not an AST node, will not be visited. |
| 3430 } | 3409 } |
| 3431 | 3410 |
| 3432 RegExpLiteral* NewRegExpLiteral(const AstRawString* pattern, | 3411 RegExpLiteral* NewRegExpLiteral(const AstRawString* pattern, |
| 3433 const AstRawString* flags, | 3412 const AstRawString* flags, |
| 3434 int literal_index, | 3413 int literal_index, |
| 3435 int pos) { | 3414 int pos) { |
| 3436 RegExpLiteral* lit = new (zone_) | 3415 RegExpLiteral* lit = |
| 3437 RegExpLiteral(zone_, pattern, flags, literal_index, pos, id_gen_); | 3416 new (zone_) RegExpLiteral(zone_, pattern, flags, literal_index, pos); |
| 3438 VISIT_AND_RETURN(RegExpLiteral, lit); | 3417 VISIT_AND_RETURN(RegExpLiteral, lit); |
| 3439 } | 3418 } |
| 3440 | 3419 |
| 3441 ArrayLiteral* NewArrayLiteral(ZoneList<Expression*>* values, | 3420 ArrayLiteral* NewArrayLiteral(ZoneList<Expression*>* values, |
| 3442 int literal_index, | 3421 int literal_index, |
| 3443 int pos) { | 3422 int pos) { |
| 3444 ArrayLiteral* lit = | 3423 ArrayLiteral* lit = |
| 3445 new (zone_) ArrayLiteral(zone_, values, literal_index, pos, id_gen_); | 3424 new (zone_) ArrayLiteral(zone_, values, literal_index, pos); |
| 3446 VISIT_AND_RETURN(ArrayLiteral, lit) | 3425 VISIT_AND_RETURN(ArrayLiteral, lit) |
| 3447 } | 3426 } |
| 3448 | 3427 |
| 3449 VariableProxy* NewVariableProxy(Variable* var, | 3428 VariableProxy* NewVariableProxy(Variable* var, |
| 3450 int pos = RelocInfo::kNoPosition) { | 3429 int pos = RelocInfo::kNoPosition) { |
| 3451 VariableProxy* proxy = new (zone_) VariableProxy(zone_, var, pos, id_gen_); | 3430 VariableProxy* proxy = new (zone_) VariableProxy(zone_, var, pos); |
| 3452 VISIT_AND_RETURN(VariableProxy, proxy) | 3431 VISIT_AND_RETURN(VariableProxy, proxy) |
| 3453 } | 3432 } |
| 3454 | 3433 |
| 3455 VariableProxy* NewVariableProxy(const AstRawString* name, | 3434 VariableProxy* NewVariableProxy(const AstRawString* name, |
| 3456 bool is_this, | 3435 bool is_this, |
| 3457 Interface* interface = Interface::NewValue(), | 3436 Interface* interface = Interface::NewValue(), |
| 3458 int position = RelocInfo::kNoPosition) { | 3437 int position = RelocInfo::kNoPosition) { |
| 3459 VariableProxy* proxy = new (zone_) | 3438 VariableProxy* proxy = |
| 3460 VariableProxy(zone_, name, is_this, interface, position, id_gen_); | 3439 new (zone_) VariableProxy(zone_, name, is_this, interface, position); |
| 3461 VISIT_AND_RETURN(VariableProxy, proxy) | 3440 VISIT_AND_RETURN(VariableProxy, proxy) |
| 3462 } | 3441 } |
| 3463 | 3442 |
| 3464 Property* NewProperty(Expression* obj, Expression* key, int pos) { | 3443 Property* NewProperty(Expression* obj, Expression* key, int pos) { |
| 3465 Property* prop = new (zone_) Property(zone_, obj, key, pos, id_gen_); | 3444 Property* prop = new (zone_) Property(zone_, obj, key, pos); |
| 3466 VISIT_AND_RETURN(Property, prop) | 3445 VISIT_AND_RETURN(Property, prop) |
| 3467 } | 3446 } |
| 3468 | 3447 |
| 3469 Call* NewCall(Expression* expression, | 3448 Call* NewCall(Expression* expression, |
| 3470 ZoneList<Expression*>* arguments, | 3449 ZoneList<Expression*>* arguments, |
| 3471 int pos) { | 3450 int pos) { |
| 3472 SuperReference* super_ref = expression->AsSuperReference(); | 3451 SuperReference* super_ref = expression->AsSuperReference(); |
| 3473 Call* call; | 3452 Call* call; |
| 3474 if (super_ref != NULL) { | 3453 if (super_ref != NULL) { |
| 3475 Literal* constructor = | 3454 Literal* constructor = |
| 3476 NewStringLiteral(ast_value_factory_->constructor_string(), pos); | 3455 NewStringLiteral(ast_value_factory_->constructor_string(), pos); |
| 3477 Property* superConstructor = NewProperty(super_ref, constructor, pos); | 3456 Property* superConstructor = NewProperty(super_ref, constructor, pos); |
| 3478 call = new (zone_) Call(zone_, superConstructor, arguments, pos, id_gen_); | 3457 call = new (zone_) Call(zone_, superConstructor, arguments, pos); |
| 3479 } else { | 3458 } else { |
| 3480 call = new (zone_) Call(zone_, expression, arguments, pos, id_gen_); | 3459 call = new (zone_) Call(zone_, expression, arguments, pos); |
| 3481 } | 3460 } |
| 3482 VISIT_AND_RETURN(Call, call) | 3461 VISIT_AND_RETURN(Call, call) |
| 3483 } | 3462 } |
| 3484 | 3463 |
| 3485 CallNew* NewCallNew(Expression* expression, | 3464 CallNew* NewCallNew(Expression* expression, |
| 3486 ZoneList<Expression*>* arguments, | 3465 ZoneList<Expression*>* arguments, |
| 3487 int pos) { | 3466 int pos) { |
| 3488 CallNew* call = | 3467 CallNew* call = new (zone_) CallNew(zone_, expression, arguments, pos); |
| 3489 new (zone_) CallNew(zone_, expression, arguments, pos, id_gen_); | |
| 3490 VISIT_AND_RETURN(CallNew, call) | 3468 VISIT_AND_RETURN(CallNew, call) |
| 3491 } | 3469 } |
| 3492 | 3470 |
| 3493 CallRuntime* NewCallRuntime(const AstRawString* name, | 3471 CallRuntime* NewCallRuntime(const AstRawString* name, |
| 3494 const Runtime::Function* function, | 3472 const Runtime::Function* function, |
| 3495 ZoneList<Expression*>* arguments, | 3473 ZoneList<Expression*>* arguments, |
| 3496 int pos) { | 3474 int pos) { |
| 3497 CallRuntime* call = | 3475 CallRuntime* call = |
| 3498 new (zone_) CallRuntime(zone_, name, function, arguments, pos, id_gen_); | 3476 new (zone_) CallRuntime(zone_, name, function, arguments, pos); |
| 3499 VISIT_AND_RETURN(CallRuntime, call) | 3477 VISIT_AND_RETURN(CallRuntime, call) |
| 3500 } | 3478 } |
| 3501 | 3479 |
| 3502 UnaryOperation* NewUnaryOperation(Token::Value op, | 3480 UnaryOperation* NewUnaryOperation(Token::Value op, |
| 3503 Expression* expression, | 3481 Expression* expression, |
| 3504 int pos) { | 3482 int pos) { |
| 3505 UnaryOperation* node = | 3483 UnaryOperation* node = |
| 3506 new (zone_) UnaryOperation(zone_, op, expression, pos, id_gen_); | 3484 new (zone_) UnaryOperation(zone_, op, expression, pos); |
| 3507 VISIT_AND_RETURN(UnaryOperation, node) | 3485 VISIT_AND_RETURN(UnaryOperation, node) |
| 3508 } | 3486 } |
| 3509 | 3487 |
| 3510 BinaryOperation* NewBinaryOperation(Token::Value op, | 3488 BinaryOperation* NewBinaryOperation(Token::Value op, |
| 3511 Expression* left, | 3489 Expression* left, |
| 3512 Expression* right, | 3490 Expression* right, |
| 3513 int pos) { | 3491 int pos) { |
| 3514 BinaryOperation* node = | 3492 BinaryOperation* node = |
| 3515 new (zone_) BinaryOperation(zone_, op, left, right, pos, id_gen_); | 3493 new (zone_) BinaryOperation(zone_, op, left, right, pos); |
| 3516 VISIT_AND_RETURN(BinaryOperation, node) | 3494 VISIT_AND_RETURN(BinaryOperation, node) |
| 3517 } | 3495 } |
| 3518 | 3496 |
| 3519 CountOperation* NewCountOperation(Token::Value op, | 3497 CountOperation* NewCountOperation(Token::Value op, |
| 3520 bool is_prefix, | 3498 bool is_prefix, |
| 3521 Expression* expr, | 3499 Expression* expr, |
| 3522 int pos) { | 3500 int pos) { |
| 3523 CountOperation* node = | 3501 CountOperation* node = |
| 3524 new (zone_) CountOperation(zone_, op, is_prefix, expr, pos, id_gen_); | 3502 new (zone_) CountOperation(zone_, op, is_prefix, expr, pos); |
| 3525 VISIT_AND_RETURN(CountOperation, node) | 3503 VISIT_AND_RETURN(CountOperation, node) |
| 3526 } | 3504 } |
| 3527 | 3505 |
| 3528 CompareOperation* NewCompareOperation(Token::Value op, | 3506 CompareOperation* NewCompareOperation(Token::Value op, |
| 3529 Expression* left, | 3507 Expression* left, |
| 3530 Expression* right, | 3508 Expression* right, |
| 3531 int pos) { | 3509 int pos) { |
| 3532 CompareOperation* node = | 3510 CompareOperation* node = |
| 3533 new (zone_) CompareOperation(zone_, op, left, right, pos, id_gen_); | 3511 new (zone_) CompareOperation(zone_, op, left, right, pos); |
| 3534 VISIT_AND_RETURN(CompareOperation, node) | 3512 VISIT_AND_RETURN(CompareOperation, node) |
| 3535 } | 3513 } |
| 3536 | 3514 |
| 3537 Conditional* NewConditional(Expression* condition, | 3515 Conditional* NewConditional(Expression* condition, |
| 3538 Expression* then_expression, | 3516 Expression* then_expression, |
| 3539 Expression* else_expression, | 3517 Expression* else_expression, |
| 3540 int position) { | 3518 int position) { |
| 3541 Conditional* cond = new (zone_) Conditional( | 3519 Conditional* cond = new (zone_) Conditional( |
| 3542 zone_, condition, then_expression, else_expression, position, id_gen_); | 3520 zone_, condition, then_expression, else_expression, position); |
| 3543 VISIT_AND_RETURN(Conditional, cond) | 3521 VISIT_AND_RETURN(Conditional, cond) |
| 3544 } | 3522 } |
| 3545 | 3523 |
| 3546 Assignment* NewAssignment(Token::Value op, | 3524 Assignment* NewAssignment(Token::Value op, |
| 3547 Expression* target, | 3525 Expression* target, |
| 3548 Expression* value, | 3526 Expression* value, |
| 3549 int pos) { | 3527 int pos) { |
| 3550 Assignment* assign = | 3528 Assignment* assign = new (zone_) Assignment(zone_, op, target, value, pos); |
| 3551 new (zone_) Assignment(zone_, op, target, value, pos, id_gen_); | |
| 3552 assign->Init(zone_, this); | 3529 assign->Init(zone_, this); |
| 3553 VISIT_AND_RETURN(Assignment, assign) | 3530 VISIT_AND_RETURN(Assignment, assign) |
| 3554 } | 3531 } |
| 3555 | 3532 |
| 3556 Yield* NewYield(Expression *generator_object, | 3533 Yield* NewYield(Expression *generator_object, |
| 3557 Expression* expression, | 3534 Expression* expression, |
| 3558 Yield::Kind yield_kind, | 3535 Yield::Kind yield_kind, |
| 3559 int pos) { | 3536 int pos) { |
| 3560 if (!expression) expression = NewUndefinedLiteral(pos); | 3537 if (!expression) expression = NewUndefinedLiteral(pos); |
| 3561 Yield* yield = new (zone_) | 3538 Yield* yield = |
| 3562 Yield(zone_, generator_object, expression, yield_kind, pos, id_gen_); | 3539 new (zone_) Yield(zone_, generator_object, expression, yield_kind, pos); |
| 3563 VISIT_AND_RETURN(Yield, yield) | 3540 VISIT_AND_RETURN(Yield, yield) |
| 3564 } | 3541 } |
| 3565 | 3542 |
| 3566 Throw* NewThrow(Expression* exception, int pos) { | 3543 Throw* NewThrow(Expression* exception, int pos) { |
| 3567 Throw* t = new (zone_) Throw(zone_, exception, pos, id_gen_); | 3544 Throw* t = new (zone_) Throw(zone_, exception, pos); |
| 3568 VISIT_AND_RETURN(Throw, t) | 3545 VISIT_AND_RETURN(Throw, t) |
| 3569 } | 3546 } |
| 3570 | 3547 |
| 3571 FunctionLiteral* NewFunctionLiteral( | 3548 FunctionLiteral* NewFunctionLiteral( |
| 3572 const AstRawString* name, AstValueFactory* ast_value_factory, | 3549 const AstRawString* name, AstValueFactory* ast_value_factory, |
| 3573 Scope* scope, ZoneList<Statement*>* body, int materialized_literal_count, | 3550 Scope* scope, ZoneList<Statement*>* body, int materialized_literal_count, |
| 3574 int expected_property_count, int handler_count, int parameter_count, | 3551 int expected_property_count, int handler_count, int parameter_count, |
| 3575 FunctionLiteral::ParameterFlag has_duplicate_parameters, | 3552 FunctionLiteral::ParameterFlag has_duplicate_parameters, |
| 3576 FunctionLiteral::FunctionType function_type, | 3553 FunctionLiteral::FunctionType function_type, |
| 3577 FunctionLiteral::IsFunctionFlag is_function, | 3554 FunctionLiteral::IsFunctionFlag is_function, |
| 3578 FunctionLiteral::IsParenthesizedFlag is_parenthesized, FunctionKind kind, | 3555 FunctionLiteral::IsParenthesizedFlag is_parenthesized, FunctionKind kind, |
| 3579 int position) { | 3556 int position) { |
| 3580 FunctionLiteral* lit = new (zone_) FunctionLiteral( | 3557 FunctionLiteral* lit = new (zone_) FunctionLiteral( |
| 3581 zone_, name, ast_value_factory, scope, body, materialized_literal_count, | 3558 zone_, name, ast_value_factory, scope, body, materialized_literal_count, |
| 3582 expected_property_count, handler_count, parameter_count, function_type, | 3559 expected_property_count, handler_count, parameter_count, function_type, |
| 3583 has_duplicate_parameters, is_function, is_parenthesized, kind, position, | 3560 has_duplicate_parameters, is_function, is_parenthesized, kind, |
| 3584 id_gen_); | 3561 position); |
| 3585 // Top-level literal doesn't count for the AST's properties. | 3562 // Top-level literal doesn't count for the AST's properties. |
| 3586 if (is_function == FunctionLiteral::kIsFunction) { | 3563 if (is_function == FunctionLiteral::kIsFunction) { |
| 3587 visitor_.VisitFunctionLiteral(lit); | 3564 visitor_.VisitFunctionLiteral(lit); |
| 3588 } | 3565 } |
| 3589 return lit; | 3566 return lit; |
| 3590 } | 3567 } |
| 3591 | 3568 |
| 3592 ClassLiteral* NewClassLiteral(const AstRawString* name, Expression* extends, | 3569 ClassLiteral* NewClassLiteral(const AstRawString* name, Expression* extends, |
| 3593 Expression* constructor, | 3570 Expression* constructor, |
| 3594 ZoneList<ObjectLiteral::Property*>* properties, | 3571 ZoneList<ObjectLiteral::Property*>* properties, |
| 3595 int start_position, int end_position) { | 3572 int start_position, int end_position) { |
| 3596 ClassLiteral* lit = | 3573 ClassLiteral* lit = |
| 3597 new (zone_) ClassLiteral(zone_, name, extends, constructor, properties, | 3574 new (zone_) ClassLiteral(zone_, name, extends, constructor, properties, |
| 3598 start_position, end_position, id_gen_); | 3575 start_position, end_position); |
| 3599 VISIT_AND_RETURN(ClassLiteral, lit) | 3576 VISIT_AND_RETURN(ClassLiteral, lit) |
| 3600 } | 3577 } |
| 3601 | 3578 |
| 3602 NativeFunctionLiteral* NewNativeFunctionLiteral(const AstRawString* name, | 3579 NativeFunctionLiteral* NewNativeFunctionLiteral(const AstRawString* name, |
| 3603 v8::Extension* extension, | 3580 v8::Extension* extension, |
| 3604 int pos) { | 3581 int pos) { |
| 3605 NativeFunctionLiteral* lit = | 3582 NativeFunctionLiteral* lit = |
| 3606 new (zone_) NativeFunctionLiteral(zone_, name, extension, pos, id_gen_); | 3583 new (zone_) NativeFunctionLiteral(zone_, name, extension, pos); |
| 3607 VISIT_AND_RETURN(NativeFunctionLiteral, lit) | 3584 VISIT_AND_RETURN(NativeFunctionLiteral, lit) |
| 3608 } | 3585 } |
| 3609 | 3586 |
| 3610 ThisFunction* NewThisFunction(int pos) { | 3587 ThisFunction* NewThisFunction(int pos) { |
| 3611 ThisFunction* fun = new (zone_) ThisFunction(zone_, pos, id_gen_); | 3588 ThisFunction* fun = new (zone_) ThisFunction(zone_, pos); |
| 3612 VISIT_AND_RETURN(ThisFunction, fun) | 3589 VISIT_AND_RETURN(ThisFunction, fun) |
| 3613 } | 3590 } |
| 3614 | 3591 |
| 3615 SuperReference* NewSuperReference(VariableProxy* this_var, int pos) { | 3592 SuperReference* NewSuperReference(VariableProxy* this_var, int pos) { |
| 3616 SuperReference* super = | 3593 SuperReference* super = new (zone_) SuperReference(zone_, this_var, pos); |
| 3617 new (zone_) SuperReference(zone_, this_var, pos, id_gen_); | |
| 3618 VISIT_AND_RETURN(SuperReference, super); | 3594 VISIT_AND_RETURN(SuperReference, super); |
| 3619 } | 3595 } |
| 3620 | 3596 |
| 3621 #undef VISIT_AND_RETURN | 3597 #undef VISIT_AND_RETURN |
| 3622 | 3598 |
| 3623 private: | 3599 private: |
| 3624 Zone* zone_; | 3600 Zone* zone_; |
| 3625 Visitor visitor_; | 3601 Visitor visitor_; |
| 3626 AstValueFactory* ast_value_factory_; | 3602 AstValueFactory* ast_value_factory_; |
| 3627 AstNode::IdGen* id_gen_; | |
| 3628 }; | 3603 }; |
| 3629 | 3604 |
| 3630 | 3605 |
| 3631 } } // namespace v8::internal | 3606 } } // namespace v8::internal |
| 3632 | 3607 |
| 3633 #endif // V8_AST_H_ | 3608 #endif // V8_AST_H_ |
| OLD | NEW |