Reviewers: ulan,

Message:
Please take a look.

Description:
Correctly resolve forcibly context allocated parameters in debug-evaluate.

[email protected]
BUG=325676
LOG=Y

Please review this at https://codereview.chromium.org/107243006/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+37, -34 lines):
  src/runtime.cc
  test/mjsunit/regress/regress-325676.js


Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index e763d435cc985e80a21f0fe43b4e11439c534e6b..497e8d338381df5d139fb3a3b0f01f5bcb7e744a 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -11364,6 +11364,12 @@ static Handle<JSObject> MaterializeStackLocalsWithFrameInspector(

   // First fill all parameters.
   for (int i = 0; i < scope_info->ParameterCount(); ++i) {
+    Handle<String> name(scope_info->ParameterName(i));
+    VariableMode mode;
+    InitializationFlag init_flag;
+ // Do not materialize the parameter if it is shadowed by a context local. + if (scope_info->ContextSlotIndex(*name, &mode, &init_flag) != -1) continue;
+
     Handle<Object> value(i < frame_inspector->GetParametersCount()
                              ? frame_inspector->GetParameter(i)
                              : isolate->heap()->undefined_value(),
@@ -11372,32 +11378,23 @@ static Handle<JSObject> MaterializeStackLocalsWithFrameInspector(

     RETURN_IF_EMPTY_HANDLE_VALUE(
         isolate,
-        Runtime::SetObjectProperty(isolate,
-                                   target,
- Handle<String>(scope_info->ParameterName(i)),
-                                   value,
-                                   NONE,
-                                   kNonStrictMode),
+        Runtime::SetObjectProperty(
+            isolate, target, name, value, NONE, kNonStrictMode),
         Handle<JSObject>());
   }

   // Second fill all stack locals.
   for (int i = 0; i < scope_info->StackLocalCount(); ++i) {
+    Handle<String> name(scope_info->StackLocalName(i));
     Handle<Object> value(frame_inspector->GetExpression(i), isolate);
     if (value->IsTheHole()) continue;

     RETURN_IF_EMPTY_HANDLE_VALUE(
         isolate,
         Runtime::SetObjectProperty(
-            isolate,
-            target,
-            Handle<String>(scope_info->StackLocalName(i)),
-            value,
-            NONE,
-            kNonStrictMode),
+            isolate, target, name, value, NONE, kNonStrictMode),
         Handle<JSObject>());
   }
-
   return target;
 }

Index: test/mjsunit/regress/regress-325676.js
diff --git a/test/mjsunit/regress/regress-crbug-222893.js b/test/mjsunit/regress/regress-325676.js
similarity index 71%
copy from test/mjsunit/regress/regress-crbug-222893.js
copy to test/mjsunit/regress/regress-325676.js
index 39363bc91251d9b7c06eae0ab41bf674b9151ca4..427bbc38dcb3d909b3bfb1dc3a6008cec63cf9ab 100644
--- a/test/mjsunit/regress/regress-crbug-222893.js
+++ b/test/mjsunit/regress/regress-325676.js
@@ -27,37 +27,43 @@

 // Flags: --expose-debug-as debug

-Debug = debug.Debug
+// If a function parameter is forced to be context allocated,
+// debug evaluate need to resolve it to a context slot instead of
+// parameter slot on the stack.

-var error = null;
-var array = ["a", "b", "c"];
+var Debug = debug.Debug;
+
+var expected;
+var exception = null;

 function listener(event, exec_state, event_data, data) {
+  if (event != Debug.DebugEvent.Break) return;
   try {
-    if (event == Debug.DebugEvent.Break) {
-      assertArrayEquals(array,
-                        exec_state.frame(0).evaluate('arguments').value());
-    }
+    assertEquals(expected, exec_state.frame(0).evaluate('arg').value());
+    exec_state.frame(0).evaluate('arg = "evaluated";');
   } catch (e) {
-    error = e;
+    exception = e;
   }
-};
+}

 Debug.setListener(listener);

+function f(arg) {
+  expected = arg;
+  debugger;
+  assertEquals("evaluated", arg);

-function f(a, b) {
-  arguments;
-  debugger;  // Arguments object is already materialized.
+  arg = "value";
+  expected = arg;
+  debugger;
+  assertEquals("evaluated", arg);
+
+  // Forces arg to be context allocated even though a parameter.
+  function g() { arg; }
 }

-f.apply(this, array);
-f("a", "b", "c");
-assertNull(error);
+f();
+f(1);
+f(1, 2);

-function g(a, b) {
-  debugger;  // Arguments object is not yet materialized.
-}
-g.apply(this, array);
-g("a", "b", "c");
-assertNull(error);
+assertNull(exception);


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to