| OLD | NEW |
| 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 node->cond()->set_no_negative_zero(true); | 99 node->cond()->set_no_negative_zero(true); |
| 100 Visit(node->cond()); | 100 Visit(node->cond()); |
| 101 Visit(node->body()); | 101 Visit(node->body()); |
| 102 } | 102 } |
| 103 | 103 |
| 104 | 104 |
| 105 void AstOptimizer::VisitWhileStatement(WhileStatement* node) { | 105 void AstOptimizer::VisitWhileStatement(WhileStatement* node) { |
| 106 has_function_literal_ = false; | 106 has_function_literal_ = false; |
| 107 node->cond()->set_no_negative_zero(true); | 107 node->cond()->set_no_negative_zero(true); |
| 108 Visit(node->cond()); | 108 Visit(node->cond()); |
| 109 node->may_have_function_literal_ = has_function_literal_; | 109 node->set_may_have_function_literal(has_function_literal_); |
| 110 Visit(node->body()); | 110 Visit(node->body()); |
| 111 } | 111 } |
| 112 | 112 |
| 113 | 113 |
| 114 void AstOptimizer::VisitForStatement(ForStatement* node) { | 114 void AstOptimizer::VisitForStatement(ForStatement* node) { |
| 115 if (node->init() != NULL) { | 115 if (node->init() != NULL) { |
| 116 Visit(node->init()); | 116 Visit(node->init()); |
| 117 } | 117 } |
| 118 if (node->cond() != NULL) { | 118 if (node->cond() != NULL) { |
| 119 has_function_literal_ = false; | 119 has_function_literal_ = false; |
| 120 node->cond()->set_no_negative_zero(true); | 120 node->cond()->set_no_negative_zero(true); |
| 121 Visit(node->cond()); | 121 Visit(node->cond()); |
| 122 node->may_have_function_literal_ = has_function_literal_; | 122 node->set_may_have_function_literal(has_function_literal_); |
| 123 } | 123 } |
| 124 Visit(node->body()); | 124 Visit(node->body()); |
| 125 if (node->next() != NULL) { | 125 if (node->next() != NULL) { |
| 126 Visit(node->next()); | 126 Visit(node->next()); |
| 127 } | 127 } |
| 128 } | 128 } |
| 129 | 129 |
| 130 | 130 |
| 131 void AstOptimizer::VisitForInStatement(ForInStatement* node) { | 131 void AstOptimizer::VisitForInStatement(ForInStatement* node) { |
| 132 Visit(node->each()); | 132 Visit(node->each()); |
| (...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 661 } | 661 } |
| 662 if (node->right()->type()->IsUnknown()) { | 662 if (node->right()->type()->IsUnknown()) { |
| 663 node->right()->type()->SetAsLikelySmi(); | 663 node->right()->type()->SetAsLikelySmi(); |
| 664 Visit(node->right()); | 664 Visit(node->right()); |
| 665 } | 665 } |
| 666 } | 666 } |
| 667 } | 667 } |
| 668 } | 668 } |
| 669 | 669 |
| 670 | 670 |
| 671 void AstOptimizer::VisitCompareToNull(CompareToNull* node) { |
| 672 Visit(node->expression()); |
| 673 } |
| 674 |
| 675 |
| 671 void AstOptimizer::VisitThisFunction(ThisFunction* node) { | 676 void AstOptimizer::VisitThisFunction(ThisFunction* node) { |
| 672 USE(node); | 677 USE(node); |
| 673 } | 678 } |
| 674 | 679 |
| 675 | 680 |
| 676 class Processor: public AstVisitor { | 681 class Processor: public AstVisitor { |
| 677 public: | 682 public: |
| 678 explicit Processor(VariableProxy* result) | 683 explicit Processor(VariableProxy* result) |
| 679 : result_(result), | 684 : result_(result), |
| 680 result_assigned_(false), | 685 result_assigned_(false), |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 953 UNREACHABLE(); | 958 UNREACHABLE(); |
| 954 } | 959 } |
| 955 | 960 |
| 956 | 961 |
| 957 void Processor::VisitCompareOperation(CompareOperation* node) { | 962 void Processor::VisitCompareOperation(CompareOperation* node) { |
| 958 USE(node); | 963 USE(node); |
| 959 UNREACHABLE(); | 964 UNREACHABLE(); |
| 960 } | 965 } |
| 961 | 966 |
| 962 | 967 |
| 968 void Processor::VisitCompareToNull(CompareToNull* node) { |
| 969 USE(node); |
| 970 UNREACHABLE(); |
| 971 } |
| 972 |
| 973 |
| 963 void Processor::VisitThisFunction(ThisFunction* node) { | 974 void Processor::VisitThisFunction(ThisFunction* node) { |
| 964 USE(node); | 975 USE(node); |
| 965 UNREACHABLE(); | 976 UNREACHABLE(); |
| 966 } | 977 } |
| 967 | 978 |
| 968 | 979 |
| 969 bool Rewriter::Process(FunctionLiteral* function) { | 980 bool Rewriter::Process(FunctionLiteral* function) { |
| 970 HistogramTimerScope timer(&Counters::rewriting); | 981 HistogramTimerScope timer(&Counters::rewriting); |
| 971 Scope* scope = function->scope(); | 982 Scope* scope = function->scope(); |
| 972 if (scope->is_function_scope()) return true; | 983 if (scope->is_function_scope()) return true; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 993 optimizer.Optimize(body); | 1004 optimizer.Optimize(body); |
| 994 if (optimizer.HasStackOverflow()) { | 1005 if (optimizer.HasStackOverflow()) { |
| 995 return false; | 1006 return false; |
| 996 } | 1007 } |
| 997 } | 1008 } |
| 998 return true; | 1009 return true; |
| 999 } | 1010 } |
| 1000 | 1011 |
| 1001 | 1012 |
| 1002 } } // namespace v8::internal | 1013 } } // namespace v8::internal |
| OLD | NEW |