Revision: 20195
Author: [email protected]
Date: Mon Mar 24 14:10:57 2014 UTC
Log: Fix DebugEvaluate for generators.
[email protected]
BUG=v8:3225
LOG=N
Review URL: https://codereview.chromium.org/207153004
http://code.google.com/p/v8/source/detail?r=20195
Added:
/branches/bleeding_edge/test/mjsunit/regress-3225.js
Modified:
/branches/bleeding_edge/src/runtime.cc
=======================================
--- /dev/null
+++ /branches/bleeding_edge/test/mjsunit/regress-3225.js Mon Mar 24
14:10:57 2014 UTC
@@ -0,0 +1,48 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Flags: --expose-debug-as debug --harmony-generators
+
+Debug = debug.Debug
+
+var debug_step = 0;
+var failure = null;
+
+function listener(event, exec_state, event_data, data) {
+ if (event != Debug.DebugEvent.Break) return;
+ try {
+ if (debug_step == 0) {
+ assertEquals(1, exec_state.frame(0).evaluate('a').value());
+ assertEquals(3, exec_state.frame(0).evaluate('b').value());
+ exec_state.frame(0).evaluate("a = 4").value();
+ debug_step++;
+ } else {
+ assertEquals(4, exec_state.frame(0).evaluate('a').value());
+ assertEquals(3, exec_state.frame(0).evaluate('b').value());
+ exec_state.frame(0).evaluate("b = 5").value();
+ }
+ } catch (e) {
+ failure = e;
+ }
+}
+
+Debug.setListener(listener);
+
+function* generator(a, b) {
+ var b = 3; // Shadows a parameter.
+ debugger;
+ yield a;
+ yield b;
+ debugger;
+ return b;
+}
+
+var foo = generator(1, 2);
+
+assertEquals(4, foo.next().value);
+assertEquals(3, foo.next().value);
+assertEquals(5, foo.next().value);
+assertNull(failure);
+
+Debug.setListener(null);
=======================================
--- /branches/bleeding_edge/src/runtime.cc Mon Mar 24 10:07:15 2014 UTC
+++ /branches/bleeding_edge/src/runtime.cc Mon Mar 24 14:10:57 2014 UTC
@@ -11407,6 +11407,14 @@
ASSERT_EQ(details_size, details_index);
return *isolate->factory()->NewJSArrayWithElements(details);
}
+
+
+static bool ParameterIsShadowedByContextLocal(Handle<ScopeInfo> info,
+ int index) {
+ VariableMode mode;
+ InitializationFlag flag;
+ return info->ContextSlotIndex(info->ParameterName(index), &mode,
&flag) != -1;
+}
// Create a plain JSObject which materializes the local scope for the
specified
@@ -11421,17 +11429,16 @@
// 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;
+ if (ParameterIsShadowedByContextLocal(scope_info, i)) continue;
+ HandleScope scope(isolate);
Handle<Object> value(i < frame_inspector->GetParametersCount()
? frame_inspector->GetParameter(i)
: isolate->heap()->undefined_value(),
isolate);
ASSERT(!value->IsTheHole());
+ Handle<String> name(scope_info->ParameterName(i));
RETURN_IF_EMPTY_HANDLE_VALUE(
isolate,
@@ -11472,10 +11479,13 @@
// Parameters.
for (int i = 0; i < scope_info->ParameterCount(); ++i) {
+ // Shadowed parameters were not materialized.
+ if (ParameterIsShadowedByContextLocal(scope_info, i)) continue;
+
ASSERT(!frame->GetParameter(i)->IsTheHole());
HandleScope scope(isolate);
- Handle<Object> value = GetProperty(
- isolate, target, Handle<String>(scope_info->ParameterName(i)));
+ Handle<String> name(scope_info->ParameterName(i));
+ Handle<Object> value = GetProperty(isolate, target, name);
frame->SetParameterValue(i, *value);
}
--
--
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/d/optout.