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

Side by Side Diff: src/ast.h

Issue 569573002: Remove redundant ids from AST (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/ast.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 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 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 virtual KeyedAccessStoreMode GetStoreMode() { 368 virtual KeyedAccessStoreMode GetStoreMode() {
369 UNREACHABLE(); 369 UNREACHABLE();
370 return STANDARD_STORE; 370 return STANDARD_STORE;
371 } 371 }
372 372
373 // TODO(rossberg): this should move to its own AST node eventually. 373 // TODO(rossberg): this should move to its own AST node eventually.
374 virtual void RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle); 374 virtual void RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle);
375 byte to_boolean_types() const { return to_boolean_types_; } 375 byte to_boolean_types() const { return to_boolean_types_; }
376 376
377 BailoutId id() const { return id_; } 377 BailoutId id() const { return id_; }
378 TypeFeedbackId test_id() const { return test_id_; } 378 TypeFeedbackId test_id() const { return TypeFeedbackId(id_.ToInt() + 1); }
379 379
380 protected: 380 protected:
381 Expression(Zone* zone, int pos, IdGen* id_gen) 381 Expression(Zone* zone, int pos, IdGen* id_gen)
382 : AstNode(pos), 382 : AstNode(pos),
383 bounds_(Bounds::Unbounded(zone)), 383 bounds_(Bounds::Unbounded(zone)),
384 parenthesization_level_(0), 384 parenthesization_level_(0),
385 id_(id_gen->GetNextId()), 385 id_(id_gen->ReserveIdRange(2)) {} // Reserve id and test id
386 test_id_(id_gen->GetNextId()) {} 386
387 void set_to_boolean_types(byte types) { to_boolean_types_ = types; } 387 void set_to_boolean_types(byte types) { to_boolean_types_ = types; }
388 388
389 private: 389 private:
390 Bounds bounds_; 390 Bounds bounds_;
391 byte to_boolean_types_; 391 byte to_boolean_types_;
392 unsigned parenthesization_level_; 392 unsigned parenthesization_level_;
393 393
394 const BailoutId id_; 394 const BailoutId id_;
395 const TypeFeedbackId test_id_;
396 }; 395 };
397 396
398 397
399 class BreakableStatement : public Statement { 398 class BreakableStatement : public Statement {
400 public: 399 public:
401 enum BreakableType { 400 enum BreakableType {
402 TARGET_FOR_ANONYMOUS, 401 TARGET_FOR_ANONYMOUS,
403 TARGET_FOR_NAMED_ONLY 402 TARGET_FOR_NAMED_ONLY
404 }; 403 };
405 404
406 // The labels associated with this statement. May be NULL; 405 // The labels associated with this statement. May be NULL;
407 // if it is != NULL, guaranteed to contain at least one entry. 406 // if it is != NULL, guaranteed to contain at least one entry.
408 ZoneList<const AstRawString*>* labels() const { return labels_; } 407 ZoneList<const AstRawString*>* labels() const { return labels_; }
409 408
410 // Type testing & conversion. 409 // Type testing & conversion.
411 virtual BreakableStatement* AsBreakableStatement() FINAL OVERRIDE { 410 virtual BreakableStatement* AsBreakableStatement() FINAL OVERRIDE {
412 return this; 411 return this;
413 } 412 }
414 413
415 // Code generation 414 // Code generation
416 Label* break_target() { return &break_target_; } 415 Label* break_target() { return &break_target_; }
417 416
418 // Testers. 417 // Testers.
419 bool is_target_for_anonymous() const { 418 bool is_target_for_anonymous() const {
420 return breakable_type_ == TARGET_FOR_ANONYMOUS; 419 return breakable_type_ == TARGET_FOR_ANONYMOUS;
421 } 420 }
422 421
423 BailoutId EntryId() const { return entry_id_; } 422 BailoutId EntryId() const { return entry_id_; }
424 BailoutId ExitId() const { return exit_id_; } 423 BailoutId ExitId() const { return BailoutId(entry_id_.ToInt() + 1); }
425 424
426 protected: 425 protected:
427 BreakableStatement(Zone* zone, ZoneList<const AstRawString*>* labels, 426 BreakableStatement(Zone* zone, ZoneList<const AstRawString*>* labels,
428 BreakableType breakable_type, int position, IdGen* id_gen) 427 BreakableType breakable_type, int position, IdGen* id_gen)
429 : Statement(zone, position), 428 : Statement(zone, position),
430 labels_(labels), 429 labels_(labels),
431 breakable_type_(breakable_type), 430 breakable_type_(breakable_type),
432 entry_id_(id_gen->GetNextId()), 431 entry_id_(id_gen->ReserveIdRange(2)) { // Reserve entry and exit ids
433 exit_id_(id_gen->GetNextId()) {
434 DCHECK(labels == NULL || labels->length() > 0); 432 DCHECK(labels == NULL || labels->length() > 0);
435 } 433 }
436 434
437 435
438 private: 436 private:
439 ZoneList<const AstRawString*>* labels_; 437 ZoneList<const AstRawString*>* labels_;
440 BreakableType breakable_type_; 438 BreakableType breakable_type_;
441 Label break_target_; 439 Label break_target_;
442 const BailoutId entry_id_; 440 const BailoutId entry_id_;
443 const BailoutId exit_id_;
444 }; 441 };
445 442
446 443
447 class Block FINAL : public BreakableStatement { 444 class Block FINAL : public BreakableStatement {
448 public: 445 public:
449 DECLARE_NODE_TYPE(Block) 446 DECLARE_NODE_TYPE(Block)
450 447
451 void AddStatement(Statement* statement, Zone* zone) { 448 void AddStatement(Statement* statement, Zone* zone) {
452 statements_.Add(statement, zone); 449 statements_.Add(statement, zone);
453 } 450 }
454 451
455 ZoneList<Statement*>* statements() { return &statements_; } 452 ZoneList<Statement*>* statements() { return &statements_; }
456 bool is_initializer_block() const { return is_initializer_block_; } 453 bool is_initializer_block() const { return is_initializer_block_; }
457 454
458 BailoutId DeclsId() const { return decls_id_; } 455 BailoutId DeclsId() const { return BailoutId(EntryId().ToInt() + 2); }
marja 2014/09/12 12:51:55 This looks a bit fragile... now if somebody adds a
oetuaho-nv 2014/09/12 13:26:29 Yep, the thought crossed my mind that there might
459 456
460 virtual bool IsJump() const OVERRIDE { 457 virtual bool IsJump() const OVERRIDE {
461 return !statements_.is_empty() && statements_.last()->IsJump() 458 return !statements_.is_empty() && statements_.last()->IsJump()
462 && labels() == NULL; // Good enough as an approximation... 459 && labels() == NULL; // Good enough as an approximation...
463 } 460 }
464 461
465 Scope* scope() const { return scope_; } 462 Scope* scope() const { return scope_; }
466 void set_scope(Scope* scope) { scope_ = scope; } 463 void set_scope(Scope* scope) { scope_ = scope; }
467 464
468 protected: 465 protected:
469 Block(Zone* zone, ZoneList<const AstRawString*>* labels, int capacity, 466 Block(Zone* zone, ZoneList<const AstRawString*>* labels, int capacity,
470 bool is_initializer_block, int pos, IdGen* id_gen) 467 bool is_initializer_block, int pos, IdGen* id_gen)
471 : BreakableStatement(zone, labels, TARGET_FOR_NAMED_ONLY, pos, id_gen), 468 : BreakableStatement(zone, labels, TARGET_FOR_NAMED_ONLY, pos, id_gen),
472 statements_(capacity, zone), 469 statements_(capacity, zone),
473 is_initializer_block_(is_initializer_block), 470 is_initializer_block_(is_initializer_block),
474 decls_id_(id_gen->GetNextId()), 471 scope_(NULL) {
475 scope_(NULL) {} 472 #ifdef DEBUG
473 int decls_id =
474 #endif
475 id_gen->GetNextId(); // Reserve decls id
476 DCHECK(decls_id == EntryId().ToInt() + 2);
477 }
476 478
477 private: 479 private:
478 ZoneList<Statement*> statements_; 480 ZoneList<Statement*> statements_;
479 bool is_initializer_block_; 481 bool is_initializer_block_;
480 const BailoutId decls_id_;
481 Scope* scope_; 482 Scope* scope_;
482 }; 483 };
483 484
484 485
485 class Declaration : public AstNode { 486 class Declaration : public AstNode {
486 public: 487 public:
487 VariableProxy* proxy() const { return proxy_; } 488 VariableProxy* proxy() const { return proxy_; }
488 VariableMode mode() const { return mode_; } 489 VariableMode mode() const { return mode_; }
489 Scope* scope() const { return scope_; } 490 Scope* scope() const { return scope_; }
490 virtual InitializationFlag initialization() const = 0; 491 virtual InitializationFlag initialization() const = 0;
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 723
723 class IterationStatement : public BreakableStatement { 724 class IterationStatement : public BreakableStatement {
724 public: 725 public:
725 // Type testing & conversion. 726 // Type testing & conversion.
726 virtual IterationStatement* AsIterationStatement() FINAL OVERRIDE { 727 virtual IterationStatement* AsIterationStatement() FINAL OVERRIDE {
727 return this; 728 return this;
728 } 729 }
729 730
730 Statement* body() const { return body_; } 731 Statement* body() const { return body_; }
731 732
732 BailoutId OsrEntryId() const { return osr_entry_id_; } 733 BailoutId OsrEntryId() const { return BailoutId(EntryId().ToInt() + 2); }
733 virtual BailoutId ContinueId() const = 0; 734 virtual BailoutId ContinueId() const = 0;
734 virtual BailoutId StackCheckId() const = 0; 735 virtual BailoutId StackCheckId() const = 0;
735 736
736 // Code generation 737 // Code generation
737 Label* continue_target() { return &continue_target_; } 738 Label* continue_target() { return &continue_target_; }
738 739
739 protected: 740 protected:
740 IterationStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos, 741 IterationStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos,
741 IdGen* id_gen) 742 IdGen* id_gen)
742 : BreakableStatement(zone, labels, TARGET_FOR_ANONYMOUS, pos, id_gen), 743 : BreakableStatement(zone, labels, TARGET_FOR_ANONYMOUS, pos, id_gen),
743 body_(NULL), 744 body_(NULL) {
744 osr_entry_id_(id_gen->GetNextId()) {} 745 #ifdef DEBUG
746 int id =
747 #endif
748 id_gen->GetNextId(); // Reserve osr entry id
749 DCHECK(id == EntryId().ToInt() + 2);
750 }
745 751
746 void Initialize(Statement* body) { 752 void Initialize(Statement* body) {
747 body_ = body; 753 body_ = body;
748 } 754 }
749 755
750 private: 756 private:
751 Statement* body_; 757 Statement* body_;
752 Label continue_target_; 758 Label continue_target_;
753
754 const BailoutId osr_entry_id_;
755 }; 759 };
756 760
757 761
758 class DoWhileStatement FINAL : public IterationStatement { 762 class DoWhileStatement FINAL : public IterationStatement {
759 public: 763 public:
760 DECLARE_NODE_TYPE(DoWhileStatement) 764 DECLARE_NODE_TYPE(DoWhileStatement)
761 765
762 void Initialize(Expression* cond, Statement* body) { 766 void Initialize(Expression* cond, Statement* body) {
763 IterationStatement::Initialize(body); 767 IterationStatement::Initialize(body);
764 cond_ = cond; 768 cond_ = cond;
765 } 769 }
766 770
767 Expression* cond() const { return cond_; } 771 Expression* cond() const { return cond_; }
768 772
769 virtual BailoutId ContinueId() const OVERRIDE { return continue_id_; } 773 virtual BailoutId ContinueId() const OVERRIDE {
770 virtual BailoutId StackCheckId() const OVERRIDE { return back_edge_id_; } 774 return BailoutId(EntryId().ToInt() + 3);
771 BailoutId BackEdgeId() const { return back_edge_id_; } 775 }
776 virtual BailoutId StackCheckId() const OVERRIDE {
777 return BailoutId(EntryId().ToInt() + 4);
778 }
779 BailoutId BackEdgeId() const { return BailoutId(EntryId().ToInt() + 4); }
772 780
773 protected: 781 protected:
774 DoWhileStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos, 782 DoWhileStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos,
775 IdGen* id_gen) 783 IdGen* id_gen)
776 : IterationStatement(zone, labels, pos, id_gen), 784 : IterationStatement(zone, labels, pos, id_gen),
777 cond_(NULL), 785 cond_(NULL) {
778 continue_id_(id_gen->GetNextId()), 786 // reserve continue and back edge ids
779 back_edge_id_(id_gen->GetNextId()) {} 787 #ifdef DEBUG
788 int continue_id =
789 #endif
790 id_gen->ReserveIdRange(2);
791 DCHECK(continue_id == EntryId().ToInt() + 3);
792 }
780 793
781 private: 794 private:
782 Expression* cond_; 795 Expression* cond_;
783
784 const BailoutId continue_id_;
785 const BailoutId back_edge_id_;
786 }; 796 };
787 797
788 798
789 class WhileStatement FINAL : public IterationStatement { 799 class WhileStatement FINAL : public IterationStatement {
790 public: 800 public:
791 DECLARE_NODE_TYPE(WhileStatement) 801 DECLARE_NODE_TYPE(WhileStatement)
792 802
793 void Initialize(Expression* cond, Statement* body) { 803 void Initialize(Expression* cond, Statement* body) {
794 IterationStatement::Initialize(body); 804 IterationStatement::Initialize(body);
795 cond_ = cond; 805 cond_ = cond;
796 } 806 }
797 807
798 Expression* cond() const { return cond_; } 808 Expression* cond() const { return cond_; }
799 bool may_have_function_literal() const { 809 bool may_have_function_literal() const {
800 return may_have_function_literal_; 810 return may_have_function_literal_;
801 } 811 }
802 void set_may_have_function_literal(bool value) { 812 void set_may_have_function_literal(bool value) {
803 may_have_function_literal_ = value; 813 may_have_function_literal_ = value;
804 } 814 }
805 815
806 virtual BailoutId ContinueId() const OVERRIDE { return EntryId(); } 816 virtual BailoutId ContinueId() const OVERRIDE { return EntryId(); }
807 virtual BailoutId StackCheckId() const OVERRIDE { return body_id_; } 817 virtual BailoutId StackCheckId() const OVERRIDE {
808 BailoutId BodyId() const { return body_id_; } 818 return BailoutId(EntryId().ToInt() + 3);
819 }
820 BailoutId BodyId() const { return BailoutId(EntryId().ToInt() + 3); }
809 821
810 protected: 822 protected:
811 WhileStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos, 823 WhileStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos,
812 IdGen* id_gen) 824 IdGen* id_gen)
813 : IterationStatement(zone, labels, pos, id_gen), 825 : IterationStatement(zone, labels, pos, id_gen),
814 cond_(NULL), 826 cond_(NULL),
815 may_have_function_literal_(true), 827 may_have_function_literal_(true) {
816 body_id_(id_gen->GetNextId()) {} 828 #ifdef DEBUG
829 int body_id =
830 #endif
831 id_gen->GetNextId(); // Reserve body id
832 DCHECK(body_id == EntryId().ToInt() + 3);
833 }
817 834
818 private: 835 private:
819 Expression* cond_; 836 Expression* cond_;
820 837
821 // True if there is a function literal subexpression in the condition. 838 // True if there is a function literal subexpression in the condition.
822 bool may_have_function_literal_; 839 bool may_have_function_literal_;
823
824 const BailoutId body_id_;
825 }; 840 };
826 841
827 842
828 class ForStatement FINAL : public IterationStatement { 843 class ForStatement FINAL : public IterationStatement {
829 public: 844 public:
830 DECLARE_NODE_TYPE(ForStatement) 845 DECLARE_NODE_TYPE(ForStatement)
831 846
832 void Initialize(Statement* init, 847 void Initialize(Statement* init,
833 Expression* cond, 848 Expression* cond,
834 Statement* next, 849 Statement* next,
835 Statement* body) { 850 Statement* body) {
836 IterationStatement::Initialize(body); 851 IterationStatement::Initialize(body);
837 init_ = init; 852 init_ = init;
838 cond_ = cond; 853 cond_ = cond;
839 next_ = next; 854 next_ = next;
840 } 855 }
841 856
842 Statement* init() const { return init_; } 857 Statement* init() const { return init_; }
843 Expression* cond() const { return cond_; } 858 Expression* cond() const { return cond_; }
844 Statement* next() const { return next_; } 859 Statement* next() const { return next_; }
845 860
846 bool may_have_function_literal() const { 861 bool may_have_function_literal() const {
847 return may_have_function_literal_; 862 return may_have_function_literal_;
848 } 863 }
849 void set_may_have_function_literal(bool value) { 864 void set_may_have_function_literal(bool value) {
850 may_have_function_literal_ = value; 865 may_have_function_literal_ = value;
851 } 866 }
852 867
853 virtual BailoutId ContinueId() const OVERRIDE { return continue_id_; } 868 virtual BailoutId ContinueId() const OVERRIDE {
854 virtual BailoutId StackCheckId() const OVERRIDE { return body_id_; } 869 return BailoutId(EntryId().ToInt() + 3);
855 BailoutId BodyId() const { return body_id_; } 870 }
871 virtual BailoutId StackCheckId() const OVERRIDE {
872 return BailoutId(EntryId().ToInt() + 4);
873 }
874 BailoutId BodyId() const { return BailoutId(EntryId().ToInt() + 4); }
856 875
857 bool is_fast_smi_loop() { return loop_variable_ != NULL; } 876 bool is_fast_smi_loop() { return loop_variable_ != NULL; }
858 Variable* loop_variable() { return loop_variable_; } 877 Variable* loop_variable() { return loop_variable_; }
859 void set_loop_variable(Variable* var) { loop_variable_ = var; } 878 void set_loop_variable(Variable* var) { loop_variable_ = var; }
860 879
861 protected: 880 protected:
862 ForStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos, 881 ForStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos,
863 IdGen* id_gen) 882 IdGen* id_gen)
864 : IterationStatement(zone, labels, pos, id_gen), 883 : IterationStatement(zone, labels, pos, id_gen),
865 init_(NULL), 884 init_(NULL),
866 cond_(NULL), 885 cond_(NULL),
867 next_(NULL), 886 next_(NULL),
868 may_have_function_literal_(true), 887 may_have_function_literal_(true),
869 loop_variable_(NULL), 888 loop_variable_(NULL) {
870 continue_id_(id_gen->GetNextId()), 889 #ifdef DEBUG
871 body_id_(id_gen->GetNextId()) {} 890 int continue_id =
891 #endif
892 id_gen->ReserveIdRange(2); // Reserve continue and body ids
893 DCHECK(continue_id == EntryId().ToInt() + 3);
894 }
872 895
873 private: 896 private:
874 Statement* init_; 897 Statement* init_;
875 Expression* cond_; 898 Expression* cond_;
876 Statement* next_; 899 Statement* next_;
877 900
878 // True if there is a function literal subexpression in the condition. 901 // True if there is a function literal subexpression in the condition.
879 bool may_have_function_literal_; 902 bool may_have_function_literal_;
880 Variable* loop_variable_; 903 Variable* loop_variable_;
881
882 const BailoutId continue_id_;
883 const BailoutId body_id_;
884 }; 904 };
885 905
886 906
887 class ForEachStatement : public IterationStatement { 907 class ForEachStatement : public IterationStatement {
888 public: 908 public:
889 enum VisitMode { 909 enum VisitMode {
890 ENUMERATE, // for (each in subject) body; 910 ENUMERATE, // for (each in subject) body;
891 ITERATE // for (each of subject) body; 911 ITERATE // for (each of subject) body;
892 }; 912 };
893 913
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
928 948
929 int ForInFeedbackSlot() { 949 int ForInFeedbackSlot() {
930 DCHECK(for_in_feedback_slot_ != kInvalidFeedbackSlot); 950 DCHECK(for_in_feedback_slot_ != kInvalidFeedbackSlot);
931 return for_in_feedback_slot_; 951 return for_in_feedback_slot_;
932 } 952 }
933 953
934 enum ForInType { FAST_FOR_IN, SLOW_FOR_IN }; 954 enum ForInType { FAST_FOR_IN, SLOW_FOR_IN };
935 ForInType for_in_type() const { return for_in_type_; } 955 ForInType for_in_type() const { return for_in_type_; }
936 void set_for_in_type(ForInType type) { for_in_type_ = type; } 956 void set_for_in_type(ForInType type) { for_in_type_ = type; }
937 957
938 BailoutId BodyId() const { return body_id_; } 958 BailoutId BodyId() const { return BailoutId(EntryId().ToInt() + 3); }
939 BailoutId PrepareId() const { return prepare_id_; } 959 BailoutId PrepareId() const { return BailoutId(EntryId().ToInt() + 4); }
940 virtual BailoutId ContinueId() const OVERRIDE { return EntryId(); } 960 virtual BailoutId ContinueId() const OVERRIDE { return EntryId(); }
941 virtual BailoutId StackCheckId() const OVERRIDE { return body_id_; } 961 virtual BailoutId StackCheckId() const OVERRIDE { return BodyId(); }
942 962
943 protected: 963 protected:
944 ForInStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos, 964 ForInStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos,
945 IdGen* id_gen) 965 IdGen* id_gen)
946 : ForEachStatement(zone, labels, pos, id_gen), 966 : ForEachStatement(zone, labels, pos, id_gen),
947 for_in_type_(SLOW_FOR_IN), 967 for_in_type_(SLOW_FOR_IN),
948 for_in_feedback_slot_(kInvalidFeedbackSlot), 968 for_in_feedback_slot_(kInvalidFeedbackSlot) {
949 body_id_(id_gen->GetNextId()), 969 #ifdef DEBUG
950 prepare_id_(id_gen->GetNextId()) {} 970 int body_id =
971 #endif
972 id_gen->ReserveIdRange(2); // reserve body and prepare ids
973 DCHECK(body_id == EntryId().ToInt() + 3);
974 }
951 975
952 ForInType for_in_type_; 976 ForInType for_in_type_;
953 int for_in_feedback_slot_; 977 int for_in_feedback_slot_;
954 const BailoutId body_id_;
955 const BailoutId prepare_id_;
956 }; 978 };
957 979
958 980
959 class ForOfStatement FINAL : public ForEachStatement { 981 class ForOfStatement FINAL : public ForEachStatement {
960 public: 982 public:
961 DECLARE_NODE_TYPE(ForOfStatement) 983 DECLARE_NODE_TYPE(ForOfStatement)
962 984
963 void Initialize(Expression* each, 985 void Initialize(Expression* each,
964 Expression* subject, 986 Expression* subject,
965 Statement* body, 987 Statement* body,
(...skipping 28 matching lines...) Expand all
994 } 1016 }
995 1017
996 // each = result.value 1018 // each = result.value
997 Expression* assign_each() const { 1019 Expression* assign_each() const {
998 return assign_each_; 1020 return assign_each_;
999 } 1021 }
1000 1022
1001 virtual BailoutId ContinueId() const OVERRIDE { return EntryId(); } 1023 virtual BailoutId ContinueId() const OVERRIDE { return EntryId(); }
1002 virtual BailoutId StackCheckId() const OVERRIDE { return BackEdgeId(); } 1024 virtual BailoutId StackCheckId() const OVERRIDE { return BackEdgeId(); }
1003 1025
1004 BailoutId BackEdgeId() const { return back_edge_id_; } 1026 BailoutId BackEdgeId() const { return BailoutId(EntryId().ToInt() + 3); }
1005 1027
1006 protected: 1028 protected:
1007 ForOfStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos, 1029 ForOfStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos,
1008 IdGen* id_gen) 1030 IdGen* id_gen)
1009 : ForEachStatement(zone, labels, pos, id_gen), 1031 : ForEachStatement(zone, labels, pos, id_gen),
1010 assign_iterator_(NULL), 1032 assign_iterator_(NULL),
1011 next_result_(NULL), 1033 next_result_(NULL),
1012 result_done_(NULL), 1034 result_done_(NULL),
1013 assign_each_(NULL), 1035 assign_each_(NULL) {
1014 back_edge_id_(id_gen->GetNextId()) {} 1036 #ifdef DEBUG
1037 int back_edge_id =
1038 #endif
1039 id_gen->GetNextId(); // reserve back edge id
1040 DCHECK(back_edge_id == EntryId().ToInt() + 3);
1041 }
1015 1042
1016 Expression* assign_iterator_; 1043 Expression* assign_iterator_;
1017 Expression* next_result_; 1044 Expression* next_result_;
1018 Expression* result_done_; 1045 Expression* result_done_;
1019 Expression* assign_each_; 1046 Expression* assign_each_;
1020 const BailoutId back_edge_id_;
1021 }; 1047 };
1022 1048
1023 1049
1024 class ExpressionStatement FINAL : public Statement { 1050 class ExpressionStatement FINAL : public Statement {
1025 public: 1051 public:
1026 DECLARE_NODE_TYPE(ExpressionStatement) 1052 DECLARE_NODE_TYPE(ExpressionStatement)
1027 1053
1028 void set_expression(Expression* e) { expression_ = e; } 1054 void set_expression(Expression* e) { expression_ = e; }
1029 Expression* expression() const { return expression_; } 1055 Expression* expression() const { return expression_; }
1030 virtual bool IsJump() const OVERRIDE { return expression_->IsThrow(); } 1056 virtual bool IsJump() const OVERRIDE { return expression_->IsThrow(); }
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
1121 DECLARE_NODE_TYPE(CaseClause) 1147 DECLARE_NODE_TYPE(CaseClause)
1122 1148
1123 bool is_default() const { return label_ == NULL; } 1149 bool is_default() const { return label_ == NULL; }
1124 Expression* label() const { 1150 Expression* label() const {
1125 CHECK(!is_default()); 1151 CHECK(!is_default());
1126 return label_; 1152 return label_;
1127 } 1153 }
1128 Label* body_target() { return &body_target_; } 1154 Label* body_target() { return &body_target_; }
1129 ZoneList<Statement*>* statements() const { return statements_; } 1155 ZoneList<Statement*>* statements() const { return statements_; }
1130 1156
1131 BailoutId EntryId() const { return entry_id_; } 1157 BailoutId EntryId() const { return BailoutId(id().ToInt() + 3); }
1132 1158
1133 // Type feedback information. 1159 // Type feedback information.
1134 TypeFeedbackId CompareId() { return compare_id_; } 1160 TypeFeedbackId CompareId() { return TypeFeedbackId(id().ToInt() + 2); }
1135 Type* compare_type() { return compare_type_; } 1161 Type* compare_type() { return compare_type_; }
1136 void set_compare_type(Type* type) { compare_type_ = type; } 1162 void set_compare_type(Type* type) { compare_type_ = type; }
1137 1163
1138 private: 1164 private:
1139 CaseClause(Zone* zone, Expression* label, ZoneList<Statement*>* statements, 1165 CaseClause(Zone* zone, Expression* label, ZoneList<Statement*>* statements,
1140 int pos, IdGen* id_gen); 1166 int pos, IdGen* id_gen);
1141 1167
1142 Expression* label_; 1168 Expression* label_;
1143 Label body_target_; 1169 Label body_target_;
1144 ZoneList<Statement*>* statements_; 1170 ZoneList<Statement*>* statements_;
1145 Type* compare_type_; 1171 Type* compare_type_;
1146
1147 const TypeFeedbackId compare_id_;
1148 const BailoutId entry_id_;
1149 }; 1172 };
1150 1173
1151 1174
1152 class SwitchStatement FINAL : public BreakableStatement { 1175 class SwitchStatement FINAL : public BreakableStatement {
1153 public: 1176 public:
1154 DECLARE_NODE_TYPE(SwitchStatement) 1177 DECLARE_NODE_TYPE(SwitchStatement)
1155 1178
1156 void Initialize(Expression* tag, ZoneList<CaseClause*>* cases) { 1179 void Initialize(Expression* tag, ZoneList<CaseClause*>* cases) {
1157 tag_ = tag; 1180 tag_ = tag;
1158 cases_ = cases; 1181 cases_ = cases;
(...skipping 30 matching lines...) Expand all
1189 Expression* condition() const { return condition_; } 1212 Expression* condition() const { return condition_; }
1190 Statement* then_statement() const { return then_statement_; } 1213 Statement* then_statement() const { return then_statement_; }
1191 Statement* else_statement() const { return else_statement_; } 1214 Statement* else_statement() const { return else_statement_; }
1192 1215
1193 virtual bool IsJump() const OVERRIDE { 1216 virtual bool IsJump() const OVERRIDE {
1194 return HasThenStatement() && then_statement()->IsJump() 1217 return HasThenStatement() && then_statement()->IsJump()
1195 && HasElseStatement() && else_statement()->IsJump(); 1218 && HasElseStatement() && else_statement()->IsJump();
1196 } 1219 }
1197 1220
1198 BailoutId IfId() const { return if_id_; } 1221 BailoutId IfId() const { return if_id_; }
1199 BailoutId ThenId() const { return then_id_; } 1222 BailoutId ThenId() const { return BailoutId(if_id_.ToInt() + 1); }
1200 BailoutId ElseId() const { return else_id_; } 1223 BailoutId ElseId() const { return BailoutId(if_id_.ToInt() + 2); }
1201 1224
1202 protected: 1225 protected:
1203 IfStatement(Zone* zone, Expression* condition, Statement* then_statement, 1226 IfStatement(Zone* zone, Expression* condition, Statement* then_statement,
1204 Statement* else_statement, int pos, IdGen* id_gen) 1227 Statement* else_statement, int pos, IdGen* id_gen)
1205 : Statement(zone, pos), 1228 : Statement(zone, pos),
1206 condition_(condition), 1229 condition_(condition),
1207 then_statement_(then_statement), 1230 then_statement_(then_statement),
1208 else_statement_(else_statement), 1231 else_statement_(else_statement),
1209 if_id_(id_gen->GetNextId()), 1232 if_id_(id_gen->ReserveIdRange(3)) {} // Reserve if, then, else ids
1210 then_id_(id_gen->GetNextId()),
1211 else_id_(id_gen->GetNextId()) {}
1212 1233
1213 private: 1234 private:
1214 Expression* condition_; 1235 Expression* condition_;
1215 Statement* then_statement_; 1236 Statement* then_statement_;
1216 Statement* else_statement_; 1237 Statement* else_statement_;
1217 const BailoutId if_id_; 1238 const BailoutId if_id_;
1218 const BailoutId then_id_;
1219 const BailoutId else_id_;
1220 }; 1239 };
1221 1240
1222 1241
1223 // NOTE: TargetCollectors are represented as nodes to fit in the target 1242 // NOTE: TargetCollectors are represented as nodes to fit in the target
1224 // stack in the compiler; this should probably be reworked. 1243 // stack in the compiler; this should probably be reworked.
1225 class TargetCollector FINAL : public AstNode { 1244 class TargetCollector FINAL : public AstNode {
1226 public: 1245 public:
1227 explicit TargetCollector(Zone* zone) 1246 explicit TargetCollector(Zone* zone)
1228 : AstNode(RelocInfo::kNoPosition), targets_(0, zone) { } 1247 : AstNode(RelocInfo::kNoPosition), targets_(0, zone) { }
1229 1248
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after
1784 Handle<Cell> cell() { return cell_; } 1803 Handle<Cell> cell() { return cell_; }
1785 1804
1786 Handle<AllocationSite> allocation_site() { return allocation_site_; } 1805 Handle<AllocationSite> allocation_site() { return allocation_site_; }
1787 1806
1788 void set_target(Handle<JSFunction> target) { target_ = target; } 1807 void set_target(Handle<JSFunction> target) { target_ = target; }
1789 void set_allocation_site(Handle<AllocationSite> site) { 1808 void set_allocation_site(Handle<AllocationSite> site) {
1790 allocation_site_ = site; 1809 allocation_site_ = site;
1791 } 1810 }
1792 bool ComputeGlobalTarget(Handle<GlobalObject> global, LookupIterator* it); 1811 bool ComputeGlobalTarget(Handle<GlobalObject> global, LookupIterator* it);
1793 1812
1794 BailoutId ReturnId() const { return return_id_; } 1813 BailoutId ReturnId() const { return BailoutId(id().ToInt() + 2); }
1795 1814
1796 enum CallType { 1815 enum CallType {
1797 POSSIBLY_EVAL_CALL, 1816 POSSIBLY_EVAL_CALL,
1798 GLOBAL_CALL, 1817 GLOBAL_CALL,
1799 LOOKUP_SLOT_CALL, 1818 LOOKUP_SLOT_CALL,
1800 PROPERTY_CALL, 1819 PROPERTY_CALL,
1801 OTHER_CALL 1820 OTHER_CALL
1802 }; 1821 };
1803 1822
1804 // Helpers to determine how to handle the call. 1823 // Helpers to determine how to handle the call.
1805 CallType GetCallType(Isolate* isolate) const; 1824 CallType GetCallType(Isolate* isolate) const;
1806 bool IsUsingCallFeedbackSlot(Isolate* isolate) const; 1825 bool IsUsingCallFeedbackSlot(Isolate* isolate) const;
1807 1826
1808 #ifdef DEBUG 1827 #ifdef DEBUG
1809 // Used to assert that the FullCodeGenerator records the return site. 1828 // Used to assert that the FullCodeGenerator records the return site.
1810 bool return_is_recorded_; 1829 bool return_is_recorded_;
1811 #endif 1830 #endif
1812 1831
1813 protected: 1832 protected:
1814 Call(Zone* zone, Expression* expression, ZoneList<Expression*>* arguments, 1833 Call(Zone* zone, Expression* expression, ZoneList<Expression*>* arguments,
1815 int pos, IdGen* id_gen) 1834 int pos, IdGen* id_gen)
1816 : Expression(zone, pos, id_gen), 1835 : Expression(zone, pos, id_gen),
1817 expression_(expression), 1836 expression_(expression),
1818 arguments_(arguments), 1837 arguments_(arguments),
1819 call_feedback_slot_(kInvalidFeedbackSlot), 1838 call_feedback_slot_(kInvalidFeedbackSlot) {
1820 return_id_(id_gen->GetNextId()) { 1839 #ifdef DEBUG
1840 int return_id =
1841 #endif
1842 id_gen->GetNextId(); // Reserve return id
1843 DCHECK(return_id == id().ToInt() + 2);
1821 if (expression->IsProperty()) { 1844 if (expression->IsProperty()) {
1822 expression->AsProperty()->mark_for_call(); 1845 expression->AsProperty()->mark_for_call();
1823 } 1846 }
1824 } 1847 }
1825 1848
1826 private: 1849 private:
1827 Expression* expression_; 1850 Expression* expression_;
1828 ZoneList<Expression*>* arguments_; 1851 ZoneList<Expression*>* arguments_;
1829 1852
1830 Handle<JSFunction> target_; 1853 Handle<JSFunction> target_;
1831 Handle<Cell> cell_; 1854 Handle<Cell> cell_;
1832 Handle<AllocationSite> allocation_site_; 1855 Handle<AllocationSite> allocation_site_;
1833 int call_feedback_slot_; 1856 int call_feedback_slot_;
1834
1835 const BailoutId return_id_;
1836 }; 1857 };
1837 1858
1838 1859
1839 class CallNew FINAL : public Expression, public FeedbackSlotInterface { 1860 class CallNew FINAL : public Expression, public FeedbackSlotInterface {
1840 public: 1861 public:
1841 DECLARE_NODE_TYPE(CallNew) 1862 DECLARE_NODE_TYPE(CallNew)
1842 1863
1843 Expression* expression() const { return expression_; } 1864 Expression* expression() const { return expression_; }
1844 ZoneList<Expression*>* arguments() const { return arguments_; } 1865 ZoneList<Expression*>* arguments() const { return arguments_; }
1845 1866
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1945 }; 1966 };
1946 1967
1947 1968
1948 class UnaryOperation FINAL : public Expression { 1969 class UnaryOperation FINAL : public Expression {
1949 public: 1970 public:
1950 DECLARE_NODE_TYPE(UnaryOperation) 1971 DECLARE_NODE_TYPE(UnaryOperation)
1951 1972
1952 Token::Value op() const { return op_; } 1973 Token::Value op() const { return op_; }
1953 Expression* expression() const { return expression_; } 1974 Expression* expression() const { return expression_; }
1954 1975
1955 BailoutId MaterializeTrueId() { return materialize_true_id_; } 1976 // For unary not (Token::NOT), the AST ids where true and false will
1956 BailoutId MaterializeFalseId() { return materialize_false_id_; } 1977 // actually be materialized, respectively.
1978 BailoutId MaterializeTrueId() { return BailoutId(id().ToInt() + 2); }
1979 BailoutId MaterializeFalseId() { return BailoutId(id().ToInt() + 3); }
1957 1980
1958 virtual void RecordToBooleanTypeFeedback( 1981 virtual void RecordToBooleanTypeFeedback(
1959 TypeFeedbackOracle* oracle) OVERRIDE; 1982 TypeFeedbackOracle* oracle) OVERRIDE;
1960 1983
1961 protected: 1984 protected:
1962 UnaryOperation(Zone* zone, Token::Value op, Expression* expression, int pos, 1985 UnaryOperation(Zone* zone, Token::Value op, Expression* expression, int pos,
1963 IdGen* id_gen) 1986 IdGen* id_gen)
1964 : Expression(zone, pos, id_gen), 1987 : Expression(zone, pos, id_gen),
1965 op_(op), 1988 op_(op),
1966 expression_(expression), 1989 expression_(expression) {
1967 materialize_true_id_(id_gen->GetNextId()), 1990 // Reserve materialize true and false ids
1968 materialize_false_id_(id_gen->GetNextId()) { 1991 #ifdef DEBUG
1992 int materialize_true_id =
1993 #endif
1994 id_gen->ReserveIdRange(2);
1995 DCHECK(materialize_true_id == id().ToInt() + 2);
1969 DCHECK(Token::IsUnaryOp(op)); 1996 DCHECK(Token::IsUnaryOp(op));
1970 } 1997 }
1971 1998
1972 private: 1999 private:
1973 Token::Value op_; 2000 Token::Value op_;
1974 Expression* expression_; 2001 Expression* expression_;
1975
1976 // For unary not (Token::NOT), the AST ids where true and false will
1977 // actually be materialized, respectively.
1978 const BailoutId materialize_true_id_;
1979 const BailoutId materialize_false_id_;
1980 }; 2002 };
1981 2003
1982 2004
1983 class BinaryOperation FINAL : public Expression { 2005 class BinaryOperation FINAL : public Expression {
1984 public: 2006 public:
1985 DECLARE_NODE_TYPE(BinaryOperation) 2007 DECLARE_NODE_TYPE(BinaryOperation)
1986 2008
1987 virtual bool ResultOverwriteAllowed() const OVERRIDE; 2009 virtual bool ResultOverwriteAllowed() const OVERRIDE;
1988 2010
1989 Token::Value op() const { return op_; } 2011 Token::Value op() const { return op_; }
1990 Expression* left() const { return left_; } 2012 Expression* left() const { return left_; }
1991 Expression* right() const { return right_; } 2013 Expression* right() const { return right_; }
1992 Handle<AllocationSite> allocation_site() const { return allocation_site_; } 2014 Handle<AllocationSite> allocation_site() const { return allocation_site_; }
1993 void set_allocation_site(Handle<AllocationSite> allocation_site) { 2015 void set_allocation_site(Handle<AllocationSite> allocation_site) {
1994 allocation_site_ = allocation_site; 2016 allocation_site_ = allocation_site;
1995 } 2017 }
1996 2018
1997 BailoutId RightId() const { return right_id_; } 2019 // The short-circuit logical operations need an AST ID for their
2020 // right-hand subexpression.
2021 BailoutId RightId() const { return BailoutId(id().ToInt() + 2); }
1998 2022
1999 TypeFeedbackId BinaryOperationFeedbackId() const { return reuse(id()); } 2023 TypeFeedbackId BinaryOperationFeedbackId() const { return reuse(id()); }
2000 Maybe<int> fixed_right_arg() const { return fixed_right_arg_; } 2024 Maybe<int> fixed_right_arg() const { return fixed_right_arg_; }
2001 void set_fixed_right_arg(Maybe<int> arg) { fixed_right_arg_ = arg; } 2025 void set_fixed_right_arg(Maybe<int> arg) { fixed_right_arg_ = arg; }
2002 2026
2003 virtual void RecordToBooleanTypeFeedback( 2027 virtual void RecordToBooleanTypeFeedback(
2004 TypeFeedbackOracle* oracle) OVERRIDE; 2028 TypeFeedbackOracle* oracle) OVERRIDE;
2005 2029
2006 protected: 2030 protected:
2007 BinaryOperation(Zone* zone, Token::Value op, Expression* left, 2031 BinaryOperation(Zone* zone, Token::Value op, Expression* left,
2008 Expression* right, int pos, IdGen* id_gen) 2032 Expression* right, int pos, IdGen* id_gen)
2009 : Expression(zone, pos, id_gen), 2033 : Expression(zone, pos, id_gen),
2010 op_(op), 2034 op_(op),
2011 left_(left), 2035 left_(left),
2012 right_(right), 2036 right_(right) {
2013 right_id_(id_gen->GetNextId()) { 2037 #ifdef DEBUG
2038 int right_id =
2039 #endif
2040 id_gen->GetNextId(); // Reserve right id
2041 DCHECK(right_id == id().ToInt() + 2);
2014 DCHECK(Token::IsBinaryOp(op)); 2042 DCHECK(Token::IsBinaryOp(op));
2015 } 2043 }
2016 2044
2017 private: 2045 private:
2018 Token::Value op_; 2046 Token::Value op_;
2019 Expression* left_; 2047 Expression* left_;
2020 Expression* right_; 2048 Expression* right_;
2021 Handle<AllocationSite> allocation_site_; 2049 Handle<AllocationSite> allocation_site_;
2022 2050
2023 // TODO(rossberg): the fixed arg should probably be represented as a Constant 2051 // TODO(rossberg): the fixed arg should probably be represented as a Constant
2024 // type for the RHS. 2052 // type for the RHS.
2025 Maybe<int> fixed_right_arg_; 2053 Maybe<int> fixed_right_arg_;
2026
2027 // The short-circuit logical operations need an AST ID for their
2028 // right-hand subexpression.
2029 const BailoutId right_id_;
2030 }; 2054 };
2031 2055
2032 2056
2033 class CountOperation FINAL : public Expression { 2057 class CountOperation FINAL : public Expression {
2034 public: 2058 public:
2035 DECLARE_NODE_TYPE(CountOperation) 2059 DECLARE_NODE_TYPE(CountOperation)
2036 2060
2037 bool is_prefix() const { return is_prefix_; } 2061 bool is_prefix() const { return is_prefix_; }
2038 bool is_postfix() const { return !is_prefix_; } 2062 bool is_postfix() const { return !is_prefix_; }
2039 2063
(...skipping 10 matching lines...) Expand all
2050 virtual SmallMapList* GetReceiverTypes() OVERRIDE { 2074 virtual SmallMapList* GetReceiverTypes() OVERRIDE {
2051 return &receiver_types_; 2075 return &receiver_types_;
2052 } 2076 }
2053 virtual KeyedAccessStoreMode GetStoreMode() OVERRIDE { 2077 virtual KeyedAccessStoreMode GetStoreMode() OVERRIDE {
2054 return store_mode_; 2078 return store_mode_;
2055 } 2079 }
2056 Type* type() const { return type_; } 2080 Type* type() const { return type_; }
2057 void set_store_mode(KeyedAccessStoreMode mode) { store_mode_ = mode; } 2081 void set_store_mode(KeyedAccessStoreMode mode) { store_mode_ = mode; }
2058 void set_type(Type* type) { type_ = type; } 2082 void set_type(Type* type) { type_ = type; }
2059 2083
2060 BailoutId AssignmentId() const { return assignment_id_; } 2084 BailoutId AssignmentId() const { return BailoutId(id().ToInt() + 2); }
2061 2085
2062 TypeFeedbackId CountBinOpFeedbackId() const { return count_id_; } 2086 TypeFeedbackId CountBinOpFeedbackId() const {
2087 return TypeFeedbackId(id().ToInt() + 3);
2088 }
2063 TypeFeedbackId CountStoreFeedbackId() const { return reuse(id()); } 2089 TypeFeedbackId CountStoreFeedbackId() const { return reuse(id()); }
2064 2090
2065 protected: 2091 protected:
2066 CountOperation(Zone* zone, Token::Value op, bool is_prefix, Expression* expr, 2092 CountOperation(Zone* zone, Token::Value op, bool is_prefix, Expression* expr,
2067 int pos, IdGen* id_gen) 2093 int pos, IdGen* id_gen)
2068 : Expression(zone, pos, id_gen), 2094 : Expression(zone, pos, id_gen),
2069 op_(op), 2095 op_(op),
2070 is_prefix_(is_prefix), 2096 is_prefix_(is_prefix),
2071 store_mode_(STANDARD_STORE), 2097 store_mode_(STANDARD_STORE),
2072 expression_(expr), 2098 expression_(expr) {
2073 assignment_id_(id_gen->GetNextId()), 2099 // Reserve assignment and count ids
2074 count_id_(id_gen->GetNextId()) {} 2100 #ifdef DEBUG
2101 int assignment_id =
2102 #endif
2103 id_gen->ReserveIdRange(2);
2104 DCHECK(assignment_id == id().ToInt() + 2);
2105 }
2075 2106
2076 private: 2107 private:
2077 Token::Value op_; 2108 Token::Value op_;
2078 bool is_prefix_ : 1; 2109 bool is_prefix_ : 1;
2079 KeyedAccessStoreMode store_mode_ : 5; // Windows treats as signed, 2110 KeyedAccessStoreMode store_mode_ : 5; // Windows treats as signed,
2080 // must have extra bit. 2111 // must have extra bit.
2081 Type* type_; 2112 Type* type_;
2082 2113
2083 Expression* expression_; 2114 Expression* expression_;
2084 const BailoutId assignment_id_;
2085 const TypeFeedbackId count_id_;
2086 SmallMapList receiver_types_; 2115 SmallMapList receiver_types_;
2087 }; 2116 };
2088 2117
2089 2118
2090 class CompareOperation FINAL : public Expression { 2119 class CompareOperation FINAL : public Expression {
2091 public: 2120 public:
2092 DECLARE_NODE_TYPE(CompareOperation) 2121 DECLARE_NODE_TYPE(CompareOperation)
2093 2122
2094 Token::Value op() const { return op_; } 2123 Token::Value op() const { return op_; }
2095 Expression* left() const { return left_; } 2124 Expression* left() const { return left_; }
(...skipping 30 matching lines...) Expand all
2126 2155
2127 2156
2128 class Conditional FINAL : public Expression { 2157 class Conditional FINAL : public Expression {
2129 public: 2158 public:
2130 DECLARE_NODE_TYPE(Conditional) 2159 DECLARE_NODE_TYPE(Conditional)
2131 2160
2132 Expression* condition() const { return condition_; } 2161 Expression* condition() const { return condition_; }
2133 Expression* then_expression() const { return then_expression_; } 2162 Expression* then_expression() const { return then_expression_; }
2134 Expression* else_expression() const { return else_expression_; } 2163 Expression* else_expression() const { return else_expression_; }
2135 2164
2136 BailoutId ThenId() const { return then_id_; } 2165 BailoutId ThenId() const { return BailoutId(id().ToInt() + 2); }
2137 BailoutId ElseId() const { return else_id_; } 2166 BailoutId ElseId() const { return BailoutId(id().ToInt() + 3); }
2138 2167
2139 protected: 2168 protected:
2140 Conditional(Zone* zone, Expression* condition, Expression* then_expression, 2169 Conditional(Zone* zone, Expression* condition, Expression* then_expression,
2141 Expression* else_expression, int position, IdGen* id_gen) 2170 Expression* else_expression, int position, IdGen* id_gen)
2142 : Expression(zone, position, id_gen), 2171 : Expression(zone, position, id_gen),
2143 condition_(condition), 2172 condition_(condition),
2144 then_expression_(then_expression), 2173 then_expression_(then_expression),
2145 else_expression_(else_expression), 2174 else_expression_(else_expression) {
2146 then_id_(id_gen->GetNextId()), 2175 #ifdef DEBUG
2147 else_id_(id_gen->GetNextId()) {} 2176 int then_id =
2177 #endif
2178 id_gen->ReserveIdRange(2); // Reserve then and else ids
2179 DCHECK(then_id == id().ToInt() + 2);
2180 }
2148 2181
2149 private: 2182 private:
2150 Expression* condition_; 2183 Expression* condition_;
2151 Expression* then_expression_; 2184 Expression* then_expression_;
2152 Expression* else_expression_; 2185 Expression* else_expression_;
2153 const BailoutId then_id_;
2154 const BailoutId else_id_;
2155 }; 2186 };
2156 2187
2157 2188
2158 class Assignment FINAL : public Expression { 2189 class Assignment FINAL : public Expression {
2159 public: 2190 public:
2160 DECLARE_NODE_TYPE(Assignment) 2191 DECLARE_NODE_TYPE(Assignment)
2161 2192
2162 Assignment* AsSimpleAssignment() { return !is_compound() ? this : NULL; } 2193 Assignment* AsSimpleAssignment() { return !is_compound() ? this : NULL; }
2163 2194
2164 Token::Value binary_op() const; 2195 Token::Value binary_op() const;
2165 2196
2166 Token::Value op() const { return op_; } 2197 Token::Value op() const { return op_; }
2167 Expression* target() const { return target_; } 2198 Expression* target() const { return target_; }
2168 Expression* value() const { return value_; } 2199 Expression* value() const { return value_; }
2169 BinaryOperation* binary_operation() const { return binary_operation_; } 2200 BinaryOperation* binary_operation() const { return binary_operation_; }
2170 2201
2171 // This check relies on the definition order of token in token.h. 2202 // This check relies on the definition order of token in token.h.
2172 bool is_compound() const { return op() > Token::ASSIGN; } 2203 bool is_compound() const { return op() > Token::ASSIGN; }
2173 2204
2174 BailoutId AssignmentId() const { return assignment_id_; } 2205 BailoutId AssignmentId() const { return BailoutId(id().ToInt() + 2); }
2175 2206
2176 // Type feedback information. 2207 // Type feedback information.
2177 TypeFeedbackId AssignmentFeedbackId() { return reuse(id()); } 2208 TypeFeedbackId AssignmentFeedbackId() { return reuse(id()); }
2178 virtual bool IsMonomorphic() OVERRIDE { 2209 virtual bool IsMonomorphic() OVERRIDE {
2179 return receiver_types_.length() == 1; 2210 return receiver_types_.length() == 1;
2180 } 2211 }
2181 bool IsUninitialized() { return is_uninitialized_; } 2212 bool IsUninitialized() { return is_uninitialized_; }
2182 bool HasNoTypeInformation() { 2213 bool HasNoTypeInformation() {
2183 return is_uninitialized_; 2214 return is_uninitialized_;
2184 } 2215 }
(...skipping 17 matching lines...) Expand all
2202 binary_operation_ = factory->NewBinaryOperation( 2233 binary_operation_ = factory->NewBinaryOperation(
2203 binary_op(), target_, value_, position() + 1); 2234 binary_op(), target_, value_, position() + 1);
2204 } 2235 }
2205 } 2236 }
2206 2237
2207 private: 2238 private:
2208 Token::Value op_; 2239 Token::Value op_;
2209 Expression* target_; 2240 Expression* target_;
2210 Expression* value_; 2241 Expression* value_;
2211 BinaryOperation* binary_operation_; 2242 BinaryOperation* binary_operation_;
2212 const BailoutId assignment_id_;
2213 2243
2214 bool is_uninitialized_ : 1; 2244 bool is_uninitialized_ : 1;
2215 KeyedAccessStoreMode store_mode_ : 5; // Windows treats as signed, 2245 KeyedAccessStoreMode store_mode_ : 5; // Windows treats as signed,
2216 // must have extra bit. 2246 // must have extra bit.
2217 SmallMapList receiver_types_; 2247 SmallMapList receiver_types_;
2218 }; 2248 };
2219 2249
2220 2250
2221 class Yield FINAL : public Expression, public FeedbackSlotInterface { 2251 class Yield FINAL : public Expression, public FeedbackSlotInterface {
2222 public: 2252 public:
(...skipping 1256 matching lines...) Expand 10 before | Expand all | Expand 10 after
3479 Zone* zone_; 3509 Zone* zone_;
3480 Visitor visitor_; 3510 Visitor visitor_;
3481 AstValueFactory* ast_value_factory_; 3511 AstValueFactory* ast_value_factory_;
3482 AstNode::IdGen* id_gen_; 3512 AstNode::IdGen* id_gen_;
3483 }; 3513 };
3484 3514
3485 3515
3486 } } // namespace v8::internal 3516 } } // namespace v8::internal
3487 3517
3488 #endif // V8_AST_H_ 3518 #endif // V8_AST_H_
OLDNEW
« no previous file with comments | « no previous file | src/ast.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698