| 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 802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 813 } | 813 } |
| 814 | 814 |
| 815 | 815 |
| 816 void Processor::VisitThisFunction(ThisFunction* node) { | 816 void Processor::VisitThisFunction(ThisFunction* node) { |
| 817 USE(node); | 817 USE(node); |
| 818 UNREACHABLE(); | 818 UNREACHABLE(); |
| 819 } | 819 } |
| 820 | 820 |
| 821 | 821 |
| 822 bool Rewriter::Process(FunctionLiteral* function) { | 822 bool Rewriter::Process(FunctionLiteral* function) { |
| 823 HistogramTimerScope timer(&Counters::rewriting); | 823 HistogramTimerScope timer(&COUNTER(rewriting)); |
| 824 Scope* scope = function->scope(); | 824 Scope* scope = function->scope(); |
| 825 if (scope->is_function_scope()) return true; | 825 if (scope->is_function_scope()) return true; |
| 826 | 826 |
| 827 ZoneList<Statement*>* body = function->body(); | 827 ZoneList<Statement*>* body = function->body(); |
| 828 if (body->is_empty()) return true; | 828 if (body->is_empty()) return true; |
| 829 | 829 |
| 830 VariableProxy* result = scope->NewTemporary(Factory::result_symbol()); | 830 VariableProxy* result = scope->NewTemporary(Factory::result_symbol()); |
| 831 Processor processor(result); | 831 Processor processor(result); |
| 832 processor.Process(body); | 832 processor.Process(body); |
| 833 if (processor.HasStackOverflow()) return false; | 833 if (processor.HasStackOverflow()) return false; |
| 834 | 834 |
| 835 if (processor.result_assigned()) body->Add(new ReturnStatement(result)); | 835 if (processor.result_assigned()) body->Add(new ReturnStatement(result)); |
| 836 return true; | 836 return true; |
| 837 } | 837 } |
| 838 | 838 |
| 839 | 839 |
| 840 bool Rewriter::Optimize(FunctionLiteral* function) { | 840 bool Rewriter::Optimize(FunctionLiteral* function) { |
| 841 ZoneList<Statement*>* body = function->body(); | 841 ZoneList<Statement*>* body = function->body(); |
| 842 | 842 |
| 843 if (FLAG_optimize_ast && !body->is_empty()) { | 843 if (FLAG_optimize_ast && !body->is_empty()) { |
| 844 HistogramTimerScope timer(&Counters::ast_optimization); | 844 HistogramTimerScope timer(&COUNTER(ast_optimization)); |
| 845 AstOptimizer optimizer(function->name()); | 845 AstOptimizer optimizer(function->name()); |
| 846 optimizer.Optimize(body); | 846 optimizer.Optimize(body); |
| 847 if (optimizer.HasStackOverflow()) { | 847 if (optimizer.HasStackOverflow()) { |
| 848 return false; | 848 return false; |
| 849 } | 849 } |
| 850 } | 850 } |
| 851 return true; | 851 return true; |
| 852 } | 852 } |
| 853 | 853 |
| 854 | 854 |
| 855 } } // namespace v8::internal | 855 } } // namespace v8::internal |
| OLD | NEW |