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

Side by Side Diff: src/ast.cc

Issue 998001: Loop peeling for inner loops.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/ast.h ('k') | src/compiler.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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 572 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 // with the exception of +, which expresses a Number or a String. 583 // with the exception of +, which expresses a Number or a String.
584 return true; 584 return true;
585 } 585 }
586 } 586 }
587 587
588 588
589 // Compare operations always express Boolean values. 589 // Compare operations always express Boolean values.
590 bool CompareOperation::IsPrimitive() { return true; } 590 bool CompareOperation::IsPrimitive() { return true; }
591 591
592 592
593 // Implementation of a copy visitor. The visitor create a deep copy
594 // of ast nodes. Nodes that do not require a deep copy are copied
595 // with the default copy constructor.
596
597 AstNode::AstNode(AstNode* other) : num_(kNoNumber) {
598 // AST node number should be unique. Assert that we only copy AstNodes
599 // before node numbers are assigned.
600 ASSERT(other->num_ == kNoNumber);
601 }
602
603
604 Statement::Statement(Statement* other)
605 : AstNode(other), statement_pos_(other->statement_pos_) {}
606
607
608 Expression::Expression(Expression* other)
609 : AstNode(other),
610 bitfields_(other->bitfields_),
611 type_(other->type_),
612 def_(other->def_),
613 defined_vars_(other->defined_vars_) {}
614
615
616 BreakableStatement::BreakableStatement(BreakableStatement* other)
617 : Statement(other), labels_(other->labels_), type_(other->type_) {}
618
619
620 Block::Block(Block* other, ZoneList<Statement*>* statements)
621 : BreakableStatement(other),
622 statements_(statements->length()),
623 is_initializer_block_(other->is_initializer_block_) {
624 statements_.AddAll(*statements);
625 }
626
627
628 ExpressionStatement::ExpressionStatement(ExpressionStatement* other,
629 Expression* expression)
630 : Statement(other), expression_(expression) {}
631
632
633 IfStatement::IfStatement(IfStatement* other,
634 Expression* condition,
635 Statement* then_statement,
636 Statement* else_statement)
637 : Statement(other),
638 condition_(condition),
639 then_statement_(then_statement),
640 else_statement_(else_statement) {}
641
642
643 EmptyStatement::EmptyStatement(EmptyStatement* other) : Statement(other) {}
644
645
646 IterationStatement::IterationStatement(IterationStatement* other,
647 Statement* body)
648 : BreakableStatement(other), body_(body) {}
649
650
651 ForStatement::ForStatement(ForStatement* other,
652 Statement* init,
653 Expression* cond,
654 Statement* next,
655 Statement* body)
656 : IterationStatement(other, body),
657 init_(init),
658 cond_(cond),
659 next_(next),
660 may_have_function_literal_(other->may_have_function_literal_),
661 loop_variable_(other->loop_variable_),
662 peel_this_loop_(other->peel_this_loop_) {}
663
664
665 Assignment::Assignment(Assignment* other,
666 Expression* target,
667 Expression* value)
668 : Expression(other),
669 op_(other->op_),
670 target_(target),
671 value_(value),
672 pos_(other->pos_),
673 block_start_(other->block_start_),
674 block_end_(other->block_end_) {}
675
676
677 Property::Property(Property* other, Expression* obj, Expression* key)
678 : Expression(other),
679 obj_(obj),
680 key_(key),
681 pos_(other->pos_),
682 type_(other->type_) {}
683
684
685 Call::Call(Call* other,
686 Expression* expression,
687 ZoneList<Expression*>* arguments)
688 : Expression(other),
689 expression_(expression),
690 arguments_(arguments),
691 pos_(other->pos_) {}
692
693
694 UnaryOperation::UnaryOperation(UnaryOperation* other, Expression* expression)
695 : Expression(other), op_(other->op_), expression_(expression) {}
696
697
698 BinaryOperation::BinaryOperation(BinaryOperation* other,
699 Expression* left,
700 Expression* right)
701 : Expression(other),
702 op_(other->op_),
703 left_(left),
704 right_(right) {}
705
706
707 CountOperation::CountOperation(CountOperation* other, Expression* expression)
708 : Expression(other),
709 is_prefix_(other->is_prefix_),
710 op_(other->op_),
711 expression_(expression) {}
712
713
714 CompareOperation::CompareOperation(CompareOperation* other,
715 Expression* left,
716 Expression* right)
717 : Expression(other),
718 op_(other->op_),
719 left_(left),
720 right_(right),
721 is_for_loop_condition_(other->is_for_loop_condition_) {}
722
723
724 Expression* CopyAstVisitor::DeepCopyExpr(Expression* expr) {
725 expr_ = NULL;
726 if (expr != NULL) Visit(expr);
727 return expr_;
728 }
729
730
731 Statement* CopyAstVisitor::DeepCopyStmt(Statement* stmt) {
732 stmt_ = NULL;
733 if (stmt != NULL) Visit(stmt);
734 return stmt_;
735 }
736
737
738 ZoneList<Expression*>* CopyAstVisitor::DeepCopyExprList(
739 ZoneList<Expression*>* expressions) {
740 ZoneList<Expression*>* copy =
741 new ZoneList<Expression*>(expressions->length());
742 for (int i = 0; i < expressions->length(); i++) {
743 copy->Add(DeepCopyExpr(expressions->at(i)));
744 }
745 return copy;
746 }
747
748
749 ZoneList<Statement*>* CopyAstVisitor::DeepCopyStmtList(
750 ZoneList<Statement*>* statements) {
751 ZoneList<Statement*>* copy = new ZoneList<Statement*>(statements->length());
752 for (int i = 0; i < statements->length(); i++) {
753 copy->Add(DeepCopyStmt(statements->at(i)));
754 }
755 return copy;
756 }
757
758
759 void CopyAstVisitor::VisitBlock(Block* stmt) {
760 stmt_ = new Block(stmt,
761 DeepCopyStmtList(stmt->statements()));
762 }
763
764
765 void CopyAstVisitor::VisitExpressionStatement(
766 ExpressionStatement* stmt) {
767 stmt_ = new ExpressionStatement(stmt, DeepCopyExpr(stmt->expression()));
768 }
769
770
771 void CopyAstVisitor::VisitEmptyStatement(EmptyStatement* stmt) {
772 stmt_ = new EmptyStatement(stmt);
773 }
774
775
776 void CopyAstVisitor::VisitIfStatement(IfStatement* stmt) {
777 stmt_ = new IfStatement(stmt,
778 DeepCopyExpr(stmt->condition()),
779 DeepCopyStmt(stmt->then_statement()),
780 DeepCopyStmt(stmt->else_statement()));
781 }
782
783
784 void CopyAstVisitor::VisitContinueStatement(ContinueStatement* stmt) {
785 SetStackOverflow();
786 }
787
788
789 void CopyAstVisitor::VisitBreakStatement(BreakStatement* stmt) {
790 SetStackOverflow();
791 }
792
793
794 void CopyAstVisitor::VisitReturnStatement(ReturnStatement* stmt) {
795 SetStackOverflow();
796 }
797
798
799 void CopyAstVisitor::VisitWithEnterStatement(
800 WithEnterStatement* stmt) {
801 SetStackOverflow();
802 }
803
804
805 void CopyAstVisitor::VisitWithExitStatement(WithExitStatement* stmt) {
806 SetStackOverflow();
807 }
808
809
810 void CopyAstVisitor::VisitSwitchStatement(SwitchStatement* stmt) {
811 SetStackOverflow();
812 }
813
814
815 void CopyAstVisitor::VisitDoWhileStatement(DoWhileStatement* stmt) {
816 SetStackOverflow();
817 }
818
819
820 void CopyAstVisitor::VisitWhileStatement(WhileStatement* stmt) {
821 SetStackOverflow();
822 }
823
824
825 void CopyAstVisitor::VisitForStatement(ForStatement* stmt) {
826 stmt_ = new ForStatement(stmt,
827 DeepCopyStmt(stmt->init()),
828 DeepCopyExpr(stmt->cond()),
829 DeepCopyStmt(stmt->next()),
830 DeepCopyStmt(stmt->body()));
831 }
832
833
834 void CopyAstVisitor::VisitForInStatement(ForInStatement* stmt) {
835 SetStackOverflow();
836 }
837
838
839 void CopyAstVisitor::VisitTryCatchStatement(TryCatchStatement* stmt) {
840 SetStackOverflow();
841 }
842
843
844 void CopyAstVisitor::VisitTryFinallyStatement(
845 TryFinallyStatement* stmt) {
846 SetStackOverflow();
847 }
848
849
850 void CopyAstVisitor::VisitDebuggerStatement(
851 DebuggerStatement* stmt) {
852 SetStackOverflow();
853 }
854
855
856 void CopyAstVisitor::VisitFunctionLiteral(FunctionLiteral* expr) {
857 SetStackOverflow();
858 }
859
860
861 void CopyAstVisitor::VisitFunctionBoilerplateLiteral(
862 FunctionBoilerplateLiteral* expr) {
863 SetStackOverflow();
864 }
865
866
867 void CopyAstVisitor::VisitConditional(Conditional* expr) {
868 SetStackOverflow();
869 }
870
871
872 void CopyAstVisitor::VisitSlot(Slot* expr) {
873 UNREACHABLE();
874 }
875
876
877 void CopyAstVisitor::VisitVariableProxy(VariableProxy* expr) {
878 expr_ = new VariableProxy(*expr);
879 }
880
881
882 void CopyAstVisitor::VisitLiteral(Literal* expr) {
883 expr_ = new Literal(*expr);
884 }
885
886
887 void CopyAstVisitor::VisitRegExpLiteral(RegExpLiteral* expr) {
888 SetStackOverflow();
889 }
890
891
892 void CopyAstVisitor::VisitObjectLiteral(ObjectLiteral* expr) {
893 SetStackOverflow();
894 }
895
896
897 void CopyAstVisitor::VisitArrayLiteral(ArrayLiteral* expr) {
898 SetStackOverflow();
899 }
900
901
902 void CopyAstVisitor::VisitCatchExtensionObject(
903 CatchExtensionObject* expr) {
904 SetStackOverflow();
905 }
906
907
908 void CopyAstVisitor::VisitAssignment(Assignment* expr) {
909 expr_ = new Assignment(expr,
910 DeepCopyExpr(expr->target()),
911 DeepCopyExpr(expr->value()));
912 }
913
914
915 void CopyAstVisitor::VisitThrow(Throw* expr) {
916 SetStackOverflow();
917 }
918
919
920 void CopyAstVisitor::VisitProperty(Property* expr) {
921 expr_ = new Property(expr,
922 DeepCopyExpr(expr->obj()),
923 DeepCopyExpr(expr->key()));
924 }
925
926
927 void CopyAstVisitor::VisitCall(Call* expr) {
928 expr_ = new Call(expr,
929 DeepCopyExpr(expr->expression()),
930 DeepCopyExprList(expr->arguments()));
931 }
932
933
934 void CopyAstVisitor::VisitCallNew(CallNew* expr) {
935 SetStackOverflow();
936 }
937
938
939 void CopyAstVisitor::VisitCallRuntime(CallRuntime* expr) {
940 SetStackOverflow();
941 }
942
943
944 void CopyAstVisitor::VisitUnaryOperation(UnaryOperation* expr) {
945 expr_ = new UnaryOperation(expr, DeepCopyExpr(expr->expression()));
946 }
947
948
949 void CopyAstVisitor::VisitCountOperation(CountOperation* expr) {
950 expr_ = new CountOperation(expr,
951 DeepCopyExpr(expr->expression()));
952 }
953
954
955 void CopyAstVisitor::VisitBinaryOperation(BinaryOperation* expr) {
956 expr_ = new BinaryOperation(expr,
957 DeepCopyExpr(expr->left()),
958 DeepCopyExpr(expr->right()));
959 }
960
961
962 void CopyAstVisitor::VisitCompareOperation(CompareOperation* expr) {
963 expr_ = new CompareOperation(expr,
964 DeepCopyExpr(expr->left()),
965 DeepCopyExpr(expr->right()));
966 }
967
968
969 void CopyAstVisitor::VisitThisFunction(ThisFunction* expr) {
970 SetStackOverflow();
971 }
972
973
974 void CopyAstVisitor::VisitDeclaration(Declaration* decl) {
975 UNREACHABLE();
976 }
977
978
593 } } // namespace v8::internal 979 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ast.h ('k') | src/compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698