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

Side by Side Diff: src/ast.h

Issue 636403003: Assign bailout and type feedback IDs in a post-pass (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « BUILD.gn ('k') | src/ast.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 private: 192 private:
193 Flags flags_; 193 Flags flags_;
194 int node_count_; 194 int node_count_;
195 int feedback_slots_; 195 int feedback_slots_;
196 int ic_feedback_slots_; 196 int ic_feedback_slots_;
197 }; 197 };
198 198
199 199
200 class AstNode: public ZoneObject { 200 class AstNode: public ZoneObject {
201 public: 201 public:
202 // For generating IDs for AstNodes.
203 class IdGen {
204 public:
205 IdGen() : id_(BailoutId::FirstUsable().ToInt()) {}
206
207 int ReserveIdRange(int n) {
208 int tmp = id_;
209 id_ += n;
210 return tmp;
211 }
212
213 private:
214 int id_;
215
216 DISALLOW_COPY_AND_ASSIGN(IdGen);
217 };
218
219 #define DECLARE_TYPE_ENUM(type) k##type, 202 #define DECLARE_TYPE_ENUM(type) k##type,
220 enum NodeType { 203 enum NodeType {
221 AST_NODE_LIST(DECLARE_TYPE_ENUM) 204 AST_NODE_LIST(DECLARE_TYPE_ENUM)
222 kInvalid = -1 205 kInvalid = -1
223 }; 206 };
224 #undef DECLARE_TYPE_ENUM 207 #undef DECLARE_TYPE_ENUM
225 208
226 void* operator new(size_t size, Zone* zone) { 209 void* operator new(size_t size, Zone* zone) {
227 return zone->New(static_cast<int>(size)); 210 return zone->New(static_cast<int>(size));
228 } 211 }
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 } 381 }
399 virtual IcCheckType GetKeyType() { 382 virtual IcCheckType GetKeyType() {
400 UNREACHABLE(); 383 UNREACHABLE();
401 return ELEMENT; 384 return ELEMENT;
402 } 385 }
403 386
404 // TODO(rossberg): this should move to its own AST node eventually. 387 // TODO(rossberg): this should move to its own AST node eventually.
405 virtual void RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle); 388 virtual void RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle);
406 byte to_boolean_types() const { return to_boolean_types_; } 389 byte to_boolean_types() const { return to_boolean_types_; }
407 390
408 BailoutId id() const { return BailoutId(base_id() + 0); } 391 void set_base_id(int id) { base_id_ = id; }
409 TypeFeedbackId test_id() const { return TypeFeedbackId(base_id() + 1); } 392 static int num_ids() { return parent_num_ids() + 2; }
393 BailoutId id() const { return BailoutId(local_id(0)); }
394 TypeFeedbackId test_id() const { return TypeFeedbackId(local_id(1)); }
410 395
411 protected: 396 protected:
412 Expression(Zone* zone, int pos, int num_ids_needed_by_subclass, IdGen* id_gen) 397 Expression(Zone* zone, int pos)
413 : AstNode(pos), 398 : AstNode(pos),
414 base_id_( 399 base_id_(BailoutId::None().ToInt()),
415 id_gen->ReserveIdRange(num_ids_needed_by_subclass + num_ids())),
416 bounds_(Bounds::Unbounded(zone)), 400 bounds_(Bounds::Unbounded(zone)),
417 is_parenthesized_(false), 401 is_parenthesized_(false),
418 is_multi_parenthesized_(false) {} 402 is_multi_parenthesized_(false) {}
403 static int parent_num_ids() { return 0; }
419 void set_to_boolean_types(byte types) { to_boolean_types_ = types; } 404 void set_to_boolean_types(byte types) { to_boolean_types_ = types; }
420 405
421 static int num_ids() { return 2; } 406 int base_id() const {
422 int base_id() const { return base_id_; } 407 DCHECK(!BailoutId(base_id_).IsNone());
408 return base_id_;
409 }
423 410
424 private: 411 private:
425 const int base_id_; 412 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
413
414 int base_id_;
426 Bounds bounds_; 415 Bounds bounds_;
427 byte to_boolean_types_; 416 byte to_boolean_types_;
428 bool is_parenthesized_ : 1; 417 bool is_parenthesized_ : 1;
429 bool is_multi_parenthesized_ : 1; 418 bool is_multi_parenthesized_ : 1;
430 }; 419 };
431 420
432 421
433 class BreakableStatement : public Statement { 422 class BreakableStatement : public Statement {
434 public: 423 public:
435 enum BreakableType { 424 enum BreakableType {
(...skipping 11 matching lines...) Expand all
447 } 436 }
448 437
449 // Code generation 438 // Code generation
450 Label* break_target() { return &break_target_; } 439 Label* break_target() { return &break_target_; }
451 440
452 // Testers. 441 // Testers.
453 bool is_target_for_anonymous() const { 442 bool is_target_for_anonymous() const {
454 return breakable_type_ == TARGET_FOR_ANONYMOUS; 443 return breakable_type_ == TARGET_FOR_ANONYMOUS;
455 } 444 }
456 445
457 BailoutId EntryId() const { return BailoutId(base_id() + 0); } 446 void set_base_id(int id) { base_id_ = id; }
458 BailoutId ExitId() const { return BailoutId(base_id() + 1); } 447 static int num_ids() { return parent_num_ids() + 2; }
448 BailoutId EntryId() const { return BailoutId(local_id(0)); }
449 BailoutId ExitId() const { return BailoutId(local_id(1)); }
459 450
460 protected: 451 protected:
461 BreakableStatement(Zone* zone, ZoneList<const AstRawString*>* labels, 452 BreakableStatement(Zone* zone, ZoneList<const AstRawString*>* labels,
462 BreakableType breakable_type, int position, 453 BreakableType breakable_type, int position)
463 int num_ids_needed_by_subclass, IdGen* id_gen)
464 : Statement(zone, position), 454 : Statement(zone, position),
465 labels_(labels), 455 labels_(labels),
466 breakable_type_(breakable_type), 456 breakable_type_(breakable_type),
467 base_id_( 457 base_id_(BailoutId::None().ToInt()) {
468 id_gen->ReserveIdRange(num_ids_needed_by_subclass + num_ids())) {
469 DCHECK(labels == NULL || labels->length() > 0); 458 DCHECK(labels == NULL || labels->length() > 0);
470 } 459 }
460 static int parent_num_ids() { return 0; }
471 461
472 static int num_ids() { return 2; } 462 int base_id() const {
473 int base_id() const { return base_id_; } 463 DCHECK(!BailoutId(base_id_).IsNone());
464 return base_id_;
465 }
474 466
475 private: 467 private:
468 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
469
476 ZoneList<const AstRawString*>* labels_; 470 ZoneList<const AstRawString*>* labels_;
477 BreakableType breakable_type_; 471 BreakableType breakable_type_;
478 Label break_target_; 472 Label break_target_;
479 const int base_id_; 473 int base_id_;
480 }; 474 };
481 475
482 476
483 class Block FINAL : public BreakableStatement { 477 class Block FINAL : public BreakableStatement {
484 public: 478 public:
485 DECLARE_NODE_TYPE(Block) 479 DECLARE_NODE_TYPE(Block)
486 480
487 void AddStatement(Statement* statement, Zone* zone) { 481 void AddStatement(Statement* statement, Zone* zone) {
488 statements_.Add(statement, zone); 482 statements_.Add(statement, zone);
489 } 483 }
490 484
491 ZoneList<Statement*>* statements() { return &statements_; } 485 ZoneList<Statement*>* statements() { return &statements_; }
492 bool is_initializer_block() const { return is_initializer_block_; } 486 bool is_initializer_block() const { return is_initializer_block_; }
493 487
494 BailoutId DeclsId() const { return BailoutId(base_id() + 0); } 488 static int num_ids() { return parent_num_ids() + 1; }
489 BailoutId DeclsId() const { return BailoutId(local_id(0)); }
495 490
496 virtual bool IsJump() const OVERRIDE { 491 virtual bool IsJump() const OVERRIDE {
497 return !statements_.is_empty() && statements_.last()->IsJump() 492 return !statements_.is_empty() && statements_.last()->IsJump()
498 && labels() == NULL; // Good enough as an approximation... 493 && labels() == NULL; // Good enough as an approximation...
499 } 494 }
500 495
501 Scope* scope() const { return scope_; } 496 Scope* scope() const { return scope_; }
502 void set_scope(Scope* scope) { scope_ = scope; } 497 void set_scope(Scope* scope) { scope_ = scope; }
503 498
504 protected: 499 protected:
505 Block(Zone* zone, ZoneList<const AstRawString*>* labels, int capacity, 500 Block(Zone* zone, ZoneList<const AstRawString*>* labels, int capacity,
506 bool is_initializer_block, int pos, IdGen* id_gen) 501 bool is_initializer_block, int pos)
507 : BreakableStatement(zone, labels, TARGET_FOR_NAMED_ONLY, pos, num_ids(), 502 : BreakableStatement(zone, labels, TARGET_FOR_NAMED_ONLY, pos),
508 id_gen),
509 statements_(capacity, zone), 503 statements_(capacity, zone),
510 is_initializer_block_(is_initializer_block), 504 is_initializer_block_(is_initializer_block),
511 scope_(NULL) {} 505 scope_(NULL) {}
512 506 static int parent_num_ids() { return BreakableStatement::num_ids(); }
513 static int num_ids() { return 1; }
514 int base_id() const {
515 return BreakableStatement::base_id() + BreakableStatement::num_ids();
516 }
517 507
518 private: 508 private:
509 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
510
519 ZoneList<Statement*> statements_; 511 ZoneList<Statement*> statements_;
520 bool is_initializer_block_; 512 bool is_initializer_block_;
521 Scope* scope_; 513 Scope* scope_;
522 }; 514 };
523 515
524 516
525 class Declaration : public AstNode { 517 class Declaration : public AstNode {
526 public: 518 public:
527 VariableProxy* proxy() const { return proxy_; } 519 VariableProxy* proxy() const { return proxy_; }
528 VariableMode mode() const { return mode_; } 520 VariableMode mode() const { return mode_; }
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 748
757 class IterationStatement : public BreakableStatement { 749 class IterationStatement : public BreakableStatement {
758 public: 750 public:
759 // Type testing & conversion. 751 // Type testing & conversion.
760 virtual IterationStatement* AsIterationStatement() FINAL OVERRIDE { 752 virtual IterationStatement* AsIterationStatement() FINAL OVERRIDE {
761 return this; 753 return this;
762 } 754 }
763 755
764 Statement* body() const { return body_; } 756 Statement* body() const { return body_; }
765 757
766 BailoutId OsrEntryId() const { return BailoutId(base_id() + 0); } 758 static int num_ids() { return parent_num_ids() + 1; }
759 BailoutId OsrEntryId() const { return BailoutId(local_id(0)); }
767 virtual BailoutId ContinueId() const = 0; 760 virtual BailoutId ContinueId() const = 0;
768 virtual BailoutId StackCheckId() const = 0; 761 virtual BailoutId StackCheckId() const = 0;
769 762
770 // Code generation 763 // Code generation
771 Label* continue_target() { return &continue_target_; } 764 Label* continue_target() { return &continue_target_; }
772 765
773 protected: 766 protected:
774 IterationStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos, 767 IterationStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos)
775 int num_ids_needed_by_subclass, IdGen* id_gen) 768 : BreakableStatement(zone, labels, TARGET_FOR_ANONYMOUS, pos),
776 : BreakableStatement(zone, labels, TARGET_FOR_ANONYMOUS, pos,
777 num_ids_needed_by_subclass + num_ids(), id_gen),
778 body_(NULL) {} 769 body_(NULL) {}
779 770 static int parent_num_ids() { return BreakableStatement::num_ids(); }
780 void Initialize(Statement* body) { 771 void Initialize(Statement* body) { body_ = body; }
781 body_ = body;
782 }
783
784 static int num_ids() { return 1; }
785 int base_id() const {
786 return BreakableStatement::base_id() + BreakableStatement::num_ids();
787 }
788 772
789 private: 773 private:
774 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
775
790 Statement* body_; 776 Statement* body_;
791 Label continue_target_; 777 Label continue_target_;
792 }; 778 };
793 779
794 780
795 class DoWhileStatement FINAL : public IterationStatement { 781 class DoWhileStatement FINAL : public IterationStatement {
796 public: 782 public:
797 DECLARE_NODE_TYPE(DoWhileStatement) 783 DECLARE_NODE_TYPE(DoWhileStatement)
798 784
799 void Initialize(Expression* cond, Statement* body) { 785 void Initialize(Expression* cond, Statement* body) {
800 IterationStatement::Initialize(body); 786 IterationStatement::Initialize(body);
801 cond_ = cond; 787 cond_ = cond;
802 } 788 }
803 789
804 Expression* cond() const { return cond_; } 790 Expression* cond() const { return cond_; }
805 791
792 static int num_ids() { return parent_num_ids() + 2; }
806 virtual BailoutId ContinueId() const OVERRIDE { 793 virtual BailoutId ContinueId() const OVERRIDE {
807 return BailoutId(base_id() + 0); 794 return BailoutId(local_id(0));
808 } 795 }
809 virtual BailoutId StackCheckId() const OVERRIDE { return BackEdgeId(); } 796 virtual BailoutId StackCheckId() const OVERRIDE { return BackEdgeId(); }
810 BailoutId BackEdgeId() const { return BailoutId(base_id() + 1); } 797 BailoutId BackEdgeId() const { return BailoutId(local_id(1)); }
811 798
812 protected: 799 protected:
813 DoWhileStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos, 800 DoWhileStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos)
814 IdGen* id_gen) 801 : IterationStatement(zone, labels, pos), cond_(NULL) {}
815 : IterationStatement(zone, labels, pos, num_ids(), id_gen), cond_(NULL) {} 802 static int parent_num_ids() { return IterationStatement::num_ids(); }
816
817 static int num_ids() { return 2; }
818 int base_id() const {
819 return IterationStatement::base_id() + IterationStatement::num_ids();
820 }
821 803
822 private: 804 private:
805 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
806
823 Expression* cond_; 807 Expression* cond_;
824 }; 808 };
825 809
826 810
827 class WhileStatement FINAL : public IterationStatement { 811 class WhileStatement FINAL : public IterationStatement {
828 public: 812 public:
829 DECLARE_NODE_TYPE(WhileStatement) 813 DECLARE_NODE_TYPE(WhileStatement)
830 814
831 void Initialize(Expression* cond, Statement* body) { 815 void Initialize(Expression* cond, Statement* body) {
832 IterationStatement::Initialize(body); 816 IterationStatement::Initialize(body);
833 cond_ = cond; 817 cond_ = cond;
834 } 818 }
835 819
836 Expression* cond() const { return cond_; } 820 Expression* cond() const { return cond_; }
837 bool may_have_function_literal() const { 821 bool may_have_function_literal() const {
838 return may_have_function_literal_; 822 return may_have_function_literal_;
839 } 823 }
840 void set_may_have_function_literal(bool value) { 824 void set_may_have_function_literal(bool value) {
841 may_have_function_literal_ = value; 825 may_have_function_literal_ = value;
842 } 826 }
843 827
828 static int num_ids() { return parent_num_ids() + 1; }
844 virtual BailoutId ContinueId() const OVERRIDE { return EntryId(); } 829 virtual BailoutId ContinueId() const OVERRIDE { return EntryId(); }
845 virtual BailoutId StackCheckId() const OVERRIDE { return BodyId(); } 830 virtual BailoutId StackCheckId() const OVERRIDE { return BodyId(); }
846 BailoutId BodyId() const { return BailoutId(base_id() + 0); } 831 BailoutId BodyId() const { return BailoutId(local_id(0)); }
847 832
848 protected: 833 protected:
849 WhileStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos, 834 WhileStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos)
850 IdGen* id_gen) 835 : IterationStatement(zone, labels, pos),
851 : IterationStatement(zone, labels, pos, num_ids(), id_gen),
852 cond_(NULL), 836 cond_(NULL),
853 may_have_function_literal_(true) {} 837 may_have_function_literal_(true) {}
854 838 static int parent_num_ids() { return IterationStatement::num_ids(); }
855 static int num_ids() { return 1; }
856 int base_id() const {
857 return IterationStatement::base_id() + IterationStatement::num_ids();
858 }
859 839
860 private: 840 private:
841 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
842
861 Expression* cond_; 843 Expression* cond_;
862 844
863 // True if there is a function literal subexpression in the condition. 845 // True if there is a function literal subexpression in the condition.
864 bool may_have_function_literal_; 846 bool may_have_function_literal_;
865 }; 847 };
866 848
867 849
868 class ForStatement FINAL : public IterationStatement { 850 class ForStatement FINAL : public IterationStatement {
869 public: 851 public:
870 DECLARE_NODE_TYPE(ForStatement) 852 DECLARE_NODE_TYPE(ForStatement)
(...skipping 12 matching lines...) Expand all
883 Expression* cond() const { return cond_; } 865 Expression* cond() const { return cond_; }
884 Statement* next() const { return next_; } 866 Statement* next() const { return next_; }
885 867
886 bool may_have_function_literal() const { 868 bool may_have_function_literal() const {
887 return may_have_function_literal_; 869 return may_have_function_literal_;
888 } 870 }
889 void set_may_have_function_literal(bool value) { 871 void set_may_have_function_literal(bool value) {
890 may_have_function_literal_ = value; 872 may_have_function_literal_ = value;
891 } 873 }
892 874
875 static int num_ids() { return parent_num_ids() + 2; }
893 virtual BailoutId ContinueId() const OVERRIDE { 876 virtual BailoutId ContinueId() const OVERRIDE {
894 return BailoutId(base_id() + 0); 877 return BailoutId(local_id(0));
895 } 878 }
896 virtual BailoutId StackCheckId() const OVERRIDE { return BodyId(); } 879 virtual BailoutId StackCheckId() const OVERRIDE { return BodyId(); }
897 BailoutId BodyId() const { return BailoutId(base_id() + 1); } 880 BailoutId BodyId() const { return BailoutId(local_id(1)); }
898 881
899 bool is_fast_smi_loop() { return loop_variable_ != NULL; } 882 bool is_fast_smi_loop() { return loop_variable_ != NULL; }
900 Variable* loop_variable() { return loop_variable_; } 883 Variable* loop_variable() { return loop_variable_; }
901 void set_loop_variable(Variable* var) { loop_variable_ = var; } 884 void set_loop_variable(Variable* var) { loop_variable_ = var; }
902 885
903 protected: 886 protected:
904 ForStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos, 887 ForStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos)
905 IdGen* id_gen) 888 : IterationStatement(zone, labels, pos),
906 : IterationStatement(zone, labels, pos, num_ids(), id_gen),
907 init_(NULL), 889 init_(NULL),
908 cond_(NULL), 890 cond_(NULL),
909 next_(NULL), 891 next_(NULL),
910 may_have_function_literal_(true), 892 may_have_function_literal_(true),
911 loop_variable_(NULL) {} 893 loop_variable_(NULL) {}
912 894 static int parent_num_ids() { return IterationStatement::num_ids(); }
913 static int num_ids() { return 2; }
914 int base_id() const {
915 return IterationStatement::base_id() + IterationStatement::num_ids();
916 }
917 895
918 private: 896 private:
897 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
898
919 Statement* init_; 899 Statement* init_;
920 Expression* cond_; 900 Expression* cond_;
921 Statement* next_; 901 Statement* next_;
922 902
923 // True if there is a function literal subexpression in the condition. 903 // True if there is a function literal subexpression in the condition.
924 bool may_have_function_literal_; 904 bool may_have_function_literal_;
925 Variable* loop_variable_; 905 Variable* loop_variable_;
926 }; 906 };
927 907
928 908
929 class ForEachStatement : public IterationStatement { 909 class ForEachStatement : public IterationStatement {
930 public: 910 public:
931 enum VisitMode { 911 enum VisitMode {
932 ENUMERATE, // for (each in subject) body; 912 ENUMERATE, // for (each in subject) body;
933 ITERATE // for (each of subject) body; 913 ITERATE // for (each of subject) body;
934 }; 914 };
935 915
936 void Initialize(Expression* each, Expression* subject, Statement* body) { 916 void Initialize(Expression* each, Expression* subject, Statement* body) {
937 IterationStatement::Initialize(body); 917 IterationStatement::Initialize(body);
938 each_ = each; 918 each_ = each;
939 subject_ = subject; 919 subject_ = subject;
940 } 920 }
941 921
942 Expression* each() const { return each_; } 922 Expression* each() const { return each_; }
943 Expression* subject() const { return subject_; } 923 Expression* subject() const { return subject_; }
944 924
945 protected: 925 protected:
946 ForEachStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos, 926 ForEachStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos)
947 int num_ids_needed_by_subclass, IdGen* id_gen) 927 : IterationStatement(zone, labels, pos), each_(NULL), subject_(NULL) {}
948 : IterationStatement(zone, labels, pos, num_ids_needed_by_subclass,
949 id_gen),
950 each_(NULL),
951 subject_(NULL) {}
952 928
953 private: 929 private:
954 Expression* each_; 930 Expression* each_;
955 Expression* subject_; 931 Expression* subject_;
956 }; 932 };
957 933
958 934
959 class ForInStatement FINAL : public ForEachStatement { 935 class ForInStatement FINAL : public ForEachStatement {
960 public: 936 public:
961 DECLARE_NODE_TYPE(ForInStatement) 937 DECLARE_NODE_TYPE(ForInStatement)
(...skipping 12 matching lines...) Expand all
974 950
975 FeedbackVectorSlot ForInFeedbackSlot() { 951 FeedbackVectorSlot ForInFeedbackSlot() {
976 DCHECK(!for_in_feedback_slot_.IsInvalid()); 952 DCHECK(!for_in_feedback_slot_.IsInvalid());
977 return for_in_feedback_slot_; 953 return for_in_feedback_slot_;
978 } 954 }
979 955
980 enum ForInType { FAST_FOR_IN, SLOW_FOR_IN }; 956 enum ForInType { FAST_FOR_IN, SLOW_FOR_IN };
981 ForInType for_in_type() const { return for_in_type_; } 957 ForInType for_in_type() const { return for_in_type_; }
982 void set_for_in_type(ForInType type) { for_in_type_ = type; } 958 void set_for_in_type(ForInType type) { for_in_type_ = type; }
983 959
984 BailoutId BodyId() const { return BailoutId(base_id() + 0); } 960 static int num_ids() { return parent_num_ids() + 2; }
985 BailoutId PrepareId() const { return BailoutId(base_id() + 1); } 961 BailoutId BodyId() const { return BailoutId(local_id(0)); }
962 BailoutId PrepareId() const { return BailoutId(local_id(1)); }
986 virtual BailoutId ContinueId() const OVERRIDE { return EntryId(); } 963 virtual BailoutId ContinueId() const OVERRIDE { return EntryId(); }
987 virtual BailoutId StackCheckId() const OVERRIDE { return BodyId(); } 964 virtual BailoutId StackCheckId() const OVERRIDE { return BodyId(); }
988 965
989 protected: 966 protected:
990 ForInStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos, 967 ForInStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos)
991 IdGen* id_gen) 968 : ForEachStatement(zone, labels, pos),
992 : ForEachStatement(zone, labels, pos, num_ids(), id_gen),
993 for_in_type_(SLOW_FOR_IN), 969 for_in_type_(SLOW_FOR_IN),
994 for_in_feedback_slot_(FeedbackVectorSlot::Invalid()) {} 970 for_in_feedback_slot_(FeedbackVectorSlot::Invalid()) {}
995 971 static int parent_num_ids() { return ForEachStatement::num_ids(); }
996 static int num_ids() { return 2; }
997 int base_id() const {
998 return ForEachStatement::base_id() + ForEachStatement::num_ids();
999 }
1000 972
1001 private: 973 private:
974 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
975
1002 ForInType for_in_type_; 976 ForInType for_in_type_;
1003 FeedbackVectorSlot for_in_feedback_slot_; 977 FeedbackVectorSlot for_in_feedback_slot_;
1004 }; 978 };
1005 979
1006 980
1007 class ForOfStatement FINAL : public ForEachStatement { 981 class ForOfStatement FINAL : public ForEachStatement {
1008 public: 982 public:
1009 DECLARE_NODE_TYPE(ForOfStatement) 983 DECLARE_NODE_TYPE(ForOfStatement)
1010 984
1011 void Initialize(Expression* each, 985 void Initialize(Expression* each,
(...skipping 30 matching lines...) Expand all
1042 } 1016 }
1043 1017
1044 // each = result.value 1018 // each = result.value
1045 Expression* assign_each() const { 1019 Expression* assign_each() const {
1046 return assign_each_; 1020 return assign_each_;
1047 } 1021 }
1048 1022
1049 virtual BailoutId ContinueId() const OVERRIDE { return EntryId(); } 1023 virtual BailoutId ContinueId() const OVERRIDE { return EntryId(); }
1050 virtual BailoutId StackCheckId() const OVERRIDE { return BackEdgeId(); } 1024 virtual BailoutId StackCheckId() const OVERRIDE { return BackEdgeId(); }
1051 1025
1052 BailoutId BackEdgeId() const { return BailoutId(base_id() + 0); } 1026 static int num_ids() { return parent_num_ids() + 1; }
1027 BailoutId BackEdgeId() const { return BailoutId(local_id(0)); }
1053 1028
1054 protected: 1029 protected:
1055 ForOfStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos, 1030 ForOfStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos)
1056 IdGen* id_gen) 1031 : ForEachStatement(zone, labels, pos),
1057 : ForEachStatement(zone, labels, pos, num_ids(), id_gen),
1058 assign_iterator_(NULL), 1032 assign_iterator_(NULL),
1059 next_result_(NULL), 1033 next_result_(NULL),
1060 result_done_(NULL), 1034 result_done_(NULL),
1061 assign_each_(NULL) {} 1035 assign_each_(NULL) {}
1062 1036 static int parent_num_ids() { return ForEachStatement::num_ids(); }
1063 static int num_ids() { return 1; }
1064 int base_id() const {
1065 return ForEachStatement::base_id() + ForEachStatement::num_ids();
1066 }
1067 1037
1068 private: 1038 private:
1039 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
1040
1069 Expression* assign_iterator_; 1041 Expression* assign_iterator_;
1070 Expression* next_result_; 1042 Expression* next_result_;
1071 Expression* result_done_; 1043 Expression* result_done_;
1072 Expression* assign_each_; 1044 Expression* assign_each_;
1073 }; 1045 };
1074 1046
1075 1047
1076 class ExpressionStatement FINAL : public Statement { 1048 class ExpressionStatement FINAL : public Statement {
1077 public: 1049 public:
1078 DECLARE_NODE_TYPE(ExpressionStatement) 1050 DECLARE_NODE_TYPE(ExpressionStatement)
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
1173 DECLARE_NODE_TYPE(CaseClause) 1145 DECLARE_NODE_TYPE(CaseClause)
1174 1146
1175 bool is_default() const { return label_ == NULL; } 1147 bool is_default() const { return label_ == NULL; }
1176 Expression* label() const { 1148 Expression* label() const {
1177 CHECK(!is_default()); 1149 CHECK(!is_default());
1178 return label_; 1150 return label_;
1179 } 1151 }
1180 Label* body_target() { return &body_target_; } 1152 Label* body_target() { return &body_target_; }
1181 ZoneList<Statement*>* statements() const { return statements_; } 1153 ZoneList<Statement*>* statements() const { return statements_; }
1182 1154
1183 BailoutId EntryId() const { return BailoutId(base_id() + 0); } 1155 static int num_ids() { return parent_num_ids() + 2; }
1184 TypeFeedbackId CompareId() { return TypeFeedbackId(base_id() + 1); } 1156 BailoutId EntryId() const { return BailoutId(local_id(0)); }
1157 TypeFeedbackId CompareId() { return TypeFeedbackId(local_id(1)); }
1185 1158
1186 Type* compare_type() { return compare_type_; } 1159 Type* compare_type() { return compare_type_; }
1187 void set_compare_type(Type* type) { compare_type_ = type; } 1160 void set_compare_type(Type* type) { compare_type_ = type; }
1188 1161
1162 protected:
1163 static int parent_num_ids() { return Expression::num_ids(); }
1164
1189 private: 1165 private:
1190 CaseClause(Zone* zone, Expression* label, ZoneList<Statement*>* statements, 1166 CaseClause(Zone* zone, Expression* label, ZoneList<Statement*>* statements,
1191 int pos, IdGen* id_gen); 1167 int pos);
1192 1168 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
1193 static int num_ids() { return 2; }
1194 int base_id() const { return Expression::base_id() + Expression::num_ids(); }
1195 1169
1196 Expression* label_; 1170 Expression* label_;
1197 Label body_target_; 1171 Label body_target_;
1198 ZoneList<Statement*>* statements_; 1172 ZoneList<Statement*>* statements_;
1199 Type* compare_type_; 1173 Type* compare_type_;
1200 }; 1174 };
1201 1175
1202 1176
1203 class SwitchStatement FINAL : public BreakableStatement { 1177 class SwitchStatement FINAL : public BreakableStatement {
1204 public: 1178 public:
1205 DECLARE_NODE_TYPE(SwitchStatement) 1179 DECLARE_NODE_TYPE(SwitchStatement)
1206 1180
1207 void Initialize(Expression* tag, ZoneList<CaseClause*>* cases) { 1181 void Initialize(Expression* tag, ZoneList<CaseClause*>* cases) {
1208 tag_ = tag; 1182 tag_ = tag;
1209 cases_ = cases; 1183 cases_ = cases;
1210 } 1184 }
1211 1185
1212 Expression* tag() const { return tag_; } 1186 Expression* tag() const { return tag_; }
1213 ZoneList<CaseClause*>* cases() const { return cases_; } 1187 ZoneList<CaseClause*>* cases() const { return cases_; }
1214 1188
1215 protected: 1189 protected:
1216 SwitchStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos, 1190 SwitchStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos)
1217 IdGen* id_gen) 1191 : BreakableStatement(zone, labels, TARGET_FOR_ANONYMOUS, pos),
1218 : BreakableStatement(zone, labels, TARGET_FOR_ANONYMOUS, pos, 0, id_gen),
1219 tag_(NULL), 1192 tag_(NULL),
1220 cases_(NULL) {} 1193 cases_(NULL) {}
1221 1194
1222 private: 1195 private:
1223 Expression* tag_; 1196 Expression* tag_;
1224 ZoneList<CaseClause*>* cases_; 1197 ZoneList<CaseClause*>* cases_;
1225 }; 1198 };
1226 1199
1227 1200
1228 // If-statements always have non-null references to their then- and 1201 // If-statements always have non-null references to their then- and
(...skipping 10 matching lines...) Expand all
1239 1212
1240 Expression* condition() const { return condition_; } 1213 Expression* condition() const { return condition_; }
1241 Statement* then_statement() const { return then_statement_; } 1214 Statement* then_statement() const { return then_statement_; }
1242 Statement* else_statement() const { return else_statement_; } 1215 Statement* else_statement() const { return else_statement_; }
1243 1216
1244 virtual bool IsJump() const OVERRIDE { 1217 virtual bool IsJump() const OVERRIDE {
1245 return HasThenStatement() && then_statement()->IsJump() 1218 return HasThenStatement() && then_statement()->IsJump()
1246 && HasElseStatement() && else_statement()->IsJump(); 1219 && HasElseStatement() && else_statement()->IsJump();
1247 } 1220 }
1248 1221
1249 BailoutId IfId() const { return BailoutId(base_id() + 0); } 1222 void set_base_id(int id) { base_id_ = id; }
1250 BailoutId ThenId() const { return BailoutId(base_id() + 1); } 1223 static int num_ids() { return parent_num_ids() + 3; }
1251 BailoutId ElseId() const { return BailoutId(base_id() + 2); } 1224 BailoutId IfId() const { return BailoutId(local_id(0)); }
1225 BailoutId ThenId() const { return BailoutId(local_id(1)); }
1226 BailoutId ElseId() const { return BailoutId(local_id(2)); }
1252 1227
1253 protected: 1228 protected:
1254 IfStatement(Zone* zone, Expression* condition, Statement* then_statement, 1229 IfStatement(Zone* zone, Expression* condition, Statement* then_statement,
1255 Statement* else_statement, int pos, IdGen* id_gen) 1230 Statement* else_statement, int pos)
1256 : Statement(zone, pos), 1231 : Statement(zone, pos),
1257 condition_(condition), 1232 condition_(condition),
1258 then_statement_(then_statement), 1233 then_statement_(then_statement),
1259 else_statement_(else_statement), 1234 else_statement_(else_statement),
1260 base_id_(id_gen->ReserveIdRange(num_ids())) {} 1235 base_id_(BailoutId::None().ToInt()) {}
1236 static int parent_num_ids() { return 0; }
1261 1237
1262 static int num_ids() { return 3; } 1238 int base_id() const {
1263 int base_id() const { return base_id_; } 1239 DCHECK(!BailoutId(base_id_).IsNone());
1240 return base_id_;
1241 }
1264 1242
1265 private: 1243 private:
1244 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
1245
1266 Expression* condition_; 1246 Expression* condition_;
1267 Statement* then_statement_; 1247 Statement* then_statement_;
1268 Statement* else_statement_; 1248 Statement* else_statement_;
1269 const int base_id_; 1249 int base_id_;
1270 }; 1250 };
1271 1251
1272 1252
1273 // NOTE: TargetCollectors are represented as nodes to fit in the target 1253 // NOTE: TargetCollectors are represented as nodes to fit in the target
1274 // stack in the compiler; this should probably be reworked. 1254 // stack in the compiler; this should probably be reworked.
1275 class TargetCollector FINAL : public AstNode { 1255 class TargetCollector FINAL : public AstNode {
1276 public: 1256 public:
1277 explicit TargetCollector(Zone* zone) 1257 explicit TargetCollector(Zone* zone)
1278 : AstNode(RelocInfo::kNoPosition), targets_(0, zone) { } 1258 : AstNode(RelocInfo::kNoPosition), targets_(0, zone) { }
1279 1259
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1363 1343
1364 private: 1344 private:
1365 Block* finally_block_; 1345 Block* finally_block_;
1366 }; 1346 };
1367 1347
1368 1348
1369 class DebuggerStatement FINAL : public Statement { 1349 class DebuggerStatement FINAL : public Statement {
1370 public: 1350 public:
1371 DECLARE_NODE_TYPE(DebuggerStatement) 1351 DECLARE_NODE_TYPE(DebuggerStatement)
1372 1352
1373 BailoutId DebugBreakId() const { return BailoutId(base_id() + 0); } 1353 void set_base_id(int id) { base_id_ = id; }
1354 static int num_ids() { return parent_num_ids() + 1; }
1355 BailoutId DebugBreakId() const { return BailoutId(local_id(0)); }
1374 1356
1375 protected: 1357 protected:
1376 explicit DebuggerStatement(Zone* zone, int pos, IdGen* id_gen) 1358 explicit DebuggerStatement(Zone* zone, int pos)
1377 : Statement(zone, pos), base_id_(id_gen->ReserveIdRange(num_ids())) {} 1359 : Statement(zone, pos), base_id_(BailoutId::None().ToInt()) {}
1360 static int parent_num_ids() { return 0; }
1378 1361
1379 static int num_ids() { return 1; } 1362 int base_id() const {
1380 int base_id() const { return base_id_; } 1363 DCHECK(!BailoutId(base_id_).IsNone());
1364 return base_id_;
1365 }
1381 1366
1382 private: 1367 private:
1383 const int base_id_; 1368 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
1369
1370 int base_id_;
1384 }; 1371 };
1385 1372
1386 1373
1387 class EmptyStatement FINAL : public Statement { 1374 class EmptyStatement FINAL : public Statement {
1388 public: 1375 public:
1389 DECLARE_NODE_TYPE(EmptyStatement) 1376 DECLARE_NODE_TYPE(EmptyStatement)
1390 1377
1391 protected: 1378 protected:
1392 explicit EmptyStatement(Zone* zone, int pos): Statement(zone, pos) {} 1379 explicit EmptyStatement(Zone* zone, int pos): Statement(zone, pos) {}
1393 }; 1380 };
(...skipping 25 matching lines...) Expand all
1419 } 1406 }
1420 1407
1421 Handle<Object> value() const { return value_->value(); } 1408 Handle<Object> value() const { return value_->value(); }
1422 const AstValue* raw_value() const { return value_; } 1409 const AstValue* raw_value() const { return value_; }
1423 1410
1424 // Support for using Literal as a HashMap key. NOTE: Currently, this works 1411 // Support for using Literal as a HashMap key. NOTE: Currently, this works
1425 // only for string and number literals! 1412 // only for string and number literals!
1426 uint32_t Hash(); 1413 uint32_t Hash();
1427 static bool Match(void* literal1, void* literal2); 1414 static bool Match(void* literal1, void* literal2);
1428 1415
1416 static int num_ids() { return parent_num_ids() + 1; }
1429 TypeFeedbackId LiteralFeedbackId() const { 1417 TypeFeedbackId LiteralFeedbackId() const {
1430 return TypeFeedbackId(base_id() + 0); 1418 return TypeFeedbackId(local_id(0));
1431 } 1419 }
1432 1420
1433 protected: 1421 protected:
1434 Literal(Zone* zone, const AstValue* value, int position, IdGen* id_gen) 1422 Literal(Zone* zone, const AstValue* value, int position)
1435 : Expression(zone, position, num_ids(), id_gen), value_(value) {} 1423 : Expression(zone, position), value_(value) {}
1436 1424 static int parent_num_ids() { return Expression::num_ids(); }
1437 static int num_ids() { return 1; }
1438 int base_id() const { return Expression::base_id() + Expression::num_ids(); }
1439 1425
1440 private: 1426 private:
1427 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
1428
1441 const AstValue* value_; 1429 const AstValue* value_;
1442 }; 1430 };
1443 1431
1444 1432
1445 // Base class for literals that needs space in the corresponding JSFunction. 1433 // Base class for literals that needs space in the corresponding JSFunction.
1446 class MaterializedLiteral : public Expression { 1434 class MaterializedLiteral : public Expression {
1447 public: 1435 public:
1448 virtual MaterializedLiteral* AsMaterializedLiteral() { return this; } 1436 virtual MaterializedLiteral* AsMaterializedLiteral() { return this; }
1449 1437
1450 int literal_index() { return literal_index_; } 1438 int literal_index() { return literal_index_; }
1451 1439
1452 int depth() const { 1440 int depth() const {
1453 // only callable after initialization. 1441 // only callable after initialization.
1454 DCHECK(depth_ >= 1); 1442 DCHECK(depth_ >= 1);
1455 return depth_; 1443 return depth_;
1456 } 1444 }
1457 1445
1458 protected: 1446 protected:
1459 MaterializedLiteral(Zone* zone, int literal_index, int pos, 1447 MaterializedLiteral(Zone* zone, int literal_index, int pos)
1460 int num_ids_needed_by_subclass, IdGen* id_gen) 1448 : Expression(zone, pos),
1461 : Expression(zone, pos, num_ids_needed_by_subclass, id_gen),
1462 literal_index_(literal_index), 1449 literal_index_(literal_index),
1463 is_simple_(false), 1450 is_simple_(false),
1464 depth_(0) {} 1451 depth_(0) {}
1465 1452
1466 // A materialized literal is simple if the values consist of only 1453 // A materialized literal is simple if the values consist of only
1467 // constants and simple object and array literals. 1454 // constants and simple object and array literals.
1468 bool is_simple() const { return is_simple_; } 1455 bool is_simple() const { return is_simple_; }
1469 void set_is_simple(bool is_simple) { is_simple_ = is_simple; } 1456 void set_is_simple(bool is_simple) { is_simple_ = is_simple; }
1470 friend class CompileTimeValue; 1457 friend class CompileTimeValue;
1471 1458
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
1581 }; 1568 };
1582 1569
1583 struct Accessors: public ZoneObject { 1570 struct Accessors: public ZoneObject {
1584 Accessors() : getter(NULL), setter(NULL) { } 1571 Accessors() : getter(NULL), setter(NULL) { }
1585 Expression* getter; 1572 Expression* getter;
1586 Expression* setter; 1573 Expression* setter;
1587 }; 1574 };
1588 1575
1589 protected: 1576 protected:
1590 ObjectLiteral(Zone* zone, ZoneList<Property*>* properties, int literal_index, 1577 ObjectLiteral(Zone* zone, ZoneList<Property*>* properties, int literal_index,
1591 int boilerplate_properties, bool has_function, int pos, 1578 int boilerplate_properties, bool has_function, int pos)
1592 IdGen* id_gen) 1579 : MaterializedLiteral(zone, literal_index, pos),
1593 : MaterializedLiteral(zone, literal_index, pos, 0, id_gen),
1594 properties_(properties), 1580 properties_(properties),
1595 boilerplate_properties_(boilerplate_properties), 1581 boilerplate_properties_(boilerplate_properties),
1596 fast_elements_(false), 1582 fast_elements_(false),
1597 may_store_doubles_(false), 1583 may_store_doubles_(false),
1598 has_function_(has_function) {} 1584 has_function_(has_function) {}
1599 1585
1600 private: 1586 private:
1601 Handle<FixedArray> constant_properties_; 1587 Handle<FixedArray> constant_properties_;
1602 ZoneList<Property*>* properties_; 1588 ZoneList<Property*>* properties_;
1603 int boilerplate_properties_; 1589 int boilerplate_properties_;
1604 bool fast_elements_; 1590 bool fast_elements_;
1605 bool may_store_doubles_; 1591 bool may_store_doubles_;
1606 bool has_function_; 1592 bool has_function_;
1607 }; 1593 };
1608 1594
1609 1595
1610 // Node for capturing a regexp literal. 1596 // Node for capturing a regexp literal.
1611 class RegExpLiteral FINAL : public MaterializedLiteral { 1597 class RegExpLiteral FINAL : public MaterializedLiteral {
1612 public: 1598 public:
1613 DECLARE_NODE_TYPE(RegExpLiteral) 1599 DECLARE_NODE_TYPE(RegExpLiteral)
1614 1600
1615 Handle<String> pattern() const { return pattern_->string(); } 1601 Handle<String> pattern() const { return pattern_->string(); }
1616 Handle<String> flags() const { return flags_->string(); } 1602 Handle<String> flags() const { return flags_->string(); }
1617 1603
1618 protected: 1604 protected:
1619 RegExpLiteral(Zone* zone, const AstRawString* pattern, 1605 RegExpLiteral(Zone* zone, const AstRawString* pattern,
1620 const AstRawString* flags, int literal_index, int pos, 1606 const AstRawString* flags, int literal_index, int pos)
1621 IdGen* id_gen) 1607 : MaterializedLiteral(zone, literal_index, pos),
1622 : MaterializedLiteral(zone, literal_index, pos, 0, id_gen),
1623 pattern_(pattern), 1608 pattern_(pattern),
1624 flags_(flags) { 1609 flags_(flags) {
1625 set_depth(1); 1610 set_depth(1);
1626 } 1611 }
1627 1612
1628 private: 1613 private:
1629 const AstRawString* pattern_; 1614 const AstRawString* pattern_;
1630 const AstRawString* flags_; 1615 const AstRawString* flags_;
1631 }; 1616 };
1632 1617
1633 1618
1634 // An array literal has a literals object that is used 1619 // An array literal has a literals object that is used
1635 // for minimizing the work when constructing it at runtime. 1620 // for minimizing the work when constructing it at runtime.
1636 class ArrayLiteral FINAL : public MaterializedLiteral { 1621 class ArrayLiteral FINAL : public MaterializedLiteral {
1637 public: 1622 public:
1638 DECLARE_NODE_TYPE(ArrayLiteral) 1623 DECLARE_NODE_TYPE(ArrayLiteral)
1639 1624
1640 Handle<FixedArray> constant_elements() const { return constant_elements_; } 1625 Handle<FixedArray> constant_elements() const { return constant_elements_; }
1641 ZoneList<Expression*>* values() const { return values_; } 1626 ZoneList<Expression*>* values() const { return values_; }
1642 1627
1628 // Unlike other AST nodes, this number of bailout IDs allocated for an
1629 // ArrayLiteral can vary, so num_ids() is not a static method.
1630 int num_ids() const { return parent_num_ids() + values()->length(); }
1631
1643 // Return an AST id for an element that is used in simulate instructions. 1632 // Return an AST id for an element that is used in simulate instructions.
1644 BailoutId GetIdForElement(int i) { return BailoutId(base_id() + i); } 1633 BailoutId GetIdForElement(int i) { return BailoutId(local_id(i)); }
1645 1634
1646 // Populate the constant elements fixed array. 1635 // Populate the constant elements fixed array.
1647 void BuildConstantElements(Isolate* isolate); 1636 void BuildConstantElements(Isolate* isolate);
1648 1637
1649 // Assemble bitfield of flags for the CreateArrayLiteral helper. 1638 // Assemble bitfield of flags for the CreateArrayLiteral helper.
1650 int ComputeFlags() const { 1639 int ComputeFlags() const {
1651 int flags = depth() == 1 ? kShallowElements : kNoFlags; 1640 int flags = depth() == 1 ? kShallowElements : kNoFlags;
1652 flags |= ArrayLiteral::kDisableMementos; 1641 flags |= ArrayLiteral::kDisableMementos;
1653 return flags; 1642 return flags;
1654 } 1643 }
1655 1644
1656 enum Flags { 1645 enum Flags {
1657 kNoFlags = 0, 1646 kNoFlags = 0,
1658 kShallowElements = 1, 1647 kShallowElements = 1,
1659 kDisableMementos = 1 << 1 1648 kDisableMementos = 1 << 1
1660 }; 1649 };
1661 1650
1662 protected: 1651 protected:
1663 ArrayLiteral(Zone* zone, ZoneList<Expression*>* values, int literal_index, 1652 ArrayLiteral(Zone* zone, ZoneList<Expression*>* values, int literal_index,
1664 int pos, IdGen* id_gen) 1653 int pos)
1665 : MaterializedLiteral(zone, literal_index, pos, num_ids(values), id_gen), 1654 : MaterializedLiteral(zone, literal_index, pos), values_(values) {}
1666 values_(values) {} 1655 static int parent_num_ids() { return MaterializedLiteral::num_ids(); }
1667
1668 static int num_ids(ZoneList<Expression*>* values) { return values->length(); }
1669 int base_id() const {
1670 return MaterializedLiteral::base_id() + MaterializedLiteral::num_ids();
1671 }
1672 1656
1673 private: 1657 private:
1658 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
1659
1674 Handle<FixedArray> constant_elements_; 1660 Handle<FixedArray> constant_elements_;
1675 ZoneList<Expression*>* values_; 1661 ZoneList<Expression*>* values_;
1676 }; 1662 };
1677 1663
1678 1664
1679 class VariableProxy FINAL : public Expression { 1665 class VariableProxy FINAL : public Expression {
1680 public: 1666 public:
1681 DECLARE_NODE_TYPE(VariableProxy) 1667 DECLARE_NODE_TYPE(VariableProxy)
1682 1668
1683 virtual bool IsValidReferenceExpression() const OVERRIDE { 1669 virtual bool IsValidReferenceExpression() const OVERRIDE {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1719 } 1705 }
1720 virtual void SetFirstICFeedbackSlot(FeedbackVectorICSlot slot) { 1706 virtual void SetFirstICFeedbackSlot(FeedbackVectorICSlot slot) {
1721 variable_feedback_slot_ = slot; 1707 variable_feedback_slot_ = slot;
1722 } 1708 }
1723 1709
1724 FeedbackVectorICSlot VariableFeedbackSlot() { 1710 FeedbackVectorICSlot VariableFeedbackSlot() {
1725 return variable_feedback_slot_; 1711 return variable_feedback_slot_;
1726 } 1712 }
1727 1713
1728 protected: 1714 protected:
1729 VariableProxy(Zone* zone, Variable* var, int position, IdGen* id_gen); 1715 VariableProxy(Zone* zone, Variable* var, int position);
1730 1716
1731 VariableProxy(Zone* zone, const AstRawString* name, bool is_this, 1717 VariableProxy(Zone* zone, const AstRawString* name, bool is_this,
1732 Interface* interface, int position, IdGen* id_gen); 1718 Interface* interface, int position);
1733 1719
1734 bool is_this_ : 1; 1720 bool is_this_ : 1;
1735 bool is_assigned_ : 1; 1721 bool is_assigned_ : 1;
1736 bool is_resolved_ : 1; 1722 bool is_resolved_ : 1;
1737 FeedbackVectorICSlot variable_feedback_slot_; 1723 FeedbackVectorICSlot variable_feedback_slot_;
1738 union { 1724 union {
1739 const AstRawString* raw_name_; // if !is_resolved_ 1725 const AstRawString* raw_name_; // if !is_resolved_
1740 Variable* var_; // if is_resolved_ 1726 Variable* var_; // if is_resolved_
1741 }; 1727 };
1742 Interface* interface_; 1728 Interface* interface_;
1743 }; 1729 };
1744 1730
1745 1731
1746 class Property FINAL : public Expression { 1732 class Property FINAL : public Expression {
1747 public: 1733 public:
1748 DECLARE_NODE_TYPE(Property) 1734 DECLARE_NODE_TYPE(Property)
1749 1735
1750 virtual bool IsValidReferenceExpression() const OVERRIDE { return true; } 1736 virtual bool IsValidReferenceExpression() const OVERRIDE { return true; }
1751 1737
1752 Expression* obj() const { return obj_; } 1738 Expression* obj() const { return obj_; }
1753 Expression* key() const { return key_; } 1739 Expression* key() const { return key_; }
1754 1740
1755 BailoutId LoadId() const { return BailoutId(base_id() + 0); } 1741 static int num_ids() { return parent_num_ids() + 2; }
1756 TypeFeedbackId PropertyFeedbackId() { return TypeFeedbackId(base_id() + 1); } 1742 BailoutId LoadId() const { return BailoutId(local_id(0)); }
1757 1743 TypeFeedbackId PropertyFeedbackId() { return TypeFeedbackId(local_id(1)); }
1758 1744
1759 bool IsStringAccess() const { return is_string_access_; } 1745 bool IsStringAccess() const { return is_string_access_; }
1760 1746
1761 // Type feedback information. 1747 // Type feedback information.
1762 virtual bool IsMonomorphic() OVERRIDE { 1748 virtual bool IsMonomorphic() OVERRIDE {
1763 return receiver_types_.length() == 1; 1749 return receiver_types_.length() == 1;
1764 } 1750 }
1765 virtual SmallMapList* GetReceiverTypes() OVERRIDE { 1751 virtual SmallMapList* GetReceiverTypes() OVERRIDE {
1766 return &receiver_types_; 1752 return &receiver_types_;
1767 } 1753 }
(...skipping 22 matching lines...) Expand all
1790 } 1776 }
1791 virtual void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot) { 1777 virtual void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot) {
1792 property_feedback_slot_ = slot; 1778 property_feedback_slot_ = slot;
1793 } 1779 }
1794 1780
1795 FeedbackVectorICSlot PropertyFeedbackSlot() const { 1781 FeedbackVectorICSlot PropertyFeedbackSlot() const {
1796 return property_feedback_slot_; 1782 return property_feedback_slot_;
1797 } 1783 }
1798 1784
1799 protected: 1785 protected:
1800 Property(Zone* zone, Expression* obj, Expression* key, int pos, IdGen* id_gen) 1786 Property(Zone* zone, Expression* obj, Expression* key, int pos)
1801 : Expression(zone, pos, num_ids(), id_gen), 1787 : Expression(zone, pos),
1802 is_for_call_(false), 1788 is_for_call_(false),
1803 is_uninitialized_(false), 1789 is_uninitialized_(false),
1804 is_string_access_(false), 1790 is_string_access_(false),
1805 property_feedback_slot_(FeedbackVectorICSlot::Invalid()), 1791 property_feedback_slot_(FeedbackVectorICSlot::Invalid()),
1806 obj_(obj), 1792 obj_(obj),
1807 key_(key) {} 1793 key_(key) {}
1808 1794 static int parent_num_ids() { return Expression::num_ids(); }
1809 static int num_ids() { return 2; }
1810 int base_id() const { return Expression::base_id() + Expression::num_ids(); }
1811 1795
1812 private: 1796 private:
1797 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
1798
1813 bool is_for_call_ : 1; 1799 bool is_for_call_ : 1;
1814 bool is_uninitialized_ : 1; 1800 bool is_uninitialized_ : 1;
1815 bool is_string_access_ : 1; 1801 bool is_string_access_ : 1;
1816 FeedbackVectorICSlot property_feedback_slot_; 1802 FeedbackVectorICSlot property_feedback_slot_;
1817 Expression* obj_; 1803 Expression* obj_;
1818 Expression* key_; 1804 Expression* key_;
1819 SmallMapList receiver_types_; 1805 SmallMapList receiver_types_;
1820 }; 1806 };
1821 1807
1822 1808
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1866 Handle<Cell> cell() { return cell_; } 1852 Handle<Cell> cell() { return cell_; }
1867 1853
1868 Handle<AllocationSite> allocation_site() { return allocation_site_; } 1854 Handle<AllocationSite> allocation_site() { return allocation_site_; }
1869 1855
1870 void set_target(Handle<JSFunction> target) { target_ = target; } 1856 void set_target(Handle<JSFunction> target) { target_ = target; }
1871 void set_allocation_site(Handle<AllocationSite> site) { 1857 void set_allocation_site(Handle<AllocationSite> site) {
1872 allocation_site_ = site; 1858 allocation_site_ = site;
1873 } 1859 }
1874 bool ComputeGlobalTarget(Handle<GlobalObject> global, LookupIterator* it); 1860 bool ComputeGlobalTarget(Handle<GlobalObject> global, LookupIterator* it);
1875 1861
1876 BailoutId ReturnId() const { return BailoutId(base_id() + 0); } 1862 static int num_ids() { return parent_num_ids() + 2; }
1877 BailoutId EvalOrLookupId() const { return BailoutId(base_id() + 1); } 1863 BailoutId ReturnId() const { return BailoutId(local_id(0)); }
1864 BailoutId EvalOrLookupId() const { return BailoutId(local_id(1)); }
1878 1865
1879 enum CallType { 1866 enum CallType {
1880 POSSIBLY_EVAL_CALL, 1867 POSSIBLY_EVAL_CALL,
1881 GLOBAL_CALL, 1868 GLOBAL_CALL,
1882 LOOKUP_SLOT_CALL, 1869 LOOKUP_SLOT_CALL,
1883 PROPERTY_CALL, 1870 PROPERTY_CALL,
1884 SUPER_CALL, 1871 SUPER_CALL,
1885 OTHER_CALL 1872 OTHER_CALL
1886 }; 1873 };
1887 1874
1888 // Helpers to determine how to handle the call. 1875 // Helpers to determine how to handle the call.
1889 CallType GetCallType(Isolate* isolate) const; 1876 CallType GetCallType(Isolate* isolate) const;
1890 bool IsUsingCallFeedbackSlot(Isolate* isolate) const; 1877 bool IsUsingCallFeedbackSlot(Isolate* isolate) const;
1891 1878
1892 #ifdef DEBUG 1879 #ifdef DEBUG
1893 // Used to assert that the FullCodeGenerator records the return site. 1880 // Used to assert that the FullCodeGenerator records the return site.
1894 bool return_is_recorded_; 1881 bool return_is_recorded_;
1895 #endif 1882 #endif
1896 1883
1897 protected: 1884 protected:
1898 Call(Zone* zone, Expression* expression, ZoneList<Expression*>* arguments, 1885 Call(Zone* zone, Expression* expression, ZoneList<Expression*>* arguments,
1899 int pos, IdGen* id_gen) 1886 int pos)
1900 : Expression(zone, pos, num_ids(), id_gen), 1887 : Expression(zone, pos),
1901 call_feedback_slot_(FeedbackVectorICSlot::Invalid()), 1888 call_feedback_slot_(FeedbackVectorICSlot::Invalid()),
1902 expression_(expression), 1889 expression_(expression),
1903 arguments_(arguments) { 1890 arguments_(arguments) {
1904 if (expression->IsProperty()) { 1891 if (expression->IsProperty()) {
1905 expression->AsProperty()->mark_for_call(); 1892 expression->AsProperty()->mark_for_call();
1906 } 1893 }
1907 } 1894 }
1908 1895 static int parent_num_ids() { return Expression::num_ids(); }
1909 static int num_ids() { return 2; }
1910 int base_id() const { return Expression::base_id() + Expression::num_ids(); }
1911 1896
1912 private: 1897 private:
1898 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
1899
1913 FeedbackVectorICSlot call_feedback_slot_; 1900 FeedbackVectorICSlot call_feedback_slot_;
1914 Expression* expression_; 1901 Expression* expression_;
1915 ZoneList<Expression*>* arguments_; 1902 ZoneList<Expression*>* arguments_;
1916 Handle<JSFunction> target_; 1903 Handle<JSFunction> target_;
1917 Handle<Cell> cell_; 1904 Handle<Cell> cell_;
1918 Handle<AllocationSite> allocation_site_; 1905 Handle<AllocationSite> allocation_site_;
1919 }; 1906 };
1920 1907
1921 1908
1922 class CallNew FINAL : public Expression { 1909 class CallNew FINAL : public Expression {
(...skipping 17 matching lines...) Expand all
1940 return CallNewFeedbackSlot().next(); 1927 return CallNewFeedbackSlot().next();
1941 } 1928 }
1942 1929
1943 void RecordTypeFeedback(TypeFeedbackOracle* oracle); 1930 void RecordTypeFeedback(TypeFeedbackOracle* oracle);
1944 virtual bool IsMonomorphic() OVERRIDE { return is_monomorphic_; } 1931 virtual bool IsMonomorphic() OVERRIDE { return is_monomorphic_; }
1945 Handle<JSFunction> target() const { return target_; } 1932 Handle<JSFunction> target() const { return target_; }
1946 Handle<AllocationSite> allocation_site() const { 1933 Handle<AllocationSite> allocation_site() const {
1947 return allocation_site_; 1934 return allocation_site_;
1948 } 1935 }
1949 1936
1937 static int num_ids() { return parent_num_ids() + 1; }
1950 static int feedback_slots() { return 1; } 1938 static int feedback_slots() { return 1; }
1951 1939 BailoutId ReturnId() const { return BailoutId(local_id(0)); }
1952 BailoutId ReturnId() const { return BailoutId(base_id() + 0); }
1953 1940
1954 protected: 1941 protected:
1955 CallNew(Zone* zone, Expression* expression, ZoneList<Expression*>* arguments, 1942 CallNew(Zone* zone, Expression* expression, ZoneList<Expression*>* arguments,
1956 int pos, IdGen* id_gen) 1943 int pos)
1957 : Expression(zone, pos, num_ids(), id_gen), 1944 : Expression(zone, pos),
1958 expression_(expression), 1945 expression_(expression),
1959 arguments_(arguments), 1946 arguments_(arguments),
1960 is_monomorphic_(false), 1947 is_monomorphic_(false),
1961 callnew_feedback_slot_(FeedbackVectorSlot::Invalid()) {} 1948 callnew_feedback_slot_(FeedbackVectorSlot::Invalid()) {}
1962 1949
1963 static int num_ids() { return 1; } 1950 static int parent_num_ids() { return Expression::num_ids(); }
1964 int base_id() const { return Expression::base_id() + Expression::num_ids(); }
1965 1951
1966 private: 1952 private:
1953 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
1954
1967 Expression* expression_; 1955 Expression* expression_;
1968 ZoneList<Expression*>* arguments_; 1956 ZoneList<Expression*>* arguments_;
1969 bool is_monomorphic_; 1957 bool is_monomorphic_;
1970 Handle<JSFunction> target_; 1958 Handle<JSFunction> target_;
1971 Handle<AllocationSite> allocation_site_; 1959 Handle<AllocationSite> allocation_site_;
1972 FeedbackVectorSlot callnew_feedback_slot_; 1960 FeedbackVectorSlot callnew_feedback_slot_;
1973 }; 1961 };
1974 1962
1975 1963
1976 // The CallRuntime class does not represent any official JavaScript 1964 // The CallRuntime class does not represent any official JavaScript
(...skipping 16 matching lines...) Expand all
1993 0, (FLAG_vector_ics && is_jsruntime()) ? 1 : 0); 1981 0, (FLAG_vector_ics && is_jsruntime()) ? 1 : 0);
1994 } 1982 }
1995 virtual void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot) { 1983 virtual void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot) {
1996 callruntime_feedback_slot_ = slot; 1984 callruntime_feedback_slot_ = slot;
1997 } 1985 }
1998 1986
1999 FeedbackVectorICSlot CallRuntimeFeedbackSlot() { 1987 FeedbackVectorICSlot CallRuntimeFeedbackSlot() {
2000 return callruntime_feedback_slot_; 1988 return callruntime_feedback_slot_;
2001 } 1989 }
2002 1990
1991 static int num_ids() { return parent_num_ids() + 1; }
2003 TypeFeedbackId CallRuntimeFeedbackId() const { 1992 TypeFeedbackId CallRuntimeFeedbackId() const {
2004 return TypeFeedbackId(base_id() + 0); 1993 return TypeFeedbackId(local_id(0));
2005 } 1994 }
2006 1995
2007 protected: 1996 protected:
2008 CallRuntime(Zone* zone, const AstRawString* name, 1997 CallRuntime(Zone* zone, const AstRawString* name,
2009 const Runtime::Function* function, 1998 const Runtime::Function* function,
2010 ZoneList<Expression*>* arguments, int pos, IdGen* id_gen) 1999 ZoneList<Expression*>* arguments, int pos)
2011 : Expression(zone, pos, num_ids(), id_gen), 2000 : Expression(zone, pos),
2012 raw_name_(name), 2001 raw_name_(name),
2013 function_(function), 2002 function_(function),
2014 arguments_(arguments), 2003 arguments_(arguments),
2015 callruntime_feedback_slot_(FeedbackVectorICSlot::Invalid()) {} 2004 callruntime_feedback_slot_(FeedbackVectorICSlot::Invalid()) {}
2016 2005 static int parent_num_ids() { return Expression::num_ids(); }
2017 static int num_ids() { return 1; }
2018 int base_id() const { return Expression::base_id() + Expression::num_ids(); }
2019 2006
2020 private: 2007 private:
2008 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
2009
2021 const AstRawString* raw_name_; 2010 const AstRawString* raw_name_;
2022 const Runtime::Function* function_; 2011 const Runtime::Function* function_;
2023 ZoneList<Expression*>* arguments_; 2012 ZoneList<Expression*>* arguments_;
2024 FeedbackVectorICSlot callruntime_feedback_slot_; 2013 FeedbackVectorICSlot callruntime_feedback_slot_;
2025 }; 2014 };
2026 2015
2027 2016
2028 class UnaryOperation FINAL : public Expression { 2017 class UnaryOperation FINAL : public Expression {
2029 public: 2018 public:
2030 DECLARE_NODE_TYPE(UnaryOperation) 2019 DECLARE_NODE_TYPE(UnaryOperation)
2031 2020
2032 Token::Value op() const { return op_; } 2021 Token::Value op() const { return op_; }
2033 Expression* expression() const { return expression_; } 2022 Expression* expression() const { return expression_; }
2034 2023
2035 // For unary not (Token::NOT), the AST ids where true and false will 2024 // For unary not (Token::NOT), the AST ids where true and false will
2036 // actually be materialized, respectively. 2025 // actually be materialized, respectively.
2037 BailoutId MaterializeTrueId() const { return BailoutId(base_id() + 0); } 2026 static int num_ids() { return parent_num_ids() + 2; }
2038 BailoutId MaterializeFalseId() const { return BailoutId(base_id() + 1); } 2027 BailoutId MaterializeTrueId() const { return BailoutId(local_id(0)); }
2028 BailoutId MaterializeFalseId() const { return BailoutId(local_id(1)); }
2039 2029
2040 virtual void RecordToBooleanTypeFeedback( 2030 virtual void RecordToBooleanTypeFeedback(
2041 TypeFeedbackOracle* oracle) OVERRIDE; 2031 TypeFeedbackOracle* oracle) OVERRIDE;
2042 2032
2043 protected: 2033 protected:
2044 UnaryOperation(Zone* zone, Token::Value op, Expression* expression, int pos, 2034 UnaryOperation(Zone* zone, Token::Value op, Expression* expression, int pos)
2045 IdGen* id_gen) 2035 : Expression(zone, pos), op_(op), expression_(expression) {
2046 : Expression(zone, pos, num_ids(), id_gen),
2047 op_(op),
2048 expression_(expression) {
2049 DCHECK(Token::IsUnaryOp(op)); 2036 DCHECK(Token::IsUnaryOp(op));
2050 } 2037 }
2051 2038 static int parent_num_ids() { return Expression::num_ids(); }
2052 static int num_ids() { return 2; }
2053 int base_id() const { return Expression::base_id() + Expression::num_ids(); }
2054 2039
2055 private: 2040 private:
2041 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
2042
2056 Token::Value op_; 2043 Token::Value op_;
2057 Expression* expression_; 2044 Expression* expression_;
2058 }; 2045 };
2059 2046
2060 2047
2061 class BinaryOperation FINAL : public Expression { 2048 class BinaryOperation FINAL : public Expression {
2062 public: 2049 public:
2063 DECLARE_NODE_TYPE(BinaryOperation) 2050 DECLARE_NODE_TYPE(BinaryOperation)
2064 2051
2065 virtual bool ResultOverwriteAllowed() const OVERRIDE; 2052 virtual bool ResultOverwriteAllowed() const OVERRIDE;
2066 2053
2067 Token::Value op() const { return static_cast<Token::Value>(op_); } 2054 Token::Value op() const { return static_cast<Token::Value>(op_); }
2068 Expression* left() const { return left_; } 2055 Expression* left() const { return left_; }
2069 Expression* right() const { return right_; } 2056 Expression* right() const { return right_; }
2070 Handle<AllocationSite> allocation_site() const { return allocation_site_; } 2057 Handle<AllocationSite> allocation_site() const { return allocation_site_; }
2071 void set_allocation_site(Handle<AllocationSite> allocation_site) { 2058 void set_allocation_site(Handle<AllocationSite> allocation_site) {
2072 allocation_site_ = allocation_site; 2059 allocation_site_ = allocation_site;
2073 } 2060 }
2074 2061
2075 // The short-circuit logical operations need an AST ID for their 2062 // The short-circuit logical operations need an AST ID for their
2076 // right-hand subexpression. 2063 // right-hand subexpression.
2077 BailoutId RightId() const { return BailoutId(base_id() + 0); } 2064 static int num_ids() { return parent_num_ids() + 2; }
2065 BailoutId RightId() const { return BailoutId(local_id(0)); }
2078 2066
2079 TypeFeedbackId BinaryOperationFeedbackId() const { 2067 TypeFeedbackId BinaryOperationFeedbackId() const {
2080 return TypeFeedbackId(base_id() + 1); 2068 return TypeFeedbackId(local_id(1));
2081 } 2069 }
2082 Maybe<int> fixed_right_arg() const { 2070 Maybe<int> fixed_right_arg() const {
2083 return has_fixed_right_arg_ ? Maybe<int>(fixed_right_arg_value_) 2071 return has_fixed_right_arg_ ? Maybe<int>(fixed_right_arg_value_)
2084 : Maybe<int>(); 2072 : Maybe<int>();
2085 } 2073 }
2086 void set_fixed_right_arg(Maybe<int> arg) { 2074 void set_fixed_right_arg(Maybe<int> arg) {
2087 has_fixed_right_arg_ = arg.has_value; 2075 has_fixed_right_arg_ = arg.has_value;
2088 if (arg.has_value) fixed_right_arg_value_ = arg.value; 2076 if (arg.has_value) fixed_right_arg_value_ = arg.value;
2089 } 2077 }
2090 2078
2091 virtual void RecordToBooleanTypeFeedback( 2079 virtual void RecordToBooleanTypeFeedback(
2092 TypeFeedbackOracle* oracle) OVERRIDE; 2080 TypeFeedbackOracle* oracle) OVERRIDE;
2093 2081
2094 protected: 2082 protected:
2095 BinaryOperation(Zone* zone, Token::Value op, Expression* left, 2083 BinaryOperation(Zone* zone, Token::Value op, Expression* left,
2096 Expression* right, int pos, IdGen* id_gen) 2084 Expression* right, int pos)
2097 : Expression(zone, pos, num_ids(), id_gen), 2085 : Expression(zone, pos),
2098 op_(static_cast<byte>(op)), 2086 op_(static_cast<byte>(op)),
2099 left_(left), 2087 left_(left),
2100 right_(right) { 2088 right_(right) {
2101 DCHECK(Token::IsBinaryOp(op)); 2089 DCHECK(Token::IsBinaryOp(op));
2102 } 2090 }
2103 2091 static int parent_num_ids() { return Expression::num_ids(); }
2104 static int num_ids() { return 2; }
2105 int base_id() const { return Expression::base_id() + Expression::num_ids(); }
2106 2092
2107 private: 2093 private:
2094 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
2095
2108 const byte op_; // actually Token::Value 2096 const byte op_; // actually Token::Value
2109 // TODO(rossberg): the fixed arg should probably be represented as a Constant 2097 // TODO(rossberg): the fixed arg should probably be represented as a Constant
2110 // type for the RHS. Currenty it's actually a Maybe<int> 2098 // type for the RHS. Currenty it's actually a Maybe<int>
2111 bool has_fixed_right_arg_; 2099 bool has_fixed_right_arg_;
2112 int fixed_right_arg_value_; 2100 int fixed_right_arg_value_;
2113 Expression* left_; 2101 Expression* left_;
2114 Expression* right_; 2102 Expression* right_;
2115 Handle<AllocationSite> allocation_site_; 2103 Handle<AllocationSite> allocation_site_;
2116 }; 2104 };
2117 2105
(...skipping 20 matching lines...) Expand all
2138 } 2126 }
2139 virtual IcCheckType GetKeyType() OVERRIDE { return key_type_; } 2127 virtual IcCheckType GetKeyType() OVERRIDE { return key_type_; }
2140 virtual KeyedAccessStoreMode GetStoreMode() OVERRIDE { 2128 virtual KeyedAccessStoreMode GetStoreMode() OVERRIDE {
2141 return store_mode_; 2129 return store_mode_;
2142 } 2130 }
2143 Type* type() const { return type_; } 2131 Type* type() const { return type_; }
2144 void set_key_type(IcCheckType type) { key_type_ = type; } 2132 void set_key_type(IcCheckType type) { key_type_ = type; }
2145 void set_store_mode(KeyedAccessStoreMode mode) { store_mode_ = mode; } 2133 void set_store_mode(KeyedAccessStoreMode mode) { store_mode_ = mode; }
2146 void set_type(Type* type) { type_ = type; } 2134 void set_type(Type* type) { type_ = type; }
2147 2135
2148 BailoutId AssignmentId() const { return BailoutId(base_id() + 0); } 2136 static int num_ids() { return parent_num_ids() + 3; }
2137 BailoutId AssignmentId() const { return BailoutId(local_id(0)); }
2149 TypeFeedbackId CountBinOpFeedbackId() const { 2138 TypeFeedbackId CountBinOpFeedbackId() const {
2150 return TypeFeedbackId(base_id() + 1); 2139 return TypeFeedbackId(local_id(1));
2151 } 2140 }
2152 TypeFeedbackId CountStoreFeedbackId() const { 2141 TypeFeedbackId CountStoreFeedbackId() const {
2153 return TypeFeedbackId(base_id() + 2); 2142 return TypeFeedbackId(local_id(2));
2154 } 2143 }
2155 2144
2156 protected: 2145 protected:
2157 CountOperation(Zone* zone, Token::Value op, bool is_prefix, Expression* expr, 2146 CountOperation(Zone* zone, Token::Value op, bool is_prefix, Expression* expr,
2158 int pos, IdGen* id_gen) 2147 int pos)
2159 : Expression(zone, pos, num_ids(), id_gen), 2148 : Expression(zone, pos),
2160 op_(op), 2149 op_(op),
2161 is_prefix_(is_prefix), 2150 is_prefix_(is_prefix),
2162 key_type_(ELEMENT), 2151 key_type_(ELEMENT),
2163 store_mode_(STANDARD_STORE), 2152 store_mode_(STANDARD_STORE),
2164 expression_(expr) {} 2153 expression_(expr) {}
2165 2154 static int parent_num_ids() { return Expression::num_ids(); }
2166 static int num_ids() { return 3; }
2167 int base_id() const { return Expression::base_id() + Expression::num_ids(); }
2168 2155
2169 private: 2156 private:
2157 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
2158
2170 Token::Value op_; 2159 Token::Value op_;
2171 bool is_prefix_ : 1; 2160 bool is_prefix_ : 1;
2172 IcCheckType key_type_ : 1; 2161 IcCheckType key_type_ : 1;
2173 KeyedAccessStoreMode store_mode_ : 5; // Windows treats as signed, 2162 KeyedAccessStoreMode store_mode_ : 5; // Windows treats as signed,
2174 // must have extra bit. 2163 // must have extra bit.
2175 Type* type_; 2164 Type* type_;
2176 Expression* expression_; 2165 Expression* expression_;
2177 SmallMapList receiver_types_; 2166 SmallMapList receiver_types_;
2178 }; 2167 };
2179 2168
2180 2169
2181 class CompareOperation FINAL : public Expression { 2170 class CompareOperation FINAL : public Expression {
2182 public: 2171 public:
2183 DECLARE_NODE_TYPE(CompareOperation) 2172 DECLARE_NODE_TYPE(CompareOperation)
2184 2173
2185 Token::Value op() const { return op_; } 2174 Token::Value op() const { return op_; }
2186 Expression* left() const { return left_; } 2175 Expression* left() const { return left_; }
2187 Expression* right() const { return right_; } 2176 Expression* right() const { return right_; }
2188 2177
2189 // Type feedback information. 2178 // Type feedback information.
2179 static int num_ids() { return parent_num_ids() + 1; }
2190 TypeFeedbackId CompareOperationFeedbackId() const { 2180 TypeFeedbackId CompareOperationFeedbackId() const {
2191 return TypeFeedbackId(base_id() + 0); 2181 return TypeFeedbackId(local_id(0));
2192 } 2182 }
2193 Type* combined_type() const { return combined_type_; } 2183 Type* combined_type() const { return combined_type_; }
2194 void set_combined_type(Type* type) { combined_type_ = type; } 2184 void set_combined_type(Type* type) { combined_type_ = type; }
2195 2185
2196 // Match special cases. 2186 // Match special cases.
2197 bool IsLiteralCompareTypeof(Expression** expr, Handle<String>* check); 2187 bool IsLiteralCompareTypeof(Expression** expr, Handle<String>* check);
2198 bool IsLiteralCompareUndefined(Expression** expr, Isolate* isolate); 2188 bool IsLiteralCompareUndefined(Expression** expr, Isolate* isolate);
2199 bool IsLiteralCompareNull(Expression** expr); 2189 bool IsLiteralCompareNull(Expression** expr);
2200 2190
2201 protected: 2191 protected:
2202 CompareOperation(Zone* zone, Token::Value op, Expression* left, 2192 CompareOperation(Zone* zone, Token::Value op, Expression* left,
2203 Expression* right, int pos, IdGen* id_gen) 2193 Expression* right, int pos)
2204 : Expression(zone, pos, num_ids(), id_gen), 2194 : Expression(zone, pos),
2205 op_(op), 2195 op_(op),
2206 left_(left), 2196 left_(left),
2207 right_(right), 2197 right_(right),
2208 combined_type_(Type::None(zone)) { 2198 combined_type_(Type::None(zone)) {
2209 DCHECK(Token::IsCompareOp(op)); 2199 DCHECK(Token::IsCompareOp(op));
2210 } 2200 }
2211 2201 static int parent_num_ids() { return Expression::num_ids(); }
2212 static int num_ids() { return 1; }
2213 int base_id() const { return Expression::base_id() + Expression::num_ids(); }
2214 2202
2215 private: 2203 private:
2204 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
2205
2216 Token::Value op_; 2206 Token::Value op_;
2217 Expression* left_; 2207 Expression* left_;
2218 Expression* right_; 2208 Expression* right_;
2219 2209
2220 Type* combined_type_; 2210 Type* combined_type_;
2221 }; 2211 };
2222 2212
2223 2213
2224 class Conditional FINAL : public Expression { 2214 class Conditional FINAL : public Expression {
2225 public: 2215 public:
2226 DECLARE_NODE_TYPE(Conditional) 2216 DECLARE_NODE_TYPE(Conditional)
2227 2217
2228 Expression* condition() const { return condition_; } 2218 Expression* condition() const { return condition_; }
2229 Expression* then_expression() const { return then_expression_; } 2219 Expression* then_expression() const { return then_expression_; }
2230 Expression* else_expression() const { return else_expression_; } 2220 Expression* else_expression() const { return else_expression_; }
2231 2221
2232 BailoutId ThenId() const { return BailoutId(base_id() + 0); } 2222 static int num_ids() { return parent_num_ids() + 2; }
2233 BailoutId ElseId() const { return BailoutId(base_id() + 1); } 2223 BailoutId ThenId() const { return BailoutId(local_id(0)); }
2224 BailoutId ElseId() const { return BailoutId(local_id(1)); }
2234 2225
2235 protected: 2226 protected:
2236 Conditional(Zone* zone, Expression* condition, Expression* then_expression, 2227 Conditional(Zone* zone, Expression* condition, Expression* then_expression,
2237 Expression* else_expression, int position, IdGen* id_gen) 2228 Expression* else_expression, int position)
2238 : Expression(zone, position, num_ids(), id_gen), 2229 : Expression(zone, position),
2239 condition_(condition), 2230 condition_(condition),
2240 then_expression_(then_expression), 2231 then_expression_(then_expression),
2241 else_expression_(else_expression) {} 2232 else_expression_(else_expression) {}
2242 2233 static int parent_num_ids() { return Expression::num_ids(); }
2243 static int num_ids() { return 2; }
2244 int base_id() const { return Expression::base_id() + Expression::num_ids(); }
2245 2234
2246 private: 2235 private:
2236 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
2237
2247 Expression* condition_; 2238 Expression* condition_;
2248 Expression* then_expression_; 2239 Expression* then_expression_;
2249 Expression* else_expression_; 2240 Expression* else_expression_;
2250 }; 2241 };
2251 2242
2252 2243
2253 class Assignment FINAL : public Expression { 2244 class Assignment FINAL : public Expression {
2254 public: 2245 public:
2255 DECLARE_NODE_TYPE(Assignment) 2246 DECLARE_NODE_TYPE(Assignment)
2256 2247
2257 Assignment* AsSimpleAssignment() { return !is_compound() ? this : NULL; } 2248 Assignment* AsSimpleAssignment() { return !is_compound() ? this : NULL; }
2258 2249
2259 Token::Value binary_op() const; 2250 Token::Value binary_op() const;
2260 2251
2261 Token::Value op() const { return op_; } 2252 Token::Value op() const { return op_; }
2262 Expression* target() const { return target_; } 2253 Expression* target() const { return target_; }
2263 Expression* value() const { return value_; } 2254 Expression* value() const { return value_; }
2264 BinaryOperation* binary_operation() const { return binary_operation_; } 2255 BinaryOperation* binary_operation() const { return binary_operation_; }
2265 2256
2266 // This check relies on the definition order of token in token.h. 2257 // This check relies on the definition order of token in token.h.
2267 bool is_compound() const { return op() > Token::ASSIGN; } 2258 bool is_compound() const { return op() > Token::ASSIGN; }
2268 2259
2269 BailoutId AssignmentId() const { return BailoutId(base_id() + 0); } 2260 static int num_ids() { return parent_num_ids() + 2; }
2261 BailoutId AssignmentId() const { return BailoutId(local_id(0)); }
2270 2262
2271 // Type feedback information. 2263 // Type feedback information.
2272 TypeFeedbackId AssignmentFeedbackId() { 2264 TypeFeedbackId AssignmentFeedbackId() { return TypeFeedbackId(local_id(1)); }
2273 return TypeFeedbackId(base_id() + 1);
2274 }
2275 virtual bool IsMonomorphic() OVERRIDE { 2265 virtual bool IsMonomorphic() OVERRIDE {
2276 return receiver_types_.length() == 1; 2266 return receiver_types_.length() == 1;
2277 } 2267 }
2278 bool IsUninitialized() { return is_uninitialized_; } 2268 bool IsUninitialized() { return is_uninitialized_; }
2279 bool HasNoTypeInformation() { 2269 bool HasNoTypeInformation() {
2280 return is_uninitialized_; 2270 return is_uninitialized_;
2281 } 2271 }
2282 virtual SmallMapList* GetReceiverTypes() OVERRIDE { 2272 virtual SmallMapList* GetReceiverTypes() OVERRIDE {
2283 return &receiver_types_; 2273 return &receiver_types_;
2284 } 2274 }
2285 virtual IcCheckType GetKeyType() OVERRIDE { return key_type_; } 2275 virtual IcCheckType GetKeyType() OVERRIDE { return key_type_; }
2286 virtual KeyedAccessStoreMode GetStoreMode() OVERRIDE { 2276 virtual KeyedAccessStoreMode GetStoreMode() OVERRIDE {
2287 return store_mode_; 2277 return store_mode_;
2288 } 2278 }
2289 void set_is_uninitialized(bool b) { is_uninitialized_ = b; } 2279 void set_is_uninitialized(bool b) { is_uninitialized_ = b; }
2290 void set_key_type(IcCheckType key_type) { key_type_ = key_type; } 2280 void set_key_type(IcCheckType key_type) { key_type_ = key_type; }
2291 void set_store_mode(KeyedAccessStoreMode mode) { store_mode_ = mode; } 2281 void set_store_mode(KeyedAccessStoreMode mode) { store_mode_ = mode; }
2292 2282
2293 protected: 2283 protected:
2294 Assignment(Zone* zone, Token::Value op, Expression* target, Expression* value, 2284 Assignment(Zone* zone, Token::Value op, Expression* target, Expression* value,
2295 int pos, IdGen* id_gen); 2285 int pos);
2286 static int parent_num_ids() { return Expression::num_ids(); }
2296 2287
2297 static int num_ids() { return 2; } 2288 template <class Visitor>
2298 int base_id() const { return Expression::base_id() + Expression::num_ids(); } 2289 void Init(AstNodeFactory<Visitor>* factory) {
2299
2300 template<class Visitor>
2301 void Init(Zone* zone, AstNodeFactory<Visitor>* factory) {
2302 DCHECK(Token::IsAssignmentOp(op_)); 2290 DCHECK(Token::IsAssignmentOp(op_));
2303 if (is_compound()) { 2291 if (is_compound()) {
2304 binary_operation_ = factory->NewBinaryOperation( 2292 binary_operation_ = factory->NewBinaryOperation(
2305 binary_op(), target_, value_, position() + 1); 2293 binary_op(), target_, value_, position() + 1);
2306 } 2294 }
2307 } 2295 }
2308 2296
2309 private: 2297 private:
2298 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
2299
2310 bool is_uninitialized_ : 1; 2300 bool is_uninitialized_ : 1;
2311 IcCheckType key_type_ : 1; 2301 IcCheckType key_type_ : 1;
2312 KeyedAccessStoreMode store_mode_ : 5; // Windows treats as signed, 2302 KeyedAccessStoreMode store_mode_ : 5; // Windows treats as signed,
2313 // must have extra bit. 2303 // must have extra bit.
2314 Token::Value op_; 2304 Token::Value op_;
2315 Expression* target_; 2305 Expression* target_;
2316 Expression* value_; 2306 Expression* value_;
2317 BinaryOperation* binary_operation_; 2307 BinaryOperation* binary_operation_;
2318 SmallMapList receiver_types_; 2308 SmallMapList receiver_types_;
2319 }; 2309 };
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
2360 } 2350 }
2361 2351
2362 FeedbackVectorICSlot DoneFeedbackSlot() { 2352 FeedbackVectorICSlot DoneFeedbackSlot() {
2363 return KeyedLoadFeedbackSlot().next(); 2353 return KeyedLoadFeedbackSlot().next();
2364 } 2354 }
2365 2355
2366 FeedbackVectorICSlot ValueFeedbackSlot() { return DoneFeedbackSlot().next(); } 2356 FeedbackVectorICSlot ValueFeedbackSlot() { return DoneFeedbackSlot().next(); }
2367 2357
2368 protected: 2358 protected:
2369 Yield(Zone* zone, Expression* generator_object, Expression* expression, 2359 Yield(Zone* zone, Expression* generator_object, Expression* expression,
2370 Kind yield_kind, int pos, IdGen* id_gen) 2360 Kind yield_kind, int pos)
2371 : Expression(zone, pos, 0, id_gen), 2361 : Expression(zone, pos),
2372 generator_object_(generator_object), 2362 generator_object_(generator_object),
2373 expression_(expression), 2363 expression_(expression),
2374 yield_kind_(yield_kind), 2364 yield_kind_(yield_kind),
2375 index_(-1), 2365 index_(-1),
2376 yield_first_feedback_slot_(FeedbackVectorICSlot::Invalid()) {} 2366 yield_first_feedback_slot_(FeedbackVectorICSlot::Invalid()) {}
2377 2367
2378 private: 2368 private:
2379 Expression* generator_object_; 2369 Expression* generator_object_;
2380 Expression* expression_; 2370 Expression* expression_;
2381 Kind yield_kind_; 2371 Kind yield_kind_;
2382 int index_; 2372 int index_;
2383 FeedbackVectorICSlot yield_first_feedback_slot_; 2373 FeedbackVectorICSlot yield_first_feedback_slot_;
2384 }; 2374 };
2385 2375
2386 2376
2387 class Throw FINAL : public Expression { 2377 class Throw FINAL : public Expression {
2388 public: 2378 public:
2389 DECLARE_NODE_TYPE(Throw) 2379 DECLARE_NODE_TYPE(Throw)
2390 2380
2391 Expression* exception() const { return exception_; } 2381 Expression* exception() const { return exception_; }
2392 2382
2393 protected: 2383 protected:
2394 Throw(Zone* zone, Expression* exception, int pos, IdGen* id_gen) 2384 Throw(Zone* zone, Expression* exception, int pos)
2395 : Expression(zone, pos, 0, id_gen), exception_(exception) {} 2385 : Expression(zone, pos), exception_(exception) {}
2396 2386
2397 private: 2387 private:
2398 Expression* exception_; 2388 Expression* exception_;
2399 }; 2389 };
2400 2390
2401 2391
2402 class FunctionLiteral FINAL : public Expression { 2392 class FunctionLiteral FINAL : public Expression {
2403 public: 2393 public:
2404 enum FunctionType { 2394 enum FunctionType {
2405 ANONYMOUS_EXPRESSION, 2395 ANONYMOUS_EXPRESSION,
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
2539 2529
2540 protected: 2530 protected:
2541 FunctionLiteral(Zone* zone, const AstRawString* name, 2531 FunctionLiteral(Zone* zone, const AstRawString* name,
2542 AstValueFactory* ast_value_factory, Scope* scope, 2532 AstValueFactory* ast_value_factory, Scope* scope,
2543 ZoneList<Statement*>* body, int materialized_literal_count, 2533 ZoneList<Statement*>* body, int materialized_literal_count,
2544 int expected_property_count, int handler_count, 2534 int expected_property_count, int handler_count,
2545 int parameter_count, FunctionType function_type, 2535 int parameter_count, FunctionType function_type,
2546 ParameterFlag has_duplicate_parameters, 2536 ParameterFlag has_duplicate_parameters,
2547 IsFunctionFlag is_function, 2537 IsFunctionFlag is_function,
2548 IsParenthesizedFlag is_parenthesized, FunctionKind kind, 2538 IsParenthesizedFlag is_parenthesized, FunctionKind kind,
2549 int position, IdGen* id_gen) 2539 int position)
2550 : Expression(zone, position, 0, id_gen), 2540 : Expression(zone, position),
2551 raw_name_(name), 2541 raw_name_(name),
2552 scope_(scope), 2542 scope_(scope),
2553 body_(body), 2543 body_(body),
2554 raw_inferred_name_(ast_value_factory->empty_string()), 2544 raw_inferred_name_(ast_value_factory->empty_string()),
2555 dont_optimize_reason_(kNoReason), 2545 dont_optimize_reason_(kNoReason),
2556 materialized_literal_count_(materialized_literal_count), 2546 materialized_literal_count_(materialized_literal_count),
2557 expected_property_count_(expected_property_count), 2547 expected_property_count_(expected_property_count),
2558 handler_count_(handler_count), 2548 handler_count_(handler_count),
2559 parameter_count_(parameter_count), 2549 parameter_count_(parameter_count),
2560 function_token_position_(RelocInfo::kNoPosition) { 2550 function_token_position_(RelocInfo::kNoPosition) {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
2606 const AstRawString* raw_name() const { return raw_name_; } 2596 const AstRawString* raw_name() const { return raw_name_; }
2607 Expression* extends() const { return extends_; } 2597 Expression* extends() const { return extends_; }
2608 Expression* constructor() const { return constructor_; } 2598 Expression* constructor() const { return constructor_; }
2609 ZoneList<Property*>* properties() const { return properties_; } 2599 ZoneList<Property*>* properties() const { return properties_; }
2610 int start_position() const { return position(); } 2600 int start_position() const { return position(); }
2611 int end_position() const { return end_position_; } 2601 int end_position() const { return end_position_; }
2612 2602
2613 protected: 2603 protected:
2614 ClassLiteral(Zone* zone, const AstRawString* name, Expression* extends, 2604 ClassLiteral(Zone* zone, const AstRawString* name, Expression* extends,
2615 Expression* constructor, ZoneList<Property*>* properties, 2605 Expression* constructor, ZoneList<Property*>* properties,
2616 int start_position, int end_position, IdGen* id_gen) 2606 int start_position, int end_position)
2617 : Expression(zone, start_position, 0, id_gen), 2607 : Expression(zone, start_position),
2618 raw_name_(name), 2608 raw_name_(name),
2619 extends_(extends), 2609 extends_(extends),
2620 constructor_(constructor), 2610 constructor_(constructor),
2621 properties_(properties), 2611 properties_(properties),
2622 end_position_(end_position) {} 2612 end_position_(end_position) {}
2623 2613
2624 private: 2614 private:
2625 const AstRawString* raw_name_; 2615 const AstRawString* raw_name_;
2626 Expression* extends_; 2616 Expression* extends_;
2627 Expression* constructor_; 2617 Expression* constructor_;
2628 ZoneList<Property*>* properties_; 2618 ZoneList<Property*>* properties_;
2629 int end_position_; 2619 int end_position_;
2630 }; 2620 };
2631 2621
2632 2622
2633 class NativeFunctionLiteral FINAL : public Expression { 2623 class NativeFunctionLiteral FINAL : public Expression {
2634 public: 2624 public:
2635 DECLARE_NODE_TYPE(NativeFunctionLiteral) 2625 DECLARE_NODE_TYPE(NativeFunctionLiteral)
2636 2626
2637 Handle<String> name() const { return name_->string(); } 2627 Handle<String> name() const { return name_->string(); }
2638 v8::Extension* extension() const { return extension_; } 2628 v8::Extension* extension() const { return extension_; }
2639 2629
2640 protected: 2630 protected:
2641 NativeFunctionLiteral(Zone* zone, const AstRawString* name, 2631 NativeFunctionLiteral(Zone* zone, const AstRawString* name,
2642 v8::Extension* extension, int pos, IdGen* id_gen) 2632 v8::Extension* extension, int pos)
2643 : Expression(zone, pos, 0, id_gen), name_(name), extension_(extension) {} 2633 : Expression(zone, pos), name_(name), extension_(extension) {}
2644 2634
2645 private: 2635 private:
2646 const AstRawString* name_; 2636 const AstRawString* name_;
2647 v8::Extension* extension_; 2637 v8::Extension* extension_;
2648 }; 2638 };
2649 2639
2650 2640
2651 class ThisFunction FINAL : public Expression { 2641 class ThisFunction FINAL : public Expression {
2652 public: 2642 public:
2653 DECLARE_NODE_TYPE(ThisFunction) 2643 DECLARE_NODE_TYPE(ThisFunction)
2654 2644
2655 protected: 2645 protected:
2656 ThisFunction(Zone* zone, int pos, IdGen* id_gen) 2646 ThisFunction(Zone* zone, int pos) : Expression(zone, pos) {}
2657 : Expression(zone, pos, 0, id_gen) {}
2658 }; 2647 };
2659 2648
2660 2649
2661 class SuperReference FINAL : public Expression { 2650 class SuperReference FINAL : public Expression {
2662 public: 2651 public:
2663 DECLARE_NODE_TYPE(SuperReference) 2652 DECLARE_NODE_TYPE(SuperReference)
2664 2653
2665 VariableProxy* this_var() const { return this_var_; } 2654 VariableProxy* this_var() const { return this_var_; }
2666 2655
2667 TypeFeedbackId HomeObjectFeedbackId() { 2656 static int num_ids() { return parent_num_ids() + 1; }
2668 return TypeFeedbackId(base_id() + 0); 2657 TypeFeedbackId HomeObjectFeedbackId() { return TypeFeedbackId(local_id(0)); }
2669 }
2670 2658
2671 // Type feedback information. 2659 // Type feedback information.
2672 virtual FeedbackVectorRequirements ComputeFeedbackRequirements() { 2660 virtual FeedbackVectorRequirements ComputeFeedbackRequirements() {
2673 return FeedbackVectorRequirements(0, FLAG_vector_ics ? 1 : 0); 2661 return FeedbackVectorRequirements(0, FLAG_vector_ics ? 1 : 0);
2674 } 2662 }
2675 virtual void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot) { 2663 virtual void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot) {
2676 homeobject_feedback_slot_ = slot; 2664 homeobject_feedback_slot_ = slot;
2677 } 2665 }
2678 2666
2679 FeedbackVectorICSlot HomeObjectFeedbackSlot() { 2667 FeedbackVectorICSlot HomeObjectFeedbackSlot() {
2680 DCHECK(!FLAG_vector_ics || !homeobject_feedback_slot_.IsInvalid()); 2668 DCHECK(!FLAG_vector_ics || !homeobject_feedback_slot_.IsInvalid());
2681 return homeobject_feedback_slot_; 2669 return homeobject_feedback_slot_;
2682 } 2670 }
2683 2671
2684 protected: 2672 protected:
2685 SuperReference(Zone* zone, VariableProxy* this_var, int pos, IdGen* id_gen) 2673 SuperReference(Zone* zone, VariableProxy* this_var, int pos)
2686 : Expression(zone, pos, num_ids(), id_gen), 2674 : Expression(zone, pos),
2687 this_var_(this_var), 2675 this_var_(this_var),
2688 homeobject_feedback_slot_(FeedbackVectorICSlot::Invalid()) { 2676 homeobject_feedback_slot_(FeedbackVectorICSlot::Invalid()) {
2689 DCHECK(this_var->is_this()); 2677 DCHECK(this_var->is_this());
2690 } 2678 }
2691 2679 static int parent_num_ids() { return Expression::num_ids(); }
2692 static int num_ids() { return 1; }
2693 int base_id() const { return Expression::base_id() + Expression::num_ids(); }
2694 2680
2695 private: 2681 private:
2682 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
2683
2696 VariableProxy* this_var_; 2684 VariableProxy* this_var_;
2697 FeedbackVectorICSlot homeobject_feedback_slot_; 2685 FeedbackVectorICSlot homeobject_feedback_slot_;
2698 }; 2686 };
2699 2687
2700 2688
2701 #undef DECLARE_NODE_TYPE 2689 #undef DECLARE_NODE_TYPE
2702 2690
2703 2691
2704 // ---------------------------------------------------------------------------- 2692 // ----------------------------------------------------------------------------
2705 // Regular expressions 2693 // Regular expressions
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
3187 }; 3175 };
3188 3176
3189 3177
3190 3178
3191 // ---------------------------------------------------------------------------- 3179 // ----------------------------------------------------------------------------
3192 // AstNode factory 3180 // AstNode factory
3193 3181
3194 template<class Visitor> 3182 template<class Visitor>
3195 class AstNodeFactory FINAL BASE_EMBEDDED { 3183 class AstNodeFactory FINAL BASE_EMBEDDED {
3196 public: 3184 public:
3197 AstNodeFactory(Zone* zone, AstValueFactory* ast_value_factory, 3185 explicit AstNodeFactory(AstValueFactory* ast_value_factory)
3198 AstNode::IdGen* id_gen) 3186 : zone_(ast_value_factory->zone()),
3199 : zone_(zone), ast_value_factory_(ast_value_factory), id_gen_(id_gen) {} 3187 ast_value_factory_(ast_value_factory) {}
3200 3188
3201 Visitor* visitor() { return &visitor_; } 3189 Visitor* visitor() { return &visitor_; }
3202 3190
3203 #define VISIT_AND_RETURN(NodeType, node) \ 3191 #define VISIT_AND_RETURN(NodeType, node) \
3204 visitor_.Visit##NodeType((node)); \ 3192 visitor_.Visit##NodeType((node)); \
3205 return node; 3193 return node;
3206 3194
3207 VariableDeclaration* NewVariableDeclaration(VariableProxy* proxy, 3195 VariableDeclaration* NewVariableDeclaration(VariableProxy* proxy,
3208 VariableMode mode, 3196 VariableMode mode,
3209 Scope* scope, 3197 Scope* scope,
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
3267 3255
3268 ModuleUrl* NewModuleUrl(Handle<String> url, int pos) { 3256 ModuleUrl* NewModuleUrl(Handle<String> url, int pos) {
3269 ModuleUrl* module = new(zone_) ModuleUrl(zone_, url, pos); 3257 ModuleUrl* module = new(zone_) ModuleUrl(zone_, url, pos);
3270 VISIT_AND_RETURN(ModuleUrl, module) 3258 VISIT_AND_RETURN(ModuleUrl, module)
3271 } 3259 }
3272 3260
3273 Block* NewBlock(ZoneList<const AstRawString*>* labels, 3261 Block* NewBlock(ZoneList<const AstRawString*>* labels,
3274 int capacity, 3262 int capacity,
3275 bool is_initializer_block, 3263 bool is_initializer_block,
3276 int pos) { 3264 int pos) {
3277 Block* block = new (zone_) 3265 Block* block =
3278 Block(zone_, labels, capacity, is_initializer_block, pos, id_gen_); 3266 new (zone_) Block(zone_, labels, capacity, is_initializer_block, pos);
3279 VISIT_AND_RETURN(Block, block) 3267 VISIT_AND_RETURN(Block, block)
3280 } 3268 }
3281 3269
3282 #define STATEMENT_WITH_LABELS(NodeType) \ 3270 #define STATEMENT_WITH_LABELS(NodeType) \
3283 NodeType* New##NodeType(ZoneList<const AstRawString*>* labels, int pos) { \ 3271 NodeType* New##NodeType(ZoneList<const AstRawString*>* labels, int pos) { \
3284 NodeType* stmt = new (zone_) NodeType(zone_, labels, pos, id_gen_); \ 3272 NodeType* stmt = new (zone_) NodeType(zone_, labels, pos); \
3285 VISIT_AND_RETURN(NodeType, stmt); \ 3273 VISIT_AND_RETURN(NodeType, stmt); \
3286 } 3274 }
3287 STATEMENT_WITH_LABELS(DoWhileStatement) 3275 STATEMENT_WITH_LABELS(DoWhileStatement)
3288 STATEMENT_WITH_LABELS(WhileStatement) 3276 STATEMENT_WITH_LABELS(WhileStatement)
3289 STATEMENT_WITH_LABELS(ForStatement) 3277 STATEMENT_WITH_LABELS(ForStatement)
3290 STATEMENT_WITH_LABELS(SwitchStatement) 3278 STATEMENT_WITH_LABELS(SwitchStatement)
3291 #undef STATEMENT_WITH_LABELS 3279 #undef STATEMENT_WITH_LABELS
3292 3280
3293 ForEachStatement* NewForEachStatement(ForEachStatement::VisitMode visit_mode, 3281 ForEachStatement* NewForEachStatement(ForEachStatement::VisitMode visit_mode,
3294 ZoneList<const AstRawString*>* labels, 3282 ZoneList<const AstRawString*>* labels,
3295 int pos) { 3283 int pos) {
3296 switch (visit_mode) { 3284 switch (visit_mode) {
3297 case ForEachStatement::ENUMERATE: { 3285 case ForEachStatement::ENUMERATE: {
3298 ForInStatement* stmt = 3286 ForInStatement* stmt = new (zone_) ForInStatement(zone_, labels, pos);
3299 new (zone_) ForInStatement(zone_, labels, pos, id_gen_);
3300 VISIT_AND_RETURN(ForInStatement, stmt); 3287 VISIT_AND_RETURN(ForInStatement, stmt);
3301 } 3288 }
3302 case ForEachStatement::ITERATE: { 3289 case ForEachStatement::ITERATE: {
3303 ForOfStatement* stmt = 3290 ForOfStatement* stmt = new (zone_) ForOfStatement(zone_, labels, pos);
3304 new (zone_) ForOfStatement(zone_, labels, pos, id_gen_);
3305 VISIT_AND_RETURN(ForOfStatement, stmt); 3291 VISIT_AND_RETURN(ForOfStatement, stmt);
3306 } 3292 }
3307 } 3293 }
3308 UNREACHABLE(); 3294 UNREACHABLE();
3309 return NULL; 3295 return NULL;
3310 } 3296 }
3311 3297
3312 ModuleStatement* NewModuleStatement( 3298 ModuleStatement* NewModuleStatement(
3313 VariableProxy* proxy, Block* body, int pos) { 3299 VariableProxy* proxy, Block* body, int pos) {
3314 ModuleStatement* stmt = new(zone_) ModuleStatement(zone_, proxy, body, pos); 3300 ModuleStatement* stmt = new(zone_) ModuleStatement(zone_, proxy, body, pos);
(...skipping 27 matching lines...) Expand all
3342 int pos) { 3328 int pos) {
3343 WithStatement* stmt = new(zone_) WithStatement( 3329 WithStatement* stmt = new(zone_) WithStatement(
3344 zone_, scope, expression, statement, pos); 3330 zone_, scope, expression, statement, pos);
3345 VISIT_AND_RETURN(WithStatement, stmt) 3331 VISIT_AND_RETURN(WithStatement, stmt)
3346 } 3332 }
3347 3333
3348 IfStatement* NewIfStatement(Expression* condition, 3334 IfStatement* NewIfStatement(Expression* condition,
3349 Statement* then_statement, 3335 Statement* then_statement,
3350 Statement* else_statement, 3336 Statement* else_statement,
3351 int pos) { 3337 int pos) {
3352 IfStatement* stmt = new (zone_) IfStatement( 3338 IfStatement* stmt = new (zone_)
3353 zone_, condition, then_statement, else_statement, pos, id_gen_); 3339 IfStatement(zone_, condition, then_statement, else_statement, pos);
3354 VISIT_AND_RETURN(IfStatement, stmt) 3340 VISIT_AND_RETURN(IfStatement, stmt)
3355 } 3341 }
3356 3342
3357 TryCatchStatement* NewTryCatchStatement(int index, 3343 TryCatchStatement* NewTryCatchStatement(int index,
3358 Block* try_block, 3344 Block* try_block,
3359 Scope* scope, 3345 Scope* scope,
3360 Variable* variable, 3346 Variable* variable,
3361 Block* catch_block, 3347 Block* catch_block,
3362 int pos) { 3348 int pos) {
3363 TryCatchStatement* stmt = new(zone_) TryCatchStatement( 3349 TryCatchStatement* stmt = new(zone_) TryCatchStatement(
3364 zone_, index, try_block, scope, variable, catch_block, pos); 3350 zone_, index, try_block, scope, variable, catch_block, pos);
3365 VISIT_AND_RETURN(TryCatchStatement, stmt) 3351 VISIT_AND_RETURN(TryCatchStatement, stmt)
3366 } 3352 }
3367 3353
3368 TryFinallyStatement* NewTryFinallyStatement(int index, 3354 TryFinallyStatement* NewTryFinallyStatement(int index,
3369 Block* try_block, 3355 Block* try_block,
3370 Block* finally_block, 3356 Block* finally_block,
3371 int pos) { 3357 int pos) {
3372 TryFinallyStatement* stmt = new(zone_) TryFinallyStatement( 3358 TryFinallyStatement* stmt = new(zone_) TryFinallyStatement(
3373 zone_, index, try_block, finally_block, pos); 3359 zone_, index, try_block, finally_block, pos);
3374 VISIT_AND_RETURN(TryFinallyStatement, stmt) 3360 VISIT_AND_RETURN(TryFinallyStatement, stmt)
3375 } 3361 }
3376 3362
3377 DebuggerStatement* NewDebuggerStatement(int pos) { 3363 DebuggerStatement* NewDebuggerStatement(int pos) {
3378 DebuggerStatement* stmt = 3364 DebuggerStatement* stmt = new (zone_) DebuggerStatement(zone_, pos);
3379 new (zone_) DebuggerStatement(zone_, pos, id_gen_);
3380 VISIT_AND_RETURN(DebuggerStatement, stmt) 3365 VISIT_AND_RETURN(DebuggerStatement, stmt)
3381 } 3366 }
3382 3367
3383 EmptyStatement* NewEmptyStatement(int pos) { 3368 EmptyStatement* NewEmptyStatement(int pos) {
3384 return new(zone_) EmptyStatement(zone_, pos); 3369 return new(zone_) EmptyStatement(zone_, pos);
3385 } 3370 }
3386 3371
3387 CaseClause* NewCaseClause( 3372 CaseClause* NewCaseClause(
3388 Expression* label, ZoneList<Statement*>* statements, int pos) { 3373 Expression* label, ZoneList<Statement*>* statements, int pos) {
3389 CaseClause* clause = 3374 CaseClause* clause = new (zone_) CaseClause(zone_, label, statements, pos);
3390 new (zone_) CaseClause(zone_, label, statements, pos, id_gen_);
3391 VISIT_AND_RETURN(CaseClause, clause) 3375 VISIT_AND_RETURN(CaseClause, clause)
3392 } 3376 }
3393 3377
3394 Literal* NewStringLiteral(const AstRawString* string, int pos) { 3378 Literal* NewStringLiteral(const AstRawString* string, int pos) {
3395 Literal* lit = new (zone_) 3379 Literal* lit =
3396 Literal(zone_, ast_value_factory_->NewString(string), pos, id_gen_); 3380 new (zone_) Literal(zone_, ast_value_factory_->NewString(string), pos);
3397 VISIT_AND_RETURN(Literal, lit) 3381 VISIT_AND_RETURN(Literal, lit)
3398 } 3382 }
3399 3383
3400 // A JavaScript symbol (ECMA-262 edition 6). 3384 // A JavaScript symbol (ECMA-262 edition 6).
3401 Literal* NewSymbolLiteral(const char* name, int pos) { 3385 Literal* NewSymbolLiteral(const char* name, int pos) {
3402 Literal* lit = new (zone_) 3386 Literal* lit =
3403 Literal(zone_, ast_value_factory_->NewSymbol(name), pos, id_gen_); 3387 new (zone_) Literal(zone_, ast_value_factory_->NewSymbol(name), pos);
3404 VISIT_AND_RETURN(Literal, lit) 3388 VISIT_AND_RETURN(Literal, lit)
3405 } 3389 }
3406 3390
3407 Literal* NewNumberLiteral(double number, int pos) { 3391 Literal* NewNumberLiteral(double number, int pos) {
3408 Literal* lit = new (zone_) 3392 Literal* lit =
3409 Literal(zone_, ast_value_factory_->NewNumber(number), pos, id_gen_); 3393 new (zone_) Literal(zone_, ast_value_factory_->NewNumber(number), pos);
3410 VISIT_AND_RETURN(Literal, lit) 3394 VISIT_AND_RETURN(Literal, lit)
3411 } 3395 }
3412 3396
3413 Literal* NewSmiLiteral(int number, int pos) { 3397 Literal* NewSmiLiteral(int number, int pos) {
3414 Literal* lit = new (zone_) 3398 Literal* lit =
3415 Literal(zone_, ast_value_factory_->NewSmi(number), pos, id_gen_); 3399 new (zone_) Literal(zone_, ast_value_factory_->NewSmi(number), pos);
3416 VISIT_AND_RETURN(Literal, lit) 3400 VISIT_AND_RETURN(Literal, lit)
3417 } 3401 }
3418 3402
3419 Literal* NewBooleanLiteral(bool b, int pos) { 3403 Literal* NewBooleanLiteral(bool b, int pos) {
3420 Literal* lit = new (zone_) 3404 Literal* lit =
3421 Literal(zone_, ast_value_factory_->NewBoolean(b), pos, id_gen_); 3405 new (zone_) Literal(zone_, ast_value_factory_->NewBoolean(b), pos);
3422 VISIT_AND_RETURN(Literal, lit) 3406 VISIT_AND_RETURN(Literal, lit)
3423 } 3407 }
3424 3408
3425 Literal* NewStringListLiteral(ZoneList<const AstRawString*>* strings, 3409 Literal* NewStringListLiteral(ZoneList<const AstRawString*>* strings,
3426 int pos) { 3410 int pos) {
3427 Literal* lit = new (zone_) Literal( 3411 Literal* lit = new (zone_)
3428 zone_, ast_value_factory_->NewStringList(strings), pos, id_gen_); 3412 Literal(zone_, ast_value_factory_->NewStringList(strings), pos);
3429 VISIT_AND_RETURN(Literal, lit) 3413 VISIT_AND_RETURN(Literal, lit)
3430 } 3414 }
3431 3415
3432 Literal* NewNullLiteral(int pos) { 3416 Literal* NewNullLiteral(int pos) {
3433 Literal* lit = 3417 Literal* lit =
3434 new (zone_) Literal(zone_, ast_value_factory_->NewNull(), pos, id_gen_); 3418 new (zone_) Literal(zone_, ast_value_factory_->NewNull(), pos);
3435 VISIT_AND_RETURN(Literal, lit) 3419 VISIT_AND_RETURN(Literal, lit)
3436 } 3420 }
3437 3421
3438 Literal* NewUndefinedLiteral(int pos) { 3422 Literal* NewUndefinedLiteral(int pos) {
3439 Literal* lit = new (zone_) 3423 Literal* lit =
3440 Literal(zone_, ast_value_factory_->NewUndefined(), pos, id_gen_); 3424 new (zone_) Literal(zone_, ast_value_factory_->NewUndefined(), pos);
3441 VISIT_AND_RETURN(Literal, lit) 3425 VISIT_AND_RETURN(Literal, lit)
3442 } 3426 }
3443 3427
3444 Literal* NewTheHoleLiteral(int pos) { 3428 Literal* NewTheHoleLiteral(int pos) {
3445 Literal* lit = new (zone_) 3429 Literal* lit =
3446 Literal(zone_, ast_value_factory_->NewTheHole(), pos, id_gen_); 3430 new (zone_) Literal(zone_, ast_value_factory_->NewTheHole(), pos);
3447 VISIT_AND_RETURN(Literal, lit) 3431 VISIT_AND_RETURN(Literal, lit)
3448 } 3432 }
3449 3433
3450 ObjectLiteral* NewObjectLiteral( 3434 ObjectLiteral* NewObjectLiteral(
3451 ZoneList<ObjectLiteral::Property*>* properties, 3435 ZoneList<ObjectLiteral::Property*>* properties,
3452 int literal_index, 3436 int literal_index,
3453 int boilerplate_properties, 3437 int boilerplate_properties,
3454 bool has_function, 3438 bool has_function,
3455 int pos) { 3439 int pos) {
3456 ObjectLiteral* lit = new (zone_) 3440 ObjectLiteral* lit =
3457 ObjectLiteral(zone_, properties, literal_index, boilerplate_properties, 3441 new (zone_) ObjectLiteral(zone_, properties, literal_index,
3458 has_function, pos, id_gen_); 3442 boilerplate_properties, has_function, pos);
3459 VISIT_AND_RETURN(ObjectLiteral, lit) 3443 VISIT_AND_RETURN(ObjectLiteral, lit)
3460 } 3444 }
3461 3445
3462 ObjectLiteral::Property* NewObjectLiteralProperty(Literal* key, 3446 ObjectLiteral::Property* NewObjectLiteralProperty(Literal* key,
3463 Expression* value, 3447 Expression* value,
3464 bool is_static) { 3448 bool is_static) {
3465 return new (zone_) ObjectLiteral::Property(zone_, ast_value_factory_, key, 3449 return new (zone_) ObjectLiteral::Property(zone_, ast_value_factory_, key,
3466 value, is_static); 3450 value, is_static);
3467 } 3451 }
3468 3452
3469 ObjectLiteral::Property* NewObjectLiteralProperty(bool is_getter, 3453 ObjectLiteral::Property* NewObjectLiteralProperty(bool is_getter,
3470 FunctionLiteral* value, 3454 FunctionLiteral* value,
3471 int pos, bool is_static) { 3455 int pos, bool is_static) {
3472 ObjectLiteral::Property* prop = 3456 ObjectLiteral::Property* prop =
3473 new (zone_) ObjectLiteral::Property(zone_, is_getter, value, is_static); 3457 new (zone_) ObjectLiteral::Property(zone_, is_getter, value, is_static);
3474 prop->set_key(NewStringLiteral(value->raw_name(), pos)); 3458 prop->set_key(NewStringLiteral(value->raw_name(), pos));
3475 return prop; // Not an AST node, will not be visited. 3459 return prop; // Not an AST node, will not be visited.
3476 } 3460 }
3477 3461
3478 RegExpLiteral* NewRegExpLiteral(const AstRawString* pattern, 3462 RegExpLiteral* NewRegExpLiteral(const AstRawString* pattern,
3479 const AstRawString* flags, 3463 const AstRawString* flags,
3480 int literal_index, 3464 int literal_index,
3481 int pos) { 3465 int pos) {
3482 RegExpLiteral* lit = new (zone_) 3466 RegExpLiteral* lit =
3483 RegExpLiteral(zone_, pattern, flags, literal_index, pos, id_gen_); 3467 new (zone_) RegExpLiteral(zone_, pattern, flags, literal_index, pos);
3484 VISIT_AND_RETURN(RegExpLiteral, lit); 3468 VISIT_AND_RETURN(RegExpLiteral, lit);
3485 } 3469 }
3486 3470
3487 ArrayLiteral* NewArrayLiteral(ZoneList<Expression*>* values, 3471 ArrayLiteral* NewArrayLiteral(ZoneList<Expression*>* values,
3488 int literal_index, 3472 int literal_index,
3489 int pos) { 3473 int pos) {
3490 ArrayLiteral* lit = 3474 ArrayLiteral* lit =
3491 new (zone_) ArrayLiteral(zone_, values, literal_index, pos, id_gen_); 3475 new (zone_) ArrayLiteral(zone_, values, literal_index, pos);
3492 VISIT_AND_RETURN(ArrayLiteral, lit) 3476 VISIT_AND_RETURN(ArrayLiteral, lit)
3493 } 3477 }
3494 3478
3495 VariableProxy* NewVariableProxy(Variable* var, 3479 VariableProxy* NewVariableProxy(Variable* var,
3496 int pos = RelocInfo::kNoPosition) { 3480 int pos = RelocInfo::kNoPosition) {
3497 VariableProxy* proxy = new (zone_) VariableProxy(zone_, var, pos, id_gen_); 3481 VariableProxy* proxy = new (zone_) VariableProxy(zone_, var, pos);
3498 VISIT_AND_RETURN(VariableProxy, proxy) 3482 VISIT_AND_RETURN(VariableProxy, proxy)
3499 } 3483 }
3500 3484
3501 VariableProxy* NewVariableProxy(const AstRawString* name, 3485 VariableProxy* NewVariableProxy(const AstRawString* name,
3502 bool is_this, 3486 bool is_this,
3503 Interface* interface = Interface::NewValue(), 3487 Interface* interface = Interface::NewValue(),
3504 int position = RelocInfo::kNoPosition) { 3488 int position = RelocInfo::kNoPosition) {
3505 VariableProxy* proxy = new (zone_) 3489 VariableProxy* proxy =
3506 VariableProxy(zone_, name, is_this, interface, position, id_gen_); 3490 new (zone_) VariableProxy(zone_, name, is_this, interface, position);
3507 VISIT_AND_RETURN(VariableProxy, proxy) 3491 VISIT_AND_RETURN(VariableProxy, proxy)
3508 } 3492 }
3509 3493
3510 Property* NewProperty(Expression* obj, Expression* key, int pos) { 3494 Property* NewProperty(Expression* obj, Expression* key, int pos) {
3511 Property* prop = new (zone_) Property(zone_, obj, key, pos, id_gen_); 3495 Property* prop = new (zone_) Property(zone_, obj, key, pos);
3512 VISIT_AND_RETURN(Property, prop) 3496 VISIT_AND_RETURN(Property, prop)
3513 } 3497 }
3514 3498
3515 Call* NewCall(Expression* expression, 3499 Call* NewCall(Expression* expression,
3516 ZoneList<Expression*>* arguments, 3500 ZoneList<Expression*>* arguments,
3517 int pos) { 3501 int pos) {
3518 Call* call = new (zone_) Call(zone_, expression, arguments, pos, id_gen_); 3502 Call* call = new (zone_) Call(zone_, expression, arguments, pos);
3519 VISIT_AND_RETURN(Call, call) 3503 VISIT_AND_RETURN(Call, call)
3520 } 3504 }
3521 3505
3522 CallNew* NewCallNew(Expression* expression, 3506 CallNew* NewCallNew(Expression* expression,
3523 ZoneList<Expression*>* arguments, 3507 ZoneList<Expression*>* arguments,
3524 int pos) { 3508 int pos) {
3525 CallNew* call = 3509 CallNew* call = new (zone_) CallNew(zone_, expression, arguments, pos);
3526 new (zone_) CallNew(zone_, expression, arguments, pos, id_gen_);
3527 VISIT_AND_RETURN(CallNew, call) 3510 VISIT_AND_RETURN(CallNew, call)
3528 } 3511 }
3529 3512
3530 CallRuntime* NewCallRuntime(const AstRawString* name, 3513 CallRuntime* NewCallRuntime(const AstRawString* name,
3531 const Runtime::Function* function, 3514 const Runtime::Function* function,
3532 ZoneList<Expression*>* arguments, 3515 ZoneList<Expression*>* arguments,
3533 int pos) { 3516 int pos) {
3534 CallRuntime* call = 3517 CallRuntime* call =
3535 new (zone_) CallRuntime(zone_, name, function, arguments, pos, id_gen_); 3518 new (zone_) CallRuntime(zone_, name, function, arguments, pos);
3536 VISIT_AND_RETURN(CallRuntime, call) 3519 VISIT_AND_RETURN(CallRuntime, call)
3537 } 3520 }
3538 3521
3539 UnaryOperation* NewUnaryOperation(Token::Value op, 3522 UnaryOperation* NewUnaryOperation(Token::Value op,
3540 Expression* expression, 3523 Expression* expression,
3541 int pos) { 3524 int pos) {
3542 UnaryOperation* node = 3525 UnaryOperation* node =
3543 new (zone_) UnaryOperation(zone_, op, expression, pos, id_gen_); 3526 new (zone_) UnaryOperation(zone_, op, expression, pos);
3544 VISIT_AND_RETURN(UnaryOperation, node) 3527 VISIT_AND_RETURN(UnaryOperation, node)
3545 } 3528 }
3546 3529
3547 BinaryOperation* NewBinaryOperation(Token::Value op, 3530 BinaryOperation* NewBinaryOperation(Token::Value op,
3548 Expression* left, 3531 Expression* left,
3549 Expression* right, 3532 Expression* right,
3550 int pos) { 3533 int pos) {
3551 BinaryOperation* node = 3534 BinaryOperation* node =
3552 new (zone_) BinaryOperation(zone_, op, left, right, pos, id_gen_); 3535 new (zone_) BinaryOperation(zone_, op, left, right, pos);
3553 VISIT_AND_RETURN(BinaryOperation, node) 3536 VISIT_AND_RETURN(BinaryOperation, node)
3554 } 3537 }
3555 3538
3556 CountOperation* NewCountOperation(Token::Value op, 3539 CountOperation* NewCountOperation(Token::Value op,
3557 bool is_prefix, 3540 bool is_prefix,
3558 Expression* expr, 3541 Expression* expr,
3559 int pos) { 3542 int pos) {
3560 CountOperation* node = 3543 CountOperation* node =
3561 new (zone_) CountOperation(zone_, op, is_prefix, expr, pos, id_gen_); 3544 new (zone_) CountOperation(zone_, op, is_prefix, expr, pos);
3562 VISIT_AND_RETURN(CountOperation, node) 3545 VISIT_AND_RETURN(CountOperation, node)
3563 } 3546 }
3564 3547
3565 CompareOperation* NewCompareOperation(Token::Value op, 3548 CompareOperation* NewCompareOperation(Token::Value op,
3566 Expression* left, 3549 Expression* left,
3567 Expression* right, 3550 Expression* right,
3568 int pos) { 3551 int pos) {
3569 CompareOperation* node = 3552 CompareOperation* node =
3570 new (zone_) CompareOperation(zone_, op, left, right, pos, id_gen_); 3553 new (zone_) CompareOperation(zone_, op, left, right, pos);
3571 VISIT_AND_RETURN(CompareOperation, node) 3554 VISIT_AND_RETURN(CompareOperation, node)
3572 } 3555 }
3573 3556
3574 Conditional* NewConditional(Expression* condition, 3557 Conditional* NewConditional(Expression* condition,
3575 Expression* then_expression, 3558 Expression* then_expression,
3576 Expression* else_expression, 3559 Expression* else_expression,
3577 int position) { 3560 int position) {
3578 Conditional* cond = new (zone_) Conditional( 3561 Conditional* cond = new (zone_) Conditional(
3579 zone_, condition, then_expression, else_expression, position, id_gen_); 3562 zone_, condition, then_expression, else_expression, position);
3580 VISIT_AND_RETURN(Conditional, cond) 3563 VISIT_AND_RETURN(Conditional, cond)
3581 } 3564 }
3582 3565
3583 Assignment* NewAssignment(Token::Value op, 3566 Assignment* NewAssignment(Token::Value op,
3584 Expression* target, 3567 Expression* target,
3585 Expression* value, 3568 Expression* value,
3586 int pos) { 3569 int pos) {
3587 Assignment* assign = 3570 Assignment* assign = new (zone_) Assignment(zone_, op, target, value, pos);
3588 new (zone_) Assignment(zone_, op, target, value, pos, id_gen_); 3571 assign->Init(this);
3589 assign->Init(zone_, this);
3590 VISIT_AND_RETURN(Assignment, assign) 3572 VISIT_AND_RETURN(Assignment, assign)
3591 } 3573 }
3592 3574
3593 Yield* NewYield(Expression *generator_object, 3575 Yield* NewYield(Expression *generator_object,
3594 Expression* expression, 3576 Expression* expression,
3595 Yield::Kind yield_kind, 3577 Yield::Kind yield_kind,
3596 int pos) { 3578 int pos) {
3597 if (!expression) expression = NewUndefinedLiteral(pos); 3579 if (!expression) expression = NewUndefinedLiteral(pos);
3598 Yield* yield = new (zone_) 3580 Yield* yield =
3599 Yield(zone_, generator_object, expression, yield_kind, pos, id_gen_); 3581 new (zone_) Yield(zone_, generator_object, expression, yield_kind, pos);
3600 VISIT_AND_RETURN(Yield, yield) 3582 VISIT_AND_RETURN(Yield, yield)
3601 } 3583 }
3602 3584
3603 Throw* NewThrow(Expression* exception, int pos) { 3585 Throw* NewThrow(Expression* exception, int pos) {
3604 Throw* t = new (zone_) Throw(zone_, exception, pos, id_gen_); 3586 Throw* t = new (zone_) Throw(zone_, exception, pos);
3605 VISIT_AND_RETURN(Throw, t) 3587 VISIT_AND_RETURN(Throw, t)
3606 } 3588 }
3607 3589
3608 FunctionLiteral* NewFunctionLiteral( 3590 FunctionLiteral* NewFunctionLiteral(
3609 const AstRawString* name, AstValueFactory* ast_value_factory, 3591 const AstRawString* name, AstValueFactory* ast_value_factory,
3610 Scope* scope, ZoneList<Statement*>* body, int materialized_literal_count, 3592 Scope* scope, ZoneList<Statement*>* body, int materialized_literal_count,
3611 int expected_property_count, int handler_count, int parameter_count, 3593 int expected_property_count, int handler_count, int parameter_count,
3612 FunctionLiteral::ParameterFlag has_duplicate_parameters, 3594 FunctionLiteral::ParameterFlag has_duplicate_parameters,
3613 FunctionLiteral::FunctionType function_type, 3595 FunctionLiteral::FunctionType function_type,
3614 FunctionLiteral::IsFunctionFlag is_function, 3596 FunctionLiteral::IsFunctionFlag is_function,
3615 FunctionLiteral::IsParenthesizedFlag is_parenthesized, FunctionKind kind, 3597 FunctionLiteral::IsParenthesizedFlag is_parenthesized, FunctionKind kind,
3616 int position) { 3598 int position) {
3617 FunctionLiteral* lit = new (zone_) FunctionLiteral( 3599 FunctionLiteral* lit = new (zone_) FunctionLiteral(
3618 zone_, name, ast_value_factory, scope, body, materialized_literal_count, 3600 zone_, name, ast_value_factory, scope, body, materialized_literal_count,
3619 expected_property_count, handler_count, parameter_count, function_type, 3601 expected_property_count, handler_count, parameter_count, function_type,
3620 has_duplicate_parameters, is_function, is_parenthesized, kind, position, 3602 has_duplicate_parameters, is_function, is_parenthesized, kind,
3621 id_gen_); 3603 position);
3622 // Top-level literal doesn't count for the AST's properties. 3604 // Top-level literal doesn't count for the AST's properties.
3623 if (is_function == FunctionLiteral::kIsFunction) { 3605 if (is_function == FunctionLiteral::kIsFunction) {
3624 visitor_.VisitFunctionLiteral(lit); 3606 visitor_.VisitFunctionLiteral(lit);
3625 } 3607 }
3626 return lit; 3608 return lit;
3627 } 3609 }
3628 3610
3629 ClassLiteral* NewClassLiteral(const AstRawString* name, Expression* extends, 3611 ClassLiteral* NewClassLiteral(const AstRawString* name, Expression* extends,
3630 Expression* constructor, 3612 Expression* constructor,
3631 ZoneList<ObjectLiteral::Property*>* properties, 3613 ZoneList<ObjectLiteral::Property*>* properties,
3632 int start_position, int end_position) { 3614 int start_position, int end_position) {
3633 ClassLiteral* lit = 3615 ClassLiteral* lit =
3634 new (zone_) ClassLiteral(zone_, name, extends, constructor, properties, 3616 new (zone_) ClassLiteral(zone_, name, extends, constructor, properties,
3635 start_position, end_position, id_gen_); 3617 start_position, end_position);
3636 VISIT_AND_RETURN(ClassLiteral, lit) 3618 VISIT_AND_RETURN(ClassLiteral, lit)
3637 } 3619 }
3638 3620
3639 NativeFunctionLiteral* NewNativeFunctionLiteral(const AstRawString* name, 3621 NativeFunctionLiteral* NewNativeFunctionLiteral(const AstRawString* name,
3640 v8::Extension* extension, 3622 v8::Extension* extension,
3641 int pos) { 3623 int pos) {
3642 NativeFunctionLiteral* lit = 3624 NativeFunctionLiteral* lit =
3643 new (zone_) NativeFunctionLiteral(zone_, name, extension, pos, id_gen_); 3625 new (zone_) NativeFunctionLiteral(zone_, name, extension, pos);
3644 VISIT_AND_RETURN(NativeFunctionLiteral, lit) 3626 VISIT_AND_RETURN(NativeFunctionLiteral, lit)
3645 } 3627 }
3646 3628
3647 ThisFunction* NewThisFunction(int pos) { 3629 ThisFunction* NewThisFunction(int pos) {
3648 ThisFunction* fun = new (zone_) ThisFunction(zone_, pos, id_gen_); 3630 ThisFunction* fun = new (zone_) ThisFunction(zone_, pos);
3649 VISIT_AND_RETURN(ThisFunction, fun) 3631 VISIT_AND_RETURN(ThisFunction, fun)
3650 } 3632 }
3651 3633
3652 SuperReference* NewSuperReference(VariableProxy* this_var, int pos) { 3634 SuperReference* NewSuperReference(VariableProxy* this_var, int pos) {
3653 SuperReference* super = 3635 SuperReference* super = new (zone_) SuperReference(zone_, this_var, pos);
3654 new (zone_) SuperReference(zone_, this_var, pos, id_gen_);
3655 VISIT_AND_RETURN(SuperReference, super); 3636 VISIT_AND_RETURN(SuperReference, super);
3656 } 3637 }
3657 3638
3658 #undef VISIT_AND_RETURN 3639 #undef VISIT_AND_RETURN
3659 3640
3660 private: 3641 private:
3661 Zone* zone_; 3642 Zone* zone_;
3662 Visitor visitor_; 3643 Visitor visitor_;
3663 AstValueFactory* ast_value_factory_; 3644 AstValueFactory* ast_value_factory_;
3664 AstNode::IdGen* id_gen_;
3665 }; 3645 };
3666 3646
3667 3647
3668 } } // namespace v8::internal 3648 } } // namespace v8::internal
3669 3649
3670 #endif // V8_AST_H_ 3650 #endif // V8_AST_H_
OLDNEW
« no previous file with comments | « BUILD.gn ('k') | src/ast.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698