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 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
796 } | 796 } |
797 | 797 |
798 | 798 |
799 void Processor::VisitThisFunction(ThisFunction* node) { | 799 void Processor::VisitThisFunction(ThisFunction* node) { |
800 USE(node); | 800 USE(node); |
801 UNREACHABLE(); | 801 UNREACHABLE(); |
802 } | 802 } |
803 | 803 |
804 | 804 |
805 bool Rewriter::Process(FunctionLiteral* function) { | 805 bool Rewriter::Process(FunctionLiteral* function) { |
| 806 HistogramTimerScope timer(&Counters::rewriting); |
806 Scope* scope = function->scope(); | 807 Scope* scope = function->scope(); |
807 if (scope->is_function_scope()) return true; | 808 if (scope->is_function_scope()) return true; |
808 | 809 |
809 ZoneList<Statement*>* body = function->body(); | 810 ZoneList<Statement*>* body = function->body(); |
810 if (body->is_empty()) return true; | 811 if (body->is_empty()) return true; |
811 | 812 |
812 VariableProxy* result = scope->NewTemporary(Factory::result_symbol()); | 813 VariableProxy* result = scope->NewTemporary(Factory::result_symbol()); |
813 Processor processor(result); | 814 Processor processor(result); |
814 processor.Process(body); | 815 processor.Process(body); |
815 if (processor.HasStackOverflow()) return false; | 816 if (processor.HasStackOverflow()) return false; |
816 | 817 |
817 if (processor.result_assigned()) body->Add(new ReturnStatement(result)); | 818 if (processor.result_assigned()) body->Add(new ReturnStatement(result)); |
818 return true; | 819 return true; |
819 } | 820 } |
820 | 821 |
821 | 822 |
822 bool Rewriter::Optimize(FunctionLiteral* function) { | 823 bool Rewriter::Optimize(FunctionLiteral* function) { |
823 ZoneList<Statement*>* body = function->body(); | 824 ZoneList<Statement*>* body = function->body(); |
824 | 825 |
825 if (FLAG_optimize_ast && !body->is_empty()) { | 826 if (FLAG_optimize_ast && !body->is_empty()) { |
| 827 HistogramTimerScope timer(&Counters::ast_optimization); |
826 AstOptimizer optimizer(function->name()); | 828 AstOptimizer optimizer(function->name()); |
827 optimizer.Optimize(body); | 829 optimizer.Optimize(body); |
828 if (optimizer.HasStackOverflow()) { | 830 if (optimizer.HasStackOverflow()) { |
829 return false; | 831 return false; |
830 } | 832 } |
831 } | 833 } |
832 return true; | 834 return true; |
833 } | 835 } |
834 | 836 |
835 | 837 |
836 } } // namespace v8::internal | 838 } } // namespace v8::internal |
OLD | NEW |