Reviewers: Mads Ager, Description: Experimental: simple fix for the issue of stack overflow during compilation of an expression. Ensure that CodeGenerator::LoadCondition returns with a valid-looking virtual frame even in the case that the expression was not visited.
Please review this at http://codereview.chromium.org/21541 SVN Base: http://v8.googlecode.com/svn/branches/experimental/toiger/ Affected files: M src/codegen-arm.cc M src/codegen-ia32.cc Index: src/codegen-arm.cc =================================================================== --- src/codegen-arm.cc (revision 1328) +++ src/codegen-arm.cc (working copy) @@ -382,14 +382,28 @@ JumpTarget* true_target, JumpTarget* false_target, bool force_cc) { -#ifdef DEBUG - int original_height = frame_->height(); -#endif ASSERT(!in_spilled_code()); ASSERT(!has_cc()); + int original_height = frame_->height(); { CodeGenState new_state(this, typeof_state, true_target, false_target); Visit(x); + + // If we hit a stack overflow, we may not have actually visited + // the expression. In that case, we ensure that we have a + // valid-looking frame state because we will continue to generate + // code as we unwind the C++ stack. + // + // It's possible to have both a stack overflow and a valid frame + // state (eg, a subexpression overflowed, visiting it returned + // with a dummied frame state, and visiting this expression + // returned with a normal-looking state). + if (HasStackOverflow() && + has_valid_frame() && + !has_cc() && + frame_->height() == original_height) { + true_target->Jump(); + } } if (force_cc && frame_ != NULL && !has_cc()) { // Convert the TOS value to a boolean in the condition code register. Index: src/codegen-ia32.cc =================================================================== --- src/codegen-ia32.cc (revision 1325) +++ src/codegen-ia32.cc (working copy) @@ -410,11 +410,25 @@ ControlDestination* dest, bool force_control) { ASSERT(!in_spilled_code()); -#ifdef DEBUG int original_height = frame_->height(); -#endif + { CodeGenState new_state(this, typeof_state, dest); Visit(x); + + // If we hit a stack overflow, we may not have actually visited + // the expression. In that case, we ensure that we have a + // valid-looking frame state because we will continue to generate + // code as we unwind the C++ stack. + // + // It's possible to have both a stack overflow and a valid frame + // state (eg, a subexpression overflowed, visiting it returned + // with a dummied frame state, and visiting this expression + // returned with a normal-looking state). + if (HasStackOverflow() && + !dest->is_used() && + frame_->height() == original_height) { + dest->Goto(true); + } } if (force_control && !dest->is_used()) { --~--~---------~--~----~------------~-------~--~----~ v8-dev mailing list [email protected] http://groups.google.com/group/v8-dev -~----------~----~----~----~------~----~------~--~---
