Revision: 13225
Author:   [email protected]
Date:     Fri Dec 14 10:36:51 2012
Log: Fix set variable value bug: a function argument must be updated in 2 places

Review URL: https://codereview.chromium.org/11519020
http://code.google.com/p/v8/source/detail?r=13225

Modified:
 /branches/bleeding_edge/src/runtime.cc
 /branches/bleeding_edge/test/mjsunit/debug-set-variable-value.js

=======================================
--- /branches/bleeding_edge/src/runtime.cc      Fri Dec 14 06:19:18 2012
+++ /branches/bleeding_edge/src/runtime.cc      Fri Dec 14 10:36:51 2012
@@ -10836,11 +10836,14 @@
   Handle<SharedFunctionInfo> shared(function->shared());
   Handle<ScopeInfo> scope_info(shared->scope_info());

+  bool default_result = false;
+
   // Parameters.
   for (int i = 0; i < scope_info->ParameterCount(); ++i) {
     if (scope_info->ParameterName(i)->Equals(*variable_name)) {
       frame->SetParameterValue(i, *new_value);
-      return true;
+      // Argument might be shadowed in heap context, don't stop here.
+      default_result = true;
     }
   }

@@ -10882,7 +10885,7 @@
     }
   }

-  return false;
+  return default_result;
 }


=======================================
--- /branches/bleeding_edge/test/mjsunit/debug-set-variable-value.js Tue Dec 11 15:27:38 2012 +++ /branches/bleeding_edge/test/mjsunit/debug-set-variable-value.js Fri Dec 14 10:36:51 2012
@@ -257,6 +257,38 @@
 })());


+// Check that we correctly update local variable that
+// is referenced from an inner closure.
+RunPauseTest(0, 'Blue', 'v', 'Green', 'Green', (function Factory() {
+  return function() {
+    function A() {
+      var v = "Blue";
+      function Inner() {
+        return void v;
+      }
+      debugger;
+      return v;
+    }
+    return A();
+  }
+})());
+
+// Check that we correctly update parameter, that is known to be stored
+// both on stack and in heap.
+RunPauseTest(0, 5, 'p', 2012, 2012, (function Factory() {
+  return function() {
+    function A(p) {
+      function Inner() {
+        return void p;
+      }
+      debugger;
+      return p;
+    }
+    return A(5);
+  }
+})());
+
+
 // Test value description protocol JSON

assertEquals(true, Debug.TestApi.CommandProcessorResolveValue({value: true}));

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to