Author: [email protected]
Date: Mon Feb 23 00:48:17 2009
New Revision: 1334

Modified:
    branches/experimental/toiger/src/codegen-arm.cc
    branches/experimental/toiger/src/codegen-ia32.cc

Log:
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.

Review URL: http://codereview.chromium.org/21541

Modified: branches/experimental/toiger/src/codegen-arm.cc
==============================================================================
--- branches/experimental/toiger/src/codegen-arm.cc     (original)
+++ branches/experimental/toiger/src/codegen-arm.cc     Mon Feb 23 00:48:17 2009
@@ -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.

Modified: branches/experimental/toiger/src/codegen-ia32.cc
==============================================================================
--- branches/experimental/toiger/src/codegen-ia32.cc    (original)
+++ branches/experimental/toiger/src/codegen-ia32.cc    Mon Feb 23 00:48:17  
2009
@@ -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
-~----------~----~----~----~------~----~------~--~---

Reply via email to