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

Side by Side Diff: src/ast/ast.h

Issue 2222473002: [ast] Remove obsolete DECLARE_NODE_TYPE macro. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Address comment. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | 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_AST_H_ 5 #ifndef V8_AST_AST_H_
6 #define V8_AST_AST_H_ 6 #define V8_AST_AST_H_
7 7
8 #include "src/ast/ast-value-factory.h" 8 #include "src/ast/ast-value-factory.h"
9 #include "src/ast/modules.h" 9 #include "src/ast/modules.h"
10 #include "src/ast/variables.h" 10 #include "src/ast/variables.h"
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 #define DEF_FORWARD_DECLARATION(type) class type; 124 #define DEF_FORWARD_DECLARATION(type) class type;
125 AST_NODE_LIST(DEF_FORWARD_DECLARATION) 125 AST_NODE_LIST(DEF_FORWARD_DECLARATION)
126 #undef DEF_FORWARD_DECLARATION 126 #undef DEF_FORWARD_DECLARATION
127 127
128 128
129 // Typedef only introduced to avoid unreadable code. 129 // Typedef only introduced to avoid unreadable code.
130 typedef ZoneList<Handle<String>> ZoneStringList; 130 typedef ZoneList<Handle<String>> ZoneStringList;
131 typedef ZoneList<Handle<Object>> ZoneObjectList; 131 typedef ZoneList<Handle<Object>> ZoneObjectList;
132 132
133 133
134 #define DECLARE_NODE_TYPE(type) \
135 friend class AstNodeFactory;
136
137
138 class FeedbackVectorSlotCache { 134 class FeedbackVectorSlotCache {
139 public: 135 public:
140 explicit FeedbackVectorSlotCache(Zone* zone) 136 explicit FeedbackVectorSlotCache(Zone* zone)
141 : zone_(zone), 137 : zone_(zone),
142 hash_map_(base::HashMap::PointersMatch, 138 hash_map_(base::HashMap::PointersMatch,
143 ZoneHashMap::kDefaultHashMapCapacity, 139 ZoneHashMap::kDefaultHashMapCapacity,
144 ZoneAllocationPolicy(zone)) {} 140 ZoneAllocationPolicy(zone)) {}
145 141
146 void Put(Variable* variable, FeedbackVectorSlot slot) { 142 void Put(Variable* variable, FeedbackVectorSlot slot) {
147 ZoneHashMap::Entry* entry = hash_map_.LookupOrInsert( 143 ZoneHashMap::Entry* entry = hash_map_.LookupOrInsert(
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 void set_base_id(int id) { base_id_ = id; } 350 void set_base_id(int id) { base_id_ = id; }
355 static int num_ids() { return parent_num_ids() + 2; } 351 static int num_ids() { return parent_num_ids() + 2; }
356 BailoutId id() const { return BailoutId(local_id(0)); } 352 BailoutId id() const { return BailoutId(local_id(0)); }
357 TypeFeedbackId test_id() const { return TypeFeedbackId(local_id(1)); } 353 TypeFeedbackId test_id() const { return TypeFeedbackId(local_id(1)); }
358 354
359 protected: 355 protected:
360 Expression(Zone* zone, int pos, NodeType type) 356 Expression(Zone* zone, int pos, NodeType type)
361 : AstNode(pos, type), 357 : AstNode(pos, type),
362 bit_field_(0), 358 bit_field_(0),
363 base_id_(BailoutId::None().ToInt()) {} 359 base_id_(BailoutId::None().ToInt()) {}
360
364 static int parent_num_ids() { return 0; } 361 static int parent_num_ids() { return 0; }
365 void set_to_boolean_types(uint16_t types) { 362 void set_to_boolean_types(uint16_t types) {
366 bit_field_ = ToBooleanTypesField::update(bit_field_, types); 363 bit_field_ = ToBooleanTypesField::update(bit_field_, types);
367 } 364 }
368
369 int base_id() const { 365 int base_id() const {
370 DCHECK(!BailoutId(base_id_).IsNone()); 366 DCHECK(!BailoutId(base_id_).IsNone());
371 return base_id_; 367 return base_id_;
372 } 368 }
373 369
374 private: 370 private:
375 int local_id(int n) const { return base_id() + parent_num_ids() + n; } 371 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
376 372
377 uint16_t bit_field_; 373 uint16_t bit_field_;
378 int base_id_; 374 int base_id_;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 421
426 BreakableType breakable_type_; 422 BreakableType breakable_type_;
427 int base_id_; 423 int base_id_;
428 Label break_target_; 424 Label break_target_;
429 ZoneList<const AstRawString*>* labels_; 425 ZoneList<const AstRawString*>* labels_;
430 }; 426 };
431 427
432 428
433 class Block final : public BreakableStatement { 429 class Block final : public BreakableStatement {
434 public: 430 public:
435 DECLARE_NODE_TYPE(Block)
436
437 ZoneList<Statement*>* statements() { return &statements_; } 431 ZoneList<Statement*>* statements() { return &statements_; }
438 bool ignore_completion_value() const { return ignore_completion_value_; } 432 bool ignore_completion_value() const { return ignore_completion_value_; }
439 433
440 static int num_ids() { return parent_num_ids() + 1; } 434 static int num_ids() { return parent_num_ids() + 1; }
441 BailoutId DeclsId() const { return BailoutId(local_id(0)); } 435 BailoutId DeclsId() const { return BailoutId(local_id(0)); }
442 436
443 bool IsJump() const { 437 bool IsJump() const {
444 return !statements_.is_empty() && statements_.last()->IsJump() 438 return !statements_.is_empty() && statements_.last()->IsJump()
445 && labels() == NULL; // Good enough as an approximation... 439 && labels() == NULL; // Good enough as an approximation...
446 } 440 }
447 441
448 Scope* scope() const { return scope_; } 442 Scope* scope() const { return scope_; }
449 void set_scope(Scope* scope) { scope_ = scope; } 443 void set_scope(Scope* scope) { scope_ = scope; }
450 444
451 protected: 445 private:
446 friend class AstNodeFactory;
447
452 Block(Zone* zone, ZoneList<const AstRawString*>* labels, int capacity, 448 Block(Zone* zone, ZoneList<const AstRawString*>* labels, int capacity,
453 bool ignore_completion_value, int pos) 449 bool ignore_completion_value, int pos)
454 : BreakableStatement(zone, labels, TARGET_FOR_NAMED_ONLY, pos, kBlock), 450 : BreakableStatement(zone, labels, TARGET_FOR_NAMED_ONLY, pos, kBlock),
455 statements_(capacity, zone), 451 statements_(capacity, zone),
456 ignore_completion_value_(ignore_completion_value), 452 ignore_completion_value_(ignore_completion_value),
457 scope_(NULL) {} 453 scope_(NULL) {}
458 static int parent_num_ids() { return BreakableStatement::num_ids(); } 454 static int parent_num_ids() { return BreakableStatement::num_ids(); }
459
460 private:
461 int local_id(int n) const { return base_id() + parent_num_ids() + n; } 455 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
462 456
463 ZoneList<Statement*> statements_; 457 ZoneList<Statement*> statements_;
464 bool ignore_completion_value_; 458 bool ignore_completion_value_;
465 Scope* scope_; 459 Scope* scope_;
466 }; 460 };
467 461
468 462
469 class DoExpression final : public Expression { 463 class DoExpression final : public Expression {
470 public: 464 public:
471 DECLARE_NODE_TYPE(DoExpression)
472
473 Block* block() { return block_; } 465 Block* block() { return block_; }
474 void set_block(Block* b) { block_ = b; } 466 void set_block(Block* b) { block_ = b; }
475 VariableProxy* result() { return result_; } 467 VariableProxy* result() { return result_; }
476 void set_result(VariableProxy* v) { result_ = v; } 468 void set_result(VariableProxy* v) { result_ = v; }
477 FunctionLiteral* represented_function() { return represented_function_; } 469 FunctionLiteral* represented_function() { return represented_function_; }
478 void set_represented_function(FunctionLiteral* f) { 470 void set_represented_function(FunctionLiteral* f) {
479 represented_function_ = f; 471 represented_function_ = f;
480 } 472 }
481 bool IsAnonymousFunctionDefinition() const; 473 bool IsAnonymousFunctionDefinition() const;
482 474
483 protected: 475 private:
476 friend class AstNodeFactory;
477
484 DoExpression(Zone* zone, Block* block, VariableProxy* result, int pos) 478 DoExpression(Zone* zone, Block* block, VariableProxy* result, int pos)
485 : Expression(zone, pos, kDoExpression), 479 : Expression(zone, pos, kDoExpression),
486 block_(block), 480 block_(block),
487 result_(result), 481 result_(result),
488 represented_function_(nullptr) { 482 represented_function_(nullptr) {
489 DCHECK_NOT_NULL(block_); 483 DCHECK_NOT_NULL(block_);
490 DCHECK_NOT_NULL(result_); 484 DCHECK_NOT_NULL(result_);
491 } 485 }
492 static int parent_num_ids() { return Expression::num_ids(); } 486 static int parent_num_ids() { return Expression::num_ids(); }
493
494 private:
495 int local_id(int n) const { return base_id() + parent_num_ids() + n; } 487 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
496 488
497 Block* block_; 489 Block* block_;
498 VariableProxy* result_; 490 VariableProxy* result_;
499 FunctionLiteral* represented_function_; 491 FunctionLiteral* represented_function_;
500 }; 492 };
501 493
502 494
503 class Declaration : public AstNode { 495 class Declaration : public AstNode {
504 public: 496 public:
(...skipping 13 matching lines...) Expand all
518 VariableMode mode_; 510 VariableMode mode_;
519 VariableProxy* proxy_; 511 VariableProxy* proxy_;
520 512
521 // Nested scope from which the declaration originated. 513 // Nested scope from which the declaration originated.
522 Scope* scope_; 514 Scope* scope_;
523 }; 515 };
524 516
525 517
526 class VariableDeclaration final : public Declaration { 518 class VariableDeclaration final : public Declaration {
527 public: 519 public:
528 DECLARE_NODE_TYPE(VariableDeclaration)
529
530 InitializationFlag initialization() const { 520 InitializationFlag initialization() const {
531 return mode() == VAR ? kCreatedInitialized : kNeedsInitialization; 521 return mode() == VAR ? kCreatedInitialized : kNeedsInitialization;
532 } 522 }
533 523
534 protected: 524 private:
525 friend class AstNodeFactory;
526
535 VariableDeclaration(VariableProxy* proxy, VariableMode mode, Scope* scope, 527 VariableDeclaration(VariableProxy* proxy, VariableMode mode, Scope* scope,
536 int pos) 528 int pos)
537 : Declaration(proxy, mode, scope, pos, kVariableDeclaration) {} 529 : Declaration(proxy, mode, scope, pos, kVariableDeclaration) {}
538 }; 530 };
539 531
540 532
541 class FunctionDeclaration final : public Declaration { 533 class FunctionDeclaration final : public Declaration {
542 public: 534 public:
543 DECLARE_NODE_TYPE(FunctionDeclaration)
544
545 FunctionLiteral* fun() const { return fun_; } 535 FunctionLiteral* fun() const { return fun_; }
546 void set_fun(FunctionLiteral* f) { fun_ = f; } 536 void set_fun(FunctionLiteral* f) { fun_ = f; }
547 InitializationFlag initialization() const { return kCreatedInitialized; } 537 InitializationFlag initialization() const { return kCreatedInitialized; }
548 538
549 protected: 539 private:
540 friend class AstNodeFactory;
541
550 FunctionDeclaration(VariableProxy* proxy, VariableMode mode, 542 FunctionDeclaration(VariableProxy* proxy, VariableMode mode,
551 FunctionLiteral* fun, Scope* scope, int pos) 543 FunctionLiteral* fun, Scope* scope, int pos)
552 : Declaration(proxy, mode, scope, pos, kFunctionDeclaration), fun_(fun) { 544 : Declaration(proxy, mode, scope, pos, kFunctionDeclaration), fun_(fun) {
553 DCHECK(mode == VAR || mode == LET || mode == CONST); 545 DCHECK(mode == VAR || mode == LET || mode == CONST);
554 DCHECK(fun != NULL); 546 DCHECK(fun != NULL);
555 } 547 }
556 548
557 private:
558 FunctionLiteral* fun_; 549 FunctionLiteral* fun_;
559 }; 550 };
560 551
561 552
562 class IterationStatement : public BreakableStatement { 553 class IterationStatement : public BreakableStatement {
563 public: 554 public:
564 Statement* body() const { return body_; } 555 Statement* body() const { return body_; }
565 void set_body(Statement* s) { body_ = s; } 556 void set_body(Statement* s) { body_ = s; }
566 557
567 int yield_count() const { return yield_count_; } 558 int yield_count() const { return yield_count_; }
(...skipping 24 matching lines...) Expand all
592 583
593 Statement* body_; 584 Statement* body_;
594 Label continue_target_; 585 Label continue_target_;
595 int yield_count_; 586 int yield_count_;
596 int first_yield_id_; 587 int first_yield_id_;
597 }; 588 };
598 589
599 590
600 class DoWhileStatement final : public IterationStatement { 591 class DoWhileStatement final : public IterationStatement {
601 public: 592 public:
602 DECLARE_NODE_TYPE(DoWhileStatement)
603
604 void Initialize(Expression* cond, Statement* body) { 593 void Initialize(Expression* cond, Statement* body) {
605 IterationStatement::Initialize(body); 594 IterationStatement::Initialize(body);
606 cond_ = cond; 595 cond_ = cond;
607 } 596 }
608 597
609 Expression* cond() const { return cond_; } 598 Expression* cond() const { return cond_; }
610 void set_cond(Expression* e) { cond_ = e; } 599 void set_cond(Expression* e) { cond_ = e; }
611 600
612 static int num_ids() { return parent_num_ids() + 2; } 601 static int num_ids() { return parent_num_ids() + 2; }
613 BailoutId ContinueId() const { return BailoutId(local_id(0)); } 602 BailoutId ContinueId() const { return BailoutId(local_id(0)); }
614 BailoutId StackCheckId() const { return BackEdgeId(); } 603 BailoutId StackCheckId() const { return BackEdgeId(); }
615 BailoutId BackEdgeId() const { return BailoutId(local_id(1)); } 604 BailoutId BackEdgeId() const { return BailoutId(local_id(1)); }
616 605
617 protected: 606 private:
607 friend class AstNodeFactory;
608
618 DoWhileStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) 609 DoWhileStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos)
619 : IterationStatement(zone, labels, pos, kDoWhileStatement), cond_(NULL) {} 610 : IterationStatement(zone, labels, pos, kDoWhileStatement), cond_(NULL) {}
620 static int parent_num_ids() { return IterationStatement::num_ids(); } 611 static int parent_num_ids() { return IterationStatement::num_ids(); }
621
622 private:
623 int local_id(int n) const { return base_id() + parent_num_ids() + n; } 612 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
624 613
625 Expression* cond_; 614 Expression* cond_;
626 }; 615 };
627 616
628 617
629 class WhileStatement final : public IterationStatement { 618 class WhileStatement final : public IterationStatement {
630 public: 619 public:
631 DECLARE_NODE_TYPE(WhileStatement)
632
633 void Initialize(Expression* cond, Statement* body) { 620 void Initialize(Expression* cond, Statement* body) {
634 IterationStatement::Initialize(body); 621 IterationStatement::Initialize(body);
635 cond_ = cond; 622 cond_ = cond;
636 } 623 }
637 624
638 Expression* cond() const { return cond_; } 625 Expression* cond() const { return cond_; }
639 void set_cond(Expression* e) { cond_ = e; } 626 void set_cond(Expression* e) { cond_ = e; }
640 627
641 static int num_ids() { return parent_num_ids() + 1; } 628 static int num_ids() { return parent_num_ids() + 1; }
642 BailoutId ContinueId() const { return EntryId(); } 629 BailoutId ContinueId() const { return EntryId(); }
643 BailoutId StackCheckId() const { return BodyId(); } 630 BailoutId StackCheckId() const { return BodyId(); }
644 BailoutId BodyId() const { return BailoutId(local_id(0)); } 631 BailoutId BodyId() const { return BailoutId(local_id(0)); }
645 632
646 protected: 633 private:
634 friend class AstNodeFactory;
635
647 WhileStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) 636 WhileStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos)
648 : IterationStatement(zone, labels, pos, kWhileStatement), cond_(NULL) {} 637 : IterationStatement(zone, labels, pos, kWhileStatement), cond_(NULL) {}
649 static int parent_num_ids() { return IterationStatement::num_ids(); } 638 static int parent_num_ids() { return IterationStatement::num_ids(); }
650
651 private:
652 int local_id(int n) const { return base_id() + parent_num_ids() + n; } 639 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
653 640
654 Expression* cond_; 641 Expression* cond_;
655 }; 642 };
656 643
657 644
658 class ForStatement final : public IterationStatement { 645 class ForStatement final : public IterationStatement {
659 public: 646 public:
660 DECLARE_NODE_TYPE(ForStatement)
661
662 void Initialize(Statement* init, 647 void Initialize(Statement* init,
663 Expression* cond, 648 Expression* cond,
664 Statement* next, 649 Statement* next,
665 Statement* body) { 650 Statement* body) {
666 IterationStatement::Initialize(body); 651 IterationStatement::Initialize(body);
667 init_ = init; 652 init_ = init;
668 cond_ = cond; 653 cond_ = cond;
669 next_ = next; 654 next_ = next;
670 } 655 }
671 656
672 Statement* init() const { return init_; } 657 Statement* init() const { return init_; }
673 Expression* cond() const { return cond_; } 658 Expression* cond() const { return cond_; }
674 Statement* next() const { return next_; } 659 Statement* next() const { return next_; }
675 660
676 void set_init(Statement* s) { init_ = s; } 661 void set_init(Statement* s) { init_ = s; }
677 void set_cond(Expression* e) { cond_ = e; } 662 void set_cond(Expression* e) { cond_ = e; }
678 void set_next(Statement* s) { next_ = s; } 663 void set_next(Statement* s) { next_ = s; }
679 664
680 static int num_ids() { return parent_num_ids() + 2; } 665 static int num_ids() { return parent_num_ids() + 2; }
681 BailoutId ContinueId() const { return BailoutId(local_id(0)); } 666 BailoutId ContinueId() const { return BailoutId(local_id(0)); }
682 BailoutId StackCheckId() const { return BodyId(); } 667 BailoutId StackCheckId() const { return BodyId(); }
683 BailoutId BodyId() const { return BailoutId(local_id(1)); } 668 BailoutId BodyId() const { return BailoutId(local_id(1)); }
684 669
685 protected: 670 private:
671 friend class AstNodeFactory;
672
686 ForStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) 673 ForStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos)
687 : IterationStatement(zone, labels, pos, kForStatement), 674 : IterationStatement(zone, labels, pos, kForStatement),
688 init_(NULL), 675 init_(NULL),
689 cond_(NULL), 676 cond_(NULL),
690 next_(NULL) {} 677 next_(NULL) {}
691 static int parent_num_ids() { return IterationStatement::num_ids(); } 678 static int parent_num_ids() { return IterationStatement::num_ids(); }
692
693 private:
694 int local_id(int n) const { return base_id() + parent_num_ids() + n; } 679 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
695 680
696 Statement* init_; 681 Statement* init_;
697 Expression* cond_; 682 Expression* cond_;
698 Statement* next_; 683 Statement* next_;
699 }; 684 };
700 685
701 686
702 class ForEachStatement : public IterationStatement { 687 class ForEachStatement : public IterationStatement {
703 public: 688 public:
(...skipping 10 matching lines...) Expand all
714 699
715 protected: 700 protected:
716 ForEachStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos, 701 ForEachStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos,
717 NodeType type) 702 NodeType type)
718 : IterationStatement(zone, labels, pos, type) {} 703 : IterationStatement(zone, labels, pos, type) {}
719 }; 704 };
720 705
721 706
722 class ForInStatement final : public ForEachStatement { 707 class ForInStatement final : public ForEachStatement {
723 public: 708 public:
724 DECLARE_NODE_TYPE(ForInStatement)
725
726 void Initialize(Expression* each, Expression* subject, Statement* body) { 709 void Initialize(Expression* each, Expression* subject, Statement* body) {
727 ForEachStatement::Initialize(body); 710 ForEachStatement::Initialize(body);
728 each_ = each; 711 each_ = each;
729 subject_ = subject; 712 subject_ = subject;
730 } 713 }
731 714
732 Expression* enumerable() const { 715 Expression* enumerable() const {
733 return subject(); 716 return subject();
734 } 717 }
735 718
(...skipping 19 matching lines...) Expand all
755 static int num_ids() { return parent_num_ids() + 6; } 738 static int num_ids() { return parent_num_ids() + 6; }
756 BailoutId BodyId() const { return BailoutId(local_id(0)); } 739 BailoutId BodyId() const { return BailoutId(local_id(0)); }
757 BailoutId EnumId() const { return BailoutId(local_id(1)); } 740 BailoutId EnumId() const { return BailoutId(local_id(1)); }
758 BailoutId ToObjectId() const { return BailoutId(local_id(2)); } 741 BailoutId ToObjectId() const { return BailoutId(local_id(2)); }
759 BailoutId PrepareId() const { return BailoutId(local_id(3)); } 742 BailoutId PrepareId() const { return BailoutId(local_id(3)); }
760 BailoutId FilterId() const { return BailoutId(local_id(4)); } 743 BailoutId FilterId() const { return BailoutId(local_id(4)); }
761 BailoutId AssignmentId() const { return BailoutId(local_id(5)); } 744 BailoutId AssignmentId() const { return BailoutId(local_id(5)); }
762 BailoutId ContinueId() const { return EntryId(); } 745 BailoutId ContinueId() const { return EntryId(); }
763 BailoutId StackCheckId() const { return BodyId(); } 746 BailoutId StackCheckId() const { return BodyId(); }
764 747
765 protected: 748 private:
749 friend class AstNodeFactory;
750
766 ForInStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) 751 ForInStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos)
767 : ForEachStatement(zone, labels, pos, kForInStatement), 752 : ForEachStatement(zone, labels, pos, kForInStatement),
768 each_(nullptr), 753 each_(nullptr),
769 subject_(nullptr), 754 subject_(nullptr),
770 for_in_type_(SLOW_FOR_IN) {} 755 for_in_type_(SLOW_FOR_IN) {}
771 static int parent_num_ids() { return ForEachStatement::num_ids(); } 756 static int parent_num_ids() { return ForEachStatement::num_ids(); }
772
773 private:
774 int local_id(int n) const { return base_id() + parent_num_ids() + n; } 757 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
775 758
776 Expression* each_; 759 Expression* each_;
777 Expression* subject_; 760 Expression* subject_;
778 ForInType for_in_type_; 761 ForInType for_in_type_;
779 FeedbackVectorSlot each_slot_; 762 FeedbackVectorSlot each_slot_;
780 FeedbackVectorSlot for_in_feedback_slot_; 763 FeedbackVectorSlot for_in_feedback_slot_;
781 }; 764 };
782 765
783 766
784 class ForOfStatement final : public ForEachStatement { 767 class ForOfStatement final : public ForEachStatement {
785 public: 768 public:
786 DECLARE_NODE_TYPE(ForOfStatement)
787
788 void Initialize(Statement* body, Variable* iterator, 769 void Initialize(Statement* body, Variable* iterator,
789 Expression* assign_iterator, Expression* next_result, 770 Expression* assign_iterator, Expression* next_result,
790 Expression* result_done, Expression* assign_each) { 771 Expression* result_done, Expression* assign_each) {
791 ForEachStatement::Initialize(body); 772 ForEachStatement::Initialize(body);
792 iterator_ = iterator; 773 iterator_ = iterator;
793 assign_iterator_ = assign_iterator; 774 assign_iterator_ = assign_iterator;
794 next_result_ = next_result; 775 next_result_ = next_result;
795 result_done_ = result_done; 776 result_done_ = result_done;
796 assign_each_ = assign_each; 777 assign_each_ = assign_each;
797 } 778 }
(...skipping 26 matching lines...) Expand all
824 void set_next_result(Expression* e) { next_result_ = e; } 805 void set_next_result(Expression* e) { next_result_ = e; }
825 void set_result_done(Expression* e) { result_done_ = e; } 806 void set_result_done(Expression* e) { result_done_ = e; }
826 void set_assign_each(Expression* e) { assign_each_ = e; } 807 void set_assign_each(Expression* e) { assign_each_ = e; }
827 808
828 BailoutId ContinueId() const { return EntryId(); } 809 BailoutId ContinueId() const { return EntryId(); }
829 BailoutId StackCheckId() const { return BackEdgeId(); } 810 BailoutId StackCheckId() const { return BackEdgeId(); }
830 811
831 static int num_ids() { return parent_num_ids() + 1; } 812 static int num_ids() { return parent_num_ids() + 1; }
832 BailoutId BackEdgeId() const { return BailoutId(local_id(0)); } 813 BailoutId BackEdgeId() const { return BailoutId(local_id(0)); }
833 814
834 protected: 815 private:
816 friend class AstNodeFactory;
817
835 ForOfStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) 818 ForOfStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos)
836 : ForEachStatement(zone, labels, pos, kForOfStatement), 819 : ForEachStatement(zone, labels, pos, kForOfStatement),
837 iterator_(NULL), 820 iterator_(NULL),
838 assign_iterator_(NULL), 821 assign_iterator_(NULL),
839 next_result_(NULL), 822 next_result_(NULL),
840 result_done_(NULL), 823 result_done_(NULL),
841 assign_each_(NULL) {} 824 assign_each_(NULL) {}
842 static int parent_num_ids() { return ForEachStatement::num_ids(); } 825 static int parent_num_ids() { return ForEachStatement::num_ids(); }
843
844 private:
845 int local_id(int n) const { return base_id() + parent_num_ids() + n; } 826 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
846 827
847 Variable* iterator_; 828 Variable* iterator_;
848 Expression* assign_iterator_; 829 Expression* assign_iterator_;
849 Expression* next_result_; 830 Expression* next_result_;
850 Expression* result_done_; 831 Expression* result_done_;
851 Expression* assign_each_; 832 Expression* assign_each_;
852 }; 833 };
853 834
854 835
855 class ExpressionStatement final : public Statement { 836 class ExpressionStatement final : public Statement {
856 public: 837 public:
857 DECLARE_NODE_TYPE(ExpressionStatement)
858
859 void set_expression(Expression* e) { expression_ = e; } 838 void set_expression(Expression* e) { expression_ = e; }
860 Expression* expression() const { return expression_; } 839 Expression* expression() const { return expression_; }
861 bool IsJump() const { return expression_->IsThrow(); } 840 bool IsJump() const { return expression_->IsThrow(); }
862 841
863 protected: 842 private:
843 friend class AstNodeFactory;
844
864 ExpressionStatement(Zone* zone, Expression* expression, int pos) 845 ExpressionStatement(Zone* zone, Expression* expression, int pos)
865 : Statement(zone, pos, kExpressionStatement), expression_(expression) {} 846 : Statement(zone, pos, kExpressionStatement), expression_(expression) {}
866 847
867 private:
868 Expression* expression_; 848 Expression* expression_;
869 }; 849 };
870 850
871 851
872 class JumpStatement : public Statement { 852 class JumpStatement : public Statement {
873 public: 853 public:
874 bool IsJump() const { return true; } 854 bool IsJump() const { return true; }
875 855
876 protected: 856 protected:
877 JumpStatement(Zone* zone, int pos, NodeType type) 857 JumpStatement(Zone* zone, int pos, NodeType type)
878 : Statement(zone, pos, type) {} 858 : Statement(zone, pos, type) {}
879 }; 859 };
880 860
881 861
882 class ContinueStatement final : public JumpStatement { 862 class ContinueStatement final : public JumpStatement {
883 public: 863 public:
884 DECLARE_NODE_TYPE(ContinueStatement)
885
886 IterationStatement* target() const { return target_; } 864 IterationStatement* target() const { return target_; }
887 865
888 protected: 866 private:
867 friend class AstNodeFactory;
868
889 ContinueStatement(Zone* zone, IterationStatement* target, int pos) 869 ContinueStatement(Zone* zone, IterationStatement* target, int pos)
890 : JumpStatement(zone, pos, kContinueStatement), target_(target) {} 870 : JumpStatement(zone, pos, kContinueStatement), target_(target) {}
891 871
892 private:
893 IterationStatement* target_; 872 IterationStatement* target_;
894 }; 873 };
895 874
896 875
897 class BreakStatement final : public JumpStatement { 876 class BreakStatement final : public JumpStatement {
898 public: 877 public:
899 DECLARE_NODE_TYPE(BreakStatement)
900
901 BreakableStatement* target() const { return target_; } 878 BreakableStatement* target() const { return target_; }
902 879
903 protected: 880 private:
881 friend class AstNodeFactory;
882
904 BreakStatement(Zone* zone, BreakableStatement* target, int pos) 883 BreakStatement(Zone* zone, BreakableStatement* target, int pos)
905 : JumpStatement(zone, pos, kBreakStatement), target_(target) {} 884 : JumpStatement(zone, pos, kBreakStatement), target_(target) {}
906 885
907 private:
908 BreakableStatement* target_; 886 BreakableStatement* target_;
909 }; 887 };
910 888
911 889
912 class ReturnStatement final : public JumpStatement { 890 class ReturnStatement final : public JumpStatement {
913 public: 891 public:
914 DECLARE_NODE_TYPE(ReturnStatement)
915
916 Expression* expression() const { return expression_; } 892 Expression* expression() const { return expression_; }
917 893
918 void set_expression(Expression* e) { expression_ = e; } 894 void set_expression(Expression* e) { expression_ = e; }
919 895
920 protected: 896 private:
897 friend class AstNodeFactory;
898
921 ReturnStatement(Zone* zone, Expression* expression, int pos) 899 ReturnStatement(Zone* zone, Expression* expression, int pos)
922 : JumpStatement(zone, pos, kReturnStatement), expression_(expression) {} 900 : JumpStatement(zone, pos, kReturnStatement), expression_(expression) {}
923 901
924 private:
925 Expression* expression_; 902 Expression* expression_;
926 }; 903 };
927 904
928 905
929 class WithStatement final : public Statement { 906 class WithStatement final : public Statement {
930 public: 907 public:
931 DECLARE_NODE_TYPE(WithStatement)
932
933 Scope* scope() { return scope_; } 908 Scope* scope() { return scope_; }
934 Expression* expression() const { return expression_; } 909 Expression* expression() const { return expression_; }
935 void set_expression(Expression* e) { expression_ = e; } 910 void set_expression(Expression* e) { expression_ = e; }
936 Statement* statement() const { return statement_; } 911 Statement* statement() const { return statement_; }
937 void set_statement(Statement* s) { statement_ = s; } 912 void set_statement(Statement* s) { statement_ = s; }
938 913
939 void set_base_id(int id) { base_id_ = id; } 914 void set_base_id(int id) { base_id_ = id; }
940 static int num_ids() { return parent_num_ids() + 2; } 915 static int num_ids() { return parent_num_ids() + 2; }
941 BailoutId ToObjectId() const { return BailoutId(local_id(0)); } 916 BailoutId ToObjectId() const { return BailoutId(local_id(0)); }
942 BailoutId EntryId() const { return BailoutId(local_id(1)); } 917 BailoutId EntryId() const { return BailoutId(local_id(1)); }
943 918
944 protected: 919 private:
920 friend class AstNodeFactory;
921
945 WithStatement(Zone* zone, Scope* scope, Expression* expression, 922 WithStatement(Zone* zone, Scope* scope, Expression* expression,
946 Statement* statement, int pos) 923 Statement* statement, int pos)
947 : Statement(zone, pos, kWithStatement), 924 : Statement(zone, pos, kWithStatement),
948 base_id_(BailoutId::None().ToInt()), 925 base_id_(BailoutId::None().ToInt()),
949 scope_(scope), 926 scope_(scope),
950 expression_(expression), 927 expression_(expression),
951 statement_(statement) {} 928 statement_(statement) {}
929
952 static int parent_num_ids() { return 0; } 930 static int parent_num_ids() { return 0; }
953
954 int base_id() const { 931 int base_id() const {
955 DCHECK(!BailoutId(base_id_).IsNone()); 932 DCHECK(!BailoutId(base_id_).IsNone());
956 return base_id_; 933 return base_id_;
957 } 934 }
958
959 private:
960 int local_id(int n) const { return base_id() + parent_num_ids() + n; } 935 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
961 936
962 int base_id_; 937 int base_id_;
963 Scope* scope_; 938 Scope* scope_;
964 Expression* expression_; 939 Expression* expression_;
965 Statement* statement_; 940 Statement* statement_;
966 }; 941 };
967 942
968 943
969 class CaseClause final : public Expression { 944 class CaseClause final : public Expression {
970 public: 945 public:
971 DECLARE_NODE_TYPE(CaseClause)
972
973 bool is_default() const { return label_ == NULL; } 946 bool is_default() const { return label_ == NULL; }
974 Expression* label() const { 947 Expression* label() const {
975 CHECK(!is_default()); 948 CHECK(!is_default());
976 return label_; 949 return label_;
977 } 950 }
978 void set_label(Expression* e) { label_ = e; } 951 void set_label(Expression* e) { label_ = e; }
979 Label* body_target() { return &body_target_; } 952 Label* body_target() { return &body_target_; }
980 ZoneList<Statement*>* statements() const { return statements_; } 953 ZoneList<Statement*>* statements() const { return statements_; }
981 954
982 static int num_ids() { return parent_num_ids() + 2; } 955 static int num_ids() { return parent_num_ids() + 2; }
983 BailoutId EntryId() const { return BailoutId(local_id(0)); } 956 BailoutId EntryId() const { return BailoutId(local_id(0)); }
984 TypeFeedbackId CompareId() { return TypeFeedbackId(local_id(1)); } 957 TypeFeedbackId CompareId() { return TypeFeedbackId(local_id(1)); }
985 958
986 Type* compare_type() { return compare_type_; } 959 Type* compare_type() { return compare_type_; }
987 void set_compare_type(Type* type) { compare_type_ = type; } 960 void set_compare_type(Type* type) { compare_type_ = type; }
988 961
989 protected: 962 private:
963 friend class AstNodeFactory;
964
990 static int parent_num_ids() { return Expression::num_ids(); } 965 static int parent_num_ids() { return Expression::num_ids(); }
991
992 private:
993 CaseClause(Zone* zone, Expression* label, ZoneList<Statement*>* statements, 966 CaseClause(Zone* zone, Expression* label, ZoneList<Statement*>* statements,
994 int pos); 967 int pos);
995 int local_id(int n) const { return base_id() + parent_num_ids() + n; } 968 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
996 969
997 Expression* label_; 970 Expression* label_;
998 Label body_target_; 971 Label body_target_;
999 ZoneList<Statement*>* statements_; 972 ZoneList<Statement*>* statements_;
1000 Type* compare_type_; 973 Type* compare_type_;
1001 }; 974 };
1002 975
1003 976
1004 class SwitchStatement final : public BreakableStatement { 977 class SwitchStatement final : public BreakableStatement {
1005 public: 978 public:
1006 DECLARE_NODE_TYPE(SwitchStatement)
1007
1008 void Initialize(Expression* tag, ZoneList<CaseClause*>* cases) { 979 void Initialize(Expression* tag, ZoneList<CaseClause*>* cases) {
1009 tag_ = tag; 980 tag_ = tag;
1010 cases_ = cases; 981 cases_ = cases;
1011 } 982 }
1012 983
1013 Expression* tag() const { return tag_; } 984 Expression* tag() const { return tag_; }
1014 ZoneList<CaseClause*>* cases() const { return cases_; } 985 ZoneList<CaseClause*>* cases() const { return cases_; }
1015 986
1016 void set_tag(Expression* t) { tag_ = t; } 987 void set_tag(Expression* t) { tag_ = t; }
1017 988
1018 protected: 989 private:
990 friend class AstNodeFactory;
991
1019 SwitchStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) 992 SwitchStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos)
1020 : BreakableStatement(zone, labels, TARGET_FOR_ANONYMOUS, pos, 993 : BreakableStatement(zone, labels, TARGET_FOR_ANONYMOUS, pos,
1021 kSwitchStatement), 994 kSwitchStatement),
1022 tag_(NULL), 995 tag_(NULL),
1023 cases_(NULL) {} 996 cases_(NULL) {}
1024 997
1025 private:
1026 Expression* tag_; 998 Expression* tag_;
1027 ZoneList<CaseClause*>* cases_; 999 ZoneList<CaseClause*>* cases_;
1028 }; 1000 };
1029 1001
1030 1002
1031 // If-statements always have non-null references to their then- and 1003 // If-statements always have non-null references to their then- and
1032 // else-parts. When parsing if-statements with no explicit else-part, 1004 // else-parts. When parsing if-statements with no explicit else-part,
1033 // the parser implicitly creates an empty statement. Use the 1005 // the parser implicitly creates an empty statement. Use the
1034 // HasThenStatement() and HasElseStatement() functions to check if a 1006 // HasThenStatement() and HasElseStatement() functions to check if a
1035 // given if-statement has a then- or an else-part containing code. 1007 // given if-statement has a then- or an else-part containing code.
1036 class IfStatement final : public Statement { 1008 class IfStatement final : public Statement {
1037 public: 1009 public:
1038 DECLARE_NODE_TYPE(IfStatement)
1039
1040 bool HasThenStatement() const { return !then_statement()->IsEmpty(); } 1010 bool HasThenStatement() const { return !then_statement()->IsEmpty(); }
1041 bool HasElseStatement() const { return !else_statement()->IsEmpty(); } 1011 bool HasElseStatement() const { return !else_statement()->IsEmpty(); }
1042 1012
1043 Expression* condition() const { return condition_; } 1013 Expression* condition() const { return condition_; }
1044 Statement* then_statement() const { return then_statement_; } 1014 Statement* then_statement() const { return then_statement_; }
1045 Statement* else_statement() const { return else_statement_; } 1015 Statement* else_statement() const { return else_statement_; }
1046 1016
1047 void set_condition(Expression* e) { condition_ = e; } 1017 void set_condition(Expression* e) { condition_ = e; }
1048 void set_then_statement(Statement* s) { then_statement_ = s; } 1018 void set_then_statement(Statement* s) { then_statement_ = s; }
1049 void set_else_statement(Statement* s) { else_statement_ = s; } 1019 void set_else_statement(Statement* s) { else_statement_ = s; }
1050 1020
1051 bool IsJump() const { 1021 bool IsJump() const {
1052 return HasThenStatement() && then_statement()->IsJump() 1022 return HasThenStatement() && then_statement()->IsJump()
1053 && HasElseStatement() && else_statement()->IsJump(); 1023 && HasElseStatement() && else_statement()->IsJump();
1054 } 1024 }
1055 1025
1056 void set_base_id(int id) { base_id_ = id; } 1026 void set_base_id(int id) { base_id_ = id; }
1057 static int num_ids() { return parent_num_ids() + 3; } 1027 static int num_ids() { return parent_num_ids() + 3; }
1058 BailoutId IfId() const { return BailoutId(local_id(0)); } 1028 BailoutId IfId() const { return BailoutId(local_id(0)); }
1059 BailoutId ThenId() const { return BailoutId(local_id(1)); } 1029 BailoutId ThenId() const { return BailoutId(local_id(1)); }
1060 BailoutId ElseId() const { return BailoutId(local_id(2)); } 1030 BailoutId ElseId() const { return BailoutId(local_id(2)); }
1061 1031
1062 protected: 1032 private:
1033 friend class AstNodeFactory;
1034
1063 IfStatement(Zone* zone, Expression* condition, Statement* then_statement, 1035 IfStatement(Zone* zone, Expression* condition, Statement* then_statement,
1064 Statement* else_statement, int pos) 1036 Statement* else_statement, int pos)
1065 : Statement(zone, pos, kIfStatement), 1037 : Statement(zone, pos, kIfStatement),
1066 base_id_(BailoutId::None().ToInt()), 1038 base_id_(BailoutId::None().ToInt()),
1067 condition_(condition), 1039 condition_(condition),
1068 then_statement_(then_statement), 1040 then_statement_(then_statement),
1069 else_statement_(else_statement) {} 1041 else_statement_(else_statement) {}
1042
1070 static int parent_num_ids() { return 0; } 1043 static int parent_num_ids() { return 0; }
1071
1072 int base_id() const { 1044 int base_id() const {
1073 DCHECK(!BailoutId(base_id_).IsNone()); 1045 DCHECK(!BailoutId(base_id_).IsNone());
1074 return base_id_; 1046 return base_id_;
1075 } 1047 }
1076
1077 private:
1078 int local_id(int n) const { return base_id() + parent_num_ids() + n; } 1048 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
1079 1049
1080 int base_id_; 1050 int base_id_;
1081 Expression* condition_; 1051 Expression* condition_;
1082 Statement* then_statement_; 1052 Statement* then_statement_;
1083 Statement* else_statement_; 1053 Statement* else_statement_;
1084 }; 1054 };
1085 1055
1086 1056
1087 class TryStatement : public Statement { 1057 class TryStatement : public Statement {
(...skipping 26 matching lines...) Expand all
1114 1084
1115 HandlerTable::CatchPrediction catch_prediction_; 1085 HandlerTable::CatchPrediction catch_prediction_;
1116 1086
1117 private: 1087 private:
1118 Block* try_block_; 1088 Block* try_block_;
1119 }; 1089 };
1120 1090
1121 1091
1122 class TryCatchStatement final : public TryStatement { 1092 class TryCatchStatement final : public TryStatement {
1123 public: 1093 public:
1124 DECLARE_NODE_TYPE(TryCatchStatement)
1125
1126 Scope* scope() { return scope_; } 1094 Scope* scope() { return scope_; }
1127 Variable* variable() { return variable_; } 1095 Variable* variable() { return variable_; }
1128 Block* catch_block() const { return catch_block_; } 1096 Block* catch_block() const { return catch_block_; }
1129 void set_catch_block(Block* b) { catch_block_ = b; } 1097 void set_catch_block(Block* b) { catch_block_ = b; }
1130 1098
1131 // The clear_pending_message flag indicates whether or not to clear the 1099 // The clear_pending_message flag indicates whether or not to clear the
1132 // isolate's pending exception message before executing the catch_block. In 1100 // isolate's pending exception message before executing the catch_block. In
1133 // the normal use case, this flag is always on because the message object 1101 // the normal use case, this flag is always on because the message object
1134 // is not needed anymore when entering the catch block and should not be kept 1102 // is not needed anymore when entering the catch block and should not be kept
1135 // alive. 1103 // alive.
1136 // The use case where the flag is off is when the catch block is guaranteed to 1104 // The use case where the flag is off is when the catch block is guaranteed to
1137 // rethrow the caught exception (using %ReThrow), which reuses the pending 1105 // rethrow the caught exception (using %ReThrow), which reuses the pending
1138 // message instead of generating a new one. 1106 // message instead of generating a new one.
1139 // (When the catch block doesn't rethrow but is guaranteed to perform an 1107 // (When the catch block doesn't rethrow but is guaranteed to perform an
1140 // ordinary throw, not clearing the old message is safe but not very useful.) 1108 // ordinary throw, not clearing the old message is safe but not very useful.)
1141 bool clear_pending_message() const { 1109 bool clear_pending_message() const {
1142 return catch_prediction_ != HandlerTable::UNCAUGHT; 1110 return catch_prediction_ != HandlerTable::UNCAUGHT;
1143 } 1111 }
1144 1112
1145 protected: 1113 private:
1114 friend class AstNodeFactory;
1115
1146 TryCatchStatement(Zone* zone, Block* try_block, Scope* scope, 1116 TryCatchStatement(Zone* zone, Block* try_block, Scope* scope,
1147 Variable* variable, Block* catch_block, 1117 Variable* variable, Block* catch_block,
1148 HandlerTable::CatchPrediction catch_prediction, int pos) 1118 HandlerTable::CatchPrediction catch_prediction, int pos)
1149 : TryStatement(zone, try_block, pos, kTryCatchStatement), 1119 : TryStatement(zone, try_block, pos, kTryCatchStatement),
1150 scope_(scope), 1120 scope_(scope),
1151 variable_(variable), 1121 variable_(variable),
1152 catch_block_(catch_block) { 1122 catch_block_(catch_block) {
1153 catch_prediction_ = catch_prediction; 1123 catch_prediction_ = catch_prediction;
1154 } 1124 }
1155 1125
1156 private:
1157 Scope* scope_; 1126 Scope* scope_;
1158 Variable* variable_; 1127 Variable* variable_;
1159 Block* catch_block_; 1128 Block* catch_block_;
1160 }; 1129 };
1161 1130
1162 1131
1163 class TryFinallyStatement final : public TryStatement { 1132 class TryFinallyStatement final : public TryStatement {
1164 public: 1133 public:
1165 DECLARE_NODE_TYPE(TryFinallyStatement)
1166
1167 Block* finally_block() const { return finally_block_; } 1134 Block* finally_block() const { return finally_block_; }
1168 void set_finally_block(Block* b) { finally_block_ = b; } 1135 void set_finally_block(Block* b) { finally_block_ = b; }
1169 1136
1170 protected: 1137 private:
1138 friend class AstNodeFactory;
1139
1171 TryFinallyStatement(Zone* zone, Block* try_block, Block* finally_block, 1140 TryFinallyStatement(Zone* zone, Block* try_block, Block* finally_block,
1172 int pos) 1141 int pos)
1173 : TryStatement(zone, try_block, pos, kTryFinallyStatement), 1142 : TryStatement(zone, try_block, pos, kTryFinallyStatement),
1174 finally_block_(finally_block) {} 1143 finally_block_(finally_block) {}
1175 1144
1176 private:
1177 Block* finally_block_; 1145 Block* finally_block_;
1178 }; 1146 };
1179 1147
1180 1148
1181 class DebuggerStatement final : public Statement { 1149 class DebuggerStatement final : public Statement {
1182 public: 1150 public:
1183 DECLARE_NODE_TYPE(DebuggerStatement)
1184
1185 void set_base_id(int id) { base_id_ = id; } 1151 void set_base_id(int id) { base_id_ = id; }
1186 static int num_ids() { return parent_num_ids() + 1; } 1152 static int num_ids() { return parent_num_ids() + 1; }
1187 BailoutId DebugBreakId() const { return BailoutId(local_id(0)); } 1153 BailoutId DebugBreakId() const { return BailoutId(local_id(0)); }
1188 1154
1189 protected: 1155 private:
1156 friend class AstNodeFactory;
1157
1190 DebuggerStatement(Zone* zone, int pos) 1158 DebuggerStatement(Zone* zone, int pos)
1191 : Statement(zone, pos, kDebuggerStatement), 1159 : Statement(zone, pos, kDebuggerStatement),
1192 base_id_(BailoutId::None().ToInt()) {} 1160 base_id_(BailoutId::None().ToInt()) {}
1161
1193 static int parent_num_ids() { return 0; } 1162 static int parent_num_ids() { return 0; }
1194
1195 int base_id() const { 1163 int base_id() const {
1196 DCHECK(!BailoutId(base_id_).IsNone()); 1164 DCHECK(!BailoutId(base_id_).IsNone());
1197 return base_id_; 1165 return base_id_;
1198 } 1166 }
1199
1200 private:
1201 int local_id(int n) const { return base_id() + parent_num_ids() + n; } 1167 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
1202 1168
1203 int base_id_; 1169 int base_id_;
1204 }; 1170 };
1205 1171
1206 1172
1207 class EmptyStatement final : public Statement { 1173 class EmptyStatement final : public Statement {
1208 public: 1174 private:
1209 DECLARE_NODE_TYPE(EmptyStatement) 1175 friend class AstNodeFactory;
1210
1211 protected:
1212 EmptyStatement(Zone* zone, int pos) : Statement(zone, pos, kEmptyStatement) {} 1176 EmptyStatement(Zone* zone, int pos) : Statement(zone, pos, kEmptyStatement) {}
1213 }; 1177 };
1214 1178
1215 1179
1216 // Delegates to another statement, which may be overwritten. 1180 // Delegates to another statement, which may be overwritten.
1217 // This was introduced to implement ES2015 Annex B3.3 for conditionally making 1181 // This was introduced to implement ES2015 Annex B3.3 for conditionally making
1218 // sloppy-mode block-scoped functions have a var binding, which is changed 1182 // sloppy-mode block-scoped functions have a var binding, which is changed
1219 // from one statement to another during parsing. 1183 // from one statement to another during parsing.
1220 class SloppyBlockFunctionStatement final : public Statement { 1184 class SloppyBlockFunctionStatement final : public Statement {
1221 public: 1185 public:
1222 DECLARE_NODE_TYPE(SloppyBlockFunctionStatement)
1223
1224 Statement* statement() const { return statement_; } 1186 Statement* statement() const { return statement_; }
1225 void set_statement(Statement* statement) { statement_ = statement; } 1187 void set_statement(Statement* statement) { statement_ = statement; }
1226 Scope* scope() const { return scope_; } 1188 Scope* scope() const { return scope_; }
1227 1189
1228 private: 1190 private:
1191 friend class AstNodeFactory;
1192
1229 SloppyBlockFunctionStatement(Zone* zone, Statement* statement, Scope* scope) 1193 SloppyBlockFunctionStatement(Zone* zone, Statement* statement, Scope* scope)
1230 : Statement(zone, kNoSourcePosition, kSloppyBlockFunctionStatement), 1194 : Statement(zone, kNoSourcePosition, kSloppyBlockFunctionStatement),
1231 statement_(statement), 1195 statement_(statement),
1232 scope_(scope) {} 1196 scope_(scope) {}
1233 1197
1234 Statement* statement_; 1198 Statement* statement_;
1235 Scope* const scope_; 1199 Scope* const scope_;
1236 }; 1200 };
1237 1201
1238 1202
1239 class Literal final : public Expression { 1203 class Literal final : public Expression {
1240 public: 1204 public:
1241 DECLARE_NODE_TYPE(Literal)
1242
1243 bool IsPropertyName() const { return value_->IsPropertyName(); } 1205 bool IsPropertyName() const { return value_->IsPropertyName(); }
1244 1206
1245 Handle<String> AsPropertyName() { 1207 Handle<String> AsPropertyName() {
1246 DCHECK(IsPropertyName()); 1208 DCHECK(IsPropertyName());
1247 return Handle<String>::cast(value()); 1209 return Handle<String>::cast(value());
1248 } 1210 }
1249 1211
1250 const AstRawString* AsRawPropertyName() { 1212 const AstRawString* AsRawPropertyName() {
1251 DCHECK(IsPropertyName()); 1213 DCHECK(IsPropertyName());
1252 return value_->AsString(); 1214 return value_->AsString();
1253 } 1215 }
1254 1216
1255 bool ToBooleanIsTrue() const { return value()->BooleanValue(); } 1217 bool ToBooleanIsTrue() const { return value()->BooleanValue(); }
1256 bool ToBooleanIsFalse() const { return !value()->BooleanValue(); } 1218 bool ToBooleanIsFalse() const { return !value()->BooleanValue(); }
1257 1219
1258 Handle<Object> value() const { return value_->value(); } 1220 Handle<Object> value() const { return value_->value(); }
1259 const AstValue* raw_value() const { return value_; } 1221 const AstValue* raw_value() const { return value_; }
1260 1222
1261 // Support for using Literal as a HashMap key. NOTE: Currently, this works 1223 // Support for using Literal as a HashMap key. NOTE: Currently, this works
1262 // only for string and number literals! 1224 // only for string and number literals!
1263 uint32_t Hash(); 1225 uint32_t Hash();
1264 static bool Match(void* literal1, void* literal2); 1226 static bool Match(void* literal1, void* literal2);
1265 1227
1266 static int num_ids() { return parent_num_ids() + 1; } 1228 static int num_ids() { return parent_num_ids() + 1; }
1267 TypeFeedbackId LiteralFeedbackId() const { 1229 TypeFeedbackId LiteralFeedbackId() const {
1268 return TypeFeedbackId(local_id(0)); 1230 return TypeFeedbackId(local_id(0));
1269 } 1231 }
1270 1232
1271 protected: 1233 private:
1234 friend class AstNodeFactory;
1235
1272 Literal(Zone* zone, const AstValue* value, int position) 1236 Literal(Zone* zone, const AstValue* value, int position)
1273 : Expression(zone, position, kLiteral), value_(value) {} 1237 : Expression(zone, position, kLiteral), value_(value) {}
1238
1274 static int parent_num_ids() { return Expression::num_ids(); } 1239 static int parent_num_ids() { return Expression::num_ids(); }
1275
1276 private:
1277 int local_id(int n) const { return base_id() + parent_num_ids() + n; } 1240 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
1278 1241
1279 const AstValue* value_; 1242 const AstValue* value_;
1280 }; 1243 };
1281 1244
1282 1245
1283 class AstLiteralReindexer; 1246 class AstLiteralReindexer;
1284 1247
1285 // Base class for literals that needs space in the corresponding JSFunction. 1248 // Base class for literals that needs space in the corresponding JSFunction.
1286 class MaterializedLiteral : public Expression { 1249 class MaterializedLiteral : public Expression {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1371 } 1334 }
1372 void SetSlot(FeedbackVectorSlot slot, int offset = 0) { 1335 void SetSlot(FeedbackVectorSlot slot, int offset = 0) {
1373 DCHECK_LT(offset, static_cast<int>(arraysize(slots_))); 1336 DCHECK_LT(offset, static_cast<int>(arraysize(slots_)));
1374 slots_[offset] = slot; 1337 slots_[offset] = slot;
1375 } 1338 }
1376 1339
1377 void set_receiver_type(Handle<Map> map) { receiver_type_ = map; } 1340 void set_receiver_type(Handle<Map> map) { receiver_type_ = map; }
1378 1341
1379 bool NeedsSetFunctionName() const; 1342 bool NeedsSetFunctionName() const;
1380 1343
1381 protected: 1344 private:
1382 friend class AstNodeFactory; 1345 friend class AstNodeFactory;
1383 1346
1384 ObjectLiteralProperty(Expression* key, Expression* value, Kind kind, 1347 ObjectLiteralProperty(Expression* key, Expression* value, Kind kind,
1385 bool is_static, bool is_computed_name); 1348 bool is_static, bool is_computed_name);
1386 ObjectLiteralProperty(AstValueFactory* ast_value_factory, Expression* key, 1349 ObjectLiteralProperty(AstValueFactory* ast_value_factory, Expression* key,
1387 Expression* value, bool is_static, 1350 Expression* value, bool is_static,
1388 bool is_computed_name); 1351 bool is_computed_name);
1389 1352
1390 private:
1391 Expression* key_; 1353 Expression* key_;
1392 Expression* value_; 1354 Expression* value_;
1393 FeedbackVectorSlot slots_[2]; 1355 FeedbackVectorSlot slots_[2];
1394 Kind kind_; 1356 Kind kind_;
1395 bool emit_store_; 1357 bool emit_store_;
1396 bool is_static_; 1358 bool is_static_;
1397 bool is_computed_name_; 1359 bool is_computed_name_;
1398 Handle<Map> receiver_type_; 1360 Handle<Map> receiver_type_;
1399 }; 1361 };
1400 1362
1401 1363
1402 // An object literal has a boilerplate object that is used 1364 // An object literal has a boilerplate object that is used
1403 // for minimizing the work when constructing it at runtime. 1365 // for minimizing the work when constructing it at runtime.
1404 class ObjectLiteral final : public MaterializedLiteral { 1366 class ObjectLiteral final : public MaterializedLiteral {
1405 public: 1367 public:
1406 typedef ObjectLiteralProperty Property; 1368 typedef ObjectLiteralProperty Property;
1407 1369
1408 DECLARE_NODE_TYPE(ObjectLiteral)
1409
1410 Handle<FixedArray> constant_properties() const { 1370 Handle<FixedArray> constant_properties() const {
1411 return constant_properties_; 1371 return constant_properties_;
1412 } 1372 }
1413 int properties_count() const { return constant_properties_->length() / 2; } 1373 int properties_count() const { return constant_properties_->length() / 2; }
1414 ZoneList<Property*>* properties() const { return properties_; } 1374 ZoneList<Property*>* properties() const { return properties_; }
1415 bool fast_elements() const { return fast_elements_; } 1375 bool fast_elements() const { return fast_elements_; }
1416 bool may_store_doubles() const { return may_store_doubles_; } 1376 bool may_store_doubles() const { return may_store_doubles_; }
1417 bool has_elements() const { return has_elements_; } 1377 bool has_elements() const { return has_elements_; }
1418 bool has_shallow_properties() const { 1378 bool has_shallow_properties() const {
1419 return depth() == 1 && !has_elements() && !may_store_doubles(); 1379 return depth() == 1 && !has_elements() && !may_store_doubles();
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1470 // ObjectLiteral can vary, so num_ids() is not a static method. 1430 // ObjectLiteral can vary, so num_ids() is not a static method.
1471 int num_ids() const { 1431 int num_ids() const {
1472 return parent_num_ids() + 1 + 2 * properties()->length(); 1432 return parent_num_ids() + 1 + 2 * properties()->length();
1473 } 1433 }
1474 1434
1475 // Object literals need one feedback slot for each non-trivial value, as well 1435 // Object literals need one feedback slot for each non-trivial value, as well
1476 // as some slots for home objects. 1436 // as some slots for home objects.
1477 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, 1437 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec,
1478 FeedbackVectorSlotCache* cache); 1438 FeedbackVectorSlotCache* cache);
1479 1439
1480 protected: 1440 private:
1441 friend class AstNodeFactory;
1442
1481 ObjectLiteral(Zone* zone, ZoneList<Property*>* properties, int literal_index, 1443 ObjectLiteral(Zone* zone, ZoneList<Property*>* properties, int literal_index,
1482 uint32_t boilerplate_properties, int pos) 1444 uint32_t boilerplate_properties, int pos)
1483 : MaterializedLiteral(zone, literal_index, pos, kObjectLiteral), 1445 : MaterializedLiteral(zone, literal_index, pos, kObjectLiteral),
1484 boilerplate_properties_(boilerplate_properties), 1446 boilerplate_properties_(boilerplate_properties),
1485 fast_elements_(false), 1447 fast_elements_(false),
1486 has_elements_(false), 1448 has_elements_(false),
1487 may_store_doubles_(false), 1449 may_store_doubles_(false),
1488 properties_(properties) {} 1450 properties_(properties) {}
1451
1489 static int parent_num_ids() { return MaterializedLiteral::num_ids(); } 1452 static int parent_num_ids() { return MaterializedLiteral::num_ids(); }
1453 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
1490 1454
1491 private:
1492 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
1493 uint32_t boilerplate_properties_ : 29; 1455 uint32_t boilerplate_properties_ : 29;
1494 bool fast_elements_ : 1; 1456 bool fast_elements_ : 1;
1495 bool has_elements_ : 1; 1457 bool has_elements_ : 1;
1496 bool may_store_doubles_ : 1; 1458 bool may_store_doubles_ : 1;
1497 FeedbackVectorSlot slot_; 1459 FeedbackVectorSlot slot_;
1498 Handle<FixedArray> constant_properties_; 1460 Handle<FixedArray> constant_properties_;
1499 ZoneList<Property*>* properties_; 1461 ZoneList<Property*>* properties_;
1500 }; 1462 };
1501 1463
1502 1464
(...skipping 15 matching lines...) Expand all
1518 } 1480 }
1519 1481
1520 private: 1482 private:
1521 Zone* zone_; 1483 Zone* zone_;
1522 }; 1484 };
1523 1485
1524 1486
1525 // Node for capturing a regexp literal. 1487 // Node for capturing a regexp literal.
1526 class RegExpLiteral final : public MaterializedLiteral { 1488 class RegExpLiteral final : public MaterializedLiteral {
1527 public: 1489 public:
1528 DECLARE_NODE_TYPE(RegExpLiteral)
1529
1530 Handle<String> pattern() const { return pattern_->string(); } 1490 Handle<String> pattern() const { return pattern_->string(); }
1531 int flags() const { return flags_; } 1491 int flags() const { return flags_; }
1532 1492
1533 protected: 1493 private:
1494 friend class AstNodeFactory;
1495
1534 RegExpLiteral(Zone* zone, const AstRawString* pattern, int flags, 1496 RegExpLiteral(Zone* zone, const AstRawString* pattern, int flags,
1535 int literal_index, int pos) 1497 int literal_index, int pos)
1536 : MaterializedLiteral(zone, literal_index, pos, kRegExpLiteral), 1498 : MaterializedLiteral(zone, literal_index, pos, kRegExpLiteral),
1537 flags_(flags), 1499 flags_(flags),
1538 pattern_(pattern) { 1500 pattern_(pattern) {
1539 set_depth(1); 1501 set_depth(1);
1540 } 1502 }
1541 1503
1542 private:
1543 int const flags_; 1504 int const flags_;
1544 const AstRawString* const pattern_; 1505 const AstRawString* const pattern_;
1545 }; 1506 };
1546 1507
1547 1508
1548 // An array literal has a literals object that is used 1509 // An array literal has a literals object that is used
1549 // for minimizing the work when constructing it at runtime. 1510 // for minimizing the work when constructing it at runtime.
1550 class ArrayLiteral final : public MaterializedLiteral { 1511 class ArrayLiteral final : public MaterializedLiteral {
1551 public: 1512 public:
1552 DECLARE_NODE_TYPE(ArrayLiteral)
1553
1554 Handle<FixedArray> constant_elements() const { return constant_elements_; } 1513 Handle<FixedArray> constant_elements() const { return constant_elements_; }
1555 ElementsKind constant_elements_kind() const { 1514 ElementsKind constant_elements_kind() const {
1556 DCHECK_EQ(2, constant_elements_->length()); 1515 DCHECK_EQ(2, constant_elements_->length());
1557 return static_cast<ElementsKind>( 1516 return static_cast<ElementsKind>(
1558 Smi::cast(constant_elements_->get(0))->value()); 1517 Smi::cast(constant_elements_->get(0))->value());
1559 } 1518 }
1560 1519
1561 ZoneList<Expression*>* values() const { return values_; } 1520 ZoneList<Expression*>* values() const { return values_; }
1562 1521
1563 BailoutId CreateLiteralId() const { return BailoutId(local_id(0)); } 1522 BailoutId CreateLiteralId() const { return BailoutId(local_id(0)); }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1597 enum Flags { 1556 enum Flags {
1598 kNoFlags = 0, 1557 kNoFlags = 0,
1599 kShallowElements = 1, 1558 kShallowElements = 1,
1600 kDisableMementos = 1 << 1 1559 kDisableMementos = 1 << 1
1601 }; 1560 };
1602 1561
1603 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, 1562 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec,
1604 FeedbackVectorSlotCache* cache); 1563 FeedbackVectorSlotCache* cache);
1605 FeedbackVectorSlot LiteralFeedbackSlot() const { return literal_slot_; } 1564 FeedbackVectorSlot LiteralFeedbackSlot() const { return literal_slot_; }
1606 1565
1607 protected: 1566 private:
1567 friend class AstNodeFactory;
1568
1608 ArrayLiteral(Zone* zone, ZoneList<Expression*>* values, 1569 ArrayLiteral(Zone* zone, ZoneList<Expression*>* values,
1609 int first_spread_index, int literal_index, int pos) 1570 int first_spread_index, int literal_index, int pos)
1610 : MaterializedLiteral(zone, literal_index, pos, kArrayLiteral), 1571 : MaterializedLiteral(zone, literal_index, pos, kArrayLiteral),
1611 first_spread_index_(first_spread_index), 1572 first_spread_index_(first_spread_index),
1612 values_(values) {} 1573 values_(values) {}
1574
1613 static int parent_num_ids() { return MaterializedLiteral::num_ids(); } 1575 static int parent_num_ids() { return MaterializedLiteral::num_ids(); }
1614
1615 private:
1616 int local_id(int n) const { return base_id() + parent_num_ids() + n; } 1576 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
1617 1577
1618 int first_spread_index_; 1578 int first_spread_index_;
1619 FeedbackVectorSlot literal_slot_; 1579 FeedbackVectorSlot literal_slot_;
1620 Handle<FixedArray> constant_elements_; 1580 Handle<FixedArray> constant_elements_;
1621 ZoneList<Expression*>* values_; 1581 ZoneList<Expression*>* values_;
1622 }; 1582 };
1623 1583
1624 1584
1625 class VariableProxy final : public Expression { 1585 class VariableProxy final : public Expression {
1626 public: 1586 public:
1627 DECLARE_NODE_TYPE(VariableProxy)
1628
1629 bool IsValidReferenceExpression() const { 1587 bool IsValidReferenceExpression() const {
1630 return !is_this() && !is_new_target(); 1588 return !is_this() && !is_new_target();
1631 } 1589 }
1632 1590
1633 bool IsArguments() const { return is_resolved() && var()->is_arguments(); } 1591 bool IsArguments() const { return is_resolved() && var()->is_arguments(); }
1634 1592
1635 Handle<String> name() const { return raw_name()->string(); } 1593 Handle<String> name() const { return raw_name()->string(); }
1636 const AstRawString* raw_name() const { 1594 const AstRawString* raw_name() const {
1637 return is_resolved() ? var_->raw_name() : raw_name_; 1595 return is_resolved() ? var_->raw_name() : raw_name_;
1638 } 1596 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1676 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, 1634 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec,
1677 FeedbackVectorSlotCache* cache); 1635 FeedbackVectorSlotCache* cache);
1678 1636
1679 FeedbackVectorSlot VariableFeedbackSlot() { return variable_feedback_slot_; } 1637 FeedbackVectorSlot VariableFeedbackSlot() { return variable_feedback_slot_; }
1680 1638
1681 static int num_ids() { return parent_num_ids() + 1; } 1639 static int num_ids() { return parent_num_ids() + 1; }
1682 BailoutId BeforeId() const { return BailoutId(local_id(0)); } 1640 BailoutId BeforeId() const { return BailoutId(local_id(0)); }
1683 void set_next_unresolved(VariableProxy* next) { next_unresolved_ = next; } 1641 void set_next_unresolved(VariableProxy* next) { next_unresolved_ = next; }
1684 VariableProxy* next_unresolved() { return next_unresolved_; } 1642 VariableProxy* next_unresolved() { return next_unresolved_; }
1685 1643
1686 protected: 1644 private:
1645 friend class AstNodeFactory;
1646
1687 VariableProxy(Zone* zone, Variable* var, int start_position, 1647 VariableProxy(Zone* zone, Variable* var, int start_position,
1688 int end_position); 1648 int end_position);
1689
1690 VariableProxy(Zone* zone, const AstRawString* name, 1649 VariableProxy(Zone* zone, const AstRawString* name,
1691 Variable::Kind variable_kind, int start_position, 1650 Variable::Kind variable_kind, int start_position,
1692 int end_position); 1651 int end_position);
1693 VariableProxy(Zone* zone, const VariableProxy* copy_from); 1652 VariableProxy(Zone* zone, const VariableProxy* copy_from);
1653
1694 static int parent_num_ids() { return Expression::num_ids(); } 1654 static int parent_num_ids() { return Expression::num_ids(); }
1695 int local_id(int n) const { return base_id() + parent_num_ids() + n; } 1655 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
1696 1656
1697 class IsThisField : public BitField8<bool, 0, 1> {}; 1657 class IsThisField : public BitField8<bool, 0, 1> {};
1698 class IsAssignedField : public BitField8<bool, 1, 1> {}; 1658 class IsAssignedField : public BitField8<bool, 1, 1> {};
1699 class IsResolvedField : public BitField8<bool, 2, 1> {}; 1659 class IsResolvedField : public BitField8<bool, 2, 1> {};
1700 class IsNewTargetField : public BitField8<bool, 3, 1> {}; 1660 class IsNewTargetField : public BitField8<bool, 3, 1> {};
1701 1661
1702 // Start with 16-bit (or smaller) field, which should get packed together 1662 // Start with 16-bit (or smaller) field, which should get packed together
1703 // with Expression's trailing 16-bit field. 1663 // with Expression's trailing 16-bit field.
(...skipping 17 matching lines...) Expand all
1721 VARIABLE, 1681 VARIABLE,
1722 NAMED_PROPERTY, 1682 NAMED_PROPERTY,
1723 KEYED_PROPERTY, 1683 KEYED_PROPERTY,
1724 NAMED_SUPER_PROPERTY, 1684 NAMED_SUPER_PROPERTY,
1725 KEYED_SUPER_PROPERTY 1685 KEYED_SUPER_PROPERTY
1726 }; 1686 };
1727 1687
1728 1688
1729 class Property final : public Expression { 1689 class Property final : public Expression {
1730 public: 1690 public:
1731 DECLARE_NODE_TYPE(Property)
1732
1733 bool IsValidReferenceExpression() const { return true; } 1691 bool IsValidReferenceExpression() const { return true; }
1734 1692
1735 Expression* obj() const { return obj_; } 1693 Expression* obj() const { return obj_; }
1736 Expression* key() const { return key_; } 1694 Expression* key() const { return key_; }
1737 1695
1738 void set_obj(Expression* e) { obj_ = e; } 1696 void set_obj(Expression* e) { obj_ = e; }
1739 void set_key(Expression* e) { key_ = e; } 1697 void set_key(Expression* e) { key_ = e; }
1740 1698
1741 static int num_ids() { return parent_num_ids() + 1; } 1699 static int num_ids() { return parent_num_ids() + 1; }
1742 BailoutId LoadId() const { return BailoutId(local_id(0)); } 1700 BailoutId LoadId() const { return BailoutId(local_id(0)); }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1788 } 1746 }
1789 1747
1790 static LhsKind GetAssignType(Property* property) { 1748 static LhsKind GetAssignType(Property* property) {
1791 if (property == NULL) return VARIABLE; 1749 if (property == NULL) return VARIABLE;
1792 bool super_access = property->IsSuperAccess(); 1750 bool super_access = property->IsSuperAccess();
1793 return (property->key()->IsPropertyName()) 1751 return (property->key()->IsPropertyName())
1794 ? (super_access ? NAMED_SUPER_PROPERTY : NAMED_PROPERTY) 1752 ? (super_access ? NAMED_SUPER_PROPERTY : NAMED_PROPERTY)
1795 : (super_access ? KEYED_SUPER_PROPERTY : KEYED_PROPERTY); 1753 : (super_access ? KEYED_SUPER_PROPERTY : KEYED_PROPERTY);
1796 } 1754 }
1797 1755
1798 protected: 1756 private:
1757 friend class AstNodeFactory;
1758
1799 Property(Zone* zone, Expression* obj, Expression* key, int pos) 1759 Property(Zone* zone, Expression* obj, Expression* key, int pos)
1800 : Expression(zone, pos, kProperty), 1760 : Expression(zone, pos, kProperty),
1801 bit_field_(IsForCallField::encode(false) | 1761 bit_field_(IsForCallField::encode(false) |
1802 IsStringAccessField::encode(false) | 1762 IsStringAccessField::encode(false) |
1803 InlineCacheStateField::encode(UNINITIALIZED)), 1763 InlineCacheStateField::encode(UNINITIALIZED)),
1804 obj_(obj), 1764 obj_(obj),
1805 key_(key) {} 1765 key_(key) {}
1766
1806 static int parent_num_ids() { return Expression::num_ids(); } 1767 static int parent_num_ids() { return Expression::num_ids(); }
1807
1808 private:
1809 int local_id(int n) const { return base_id() + parent_num_ids() + n; } 1768 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
1810 1769
1811 class IsForCallField : public BitField8<bool, 0, 1> {}; 1770 class IsForCallField : public BitField8<bool, 0, 1> {};
1812 class IsStringAccessField : public BitField8<bool, 1, 1> {}; 1771 class IsStringAccessField : public BitField8<bool, 1, 1> {};
1813 class KeyTypeField : public BitField8<IcCheckType, 2, 1> {}; 1772 class KeyTypeField : public BitField8<IcCheckType, 2, 1> {};
1814 class InlineCacheStateField : public BitField8<InlineCacheState, 3, 4> {}; 1773 class InlineCacheStateField : public BitField8<InlineCacheState, 3, 4> {};
1774
1815 uint8_t bit_field_; 1775 uint8_t bit_field_;
1816 FeedbackVectorSlot property_feedback_slot_; 1776 FeedbackVectorSlot property_feedback_slot_;
1817 Expression* obj_; 1777 Expression* obj_;
1818 Expression* key_; 1778 Expression* key_;
1819 SmallMapList receiver_types_; 1779 SmallMapList receiver_types_;
1820 }; 1780 };
1821 1781
1822 1782
1823 class Call final : public Expression { 1783 class Call final : public Expression {
1824 public: 1784 public:
1825 DECLARE_NODE_TYPE(Call)
1826
1827 Expression* expression() const { return expression_; } 1785 Expression* expression() const { return expression_; }
1828 ZoneList<Expression*>* arguments() const { return arguments_; } 1786 ZoneList<Expression*>* arguments() const { return arguments_; }
1829 1787
1830 void set_expression(Expression* e) { expression_ = e; } 1788 void set_expression(Expression* e) { expression_ = e; }
1831 1789
1832 // Type feedback information. 1790 // Type feedback information.
1833 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, 1791 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec,
1834 FeedbackVectorSlotCache* cache); 1792 FeedbackVectorSlotCache* cache);
1835 1793
1836 FeedbackVectorSlot CallFeedbackSlot() const { return stub_slot_; } 1794 FeedbackVectorSlot CallFeedbackSlot() const { return stub_slot_; }
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1907 // Helpers to determine how to handle the call. 1865 // Helpers to determine how to handle the call.
1908 CallType GetCallType(Isolate* isolate) const; 1866 CallType GetCallType(Isolate* isolate) const;
1909 bool IsUsingCallFeedbackSlot(Isolate* isolate) const; 1867 bool IsUsingCallFeedbackSlot(Isolate* isolate) const;
1910 bool IsUsingCallFeedbackICSlot(Isolate* isolate) const; 1868 bool IsUsingCallFeedbackICSlot(Isolate* isolate) const;
1911 1869
1912 #ifdef DEBUG 1870 #ifdef DEBUG
1913 // Used to assert that the FullCodeGenerator records the return site. 1871 // Used to assert that the FullCodeGenerator records the return site.
1914 bool return_is_recorded_; 1872 bool return_is_recorded_;
1915 #endif 1873 #endif
1916 1874
1917 protected: 1875 private:
1876 friend class AstNodeFactory;
1877
1918 Call(Zone* zone, Expression* expression, ZoneList<Expression*>* arguments, 1878 Call(Zone* zone, Expression* expression, ZoneList<Expression*>* arguments,
1919 int pos) 1879 int pos)
1920 : Expression(zone, pos, kCall), 1880 : Expression(zone, pos, kCall),
1921 bit_field_(IsUninitializedField::encode(false)), 1881 bit_field_(IsUninitializedField::encode(false)),
1922 expression_(expression), 1882 expression_(expression),
1923 arguments_(arguments) { 1883 arguments_(arguments) {
1924 if (expression->IsProperty()) { 1884 if (expression->IsProperty()) {
1925 expression->AsProperty()->mark_for_call(); 1885 expression->AsProperty()->mark_for_call();
1926 } 1886 }
1927 } 1887 }
1888
1928 static int parent_num_ids() { return Expression::num_ids(); } 1889 static int parent_num_ids() { return Expression::num_ids(); }
1929
1930 private:
1931 int local_id(int n) const { return base_id() + parent_num_ids() + n; } 1890 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
1932 1891
1933 class IsUninitializedField : public BitField8<bool, 0, 1> {}; 1892 class IsUninitializedField : public BitField8<bool, 0, 1> {};
1934 class IsTailField : public BitField8<bool, 1, 1> {}; 1893 class IsTailField : public BitField8<bool, 1, 1> {};
1894
1935 uint8_t bit_field_; 1895 uint8_t bit_field_;
1936 FeedbackVectorSlot ic_slot_; 1896 FeedbackVectorSlot ic_slot_;
1937 FeedbackVectorSlot stub_slot_; 1897 FeedbackVectorSlot stub_slot_;
1938 Expression* expression_; 1898 Expression* expression_;
1939 ZoneList<Expression*>* arguments_; 1899 ZoneList<Expression*>* arguments_;
1940 Handle<JSFunction> target_; 1900 Handle<JSFunction> target_;
1941 Handle<AllocationSite> allocation_site_; 1901 Handle<AllocationSite> allocation_site_;
1942 }; 1902 };
1943 1903
1944 1904
1945 class CallNew final : public Expression { 1905 class CallNew final : public Expression {
1946 public: 1906 public:
1947 DECLARE_NODE_TYPE(CallNew)
1948
1949 Expression* expression() const { return expression_; } 1907 Expression* expression() const { return expression_; }
1950 ZoneList<Expression*>* arguments() const { return arguments_; } 1908 ZoneList<Expression*>* arguments() const { return arguments_; }
1951 1909
1952 void set_expression(Expression* e) { expression_ = e; } 1910 void set_expression(Expression* e) { expression_ = e; }
1953 1911
1954 // Type feedback information. 1912 // Type feedback information.
1955 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, 1913 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec,
1956 FeedbackVectorSlotCache* cache) { 1914 FeedbackVectorSlotCache* cache) {
1957 callnew_feedback_slot_ = spec->AddGeneralSlot(); 1915 callnew_feedback_slot_ = spec->AddGeneralSlot();
1958 // Construct calls have two slots, one right after the other. 1916 // Construct calls have two slots, one right after the other.
(...skipping 19 matching lines...) Expand all
1978 void set_allocation_site(Handle<AllocationSite> site) { 1936 void set_allocation_site(Handle<AllocationSite> site) {
1979 allocation_site_ = site; 1937 allocation_site_ = site;
1980 } 1938 }
1981 void set_is_monomorphic(bool monomorphic) { is_monomorphic_ = monomorphic; } 1939 void set_is_monomorphic(bool monomorphic) { is_monomorphic_ = monomorphic; }
1982 void set_target(Handle<JSFunction> target) { target_ = target; } 1940 void set_target(Handle<JSFunction> target) { target_ = target; }
1983 void SetKnownGlobalTarget(Handle<JSFunction> target) { 1941 void SetKnownGlobalTarget(Handle<JSFunction> target) {
1984 target_ = target; 1942 target_ = target;
1985 is_monomorphic_ = true; 1943 is_monomorphic_ = true;
1986 } 1944 }
1987 1945
1988 protected: 1946 private:
1947 friend class AstNodeFactory;
1948
1989 CallNew(Zone* zone, Expression* expression, ZoneList<Expression*>* arguments, 1949 CallNew(Zone* zone, Expression* expression, ZoneList<Expression*>* arguments,
1990 int pos) 1950 int pos)
1991 : Expression(zone, pos, kCallNew), 1951 : Expression(zone, pos, kCallNew),
1992 is_monomorphic_(false), 1952 is_monomorphic_(false),
1993 expression_(expression), 1953 expression_(expression),
1994 arguments_(arguments) {} 1954 arguments_(arguments) {}
1995 1955
1996 static int parent_num_ids() { return Expression::num_ids(); } 1956 static int parent_num_ids() { return Expression::num_ids(); }
1997
1998 private:
1999 int local_id(int n) const { return base_id() + parent_num_ids() + n; } 1957 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
2000 1958
2001 bool is_monomorphic_; 1959 bool is_monomorphic_;
2002 FeedbackVectorSlot callnew_feedback_slot_; 1960 FeedbackVectorSlot callnew_feedback_slot_;
2003 Expression* expression_; 1961 Expression* expression_;
2004 ZoneList<Expression*>* arguments_; 1962 ZoneList<Expression*>* arguments_;
2005 Handle<JSFunction> target_; 1963 Handle<JSFunction> target_;
2006 Handle<AllocationSite> allocation_site_; 1964 Handle<AllocationSite> allocation_site_;
2007 }; 1965 };
2008 1966
2009 1967
2010 // The CallRuntime class does not represent any official JavaScript 1968 // The CallRuntime class does not represent any official JavaScript
2011 // language construct. Instead it is used to call a C or JS function 1969 // language construct. Instead it is used to call a C or JS function
2012 // with a set of arguments. This is used from the builtins that are 1970 // with a set of arguments. This is used from the builtins that are
2013 // implemented in JavaScript (see "v8natives.js"). 1971 // implemented in JavaScript (see "v8natives.js").
2014 class CallRuntime final : public Expression { 1972 class CallRuntime final : public Expression {
2015 public: 1973 public:
2016 DECLARE_NODE_TYPE(CallRuntime)
2017
2018 ZoneList<Expression*>* arguments() const { return arguments_; } 1974 ZoneList<Expression*>* arguments() const { return arguments_; }
2019 bool is_jsruntime() const { return function_ == NULL; } 1975 bool is_jsruntime() const { return function_ == NULL; }
2020 1976
2021 int context_index() const { 1977 int context_index() const {
2022 DCHECK(is_jsruntime()); 1978 DCHECK(is_jsruntime());
2023 return context_index_; 1979 return context_index_;
2024 } 1980 }
2025 const Runtime::Function* function() const { 1981 const Runtime::Function* function() const {
2026 DCHECK(!is_jsruntime()); 1982 DCHECK(!is_jsruntime());
2027 return function_; 1983 return function_;
2028 } 1984 }
2029 1985
2030 static int num_ids() { return parent_num_ids() + 1; } 1986 static int num_ids() { return parent_num_ids() + 1; }
2031 BailoutId CallId() { return BailoutId(local_id(0)); } 1987 BailoutId CallId() { return BailoutId(local_id(0)); }
2032 1988
2033 const char* debug_name() { 1989 const char* debug_name() {
2034 return is_jsruntime() ? "(context function)" : function_->name; 1990 return is_jsruntime() ? "(context function)" : function_->name;
2035 } 1991 }
2036 1992
2037 protected: 1993 private:
1994 friend class AstNodeFactory;
1995
2038 CallRuntime(Zone* zone, const Runtime::Function* function, 1996 CallRuntime(Zone* zone, const Runtime::Function* function,
2039 ZoneList<Expression*>* arguments, int pos) 1997 ZoneList<Expression*>* arguments, int pos)
2040 : Expression(zone, pos, kCallRuntime), 1998 : Expression(zone, pos, kCallRuntime),
2041 function_(function), 1999 function_(function),
2042 arguments_(arguments) {} 2000 arguments_(arguments) {}
2043
2044 CallRuntime(Zone* zone, int context_index, ZoneList<Expression*>* arguments, 2001 CallRuntime(Zone* zone, int context_index, ZoneList<Expression*>* arguments,
2045 int pos) 2002 int pos)
2046 : Expression(zone, pos, kCallRuntime), 2003 : Expression(zone, pos, kCallRuntime),
2047 context_index_(context_index), 2004 context_index_(context_index),
2048 function_(NULL), 2005 function_(NULL),
2049 arguments_(arguments) {} 2006 arguments_(arguments) {}
2050 2007
2051 static int parent_num_ids() { return Expression::num_ids(); } 2008 static int parent_num_ids() { return Expression::num_ids(); }
2052
2053 private:
2054 int local_id(int n) const { return base_id() + parent_num_ids() + n; } 2009 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
2055 2010
2056 int context_index_; 2011 int context_index_;
2057 const Runtime::Function* function_; 2012 const Runtime::Function* function_;
2058 ZoneList<Expression*>* arguments_; 2013 ZoneList<Expression*>* arguments_;
2059 }; 2014 };
2060 2015
2061 2016
2062 class UnaryOperation final : public Expression { 2017 class UnaryOperation final : public Expression {
2063 public: 2018 public:
2064 DECLARE_NODE_TYPE(UnaryOperation)
2065
2066 Token::Value op() const { return op_; } 2019 Token::Value op() const { return op_; }
2067 Expression* expression() const { return expression_; } 2020 Expression* expression() const { return expression_; }
2068 void set_expression(Expression* e) { expression_ = e; } 2021 void set_expression(Expression* e) { expression_ = e; }
2069 2022
2070 // For unary not (Token::NOT), the AST ids where true and false will 2023 // For unary not (Token::NOT), the AST ids where true and false will
2071 // actually be materialized, respectively. 2024 // actually be materialized, respectively.
2072 static int num_ids() { return parent_num_ids() + 2; } 2025 static int num_ids() { return parent_num_ids() + 2; }
2073 BailoutId MaterializeTrueId() const { return BailoutId(local_id(0)); } 2026 BailoutId MaterializeTrueId() const { return BailoutId(local_id(0)); }
2074 BailoutId MaterializeFalseId() const { return BailoutId(local_id(1)); } 2027 BailoutId MaterializeFalseId() const { return BailoutId(local_id(1)); }
2075 2028
2076 void RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle); 2029 void RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle);
2077 2030
2078 protected: 2031 private:
2032 friend class AstNodeFactory;
2033
2079 UnaryOperation(Zone* zone, Token::Value op, Expression* expression, int pos) 2034 UnaryOperation(Zone* zone, Token::Value op, Expression* expression, int pos)
2080 : Expression(zone, pos, kUnaryOperation), 2035 : Expression(zone, pos, kUnaryOperation),
2081 op_(op), 2036 op_(op),
2082 expression_(expression) { 2037 expression_(expression) {
2083 DCHECK(Token::IsUnaryOp(op)); 2038 DCHECK(Token::IsUnaryOp(op));
2084 } 2039 }
2040
2085 static int parent_num_ids() { return Expression::num_ids(); } 2041 static int parent_num_ids() { return Expression::num_ids(); }
2086
2087 private:
2088 int local_id(int n) const { return base_id() + parent_num_ids() + n; } 2042 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
2089 2043
2090 Token::Value op_; 2044 Token::Value op_;
2091 Expression* expression_; 2045 Expression* expression_;
2092 }; 2046 };
2093 2047
2094 2048
2095 class BinaryOperation final : public Expression { 2049 class BinaryOperation final : public Expression {
2096 public: 2050 public:
2097 DECLARE_NODE_TYPE(BinaryOperation)
2098
2099 Token::Value op() const { return static_cast<Token::Value>(op_); } 2051 Token::Value op() const { return static_cast<Token::Value>(op_); }
2100 Expression* left() const { return left_; } 2052 Expression* left() const { return left_; }
2101 void set_left(Expression* e) { left_ = e; } 2053 void set_left(Expression* e) { left_ = e; }
2102 Expression* right() const { return right_; } 2054 Expression* right() const { return right_; }
2103 void set_right(Expression* e) { right_ = e; } 2055 void set_right(Expression* e) { right_ = e; }
2104 Handle<AllocationSite> allocation_site() const { return allocation_site_; } 2056 Handle<AllocationSite> allocation_site() const { return allocation_site_; }
2105 void set_allocation_site(Handle<AllocationSite> allocation_site) { 2057 void set_allocation_site(Handle<AllocationSite> allocation_site) {
2106 allocation_site_ = allocation_site; 2058 allocation_site_ = allocation_site;
2107 } 2059 }
2108 2060
(...skipping 29 matching lines...) Expand all
2138 Maybe<int> fixed_right_arg() const { 2090 Maybe<int> fixed_right_arg() const {
2139 return has_fixed_right_arg_ ? Just(fixed_right_arg_value_) : Nothing<int>(); 2091 return has_fixed_right_arg_ ? Just(fixed_right_arg_value_) : Nothing<int>();
2140 } 2092 }
2141 void set_fixed_right_arg(Maybe<int> arg) { 2093 void set_fixed_right_arg(Maybe<int> arg) {
2142 has_fixed_right_arg_ = arg.IsJust(); 2094 has_fixed_right_arg_ = arg.IsJust();
2143 if (arg.IsJust()) fixed_right_arg_value_ = arg.FromJust(); 2095 if (arg.IsJust()) fixed_right_arg_value_ = arg.FromJust();
2144 } 2096 }
2145 2097
2146 void RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle); 2098 void RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle);
2147 2099
2148 protected: 2100 private:
2101 friend class AstNodeFactory;
2102
2149 BinaryOperation(Zone* zone, Token::Value op, Expression* left, 2103 BinaryOperation(Zone* zone, Token::Value op, Expression* left,
2150 Expression* right, int pos) 2104 Expression* right, int pos)
2151 : Expression(zone, pos, kBinaryOperation), 2105 : Expression(zone, pos, kBinaryOperation),
2152 op_(static_cast<byte>(op)), 2106 op_(static_cast<byte>(op)),
2153 has_fixed_right_arg_(false), 2107 has_fixed_right_arg_(false),
2154 fixed_right_arg_value_(0), 2108 fixed_right_arg_value_(0),
2155 left_(left), 2109 left_(left),
2156 right_(right) { 2110 right_(right) {
2157 DCHECK(Token::IsBinaryOp(op)); 2111 DCHECK(Token::IsBinaryOp(op));
2158 } 2112 }
2113
2159 static int parent_num_ids() { return Expression::num_ids(); } 2114 static int parent_num_ids() { return Expression::num_ids(); }
2160
2161 private:
2162 int local_id(int n) const { return base_id() + parent_num_ids() + n; } 2115 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
2163 2116
2164 const byte op_; // actually Token::Value 2117 const byte op_; // actually Token::Value
2165 // TODO(rossberg): the fixed arg should probably be represented as a Constant 2118 // TODO(rossberg): the fixed arg should probably be represented as a Constant
2166 // type for the RHS. Currenty it's actually a Maybe<int> 2119 // type for the RHS. Currenty it's actually a Maybe<int>
2167 bool has_fixed_right_arg_; 2120 bool has_fixed_right_arg_;
2168 int fixed_right_arg_value_; 2121 int fixed_right_arg_value_;
2169 Expression* left_; 2122 Expression* left_;
2170 Expression* right_; 2123 Expression* right_;
2171 Handle<AllocationSite> allocation_site_; 2124 Handle<AllocationSite> allocation_site_;
2172 FeedbackVectorSlot type_feedback_slot_; 2125 FeedbackVectorSlot type_feedback_slot_;
2173 }; 2126 };
2174 2127
2175 2128
2176 class CountOperation final : public Expression { 2129 class CountOperation final : public Expression {
2177 public: 2130 public:
2178 DECLARE_NODE_TYPE(CountOperation)
2179
2180 bool is_prefix() const { return IsPrefixField::decode(bit_field_); } 2131 bool is_prefix() const { return IsPrefixField::decode(bit_field_); }
2181 bool is_postfix() const { return !is_prefix(); } 2132 bool is_postfix() const { return !is_prefix(); }
2182 2133
2183 Token::Value op() const { return TokenField::decode(bit_field_); } 2134 Token::Value op() const { return TokenField::decode(bit_field_); }
2184 Token::Value binary_op() { 2135 Token::Value binary_op() {
2185 return (op() == Token::INC) ? Token::ADD : Token::SUB; 2136 return (op() == Token::INC) ? Token::ADD : Token::SUB;
2186 } 2137 }
2187 2138
2188 Expression* expression() const { return expression_; } 2139 Expression* expression() const { return expression_; }
2189 void set_expression(Expression* e) { expression_ = e; } 2140 void set_expression(Expression* e) { expression_ = e; }
(...skipping 25 matching lines...) Expand all
2215 2166
2216 // Feedback slot for binary operation is only used by ignition. 2167 // Feedback slot for binary operation is only used by ignition.
2217 FeedbackVectorSlot CountBinaryOpFeedbackSlot() const { 2168 FeedbackVectorSlot CountBinaryOpFeedbackSlot() const {
2218 return binary_operation_slot_; 2169 return binary_operation_slot_;
2219 } 2170 }
2220 2171
2221 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, 2172 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec,
2222 FeedbackVectorSlotCache* cache); 2173 FeedbackVectorSlotCache* cache);
2223 FeedbackVectorSlot CountSlot() const { return slot_; } 2174 FeedbackVectorSlot CountSlot() const { return slot_; }
2224 2175
2225 protected: 2176 private:
2177 friend class AstNodeFactory;
2178
2226 CountOperation(Zone* zone, Token::Value op, bool is_prefix, Expression* expr, 2179 CountOperation(Zone* zone, Token::Value op, bool is_prefix, Expression* expr,
2227 int pos) 2180 int pos)
2228 : Expression(zone, pos, kCountOperation), 2181 : Expression(zone, pos, kCountOperation),
2229 bit_field_( 2182 bit_field_(
2230 IsPrefixField::encode(is_prefix) | KeyTypeField::encode(ELEMENT) | 2183 IsPrefixField::encode(is_prefix) | KeyTypeField::encode(ELEMENT) |
2231 StoreModeField::encode(STANDARD_STORE) | TokenField::encode(op)), 2184 StoreModeField::encode(STANDARD_STORE) | TokenField::encode(op)),
2232 type_(NULL), 2185 type_(NULL),
2233 expression_(expr) {} 2186 expression_(expr) {}
2187
2234 static int parent_num_ids() { return Expression::num_ids(); } 2188 static int parent_num_ids() { return Expression::num_ids(); }
2235
2236 private:
2237 int local_id(int n) const { return base_id() + parent_num_ids() + n; } 2189 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
2238 2190
2239 class IsPrefixField : public BitField16<bool, 0, 1> {}; 2191 class IsPrefixField : public BitField16<bool, 0, 1> {};
2240 class KeyTypeField : public BitField16<IcCheckType, 1, 1> {}; 2192 class KeyTypeField : public BitField16<IcCheckType, 1, 1> {};
2241 class StoreModeField : public BitField16<KeyedAccessStoreMode, 2, 3> {}; 2193 class StoreModeField : public BitField16<KeyedAccessStoreMode, 2, 3> {};
2242 class TokenField : public BitField16<Token::Value, 5, 8> {}; 2194 class TokenField : public BitField16<Token::Value, 5, 8> {};
2243 2195
2244 // Starts with 16-bit field, which should get packed together with 2196 // Starts with 16-bit field, which should get packed together with
2245 // Expression's trailing 16-bit field. 2197 // Expression's trailing 16-bit field.
2246 uint16_t bit_field_; 2198 uint16_t bit_field_;
2247 FeedbackVectorSlot slot_; 2199 FeedbackVectorSlot slot_;
2248 FeedbackVectorSlot binary_operation_slot_; 2200 FeedbackVectorSlot binary_operation_slot_;
2249 Type* type_; 2201 Type* type_;
2250 Expression* expression_; 2202 Expression* expression_;
2251 SmallMapList receiver_types_; 2203 SmallMapList receiver_types_;
2252 }; 2204 };
2253 2205
2254 2206
2255 class CompareOperation final : public Expression { 2207 class CompareOperation final : public Expression {
2256 public: 2208 public:
2257 DECLARE_NODE_TYPE(CompareOperation)
2258
2259 Token::Value op() const { return op_; } 2209 Token::Value op() const { return op_; }
2260 Expression* left() const { return left_; } 2210 Expression* left() const { return left_; }
2261 Expression* right() const { return right_; } 2211 Expression* right() const { return right_; }
2262 2212
2263 void set_left(Expression* e) { left_ = e; } 2213 void set_left(Expression* e) { left_ = e; }
2264 void set_right(Expression* e) { right_ = e; } 2214 void set_right(Expression* e) { right_ = e; }
2265 2215
2266 // Type feedback information. 2216 // Type feedback information.
2267 static int num_ids() { return parent_num_ids() + 1; } 2217 static int num_ids() { return parent_num_ids() + 1; }
2268 TypeFeedbackId CompareOperationFeedbackId() const { 2218 TypeFeedbackId CompareOperationFeedbackId() const {
2269 return TypeFeedbackId(local_id(0)); 2219 return TypeFeedbackId(local_id(0));
2270 } 2220 }
2271 Type* combined_type() const { return combined_type_; } 2221 Type* combined_type() const { return combined_type_; }
2272 void set_combined_type(Type* type) { combined_type_ = type; } 2222 void set_combined_type(Type* type) { combined_type_ = type; }
2273 2223
2274 // Match special cases. 2224 // Match special cases.
2275 bool IsLiteralCompareTypeof(Expression** expr, Handle<String>* check); 2225 bool IsLiteralCompareTypeof(Expression** expr, Handle<String>* check);
2276 bool IsLiteralCompareUndefined(Expression** expr); 2226 bool IsLiteralCompareUndefined(Expression** expr);
2277 bool IsLiteralCompareNull(Expression** expr); 2227 bool IsLiteralCompareNull(Expression** expr);
2278 2228
2279 protected: 2229 private:
2230 friend class AstNodeFactory;
2231
2280 CompareOperation(Zone* zone, Token::Value op, Expression* left, 2232 CompareOperation(Zone* zone, Token::Value op, Expression* left,
2281 Expression* right, int pos) 2233 Expression* right, int pos)
2282 : Expression(zone, pos, kCompareOperation), 2234 : Expression(zone, pos, kCompareOperation),
2283 op_(op), 2235 op_(op),
2284 left_(left), 2236 left_(left),
2285 right_(right), 2237 right_(right),
2286 combined_type_(Type::None()) { 2238 combined_type_(Type::None()) {
2287 DCHECK(Token::IsCompareOp(op)); 2239 DCHECK(Token::IsCompareOp(op));
2288 } 2240 }
2241
2289 static int parent_num_ids() { return Expression::num_ids(); } 2242 static int parent_num_ids() { return Expression::num_ids(); }
2290
2291 private:
2292 int local_id(int n) const { return base_id() + parent_num_ids() + n; } 2243 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
2293 2244
2294 Token::Value op_; 2245 Token::Value op_;
2295 Expression* left_; 2246 Expression* left_;
2296 Expression* right_; 2247 Expression* right_;
2297 2248
2298 Type* combined_type_; 2249 Type* combined_type_;
2299 }; 2250 };
2300 2251
2301 2252
2302 class Spread final : public Expression { 2253 class Spread final : public Expression {
2303 public: 2254 public:
2304 DECLARE_NODE_TYPE(Spread)
2305
2306 Expression* expression() const { return expression_; } 2255 Expression* expression() const { return expression_; }
2307 void set_expression(Expression* e) { expression_ = e; } 2256 void set_expression(Expression* e) { expression_ = e; }
2308 2257
2309 int expression_position() const { return expr_pos_; } 2258 int expression_position() const { return expr_pos_; }
2310 2259
2311 static int num_ids() { return parent_num_ids(); } 2260 static int num_ids() { return parent_num_ids(); }
2312 2261
2313 protected: 2262 private:
2263 friend class AstNodeFactory;
2264
2314 Spread(Zone* zone, Expression* expression, int pos, int expr_pos) 2265 Spread(Zone* zone, Expression* expression, int pos, int expr_pos)
2315 : Expression(zone, pos, kSpread), 2266 : Expression(zone, pos, kSpread),
2316 expr_pos_(expr_pos), 2267 expr_pos_(expr_pos),
2317 expression_(expression) {} 2268 expression_(expression) {}
2269
2318 static int parent_num_ids() { return Expression::num_ids(); } 2270 static int parent_num_ids() { return Expression::num_ids(); }
2319
2320 private:
2321 int local_id(int n) const { return base_id() + parent_num_ids() + n; } 2271 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
2322 2272
2323 int expr_pos_; 2273 int expr_pos_;
2324 Expression* expression_; 2274 Expression* expression_;
2325 }; 2275 };
2326 2276
2327 2277
2328 class Conditional final : public Expression { 2278 class Conditional final : public Expression {
2329 public: 2279 public:
2330 DECLARE_NODE_TYPE(Conditional)
2331
2332 Expression* condition() const { return condition_; } 2280 Expression* condition() const { return condition_; }
2333 Expression* then_expression() const { return then_expression_; } 2281 Expression* then_expression() const { return then_expression_; }
2334 Expression* else_expression() const { return else_expression_; } 2282 Expression* else_expression() const { return else_expression_; }
2335 2283
2336 void set_condition(Expression* e) { condition_ = e; } 2284 void set_condition(Expression* e) { condition_ = e; }
2337 void set_then_expression(Expression* e) { then_expression_ = e; } 2285 void set_then_expression(Expression* e) { then_expression_ = e; }
2338 void set_else_expression(Expression* e) { else_expression_ = e; } 2286 void set_else_expression(Expression* e) { else_expression_ = e; }
2339 2287
2340 void MarkTail() { 2288 void MarkTail() {
2341 then_expression_->MarkTail(); 2289 then_expression_->MarkTail();
2342 else_expression_->MarkTail(); 2290 else_expression_->MarkTail();
2343 } 2291 }
2344 2292
2345 static int num_ids() { return parent_num_ids() + 2; } 2293 static int num_ids() { return parent_num_ids() + 2; }
2346 BailoutId ThenId() const { return BailoutId(local_id(0)); } 2294 BailoutId ThenId() const { return BailoutId(local_id(0)); }
2347 BailoutId ElseId() const { return BailoutId(local_id(1)); } 2295 BailoutId ElseId() const { return BailoutId(local_id(1)); }
2348 2296
2349 protected: 2297 private:
2298 friend class AstNodeFactory;
2299
2350 Conditional(Zone* zone, Expression* condition, Expression* then_expression, 2300 Conditional(Zone* zone, Expression* condition, Expression* then_expression,
2351 Expression* else_expression, int position) 2301 Expression* else_expression, int position)
2352 : Expression(zone, position, kConditional), 2302 : Expression(zone, position, kConditional),
2353 condition_(condition), 2303 condition_(condition),
2354 then_expression_(then_expression), 2304 then_expression_(then_expression),
2355 else_expression_(else_expression) {} 2305 else_expression_(else_expression) {}
2306
2356 static int parent_num_ids() { return Expression::num_ids(); } 2307 static int parent_num_ids() { return Expression::num_ids(); }
2357
2358 private:
2359 int local_id(int n) const { return base_id() + parent_num_ids() + n; } 2308 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
2360 2309
2361 Expression* condition_; 2310 Expression* condition_;
2362 Expression* then_expression_; 2311 Expression* then_expression_;
2363 Expression* else_expression_; 2312 Expression* else_expression_;
2364 }; 2313 };
2365 2314
2366 2315
2367 class Assignment final : public Expression { 2316 class Assignment final : public Expression {
2368 public: 2317 public:
2369 DECLARE_NODE_TYPE(Assignment)
2370
2371 Assignment* AsSimpleAssignment() { return !is_compound() ? this : NULL; } 2318 Assignment* AsSimpleAssignment() { return !is_compound() ? this : NULL; }
2372 2319
2373 Token::Value binary_op() const; 2320 Token::Value binary_op() const;
2374 2321
2375 Token::Value op() const { return TokenField::decode(bit_field_); } 2322 Token::Value op() const { return TokenField::decode(bit_field_); }
2376 Expression* target() const { return target_; } 2323 Expression* target() const { return target_; }
2377 Expression* value() const { return value_; } 2324 Expression* value() const { return value_; }
2378 2325
2379 void set_target(Expression* e) { target_ = e; } 2326 void set_target(Expression* e) { target_ = e; }
2380 void set_value(Expression* e) { value_ = e; } 2327 void set_value(Expression* e) { value_ = e; }
(...skipping 27 matching lines...) Expand all
2408 bit_field_ = KeyTypeField::update(bit_field_, key_type); 2355 bit_field_ = KeyTypeField::update(bit_field_, key_type);
2409 } 2356 }
2410 void set_store_mode(KeyedAccessStoreMode mode) { 2357 void set_store_mode(KeyedAccessStoreMode mode) {
2411 bit_field_ = StoreModeField::update(bit_field_, mode); 2358 bit_field_ = StoreModeField::update(bit_field_, mode);
2412 } 2359 }
2413 2360
2414 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, 2361 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec,
2415 FeedbackVectorSlotCache* cache); 2362 FeedbackVectorSlotCache* cache);
2416 FeedbackVectorSlot AssignmentSlot() const { return slot_; } 2363 FeedbackVectorSlot AssignmentSlot() const { return slot_; }
2417 2364
2418 protected: 2365 private:
2366 friend class AstNodeFactory;
2367
2419 Assignment(Zone* zone, Token::Value op, Expression* target, Expression* value, 2368 Assignment(Zone* zone, Token::Value op, Expression* target, Expression* value,
2420 int pos); 2369 int pos);
2370
2421 static int parent_num_ids() { return Expression::num_ids(); } 2371 static int parent_num_ids() { return Expression::num_ids(); }
2422
2423 private:
2424 int local_id(int n) const { return base_id() + parent_num_ids() + n; } 2372 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
2425 2373
2426 class IsUninitializedField : public BitField16<bool, 0, 1> {}; 2374 class IsUninitializedField : public BitField16<bool, 0, 1> {};
2427 class KeyTypeField 2375 class KeyTypeField
2428 : public BitField16<IcCheckType, IsUninitializedField::kNext, 1> {}; 2376 : public BitField16<IcCheckType, IsUninitializedField::kNext, 1> {};
2429 class StoreModeField 2377 class StoreModeField
2430 : public BitField16<KeyedAccessStoreMode, KeyTypeField::kNext, 3> {}; 2378 : public BitField16<KeyedAccessStoreMode, KeyTypeField::kNext, 3> {};
2431 class TokenField : public BitField16<Token::Value, StoreModeField::kNext, 8> { 2379 class TokenField : public BitField16<Token::Value, StoreModeField::kNext, 8> {
2432 }; 2380 };
2433 2381
(...skipping 16 matching lines...) Expand all
2450 // phases, RewritableExpressions are considered as exceptions of AST nodes 2398 // phases, RewritableExpressions are considered as exceptions of AST nodes
2451 // in the following sense: 2399 // in the following sense:
2452 // 2400 //
2453 // 1. IsRewritableExpression and AsRewritableExpression behave as usual. 2401 // 1. IsRewritableExpression and AsRewritableExpression behave as usual.
2454 // 2. All other Is* and As* methods are practically delegated to the 2402 // 2. All other Is* and As* methods are practically delegated to the
2455 // wrapped node, i.e. IsArrayLiteral() will return true iff the 2403 // wrapped node, i.e. IsArrayLiteral() will return true iff the
2456 // wrapped node is an array literal. 2404 // wrapped node is an array literal.
2457 // 2405 //
2458 // Furthermore, an invariant that should be respected is that the wrapped 2406 // Furthermore, an invariant that should be respected is that the wrapped
2459 // node is not a RewritableExpression. 2407 // node is not a RewritableExpression.
2460 class RewritableExpression : public Expression { 2408 class RewritableExpression final : public Expression {
2461 public: 2409 public:
2462 DECLARE_NODE_TYPE(RewritableExpression)
2463
2464 Expression* expression() const { return expr_; } 2410 Expression* expression() const { return expr_; }
2465 bool is_rewritten() const { return is_rewritten_; } 2411 bool is_rewritten() const { return is_rewritten_; }
2466 2412
2467 void Rewrite(Expression* new_expression) { 2413 void Rewrite(Expression* new_expression) {
2468 DCHECK(!is_rewritten()); 2414 DCHECK(!is_rewritten());
2469 DCHECK_NOT_NULL(new_expression); 2415 DCHECK_NOT_NULL(new_expression);
2470 DCHECK(!new_expression->IsRewritableExpression()); 2416 DCHECK(!new_expression->IsRewritableExpression());
2471 expr_ = new_expression; 2417 expr_ = new_expression;
2472 is_rewritten_ = true; 2418 is_rewritten_ = true;
2473 } 2419 }
2474 2420
2475 static int num_ids() { return parent_num_ids(); } 2421 static int num_ids() { return parent_num_ids(); }
2476 2422
2477 protected: 2423 private:
2424 friend class AstNodeFactory;
2425
2478 RewritableExpression(Zone* zone, Expression* expression) 2426 RewritableExpression(Zone* zone, Expression* expression)
2479 : Expression(zone, expression->position(), kRewritableExpression), 2427 : Expression(zone, expression->position(), kRewritableExpression),
2480 is_rewritten_(false), 2428 is_rewritten_(false),
2481 expr_(expression) { 2429 expr_(expression) {
2482 DCHECK(!expression->IsRewritableExpression()); 2430 DCHECK(!expression->IsRewritableExpression());
2483 } 2431 }
2484 2432
2485 private:
2486 int local_id(int n) const { return base_id() + parent_num_ids() + n; } 2433 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
2487 2434
2488 bool is_rewritten_; 2435 bool is_rewritten_;
2489 Expression* expr_; 2436 Expression* expr_;
2490 }; 2437 };
2491 2438
2492 // Our Yield is different from the JS yield in that it "returns" its argument as 2439 // Our Yield is different from the JS yield in that it "returns" its argument as
2493 // is, without wrapping it in an iterator result object. Such wrapping, if 2440 // is, without wrapping it in an iterator result object. Such wrapping, if
2494 // desired, must be done beforehand (see the parser). 2441 // desired, must be done beforehand (see the parser).
2495 class Yield final : public Expression { 2442 class Yield final : public Expression {
2496 public: 2443 public:
2497 DECLARE_NODE_TYPE(Yield)
2498
2499 enum OnException { kOnExceptionThrow, kOnExceptionRethrow }; 2444 enum OnException { kOnExceptionThrow, kOnExceptionRethrow };
2500 2445
2501 Expression* generator_object() const { return generator_object_; } 2446 Expression* generator_object() const { return generator_object_; }
2502 Expression* expression() const { return expression_; } 2447 Expression* expression() const { return expression_; }
2503 bool rethrow_on_exception() const { 2448 bool rethrow_on_exception() const {
2504 return on_exception_ == kOnExceptionRethrow; 2449 return on_exception_ == kOnExceptionRethrow;
2505 } 2450 }
2506 int yield_id() const { return yield_id_; } 2451 int yield_id() const { return yield_id_; }
2507 2452
2508 void set_generator_object(Expression* e) { generator_object_ = e; } 2453 void set_generator_object(Expression* e) { generator_object_ = e; }
2509 void set_expression(Expression* e) { expression_ = e; } 2454 void set_expression(Expression* e) { expression_ = e; }
2510 void set_yield_id(int yield_id) { yield_id_ = yield_id; } 2455 void set_yield_id(int yield_id) { yield_id_ = yield_id; }
2511 2456
2512 protected: 2457 private:
2458 friend class AstNodeFactory;
2459
2513 Yield(Zone* zone, Expression* generator_object, Expression* expression, 2460 Yield(Zone* zone, Expression* generator_object, Expression* expression,
2514 int pos, OnException on_exception) 2461 int pos, OnException on_exception)
2515 : Expression(zone, pos, kYield), 2462 : Expression(zone, pos, kYield),
2516 on_exception_(on_exception), 2463 on_exception_(on_exception),
2517 yield_id_(-1), 2464 yield_id_(-1),
2518 generator_object_(generator_object), 2465 generator_object_(generator_object),
2519 expression_(expression) {} 2466 expression_(expression) {}
2520 2467
2521 private:
2522 OnException on_exception_; 2468 OnException on_exception_;
2523 int yield_id_; 2469 int yield_id_;
2524 Expression* generator_object_; 2470 Expression* generator_object_;
2525 Expression* expression_; 2471 Expression* expression_;
2526 }; 2472 };
2527 2473
2528 2474
2529 class Throw final : public Expression { 2475 class Throw final : public Expression {
2530 public: 2476 public:
2531 DECLARE_NODE_TYPE(Throw)
2532
2533 Expression* exception() const { return exception_; } 2477 Expression* exception() const { return exception_; }
2534 void set_exception(Expression* e) { exception_ = e; } 2478 void set_exception(Expression* e) { exception_ = e; }
2535 2479
2536 protected: 2480 private:
2481 friend class AstNodeFactory;
2482
2537 Throw(Zone* zone, Expression* exception, int pos) 2483 Throw(Zone* zone, Expression* exception, int pos)
2538 : Expression(zone, pos, kThrow), exception_(exception) {} 2484 : Expression(zone, pos, kThrow), exception_(exception) {}
2539 2485
2540 private:
2541 Expression* exception_; 2486 Expression* exception_;
2542 }; 2487 };
2543 2488
2544 2489
2545 class FunctionLiteral final : public Expression { 2490 class FunctionLiteral final : public Expression {
2546 public: 2491 public:
2547 enum FunctionType { 2492 enum FunctionType {
2548 kAnonymousExpression, 2493 kAnonymousExpression,
2549 kNamedExpression, 2494 kNamedExpression,
2550 kDeclaration, 2495 kDeclaration,
2551 kAccessorOrMethod 2496 kAccessorOrMethod
2552 }; 2497 };
2553 2498
2554 enum ParameterFlag { kNoDuplicateParameters, kHasDuplicateParameters }; 2499 enum ParameterFlag { kNoDuplicateParameters, kHasDuplicateParameters };
2555 2500
2556 enum EagerCompileHint { kShouldEagerCompile, kShouldLazyCompile }; 2501 enum EagerCompileHint { kShouldEagerCompile, kShouldLazyCompile };
2557 2502
2558 DECLARE_NODE_TYPE(FunctionLiteral)
2559
2560 Handle<String> name() const { return raw_name_->string(); } 2503 Handle<String> name() const { return raw_name_->string(); }
2561 const AstString* raw_name() const { return raw_name_; } 2504 const AstString* raw_name() const { return raw_name_; }
2562 void set_raw_name(const AstString* name) { raw_name_ = name; } 2505 void set_raw_name(const AstString* name) { raw_name_ = name; }
2563 DeclarationScope* scope() const { return scope_; } 2506 DeclarationScope* scope() const { return scope_; }
2564 ZoneList<Statement*>* body() const { return body_; } 2507 ZoneList<Statement*>* body() const { return body_; }
2565 void set_function_token_position(int pos) { function_token_position_ = pos; } 2508 void set_function_token_position(int pos) { function_token_position_ = pos; }
2566 int function_token_position() const { return function_token_position_; } 2509 int function_token_position() const { return function_token_position_; }
2567 int start_position() const; 2510 int start_position() const;
2568 int end_position() const; 2511 int end_position() const;
2569 int SourceSize() const { return end_position() - start_position(); } 2512 int SourceSize() const { return end_position() - start_position(); }
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
2668 dont_optimize_reason_ = reason; 2611 dont_optimize_reason_ = reason;
2669 } 2612 }
2670 2613
2671 bool IsAnonymousFunctionDefinition() const { 2614 bool IsAnonymousFunctionDefinition() const {
2672 return is_anonymous_expression(); 2615 return is_anonymous_expression();
2673 } 2616 }
2674 2617
2675 int yield_count() { return yield_count_; } 2618 int yield_count() { return yield_count_; }
2676 void set_yield_count(int yield_count) { yield_count_ = yield_count; } 2619 void set_yield_count(int yield_count) { yield_count_ = yield_count; }
2677 2620
2678 protected: 2621 private:
2622 friend class AstNodeFactory;
2623
2679 FunctionLiteral(Zone* zone, const AstString* name, 2624 FunctionLiteral(Zone* zone, const AstString* name,
2680 AstValueFactory* ast_value_factory, DeclarationScope* scope, 2625 AstValueFactory* ast_value_factory, DeclarationScope* scope,
2681 ZoneList<Statement*>* body, int materialized_literal_count, 2626 ZoneList<Statement*>* body, int materialized_literal_count,
2682 int expected_property_count, int parameter_count, 2627 int expected_property_count, int parameter_count,
2683 FunctionType function_type, 2628 FunctionType function_type,
2684 ParameterFlag has_duplicate_parameters, 2629 ParameterFlag has_duplicate_parameters,
2685 EagerCompileHint eager_compile_hint, FunctionKind kind, 2630 EagerCompileHint eager_compile_hint, FunctionKind kind,
2686 int position, bool is_function) 2631 int position, bool is_function)
2687 : Expression(zone, position, kFunctionLiteral), 2632 : Expression(zone, position, kFunctionLiteral),
2688 dont_optimize_reason_(kNoReason), 2633 dont_optimize_reason_(kNoReason),
(...skipping 10 matching lines...) Expand all
2699 bitfield_ = 2644 bitfield_ =
2700 FunctionTypeBits::encode(function_type) | Pretenure::encode(false) | 2645 FunctionTypeBits::encode(function_type) | Pretenure::encode(false) |
2701 HasDuplicateParameters::encode(has_duplicate_parameters == 2646 HasDuplicateParameters::encode(has_duplicate_parameters ==
2702 kHasDuplicateParameters) | 2647 kHasDuplicateParameters) |
2703 IsFunction::encode(is_function) | 2648 IsFunction::encode(is_function) |
2704 ShouldEagerCompile::encode(eager_compile_hint == kShouldEagerCompile) | 2649 ShouldEagerCompile::encode(eager_compile_hint == kShouldEagerCompile) |
2705 FunctionKindBits::encode(kind) | ShouldBeUsedOnceHint::encode(false); 2650 FunctionKindBits::encode(kind) | ShouldBeUsedOnceHint::encode(false);
2706 DCHECK(IsValidFunctionKind(kind)); 2651 DCHECK(IsValidFunctionKind(kind));
2707 } 2652 }
2708 2653
2709 private:
2710 class FunctionTypeBits : public BitField16<FunctionType, 0, 2> {}; 2654 class FunctionTypeBits : public BitField16<FunctionType, 0, 2> {};
2711 class Pretenure : public BitField16<bool, 2, 1> {}; 2655 class Pretenure : public BitField16<bool, 2, 1> {};
2712 class HasDuplicateParameters : public BitField16<bool, 3, 1> {}; 2656 class HasDuplicateParameters : public BitField16<bool, 3, 1> {};
2713 class IsFunction : public BitField16<bool, 4, 1> {}; 2657 class IsFunction : public BitField16<bool, 4, 1> {};
2714 class ShouldEagerCompile : public BitField16<bool, 5, 1> {}; 2658 class ShouldEagerCompile : public BitField16<bool, 5, 1> {};
2715 class ShouldBeUsedOnceHint : public BitField16<bool, 6, 1> {}; 2659 class ShouldBeUsedOnceHint : public BitField16<bool, 6, 1> {};
2716 class FunctionKindBits : public BitField16<FunctionKind, 7, 9> {}; 2660 class FunctionKindBits : public BitField16<FunctionKind, 7, 9> {};
2717 2661
2718 // Start with 16-bit field, which should get packed together 2662 // Start with 16-bit field, which should get packed together
2719 // with Expression's trailing 16-bit field. 2663 // with Expression's trailing 16-bit field.
(...skipping 13 matching lines...) Expand all
2733 const AstString* raw_inferred_name_; 2677 const AstString* raw_inferred_name_;
2734 Handle<String> inferred_name_; 2678 Handle<String> inferred_name_;
2735 AstProperties ast_properties_; 2679 AstProperties ast_properties_;
2736 }; 2680 };
2737 2681
2738 2682
2739 class ClassLiteral final : public Expression { 2683 class ClassLiteral final : public Expression {
2740 public: 2684 public:
2741 typedef ObjectLiteralProperty Property; 2685 typedef ObjectLiteralProperty Property;
2742 2686
2743 DECLARE_NODE_TYPE(ClassLiteral)
2744
2745 VariableProxy* class_variable_proxy() const { return class_variable_proxy_; } 2687 VariableProxy* class_variable_proxy() const { return class_variable_proxy_; }
2746 Expression* extends() const { return extends_; } 2688 Expression* extends() const { return extends_; }
2747 void set_extends(Expression* e) { extends_ = e; } 2689 void set_extends(Expression* e) { extends_ = e; }
2748 FunctionLiteral* constructor() const { return constructor_; } 2690 FunctionLiteral* constructor() const { return constructor_; }
2749 void set_constructor(FunctionLiteral* f) { constructor_ = f; } 2691 void set_constructor(FunctionLiteral* f) { constructor_ = f; }
2750 ZoneList<Property*>* properties() const { return properties_; } 2692 ZoneList<Property*>* properties() const { return properties_; }
2751 int start_position() const { return position(); } 2693 int start_position() const { return position(); }
2752 int end_position() const { return end_position_; } 2694 int end_position() const { return end_position_; }
2753 2695
2754 BailoutId CreateLiteralId() const { return BailoutId(local_id(0)); } 2696 BailoutId CreateLiteralId() const { return BailoutId(local_id(0)); }
(...skipping 12 matching lines...) Expand all
2767 FeedbackVectorSlotCache* cache); 2709 FeedbackVectorSlotCache* cache);
2768 2710
2769 bool NeedsProxySlot() const { 2711 bool NeedsProxySlot() const {
2770 return class_variable_proxy() != nullptr && 2712 return class_variable_proxy() != nullptr &&
2771 class_variable_proxy()->var()->IsUnallocated(); 2713 class_variable_proxy()->var()->IsUnallocated();
2772 } 2714 }
2773 2715
2774 FeedbackVectorSlot PrototypeSlot() const { return prototype_slot_; } 2716 FeedbackVectorSlot PrototypeSlot() const { return prototype_slot_; }
2775 FeedbackVectorSlot ProxySlot() const { return proxy_slot_; } 2717 FeedbackVectorSlot ProxySlot() const { return proxy_slot_; }
2776 2718
2719 private:
2720 friend class AstNodeFactory;
2777 2721
2778 protected:
2779 ClassLiteral(Zone* zone, VariableProxy* class_variable_proxy, 2722 ClassLiteral(Zone* zone, VariableProxy* class_variable_proxy,
2780 Expression* extends, FunctionLiteral* constructor, 2723 Expression* extends, FunctionLiteral* constructor,
2781 ZoneList<Property*>* properties, int start_position, 2724 ZoneList<Property*>* properties, int start_position,
2782 int end_position) 2725 int end_position)
2783 : Expression(zone, start_position, kClassLiteral), 2726 : Expression(zone, start_position, kClassLiteral),
2784 end_position_(end_position), 2727 end_position_(end_position),
2785 class_variable_proxy_(class_variable_proxy), 2728 class_variable_proxy_(class_variable_proxy),
2786 extends_(extends), 2729 extends_(extends),
2787 constructor_(constructor), 2730 constructor_(constructor),
2788 properties_(properties) {} 2731 properties_(properties) {}
2789 2732
2790 static int parent_num_ids() { return Expression::num_ids(); } 2733 static int parent_num_ids() { return Expression::num_ids(); }
2791
2792 private:
2793 int local_id(int n) const { return base_id() + parent_num_ids() + n; } 2734 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
2794 2735
2795 int end_position_; 2736 int end_position_;
2796 FeedbackVectorSlot prototype_slot_; 2737 FeedbackVectorSlot prototype_slot_;
2797 FeedbackVectorSlot proxy_slot_; 2738 FeedbackVectorSlot proxy_slot_;
2798 VariableProxy* class_variable_proxy_; 2739 VariableProxy* class_variable_proxy_;
2799 Expression* extends_; 2740 Expression* extends_;
2800 FunctionLiteral* constructor_; 2741 FunctionLiteral* constructor_;
2801 ZoneList<Property*>* properties_; 2742 ZoneList<Property*>* properties_;
2802 }; 2743 };
2803 2744
2804 2745
2805 class NativeFunctionLiteral final : public Expression { 2746 class NativeFunctionLiteral final : public Expression {
2806 public: 2747 public:
2807 DECLARE_NODE_TYPE(NativeFunctionLiteral)
2808
2809 Handle<String> name() const { return name_->string(); } 2748 Handle<String> name() const { return name_->string(); }
2810 v8::Extension* extension() const { return extension_; } 2749 v8::Extension* extension() const { return extension_; }
2811 2750
2812 protected: 2751 private:
2752 friend class AstNodeFactory;
2753
2813 NativeFunctionLiteral(Zone* zone, const AstRawString* name, 2754 NativeFunctionLiteral(Zone* zone, const AstRawString* name,
2814 v8::Extension* extension, int pos) 2755 v8::Extension* extension, int pos)
2815 : Expression(zone, pos, kNativeFunctionLiteral), 2756 : Expression(zone, pos, kNativeFunctionLiteral),
2816 name_(name), 2757 name_(name),
2817 extension_(extension) {} 2758 extension_(extension) {}
2818 2759
2819 private:
2820 const AstRawString* name_; 2760 const AstRawString* name_;
2821 v8::Extension* extension_; 2761 v8::Extension* extension_;
2822 }; 2762 };
2823 2763
2824 2764
2825 class ThisFunction final : public Expression { 2765 class ThisFunction final : public Expression {
2826 public: 2766 private:
2827 DECLARE_NODE_TYPE(ThisFunction) 2767 friend class AstNodeFactory;
2828
2829 protected:
2830 ThisFunction(Zone* zone, int pos) : Expression(zone, pos, kThisFunction) {} 2768 ThisFunction(Zone* zone, int pos) : Expression(zone, pos, kThisFunction) {}
2831 }; 2769 };
2832 2770
2833 2771
2834 class SuperPropertyReference final : public Expression { 2772 class SuperPropertyReference final : public Expression {
2835 public: 2773 public:
2836 DECLARE_NODE_TYPE(SuperPropertyReference)
2837
2838 VariableProxy* this_var() const { return this_var_; } 2774 VariableProxy* this_var() const { return this_var_; }
2839 void set_this_var(VariableProxy* v) { this_var_ = v; } 2775 void set_this_var(VariableProxy* v) { this_var_ = v; }
2840 Expression* home_object() const { return home_object_; } 2776 Expression* home_object() const { return home_object_; }
2841 void set_home_object(Expression* e) { home_object_ = e; } 2777 void set_home_object(Expression* e) { home_object_ = e; }
2842 2778
2843 protected: 2779 private:
2780 friend class AstNodeFactory;
2781
2844 SuperPropertyReference(Zone* zone, VariableProxy* this_var, 2782 SuperPropertyReference(Zone* zone, VariableProxy* this_var,
2845 Expression* home_object, int pos) 2783 Expression* home_object, int pos)
2846 : Expression(zone, pos, kSuperPropertyReference), 2784 : Expression(zone, pos, kSuperPropertyReference),
2847 this_var_(this_var), 2785 this_var_(this_var),
2848 home_object_(home_object) { 2786 home_object_(home_object) {
2849 DCHECK(this_var->is_this()); 2787 DCHECK(this_var->is_this());
2850 DCHECK(home_object->IsProperty()); 2788 DCHECK(home_object->IsProperty());
2851 } 2789 }
2852 2790
2853 private:
2854 VariableProxy* this_var_; 2791 VariableProxy* this_var_;
2855 Expression* home_object_; 2792 Expression* home_object_;
2856 }; 2793 };
2857 2794
2858 2795
2859 class SuperCallReference final : public Expression { 2796 class SuperCallReference final : public Expression {
2860 public: 2797 public:
2861 DECLARE_NODE_TYPE(SuperCallReference)
2862
2863 VariableProxy* this_var() const { return this_var_; } 2798 VariableProxy* this_var() const { return this_var_; }
2864 void set_this_var(VariableProxy* v) { this_var_ = v; } 2799 void set_this_var(VariableProxy* v) { this_var_ = v; }
2865 VariableProxy* new_target_var() const { return new_target_var_; } 2800 VariableProxy* new_target_var() const { return new_target_var_; }
2866 void set_new_target_var(VariableProxy* v) { new_target_var_ = v; } 2801 void set_new_target_var(VariableProxy* v) { new_target_var_ = v; }
2867 VariableProxy* this_function_var() const { return this_function_var_; } 2802 VariableProxy* this_function_var() const { return this_function_var_; }
2868 void set_this_function_var(VariableProxy* v) { this_function_var_ = v; } 2803 void set_this_function_var(VariableProxy* v) { this_function_var_ = v; }
2869 2804
2870 protected: 2805 private:
2806 friend class AstNodeFactory;
2807
2871 SuperCallReference(Zone* zone, VariableProxy* this_var, 2808 SuperCallReference(Zone* zone, VariableProxy* this_var,
2872 VariableProxy* new_target_var, 2809 VariableProxy* new_target_var,
2873 VariableProxy* this_function_var, int pos) 2810 VariableProxy* this_function_var, int pos)
2874 : Expression(zone, pos, kSuperCallReference), 2811 : Expression(zone, pos, kSuperCallReference),
2875 this_var_(this_var), 2812 this_var_(this_var),
2876 new_target_var_(new_target_var), 2813 new_target_var_(new_target_var),
2877 this_function_var_(this_function_var) { 2814 this_function_var_(this_function_var) {
2878 DCHECK(this_var->is_this()); 2815 DCHECK(this_var->is_this());
2879 DCHECK(new_target_var->raw_name()->IsOneByteEqualTo(".new.target")); 2816 DCHECK(new_target_var->raw_name()->IsOneByteEqualTo(".new.target"));
2880 DCHECK(this_function_var->raw_name()->IsOneByteEqualTo(".this_function")); 2817 DCHECK(this_function_var->raw_name()->IsOneByteEqualTo(".this_function"));
2881 } 2818 }
2882 2819
2883 private:
2884 VariableProxy* this_var_; 2820 VariableProxy* this_var_;
2885 VariableProxy* new_target_var_; 2821 VariableProxy* new_target_var_;
2886 VariableProxy* this_function_var_; 2822 VariableProxy* this_function_var_;
2887 }; 2823 };
2888 2824
2889 2825
2890 // This class is produced when parsing the () in arrow functions without any 2826 // This class is produced when parsing the () in arrow functions without any
2891 // arguments and is not actually a valid expression. 2827 // arguments and is not actually a valid expression.
2892 class EmptyParentheses final : public Expression { 2828 class EmptyParentheses final : public Expression {
2893 public: 2829 private:
2894 DECLARE_NODE_TYPE(EmptyParentheses) 2830 friend class AstNodeFactory;
2895 2831
2896 private:
2897 EmptyParentheses(Zone* zone, int pos) 2832 EmptyParentheses(Zone* zone, int pos)
2898 : Expression(zone, pos, kEmptyParentheses) {} 2833 : Expression(zone, pos, kEmptyParentheses) {}
2899 }; 2834 };
2900 2835
2901 2836
2902 #undef DECLARE_NODE_TYPE
2903
2904 2837
2905 // ---------------------------------------------------------------------------- 2838 // ----------------------------------------------------------------------------
2906 // Basic visitor 2839 // Basic visitor
2907 // Sub-class should parametrize AstVisitor with itself, e.g.: 2840 // Sub-class should parametrize AstVisitor with itself, e.g.:
2908 // class SpecificVisitor : public AstVisitor<SpecificVisitor> { ... } 2841 // class SpecificVisitor : public AstVisitor<SpecificVisitor> { ... }
2909 2842
2910 template <class Subclass> 2843 template <class Subclass>
2911 class AstVisitor BASE_EMBEDDED { 2844 class AstVisitor BASE_EMBEDDED {
2912 public: 2845 public:
2913 void Visit(AstNode* node) { impl()->Visit(node); } 2846 void Visit(AstNode* node) { impl()->Visit(node); }
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after
3544 : NULL; \ 3477 : NULL; \
3545 } 3478 }
3546 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) 3479 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS)
3547 #undef DECLARE_NODE_FUNCTIONS 3480 #undef DECLARE_NODE_FUNCTIONS
3548 3481
3549 3482
3550 } // namespace internal 3483 } // namespace internal
3551 } // namespace v8 3484 } // namespace v8
3552 3485
3553 #endif // V8_AST_AST_H_ 3486 #endif // V8_AST_AST_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698