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

Side by Side Diff: src/ast.h

Issue 8700001: Relax inlining limits for simple leaf functions (second version). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/ast.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 131
132 static const int kNoNumber = -1; 132 static const int kNoNumber = -1;
133 static const int kFunctionEntryId = 2; // Using 0 could disguise errors. 133 static const int kFunctionEntryId = 2; // Using 0 could disguise errors.
134 // This AST id identifies the point after the declarations have been 134 // This AST id identifies the point after the declarations have been
135 // visited. We need it to capture the environment effects of declarations 135 // visited. We need it to capture the environment effects of declarations
136 // that emit code (function declarations). 136 // that emit code (function declarations).
137 static const int kDeclarationsId = 3; 137 static const int kDeclarationsId = 3;
138 138
139 // Override ZoneObject's new to count allocated AST nodes. 139 // Override ZoneObject's new to count allocated AST nodes.
140 void* operator new(size_t size, Zone* zone) { 140 void* operator new(size_t size, Zone* zone) {
141 Isolate* isolate = zone->isolate();
142 isolate->set_ast_node_count(isolate->ast_node_count() + 1);
143 return zone->New(static_cast<int>(size)); 141 return zone->New(static_cast<int>(size));
144 } 142 }
145 143
146 AstNode() {} 144 AstNode() {}
147 145
148 virtual ~AstNode() { } 146 virtual ~AstNode() { }
149 147
150 virtual void Accept(AstVisitor* v) = 0; 148 virtual void Accept(AstVisitor* v) = 0;
151 virtual Type node_type() const { return kInvalid; } 149 virtual Type node_type() const { return kInvalid; }
152 150
153 // Type testing & conversion functions overridden by concrete subclasses. 151 // Type testing & conversion functions overridden by concrete subclasses.
154 #define DECLARE_NODE_FUNCTIONS(type) \ 152 #define DECLARE_NODE_FUNCTIONS(type) \
155 bool Is##type() { return node_type() == AstNode::k##type; } \ 153 bool Is##type() { return node_type() == AstNode::k##type; } \
156 type* As##type() { return Is##type() ? reinterpret_cast<type*>(this) : NULL; } 154 type* As##type() { return Is##type() ? reinterpret_cast<type*>(this) : NULL; }
157 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) 155 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS)
158 #undef DECLARE_NODE_FUNCTIONS 156 #undef DECLARE_NODE_FUNCTIONS
159 157
160 virtual Statement* AsStatement() { return NULL; } 158 virtual Statement* AsStatement() { return NULL; }
161 virtual Expression* AsExpression() { return NULL; } 159 virtual Expression* AsExpression() { return NULL; }
162 virtual TargetCollector* AsTargetCollector() { return NULL; } 160 virtual TargetCollector* AsTargetCollector() { return NULL; }
163 virtual BreakableStatement* AsBreakableStatement() { return NULL; } 161 virtual BreakableStatement* AsBreakableStatement() { return NULL; }
164 virtual IterationStatement* AsIterationStatement() { return NULL; } 162 virtual IterationStatement* AsIterationStatement() { return NULL; }
165 virtual MaterializedLiteral* AsMaterializedLiteral() { return NULL; } 163 virtual MaterializedLiteral* AsMaterializedLiteral() { return NULL; }
166 164
167 // True if the node is simple enough for us to inline calls containing it. 165 // True if the node is simple enough for us to inline calls containing it.
168 virtual bool IsInlineable() const = 0; 166 // The 'function' argument is the function node that contains this node.
167 virtual bool IsInlineable(FunctionLiteral* function) const = 0;
169 168
170 static int Count() { return Isolate::Current()->ast_node_count(); }
171 static void ResetIds() { Isolate::Current()->set_ast_node_id(0); } 169 static void ResetIds() { Isolate::Current()->set_ast_node_id(0); }
172 170
173 protected: 171 protected:
174 static unsigned GetNextId(Isolate* isolate) { 172 static unsigned GetNextId(Isolate* isolate) {
175 return ReserveIdRange(isolate, 1); 173 return ReserveIdRange(isolate, 1);
176 } 174 }
177 175
178 static unsigned ReserveIdRange(Isolate* isolate, int n) { 176 static unsigned ReserveIdRange(Isolate* isolate, int n) {
179 unsigned tmp = isolate->ast_node_id(); 177 unsigned tmp = isolate->ast_node_id();
180 isolate->set_ast_node_id(tmp + n); 178 isolate->set_ast_node_id(tmp + n);
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 bool is_initializer_block) 359 bool is_initializer_block)
362 : BreakableStatement(isolate, labels, TARGET_FOR_NAMED_ONLY), 360 : BreakableStatement(isolate, labels, TARGET_FOR_NAMED_ONLY),
363 statements_(capacity), 361 statements_(capacity),
364 is_initializer_block_(is_initializer_block), 362 is_initializer_block_(is_initializer_block),
365 block_scope_(NULL) { 363 block_scope_(NULL) {
366 } 364 }
367 365
368 366
369 DECLARE_NODE_TYPE(Block) 367 DECLARE_NODE_TYPE(Block)
370 368
371 virtual bool IsInlineable() const; 369 virtual bool IsInlineable(FunctionLiteral* function) const;
372 370
373 void AddStatement(Statement* statement) { statements_.Add(statement); } 371 void AddStatement(Statement* statement) { statements_.Add(statement); }
374 372
375 ZoneList<Statement*>* statements() { return &statements_; } 373 ZoneList<Statement*>* statements() { return &statements_; }
376 bool is_initializer_block() const { return is_initializer_block_; } 374 bool is_initializer_block() const { return is_initializer_block_; }
377 375
378 Scope* block_scope() const { return block_scope_; } 376 Scope* block_scope() const { return block_scope_; }
379 void set_block_scope(Scope* block_scope) { block_scope_ = block_scope; } 377 void set_block_scope(Scope* block_scope) { block_scope_ = block_scope; }
380 378
381 private: 379 private:
(...skipping 19 matching lines...) Expand all
401 mode == LET); 399 mode == LET);
402 // At the moment there are no "const functions"'s in JavaScript... 400 // At the moment there are no "const functions"'s in JavaScript...
403 ASSERT(fun == NULL || mode == VAR || mode == LET); 401 ASSERT(fun == NULL || mode == VAR || mode == LET);
404 } 402 }
405 403
406 DECLARE_NODE_TYPE(Declaration) 404 DECLARE_NODE_TYPE(Declaration)
407 405
408 VariableProxy* proxy() const { return proxy_; } 406 VariableProxy* proxy() const { return proxy_; }
409 VariableMode mode() const { return mode_; } 407 VariableMode mode() const { return mode_; }
410 FunctionLiteral* fun() const { return fun_; } // may be NULL 408 FunctionLiteral* fun() const { return fun_; } // may be NULL
411 virtual bool IsInlineable() const; 409 virtual bool IsInlineable(FunctionLiteral* function) const;
412 Scope* scope() const { return scope_; } 410 Scope* scope() const { return scope_; }
413 411
414 private: 412 private:
415 VariableProxy* proxy_; 413 VariableProxy* proxy_;
416 VariableMode mode_; 414 VariableMode mode_;
417 FunctionLiteral* fun_; 415 FunctionLiteral* fun_;
418 416
419 // Nested scope from which the declaration originated. 417 // Nested scope from which the declaration originated.
420 Scope* scope_; 418 Scope* scope_;
421 }; 419 };
(...skipping 11 matching lines...) Expand all
433 virtual int ContinueId() const = 0; 431 virtual int ContinueId() const = 0;
434 virtual int StackCheckId() const = 0; 432 virtual int StackCheckId() const = 0;
435 433
436 // Code generation 434 // Code generation
437 Label* continue_target() { return &continue_target_; } 435 Label* continue_target() { return &continue_target_; }
438 436
439 protected: 437 protected:
440 IterationStatement(Isolate* isolate, ZoneStringList* labels) 438 IterationStatement(Isolate* isolate, ZoneStringList* labels)
441 : BreakableStatement(isolate, labels, TARGET_FOR_ANONYMOUS), 439 : BreakableStatement(isolate, labels, TARGET_FOR_ANONYMOUS),
442 body_(NULL), 440 body_(NULL),
443 osr_entry_id_(GetNextId(isolate)) { 441 osr_entry_id_(GetNextId(isolate)) { }
444 }
445 442
446 void Initialize(Statement* body) { 443 void Initialize(Statement* body) {
447 body_ = body; 444 body_ = body;
448 } 445 }
449 446
450 private: 447 private:
451 Statement* body_; 448 Statement* body_;
452 Label continue_target_; 449 Label continue_target_;
453 int osr_entry_id_; 450 int osr_entry_id_;
454 }; 451 };
455 452
456 453
457 class DoWhileStatement: public IterationStatement { 454 class DoWhileStatement: public IterationStatement {
458 public: 455 public:
459 DoWhileStatement(Isolate* isolate, ZoneStringList* labels) 456 DoWhileStatement(Isolate* isolate, ZoneStringList* labels)
460 : IterationStatement(isolate, labels), 457 : IterationStatement(isolate, labels),
461 cond_(NULL), 458 cond_(NULL),
462 condition_position_(-1), 459 condition_position_(-1),
463 continue_id_(GetNextId(isolate)), 460 continue_id_(GetNextId(isolate)),
464 back_edge_id_(GetNextId(isolate)) { 461 back_edge_id_(GetNextId(isolate)) { }
465 }
466 462
467 DECLARE_NODE_TYPE(DoWhileStatement) 463 DECLARE_NODE_TYPE(DoWhileStatement)
468 464
469 void Initialize(Expression* cond, Statement* body) { 465 void Initialize(Expression* cond, Statement* body) {
470 IterationStatement::Initialize(body); 466 IterationStatement::Initialize(body);
471 cond_ = cond; 467 cond_ = cond;
472 } 468 }
473 469
474 Expression* cond() const { return cond_; } 470 Expression* cond() const { return cond_; }
475 471
476 // Position where condition expression starts. We need it to make 472 // Position where condition expression starts. We need it to make
477 // the loop's condition a breakable location. 473 // the loop's condition a breakable location.
478 int condition_position() { return condition_position_; } 474 int condition_position() { return condition_position_; }
479 void set_condition_position(int pos) { condition_position_ = pos; } 475 void set_condition_position(int pos) { condition_position_ = pos; }
480 476
481 // Bailout support. 477 // Bailout support.
482 virtual int ContinueId() const { return continue_id_; } 478 virtual int ContinueId() const { return continue_id_; }
483 virtual int StackCheckId() const { return back_edge_id_; } 479 virtual int StackCheckId() const { return back_edge_id_; }
484 int BackEdgeId() const { return back_edge_id_; } 480 int BackEdgeId() const { return back_edge_id_; }
485 481
486 virtual bool IsInlineable() const; 482 virtual bool IsInlineable(FunctionLiteral* function) const;
487 483
488 private: 484 private:
489 Expression* cond_; 485 Expression* cond_;
490 int condition_position_; 486 int condition_position_;
491 int continue_id_; 487 int continue_id_;
492 int back_edge_id_; 488 int back_edge_id_;
493 }; 489 };
494 490
495 491
496 class WhileStatement: public IterationStatement { 492 class WhileStatement: public IterationStatement {
497 public: 493 public:
498 WhileStatement(Isolate* isolate, ZoneStringList* labels) 494 WhileStatement(Isolate* isolate, ZoneStringList* labels)
499 : IterationStatement(isolate, labels), 495 : IterationStatement(isolate, labels),
500 cond_(NULL), 496 cond_(NULL),
501 may_have_function_literal_(true), 497 may_have_function_literal_(true),
502 body_id_(GetNextId(isolate)) { 498 body_id_(GetNextId(isolate)) { }
503 }
504 499
505 DECLARE_NODE_TYPE(WhileStatement) 500 DECLARE_NODE_TYPE(WhileStatement)
506 501
507 void Initialize(Expression* cond, Statement* body) { 502 void Initialize(Expression* cond, Statement* body) {
508 IterationStatement::Initialize(body); 503 IterationStatement::Initialize(body);
509 cond_ = cond; 504 cond_ = cond;
510 } 505 }
511 506
512 Expression* cond() const { return cond_; } 507 Expression* cond() const { return cond_; }
513 bool may_have_function_literal() const { 508 bool may_have_function_literal() const {
514 return may_have_function_literal_; 509 return may_have_function_literal_;
515 } 510 }
516 void set_may_have_function_literal(bool value) { 511 void set_may_have_function_literal(bool value) {
517 may_have_function_literal_ = value; 512 may_have_function_literal_ = value;
518 } 513 }
519 virtual bool IsInlineable() const; 514 virtual bool IsInlineable(FunctionLiteral* function) const;
520 515
521 // Bailout support. 516 // Bailout support.
522 virtual int ContinueId() const { return EntryId(); } 517 virtual int ContinueId() const { return EntryId(); }
523 virtual int StackCheckId() const { return body_id_; } 518 virtual int StackCheckId() const { return body_id_; }
524 int BodyId() const { return body_id_; } 519 int BodyId() const { return body_id_; }
525 520
526 private: 521 private:
527 Expression* cond_; 522 Expression* cond_;
528 // True if there is a function literal subexpression in the condition. 523 // True if there is a function literal subexpression in the condition.
529 bool may_have_function_literal_; 524 bool may_have_function_literal_;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 } 563 }
569 564
570 // Bailout support. 565 // Bailout support.
571 virtual int ContinueId() const { return continue_id_; } 566 virtual int ContinueId() const { return continue_id_; }
572 virtual int StackCheckId() const { return body_id_; } 567 virtual int StackCheckId() const { return body_id_; }
573 int BodyId() const { return body_id_; } 568 int BodyId() const { return body_id_; }
574 569
575 bool is_fast_smi_loop() { return loop_variable_ != NULL; } 570 bool is_fast_smi_loop() { return loop_variable_ != NULL; }
576 Variable* loop_variable() { return loop_variable_; } 571 Variable* loop_variable() { return loop_variable_; }
577 void set_loop_variable(Variable* var) { loop_variable_ = var; } 572 void set_loop_variable(Variable* var) { loop_variable_ = var; }
578 virtual bool IsInlineable() const; 573 virtual bool IsInlineable(FunctionLiteral* function) const;
579 574
580 private: 575 private:
581 Statement* init_; 576 Statement* init_;
582 Expression* cond_; 577 Expression* cond_;
583 Statement* next_; 578 Statement* next_;
584 // True if there is a function literal subexpression in the condition. 579 // True if there is a function literal subexpression in the condition.
585 bool may_have_function_literal_; 580 bool may_have_function_literal_;
586 Variable* loop_variable_; 581 Variable* loop_variable_;
587 int continue_id_; 582 int continue_id_;
588 int body_id_; 583 int body_id_;
589 }; 584 };
590 585
591 586
592 class ForInStatement: public IterationStatement { 587 class ForInStatement: public IterationStatement {
593 public: 588 public:
594 ForInStatement(Isolate* isolate, ZoneStringList* labels) 589 ForInStatement(Isolate* isolate, ZoneStringList* labels)
595 : IterationStatement(isolate, labels), 590 : IterationStatement(isolate, labels),
596 each_(NULL), 591 each_(NULL),
597 enumerable_(NULL), 592 enumerable_(NULL),
598 assignment_id_(GetNextId(isolate)) { 593 assignment_id_(GetNextId(isolate)) { }
599 }
600 594
601 DECLARE_NODE_TYPE(ForInStatement) 595 DECLARE_NODE_TYPE(ForInStatement)
602 596
603 void Initialize(Expression* each, Expression* enumerable, Statement* body) { 597 void Initialize(Expression* each, Expression* enumerable, Statement* body) {
604 IterationStatement::Initialize(body); 598 IterationStatement::Initialize(body);
605 each_ = each; 599 each_ = each;
606 enumerable_ = enumerable; 600 enumerable_ = enumerable;
607 } 601 }
608 602
609 Expression* each() const { return each_; } 603 Expression* each() const { return each_; }
610 Expression* enumerable() const { return enumerable_; } 604 Expression* enumerable() const { return enumerable_; }
611 virtual bool IsInlineable() const; 605 virtual bool IsInlineable(FunctionLiteral* function) const;
612 606
613 // Bailout support. 607 // Bailout support.
614 int AssignmentId() const { return assignment_id_; } 608 int AssignmentId() const { return assignment_id_; }
615 virtual int ContinueId() const { return EntryId(); } 609 virtual int ContinueId() const { return EntryId(); }
616 virtual int StackCheckId() const { return EntryId(); } 610 virtual int StackCheckId() const { return EntryId(); }
617 611
618 private: 612 private:
619 Expression* each_; 613 Expression* each_;
620 Expression* enumerable_; 614 Expression* enumerable_;
621 int assignment_id_; 615 int assignment_id_;
622 }; 616 };
623 617
624 618
625 class ExpressionStatement: public Statement { 619 class ExpressionStatement: public Statement {
626 public: 620 public:
627 explicit ExpressionStatement(Expression* expression) 621 explicit ExpressionStatement(Expression* expression)
628 : expression_(expression) { } 622 : expression_(expression) { }
629 623
630 DECLARE_NODE_TYPE(ExpressionStatement) 624 DECLARE_NODE_TYPE(ExpressionStatement)
631 625
632 virtual bool IsInlineable() const; 626 virtual bool IsInlineable(FunctionLiteral* function) const;
633 627
634 void set_expression(Expression* e) { expression_ = e; } 628 void set_expression(Expression* e) { expression_ = e; }
635 Expression* expression() const { return expression_; } 629 Expression* expression() const { return expression_; }
636 630
637 private: 631 private:
638 Expression* expression_; 632 Expression* expression_;
639 }; 633 };
640 634
641 635
642 class ContinueStatement: public Statement { 636 class ContinueStatement: public Statement {
643 public: 637 public:
644 explicit ContinueStatement(IterationStatement* target) 638 explicit ContinueStatement(IterationStatement* target)
645 : target_(target) { } 639 : target_(target) { }
646 640
647 DECLARE_NODE_TYPE(ContinueStatement) 641 DECLARE_NODE_TYPE(ContinueStatement)
648 642
649 IterationStatement* target() const { return target_; } 643 IterationStatement* target() const { return target_; }
650 virtual bool IsInlineable() const; 644 virtual bool IsInlineable(FunctionLiteral* function) const;
651 645
652 private: 646 private:
653 IterationStatement* target_; 647 IterationStatement* target_;
654 }; 648 };
655 649
656 650
657 class BreakStatement: public Statement { 651 class BreakStatement: public Statement {
658 public: 652 public:
659 explicit BreakStatement(BreakableStatement* target) 653 explicit BreakStatement(BreakableStatement* target)
660 : target_(target) { } 654 : target_(target) { }
661 655
662 DECLARE_NODE_TYPE(BreakStatement) 656 DECLARE_NODE_TYPE(BreakStatement)
663 657
664 BreakableStatement* target() const { return target_; } 658 BreakableStatement* target() const { return target_; }
665 virtual bool IsInlineable() const; 659 virtual bool IsInlineable(FunctionLiteral* function) const;
666 660
667 private: 661 private:
668 BreakableStatement* target_; 662 BreakableStatement* target_;
669 }; 663 };
670 664
671 665
672 class ReturnStatement: public Statement { 666 class ReturnStatement: public Statement {
673 public: 667 public:
674 explicit ReturnStatement(Expression* expression) 668 explicit ReturnStatement(Expression* expression)
675 : expression_(expression) { } 669 : expression_(expression) { }
676 670
677 DECLARE_NODE_TYPE(ReturnStatement) 671 DECLARE_NODE_TYPE(ReturnStatement)
678 672
679 Expression* expression() const { return expression_; } 673 Expression* expression() const { return expression_; }
680 virtual bool IsInlineable() const; 674 virtual bool IsInlineable(FunctionLiteral* function) const;
681 675
682 private: 676 private:
683 Expression* expression_; 677 Expression* expression_;
684 }; 678 };
685 679
686 680
687 class WithStatement: public Statement { 681 class WithStatement: public Statement {
688 public: 682 public:
689 WithStatement(Expression* expression, Statement* statement) 683 WithStatement(Expression* expression, Statement* statement)
690 : expression_(expression), statement_(statement) { } 684 : expression_(expression), statement_(statement) { }
691 685
692 DECLARE_NODE_TYPE(WithStatement) 686 DECLARE_NODE_TYPE(WithStatement)
693 687
694 Expression* expression() const { return expression_; } 688 Expression* expression() const { return expression_; }
695 Statement* statement() const { return statement_; } 689 Statement* statement() const { return statement_; }
696 690
697 virtual bool IsInlineable() const; 691 virtual bool IsInlineable(FunctionLiteral* function) const;
698 692
699 private: 693 private:
700 Expression* expression_; 694 Expression* expression_;
701 Statement* statement_; 695 Statement* statement_;
702 }; 696 };
703 697
704 698
705 class CaseClause: public ZoneObject { 699 class CaseClause: public ZoneObject {
706 public: 700 public:
707 CaseClause(Isolate* isolate, 701 CaseClause(Isolate* isolate,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 int compare_id_; 740 int compare_id_;
747 int entry_id_; 741 int entry_id_;
748 }; 742 };
749 743
750 744
751 class SwitchStatement: public BreakableStatement { 745 class SwitchStatement: public BreakableStatement {
752 public: 746 public:
753 SwitchStatement(Isolate* isolate, ZoneStringList* labels) 747 SwitchStatement(Isolate* isolate, ZoneStringList* labels)
754 : BreakableStatement(isolate, labels, TARGET_FOR_ANONYMOUS), 748 : BreakableStatement(isolate, labels, TARGET_FOR_ANONYMOUS),
755 tag_(NULL), 749 tag_(NULL),
756 cases_(NULL) { 750 cases_(NULL) { }
757 }
758 751
759 752
760 DECLARE_NODE_TYPE(SwitchStatement) 753 DECLARE_NODE_TYPE(SwitchStatement)
761 754
762 void Initialize(Expression* tag, ZoneList<CaseClause*>* cases) { 755 void Initialize(Expression* tag, ZoneList<CaseClause*>* cases) {
763 tag_ = tag; 756 tag_ = tag;
764 cases_ = cases; 757 cases_ = cases;
765 } 758 }
766 759
767 Expression* tag() const { return tag_; } 760 Expression* tag() const { return tag_; }
768 ZoneList<CaseClause*>* cases() const { return cases_; } 761 ZoneList<CaseClause*>* cases() const { return cases_; }
769 virtual bool IsInlineable() const; 762 virtual bool IsInlineable(FunctionLiteral* function) const;
770 763
771 private: 764 private:
772 Expression* tag_; 765 Expression* tag_;
773 ZoneList<CaseClause*>* cases_; 766 ZoneList<CaseClause*>* cases_;
774 }; 767 };
775 768
776 769
777 // If-statements always have non-null references to their then- and 770 // If-statements always have non-null references to their then- and
778 // else-parts. When parsing if-statements with no explicit else-part, 771 // else-parts. When parsing if-statements with no explicit else-part,
779 // the parser implicitly creates an empty statement. Use the 772 // the parser implicitly creates an empty statement. Use the
780 // HasThenStatement() and HasElseStatement() functions to check if a 773 // HasThenStatement() and HasElseStatement() functions to check if a
781 // given if-statement has a then- or an else-part containing code. 774 // given if-statement has a then- or an else-part containing code.
782 class IfStatement: public Statement { 775 class IfStatement: public Statement {
783 public: 776 public:
784 IfStatement(Isolate* isolate, 777 IfStatement(Isolate* isolate,
785 Expression* condition, 778 Expression* condition,
786 Statement* then_statement, 779 Statement* then_statement,
787 Statement* else_statement) 780 Statement* else_statement)
788 : condition_(condition), 781 : condition_(condition),
789 then_statement_(then_statement), 782 then_statement_(then_statement),
790 else_statement_(else_statement), 783 else_statement_(else_statement),
791 if_id_(GetNextId(isolate)), 784 if_id_(GetNextId(isolate)),
792 then_id_(GetNextId(isolate)), 785 then_id_(GetNextId(isolate)),
793 else_id_(GetNextId(isolate)) { 786 else_id_(GetNextId(isolate)) { }
794 }
795 787
796 DECLARE_NODE_TYPE(IfStatement) 788 DECLARE_NODE_TYPE(IfStatement)
797 789
798 virtual bool IsInlineable() const; 790 virtual bool IsInlineable(FunctionLiteral* function) const;
799 791
800 bool HasThenStatement() const { return !then_statement()->IsEmpty(); } 792 bool HasThenStatement() const { return !then_statement()->IsEmpty(); }
801 bool HasElseStatement() const { return !else_statement()->IsEmpty(); } 793 bool HasElseStatement() const { return !else_statement()->IsEmpty(); }
802 794
803 Expression* condition() const { return condition_; } 795 Expression* condition() const { return condition_; }
804 Statement* then_statement() const { return then_statement_; } 796 Statement* then_statement() const { return then_statement_; }
805 Statement* else_statement() const { return else_statement_; } 797 Statement* else_statement() const { return else_statement_; }
806 798
807 int IfId() const { return if_id_; } 799 int IfId() const { return if_id_; }
808 int ThenId() const { return then_id_; } 800 int ThenId() const { return then_id_; }
(...skipping 18 matching lines...) Expand all
827 // Adds a jump target to the collector. The collector stores a pointer not 819 // Adds a jump target to the collector. The collector stores a pointer not
828 // a copy of the target to make binding work, so make sure not to pass in 820 // a copy of the target to make binding work, so make sure not to pass in
829 // references to something on the stack. 821 // references to something on the stack.
830 void AddTarget(Label* target); 822 void AddTarget(Label* target);
831 823
832 // Virtual behaviour. TargetCollectors are never part of the AST. 824 // Virtual behaviour. TargetCollectors are never part of the AST.
833 virtual void Accept(AstVisitor* v) { UNREACHABLE(); } 825 virtual void Accept(AstVisitor* v) { UNREACHABLE(); }
834 virtual TargetCollector* AsTargetCollector() { return this; } 826 virtual TargetCollector* AsTargetCollector() { return this; }
835 827
836 ZoneList<Label*>* targets() { return &targets_; } 828 ZoneList<Label*>* targets() { return &targets_; }
837 virtual bool IsInlineable() const; 829 virtual bool IsInlineable(FunctionLiteral* function) const;
838 830
839 private: 831 private:
840 ZoneList<Label*> targets_; 832 ZoneList<Label*> targets_;
841 }; 833 };
842 834
843 835
844 class TryStatement: public Statement { 836 class TryStatement: public Statement {
845 public: 837 public:
846 explicit TryStatement(int index, Block* try_block) 838 explicit TryStatement(int index, Block* try_block)
847 : index_(index), 839 : index_(index),
848 try_block_(try_block), 840 try_block_(try_block),
849 escaping_targets_(NULL) { 841 escaping_targets_(NULL) { }
850 }
851 842
852 void set_escaping_targets(ZoneList<Label*>* targets) { 843 void set_escaping_targets(ZoneList<Label*>* targets) {
853 escaping_targets_ = targets; 844 escaping_targets_ = targets;
854 } 845 }
855 846
856 int index() const { return index_; } 847 int index() const { return index_; }
857 Block* try_block() const { return try_block_; } 848 Block* try_block() const { return try_block_; }
858 ZoneList<Label*>* escaping_targets() const { return escaping_targets_; } 849 ZoneList<Label*>* escaping_targets() const { return escaping_targets_; }
859 virtual bool IsInlineable() const; 850 virtual bool IsInlineable(FunctionLiteral* function) const;
860 851
861 private: 852 private:
862 // Unique (per-function) index of this handler. This is not an AST ID. 853 // Unique (per-function) index of this handler. This is not an AST ID.
863 int index_; 854 int index_;
864 855
865 Block* try_block_; 856 Block* try_block_;
866 ZoneList<Label*>* escaping_targets_; 857 ZoneList<Label*>* escaping_targets_;
867 }; 858 };
868 859
869 860
870 class TryCatchStatement: public TryStatement { 861 class TryCatchStatement: public TryStatement {
871 public: 862 public:
872 TryCatchStatement(int index, 863 TryCatchStatement(int index,
873 Block* try_block, 864 Block* try_block,
874 Scope* scope, 865 Scope* scope,
875 Variable* variable, 866 Variable* variable,
876 Block* catch_block) 867 Block* catch_block)
877 : TryStatement(index, try_block), 868 : TryStatement(index, try_block),
878 scope_(scope), 869 scope_(scope),
879 variable_(variable), 870 variable_(variable),
880 catch_block_(catch_block) { 871 catch_block_(catch_block) { }
881 }
882 872
883 DECLARE_NODE_TYPE(TryCatchStatement) 873 DECLARE_NODE_TYPE(TryCatchStatement)
884 874
885 Scope* scope() { return scope_; } 875 Scope* scope() { return scope_; }
886 Variable* variable() { return variable_; } 876 Variable* variable() { return variable_; }
887 Block* catch_block() const { return catch_block_; } 877 Block* catch_block() const { return catch_block_; }
888 virtual bool IsInlineable() const; 878 virtual bool IsInlineable(FunctionLiteral* function) const;
889 879
890 private: 880 private:
891 Scope* scope_; 881 Scope* scope_;
892 Variable* variable_; 882 Variable* variable_;
893 Block* catch_block_; 883 Block* catch_block_;
894 }; 884 };
895 885
896 886
897 class TryFinallyStatement: public TryStatement { 887 class TryFinallyStatement: public TryStatement {
898 public: 888 public:
899 TryFinallyStatement(int index, Block* try_block, Block* finally_block) 889 TryFinallyStatement(int index,
890 Block* try_block,
891 Block* finally_block)
900 : TryStatement(index, try_block), 892 : TryStatement(index, try_block),
901 finally_block_(finally_block) { } 893 finally_block_(finally_block) { }
902 894
903 DECLARE_NODE_TYPE(TryFinallyStatement) 895 DECLARE_NODE_TYPE(TryFinallyStatement)
904 896
905 Block* finally_block() const { return finally_block_; } 897 Block* finally_block() const { return finally_block_; }
906 virtual bool IsInlineable() const; 898 virtual bool IsInlineable(FunctionLiteral* function) const;
907 899
908 private: 900 private:
909 Block* finally_block_; 901 Block* finally_block_;
910 }; 902 };
911 903
912 904
913 class DebuggerStatement: public Statement { 905 class DebuggerStatement: public Statement {
914 public: 906 public:
915 DECLARE_NODE_TYPE(DebuggerStatement) 907 DECLARE_NODE_TYPE(DebuggerStatement)
916 virtual bool IsInlineable() const; 908 virtual bool IsInlineable(FunctionLiteral* function) const;
917 }; 909 };
918 910
919 911
920 class EmptyStatement: public Statement { 912 class EmptyStatement: public Statement {
921 public: 913 public:
922 DECLARE_NODE_TYPE(EmptyStatement) 914 DECLARE_NODE_TYPE(EmptyStatement)
923 915
924 virtual bool IsInlineable() const; 916 virtual bool IsInlineable(FunctionLiteral* function) const;
925 }; 917 };
926 918
927 919
928 class Literal: public Expression { 920 class Literal: public Expression {
929 public: 921 public:
930 Literal(Isolate* isolate, Handle<Object> handle) 922 Literal(Isolate* isolate, Handle<Object> handle)
931 : Expression(isolate), handle_(handle) { } 923 : Expression(isolate), handle_(handle) { }
932 924
933 DECLARE_NODE_TYPE(Literal) 925 DECLARE_NODE_TYPE(Literal)
934 926
(...skipping 26 matching lines...) Expand all
961 bool IsTrue() const { 953 bool IsTrue() const {
962 ASSERT(!handle_.is_null()); 954 ASSERT(!handle_.is_null());
963 return handle_->IsTrue(); 955 return handle_->IsTrue();
964 } 956 }
965 bool IsFalse() const { 957 bool IsFalse() const {
966 ASSERT(!handle_.is_null()); 958 ASSERT(!handle_.is_null());
967 return handle_->IsFalse(); 959 return handle_->IsFalse();
968 } 960 }
969 961
970 Handle<Object> handle() const { return handle_; } 962 Handle<Object> handle() const { return handle_; }
971 virtual bool IsInlineable() const; 963 virtual bool IsInlineable(FunctionLiteral* function) const;
972 964
973 private: 965 private:
974 Handle<Object> handle_; 966 Handle<Object> handle_;
975 }; 967 };
976 968
977 969
978 // Base class for literals that needs space in the corresponding JSFunction. 970 // Base class for literals that needs space in the corresponding JSFunction.
979 class MaterializedLiteral: public Expression { 971 class MaterializedLiteral: public Expression {
980 public: 972 public:
981 MaterializedLiteral(Isolate* isolate, 973 MaterializedLiteral(Isolate* isolate,
982 int literal_index, 974 int literal_index,
983 bool is_simple, 975 bool is_simple,
984 int depth) 976 int depth)
985 : Expression(isolate), 977 : Expression(isolate),
986 literal_index_(literal_index), 978 literal_index_(literal_index),
987 is_simple_(is_simple), 979 is_simple_(is_simple),
988 depth_(depth) {} 980 depth_(depth) {}
989 981
990 virtual MaterializedLiteral* AsMaterializedLiteral() { return this; } 982 virtual MaterializedLiteral* AsMaterializedLiteral() { return this; }
991 983
992 int literal_index() { return literal_index_; } 984 int literal_index() { return literal_index_; }
993 985
994 // A materialized literal is simple if the values consist of only 986 // A materialized literal is simple if the values consist of only
995 // constants and simple object and array literals. 987 // constants and simple object and array literals.
996 bool is_simple() const { return is_simple_; } 988 bool is_simple() const { return is_simple_; }
997 989
998 int depth() const { return depth_; } 990 int depth() const { return depth_; }
999 virtual bool IsInlineable() const; 991 virtual bool IsInlineable(FunctionLiteral* function) const;
1000 992
1001 private: 993 private:
1002 int literal_index_; 994 int literal_index_;
1003 bool is_simple_; 995 bool is_simple_;
1004 int depth_; 996 int depth_;
1005 }; 997 };
1006 998
1007 999
1008 // An object literal has a boilerplate object that is used 1000 // An object literal has a boilerplate object that is used
1009 // for minimizing the work when constructing it at runtime. 1001 // for minimizing the work when constructing it at runtime.
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
1139 class VariableProxy: public Expression { 1131 class VariableProxy: public Expression {
1140 public: 1132 public:
1141 VariableProxy(Isolate* isolate, Variable* var); 1133 VariableProxy(Isolate* isolate, Variable* var);
1142 1134
1143 DECLARE_NODE_TYPE(VariableProxy) 1135 DECLARE_NODE_TYPE(VariableProxy)
1144 1136
1145 virtual bool IsValidLeftHandSide() { 1137 virtual bool IsValidLeftHandSide() {
1146 return var_ == NULL ? true : var_->IsValidLeftHandSide(); 1138 return var_ == NULL ? true : var_->IsValidLeftHandSide();
1147 } 1139 }
1148 1140
1149 virtual bool IsInlineable() const; 1141 virtual bool IsInlineable(FunctionLiteral* function) const;
1150 1142
1151 bool IsVariable(Handle<String> n) { 1143 bool IsVariable(Handle<String> n) {
1152 return !is_this() && name().is_identical_to(n); 1144 return !is_this() && name().is_identical_to(n);
1153 } 1145 }
1154 1146
1155 bool IsArguments() { return var_ != NULL && var_->is_arguments(); } 1147 bool IsArguments() { return var_ != NULL && var_->is_arguments(); }
1156 1148
1157 Handle<String> name() const { return name_; } 1149 Handle<String> name() const { return name_; }
1158 Variable* var() const { return var_; } 1150 Variable* var() const { return var_; }
1159 bool is_this() const { return is_this_; } 1151 bool is_this() const { return is_this_; }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1192 pos_(pos), 1184 pos_(pos),
1193 is_monomorphic_(false), 1185 is_monomorphic_(false),
1194 is_array_length_(false), 1186 is_array_length_(false),
1195 is_string_length_(false), 1187 is_string_length_(false),
1196 is_string_access_(false), 1188 is_string_access_(false),
1197 is_function_prototype_(false) { } 1189 is_function_prototype_(false) { }
1198 1190
1199 DECLARE_NODE_TYPE(Property) 1191 DECLARE_NODE_TYPE(Property)
1200 1192
1201 virtual bool IsValidLeftHandSide() { return true; } 1193 virtual bool IsValidLeftHandSide() { return true; }
1202 virtual bool IsInlineable() const; 1194 virtual bool IsInlineable(FunctionLiteral* function) const;
1203 1195
1204 Expression* obj() const { return obj_; } 1196 Expression* obj() const { return obj_; }
1205 Expression* key() const { return key_; } 1197 Expression* key() const { return key_; }
1206 virtual int position() const { return pos_; } 1198 virtual int position() const { return pos_; }
1207 1199
1208 bool IsStringLength() const { return is_string_length_; } 1200 bool IsStringLength() const { return is_string_length_; }
1209 bool IsStringAccess() const { return is_string_access_; } 1201 bool IsStringAccess() const { return is_string_access_; }
1210 bool IsFunctionPrototype() const { return is_function_prototype_; } 1202 bool IsFunctionPrototype() const { return is_function_prototype_; }
1211 1203
1212 // Type feedback information. 1204 // Type feedback information.
(...skipping 21 matching lines...) Expand all
1234 Call(Isolate* isolate, 1226 Call(Isolate* isolate,
1235 Expression* expression, 1227 Expression* expression,
1236 ZoneList<Expression*>* arguments, 1228 ZoneList<Expression*>* arguments,
1237 int pos) 1229 int pos)
1238 : Expression(isolate), 1230 : Expression(isolate),
1239 expression_(expression), 1231 expression_(expression),
1240 arguments_(arguments), 1232 arguments_(arguments),
1241 pos_(pos), 1233 pos_(pos),
1242 is_monomorphic_(false), 1234 is_monomorphic_(false),
1243 check_type_(RECEIVER_MAP_CHECK), 1235 check_type_(RECEIVER_MAP_CHECK),
1244 return_id_(GetNextId(isolate)) { 1236 return_id_(GetNextId(isolate)) { }
1245 }
1246 1237
1247 DECLARE_NODE_TYPE(Call) 1238 DECLARE_NODE_TYPE(Call)
1248 1239
1249 virtual bool IsInlineable() const; 1240 virtual bool IsInlineable(FunctionLiteral* function) const;
1250 1241
1251 Expression* expression() const { return expression_; } 1242 Expression* expression() const { return expression_; }
1252 ZoneList<Expression*>* arguments() const { return arguments_; } 1243 ZoneList<Expression*>* arguments() const { return arguments_; }
1253 virtual int position() const { return pos_; } 1244 virtual int position() const { return pos_; }
1254 1245
1255 void RecordTypeFeedback(TypeFeedbackOracle* oracle, 1246 void RecordTypeFeedback(TypeFeedbackOracle* oracle,
1256 CallKind call_kind); 1247 CallKind call_kind);
1257 virtual SmallMapList* GetReceiverTypes() { return &receiver_types_; } 1248 virtual SmallMapList* GetReceiverTypes() { return &receiver_types_; }
1258 virtual bool IsMonomorphic() { return is_monomorphic_; } 1249 virtual bool IsMonomorphic() { return is_monomorphic_; }
1259 CheckType check_type() const { return check_type_; } 1250 CheckType check_type() const { return check_type_; }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1294 Expression* expression, 1285 Expression* expression,
1295 ZoneList<Expression*>* arguments, 1286 ZoneList<Expression*>* arguments,
1296 int pos) 1287 int pos)
1297 : Expression(isolate), 1288 : Expression(isolate),
1298 expression_(expression), 1289 expression_(expression),
1299 arguments_(arguments), 1290 arguments_(arguments),
1300 pos_(pos) { } 1291 pos_(pos) { }
1301 1292
1302 DECLARE_NODE_TYPE(CallNew) 1293 DECLARE_NODE_TYPE(CallNew)
1303 1294
1304 virtual bool IsInlineable() const; 1295 virtual bool IsInlineable(FunctionLiteral* function) const;
1305 1296
1306 Expression* expression() const { return expression_; } 1297 Expression* expression() const { return expression_; }
1307 ZoneList<Expression*>* arguments() const { return arguments_; } 1298 ZoneList<Expression*>* arguments() const { return arguments_; }
1308 virtual int position() const { return pos_; } 1299 virtual int position() const { return pos_; }
1309 1300
1310 private: 1301 private:
1311 Expression* expression_; 1302 Expression* expression_;
1312 ZoneList<Expression*>* arguments_; 1303 ZoneList<Expression*>* arguments_;
1313 int pos_; 1304 int pos_;
1314 }; 1305 };
1315 1306
1316 1307
1317 // The CallRuntime class does not represent any official JavaScript 1308 // The CallRuntime class does not represent any official JavaScript
1318 // language construct. Instead it is used to call a C or JS function 1309 // language construct. Instead it is used to call a C or JS function
1319 // with a set of arguments. This is used from the builtins that are 1310 // with a set of arguments. This is used from the builtins that are
1320 // implemented in JavaScript (see "v8natives.js"). 1311 // implemented in JavaScript (see "v8natives.js").
1321 class CallRuntime: public Expression { 1312 class CallRuntime: public Expression {
1322 public: 1313 public:
1323 CallRuntime(Isolate* isolate, 1314 CallRuntime(Isolate* isolate,
1324 Handle<String> name, 1315 Handle<String> name,
1325 const Runtime::Function* function, 1316 const Runtime::Function* function,
1326 ZoneList<Expression*>* arguments) 1317 ZoneList<Expression*>* arguments)
1327 : Expression(isolate), 1318 : Expression(isolate),
1328 name_(name), 1319 name_(name),
1329 function_(function), 1320 function_(function),
1330 arguments_(arguments) { } 1321 arguments_(arguments) { }
1331 1322
1332 DECLARE_NODE_TYPE(CallRuntime) 1323 DECLARE_NODE_TYPE(CallRuntime)
1333 1324
1334 virtual bool IsInlineable() const; 1325 virtual bool IsInlineable(FunctionLiteral* function) const;
1335 1326
1336 Handle<String> name() const { return name_; } 1327 Handle<String> name() const { return name_; }
1337 const Runtime::Function* function() const { return function_; } 1328 const Runtime::Function* function() const { return function_; }
1338 ZoneList<Expression*>* arguments() const { return arguments_; } 1329 ZoneList<Expression*>* arguments() const { return arguments_; }
1339 bool is_jsruntime() const { return function_ == NULL; } 1330 bool is_jsruntime() const { return function_ == NULL; }
1340 1331
1341 private: 1332 private:
1342 Handle<String> name_; 1333 Handle<String> name_;
1343 const Runtime::Function* function_; 1334 const Runtime::Function* function_;
1344 ZoneList<Expression*>* arguments_; 1335 ZoneList<Expression*>* arguments_;
(...skipping 14 matching lines...) Expand all
1359 materialize_false_id_(AstNode::kNoNumber) { 1350 materialize_false_id_(AstNode::kNoNumber) {
1360 ASSERT(Token::IsUnaryOp(op)); 1351 ASSERT(Token::IsUnaryOp(op));
1361 if (op == Token::NOT) { 1352 if (op == Token::NOT) {
1362 materialize_true_id_ = GetNextId(isolate); 1353 materialize_true_id_ = GetNextId(isolate);
1363 materialize_false_id_ = GetNextId(isolate); 1354 materialize_false_id_ = GetNextId(isolate);
1364 } 1355 }
1365 } 1356 }
1366 1357
1367 DECLARE_NODE_TYPE(UnaryOperation) 1358 DECLARE_NODE_TYPE(UnaryOperation)
1368 1359
1369 virtual bool IsInlineable() const; 1360 virtual bool IsInlineable(FunctionLiteral* function) const;
1370 1361
1371 virtual bool ResultOverwriteAllowed(); 1362 virtual bool ResultOverwriteAllowed();
1372 1363
1373 Token::Value op() const { return op_; } 1364 Token::Value op() const { return op_; }
1374 Expression* expression() const { return expression_; } 1365 Expression* expression() const { return expression_; }
1375 virtual int position() const { return pos_; } 1366 virtual int position() const { return pos_; }
1376 1367
1377 int MaterializeTrueId() { return materialize_true_id_; } 1368 int MaterializeTrueId() { return materialize_true_id_; }
1378 int MaterializeFalseId() { return materialize_false_id_; } 1369 int MaterializeFalseId() { return materialize_false_id_; }
1379 1370
(...skipping 18 matching lines...) Expand all
1398 int pos) 1389 int pos)
1399 : Expression(isolate), op_(op), left_(left), right_(right), pos_(pos) { 1390 : Expression(isolate), op_(op), left_(left), right_(right), pos_(pos) {
1400 ASSERT(Token::IsBinaryOp(op)); 1391 ASSERT(Token::IsBinaryOp(op));
1401 right_id_ = (op == Token::AND || op == Token::OR) 1392 right_id_ = (op == Token::AND || op == Token::OR)
1402 ? static_cast<int>(GetNextId(isolate)) 1393 ? static_cast<int>(GetNextId(isolate))
1403 : AstNode::kNoNumber; 1394 : AstNode::kNoNumber;
1404 } 1395 }
1405 1396
1406 DECLARE_NODE_TYPE(BinaryOperation) 1397 DECLARE_NODE_TYPE(BinaryOperation)
1407 1398
1408 virtual bool IsInlineable() const; 1399 virtual bool IsInlineable(FunctionLiteral* function) const;
1409 1400
1410 virtual bool ResultOverwriteAllowed(); 1401 virtual bool ResultOverwriteAllowed();
1411 1402
1412 Token::Value op() const { return op_; } 1403 Token::Value op() const { return op_; }
1413 Expression* left() const { return left_; } 1404 Expression* left() const { return left_; }
1414 Expression* right() const { return right_; } 1405 Expression* right() const { return right_; }
1415 virtual int position() const { return pos_; } 1406 virtual int position() const { return pos_; }
1416 1407
1417 // Bailout support. 1408 // Bailout support.
1418 int RightId() const { return right_id_; } 1409 int RightId() const { return right_id_; }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1451 Token::Value op() const { return op_; } 1442 Token::Value op() const { return op_; }
1452 Token::Value binary_op() { 1443 Token::Value binary_op() {
1453 return (op() == Token::INC) ? Token::ADD : Token::SUB; 1444 return (op() == Token::INC) ? Token::ADD : Token::SUB;
1454 } 1445 }
1455 1446
1456 Expression* expression() const { return expression_; } 1447 Expression* expression() const { return expression_; }
1457 virtual int position() const { return pos_; } 1448 virtual int position() const { return pos_; }
1458 1449
1459 virtual void MarkAsStatement() { is_prefix_ = true; } 1450 virtual void MarkAsStatement() { is_prefix_ = true; }
1460 1451
1461 virtual bool IsInlineable() const; 1452 virtual bool IsInlineable(FunctionLiteral* function) const;
1462 1453
1463 void RecordTypeFeedback(TypeFeedbackOracle* oracle); 1454 void RecordTypeFeedback(TypeFeedbackOracle* oracle);
1464 virtual bool IsMonomorphic() { return is_monomorphic_; } 1455 virtual bool IsMonomorphic() { return is_monomorphic_; }
1465 virtual SmallMapList* GetReceiverTypes() { return &receiver_types_; } 1456 virtual SmallMapList* GetReceiverTypes() { return &receiver_types_; }
1466 1457
1467 // Bailout support. 1458 // Bailout support.
1468 int AssignmentId() const { return assignment_id_; } 1459 int AssignmentId() const { return assignment_id_; }
1469 int CountId() const { return count_id_; } 1460 int CountId() const { return count_id_; }
1470 1461
1471 private: 1462 private:
(...skipping 24 matching lines...) Expand all
1496 ASSERT(Token::IsCompareOp(op)); 1487 ASSERT(Token::IsCompareOp(op));
1497 } 1488 }
1498 1489
1499 DECLARE_NODE_TYPE(CompareOperation) 1490 DECLARE_NODE_TYPE(CompareOperation)
1500 1491
1501 Token::Value op() const { return op_; } 1492 Token::Value op() const { return op_; }
1502 Expression* left() const { return left_; } 1493 Expression* left() const { return left_; }
1503 Expression* right() const { return right_; } 1494 Expression* right() const { return right_; }
1504 virtual int position() const { return pos_; } 1495 virtual int position() const { return pos_; }
1505 1496
1506 virtual bool IsInlineable() const; 1497 virtual bool IsInlineable(FunctionLiteral* function) const;
1507 1498
1508 // Type feedback information. 1499 // Type feedback information.
1509 void RecordTypeFeedback(TypeFeedbackOracle* oracle); 1500 void RecordTypeFeedback(TypeFeedbackOracle* oracle);
1510 bool IsSmiCompare() { return compare_type_ == SMI_ONLY; } 1501 bool IsSmiCompare() { return compare_type_ == SMI_ONLY; }
1511 bool IsObjectCompare() { return compare_type_ == OBJECT_ONLY; } 1502 bool IsObjectCompare() { return compare_type_ == OBJECT_ONLY; }
1512 1503
1513 // Match special cases. 1504 // Match special cases.
1514 bool IsLiteralCompareTypeof(Expression** expr, Handle<String>* check); 1505 bool IsLiteralCompareTypeof(Expression** expr, Handle<String>* check);
1515 bool IsLiteralCompareUndefined(Expression** expr); 1506 bool IsLiteralCompareUndefined(Expression** expr);
1516 bool IsLiteralCompareNull(Expression** expr); 1507 bool IsLiteralCompareNull(Expression** expr);
(...skipping 22 matching lines...) Expand all
1539 then_expression_(then_expression), 1530 then_expression_(then_expression),
1540 else_expression_(else_expression), 1531 else_expression_(else_expression),
1541 then_expression_position_(then_expression_position), 1532 then_expression_position_(then_expression_position),
1542 else_expression_position_(else_expression_position), 1533 else_expression_position_(else_expression_position),
1543 then_id_(GetNextId(isolate)), 1534 then_id_(GetNextId(isolate)),
1544 else_id_(GetNextId(isolate)) { 1535 else_id_(GetNextId(isolate)) {
1545 } 1536 }
1546 1537
1547 DECLARE_NODE_TYPE(Conditional) 1538 DECLARE_NODE_TYPE(Conditional)
1548 1539
1549 virtual bool IsInlineable() const; 1540 virtual bool IsInlineable(FunctionLiteral* function) const;
1550 1541
1551 Expression* condition() const { return condition_; } 1542 Expression* condition() const { return condition_; }
1552 Expression* then_expression() const { return then_expression_; } 1543 Expression* then_expression() const { return then_expression_; }
1553 Expression* else_expression() const { return else_expression_; } 1544 Expression* else_expression() const { return else_expression_; }
1554 1545
1555 int then_expression_position() const { return then_expression_position_; } 1546 int then_expression_position() const { return then_expression_position_; }
1556 int else_expression_position() const { return else_expression_position_; } 1547 int else_expression_position() const { return else_expression_position_; }
1557 1548
1558 int ThenId() const { return then_id_; } 1549 int ThenId() const { return then_id_; }
1559 int ElseId() const { return else_id_; } 1550 int ElseId() const { return else_id_; }
(...skipping 12 matching lines...) Expand all
1572 class Assignment: public Expression { 1563 class Assignment: public Expression {
1573 public: 1564 public:
1574 Assignment(Isolate* isolate, 1565 Assignment(Isolate* isolate,
1575 Token::Value op, 1566 Token::Value op,
1576 Expression* target, 1567 Expression* target,
1577 Expression* value, 1568 Expression* value,
1578 int pos); 1569 int pos);
1579 1570
1580 DECLARE_NODE_TYPE(Assignment) 1571 DECLARE_NODE_TYPE(Assignment)
1581 1572
1582 virtual bool IsInlineable() const; 1573 virtual bool IsInlineable(FunctionLiteral* function) const;
1583 1574
1584 Assignment* AsSimpleAssignment() { return !is_compound() ? this : NULL; } 1575 Assignment* AsSimpleAssignment() { return !is_compound() ? this : NULL; }
1585 1576
1586 Token::Value binary_op() const; 1577 Token::Value binary_op() const;
1587 1578
1588 Token::Value op() const { return op_; } 1579 Token::Value op() const { return op_; }
1589 Expression* target() const { return target_; } 1580 Expression* target() const { return target_; }
1590 Expression* value() const { return value_; } 1581 Expression* value() const { return value_; }
1591 virtual int position() const { return pos_; } 1582 virtual int position() const { return pos_; }
1592 BinaryOperation* binary_operation() const { return binary_operation_; } 1583 BinaryOperation* binary_operation() const { return binary_operation_; }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1631 1622
1632 class Throw: public Expression { 1623 class Throw: public Expression {
1633 public: 1624 public:
1634 Throw(Isolate* isolate, Expression* exception, int pos) 1625 Throw(Isolate* isolate, Expression* exception, int pos)
1635 : Expression(isolate), exception_(exception), pos_(pos) {} 1626 : Expression(isolate), exception_(exception), pos_(pos) {}
1636 1627
1637 DECLARE_NODE_TYPE(Throw) 1628 DECLARE_NODE_TYPE(Throw)
1638 1629
1639 Expression* exception() const { return exception_; } 1630 Expression* exception() const { return exception_; }
1640 virtual int position() const { return pos_; } 1631 virtual int position() const { return pos_; }
1641 virtual bool IsInlineable() const; 1632 virtual bool IsInlineable(FunctionLiteral* function) const;
1642 1633
1643 private: 1634 private:
1644 Expression* exception_; 1635 Expression* exception_;
1645 int pos_; 1636 int pos_;
1646 }; 1637 };
1647 1638
1648 1639
1649 class FunctionLiteral: public Expression { 1640 class FunctionLiteral: public Expression {
1650 public: 1641 public:
1651 enum Type { 1642 enum Type {
(...skipping 17 matching lines...) Expand all
1669 : Expression(isolate), 1660 : Expression(isolate),
1670 name_(name), 1661 name_(name),
1671 scope_(scope), 1662 scope_(scope),
1672 body_(body), 1663 body_(body),
1673 this_property_assignments_(this_property_assignments), 1664 this_property_assignments_(this_property_assignments),
1674 inferred_name_(isolate->factory()->empty_string()), 1665 inferred_name_(isolate->factory()->empty_string()),
1675 materialized_literal_count_(materialized_literal_count), 1666 materialized_literal_count_(materialized_literal_count),
1676 expected_property_count_(expected_property_count), 1667 expected_property_count_(expected_property_count),
1677 handler_count_(handler_count), 1668 handler_count_(handler_count),
1678 parameter_count_(parameter_count), 1669 parameter_count_(parameter_count),
1679 function_token_position_(RelocInfo::kNoPosition) { 1670 function_token_position_(RelocInfo::kNoPosition),
1671 is_function_inlineable_(false),
1672 is_function_primitive_(false),
1673 ast_node_count_(0) {
1680 bitfield_ = 1674 bitfield_ =
1681 HasOnlySimpleThisPropertyAssignments::encode( 1675 HasOnlySimpleThisPropertyAssignments::encode(
1682 has_only_simple_this_property_assignments) | 1676 has_only_simple_this_property_assignments) |
1683 IsExpression::encode(type != DECLARATION) | 1677 IsExpression::encode(type != DECLARATION) |
1684 IsAnonymous::encode(type == ANONYMOUS_EXPRESSION) | 1678 IsAnonymous::encode(type == ANONYMOUS_EXPRESSION) |
1685 Pretenure::encode(false) | 1679 Pretenure::encode(false) |
1686 HasDuplicateParameters::encode(has_duplicate_parameters); 1680 HasDuplicateParameters::encode(has_duplicate_parameters);
1687 } 1681 }
1688 1682
1689 DECLARE_NODE_TYPE(FunctionLiteral) 1683 DECLARE_NODE_TYPE(FunctionLiteral)
(...skipping 28 matching lines...) Expand all
1718 return inferred_name(); 1712 return inferred_name();
1719 } 1713 }
1720 1714
1721 Handle<String> inferred_name() const { return inferred_name_; } 1715 Handle<String> inferred_name() const { return inferred_name_; }
1722 void set_inferred_name(Handle<String> inferred_name) { 1716 void set_inferred_name(Handle<String> inferred_name) {
1723 inferred_name_ = inferred_name; 1717 inferred_name_ = inferred_name;
1724 } 1718 }
1725 1719
1726 bool pretenure() { return Pretenure::decode(bitfield_); } 1720 bool pretenure() { return Pretenure::decode(bitfield_); }
1727 void set_pretenure() { bitfield_ |= Pretenure::encode(true); } 1721 void set_pretenure() { bitfield_ |= Pretenure::encode(true); }
1728 virtual bool IsInlineable() const; 1722 virtual bool IsInlineable(FunctionLiteral* function) const;
1729 1723
1730 bool has_duplicate_parameters() { 1724 bool has_duplicate_parameters() {
1731 return HasDuplicateParameters::decode(bitfield_); 1725 return HasDuplicateParameters::decode(bitfield_);
1732 } 1726 }
1733 1727
1728 void ComputeAstNodeCountAndInlineableFlags();
1729
1730 bool is_function_inlineable() { return is_function_inlineable_; }
1731
1732 bool is_function_primitive() { return is_function_primitive_; }
1733
1734 void mark_as_not_primitive() {
1735 is_function_primitive_ = false;
1736 }
1737
1738 int ast_node_count() { return ast_node_count_; }
1739
1740 void increment_ast_node_count() {
1741 ast_node_count_++;
1742 }
1743
1734 private: 1744 private:
1735 Handle<String> name_; 1745 Handle<String> name_;
1736 Scope* scope_; 1746 Scope* scope_;
1737 ZoneList<Statement*>* body_; 1747 ZoneList<Statement*>* body_;
1738 Handle<FixedArray> this_property_assignments_; 1748 Handle<FixedArray> this_property_assignments_;
1739 Handle<String> inferred_name_; 1749 Handle<String> inferred_name_;
1740 1750
1741 int materialized_literal_count_; 1751 int materialized_literal_count_;
1742 int expected_property_count_; 1752 int expected_property_count_;
1743 int handler_count_; 1753 int handler_count_;
1744 int parameter_count_; 1754 int parameter_count_;
1745 int function_token_position_; 1755 int function_token_position_;
1746 1756
1757 bool is_function_inlineable_;
1758 bool is_function_primitive_;
1759 int ast_node_count_;
1760
1747 unsigned bitfield_; 1761 unsigned bitfield_;
1748 class HasOnlySimpleThisPropertyAssignments: public BitField<bool, 0, 1> {}; 1762 class HasOnlySimpleThisPropertyAssignments: public BitField<bool, 0, 1> {};
1749 class IsExpression: public BitField<bool, 1, 1> {}; 1763 class IsExpression: public BitField<bool, 1, 1> {};
1750 class IsAnonymous: public BitField<bool, 2, 1> {}; 1764 class IsAnonymous: public BitField<bool, 2, 1> {};
1751 class Pretenure: public BitField<bool, 3, 1> {}; 1765 class Pretenure: public BitField<bool, 3, 1> {};
1752 class HasDuplicateParameters: public BitField<bool, 4, 1> {}; 1766 class HasDuplicateParameters: public BitField<bool, 4, 1> {};
1753 }; 1767 };
1754 1768
1755 1769
1756 class SharedFunctionInfoLiteral: public Expression { 1770 class SharedFunctionInfoLiteral: public Expression {
1757 public: 1771 public:
1758 SharedFunctionInfoLiteral( 1772 SharedFunctionInfoLiteral(
1759 Isolate* isolate, 1773 Isolate* isolate,
1760 Handle<SharedFunctionInfo> shared_function_info) 1774 Handle<SharedFunctionInfo> shared_function_info)
1761 : Expression(isolate), shared_function_info_(shared_function_info) { } 1775 : Expression(isolate), shared_function_info_(shared_function_info) { }
1762 1776
1763 DECLARE_NODE_TYPE(SharedFunctionInfoLiteral) 1777 DECLARE_NODE_TYPE(SharedFunctionInfoLiteral)
1764 1778
1765 Handle<SharedFunctionInfo> shared_function_info() const { 1779 Handle<SharedFunctionInfo> shared_function_info() const {
1766 return shared_function_info_; 1780 return shared_function_info_;
1767 } 1781 }
1768 virtual bool IsInlineable() const; 1782 virtual bool IsInlineable(FunctionLiteral* function) const;
1769 1783
1770 private: 1784 private:
1771 Handle<SharedFunctionInfo> shared_function_info_; 1785 Handle<SharedFunctionInfo> shared_function_info_;
1772 }; 1786 };
1773 1787
1774 1788
1775 class ThisFunction: public Expression { 1789 class ThisFunction: public Expression {
1776 public: 1790 public:
1777 explicit ThisFunction(Isolate* isolate) : Expression(isolate) {} 1791 explicit ThisFunction(Isolate* isolate) : Expression(isolate) { }
1778 DECLARE_NODE_TYPE(ThisFunction) 1792 DECLARE_NODE_TYPE(ThisFunction)
1779 virtual bool IsInlineable() const; 1793 virtual bool IsInlineable(FunctionLiteral* function) const;
1780 }; 1794 };
1781 1795
1782 1796
1783 // ---------------------------------------------------------------------------- 1797 // ----------------------------------------------------------------------------
1784 // Regular expressions 1798 // Regular expressions
1785 1799
1786 1800
1787 class RegExpVisitor BASE_EMBEDDED { 1801 class RegExpVisitor BASE_EMBEDDED {
1788 public: 1802 public:
1789 virtual ~RegExpVisitor() { } 1803 virtual ~RegExpVisitor() { }
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
2176 2190
2177 private: 2191 private:
2178 Isolate* isolate_; 2192 Isolate* isolate_;
2179 bool stack_overflow_; 2193 bool stack_overflow_;
2180 }; 2194 };
2181 2195
2182 2196
2183 } } // namespace v8::internal 2197 } } // namespace v8::internal
2184 2198
2185 #endif // V8_AST_H_ 2199 #endif // V8_AST_H_
OLDNEW
« no previous file with comments | « no previous file | src/ast.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698