| 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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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. | 184 // For generating IDs for AstNodes. |
| 185 class IdGen { | 185 class IdGen { |
| 186 public: | 186 public: |
| 187 IdGen() : id_(BailoutId::FirstUsable().ToInt()) {} | 187 IdGen() : id_(BailoutId::FirstUsable().ToInt()) {} |
| 188 | 188 |
| 189 int GetNextId() { return ReserveIdRange(1); } | |
| 190 int ReserveIdRange(int n) { | 189 int ReserveIdRange(int n) { |
| 191 int tmp = id_; | 190 int tmp = id_; |
| 192 id_ += n; | 191 id_ += n; |
| 193 return tmp; | 192 return tmp; |
| 194 } | 193 } |
| 195 | 194 |
| 196 private: | 195 private: |
| 197 int id_; | 196 int id_; |
| 198 | 197 |
| 199 DISALLOW_COPY_AND_ASSIGN(IdGen); | 198 DISALLOW_COPY_AND_ASSIGN(IdGen); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 // node types which don't actually have this. Note that this is conceptually | 237 // node types which don't actually have this. Note that this is conceptually |
| 239 // not really nice, but multiple inheritance would introduce yet another | 238 // not really nice, but multiple inheritance would introduce yet another |
| 240 // vtable entry per node, something we don't want for space reasons. | 239 // vtable entry per node, something we don't want for space reasons. |
| 241 static const int kInvalidFeedbackSlot = -1; | 240 static const int kInvalidFeedbackSlot = -1; |
| 242 virtual int ComputeFeedbackSlotCount() { | 241 virtual int ComputeFeedbackSlotCount() { |
| 243 UNREACHABLE(); | 242 UNREACHABLE(); |
| 244 return 0; | 243 return 0; |
| 245 } | 244 } |
| 246 virtual void SetFirstFeedbackSlot(int slot) { UNREACHABLE(); } | 245 virtual void SetFirstFeedbackSlot(int slot) { UNREACHABLE(); } |
| 247 | 246 |
| 248 protected: | |
| 249 // Some nodes re-use bailout IDs for type feedback. | |
| 250 static TypeFeedbackId reuse(BailoutId id) { | |
| 251 return TypeFeedbackId(id.ToInt()); | |
| 252 } | |
| 253 | |
| 254 | |
| 255 private: | 247 private: |
| 256 // Hidden to prevent accidental usage. It would have to load the | 248 // Hidden to prevent accidental usage. It would have to load the |
| 257 // current zone from the TLS. | 249 // current zone from the TLS. |
| 258 void* operator new(size_t size); | 250 void* operator new(size_t size); |
| 259 | 251 |
| 260 friend class CaseClause; // Generates AST IDs. | 252 friend class CaseClause; // Generates AST IDs. |
| 261 | 253 |
| 262 int position_; | 254 int position_; |
| 263 }; | 255 }; |
| 264 | 256 |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 } | 375 } |
| 384 virtual KeyedAccessStoreMode GetStoreMode() { | 376 virtual KeyedAccessStoreMode GetStoreMode() { |
| 385 UNREACHABLE(); | 377 UNREACHABLE(); |
| 386 return STANDARD_STORE; | 378 return STANDARD_STORE; |
| 387 } | 379 } |
| 388 | 380 |
| 389 // TODO(rossberg): this should move to its own AST node eventually. | 381 // TODO(rossberg): this should move to its own AST node eventually. |
| 390 virtual void RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle); | 382 virtual void RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle); |
| 391 byte to_boolean_types() const { return to_boolean_types_; } | 383 byte to_boolean_types() const { return to_boolean_types_; } |
| 392 | 384 |
| 393 BailoutId id() const { return id_; } | 385 BailoutId id() const { return BailoutId(base_id() + 0); } |
| 394 TypeFeedbackId test_id() const { return test_id_; } | 386 TypeFeedbackId test_id() const { return TypeFeedbackId(base_id() + 1); } |
| 395 | 387 |
| 396 protected: | 388 protected: |
| 397 Expression(Zone* zone, int pos, IdGen* id_gen) | 389 Expression(Zone* zone, int pos, int num_ids_needed_by_subclass, IdGen* id_gen) |
| 398 : AstNode(pos), | 390 : AstNode(pos), |
| 399 is_parenthesized_(false), | 391 is_parenthesized_(false), |
| 400 is_multi_parenthesized_(false), | 392 is_multi_parenthesized_(false), |
| 401 bounds_(Bounds::Unbounded(zone)), | 393 bounds_(Bounds::Unbounded(zone)), |
| 402 id_(id_gen->GetNextId()), | 394 base_id_( |
| 403 test_id_(id_gen->GetNextId()) {} | 395 id_gen->ReserveIdRange(num_ids_needed_by_subclass + num_ids())) {} |
| 404 void set_to_boolean_types(byte types) { to_boolean_types_ = types; } | 396 void set_to_boolean_types(byte types) { to_boolean_types_ = types; } |
| 405 | 397 |
| 398 static int num_ids() { return 2; } |
| 399 int base_id() const { return base_id_; } |
| 400 |
| 406 private: | 401 private: |
| 407 byte to_boolean_types_; | 402 byte to_boolean_types_; |
| 408 bool is_parenthesized_ : 1; | 403 bool is_parenthesized_ : 1; |
| 409 bool is_multi_parenthesized_ : 1; | 404 bool is_multi_parenthesized_ : 1; |
| 410 Bounds bounds_; | 405 Bounds bounds_; |
| 411 | 406 const int base_id_; |
| 412 const BailoutId id_; | |
| 413 const TypeFeedbackId test_id_; | |
| 414 }; | 407 }; |
| 415 | 408 |
| 416 | 409 |
| 417 class BreakableStatement : public Statement { | 410 class BreakableStatement : public Statement { |
| 418 public: | 411 public: |
| 419 enum BreakableType { | 412 enum BreakableType { |
| 420 TARGET_FOR_ANONYMOUS, | 413 TARGET_FOR_ANONYMOUS, |
| 421 TARGET_FOR_NAMED_ONLY | 414 TARGET_FOR_NAMED_ONLY |
| 422 }; | 415 }; |
| 423 | 416 |
| 424 // The labels associated with this statement. May be NULL; | 417 // The labels associated with this statement. May be NULL; |
| 425 // if it is != NULL, guaranteed to contain at least one entry. | 418 // if it is != NULL, guaranteed to contain at least one entry. |
| 426 ZoneList<const AstRawString*>* labels() const { return labels_; } | 419 ZoneList<const AstRawString*>* labels() const { return labels_; } |
| 427 | 420 |
| 428 // Type testing & conversion. | 421 // Type testing & conversion. |
| 429 virtual BreakableStatement* AsBreakableStatement() FINAL OVERRIDE { | 422 virtual BreakableStatement* AsBreakableStatement() FINAL OVERRIDE { |
| 430 return this; | 423 return this; |
| 431 } | 424 } |
| 432 | 425 |
| 433 // Code generation | 426 // Code generation |
| 434 Label* break_target() { return &break_target_; } | 427 Label* break_target() { return &break_target_; } |
| 435 | 428 |
| 436 // Testers. | 429 // Testers. |
| 437 bool is_target_for_anonymous() const { | 430 bool is_target_for_anonymous() const { |
| 438 return breakable_type_ == TARGET_FOR_ANONYMOUS; | 431 return breakable_type_ == TARGET_FOR_ANONYMOUS; |
| 439 } | 432 } |
| 440 | 433 |
| 441 BailoutId EntryId() const { return entry_id_; } | 434 BailoutId EntryId() const { return BailoutId(base_id() + 0); } |
| 442 BailoutId ExitId() const { return exit_id_; } | 435 BailoutId ExitId() const { return BailoutId(base_id() + 1); } |
| 443 | 436 |
| 444 protected: | 437 protected: |
| 445 BreakableStatement(Zone* zone, ZoneList<const AstRawString*>* labels, | 438 BreakableStatement(Zone* zone, ZoneList<const AstRawString*>* labels, |
| 446 BreakableType breakable_type, int position, IdGen* id_gen) | 439 BreakableType breakable_type, int position, |
| 440 int num_ids_needed_by_subclass, IdGen* id_gen) |
| 447 : Statement(zone, position), | 441 : Statement(zone, position), |
| 448 labels_(labels), | 442 labels_(labels), |
| 449 breakable_type_(breakable_type), | 443 breakable_type_(breakable_type), |
| 450 entry_id_(id_gen->GetNextId()), | 444 base_id_( |
| 451 exit_id_(id_gen->GetNextId()) { | 445 id_gen->ReserveIdRange(num_ids_needed_by_subclass + num_ids())) { |
| 452 DCHECK(labels == NULL || labels->length() > 0); | 446 DCHECK(labels == NULL || labels->length() > 0); |
| 453 } | 447 } |
| 454 | 448 |
| 449 static int num_ids() { return 2; } |
| 450 int base_id() const { return base_id_; } |
| 455 | 451 |
| 456 private: | 452 private: |
| 457 ZoneList<const AstRawString*>* labels_; | 453 ZoneList<const AstRawString*>* labels_; |
| 458 BreakableType breakable_type_; | 454 BreakableType breakable_type_; |
| 459 Label break_target_; | 455 Label break_target_; |
| 460 const BailoutId entry_id_; | 456 const int base_id_; |
| 461 const BailoutId exit_id_; | |
| 462 }; | 457 }; |
| 463 | 458 |
| 464 | 459 |
| 465 class Block FINAL : public BreakableStatement { | 460 class Block FINAL : public BreakableStatement { |
| 466 public: | 461 public: |
| 467 DECLARE_NODE_TYPE(Block) | 462 DECLARE_NODE_TYPE(Block) |
| 468 | 463 |
| 469 void AddStatement(Statement* statement, Zone* zone) { | 464 void AddStatement(Statement* statement, Zone* zone) { |
| 470 statements_.Add(statement, zone); | 465 statements_.Add(statement, zone); |
| 471 } | 466 } |
| 472 | 467 |
| 473 ZoneList<Statement*>* statements() { return &statements_; } | 468 ZoneList<Statement*>* statements() { return &statements_; } |
| 474 bool is_initializer_block() const { return is_initializer_block_; } | 469 bool is_initializer_block() const { return is_initializer_block_; } |
| 475 | 470 |
| 476 BailoutId DeclsId() const { return decls_id_; } | 471 BailoutId DeclsId() const { return BailoutId(base_id() + 0); } |
| 477 | 472 |
| 478 virtual bool IsJump() const OVERRIDE { | 473 virtual bool IsJump() const OVERRIDE { |
| 479 return !statements_.is_empty() && statements_.last()->IsJump() | 474 return !statements_.is_empty() && statements_.last()->IsJump() |
| 480 && labels() == NULL; // Good enough as an approximation... | 475 && labels() == NULL; // Good enough as an approximation... |
| 481 } | 476 } |
| 482 | 477 |
| 483 Scope* scope() const { return scope_; } | 478 Scope* scope() const { return scope_; } |
| 484 void set_scope(Scope* scope) { scope_ = scope; } | 479 void set_scope(Scope* scope) { scope_ = scope; } |
| 485 | 480 |
| 486 protected: | 481 protected: |
| 487 Block(Zone* zone, ZoneList<const AstRawString*>* labels, int capacity, | 482 Block(Zone* zone, ZoneList<const AstRawString*>* labels, int capacity, |
| 488 bool is_initializer_block, int pos, IdGen* id_gen) | 483 bool is_initializer_block, int pos, IdGen* id_gen) |
| 489 : BreakableStatement(zone, labels, TARGET_FOR_NAMED_ONLY, pos, id_gen), | 484 : BreakableStatement(zone, labels, TARGET_FOR_NAMED_ONLY, pos, num_ids(), |
| 485 id_gen), |
| 490 statements_(capacity, zone), | 486 statements_(capacity, zone), |
| 491 is_initializer_block_(is_initializer_block), | 487 is_initializer_block_(is_initializer_block), |
| 492 decls_id_(id_gen->GetNextId()), | |
| 493 scope_(NULL) {} | 488 scope_(NULL) {} |
| 494 | 489 |
| 490 static int num_ids() { return 1; } |
| 491 int base_id() const { |
| 492 return BreakableStatement::base_id() + BreakableStatement::num_ids(); |
| 493 } |
| 494 |
| 495 private: | 495 private: |
| 496 ZoneList<Statement*> statements_; | 496 ZoneList<Statement*> statements_; |
| 497 bool is_initializer_block_; | 497 bool is_initializer_block_; |
| 498 const BailoutId decls_id_; | |
| 499 Scope* scope_; | 498 Scope* scope_; |
| 500 }; | 499 }; |
| 501 | 500 |
| 502 | 501 |
| 503 class Declaration : public AstNode { | 502 class Declaration : public AstNode { |
| 504 public: | 503 public: |
| 505 VariableProxy* proxy() const { return proxy_; } | 504 VariableProxy* proxy() const { return proxy_; } |
| 506 VariableMode mode() const { return mode_; } | 505 VariableMode mode() const { return mode_; } |
| 507 Scope* scope() const { return scope_; } | 506 Scope* scope() const { return scope_; } |
| 508 virtual InitializationFlag initialization() const = 0; | 507 virtual InitializationFlag initialization() const = 0; |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 740 | 739 |
| 741 class IterationStatement : public BreakableStatement { | 740 class IterationStatement : public BreakableStatement { |
| 742 public: | 741 public: |
| 743 // Type testing & conversion. | 742 // Type testing & conversion. |
| 744 virtual IterationStatement* AsIterationStatement() FINAL OVERRIDE { | 743 virtual IterationStatement* AsIterationStatement() FINAL OVERRIDE { |
| 745 return this; | 744 return this; |
| 746 } | 745 } |
| 747 | 746 |
| 748 Statement* body() const { return body_; } | 747 Statement* body() const { return body_; } |
| 749 | 748 |
| 750 BailoutId OsrEntryId() const { return osr_entry_id_; } | 749 BailoutId OsrEntryId() const { return BailoutId(base_id() + 0); } |
| 751 virtual BailoutId ContinueId() const = 0; | 750 virtual BailoutId ContinueId() const = 0; |
| 752 virtual BailoutId StackCheckId() const = 0; | 751 virtual BailoutId StackCheckId() const = 0; |
| 753 | 752 |
| 754 // Code generation | 753 // Code generation |
| 755 Label* continue_target() { return &continue_target_; } | 754 Label* continue_target() { return &continue_target_; } |
| 756 | 755 |
| 757 protected: | 756 protected: |
| 758 IterationStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos, | 757 IterationStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos, |
| 759 IdGen* id_gen) | 758 int num_ids_needed_by_subclass, IdGen* id_gen) |
| 760 : BreakableStatement(zone, labels, TARGET_FOR_ANONYMOUS, pos, id_gen), | 759 : BreakableStatement(zone, labels, TARGET_FOR_ANONYMOUS, pos, |
| 761 body_(NULL), | 760 num_ids_needed_by_subclass + num_ids(), id_gen), |
| 762 osr_entry_id_(id_gen->GetNextId()) {} | 761 body_(NULL) {} |
| 763 | 762 |
| 764 void Initialize(Statement* body) { | 763 void Initialize(Statement* body) { |
| 765 body_ = body; | 764 body_ = body; |
| 766 } | 765 } |
| 767 | 766 |
| 767 static int num_ids() { return 1; } |
| 768 int base_id() const { |
| 769 return BreakableStatement::base_id() + BreakableStatement::num_ids(); |
| 770 } |
| 771 |
| 768 private: | 772 private: |
| 769 Statement* body_; | 773 Statement* body_; |
| 770 Label continue_target_; | 774 Label continue_target_; |
| 771 | |
| 772 const BailoutId osr_entry_id_; | |
| 773 }; | 775 }; |
| 774 | 776 |
| 775 | 777 |
| 776 class DoWhileStatement FINAL : public IterationStatement { | 778 class DoWhileStatement FINAL : public IterationStatement { |
| 777 public: | 779 public: |
| 778 DECLARE_NODE_TYPE(DoWhileStatement) | 780 DECLARE_NODE_TYPE(DoWhileStatement) |
| 779 | 781 |
| 780 void Initialize(Expression* cond, Statement* body) { | 782 void Initialize(Expression* cond, Statement* body) { |
| 781 IterationStatement::Initialize(body); | 783 IterationStatement::Initialize(body); |
| 782 cond_ = cond; | 784 cond_ = cond; |
| 783 } | 785 } |
| 784 | 786 |
| 785 Expression* cond() const { return cond_; } | 787 Expression* cond() const { return cond_; } |
| 786 | 788 |
| 787 virtual BailoutId ContinueId() const OVERRIDE { return continue_id_; } | 789 virtual BailoutId ContinueId() const OVERRIDE { |
| 788 virtual BailoutId StackCheckId() const OVERRIDE { return back_edge_id_; } | 790 return BailoutId(base_id() + 0); |
| 789 BailoutId BackEdgeId() const { return back_edge_id_; } | 791 } |
| 792 virtual BailoutId StackCheckId() const OVERRIDE { return BackEdgeId(); } |
| 793 BailoutId BackEdgeId() const { return BailoutId(base_id() + 1); } |
| 790 | 794 |
| 791 protected: | 795 protected: |
| 792 DoWhileStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos, | 796 DoWhileStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos, |
| 793 IdGen* id_gen) | 797 IdGen* id_gen) |
| 794 : IterationStatement(zone, labels, pos, id_gen), | 798 : IterationStatement(zone, labels, pos, num_ids(), id_gen), cond_(NULL) {} |
| 795 cond_(NULL), | 799 |
| 796 continue_id_(id_gen->GetNextId()), | 800 static int num_ids() { return 2; } |
| 797 back_edge_id_(id_gen->GetNextId()) {} | 801 int base_id() const { |
| 802 return IterationStatement::base_id() + IterationStatement::num_ids(); |
| 803 } |
| 798 | 804 |
| 799 private: | 805 private: |
| 800 Expression* cond_; | 806 Expression* cond_; |
| 801 | |
| 802 const BailoutId continue_id_; | |
| 803 const BailoutId back_edge_id_; | |
| 804 }; | 807 }; |
| 805 | 808 |
| 806 | 809 |
| 807 class WhileStatement FINAL : public IterationStatement { | 810 class WhileStatement FINAL : public IterationStatement { |
| 808 public: | 811 public: |
| 809 DECLARE_NODE_TYPE(WhileStatement) | 812 DECLARE_NODE_TYPE(WhileStatement) |
| 810 | 813 |
| 811 void Initialize(Expression* cond, Statement* body) { | 814 void Initialize(Expression* cond, Statement* body) { |
| 812 IterationStatement::Initialize(body); | 815 IterationStatement::Initialize(body); |
| 813 cond_ = cond; | 816 cond_ = cond; |
| 814 } | 817 } |
| 815 | 818 |
| 816 Expression* cond() const { return cond_; } | 819 Expression* cond() const { return cond_; } |
| 817 bool may_have_function_literal() const { | 820 bool may_have_function_literal() const { |
| 818 return may_have_function_literal_; | 821 return may_have_function_literal_; |
| 819 } | 822 } |
| 820 void set_may_have_function_literal(bool value) { | 823 void set_may_have_function_literal(bool value) { |
| 821 may_have_function_literal_ = value; | 824 may_have_function_literal_ = value; |
| 822 } | 825 } |
| 823 | 826 |
| 824 virtual BailoutId ContinueId() const OVERRIDE { return EntryId(); } | 827 virtual BailoutId ContinueId() const OVERRIDE { return EntryId(); } |
| 825 virtual BailoutId StackCheckId() const OVERRIDE { return body_id_; } | 828 virtual BailoutId StackCheckId() const OVERRIDE { return BodyId(); } |
| 826 BailoutId BodyId() const { return body_id_; } | 829 BailoutId BodyId() const { return BailoutId(base_id() + 0); } |
| 827 | 830 |
| 828 protected: | 831 protected: |
| 829 WhileStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos, | 832 WhileStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos, |
| 830 IdGen* id_gen) | 833 IdGen* id_gen) |
| 831 : IterationStatement(zone, labels, pos, id_gen), | 834 : IterationStatement(zone, labels, pos, num_ids(), id_gen), |
| 832 cond_(NULL), | 835 cond_(NULL), |
| 833 may_have_function_literal_(true), | 836 may_have_function_literal_(true) {} |
| 834 body_id_(id_gen->GetNextId()) {} | 837 |
| 838 static int num_ids() { return 1; } |
| 839 int base_id() const { |
| 840 return IterationStatement::base_id() + IterationStatement::num_ids(); |
| 841 } |
| 835 | 842 |
| 836 private: | 843 private: |
| 837 Expression* cond_; | 844 Expression* cond_; |
| 838 | 845 |
| 839 // True if there is a function literal subexpression in the condition. | 846 // True if there is a function literal subexpression in the condition. |
| 840 bool may_have_function_literal_; | 847 bool may_have_function_literal_; |
| 841 | |
| 842 const BailoutId body_id_; | |
| 843 }; | 848 }; |
| 844 | 849 |
| 845 | 850 |
| 846 class ForStatement FINAL : public IterationStatement { | 851 class ForStatement FINAL : public IterationStatement { |
| 847 public: | 852 public: |
| 848 DECLARE_NODE_TYPE(ForStatement) | 853 DECLARE_NODE_TYPE(ForStatement) |
| 849 | 854 |
| 850 void Initialize(Statement* init, | 855 void Initialize(Statement* init, |
| 851 Expression* cond, | 856 Expression* cond, |
| 852 Statement* next, | 857 Statement* next, |
| 853 Statement* body) { | 858 Statement* body) { |
| 854 IterationStatement::Initialize(body); | 859 IterationStatement::Initialize(body); |
| 855 init_ = init; | 860 init_ = init; |
| 856 cond_ = cond; | 861 cond_ = cond; |
| 857 next_ = next; | 862 next_ = next; |
| 858 } | 863 } |
| 859 | 864 |
| 860 Statement* init() const { return init_; } | 865 Statement* init() const { return init_; } |
| 861 Expression* cond() const { return cond_; } | 866 Expression* cond() const { return cond_; } |
| 862 Statement* next() const { return next_; } | 867 Statement* next() const { return next_; } |
| 863 | 868 |
| 864 bool may_have_function_literal() const { | 869 bool may_have_function_literal() const { |
| 865 return may_have_function_literal_; | 870 return may_have_function_literal_; |
| 866 } | 871 } |
| 867 void set_may_have_function_literal(bool value) { | 872 void set_may_have_function_literal(bool value) { |
| 868 may_have_function_literal_ = value; | 873 may_have_function_literal_ = value; |
| 869 } | 874 } |
| 870 | 875 |
| 871 virtual BailoutId ContinueId() const OVERRIDE { return continue_id_; } | 876 virtual BailoutId ContinueId() const OVERRIDE { |
| 872 virtual BailoutId StackCheckId() const OVERRIDE { return body_id_; } | 877 return BailoutId(base_id() + 0); |
| 873 BailoutId BodyId() const { return body_id_; } | 878 } |
| 879 virtual BailoutId StackCheckId() const OVERRIDE { return BodyId(); } |
| 880 BailoutId BodyId() const { return BailoutId(base_id() + 1); } |
| 874 | 881 |
| 875 bool is_fast_smi_loop() { return loop_variable_ != NULL; } | 882 bool is_fast_smi_loop() { return loop_variable_ != NULL; } |
| 876 Variable* loop_variable() { return loop_variable_; } | 883 Variable* loop_variable() { return loop_variable_; } |
| 877 void set_loop_variable(Variable* var) { loop_variable_ = var; } | 884 void set_loop_variable(Variable* var) { loop_variable_ = var; } |
| 878 | 885 |
| 879 protected: | 886 protected: |
| 880 ForStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos, | 887 ForStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos, |
| 881 IdGen* id_gen) | 888 IdGen* id_gen) |
| 882 : IterationStatement(zone, labels, pos, id_gen), | 889 : IterationStatement(zone, labels, pos, num_ids(), id_gen), |
| 883 init_(NULL), | 890 init_(NULL), |
| 884 cond_(NULL), | 891 cond_(NULL), |
| 885 next_(NULL), | 892 next_(NULL), |
| 886 may_have_function_literal_(true), | 893 may_have_function_literal_(true), |
| 887 loop_variable_(NULL), | 894 loop_variable_(NULL) {} |
| 888 continue_id_(id_gen->GetNextId()), | 895 |
| 889 body_id_(id_gen->GetNextId()) {} | 896 static int num_ids() { return 2; } |
| 897 int base_id() const { |
| 898 return IterationStatement::base_id() + IterationStatement::num_ids(); |
| 899 } |
| 890 | 900 |
| 891 private: | 901 private: |
| 892 Statement* init_; | 902 Statement* init_; |
| 893 Expression* cond_; | 903 Expression* cond_; |
| 894 Statement* next_; | 904 Statement* next_; |
| 895 | 905 |
| 896 // True if there is a function literal subexpression in the condition. | 906 // True if there is a function literal subexpression in the condition. |
| 897 bool may_have_function_literal_; | 907 bool may_have_function_literal_; |
| 898 Variable* loop_variable_; | 908 Variable* loop_variable_; |
| 899 | |
| 900 const BailoutId continue_id_; | |
| 901 const BailoutId body_id_; | |
| 902 }; | 909 }; |
| 903 | 910 |
| 904 | 911 |
| 905 class ForEachStatement : public IterationStatement { | 912 class ForEachStatement : public IterationStatement { |
| 906 public: | 913 public: |
| 907 enum VisitMode { | 914 enum VisitMode { |
| 908 ENUMERATE, // for (each in subject) body; | 915 ENUMERATE, // for (each in subject) body; |
| 909 ITERATE // for (each of subject) body; | 916 ITERATE // for (each of subject) body; |
| 910 }; | 917 }; |
| 911 | 918 |
| 912 void Initialize(Expression* each, Expression* subject, Statement* body) { | 919 void Initialize(Expression* each, Expression* subject, Statement* body) { |
| 913 IterationStatement::Initialize(body); | 920 IterationStatement::Initialize(body); |
| 914 each_ = each; | 921 each_ = each; |
| 915 subject_ = subject; | 922 subject_ = subject; |
| 916 } | 923 } |
| 917 | 924 |
| 918 Expression* each() const { return each_; } | 925 Expression* each() const { return each_; } |
| 919 Expression* subject() const { return subject_; } | 926 Expression* subject() const { return subject_; } |
| 920 | 927 |
| 921 protected: | 928 protected: |
| 922 ForEachStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos, | 929 ForEachStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos, |
| 923 IdGen* id_gen) | 930 int num_ids_needed_by_subclass, IdGen* id_gen) |
| 924 : IterationStatement(zone, labels, pos, id_gen), | 931 : IterationStatement(zone, labels, pos, num_ids_needed_by_subclass, |
| 932 id_gen), |
| 925 each_(NULL), | 933 each_(NULL), |
| 926 subject_(NULL) {} | 934 subject_(NULL) {} |
| 927 | 935 |
| 928 private: | 936 private: |
| 929 Expression* each_; | 937 Expression* each_; |
| 930 Expression* subject_; | 938 Expression* subject_; |
| 931 }; | 939 }; |
| 932 | 940 |
| 933 | 941 |
| 934 class ForInStatement FINAL : public ForEachStatement { | 942 class ForInStatement FINAL : public ForEachStatement { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 945 | 953 |
| 946 int ForInFeedbackSlot() { | 954 int ForInFeedbackSlot() { |
| 947 DCHECK(for_in_feedback_slot_ != kInvalidFeedbackSlot); | 955 DCHECK(for_in_feedback_slot_ != kInvalidFeedbackSlot); |
| 948 return for_in_feedback_slot_; | 956 return for_in_feedback_slot_; |
| 949 } | 957 } |
| 950 | 958 |
| 951 enum ForInType { FAST_FOR_IN, SLOW_FOR_IN }; | 959 enum ForInType { FAST_FOR_IN, SLOW_FOR_IN }; |
| 952 ForInType for_in_type() const { return for_in_type_; } | 960 ForInType for_in_type() const { return for_in_type_; } |
| 953 void set_for_in_type(ForInType type) { for_in_type_ = type; } | 961 void set_for_in_type(ForInType type) { for_in_type_ = type; } |
| 954 | 962 |
| 955 BailoutId BodyId() const { return body_id_; } | 963 BailoutId BodyId() const { return BailoutId(base_id() + 0); } |
| 956 BailoutId PrepareId() const { return prepare_id_; } | 964 BailoutId PrepareId() const { return BailoutId(base_id() + 1); } |
| 957 virtual BailoutId ContinueId() const OVERRIDE { return EntryId(); } | 965 virtual BailoutId ContinueId() const OVERRIDE { return EntryId(); } |
| 958 virtual BailoutId StackCheckId() const OVERRIDE { return body_id_; } | 966 virtual BailoutId StackCheckId() const OVERRIDE { return BodyId(); } |
| 959 | 967 |
| 960 protected: | 968 protected: |
| 961 ForInStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos, | 969 ForInStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos, |
| 962 IdGen* id_gen) | 970 IdGen* id_gen) |
| 963 : ForEachStatement(zone, labels, pos, id_gen), | 971 : ForEachStatement(zone, labels, pos, num_ids(), id_gen), |
| 964 for_in_type_(SLOW_FOR_IN), | 972 for_in_type_(SLOW_FOR_IN), |
| 965 for_in_feedback_slot_(kInvalidFeedbackSlot), | 973 for_in_feedback_slot_(kInvalidFeedbackSlot) {} |
| 966 body_id_(id_gen->GetNextId()), | |
| 967 prepare_id_(id_gen->GetNextId()) {} | |
| 968 | 974 |
| 975 static int num_ids() { return 2; } |
| 976 int base_id() const { |
| 977 return ForEachStatement::base_id() + ForEachStatement::num_ids(); |
| 978 } |
| 979 |
| 980 private: |
| 969 ForInType for_in_type_; | 981 ForInType for_in_type_; |
| 970 int for_in_feedback_slot_; | 982 int for_in_feedback_slot_; |
| 971 const BailoutId body_id_; | |
| 972 const BailoutId prepare_id_; | |
| 973 }; | 983 }; |
| 974 | 984 |
| 975 | 985 |
| 976 class ForOfStatement FINAL : public ForEachStatement { | 986 class ForOfStatement FINAL : public ForEachStatement { |
| 977 public: | 987 public: |
| 978 DECLARE_NODE_TYPE(ForOfStatement) | 988 DECLARE_NODE_TYPE(ForOfStatement) |
| 979 | 989 |
| 980 void Initialize(Expression* each, | 990 void Initialize(Expression* each, |
| 981 Expression* subject, | 991 Expression* subject, |
| 982 Statement* body, | 992 Statement* body, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1011 } | 1021 } |
| 1012 | 1022 |
| 1013 // each = result.value | 1023 // each = result.value |
| 1014 Expression* assign_each() const { | 1024 Expression* assign_each() const { |
| 1015 return assign_each_; | 1025 return assign_each_; |
| 1016 } | 1026 } |
| 1017 | 1027 |
| 1018 virtual BailoutId ContinueId() const OVERRIDE { return EntryId(); } | 1028 virtual BailoutId ContinueId() const OVERRIDE { return EntryId(); } |
| 1019 virtual BailoutId StackCheckId() const OVERRIDE { return BackEdgeId(); } | 1029 virtual BailoutId StackCheckId() const OVERRIDE { return BackEdgeId(); } |
| 1020 | 1030 |
| 1021 BailoutId BackEdgeId() const { return back_edge_id_; } | 1031 BailoutId BackEdgeId() const { return BailoutId(base_id() + 0); } |
| 1022 | 1032 |
| 1023 protected: | 1033 protected: |
| 1024 ForOfStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos, | 1034 ForOfStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos, |
| 1025 IdGen* id_gen) | 1035 IdGen* id_gen) |
| 1026 : ForEachStatement(zone, labels, pos, id_gen), | 1036 : ForEachStatement(zone, labels, pos, num_ids(), id_gen), |
| 1027 assign_iterator_(NULL), | 1037 assign_iterator_(NULL), |
| 1028 next_result_(NULL), | 1038 next_result_(NULL), |
| 1029 result_done_(NULL), | 1039 result_done_(NULL), |
| 1030 assign_each_(NULL), | 1040 assign_each_(NULL) {} |
| 1031 back_edge_id_(id_gen->GetNextId()) {} | |
| 1032 | 1041 |
| 1042 static int num_ids() { return 1; } |
| 1043 int base_id() const { |
| 1044 return ForEachStatement::base_id() + ForEachStatement::num_ids(); |
| 1045 } |
| 1046 |
| 1047 private: |
| 1033 Expression* assign_iterator_; | 1048 Expression* assign_iterator_; |
| 1034 Expression* next_result_; | 1049 Expression* next_result_; |
| 1035 Expression* result_done_; | 1050 Expression* result_done_; |
| 1036 Expression* assign_each_; | 1051 Expression* assign_each_; |
| 1037 const BailoutId back_edge_id_; | |
| 1038 }; | 1052 }; |
| 1039 | 1053 |
| 1040 | 1054 |
| 1041 class ExpressionStatement FINAL : public Statement { | 1055 class ExpressionStatement FINAL : public Statement { |
| 1042 public: | 1056 public: |
| 1043 DECLARE_NODE_TYPE(ExpressionStatement) | 1057 DECLARE_NODE_TYPE(ExpressionStatement) |
| 1044 | 1058 |
| 1045 void set_expression(Expression* e) { expression_ = e; } | 1059 void set_expression(Expression* e) { expression_ = e; } |
| 1046 Expression* expression() const { return expression_; } | 1060 Expression* expression() const { return expression_; } |
| 1047 virtual bool IsJump() const OVERRIDE { return expression_->IsThrow(); } | 1061 virtual bool IsJump() const OVERRIDE { return expression_->IsThrow(); } |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1138 DECLARE_NODE_TYPE(CaseClause) | 1152 DECLARE_NODE_TYPE(CaseClause) |
| 1139 | 1153 |
| 1140 bool is_default() const { return label_ == NULL; } | 1154 bool is_default() const { return label_ == NULL; } |
| 1141 Expression* label() const { | 1155 Expression* label() const { |
| 1142 CHECK(!is_default()); | 1156 CHECK(!is_default()); |
| 1143 return label_; | 1157 return label_; |
| 1144 } | 1158 } |
| 1145 Label* body_target() { return &body_target_; } | 1159 Label* body_target() { return &body_target_; } |
| 1146 ZoneList<Statement*>* statements() const { return statements_; } | 1160 ZoneList<Statement*>* statements() const { return statements_; } |
| 1147 | 1161 |
| 1148 BailoutId EntryId() const { return entry_id_; } | 1162 BailoutId EntryId() const { return BailoutId(base_id() + 0); } |
| 1163 TypeFeedbackId CompareId() { return TypeFeedbackId(base_id() + 1); } |
| 1149 | 1164 |
| 1150 // Type feedback information. | |
| 1151 TypeFeedbackId CompareId() { return compare_id_; } | |
| 1152 Type* compare_type() { return compare_type_; } | 1165 Type* compare_type() { return compare_type_; } |
| 1153 void set_compare_type(Type* type) { compare_type_ = type; } | 1166 void set_compare_type(Type* type) { compare_type_ = type; } |
| 1154 | 1167 |
| 1155 private: | 1168 private: |
| 1156 CaseClause(Zone* zone, Expression* label, ZoneList<Statement*>* statements, | 1169 CaseClause(Zone* zone, Expression* label, ZoneList<Statement*>* statements, |
| 1157 int pos, IdGen* id_gen); | 1170 int pos, IdGen* id_gen); |
| 1158 | 1171 |
| 1172 static int num_ids() { return 2; } |
| 1173 int base_id() const { return Expression::base_id() + Expression::num_ids(); } |
| 1174 |
| 1159 Expression* label_; | 1175 Expression* label_; |
| 1160 Label body_target_; | 1176 Label body_target_; |
| 1161 ZoneList<Statement*>* statements_; | 1177 ZoneList<Statement*>* statements_; |
| 1162 Type* compare_type_; | 1178 Type* compare_type_; |
| 1163 | |
| 1164 const TypeFeedbackId compare_id_; | |
| 1165 const BailoutId entry_id_; | |
| 1166 }; | 1179 }; |
| 1167 | 1180 |
| 1168 | 1181 |
| 1169 class SwitchStatement FINAL : public BreakableStatement { | 1182 class SwitchStatement FINAL : public BreakableStatement { |
| 1170 public: | 1183 public: |
| 1171 DECLARE_NODE_TYPE(SwitchStatement) | 1184 DECLARE_NODE_TYPE(SwitchStatement) |
| 1172 | 1185 |
| 1173 void Initialize(Expression* tag, ZoneList<CaseClause*>* cases) { | 1186 void Initialize(Expression* tag, ZoneList<CaseClause*>* cases) { |
| 1174 tag_ = tag; | 1187 tag_ = tag; |
| 1175 cases_ = cases; | 1188 cases_ = cases; |
| 1176 } | 1189 } |
| 1177 | 1190 |
| 1178 Expression* tag() const { return tag_; } | 1191 Expression* tag() const { return tag_; } |
| 1179 ZoneList<CaseClause*>* cases() const { return cases_; } | 1192 ZoneList<CaseClause*>* cases() const { return cases_; } |
| 1180 | 1193 |
| 1181 protected: | 1194 protected: |
| 1182 SwitchStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos, | 1195 SwitchStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos, |
| 1183 IdGen* id_gen) | 1196 IdGen* id_gen) |
| 1184 : BreakableStatement(zone, labels, TARGET_FOR_ANONYMOUS, pos, id_gen), | 1197 : BreakableStatement(zone, labels, TARGET_FOR_ANONYMOUS, pos, 0, id_gen), |
| 1185 tag_(NULL), | 1198 tag_(NULL), |
| 1186 cases_(NULL) {} | 1199 cases_(NULL) {} |
| 1187 | 1200 |
| 1188 private: | 1201 private: |
| 1189 Expression* tag_; | 1202 Expression* tag_; |
| 1190 ZoneList<CaseClause*>* cases_; | 1203 ZoneList<CaseClause*>* cases_; |
| 1191 }; | 1204 }; |
| 1192 | 1205 |
| 1193 | 1206 |
| 1194 // If-statements always have non-null references to their then- and | 1207 // If-statements always have non-null references to their then- and |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1205 | 1218 |
| 1206 Expression* condition() const { return condition_; } | 1219 Expression* condition() const { return condition_; } |
| 1207 Statement* then_statement() const { return then_statement_; } | 1220 Statement* then_statement() const { return then_statement_; } |
| 1208 Statement* else_statement() const { return else_statement_; } | 1221 Statement* else_statement() const { return else_statement_; } |
| 1209 | 1222 |
| 1210 virtual bool IsJump() const OVERRIDE { | 1223 virtual bool IsJump() const OVERRIDE { |
| 1211 return HasThenStatement() && then_statement()->IsJump() | 1224 return HasThenStatement() && then_statement()->IsJump() |
| 1212 && HasElseStatement() && else_statement()->IsJump(); | 1225 && HasElseStatement() && else_statement()->IsJump(); |
| 1213 } | 1226 } |
| 1214 | 1227 |
| 1215 BailoutId IfId() const { return if_id_; } | 1228 BailoutId IfId() const { return BailoutId(base_id() + 0); } |
| 1216 BailoutId ThenId() const { return then_id_; } | 1229 BailoutId ThenId() const { return BailoutId(base_id() + 1); } |
| 1217 BailoutId ElseId() const { return else_id_; } | 1230 BailoutId ElseId() const { return BailoutId(base_id() + 2); } |
| 1218 | 1231 |
| 1219 protected: | 1232 protected: |
| 1220 IfStatement(Zone* zone, Expression* condition, Statement* then_statement, | 1233 IfStatement(Zone* zone, Expression* condition, Statement* then_statement, |
| 1221 Statement* else_statement, int pos, IdGen* id_gen) | 1234 Statement* else_statement, int pos, IdGen* id_gen) |
| 1222 : Statement(zone, pos), | 1235 : Statement(zone, pos), |
| 1223 condition_(condition), | 1236 condition_(condition), |
| 1224 then_statement_(then_statement), | 1237 then_statement_(then_statement), |
| 1225 else_statement_(else_statement), | 1238 else_statement_(else_statement), |
| 1226 if_id_(id_gen->GetNextId()), | 1239 base_id_(id_gen->ReserveIdRange(num_ids())) {} |
| 1227 then_id_(id_gen->GetNextId()), | 1240 |
| 1228 else_id_(id_gen->GetNextId()) {} | 1241 static int num_ids() { return 3; } |
| 1242 int base_id() const { return base_id_; } |
| 1229 | 1243 |
| 1230 private: | 1244 private: |
| 1231 Expression* condition_; | 1245 Expression* condition_; |
| 1232 Statement* then_statement_; | 1246 Statement* then_statement_; |
| 1233 Statement* else_statement_; | 1247 Statement* else_statement_; |
| 1234 const BailoutId if_id_; | 1248 const int base_id_; |
| 1235 const BailoutId then_id_; | |
| 1236 const BailoutId else_id_; | |
| 1237 }; | 1249 }; |
| 1238 | 1250 |
| 1239 | 1251 |
| 1240 // NOTE: TargetCollectors are represented as nodes to fit in the target | 1252 // NOTE: TargetCollectors are represented as nodes to fit in the target |
| 1241 // stack in the compiler; this should probably be reworked. | 1253 // stack in the compiler; this should probably be reworked. |
| 1242 class TargetCollector FINAL : public AstNode { | 1254 class TargetCollector FINAL : public AstNode { |
| 1243 public: | 1255 public: |
| 1244 explicit TargetCollector(Zone* zone) | 1256 explicit TargetCollector(Zone* zone) |
| 1245 : AstNode(RelocInfo::kNoPosition), targets_(0, zone) { } | 1257 : AstNode(RelocInfo::kNoPosition), targets_(0, zone) { } |
| 1246 | 1258 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1330 | 1342 |
| 1331 private: | 1343 private: |
| 1332 Block* finally_block_; | 1344 Block* finally_block_; |
| 1333 }; | 1345 }; |
| 1334 | 1346 |
| 1335 | 1347 |
| 1336 class DebuggerStatement FINAL : public Statement { | 1348 class DebuggerStatement FINAL : public Statement { |
| 1337 public: | 1349 public: |
| 1338 DECLARE_NODE_TYPE(DebuggerStatement) | 1350 DECLARE_NODE_TYPE(DebuggerStatement) |
| 1339 | 1351 |
| 1340 BailoutId DebugBreakId() const { return debugger_id_; } | 1352 BailoutId DebugBreakId() const { return BailoutId(base_id() + 0); } |
| 1341 | 1353 |
| 1342 protected: | 1354 protected: |
| 1343 explicit DebuggerStatement(Zone* zone, int pos, IdGen* id_gen) | 1355 explicit DebuggerStatement(Zone* zone, int pos, IdGen* id_gen) |
| 1344 : Statement(zone, pos), debugger_id_(id_gen->GetNextId()) {} | 1356 : Statement(zone, pos), base_id_(id_gen->ReserveIdRange(num_ids())) {} |
| 1357 |
| 1358 static int num_ids() { return 1; } |
| 1359 int base_id() const { return base_id_; } |
| 1345 | 1360 |
| 1346 private: | 1361 private: |
| 1347 const BailoutId debugger_id_; | 1362 const int base_id_; |
| 1348 }; | 1363 }; |
| 1349 | 1364 |
| 1350 | 1365 |
| 1351 class EmptyStatement FINAL : public Statement { | 1366 class EmptyStatement FINAL : public Statement { |
| 1352 public: | 1367 public: |
| 1353 DECLARE_NODE_TYPE(EmptyStatement) | 1368 DECLARE_NODE_TYPE(EmptyStatement) |
| 1354 | 1369 |
| 1355 protected: | 1370 protected: |
| 1356 explicit EmptyStatement(Zone* zone, int pos): Statement(zone, pos) {} | 1371 explicit EmptyStatement(Zone* zone, int pos): Statement(zone, pos) {} |
| 1357 }; | 1372 }; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1383 } | 1398 } |
| 1384 | 1399 |
| 1385 Handle<Object> value() const { return value_->value(); } | 1400 Handle<Object> value() const { return value_->value(); } |
| 1386 const AstValue* raw_value() const { return value_; } | 1401 const AstValue* raw_value() const { return value_; } |
| 1387 | 1402 |
| 1388 // Support for using Literal as a HashMap key. NOTE: Currently, this works | 1403 // Support for using Literal as a HashMap key. NOTE: Currently, this works |
| 1389 // only for string and number literals! | 1404 // only for string and number literals! |
| 1390 uint32_t Hash(); | 1405 uint32_t Hash(); |
| 1391 static bool Match(void* literal1, void* literal2); | 1406 static bool Match(void* literal1, void* literal2); |
| 1392 | 1407 |
| 1393 TypeFeedbackId LiteralFeedbackId() const { return reuse(id()); } | 1408 TypeFeedbackId LiteralFeedbackId() const { |
| 1409 return TypeFeedbackId(base_id() + 0); |
| 1410 } |
| 1394 | 1411 |
| 1395 protected: | 1412 protected: |
| 1396 Literal(Zone* zone, const AstValue* value, int position, IdGen* id_gen) | 1413 Literal(Zone* zone, const AstValue* value, int position, IdGen* id_gen) |
| 1397 : Expression(zone, position, id_gen), value_(value) {} | 1414 : Expression(zone, position, num_ids(), id_gen), value_(value) {} |
| 1415 |
| 1416 static int num_ids() { return 1; } |
| 1417 int base_id() const { return Expression::base_id() + Expression::num_ids(); } |
| 1398 | 1418 |
| 1399 private: | 1419 private: |
| 1400 const AstValue* value_; | 1420 const AstValue* value_; |
| 1401 }; | 1421 }; |
| 1402 | 1422 |
| 1403 | 1423 |
| 1404 // Base class for literals that needs space in the corresponding JSFunction. | 1424 // Base class for literals that needs space in the corresponding JSFunction. |
| 1405 class MaterializedLiteral : public Expression { | 1425 class MaterializedLiteral : public Expression { |
| 1406 public: | 1426 public: |
| 1407 virtual MaterializedLiteral* AsMaterializedLiteral() { return this; } | 1427 virtual MaterializedLiteral* AsMaterializedLiteral() { return this; } |
| 1408 | 1428 |
| 1409 int literal_index() { return literal_index_; } | 1429 int literal_index() { return literal_index_; } |
| 1410 | 1430 |
| 1411 int depth() const { | 1431 int depth() const { |
| 1412 // only callable after initialization. | 1432 // only callable after initialization. |
| 1413 DCHECK(depth_ >= 1); | 1433 DCHECK(depth_ >= 1); |
| 1414 return depth_; | 1434 return depth_; |
| 1415 } | 1435 } |
| 1416 | 1436 |
| 1417 protected: | 1437 protected: |
| 1418 MaterializedLiteral(Zone* zone, int literal_index, int pos, IdGen* id_gen) | 1438 MaterializedLiteral(Zone* zone, int literal_index, int pos, |
| 1419 : Expression(zone, pos, id_gen), | 1439 int num_ids_needed_by_subclass, IdGen* id_gen) |
| 1440 : Expression(zone, pos, num_ids_needed_by_subclass, id_gen), |
| 1420 literal_index_(literal_index), | 1441 literal_index_(literal_index), |
| 1421 is_simple_(false), | 1442 is_simple_(false), |
| 1422 depth_(0) {} | 1443 depth_(0) {} |
| 1423 | 1444 |
| 1424 // A materialized literal is simple if the values consist of only | 1445 // A materialized literal is simple if the values consist of only |
| 1425 // constants and simple object and array literals. | 1446 // constants and simple object and array literals. |
| 1426 bool is_simple() const { return is_simple_; } | 1447 bool is_simple() const { return is_simple_; } |
| 1427 void set_is_simple(bool is_simple) { is_simple_ = is_simple; } | 1448 void set_is_simple(bool is_simple) { is_simple_ = is_simple; } |
| 1428 friend class CompileTimeValue; | 1449 friend class CompileTimeValue; |
| 1429 | 1450 |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1541 struct Accessors: public ZoneObject { | 1562 struct Accessors: public ZoneObject { |
| 1542 Accessors() : getter(NULL), setter(NULL) { } | 1563 Accessors() : getter(NULL), setter(NULL) { } |
| 1543 Expression* getter; | 1564 Expression* getter; |
| 1544 Expression* setter; | 1565 Expression* setter; |
| 1545 }; | 1566 }; |
| 1546 | 1567 |
| 1547 protected: | 1568 protected: |
| 1548 ObjectLiteral(Zone* zone, ZoneList<Property*>* properties, int literal_index, | 1569 ObjectLiteral(Zone* zone, ZoneList<Property*>* properties, int literal_index, |
| 1549 int boilerplate_properties, bool has_function, int pos, | 1570 int boilerplate_properties, bool has_function, int pos, |
| 1550 IdGen* id_gen) | 1571 IdGen* id_gen) |
| 1551 : MaterializedLiteral(zone, literal_index, pos, id_gen), | 1572 : MaterializedLiteral(zone, literal_index, pos, 0, id_gen), |
| 1552 properties_(properties), | 1573 properties_(properties), |
| 1553 boilerplate_properties_(boilerplate_properties), | 1574 boilerplate_properties_(boilerplate_properties), |
| 1554 fast_elements_(false), | 1575 fast_elements_(false), |
| 1555 may_store_doubles_(false), | 1576 may_store_doubles_(false), |
| 1556 has_function_(has_function) {} | 1577 has_function_(has_function) {} |
| 1557 | 1578 |
| 1558 private: | 1579 private: |
| 1559 Handle<FixedArray> constant_properties_; | 1580 Handle<FixedArray> constant_properties_; |
| 1560 ZoneList<Property*>* properties_; | 1581 ZoneList<Property*>* properties_; |
| 1561 int boilerplate_properties_; | 1582 int boilerplate_properties_; |
| 1562 bool fast_elements_; | 1583 bool fast_elements_; |
| 1563 bool may_store_doubles_; | 1584 bool may_store_doubles_; |
| 1564 bool has_function_; | 1585 bool has_function_; |
| 1565 }; | 1586 }; |
| 1566 | 1587 |
| 1567 | 1588 |
| 1568 // Node for capturing a regexp literal. | 1589 // Node for capturing a regexp literal. |
| 1569 class RegExpLiteral FINAL : public MaterializedLiteral { | 1590 class RegExpLiteral FINAL : public MaterializedLiteral { |
| 1570 public: | 1591 public: |
| 1571 DECLARE_NODE_TYPE(RegExpLiteral) | 1592 DECLARE_NODE_TYPE(RegExpLiteral) |
| 1572 | 1593 |
| 1573 Handle<String> pattern() const { return pattern_->string(); } | 1594 Handle<String> pattern() const { return pattern_->string(); } |
| 1574 Handle<String> flags() const { return flags_->string(); } | 1595 Handle<String> flags() const { return flags_->string(); } |
| 1575 | 1596 |
| 1576 protected: | 1597 protected: |
| 1577 RegExpLiteral(Zone* zone, const AstRawString* pattern, | 1598 RegExpLiteral(Zone* zone, const AstRawString* pattern, |
| 1578 const AstRawString* flags, int literal_index, int pos, | 1599 const AstRawString* flags, int literal_index, int pos, |
| 1579 IdGen* id_gen) | 1600 IdGen* id_gen) |
| 1580 : MaterializedLiteral(zone, literal_index, pos, id_gen), | 1601 : MaterializedLiteral(zone, literal_index, pos, 0, id_gen), |
| 1581 pattern_(pattern), | 1602 pattern_(pattern), |
| 1582 flags_(flags) { | 1603 flags_(flags) { |
| 1583 set_depth(1); | 1604 set_depth(1); |
| 1584 } | 1605 } |
| 1585 | 1606 |
| 1586 private: | 1607 private: |
| 1587 const AstRawString* pattern_; | 1608 const AstRawString* pattern_; |
| 1588 const AstRawString* flags_; | 1609 const AstRawString* flags_; |
| 1589 }; | 1610 }; |
| 1590 | 1611 |
| 1591 | 1612 |
| 1592 // An array literal has a literals object that is used | 1613 // An array literal has a literals object that is used |
| 1593 // for minimizing the work when constructing it at runtime. | 1614 // for minimizing the work when constructing it at runtime. |
| 1594 class ArrayLiteral FINAL : public MaterializedLiteral { | 1615 class ArrayLiteral FINAL : public MaterializedLiteral { |
| 1595 public: | 1616 public: |
| 1596 DECLARE_NODE_TYPE(ArrayLiteral) | 1617 DECLARE_NODE_TYPE(ArrayLiteral) |
| 1597 | 1618 |
| 1598 Handle<FixedArray> constant_elements() const { return constant_elements_; } | 1619 Handle<FixedArray> constant_elements() const { return constant_elements_; } |
| 1599 ZoneList<Expression*>* values() const { return values_; } | 1620 ZoneList<Expression*>* values() const { return values_; } |
| 1600 | 1621 |
| 1601 // Return an AST id for an element that is used in simulate instructions. | 1622 // Return an AST id for an element that is used in simulate instructions. |
| 1602 BailoutId GetIdForElement(int i) { | 1623 BailoutId GetIdForElement(int i) { return BailoutId(base_id() + i); } |
| 1603 return BailoutId(first_element_id_.ToInt() + i); | |
| 1604 } | |
| 1605 | 1624 |
| 1606 // Populate the constant elements fixed array. | 1625 // Populate the constant elements fixed array. |
| 1607 void BuildConstantElements(Isolate* isolate); | 1626 void BuildConstantElements(Isolate* isolate); |
| 1608 | 1627 |
| 1609 // Assemble bitfield of flags for the CreateArrayLiteral helper. | 1628 // Assemble bitfield of flags for the CreateArrayLiteral helper. |
| 1610 int ComputeFlags() const { | 1629 int ComputeFlags() const { |
| 1611 int flags = depth() == 1 ? kShallowElements : kNoFlags; | 1630 int flags = depth() == 1 ? kShallowElements : kNoFlags; |
| 1612 flags |= ArrayLiteral::kDisableMementos; | 1631 flags |= ArrayLiteral::kDisableMementos; |
| 1613 return flags; | 1632 return flags; |
| 1614 } | 1633 } |
| 1615 | 1634 |
| 1616 enum Flags { | 1635 enum Flags { |
| 1617 kNoFlags = 0, | 1636 kNoFlags = 0, |
| 1618 kShallowElements = 1, | 1637 kShallowElements = 1, |
| 1619 kDisableMementos = 1 << 1 | 1638 kDisableMementos = 1 << 1 |
| 1620 }; | 1639 }; |
| 1621 | 1640 |
| 1622 protected: | 1641 protected: |
| 1623 ArrayLiteral(Zone* zone, ZoneList<Expression*>* values, int literal_index, | 1642 ArrayLiteral(Zone* zone, ZoneList<Expression*>* values, int literal_index, |
| 1624 int pos, IdGen* id_gen) | 1643 int pos, IdGen* id_gen) |
| 1625 : MaterializedLiteral(zone, literal_index, pos, id_gen), | 1644 : MaterializedLiteral(zone, literal_index, pos, num_ids(values), id_gen), |
| 1626 values_(values), | 1645 values_(values) {} |
| 1627 first_element_id_(id_gen->ReserveIdRange(values->length())) {} | 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 } |
| 1628 | 1651 |
| 1629 private: | 1652 private: |
| 1630 Handle<FixedArray> constant_elements_; | 1653 Handle<FixedArray> constant_elements_; |
| 1631 ZoneList<Expression*>* values_; | 1654 ZoneList<Expression*>* values_; |
| 1632 const BailoutId first_element_id_; | |
| 1633 }; | 1655 }; |
| 1634 | 1656 |
| 1635 | 1657 |
| 1636 class VariableProxy FINAL : public Expression { | 1658 class VariableProxy FINAL : public Expression { |
| 1637 public: | 1659 public: |
| 1638 DECLARE_NODE_TYPE(VariableProxy) | 1660 DECLARE_NODE_TYPE(VariableProxy) |
| 1639 | 1661 |
| 1640 virtual bool IsValidReferenceExpression() const OVERRIDE { | 1662 virtual bool IsValidReferenceExpression() const OVERRIDE { |
| 1641 return !is_resolved() || var()->IsValidReference(); | 1663 return !is_resolved() || var()->IsValidReference(); |
| 1642 } | 1664 } |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1698 | 1720 |
| 1699 class Property FINAL : public Expression { | 1721 class Property FINAL : public Expression { |
| 1700 public: | 1722 public: |
| 1701 DECLARE_NODE_TYPE(Property) | 1723 DECLARE_NODE_TYPE(Property) |
| 1702 | 1724 |
| 1703 virtual bool IsValidReferenceExpression() const OVERRIDE { return true; } | 1725 virtual bool IsValidReferenceExpression() const OVERRIDE { return true; } |
| 1704 | 1726 |
| 1705 Expression* obj() const { return obj_; } | 1727 Expression* obj() const { return obj_; } |
| 1706 Expression* key() const { return key_; } | 1728 Expression* key() const { return key_; } |
| 1707 | 1729 |
| 1708 BailoutId LoadId() const { return load_id_; } | 1730 BailoutId LoadId() const { return BailoutId(base_id() + 0); } |
| 1731 TypeFeedbackId PropertyFeedbackId() { return TypeFeedbackId(base_id() + 1); } |
| 1732 |
| 1709 | 1733 |
| 1710 bool IsStringAccess() const { return is_string_access_; } | 1734 bool IsStringAccess() const { return is_string_access_; } |
| 1711 | 1735 |
| 1712 // Type feedback information. | 1736 // Type feedback information. |
| 1713 virtual bool IsMonomorphic() OVERRIDE { | 1737 virtual bool IsMonomorphic() OVERRIDE { |
| 1714 return receiver_types_.length() == 1; | 1738 return receiver_types_.length() == 1; |
| 1715 } | 1739 } |
| 1716 virtual SmallMapList* GetReceiverTypes() OVERRIDE { | 1740 virtual SmallMapList* GetReceiverTypes() OVERRIDE { |
| 1717 return &receiver_types_; | 1741 return &receiver_types_; |
| 1718 } | 1742 } |
| 1719 virtual KeyedAccessStoreMode GetStoreMode() OVERRIDE { | 1743 virtual KeyedAccessStoreMode GetStoreMode() OVERRIDE { |
| 1720 return STANDARD_STORE; | 1744 return STANDARD_STORE; |
| 1721 } | 1745 } |
| 1722 bool IsUninitialized() { return !is_for_call_ && is_uninitialized_; } | 1746 bool IsUninitialized() { return !is_for_call_ && is_uninitialized_; } |
| 1723 bool HasNoTypeInformation() { | 1747 bool HasNoTypeInformation() { |
| 1724 return is_uninitialized_; | 1748 return is_uninitialized_; |
| 1725 } | 1749 } |
| 1726 void set_is_uninitialized(bool b) { is_uninitialized_ = b; } | 1750 void set_is_uninitialized(bool b) { is_uninitialized_ = b; } |
| 1727 void set_is_string_access(bool b) { is_string_access_ = b; } | 1751 void set_is_string_access(bool b) { is_string_access_ = b; } |
| 1728 void mark_for_call() { is_for_call_ = true; } | 1752 void mark_for_call() { is_for_call_ = true; } |
| 1729 bool IsForCall() { return is_for_call_; } | 1753 bool IsForCall() { return is_for_call_; } |
| 1730 | 1754 |
| 1731 bool IsSuperAccess() { | 1755 bool IsSuperAccess() { |
| 1732 return obj()->IsSuperReference(); | 1756 return obj()->IsSuperReference(); |
| 1733 } | 1757 } |
| 1734 | 1758 |
| 1735 TypeFeedbackId PropertyFeedbackId() { return reuse(id()); } | |
| 1736 | |
| 1737 virtual int ComputeFeedbackSlotCount() { return FLAG_vector_ics ? 1 : 0; } | 1759 virtual int ComputeFeedbackSlotCount() { return FLAG_vector_ics ? 1 : 0; } |
| 1738 virtual void SetFirstFeedbackSlot(int slot) { | 1760 virtual void SetFirstFeedbackSlot(int slot) { |
| 1739 property_feedback_slot_ = slot; | 1761 property_feedback_slot_ = slot; |
| 1740 } | 1762 } |
| 1741 | 1763 |
| 1742 int PropertyFeedbackSlot() const { return property_feedback_slot_; } | 1764 int PropertyFeedbackSlot() const { return property_feedback_slot_; } |
| 1743 | 1765 |
| 1744 protected: | 1766 protected: |
| 1745 Property(Zone* zone, Expression* obj, Expression* key, int pos, IdGen* id_gen) | 1767 Property(Zone* zone, Expression* obj, Expression* key, int pos, IdGen* id_gen) |
| 1746 : Expression(zone, pos, id_gen), | 1768 : Expression(zone, pos, num_ids(), id_gen), |
| 1747 obj_(obj), | 1769 obj_(obj), |
| 1748 key_(key), | 1770 key_(key), |
| 1749 load_id_(id_gen->GetNextId()), | |
| 1750 property_feedback_slot_(kInvalidFeedbackSlot), | 1771 property_feedback_slot_(kInvalidFeedbackSlot), |
| 1751 is_for_call_(false), | 1772 is_for_call_(false), |
| 1752 is_uninitialized_(false), | 1773 is_uninitialized_(false), |
| 1753 is_string_access_(false) {} | 1774 is_string_access_(false) {} |
| 1754 | 1775 |
| 1776 static int num_ids() { return 2; } |
| 1777 int base_id() const { return Expression::base_id() + Expression::num_ids(); } |
| 1778 |
| 1755 private: | 1779 private: |
| 1756 Expression* obj_; | 1780 Expression* obj_; |
| 1757 Expression* key_; | 1781 Expression* key_; |
| 1758 const BailoutId load_id_; | |
| 1759 int property_feedback_slot_; | 1782 int property_feedback_slot_; |
| 1760 | 1783 |
| 1761 SmallMapList receiver_types_; | 1784 SmallMapList receiver_types_; |
| 1762 bool is_for_call_ : 1; | 1785 bool is_for_call_ : 1; |
| 1763 bool is_uninitialized_ : 1; | 1786 bool is_uninitialized_ : 1; |
| 1764 bool is_string_access_ : 1; | 1787 bool is_string_access_ : 1; |
| 1765 }; | 1788 }; |
| 1766 | 1789 |
| 1767 | 1790 |
| 1768 class Call FINAL : public Expression { | 1791 class Call FINAL : public Expression { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1811 Handle<Cell> cell() { return cell_; } | 1834 Handle<Cell> cell() { return cell_; } |
| 1812 | 1835 |
| 1813 Handle<AllocationSite> allocation_site() { return allocation_site_; } | 1836 Handle<AllocationSite> allocation_site() { return allocation_site_; } |
| 1814 | 1837 |
| 1815 void set_target(Handle<JSFunction> target) { target_ = target; } | 1838 void set_target(Handle<JSFunction> target) { target_ = target; } |
| 1816 void set_allocation_site(Handle<AllocationSite> site) { | 1839 void set_allocation_site(Handle<AllocationSite> site) { |
| 1817 allocation_site_ = site; | 1840 allocation_site_ = site; |
| 1818 } | 1841 } |
| 1819 bool ComputeGlobalTarget(Handle<GlobalObject> global, LookupIterator* it); | 1842 bool ComputeGlobalTarget(Handle<GlobalObject> global, LookupIterator* it); |
| 1820 | 1843 |
| 1821 BailoutId ReturnId() const { return return_id_; } | 1844 BailoutId ReturnId() const { return BailoutId(base_id() + 0); } |
| 1822 BailoutId EvalOrLookupId() const { return eval_or_lookup_id_; } | 1845 BailoutId EvalOrLookupId() const { return BailoutId(base_id() + 1); } |
| 1823 | 1846 |
| 1824 enum CallType { | 1847 enum CallType { |
| 1825 POSSIBLY_EVAL_CALL, | 1848 POSSIBLY_EVAL_CALL, |
| 1826 GLOBAL_CALL, | 1849 GLOBAL_CALL, |
| 1827 LOOKUP_SLOT_CALL, | 1850 LOOKUP_SLOT_CALL, |
| 1828 PROPERTY_CALL, | 1851 PROPERTY_CALL, |
| 1829 OTHER_CALL | 1852 OTHER_CALL |
| 1830 }; | 1853 }; |
| 1831 | 1854 |
| 1832 // Helpers to determine how to handle the call. | 1855 // Helpers to determine how to handle the call. |
| 1833 CallType GetCallType(Isolate* isolate) const; | 1856 CallType GetCallType(Isolate* isolate) const; |
| 1834 bool IsUsingCallFeedbackSlot(Isolate* isolate) const; | 1857 bool IsUsingCallFeedbackSlot(Isolate* isolate) const; |
| 1835 | 1858 |
| 1836 #ifdef DEBUG | 1859 #ifdef DEBUG |
| 1837 // Used to assert that the FullCodeGenerator records the return site. | 1860 // Used to assert that the FullCodeGenerator records the return site. |
| 1838 bool return_is_recorded_; | 1861 bool return_is_recorded_; |
| 1839 #endif | 1862 #endif |
| 1840 | 1863 |
| 1841 protected: | 1864 protected: |
| 1842 Call(Zone* zone, Expression* expression, ZoneList<Expression*>* arguments, | 1865 Call(Zone* zone, Expression* expression, ZoneList<Expression*>* arguments, |
| 1843 int pos, IdGen* id_gen) | 1866 int pos, IdGen* id_gen) |
| 1844 : Expression(zone, pos, id_gen), | 1867 : Expression(zone, pos, num_ids(), id_gen), |
| 1845 expression_(expression), | 1868 expression_(expression), |
| 1846 arguments_(arguments), | 1869 arguments_(arguments), |
| 1847 call_feedback_slot_(kInvalidFeedbackSlot), | 1870 call_feedback_slot_(kInvalidFeedbackSlot) { |
| 1848 return_id_(id_gen->GetNextId()), | |
| 1849 eval_or_lookup_id_(id_gen->GetNextId()) { | |
| 1850 if (expression->IsProperty()) { | 1871 if (expression->IsProperty()) { |
| 1851 expression->AsProperty()->mark_for_call(); | 1872 expression->AsProperty()->mark_for_call(); |
| 1852 } | 1873 } |
| 1853 } | 1874 } |
| 1854 | 1875 |
| 1876 static int num_ids() { return 2; } |
| 1877 int base_id() const { return Expression::base_id() + Expression::num_ids(); } |
| 1878 |
| 1855 private: | 1879 private: |
| 1856 Expression* expression_; | 1880 Expression* expression_; |
| 1857 ZoneList<Expression*>* arguments_; | 1881 ZoneList<Expression*>* arguments_; |
| 1858 | |
| 1859 Handle<JSFunction> target_; | 1882 Handle<JSFunction> target_; |
| 1860 Handle<Cell> cell_; | 1883 Handle<Cell> cell_; |
| 1861 Handle<AllocationSite> allocation_site_; | 1884 Handle<AllocationSite> allocation_site_; |
| 1862 int call_feedback_slot_; | 1885 int call_feedback_slot_; |
| 1863 | |
| 1864 const BailoutId return_id_; | |
| 1865 // TODO(jarin) Only allocate the bailout id for the POSSIBLY_EVAL_CALL and | |
| 1866 // LOOKUP_SLOT_CALL types. | |
| 1867 const BailoutId eval_or_lookup_id_; | |
| 1868 }; | 1886 }; |
| 1869 | 1887 |
| 1870 | 1888 |
| 1871 class CallNew FINAL : public Expression { | 1889 class CallNew FINAL : public Expression { |
| 1872 public: | 1890 public: |
| 1873 DECLARE_NODE_TYPE(CallNew) | 1891 DECLARE_NODE_TYPE(CallNew) |
| 1874 | 1892 |
| 1875 Expression* expression() const { return expression_; } | 1893 Expression* expression() const { return expression_; } |
| 1876 ZoneList<Expression*>* arguments() const { return arguments_; } | 1894 ZoneList<Expression*>* arguments() const { return arguments_; } |
| 1877 | 1895 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1895 | 1913 |
| 1896 void RecordTypeFeedback(TypeFeedbackOracle* oracle); | 1914 void RecordTypeFeedback(TypeFeedbackOracle* oracle); |
| 1897 virtual bool IsMonomorphic() OVERRIDE { return is_monomorphic_; } | 1915 virtual bool IsMonomorphic() OVERRIDE { return is_monomorphic_; } |
| 1898 Handle<JSFunction> target() const { return target_; } | 1916 Handle<JSFunction> target() const { return target_; } |
| 1899 Handle<AllocationSite> allocation_site() const { | 1917 Handle<AllocationSite> allocation_site() const { |
| 1900 return allocation_site_; | 1918 return allocation_site_; |
| 1901 } | 1919 } |
| 1902 | 1920 |
| 1903 static int feedback_slots() { return 1; } | 1921 static int feedback_slots() { return 1; } |
| 1904 | 1922 |
| 1905 BailoutId ReturnId() const { return return_id_; } | 1923 BailoutId ReturnId() const { return BailoutId(base_id() + 0); } |
| 1906 | 1924 |
| 1907 protected: | 1925 protected: |
| 1908 CallNew(Zone* zone, Expression* expression, ZoneList<Expression*>* arguments, | 1926 CallNew(Zone* zone, Expression* expression, ZoneList<Expression*>* arguments, |
| 1909 int pos, IdGen* id_gen) | 1927 int pos, IdGen* id_gen) |
| 1910 : Expression(zone, pos, id_gen), | 1928 : Expression(zone, pos, num_ids(), id_gen), |
| 1911 expression_(expression), | 1929 expression_(expression), |
| 1912 arguments_(arguments), | 1930 arguments_(arguments), |
| 1913 is_monomorphic_(false), | 1931 is_monomorphic_(false), |
| 1914 callnew_feedback_slot_(kInvalidFeedbackSlot), | 1932 callnew_feedback_slot_(kInvalidFeedbackSlot) {} |
| 1915 return_id_(id_gen->GetNextId()) {} | 1933 |
| 1934 static int num_ids() { return 1; } |
| 1935 int base_id() const { return Expression::base_id() + Expression::num_ids(); } |
| 1916 | 1936 |
| 1917 private: | 1937 private: |
| 1918 Expression* expression_; | 1938 Expression* expression_; |
| 1919 ZoneList<Expression*>* arguments_; | 1939 ZoneList<Expression*>* arguments_; |
| 1920 | |
| 1921 bool is_monomorphic_; | 1940 bool is_monomorphic_; |
| 1922 Handle<JSFunction> target_; | 1941 Handle<JSFunction> target_; |
| 1923 Handle<AllocationSite> allocation_site_; | 1942 Handle<AllocationSite> allocation_site_; |
| 1924 int callnew_feedback_slot_; | 1943 int callnew_feedback_slot_; |
| 1925 | |
| 1926 const BailoutId return_id_; | |
| 1927 }; | 1944 }; |
| 1928 | 1945 |
| 1929 | 1946 |
| 1930 // The CallRuntime class does not represent any official JavaScript | 1947 // The CallRuntime class does not represent any official JavaScript |
| 1931 // language construct. Instead it is used to call a C or JS function | 1948 // language construct. Instead it is used to call a C or JS function |
| 1932 // with a set of arguments. This is used from the builtins that are | 1949 // with a set of arguments. This is used from the builtins that are |
| 1933 // implemented in JavaScript (see "v8natives.js"). | 1950 // implemented in JavaScript (see "v8natives.js"). |
| 1934 class CallRuntime FINAL : public Expression { | 1951 class CallRuntime FINAL : public Expression { |
| 1935 public: | 1952 public: |
| 1936 DECLARE_NODE_TYPE(CallRuntime) | 1953 DECLARE_NODE_TYPE(CallRuntime) |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1948 virtual void SetFirstFeedbackSlot(int slot) { | 1965 virtual void SetFirstFeedbackSlot(int slot) { |
| 1949 callruntime_feedback_slot_ = slot; | 1966 callruntime_feedback_slot_ = slot; |
| 1950 } | 1967 } |
| 1951 | 1968 |
| 1952 int CallRuntimeFeedbackSlot() { | 1969 int CallRuntimeFeedbackSlot() { |
| 1953 DCHECK(!is_jsruntime() || | 1970 DCHECK(!is_jsruntime() || |
| 1954 callruntime_feedback_slot_ != kInvalidFeedbackSlot); | 1971 callruntime_feedback_slot_ != kInvalidFeedbackSlot); |
| 1955 return callruntime_feedback_slot_; | 1972 return callruntime_feedback_slot_; |
| 1956 } | 1973 } |
| 1957 | 1974 |
| 1958 TypeFeedbackId CallRuntimeFeedbackId() const { return reuse(id()); } | 1975 TypeFeedbackId CallRuntimeFeedbackId() const { |
| 1976 return TypeFeedbackId(base_id() + 0); |
| 1977 } |
| 1959 | 1978 |
| 1960 protected: | 1979 protected: |
| 1961 CallRuntime(Zone* zone, const AstRawString* name, | 1980 CallRuntime(Zone* zone, const AstRawString* name, |
| 1962 const Runtime::Function* function, | 1981 const Runtime::Function* function, |
| 1963 ZoneList<Expression*>* arguments, int pos, IdGen* id_gen) | 1982 ZoneList<Expression*>* arguments, int pos, IdGen* id_gen) |
| 1964 : Expression(zone, pos, id_gen), | 1983 : Expression(zone, pos, num_ids(), id_gen), |
| 1965 raw_name_(name), | 1984 raw_name_(name), |
| 1966 function_(function), | 1985 function_(function), |
| 1967 arguments_(arguments) {} | 1986 arguments_(arguments) {} |
| 1968 | 1987 |
| 1988 static int num_ids() { return 1; } |
| 1989 int base_id() const { return Expression::base_id() + Expression::num_ids(); } |
| 1990 |
| 1969 private: | 1991 private: |
| 1970 const AstRawString* raw_name_; | 1992 const AstRawString* raw_name_; |
| 1971 const Runtime::Function* function_; | 1993 const Runtime::Function* function_; |
| 1972 ZoneList<Expression*>* arguments_; | 1994 ZoneList<Expression*>* arguments_; |
| 1973 int callruntime_feedback_slot_; | 1995 int callruntime_feedback_slot_; |
| 1974 }; | 1996 }; |
| 1975 | 1997 |
| 1976 | 1998 |
| 1977 class UnaryOperation FINAL : public Expression { | 1999 class UnaryOperation FINAL : public Expression { |
| 1978 public: | 2000 public: |
| 1979 DECLARE_NODE_TYPE(UnaryOperation) | 2001 DECLARE_NODE_TYPE(UnaryOperation) |
| 1980 | 2002 |
| 1981 Token::Value op() const { return op_; } | 2003 Token::Value op() const { return op_; } |
| 1982 Expression* expression() const { return expression_; } | 2004 Expression* expression() const { return expression_; } |
| 1983 | 2005 |
| 1984 BailoutId MaterializeTrueId() { return materialize_true_id_; } | 2006 // For unary not (Token::NOT), the AST ids where true and false will |
| 1985 BailoutId MaterializeFalseId() { return materialize_false_id_; } | 2007 // actually be materialized, respectively. |
| 2008 BailoutId MaterializeTrueId() const { return BailoutId(base_id() + 0); } |
| 2009 BailoutId MaterializeFalseId() const { return BailoutId(base_id() + 1); } |
| 1986 | 2010 |
| 1987 virtual void RecordToBooleanTypeFeedback( | 2011 virtual void RecordToBooleanTypeFeedback( |
| 1988 TypeFeedbackOracle* oracle) OVERRIDE; | 2012 TypeFeedbackOracle* oracle) OVERRIDE; |
| 1989 | 2013 |
| 1990 protected: | 2014 protected: |
| 1991 UnaryOperation(Zone* zone, Token::Value op, Expression* expression, int pos, | 2015 UnaryOperation(Zone* zone, Token::Value op, Expression* expression, int pos, |
| 1992 IdGen* id_gen) | 2016 IdGen* id_gen) |
| 1993 : Expression(zone, pos, id_gen), | 2017 : Expression(zone, pos, num_ids(), id_gen), |
| 1994 op_(op), | 2018 op_(op), |
| 1995 expression_(expression), | 2019 expression_(expression) { |
| 1996 materialize_true_id_(id_gen->GetNextId()), | |
| 1997 materialize_false_id_(id_gen->GetNextId()) { | |
| 1998 DCHECK(Token::IsUnaryOp(op)); | 2020 DCHECK(Token::IsUnaryOp(op)); |
| 1999 } | 2021 } |
| 2000 | 2022 |
| 2023 static int num_ids() { return 2; } |
| 2024 int base_id() const { return Expression::base_id() + Expression::num_ids(); } |
| 2025 |
| 2001 private: | 2026 private: |
| 2002 Token::Value op_; | 2027 Token::Value op_; |
| 2003 Expression* expression_; | 2028 Expression* expression_; |
| 2004 | |
| 2005 // For unary not (Token::NOT), the AST ids where true and false will | |
| 2006 // actually be materialized, respectively. | |
| 2007 const BailoutId materialize_true_id_; | |
| 2008 const BailoutId materialize_false_id_; | |
| 2009 }; | 2029 }; |
| 2010 | 2030 |
| 2011 | 2031 |
| 2012 class BinaryOperation FINAL : public Expression { | 2032 class BinaryOperation FINAL : public Expression { |
| 2013 public: | 2033 public: |
| 2014 DECLARE_NODE_TYPE(BinaryOperation) | 2034 DECLARE_NODE_TYPE(BinaryOperation) |
| 2015 | 2035 |
| 2016 virtual bool ResultOverwriteAllowed() const OVERRIDE; | 2036 virtual bool ResultOverwriteAllowed() const OVERRIDE; |
| 2017 | 2037 |
| 2018 Token::Value op() const { return op_; } | 2038 Token::Value op() const { return op_; } |
| 2019 Expression* left() const { return left_; } | 2039 Expression* left() const { return left_; } |
| 2020 Expression* right() const { return right_; } | 2040 Expression* right() const { return right_; } |
| 2021 Handle<AllocationSite> allocation_site() const { return allocation_site_; } | 2041 Handle<AllocationSite> allocation_site() const { return allocation_site_; } |
| 2022 void set_allocation_site(Handle<AllocationSite> allocation_site) { | 2042 void set_allocation_site(Handle<AllocationSite> allocation_site) { |
| 2023 allocation_site_ = allocation_site; | 2043 allocation_site_ = allocation_site; |
| 2024 } | 2044 } |
| 2025 | 2045 |
| 2026 BailoutId RightId() const { return right_id_; } | 2046 // The short-circuit logical operations need an AST ID for their |
| 2047 // right-hand subexpression. |
| 2048 BailoutId RightId() const { return BailoutId(base_id() + 0); } |
| 2027 | 2049 |
| 2028 TypeFeedbackId BinaryOperationFeedbackId() const { return reuse(id()); } | 2050 TypeFeedbackId BinaryOperationFeedbackId() const { |
| 2051 return TypeFeedbackId(base_id() + 1); |
| 2052 } |
| 2029 Maybe<int> fixed_right_arg() const { return fixed_right_arg_; } | 2053 Maybe<int> fixed_right_arg() const { return fixed_right_arg_; } |
| 2030 void set_fixed_right_arg(Maybe<int> arg) { fixed_right_arg_ = arg; } | 2054 void set_fixed_right_arg(Maybe<int> arg) { fixed_right_arg_ = arg; } |
| 2031 | 2055 |
| 2032 virtual void RecordToBooleanTypeFeedback( | 2056 virtual void RecordToBooleanTypeFeedback( |
| 2033 TypeFeedbackOracle* oracle) OVERRIDE; | 2057 TypeFeedbackOracle* oracle) OVERRIDE; |
| 2034 | 2058 |
| 2035 protected: | 2059 protected: |
| 2036 BinaryOperation(Zone* zone, Token::Value op, Expression* left, | 2060 BinaryOperation(Zone* zone, Token::Value op, Expression* left, |
| 2037 Expression* right, int pos, IdGen* id_gen) | 2061 Expression* right, int pos, IdGen* id_gen) |
| 2038 : Expression(zone, pos, id_gen), | 2062 : Expression(zone, pos, num_ids(), id_gen), |
| 2039 op_(op), | 2063 op_(op), |
| 2040 left_(left), | 2064 left_(left), |
| 2041 right_(right), | 2065 right_(right) { |
| 2042 right_id_(id_gen->GetNextId()) { | |
| 2043 DCHECK(Token::IsBinaryOp(op)); | 2066 DCHECK(Token::IsBinaryOp(op)); |
| 2044 } | 2067 } |
| 2045 | 2068 |
| 2069 static int num_ids() { return 2; } |
| 2070 int base_id() const { return Expression::base_id() + Expression::num_ids(); } |
| 2071 |
| 2046 private: | 2072 private: |
| 2047 Token::Value op_; | 2073 Token::Value op_; |
| 2048 Expression* left_; | 2074 Expression* left_; |
| 2049 Expression* right_; | 2075 Expression* right_; |
| 2050 Handle<AllocationSite> allocation_site_; | 2076 Handle<AllocationSite> allocation_site_; |
| 2051 | 2077 |
| 2052 // TODO(rossberg): the fixed arg should probably be represented as a Constant | 2078 // TODO(rossberg): the fixed arg should probably be represented as a Constant |
| 2053 // type for the RHS. | 2079 // type for the RHS. |
| 2054 Maybe<int> fixed_right_arg_; | 2080 Maybe<int> fixed_right_arg_; |
| 2055 | |
| 2056 // The short-circuit logical operations need an AST ID for their | |
| 2057 // right-hand subexpression. | |
| 2058 const BailoutId right_id_; | |
| 2059 }; | 2081 }; |
| 2060 | 2082 |
| 2061 | 2083 |
| 2062 class CountOperation FINAL : public Expression { | 2084 class CountOperation FINAL : public Expression { |
| 2063 public: | 2085 public: |
| 2064 DECLARE_NODE_TYPE(CountOperation) | 2086 DECLARE_NODE_TYPE(CountOperation) |
| 2065 | 2087 |
| 2066 bool is_prefix() const { return is_prefix_; } | 2088 bool is_prefix() const { return is_prefix_; } |
| 2067 bool is_postfix() const { return !is_prefix_; } | 2089 bool is_postfix() const { return !is_prefix_; } |
| 2068 | 2090 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 2079 virtual SmallMapList* GetReceiverTypes() OVERRIDE { | 2101 virtual SmallMapList* GetReceiverTypes() OVERRIDE { |
| 2080 return &receiver_types_; | 2102 return &receiver_types_; |
| 2081 } | 2103 } |
| 2082 virtual KeyedAccessStoreMode GetStoreMode() OVERRIDE { | 2104 virtual KeyedAccessStoreMode GetStoreMode() OVERRIDE { |
| 2083 return store_mode_; | 2105 return store_mode_; |
| 2084 } | 2106 } |
| 2085 Type* type() const { return type_; } | 2107 Type* type() const { return type_; } |
| 2086 void set_store_mode(KeyedAccessStoreMode mode) { store_mode_ = mode; } | 2108 void set_store_mode(KeyedAccessStoreMode mode) { store_mode_ = mode; } |
| 2087 void set_type(Type* type) { type_ = type; } | 2109 void set_type(Type* type) { type_ = type; } |
| 2088 | 2110 |
| 2089 BailoutId AssignmentId() const { return assignment_id_; } | 2111 BailoutId AssignmentId() const { return BailoutId(base_id() + 0); } |
| 2090 | 2112 TypeFeedbackId CountBinOpFeedbackId() const { |
| 2091 TypeFeedbackId CountBinOpFeedbackId() const { return count_id_; } | 2113 return TypeFeedbackId(base_id() + 1); |
| 2092 TypeFeedbackId CountStoreFeedbackId() const { return reuse(id()); } | 2114 } |
| 2115 TypeFeedbackId CountStoreFeedbackId() const { |
| 2116 return TypeFeedbackId(base_id() + 2); |
| 2117 } |
| 2093 | 2118 |
| 2094 protected: | 2119 protected: |
| 2095 CountOperation(Zone* zone, Token::Value op, bool is_prefix, Expression* expr, | 2120 CountOperation(Zone* zone, Token::Value op, bool is_prefix, Expression* expr, |
| 2096 int pos, IdGen* id_gen) | 2121 int pos, IdGen* id_gen) |
| 2097 : Expression(zone, pos, id_gen), | 2122 : Expression(zone, pos, num_ids(), id_gen), |
| 2098 op_(op), | 2123 op_(op), |
| 2099 is_prefix_(is_prefix), | 2124 is_prefix_(is_prefix), |
| 2100 store_mode_(STANDARD_STORE), | 2125 store_mode_(STANDARD_STORE), |
| 2101 expression_(expr), | 2126 expression_(expr) {} |
| 2102 assignment_id_(id_gen->GetNextId()), | 2127 |
| 2103 count_id_(id_gen->GetNextId()) {} | 2128 static int num_ids() { return 3; } |
| 2129 int base_id() const { return Expression::base_id() + Expression::num_ids(); } |
| 2104 | 2130 |
| 2105 private: | 2131 private: |
| 2106 Token::Value op_; | 2132 Token::Value op_; |
| 2107 bool is_prefix_ : 1; | 2133 bool is_prefix_ : 1; |
| 2108 KeyedAccessStoreMode store_mode_ : 5; // Windows treats as signed, | 2134 KeyedAccessStoreMode store_mode_ : 5; // Windows treats as signed, |
| 2109 // must have extra bit. | 2135 // must have extra bit. |
| 2110 Type* type_; | 2136 Type* type_; |
| 2111 | |
| 2112 Expression* expression_; | 2137 Expression* expression_; |
| 2113 const BailoutId assignment_id_; | |
| 2114 const TypeFeedbackId count_id_; | |
| 2115 SmallMapList receiver_types_; | 2138 SmallMapList receiver_types_; |
| 2116 }; | 2139 }; |
| 2117 | 2140 |
| 2118 | 2141 |
| 2119 class CompareOperation FINAL : public Expression { | 2142 class CompareOperation FINAL : public Expression { |
| 2120 public: | 2143 public: |
| 2121 DECLARE_NODE_TYPE(CompareOperation) | 2144 DECLARE_NODE_TYPE(CompareOperation) |
| 2122 | 2145 |
| 2123 Token::Value op() const { return op_; } | 2146 Token::Value op() const { return op_; } |
| 2124 Expression* left() const { return left_; } | 2147 Expression* left() const { return left_; } |
| 2125 Expression* right() const { return right_; } | 2148 Expression* right() const { return right_; } |
| 2126 | 2149 |
| 2127 // Type feedback information. | 2150 // Type feedback information. |
| 2128 TypeFeedbackId CompareOperationFeedbackId() const { return reuse(id()); } | 2151 TypeFeedbackId CompareOperationFeedbackId() const { |
| 2152 return TypeFeedbackId(base_id() + 0); |
| 2153 } |
| 2129 Type* combined_type() const { return combined_type_; } | 2154 Type* combined_type() const { return combined_type_; } |
| 2130 void set_combined_type(Type* type) { combined_type_ = type; } | 2155 void set_combined_type(Type* type) { combined_type_ = type; } |
| 2131 | 2156 |
| 2132 // Match special cases. | 2157 // Match special cases. |
| 2133 bool IsLiteralCompareTypeof(Expression** expr, Handle<String>* check); | 2158 bool IsLiteralCompareTypeof(Expression** expr, Handle<String>* check); |
| 2134 bool IsLiteralCompareUndefined(Expression** expr, Isolate* isolate); | 2159 bool IsLiteralCompareUndefined(Expression** expr, Isolate* isolate); |
| 2135 bool IsLiteralCompareNull(Expression** expr); | 2160 bool IsLiteralCompareNull(Expression** expr); |
| 2136 | 2161 |
| 2137 protected: | 2162 protected: |
| 2138 CompareOperation(Zone* zone, Token::Value op, Expression* left, | 2163 CompareOperation(Zone* zone, Token::Value op, Expression* left, |
| 2139 Expression* right, int pos, IdGen* id_gen) | 2164 Expression* right, int pos, IdGen* id_gen) |
| 2140 : Expression(zone, pos, id_gen), | 2165 : Expression(zone, pos, num_ids(), id_gen), |
| 2141 op_(op), | 2166 op_(op), |
| 2142 left_(left), | 2167 left_(left), |
| 2143 right_(right), | 2168 right_(right), |
| 2144 combined_type_(Type::None(zone)) { | 2169 combined_type_(Type::None(zone)) { |
| 2145 DCHECK(Token::IsCompareOp(op)); | 2170 DCHECK(Token::IsCompareOp(op)); |
| 2146 } | 2171 } |
| 2147 | 2172 |
| 2173 static int num_ids() { return 1; } |
| 2174 int base_id() const { return Expression::base_id() + Expression::num_ids(); } |
| 2175 |
| 2148 private: | 2176 private: |
| 2149 Token::Value op_; | 2177 Token::Value op_; |
| 2150 Expression* left_; | 2178 Expression* left_; |
| 2151 Expression* right_; | 2179 Expression* right_; |
| 2152 | 2180 |
| 2153 Type* combined_type_; | 2181 Type* combined_type_; |
| 2154 }; | 2182 }; |
| 2155 | 2183 |
| 2156 | 2184 |
| 2157 class Conditional FINAL : public Expression { | 2185 class Conditional FINAL : public Expression { |
| 2158 public: | 2186 public: |
| 2159 DECLARE_NODE_TYPE(Conditional) | 2187 DECLARE_NODE_TYPE(Conditional) |
| 2160 | 2188 |
| 2161 Expression* condition() const { return condition_; } | 2189 Expression* condition() const { return condition_; } |
| 2162 Expression* then_expression() const { return then_expression_; } | 2190 Expression* then_expression() const { return then_expression_; } |
| 2163 Expression* else_expression() const { return else_expression_; } | 2191 Expression* else_expression() const { return else_expression_; } |
| 2164 | 2192 |
| 2165 BailoutId ThenId() const { return then_id_; } | 2193 BailoutId ThenId() const { return BailoutId(base_id() + 0); } |
| 2166 BailoutId ElseId() const { return else_id_; } | 2194 BailoutId ElseId() const { return BailoutId(base_id() + 1); } |
| 2167 | 2195 |
| 2168 protected: | 2196 protected: |
| 2169 Conditional(Zone* zone, Expression* condition, Expression* then_expression, | 2197 Conditional(Zone* zone, Expression* condition, Expression* then_expression, |
| 2170 Expression* else_expression, int position, IdGen* id_gen) | 2198 Expression* else_expression, int position, IdGen* id_gen) |
| 2171 : Expression(zone, position, id_gen), | 2199 : Expression(zone, position, num_ids(), id_gen), |
| 2172 condition_(condition), | 2200 condition_(condition), |
| 2173 then_expression_(then_expression), | 2201 then_expression_(then_expression), |
| 2174 else_expression_(else_expression), | 2202 else_expression_(else_expression) {} |
| 2175 then_id_(id_gen->GetNextId()), | 2203 |
| 2176 else_id_(id_gen->GetNextId()) {} | 2204 static int num_ids() { return 2; } |
| 2205 int base_id() const { return Expression::base_id() + Expression::num_ids(); } |
| 2177 | 2206 |
| 2178 private: | 2207 private: |
| 2179 Expression* condition_; | 2208 Expression* condition_; |
| 2180 Expression* then_expression_; | 2209 Expression* then_expression_; |
| 2181 Expression* else_expression_; | 2210 Expression* else_expression_; |
| 2182 const BailoutId then_id_; | |
| 2183 const BailoutId else_id_; | |
| 2184 }; | 2211 }; |
| 2185 | 2212 |
| 2186 | 2213 |
| 2187 class Assignment FINAL : public Expression { | 2214 class Assignment FINAL : public Expression { |
| 2188 public: | 2215 public: |
| 2189 DECLARE_NODE_TYPE(Assignment) | 2216 DECLARE_NODE_TYPE(Assignment) |
| 2190 | 2217 |
| 2191 Assignment* AsSimpleAssignment() { return !is_compound() ? this : NULL; } | 2218 Assignment* AsSimpleAssignment() { return !is_compound() ? this : NULL; } |
| 2192 | 2219 |
| 2193 Token::Value binary_op() const; | 2220 Token::Value binary_op() const; |
| 2194 | 2221 |
| 2195 Token::Value op() const { return op_; } | 2222 Token::Value op() const { return op_; } |
| 2196 Expression* target() const { return target_; } | 2223 Expression* target() const { return target_; } |
| 2197 Expression* value() const { return value_; } | 2224 Expression* value() const { return value_; } |
| 2198 BinaryOperation* binary_operation() const { return binary_operation_; } | 2225 BinaryOperation* binary_operation() const { return binary_operation_; } |
| 2199 | 2226 |
| 2200 // This check relies on the definition order of token in token.h. | 2227 // This check relies on the definition order of token in token.h. |
| 2201 bool is_compound() const { return op() > Token::ASSIGN; } | 2228 bool is_compound() const { return op() > Token::ASSIGN; } |
| 2202 | 2229 |
| 2203 BailoutId AssignmentId() const { return assignment_id_; } | 2230 BailoutId AssignmentId() const { return BailoutId(base_id() + 0); } |
| 2204 | 2231 |
| 2205 // Type feedback information. | 2232 // Type feedback information. |
| 2206 TypeFeedbackId AssignmentFeedbackId() { return reuse(id()); } | 2233 TypeFeedbackId AssignmentFeedbackId() { |
| 2234 return TypeFeedbackId(base_id() + 1); |
| 2235 } |
| 2207 virtual bool IsMonomorphic() OVERRIDE { | 2236 virtual bool IsMonomorphic() OVERRIDE { |
| 2208 return receiver_types_.length() == 1; | 2237 return receiver_types_.length() == 1; |
| 2209 } | 2238 } |
| 2210 bool IsUninitialized() { return is_uninitialized_; } | 2239 bool IsUninitialized() { return is_uninitialized_; } |
| 2211 bool HasNoTypeInformation() { | 2240 bool HasNoTypeInformation() { |
| 2212 return is_uninitialized_; | 2241 return is_uninitialized_; |
| 2213 } | 2242 } |
| 2214 virtual SmallMapList* GetReceiverTypes() OVERRIDE { | 2243 virtual SmallMapList* GetReceiverTypes() OVERRIDE { |
| 2215 return &receiver_types_; | 2244 return &receiver_types_; |
| 2216 } | 2245 } |
| 2217 virtual KeyedAccessStoreMode GetStoreMode() OVERRIDE { | 2246 virtual KeyedAccessStoreMode GetStoreMode() OVERRIDE { |
| 2218 return store_mode_; | 2247 return store_mode_; |
| 2219 } | 2248 } |
| 2220 void set_is_uninitialized(bool b) { is_uninitialized_ = b; } | 2249 void set_is_uninitialized(bool b) { is_uninitialized_ = b; } |
| 2221 void set_store_mode(KeyedAccessStoreMode mode) { store_mode_ = mode; } | 2250 void set_store_mode(KeyedAccessStoreMode mode) { store_mode_ = mode; } |
| 2222 | 2251 |
| 2223 protected: | 2252 protected: |
| 2224 Assignment(Zone* zone, Token::Value op, Expression* target, Expression* value, | 2253 Assignment(Zone* zone, Token::Value op, Expression* target, Expression* value, |
| 2225 int pos, IdGen* id_gen); | 2254 int pos, IdGen* id_gen); |
| 2226 | 2255 |
| 2256 static int num_ids() { return 2; } |
| 2257 int base_id() const { return Expression::base_id() + Expression::num_ids(); } |
| 2258 |
| 2227 template<class Visitor> | 2259 template<class Visitor> |
| 2228 void Init(Zone* zone, AstNodeFactory<Visitor>* factory) { | 2260 void Init(Zone* zone, AstNodeFactory<Visitor>* factory) { |
| 2229 DCHECK(Token::IsAssignmentOp(op_)); | 2261 DCHECK(Token::IsAssignmentOp(op_)); |
| 2230 if (is_compound()) { | 2262 if (is_compound()) { |
| 2231 binary_operation_ = factory->NewBinaryOperation( | 2263 binary_operation_ = factory->NewBinaryOperation( |
| 2232 binary_op(), target_, value_, position() + 1); | 2264 binary_op(), target_, value_, position() + 1); |
| 2233 } | 2265 } |
| 2234 } | 2266 } |
| 2235 | 2267 |
| 2236 private: | 2268 private: |
| 2237 Token::Value op_; | 2269 Token::Value op_; |
| 2238 Expression* target_; | 2270 Expression* target_; |
| 2239 Expression* value_; | 2271 Expression* value_; |
| 2240 BinaryOperation* binary_operation_; | 2272 BinaryOperation* binary_operation_; |
| 2241 const BailoutId assignment_id_; | |
| 2242 | |
| 2243 bool is_uninitialized_ : 1; | 2273 bool is_uninitialized_ : 1; |
| 2244 KeyedAccessStoreMode store_mode_ : 5; // Windows treats as signed, | 2274 KeyedAccessStoreMode store_mode_ : 5; // Windows treats as signed, |
| 2245 // must have extra bit. | 2275 // must have extra bit. |
| 2246 SmallMapList receiver_types_; | 2276 SmallMapList receiver_types_; |
| 2247 }; | 2277 }; |
| 2248 | 2278 |
| 2249 | 2279 |
| 2250 class Yield FINAL : public Expression { | 2280 class Yield FINAL : public Expression { |
| 2251 public: | 2281 public: |
| 2252 DECLARE_NODE_TYPE(Yield) | 2282 DECLARE_NODE_TYPE(Yield) |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2293 } | 2323 } |
| 2294 | 2324 |
| 2295 int ValueFeedbackSlot() { | 2325 int ValueFeedbackSlot() { |
| 2296 DCHECK(yield_first_feedback_slot_ != kInvalidFeedbackSlot); | 2326 DCHECK(yield_first_feedback_slot_ != kInvalidFeedbackSlot); |
| 2297 return yield_first_feedback_slot_ + 2; | 2327 return yield_first_feedback_slot_ + 2; |
| 2298 } | 2328 } |
| 2299 | 2329 |
| 2300 protected: | 2330 protected: |
| 2301 Yield(Zone* zone, Expression* generator_object, Expression* expression, | 2331 Yield(Zone* zone, Expression* generator_object, Expression* expression, |
| 2302 Kind yield_kind, int pos, IdGen* id_gen) | 2332 Kind yield_kind, int pos, IdGen* id_gen) |
| 2303 : Expression(zone, pos, id_gen), | 2333 : Expression(zone, pos, 0, id_gen), |
| 2304 generator_object_(generator_object), | 2334 generator_object_(generator_object), |
| 2305 expression_(expression), | 2335 expression_(expression), |
| 2306 yield_kind_(yield_kind), | 2336 yield_kind_(yield_kind), |
| 2307 index_(-1), | 2337 index_(-1), |
| 2308 yield_first_feedback_slot_(kInvalidFeedbackSlot) {} | 2338 yield_first_feedback_slot_(kInvalidFeedbackSlot) {} |
| 2309 | 2339 |
| 2310 private: | 2340 private: |
| 2311 Expression* generator_object_; | 2341 Expression* generator_object_; |
| 2312 Expression* expression_; | 2342 Expression* expression_; |
| 2313 Kind yield_kind_; | 2343 Kind yield_kind_; |
| 2314 int index_; | 2344 int index_; |
| 2315 int yield_first_feedback_slot_; | 2345 int yield_first_feedback_slot_; |
| 2316 }; | 2346 }; |
| 2317 | 2347 |
| 2318 | 2348 |
| 2319 class Throw FINAL : public Expression { | 2349 class Throw FINAL : public Expression { |
| 2320 public: | 2350 public: |
| 2321 DECLARE_NODE_TYPE(Throw) | 2351 DECLARE_NODE_TYPE(Throw) |
| 2322 | 2352 |
| 2323 Expression* exception() const { return exception_; } | 2353 Expression* exception() const { return exception_; } |
| 2324 | 2354 |
| 2325 protected: | 2355 protected: |
| 2326 Throw(Zone* zone, Expression* exception, int pos, IdGen* id_gen) | 2356 Throw(Zone* zone, Expression* exception, int pos, IdGen* id_gen) |
| 2327 : Expression(zone, pos, id_gen), exception_(exception) {} | 2357 : Expression(zone, pos, 0, id_gen), exception_(exception) {} |
| 2328 | 2358 |
| 2329 private: | 2359 private: |
| 2330 Expression* exception_; | 2360 Expression* exception_; |
| 2331 }; | 2361 }; |
| 2332 | 2362 |
| 2333 | 2363 |
| 2334 class FunctionLiteral FINAL : public Expression { | 2364 class FunctionLiteral FINAL : public Expression { |
| 2335 public: | 2365 public: |
| 2336 enum FunctionType { | 2366 enum FunctionType { |
| 2337 ANONYMOUS_EXPRESSION, | 2367 ANONYMOUS_EXPRESSION, |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2471 protected: | 2501 protected: |
| 2472 FunctionLiteral(Zone* zone, const AstRawString* name, | 2502 FunctionLiteral(Zone* zone, const AstRawString* name, |
| 2473 AstValueFactory* ast_value_factory, Scope* scope, | 2503 AstValueFactory* ast_value_factory, Scope* scope, |
| 2474 ZoneList<Statement*>* body, int materialized_literal_count, | 2504 ZoneList<Statement*>* body, int materialized_literal_count, |
| 2475 int expected_property_count, int handler_count, | 2505 int expected_property_count, int handler_count, |
| 2476 int parameter_count, FunctionType function_type, | 2506 int parameter_count, FunctionType function_type, |
| 2477 ParameterFlag has_duplicate_parameters, | 2507 ParameterFlag has_duplicate_parameters, |
| 2478 IsFunctionFlag is_function, | 2508 IsFunctionFlag is_function, |
| 2479 IsParenthesizedFlag is_parenthesized, FunctionKind kind, | 2509 IsParenthesizedFlag is_parenthesized, FunctionKind kind, |
| 2480 int position, IdGen* id_gen) | 2510 int position, IdGen* id_gen) |
| 2481 : Expression(zone, position, id_gen), | 2511 : Expression(zone, position, 0, id_gen), |
| 2482 raw_name_(name), | 2512 raw_name_(name), |
| 2483 scope_(scope), | 2513 scope_(scope), |
| 2484 body_(body), | 2514 body_(body), |
| 2485 raw_inferred_name_(ast_value_factory->empty_string()), | 2515 raw_inferred_name_(ast_value_factory->empty_string()), |
| 2486 dont_optimize_reason_(kNoReason), | 2516 dont_optimize_reason_(kNoReason), |
| 2487 materialized_literal_count_(materialized_literal_count), | 2517 materialized_literal_count_(materialized_literal_count), |
| 2488 expected_property_count_(expected_property_count), | 2518 expected_property_count_(expected_property_count), |
| 2489 handler_count_(handler_count), | 2519 handler_count_(handler_count), |
| 2490 parameter_count_(parameter_count), | 2520 parameter_count_(parameter_count), |
| 2491 function_token_position_(RelocInfo::kNoPosition) { | 2521 function_token_position_(RelocInfo::kNoPosition) { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2538 Expression* extends() const { return extends_; } | 2568 Expression* extends() const { return extends_; } |
| 2539 Expression* constructor() const { return constructor_; } | 2569 Expression* constructor() const { return constructor_; } |
| 2540 ZoneList<Property*>* properties() const { return properties_; } | 2570 ZoneList<Property*>* properties() const { return properties_; } |
| 2541 int start_position() const { return position(); } | 2571 int start_position() const { return position(); } |
| 2542 int end_position() const { return end_position_; } | 2572 int end_position() const { return end_position_; } |
| 2543 | 2573 |
| 2544 protected: | 2574 protected: |
| 2545 ClassLiteral(Zone* zone, const AstRawString* name, Expression* extends, | 2575 ClassLiteral(Zone* zone, const AstRawString* name, Expression* extends, |
| 2546 Expression* constructor, ZoneList<Property*>* properties, | 2576 Expression* constructor, ZoneList<Property*>* properties, |
| 2547 int start_position, int end_position, IdGen* id_gen) | 2577 int start_position, int end_position, IdGen* id_gen) |
| 2548 : Expression(zone, start_position, id_gen), | 2578 : Expression(zone, start_position, 0, id_gen), |
| 2549 raw_name_(name), | 2579 raw_name_(name), |
| 2550 extends_(extends), | 2580 extends_(extends), |
| 2551 constructor_(constructor), | 2581 constructor_(constructor), |
| 2552 properties_(properties), | 2582 properties_(properties), |
| 2553 end_position_(end_position) {} | 2583 end_position_(end_position) {} |
| 2554 | 2584 |
| 2555 private: | 2585 private: |
| 2556 const AstRawString* raw_name_; | 2586 const AstRawString* raw_name_; |
| 2557 Expression* extends_; | 2587 Expression* extends_; |
| 2558 Expression* constructor_; | 2588 Expression* constructor_; |
| 2559 ZoneList<Property*>* properties_; | 2589 ZoneList<Property*>* properties_; |
| 2560 int end_position_; | 2590 int end_position_; |
| 2561 }; | 2591 }; |
| 2562 | 2592 |
| 2563 | 2593 |
| 2564 class NativeFunctionLiteral FINAL : public Expression { | 2594 class NativeFunctionLiteral FINAL : public Expression { |
| 2565 public: | 2595 public: |
| 2566 DECLARE_NODE_TYPE(NativeFunctionLiteral) | 2596 DECLARE_NODE_TYPE(NativeFunctionLiteral) |
| 2567 | 2597 |
| 2568 Handle<String> name() const { return name_->string(); } | 2598 Handle<String> name() const { return name_->string(); } |
| 2569 v8::Extension* extension() const { return extension_; } | 2599 v8::Extension* extension() const { return extension_; } |
| 2570 | 2600 |
| 2571 protected: | 2601 protected: |
| 2572 NativeFunctionLiteral(Zone* zone, const AstRawString* name, | 2602 NativeFunctionLiteral(Zone* zone, const AstRawString* name, |
| 2573 v8::Extension* extension, int pos, IdGen* id_gen) | 2603 v8::Extension* extension, int pos, IdGen* id_gen) |
| 2574 : Expression(zone, pos, id_gen), name_(name), extension_(extension) {} | 2604 : Expression(zone, pos, 0, id_gen), name_(name), extension_(extension) {} |
| 2575 | 2605 |
| 2576 private: | 2606 private: |
| 2577 const AstRawString* name_; | 2607 const AstRawString* name_; |
| 2578 v8::Extension* extension_; | 2608 v8::Extension* extension_; |
| 2579 }; | 2609 }; |
| 2580 | 2610 |
| 2581 | 2611 |
| 2582 class ThisFunction FINAL : public Expression { | 2612 class ThisFunction FINAL : public Expression { |
| 2583 public: | 2613 public: |
| 2584 DECLARE_NODE_TYPE(ThisFunction) | 2614 DECLARE_NODE_TYPE(ThisFunction) |
| 2585 | 2615 |
| 2586 protected: | 2616 protected: |
| 2587 ThisFunction(Zone* zone, int pos, IdGen* id_gen) | 2617 ThisFunction(Zone* zone, int pos, IdGen* id_gen) |
| 2588 : Expression(zone, pos, id_gen) {} | 2618 : Expression(zone, pos, 0, id_gen) {} |
| 2589 }; | 2619 }; |
| 2590 | 2620 |
| 2591 | 2621 |
| 2592 class SuperReference FINAL : public Expression { | 2622 class SuperReference FINAL : public Expression { |
| 2593 public: | 2623 public: |
| 2594 DECLARE_NODE_TYPE(SuperReference) | 2624 DECLARE_NODE_TYPE(SuperReference) |
| 2595 | 2625 |
| 2596 VariableProxy* this_var() const { return this_var_; } | 2626 VariableProxy* this_var() const { return this_var_; } |
| 2597 | 2627 |
| 2598 TypeFeedbackId HomeObjectFeedbackId() { return reuse(id()); } | 2628 TypeFeedbackId HomeObjectFeedbackId() { |
| 2629 return TypeFeedbackId(base_id() + 0); |
| 2630 } |
| 2599 | 2631 |
| 2600 // Type feedback information. | 2632 // Type feedback information. |
| 2601 virtual int ComputeFeedbackSlotCount() { return FLAG_vector_ics ? 1 : 0; } | 2633 virtual int ComputeFeedbackSlotCount() { return FLAG_vector_ics ? 1 : 0; } |
| 2602 virtual void SetFirstFeedbackSlot(int slot) { | 2634 virtual void SetFirstFeedbackSlot(int slot) { |
| 2603 homeobject_feedback_slot_ = slot; | 2635 homeobject_feedback_slot_ = slot; |
| 2604 } | 2636 } |
| 2605 | 2637 |
| 2606 int HomeObjectFeedbackSlot() { | 2638 int HomeObjectFeedbackSlot() { |
| 2607 DCHECK(!FLAG_vector_ics || | 2639 DCHECK(!FLAG_vector_ics || |
| 2608 homeobject_feedback_slot_ != kInvalidFeedbackSlot); | 2640 homeobject_feedback_slot_ != kInvalidFeedbackSlot); |
| 2609 return homeobject_feedback_slot_; | 2641 return homeobject_feedback_slot_; |
| 2610 } | 2642 } |
| 2611 | 2643 |
| 2612 protected: | 2644 protected: |
| 2613 SuperReference(Zone* zone, VariableProxy* this_var, int pos, IdGen* id_gen) | 2645 SuperReference(Zone* zone, VariableProxy* this_var, int pos, IdGen* id_gen) |
| 2614 : Expression(zone, pos, id_gen), | 2646 : Expression(zone, pos, num_ids(), id_gen), |
| 2615 this_var_(this_var), | 2647 this_var_(this_var), |
| 2616 homeobject_feedback_slot_(kInvalidFeedbackSlot) { | 2648 homeobject_feedback_slot_(kInvalidFeedbackSlot) { |
| 2617 DCHECK(this_var->is_this()); | 2649 DCHECK(this_var->is_this()); |
| 2618 } | 2650 } |
| 2619 | 2651 |
| 2652 static int num_ids() { return 1; } |
| 2653 int base_id() const { return Expression::base_id() + Expression::num_ids(); } |
| 2654 |
| 2655 private: |
| 2620 VariableProxy* this_var_; | 2656 VariableProxy* this_var_; |
| 2621 int homeobject_feedback_slot_; | 2657 int homeobject_feedback_slot_; |
| 2622 }; | 2658 }; |
| 2623 | 2659 |
| 2624 | 2660 |
| 2625 #undef DECLARE_NODE_TYPE | 2661 #undef DECLARE_NODE_TYPE |
| 2626 | 2662 |
| 2627 | 2663 |
| 2628 // ---------------------------------------------------------------------------- | 2664 // ---------------------------------------------------------------------------- |
| 2629 // Regular expressions | 2665 // Regular expressions |
| (...skipping 958 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3588 Zone* zone_; | 3624 Zone* zone_; |
| 3589 Visitor visitor_; | 3625 Visitor visitor_; |
| 3590 AstValueFactory* ast_value_factory_; | 3626 AstValueFactory* ast_value_factory_; |
| 3591 AstNode::IdGen* id_gen_; | 3627 AstNode::IdGen* id_gen_; |
| 3592 }; | 3628 }; |
| 3593 | 3629 |
| 3594 | 3630 |
| 3595 } } // namespace v8::internal | 3631 } } // namespace v8::internal |
| 3596 | 3632 |
| 3597 #endif // V8_AST_H_ | 3633 #endif // V8_AST_H_ |
| OLD | NEW |