| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 | 152 |
| 153 virtual Statement* AsStatement() { return NULL; } | 153 virtual Statement* AsStatement() { return NULL; } |
| 154 virtual Expression* AsExpression() { return NULL; } | 154 virtual Expression* AsExpression() { return NULL; } |
| 155 virtual TargetCollector* AsTargetCollector() { return NULL; } | 155 virtual TargetCollector* AsTargetCollector() { return NULL; } |
| 156 virtual BreakableStatement* AsBreakableStatement() { return NULL; } | 156 virtual BreakableStatement* AsBreakableStatement() { return NULL; } |
| 157 virtual IterationStatement* AsIterationStatement() { return NULL; } | 157 virtual IterationStatement* AsIterationStatement() { return NULL; } |
| 158 virtual MaterializedLiteral* AsMaterializedLiteral() { return NULL; } | 158 virtual MaterializedLiteral* AsMaterializedLiteral() { return NULL; } |
| 159 virtual Slot* AsSlot() { return NULL; } | 159 virtual Slot* AsSlot() { return NULL; } |
| 160 | 160 |
| 161 // True if the node is simple enough for us to inline calls containing it. | 161 // True if the node is simple enough for us to inline calls containing it. |
| 162 virtual bool IsInlineable() const { return false; } | 162 virtual bool IsInlineable() const = 0; |
| 163 | 163 |
| 164 static int Count() { return Isolate::Current()->ast_node_count(); } | 164 static int Count() { return Isolate::Current()->ast_node_count(); } |
| 165 static void ResetIds() { Isolate::Current()->set_ast_node_id(0); } | 165 static void ResetIds() { Isolate::Current()->set_ast_node_id(0); } |
| 166 unsigned id() const { return id_; } | 166 unsigned id() const { return id_; } |
| 167 | 167 |
| 168 protected: | 168 protected: |
| 169 static unsigned GetNextId() { | 169 static unsigned GetNextId() { |
| 170 Isolate* isolate = Isolate::Current(); | 170 Isolate* isolate = Isolate::Current(); |
| 171 unsigned tmp = isolate->ast_node_id(); | 171 unsigned tmp = isolate->ast_node_id(); |
| 172 isolate->set_ast_node_id(tmp + 1); | 172 isolate->set_ast_node_id(tmp + 1); |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 | 284 |
| 285 /** | 285 /** |
| 286 * A sentinel used during pre parsing that represents some expression | 286 * A sentinel used during pre parsing that represents some expression |
| 287 * that is a valid left hand side without having to actually build | 287 * that is a valid left hand side without having to actually build |
| 288 * the expression. | 288 * the expression. |
| 289 */ | 289 */ |
| 290 class ValidLeftHandSideSentinel: public Expression { | 290 class ValidLeftHandSideSentinel: public Expression { |
| 291 public: | 291 public: |
| 292 virtual bool IsValidLeftHandSide() { return true; } | 292 virtual bool IsValidLeftHandSide() { return true; } |
| 293 virtual void Accept(AstVisitor* v) { UNREACHABLE(); } | 293 virtual void Accept(AstVisitor* v) { UNREACHABLE(); } |
| 294 virtual bool IsInlineable() const; |
| 294 }; | 295 }; |
| 295 | 296 |
| 296 | 297 |
| 297 class BreakableStatement: public Statement { | 298 class BreakableStatement: public Statement { |
| 298 public: | 299 public: |
| 299 enum Type { | 300 enum Type { |
| 300 TARGET_FOR_ANONYMOUS, | 301 TARGET_FOR_ANONYMOUS, |
| 301 TARGET_FOR_NAMED_ONLY | 302 TARGET_FOR_NAMED_ONLY |
| 302 }; | 303 }; |
| 303 | 304 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 ASSERT(mode == Variable::VAR || mode == Variable::CONST); | 369 ASSERT(mode == Variable::VAR || mode == Variable::CONST); |
| 369 // At the moment there are no "const functions"'s in JavaScript... | 370 // At the moment there are no "const functions"'s in JavaScript... |
| 370 ASSERT(fun == NULL || mode == Variable::VAR); | 371 ASSERT(fun == NULL || mode == Variable::VAR); |
| 371 } | 372 } |
| 372 | 373 |
| 373 DECLARE_NODE_TYPE(Declaration) | 374 DECLARE_NODE_TYPE(Declaration) |
| 374 | 375 |
| 375 VariableProxy* proxy() const { return proxy_; } | 376 VariableProxy* proxy() const { return proxy_; } |
| 376 Variable::Mode mode() const { return mode_; } | 377 Variable::Mode mode() const { return mode_; } |
| 377 FunctionLiteral* fun() const { return fun_; } // may be NULL | 378 FunctionLiteral* fun() const { return fun_; } // may be NULL |
| 379 virtual bool IsInlineable() const; |
| 378 | 380 |
| 379 private: | 381 private: |
| 380 VariableProxy* proxy_; | 382 VariableProxy* proxy_; |
| 381 Variable::Mode mode_; | 383 Variable::Mode mode_; |
| 382 FunctionLiteral* fun_; | 384 FunctionLiteral* fun_; |
| 383 }; | 385 }; |
| 384 | 386 |
| 385 | 387 |
| 386 class IterationStatement: public BreakableStatement { | 388 class IterationStatement: public BreakableStatement { |
| 387 public: | 389 public: |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 | 428 |
| 427 // Position where condition expression starts. We need it to make | 429 // Position where condition expression starts. We need it to make |
| 428 // the loop's condition a breakable location. | 430 // the loop's condition a breakable location. |
| 429 int condition_position() { return condition_position_; } | 431 int condition_position() { return condition_position_; } |
| 430 void set_condition_position(int pos) { condition_position_ = pos; } | 432 void set_condition_position(int pos) { condition_position_ = pos; } |
| 431 | 433 |
| 432 // Bailout support. | 434 // Bailout support. |
| 433 virtual int ContinueId() const { return continue_id_; } | 435 virtual int ContinueId() const { return continue_id_; } |
| 434 int BackEdgeId() const { return back_edge_id_; } | 436 int BackEdgeId() const { return back_edge_id_; } |
| 435 | 437 |
| 438 virtual bool IsInlineable() const; |
| 439 |
| 436 private: | 440 private: |
| 437 Expression* cond_; | 441 Expression* cond_; |
| 438 int condition_position_; | 442 int condition_position_; |
| 439 int continue_id_; | 443 int continue_id_; |
| 440 int back_edge_id_; | 444 int back_edge_id_; |
| 441 }; | 445 }; |
| 442 | 446 |
| 443 | 447 |
| 444 class WhileStatement: public IterationStatement { | 448 class WhileStatement: public IterationStatement { |
| 445 public: | 449 public: |
| 446 explicit inline WhileStatement(ZoneStringList* labels); | 450 explicit inline WhileStatement(ZoneStringList* labels); |
| 447 | 451 |
| 448 DECLARE_NODE_TYPE(WhileStatement) | 452 DECLARE_NODE_TYPE(WhileStatement) |
| 449 | 453 |
| 450 void Initialize(Expression* cond, Statement* body) { | 454 void Initialize(Expression* cond, Statement* body) { |
| 451 IterationStatement::Initialize(body); | 455 IterationStatement::Initialize(body); |
| 452 cond_ = cond; | 456 cond_ = cond; |
| 453 } | 457 } |
| 454 | 458 |
| 455 Expression* cond() const { return cond_; } | 459 Expression* cond() const { return cond_; } |
| 456 bool may_have_function_literal() const { | 460 bool may_have_function_literal() const { |
| 457 return may_have_function_literal_; | 461 return may_have_function_literal_; |
| 458 } | 462 } |
| 459 void set_may_have_function_literal(bool value) { | 463 void set_may_have_function_literal(bool value) { |
| 460 may_have_function_literal_ = value; | 464 may_have_function_literal_ = value; |
| 461 } | 465 } |
| 466 virtual bool IsInlineable() const; |
| 462 | 467 |
| 463 // Bailout support. | 468 // Bailout support. |
| 464 virtual int ContinueId() const { return EntryId(); } | 469 virtual int ContinueId() const { return EntryId(); } |
| 465 int BodyId() const { return body_id_; } | 470 int BodyId() const { return body_id_; } |
| 466 | 471 |
| 467 private: | 472 private: |
| 468 Expression* cond_; | 473 Expression* cond_; |
| 469 // True if there is a function literal subexpression in the condition. | 474 // True if there is a function literal subexpression in the condition. |
| 470 bool may_have_function_literal_; | 475 bool may_have_function_literal_; |
| 471 int body_id_; | 476 int body_id_; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 499 may_have_function_literal_ = value; | 504 may_have_function_literal_ = value; |
| 500 } | 505 } |
| 501 | 506 |
| 502 // Bailout support. | 507 // Bailout support. |
| 503 virtual int ContinueId() const { return continue_id_; } | 508 virtual int ContinueId() const { return continue_id_; } |
| 504 int BodyId() const { return body_id_; } | 509 int BodyId() const { return body_id_; } |
| 505 | 510 |
| 506 bool is_fast_smi_loop() { return loop_variable_ != NULL; } | 511 bool is_fast_smi_loop() { return loop_variable_ != NULL; } |
| 507 Variable* loop_variable() { return loop_variable_; } | 512 Variable* loop_variable() { return loop_variable_; } |
| 508 void set_loop_variable(Variable* var) { loop_variable_ = var; } | 513 void set_loop_variable(Variable* var) { loop_variable_ = var; } |
| 514 virtual bool IsInlineable() const; |
| 509 | 515 |
| 510 private: | 516 private: |
| 511 Statement* init_; | 517 Statement* init_; |
| 512 Expression* cond_; | 518 Expression* cond_; |
| 513 Statement* next_; | 519 Statement* next_; |
| 514 // True if there is a function literal subexpression in the condition. | 520 // True if there is a function literal subexpression in the condition. |
| 515 bool may_have_function_literal_; | 521 bool may_have_function_literal_; |
| 516 Variable* loop_variable_; | 522 Variable* loop_variable_; |
| 517 int continue_id_; | 523 int continue_id_; |
| 518 int body_id_; | 524 int body_id_; |
| 519 }; | 525 }; |
| 520 | 526 |
| 521 | 527 |
| 522 class ForInStatement: public IterationStatement { | 528 class ForInStatement: public IterationStatement { |
| 523 public: | 529 public: |
| 524 explicit inline ForInStatement(ZoneStringList* labels); | 530 explicit inline ForInStatement(ZoneStringList* labels); |
| 525 | 531 |
| 526 DECLARE_NODE_TYPE(ForInStatement) | 532 DECLARE_NODE_TYPE(ForInStatement) |
| 527 | 533 |
| 528 void Initialize(Expression* each, Expression* enumerable, Statement* body) { | 534 void Initialize(Expression* each, Expression* enumerable, Statement* body) { |
| 529 IterationStatement::Initialize(body); | 535 IterationStatement::Initialize(body); |
| 530 each_ = each; | 536 each_ = each; |
| 531 enumerable_ = enumerable; | 537 enumerable_ = enumerable; |
| 532 } | 538 } |
| 533 | 539 |
| 534 Expression* each() const { return each_; } | 540 Expression* each() const { return each_; } |
| 535 Expression* enumerable() const { return enumerable_; } | 541 Expression* enumerable() const { return enumerable_; } |
| 542 virtual bool IsInlineable() const; |
| 536 | 543 |
| 537 // Bailout support. | 544 // Bailout support. |
| 538 int AssignmentId() const { return assignment_id_; } | 545 int AssignmentId() const { return assignment_id_; } |
| 539 virtual int ContinueId() const { return EntryId(); } | 546 virtual int ContinueId() const { return EntryId(); } |
| 540 | 547 |
| 541 private: | 548 private: |
| 542 Expression* each_; | 549 Expression* each_; |
| 543 Expression* enumerable_; | 550 Expression* enumerable_; |
| 544 int assignment_id_; | 551 int assignment_id_; |
| 545 }; | 552 }; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 566 | 573 |
| 567 | 574 |
| 568 class ContinueStatement: public Statement { | 575 class ContinueStatement: public Statement { |
| 569 public: | 576 public: |
| 570 explicit ContinueStatement(IterationStatement* target) | 577 explicit ContinueStatement(IterationStatement* target) |
| 571 : target_(target) { } | 578 : target_(target) { } |
| 572 | 579 |
| 573 DECLARE_NODE_TYPE(ContinueStatement) | 580 DECLARE_NODE_TYPE(ContinueStatement) |
| 574 | 581 |
| 575 IterationStatement* target() const { return target_; } | 582 IterationStatement* target() const { return target_; } |
| 583 virtual bool IsInlineable() const; |
| 576 | 584 |
| 577 private: | 585 private: |
| 578 IterationStatement* target_; | 586 IterationStatement* target_; |
| 579 }; | 587 }; |
| 580 | 588 |
| 581 | 589 |
| 582 class BreakStatement: public Statement { | 590 class BreakStatement: public Statement { |
| 583 public: | 591 public: |
| 584 explicit BreakStatement(BreakableStatement* target) | 592 explicit BreakStatement(BreakableStatement* target) |
| 585 : target_(target) { } | 593 : target_(target) { } |
| 586 | 594 |
| 587 DECLARE_NODE_TYPE(BreakStatement) | 595 DECLARE_NODE_TYPE(BreakStatement) |
| 588 | 596 |
| 589 BreakableStatement* target() const { return target_; } | 597 BreakableStatement* target() const { return target_; } |
| 598 virtual bool IsInlineable() const; |
| 590 | 599 |
| 591 private: | 600 private: |
| 592 BreakableStatement* target_; | 601 BreakableStatement* target_; |
| 593 }; | 602 }; |
| 594 | 603 |
| 595 | 604 |
| 596 class ReturnStatement: public Statement { | 605 class ReturnStatement: public Statement { |
| 597 public: | 606 public: |
| 598 explicit ReturnStatement(Expression* expression) | 607 explicit ReturnStatement(Expression* expression) |
| 599 : expression_(expression) { } | 608 : expression_(expression) { } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 611 class WithEnterStatement: public Statement { | 620 class WithEnterStatement: public Statement { |
| 612 public: | 621 public: |
| 613 explicit WithEnterStatement(Expression* expression, bool is_catch_block) | 622 explicit WithEnterStatement(Expression* expression, bool is_catch_block) |
| 614 : expression_(expression), is_catch_block_(is_catch_block) { } | 623 : expression_(expression), is_catch_block_(is_catch_block) { } |
| 615 | 624 |
| 616 DECLARE_NODE_TYPE(WithEnterStatement) | 625 DECLARE_NODE_TYPE(WithEnterStatement) |
| 617 | 626 |
| 618 Expression* expression() const { return expression_; } | 627 Expression* expression() const { return expression_; } |
| 619 | 628 |
| 620 bool is_catch_block() const { return is_catch_block_; } | 629 bool is_catch_block() const { return is_catch_block_; } |
| 630 virtual bool IsInlineable() const; |
| 621 | 631 |
| 622 private: | 632 private: |
| 623 Expression* expression_; | 633 Expression* expression_; |
| 624 bool is_catch_block_; | 634 bool is_catch_block_; |
| 625 }; | 635 }; |
| 626 | 636 |
| 627 | 637 |
| 628 class WithExitStatement: public Statement { | 638 class WithExitStatement: public Statement { |
| 629 public: | 639 public: |
| 630 WithExitStatement() { } | 640 WithExitStatement() { } |
| 631 | 641 |
| 642 virtual bool IsInlineable() const; |
| 643 |
| 632 DECLARE_NODE_TYPE(WithExitStatement) | 644 DECLARE_NODE_TYPE(WithExitStatement) |
| 633 }; | 645 }; |
| 634 | 646 |
| 635 | 647 |
| 636 class CaseClause: public ZoneObject { | 648 class CaseClause: public ZoneObject { |
| 637 public: | 649 public: |
| 638 CaseClause(Expression* label, ZoneList<Statement*>* statements, int pos); | 650 CaseClause(Expression* label, ZoneList<Statement*>* statements, int pos); |
| 639 | 651 |
| 640 bool is_default() const { return label_ == NULL; } | 652 bool is_default() const { return label_ == NULL; } |
| 641 Expression* label() const { | 653 Expression* label() const { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 672 | 684 |
| 673 DECLARE_NODE_TYPE(SwitchStatement) | 685 DECLARE_NODE_TYPE(SwitchStatement) |
| 674 | 686 |
| 675 void Initialize(Expression* tag, ZoneList<CaseClause*>* cases) { | 687 void Initialize(Expression* tag, ZoneList<CaseClause*>* cases) { |
| 676 tag_ = tag; | 688 tag_ = tag; |
| 677 cases_ = cases; | 689 cases_ = cases; |
| 678 } | 690 } |
| 679 | 691 |
| 680 Expression* tag() const { return tag_; } | 692 Expression* tag() const { return tag_; } |
| 681 ZoneList<CaseClause*>* cases() const { return cases_; } | 693 ZoneList<CaseClause*>* cases() const { return cases_; } |
| 694 virtual bool IsInlineable() const; |
| 682 | 695 |
| 683 private: | 696 private: |
| 684 Expression* tag_; | 697 Expression* tag_; |
| 685 ZoneList<CaseClause*>* cases_; | 698 ZoneList<CaseClause*>* cases_; |
| 686 }; | 699 }; |
| 687 | 700 |
| 688 | 701 |
| 689 // If-statements always have non-null references to their then- and | 702 // If-statements always have non-null references to their then- and |
| 690 // else-parts. When parsing if-statements with no explicit else-part, | 703 // else-parts. When parsing if-statements with no explicit else-part, |
| 691 // the parser implicitly creates an empty statement. Use the | 704 // the parser implicitly creates an empty statement. Use the |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 737 // Adds a jump target to the collector. The collector stores a pointer not | 750 // Adds a jump target to the collector. The collector stores a pointer not |
| 738 // a copy of the target to make binding work, so make sure not to pass in | 751 // a copy of the target to make binding work, so make sure not to pass in |
| 739 // references to something on the stack. | 752 // references to something on the stack. |
| 740 void AddTarget(Label* target); | 753 void AddTarget(Label* target); |
| 741 | 754 |
| 742 // Virtual behaviour. TargetCollectors are never part of the AST. | 755 // Virtual behaviour. TargetCollectors are never part of the AST. |
| 743 virtual void Accept(AstVisitor* v) { UNREACHABLE(); } | 756 virtual void Accept(AstVisitor* v) { UNREACHABLE(); } |
| 744 virtual TargetCollector* AsTargetCollector() { return this; } | 757 virtual TargetCollector* AsTargetCollector() { return this; } |
| 745 | 758 |
| 746 ZoneList<Label*>* targets() { return targets_; } | 759 ZoneList<Label*>* targets() { return targets_; } |
| 760 virtual bool IsInlineable() const; |
| 747 | 761 |
| 748 private: | 762 private: |
| 749 ZoneList<Label*>* targets_; | 763 ZoneList<Label*>* targets_; |
| 750 }; | 764 }; |
| 751 | 765 |
| 752 | 766 |
| 753 class TryStatement: public Statement { | 767 class TryStatement: public Statement { |
| 754 public: | 768 public: |
| 755 explicit TryStatement(Block* try_block) | 769 explicit TryStatement(Block* try_block) |
| 756 : try_block_(try_block), escaping_targets_(NULL) { } | 770 : try_block_(try_block), escaping_targets_(NULL) { } |
| 757 | 771 |
| 758 void set_escaping_targets(ZoneList<Label*>* targets) { | 772 void set_escaping_targets(ZoneList<Label*>* targets) { |
| 759 escaping_targets_ = targets; | 773 escaping_targets_ = targets; |
| 760 } | 774 } |
| 761 | 775 |
| 762 Block* try_block() const { return try_block_; } | 776 Block* try_block() const { return try_block_; } |
| 763 ZoneList<Label*>* escaping_targets() const { return escaping_targets_; } | 777 ZoneList<Label*>* escaping_targets() const { return escaping_targets_; } |
| 778 virtual bool IsInlineable() const; |
| 764 | 779 |
| 765 private: | 780 private: |
| 766 Block* try_block_; | 781 Block* try_block_; |
| 767 ZoneList<Label*>* escaping_targets_; | 782 ZoneList<Label*>* escaping_targets_; |
| 768 }; | 783 }; |
| 769 | 784 |
| 770 | 785 |
| 771 class TryCatchStatement: public TryStatement { | 786 class TryCatchStatement: public TryStatement { |
| 772 public: | 787 public: |
| 773 TryCatchStatement(Block* try_block, | 788 TryCatchStatement(Block* try_block, |
| 774 VariableProxy* catch_var, | 789 VariableProxy* catch_var, |
| 775 Block* catch_block) | 790 Block* catch_block) |
| 776 : TryStatement(try_block), | 791 : TryStatement(try_block), |
| 777 catch_var_(catch_var), | 792 catch_var_(catch_var), |
| 778 catch_block_(catch_block) { | 793 catch_block_(catch_block) { |
| 779 } | 794 } |
| 780 | 795 |
| 781 DECLARE_NODE_TYPE(TryCatchStatement) | 796 DECLARE_NODE_TYPE(TryCatchStatement) |
| 782 | 797 |
| 783 VariableProxy* catch_var() const { return catch_var_; } | 798 VariableProxy* catch_var() const { return catch_var_; } |
| 784 Block* catch_block() const { return catch_block_; } | 799 Block* catch_block() const { return catch_block_; } |
| 800 virtual bool IsInlineable() const; |
| 785 | 801 |
| 786 private: | 802 private: |
| 787 VariableProxy* catch_var_; | 803 VariableProxy* catch_var_; |
| 788 Block* catch_block_; | 804 Block* catch_block_; |
| 789 }; | 805 }; |
| 790 | 806 |
| 791 | 807 |
| 792 class TryFinallyStatement: public TryStatement { | 808 class TryFinallyStatement: public TryStatement { |
| 793 public: | 809 public: |
| 794 TryFinallyStatement(Block* try_block, Block* finally_block) | 810 TryFinallyStatement(Block* try_block, Block* finally_block) |
| 795 : TryStatement(try_block), | 811 : TryStatement(try_block), |
| 796 finally_block_(finally_block) { } | 812 finally_block_(finally_block) { } |
| 797 | 813 |
| 798 DECLARE_NODE_TYPE(TryFinallyStatement) | 814 DECLARE_NODE_TYPE(TryFinallyStatement) |
| 799 | 815 |
| 800 Block* finally_block() const { return finally_block_; } | 816 Block* finally_block() const { return finally_block_; } |
| 817 virtual bool IsInlineable() const; |
| 801 | 818 |
| 802 private: | 819 private: |
| 803 Block* finally_block_; | 820 Block* finally_block_; |
| 804 }; | 821 }; |
| 805 | 822 |
| 806 | 823 |
| 807 class DebuggerStatement: public Statement { | 824 class DebuggerStatement: public Statement { |
| 808 public: | 825 public: |
| 809 DECLARE_NODE_TYPE(DebuggerStatement) | 826 DECLARE_NODE_TYPE(DebuggerStatement) |
| 827 virtual bool IsInlineable() const; |
| 810 }; | 828 }; |
| 811 | 829 |
| 812 | 830 |
| 813 class EmptyStatement: public Statement { | 831 class EmptyStatement: public Statement { |
| 814 public: | 832 public: |
| 815 DECLARE_NODE_TYPE(EmptyStatement) | 833 DECLARE_NODE_TYPE(EmptyStatement) |
| 816 | 834 |
| 817 virtual bool IsInlineable() const { return true; } | 835 virtual bool IsInlineable() const; |
| 818 }; | 836 }; |
| 819 | 837 |
| 820 | 838 |
| 821 class Literal: public Expression { | 839 class Literal: public Expression { |
| 822 public: | 840 public: |
| 823 explicit Literal(Handle<Object> handle) : handle_(handle) { } | 841 explicit Literal(Handle<Object> handle) : handle_(handle) { } |
| 824 | 842 |
| 825 DECLARE_NODE_TYPE(Literal) | 843 DECLARE_NODE_TYPE(Literal) |
| 826 | 844 |
| 827 virtual bool IsTrivial() { return true; } | 845 virtual bool IsTrivial() { return true; } |
| 828 virtual bool IsInlineable() const { return true; } | |
| 829 virtual bool IsSmiLiteral() { return handle_->IsSmi(); } | 846 virtual bool IsSmiLiteral() { return handle_->IsSmi(); } |
| 830 | 847 |
| 831 // Check if this literal is identical to the other literal. | 848 // Check if this literal is identical to the other literal. |
| 832 bool IsIdenticalTo(const Literal* other) const { | 849 bool IsIdenticalTo(const Literal* other) const { |
| 833 return handle_.is_identical_to(other->handle_); | 850 return handle_.is_identical_to(other->handle_); |
| 834 } | 851 } |
| 835 | 852 |
| 836 virtual bool IsPropertyName() { | 853 virtual bool IsPropertyName() { |
| 837 if (handle_->IsSymbol()) { | 854 if (handle_->IsSymbol()) { |
| 838 uint32_t ignored; | 855 uint32_t ignored; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 857 bool IsTrue() const { | 874 bool IsTrue() const { |
| 858 ASSERT(!handle_.is_null()); | 875 ASSERT(!handle_.is_null()); |
| 859 return handle_->IsTrue(); | 876 return handle_->IsTrue(); |
| 860 } | 877 } |
| 861 bool IsFalse() const { | 878 bool IsFalse() const { |
| 862 ASSERT(!handle_.is_null()); | 879 ASSERT(!handle_.is_null()); |
| 863 return handle_->IsFalse(); | 880 return handle_->IsFalse(); |
| 864 } | 881 } |
| 865 | 882 |
| 866 Handle<Object> handle() const { return handle_; } | 883 Handle<Object> handle() const { return handle_; } |
| 884 virtual bool IsInlineable() const; |
| 867 | 885 |
| 868 private: | 886 private: |
| 869 Handle<Object> handle_; | 887 Handle<Object> handle_; |
| 870 }; | 888 }; |
| 871 | 889 |
| 872 | 890 |
| 873 // Base class for literals that needs space in the corresponding JSFunction. | 891 // Base class for literals that needs space in the corresponding JSFunction. |
| 874 class MaterializedLiteral: public Expression { | 892 class MaterializedLiteral: public Expression { |
| 875 public: | 893 public: |
| 876 explicit MaterializedLiteral(int literal_index, bool is_simple, int depth) | 894 explicit MaterializedLiteral(int literal_index, bool is_simple, int depth) |
| 877 : literal_index_(literal_index), is_simple_(is_simple), depth_(depth) {} | 895 : literal_index_(literal_index), is_simple_(is_simple), depth_(depth) {} |
| 878 | 896 |
| 879 virtual MaterializedLiteral* AsMaterializedLiteral() { return this; } | 897 virtual MaterializedLiteral* AsMaterializedLiteral() { return this; } |
| 880 | 898 |
| 881 int literal_index() { return literal_index_; } | 899 int literal_index() { return literal_index_; } |
| 882 | 900 |
| 883 // A materialized literal is simple if the values consist of only | 901 // A materialized literal is simple if the values consist of only |
| 884 // constants and simple object and array literals. | 902 // constants and simple object and array literals. |
| 885 bool is_simple() const { return is_simple_; } | 903 bool is_simple() const { return is_simple_; } |
| 886 | 904 |
| 887 int depth() const { return depth_; } | 905 int depth() const { return depth_; } |
| 906 virtual bool IsInlineable() const; |
| 888 | 907 |
| 889 private: | 908 private: |
| 890 int literal_index_; | 909 int literal_index_; |
| 891 bool is_simple_; | 910 bool is_simple_; |
| 892 int depth_; | 911 int depth_; |
| 893 }; | 912 }; |
| 894 | 913 |
| 895 | 914 |
| 896 // An object literal has a boilerplate object that is used | 915 // An object literal has a boilerplate object that is used |
| 897 // for minimizing the work when constructing it at runtime. | 916 // for minimizing the work when constructing it at runtime. |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1027 class CatchExtensionObject: public Expression { | 1046 class CatchExtensionObject: public Expression { |
| 1028 public: | 1047 public: |
| 1029 CatchExtensionObject(Literal* key, VariableProxy* value) | 1048 CatchExtensionObject(Literal* key, VariableProxy* value) |
| 1030 : key_(key), value_(value) { | 1049 : key_(key), value_(value) { |
| 1031 } | 1050 } |
| 1032 | 1051 |
| 1033 DECLARE_NODE_TYPE(CatchExtensionObject) | 1052 DECLARE_NODE_TYPE(CatchExtensionObject) |
| 1034 | 1053 |
| 1035 Literal* key() const { return key_; } | 1054 Literal* key() const { return key_; } |
| 1036 VariableProxy* value() const { return value_; } | 1055 VariableProxy* value() const { return value_; } |
| 1056 virtual bool IsInlineable() const; |
| 1037 | 1057 |
| 1038 private: | 1058 private: |
| 1039 Literal* key_; | 1059 Literal* key_; |
| 1040 VariableProxy* value_; | 1060 VariableProxy* value_; |
| 1041 }; | 1061 }; |
| 1042 | 1062 |
| 1043 | 1063 |
| 1044 class VariableProxy: public Expression { | 1064 class VariableProxy: public Expression { |
| 1045 public: | 1065 public: |
| 1046 explicit VariableProxy(Variable* var); | 1066 explicit VariableProxy(Variable* var); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1153 | 1173 |
| 1154 virtual Slot* AsSlot() { return this; } | 1174 virtual Slot* AsSlot() { return this; } |
| 1155 | 1175 |
| 1156 bool IsStackAllocated() { return type_ == PARAMETER || type_ == LOCAL; } | 1176 bool IsStackAllocated() { return type_ == PARAMETER || type_ == LOCAL; } |
| 1157 | 1177 |
| 1158 // Accessors | 1178 // Accessors |
| 1159 Variable* var() const { return var_; } | 1179 Variable* var() const { return var_; } |
| 1160 Type type() const { return type_; } | 1180 Type type() const { return type_; } |
| 1161 int index() const { return index_; } | 1181 int index() const { return index_; } |
| 1162 bool is_arguments() const { return var_->is_arguments(); } | 1182 bool is_arguments() const { return var_->is_arguments(); } |
| 1183 virtual bool IsInlineable() const; |
| 1163 | 1184 |
| 1164 private: | 1185 private: |
| 1165 Variable* var_; | 1186 Variable* var_; |
| 1166 Type type_; | 1187 Type type_; |
| 1167 int index_; | 1188 int index_; |
| 1168 }; | 1189 }; |
| 1169 | 1190 |
| 1170 | 1191 |
| 1171 class Property: public Expression { | 1192 class Property: public Expression { |
| 1172 public: | 1193 public: |
| (...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1636 | 1657 |
| 1637 class Throw: public Expression { | 1658 class Throw: public Expression { |
| 1638 public: | 1659 public: |
| 1639 Throw(Expression* exception, int pos) | 1660 Throw(Expression* exception, int pos) |
| 1640 : exception_(exception), pos_(pos) {} | 1661 : exception_(exception), pos_(pos) {} |
| 1641 | 1662 |
| 1642 DECLARE_NODE_TYPE(Throw) | 1663 DECLARE_NODE_TYPE(Throw) |
| 1643 | 1664 |
| 1644 Expression* exception() const { return exception_; } | 1665 Expression* exception() const { return exception_; } |
| 1645 virtual int position() const { return pos_; } | 1666 virtual int position() const { return pos_; } |
| 1667 virtual bool IsInlineable() const; |
| 1646 | 1668 |
| 1647 private: | 1669 private: |
| 1648 Expression* exception_; | 1670 Expression* exception_; |
| 1649 int pos_; | 1671 int pos_; |
| 1650 }; | 1672 }; |
| 1651 | 1673 |
| 1652 | 1674 |
| 1653 class FunctionLiteral: public Expression { | 1675 class FunctionLiteral: public Expression { |
| 1654 public: | 1676 public: |
| 1655 FunctionLiteral(Handle<String> name, | 1677 FunctionLiteral(Handle<String> name, |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1708 return inferred_name(); | 1730 return inferred_name(); |
| 1709 } | 1731 } |
| 1710 | 1732 |
| 1711 Handle<String> inferred_name() const { return inferred_name_; } | 1733 Handle<String> inferred_name() const { return inferred_name_; } |
| 1712 void set_inferred_name(Handle<String> inferred_name) { | 1734 void set_inferred_name(Handle<String> inferred_name) { |
| 1713 inferred_name_ = inferred_name; | 1735 inferred_name_ = inferred_name; |
| 1714 } | 1736 } |
| 1715 | 1737 |
| 1716 bool pretenure() { return pretenure_; } | 1738 bool pretenure() { return pretenure_; } |
| 1717 void set_pretenure(bool value) { pretenure_ = value; } | 1739 void set_pretenure(bool value) { pretenure_ = value; } |
| 1740 virtual bool IsInlineable() const; |
| 1718 | 1741 |
| 1719 private: | 1742 private: |
| 1720 Handle<String> name_; | 1743 Handle<String> name_; |
| 1721 Scope* scope_; | 1744 Scope* scope_; |
| 1722 ZoneList<Statement*>* body_; | 1745 ZoneList<Statement*>* body_; |
| 1723 int materialized_literal_count_; | 1746 int materialized_literal_count_; |
| 1724 int expected_property_count_; | 1747 int expected_property_count_; |
| 1725 bool has_only_simple_this_property_assignments_; | 1748 bool has_only_simple_this_property_assignments_; |
| 1726 Handle<FixedArray> this_property_assignments_; | 1749 Handle<FixedArray> this_property_assignments_; |
| 1727 int num_parameters_; | 1750 int num_parameters_; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1738 public: | 1761 public: |
| 1739 explicit SharedFunctionInfoLiteral( | 1762 explicit SharedFunctionInfoLiteral( |
| 1740 Handle<SharedFunctionInfo> shared_function_info) | 1763 Handle<SharedFunctionInfo> shared_function_info) |
| 1741 : shared_function_info_(shared_function_info) { } | 1764 : shared_function_info_(shared_function_info) { } |
| 1742 | 1765 |
| 1743 DECLARE_NODE_TYPE(SharedFunctionInfoLiteral) | 1766 DECLARE_NODE_TYPE(SharedFunctionInfoLiteral) |
| 1744 | 1767 |
| 1745 Handle<SharedFunctionInfo> shared_function_info() const { | 1768 Handle<SharedFunctionInfo> shared_function_info() const { |
| 1746 return shared_function_info_; | 1769 return shared_function_info_; |
| 1747 } | 1770 } |
| 1771 virtual bool IsInlineable() const; |
| 1748 | 1772 |
| 1749 private: | 1773 private: |
| 1750 Handle<SharedFunctionInfo> shared_function_info_; | 1774 Handle<SharedFunctionInfo> shared_function_info_; |
| 1751 }; | 1775 }; |
| 1752 | 1776 |
| 1753 | 1777 |
| 1754 class ThisFunction: public Expression { | 1778 class ThisFunction: public Expression { |
| 1755 public: | 1779 public: |
| 1756 DECLARE_NODE_TYPE(ThisFunction) | 1780 DECLARE_NODE_TYPE(ThisFunction) |
| 1781 virtual bool IsInlineable() const; |
| 1757 }; | 1782 }; |
| 1758 | 1783 |
| 1759 | 1784 |
| 1760 // ---------------------------------------------------------------------------- | 1785 // ---------------------------------------------------------------------------- |
| 1761 // Regular expressions | 1786 // Regular expressions |
| 1762 | 1787 |
| 1763 | 1788 |
| 1764 class RegExpVisitor BASE_EMBEDDED { | 1789 class RegExpVisitor BASE_EMBEDDED { |
| 1765 public: | 1790 public: |
| 1766 virtual ~RegExpVisitor() { } | 1791 virtual ~RegExpVisitor() { } |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2151 | 2176 |
| 2152 private: | 2177 private: |
| 2153 Isolate* isolate_; | 2178 Isolate* isolate_; |
| 2154 bool stack_overflow_; | 2179 bool stack_overflow_; |
| 2155 }; | 2180 }; |
| 2156 | 2181 |
| 2157 | 2182 |
| 2158 } } // namespace v8::internal | 2183 } } // namespace v8::internal |
| 2159 | 2184 |
| 2160 #endif // V8_AST_H_ | 2185 #endif // V8_AST_H_ |
| OLD | NEW |