Author: [EMAIL PROTECTED] Date: Wed Nov 5 12:39:41 2008 New Revision: 701
Modified: branches/bleeding_edge/src/compiler.cc branches/bleeding_edge/src/rewriter.cc branches/bleeding_edge/src/rewriter.h Log: Handle stack overflow errors correctly when rewriting the AST for likely Smis. Review URL: http://codereview.chromium.org/9429 Modified: branches/bleeding_edge/src/compiler.cc ============================================================================== --- branches/bleeding_edge/src/compiler.cc (original) +++ branches/bleeding_edge/src/compiler.cc Wed Nov 5 12:39:41 2008 @@ -66,7 +66,11 @@ #endif // Optimize the AST. - Rewriter::Optimize(literal); + if (!Rewriter::Optimize(literal)) { + // Signal a stack overflow by returning a null handle. The stack + // overflow exception will be thrown by the caller. + return Handle<Code>::null(); + } // Generate code and return it. Handle<Code> result = CodeGenerator::MakeCode(literal, script, is_eval); Modified: branches/bleeding_edge/src/rewriter.cc ============================================================================== --- branches/bleeding_edge/src/rewriter.cc (original) +++ branches/bleeding_edge/src/rewriter.cc Wed Nov 5 12:39:41 2008 @@ -761,17 +761,20 @@ } -void Rewriter::Optimize(FunctionLiteral* function) { +bool Rewriter::Optimize(FunctionLiteral* function) { ZoneList<Statement*>* body = function->body(); - if (body->is_empty()) return; - if (FLAG_optimize_ast) { + if (FLAG_optimize_ast && !body->is_empty()) { Scope* scope = function->scope(); if (!scope->is_global_scope()) { AstOptimizer optimizer; optimizer.Optimize(body); + if (optimizer.HasStackOverflow()) { + return false; + } } } + return true; } Modified: branches/bleeding_edge/src/rewriter.h ============================================================================== --- branches/bleeding_edge/src/rewriter.h (original) +++ branches/bleeding_edge/src/rewriter.h Wed Nov 5 12:39:41 2008 @@ -44,7 +44,7 @@ class Rewriter { public: static bool Process(FunctionLiteral* function); - static void Optimize(FunctionLiteral* function); + static bool Optimize(FunctionLiteral* function); }; --~--~---------~--~----~------------~-------~--~----~ v8-dev mailing list v8-dev@googlegroups.com http://groups.google.com/group/v8-dev -~----------~----~----~----~------~----~------~--~---