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

Side by Side Diff: src/rewriter.cc

Issue 9429: Handle stack overflow errors correctly when rewriting the AST... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 12 years, 1 month 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/rewriter.h ('k') | no next file » | 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 743 matching lines...) Expand 10 before | Expand all | Expand 10 after
754 VariableProxy* result = scope->NewTemporary(Factory::result_symbol()); 754 VariableProxy* result = scope->NewTemporary(Factory::result_symbol());
755 Processor processor(result); 755 Processor processor(result);
756 processor.Process(body); 756 processor.Process(body);
757 if (processor.HasStackOverflow()) return false; 757 if (processor.HasStackOverflow()) return false;
758 758
759 if (processor.result_assigned()) body->Add(new ReturnStatement(result)); 759 if (processor.result_assigned()) body->Add(new ReturnStatement(result));
760 return true; 760 return true;
761 } 761 }
762 762
763 763
764 void Rewriter::Optimize(FunctionLiteral* function) { 764 bool Rewriter::Optimize(FunctionLiteral* function) {
765 ZoneList<Statement*>* body = function->body(); 765 ZoneList<Statement*>* body = function->body();
766 if (body->is_empty()) return;
767 766
768 if (FLAG_optimize_ast) { 767 if (FLAG_optimize_ast && !body->is_empty()) {
769 Scope* scope = function->scope(); 768 Scope* scope = function->scope();
770 if (!scope->is_global_scope()) { 769 if (!scope->is_global_scope()) {
771 AstOptimizer optimizer; 770 AstOptimizer optimizer;
772 optimizer.Optimize(body); 771 optimizer.Optimize(body);
772 if (optimizer.HasStackOverflow()) {
773 return false;
774 }
773 } 775 }
774 } 776 }
777 return true;
775 } 778 }
776 779
777 780
778 } } // namespace v8::internal 781 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/rewriter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698