Revision: 9273
Author: [email protected]
Date: Wed Sep 14 04:20:31 2011
Log: Fix scope iteration when debugging global code.
TEST=mjsunit/debug-scopes.js
Review URL: http://codereview.chromium.org/7890007
http://code.google.com/p/v8/source/detail?r=9273
Modified:
/branches/bleeding_edge/src/runtime.cc
/branches/bleeding_edge/test/mjsunit/debug-scopes.js
=======================================
--- /branches/bleeding_edge/src/runtime.cc Wed Sep 14 01:08:16 2011
+++ /branches/bleeding_edge/src/runtime.cc Wed Sep 14 04:20:31 2011
@@ -11031,15 +11031,16 @@
at_local_(false) {
// Check whether the first scope is actually a local scope.
- if (context_->IsGlobalContext()) {
- // If there is a stack slot for .result then this local scope has
been
- // created for evaluating top level code and it is not a real local
scope.
- // Checking for the existence of .result seems fragile, but the
scope info
- // saved with the code object does not otherwise have that
information.
- int index = function_->shared()->scope_info()->
- StackSlotIndex(isolate_->heap()->result_symbol());
- at_local_ = index < 0;
- } else if (context_->IsFunctionContext()) {
+ // If there is a stack slot for .result then this local scope has been
+ // created for evaluating top level code and it is not a real local
scope.
+ // Checking for the existence of .result seems fragile, but the scope
info
+ // saved with the code object does not otherwise have that information.
+ int index = function_->shared()->scope_info()->
+ StackSlotIndex(isolate_->heap()->result_symbol());
+ if (index >= 0) {
+ local_done_ = true;
+ } else if (context_->IsGlobalContext() ||
+ context_->IsFunctionContext()) {
at_local_ = true;
} else if (context_->closure() != *function_) {
// The context_ is a block or with or catch block from the outer
function.
@@ -11086,7 +11087,7 @@
}
// Return the type of the current scope.
- int Type() {
+ ScopeType Type() {
if (at_local_) {
return ScopeTypeLocal;
}
=======================================
--- /branches/bleeding_edge/test/mjsunit/debug-scopes.js Fri Apr 15
04:35:36 2011
+++ /branches/bleeding_edge/test/mjsunit/debug-scopes.js Wed Sep 14
04:20:31 2011
@@ -418,6 +418,27 @@
EndTest();
+// Nested with blocks using existing object in global code.
+BeginTest("With 6");
+listener_delegate = function(exec_state) {
+ CheckScopeChain([debug.ScopeType.With,
+ debug.ScopeType.With,
+ debug.ScopeType.Global], exec_state);
+ CheckScopeContent(with_object, 0, exec_state);
+ CheckScopeContent(with_object, 1, exec_state);
+ assertEquals(exec_state.frame().scope(0).scopeObject(),
exec_state.frame().scope(1).scopeObject());
+ assertEquals(with_object,
exec_state.frame().scope(1).scopeObject().value());
+};
+
+var with_object = {c:3,d:4};
+with(with_object) {
+ with(with_object) {
+ debugger;
+ }
+}
+EndTest();
+
+
// Simple closure formed by returning an inner function referering the
outer
// functions arguments.
BeginTest("Closure 1");
@@ -771,6 +792,23 @@
EndTest();
+BeginTest("Closure inside With 4");
+listener_delegate = function(exec_state) {
+ CheckScopeChain([debug.ScopeType.Local,
+ debug.ScopeType.With,
+ debug.ScopeType.Global], exec_state);
+ CheckScopeContent({x: 2}, 0, exec_state);
+ CheckScopeContent({x: 1}, 1, exec_state);
+};
+
+with({x:1}) {
+ (function(x) {
+ debugger;
+ })(2);
+}
+EndTest();
+
+
// Test global scope.
BeginTest("Global");
listener_delegate = function(exec_state) {
@@ -875,6 +913,43 @@
EndTest();
+// Test catch in global scope.
+BeginTest("Catch block 5");
+listener_delegate = function(exec_state) {
+ CheckScopeChain([debug.ScopeType.Catch,
+ debug.ScopeType.Global], exec_state);
+ CheckScopeContent({e:'Exception'}, 0, exec_state);
+};
+
+try {
+ throw 'Exception';
+} catch (e) {
+ debugger;
+}
+
+EndTest();
+
+
+// Closure inside catch in global code.
+BeginTest("Catch block 6");
+listener_delegate = function(exec_state) {
+ CheckScopeChain([debug.ScopeType.Local,
+ debug.ScopeType.Catch,
+ debug.ScopeType.Global], exec_state);
+ CheckScopeContent({x: 2}, 0, exec_state);
+ CheckScopeContent({e:'Exception'}, 1, exec_state);
+};
+
+try {
+ throw 'Exception';
+} catch (e) {
+ (function(x) {
+ debugger;
+ })(2);
+}
+EndTest();
+
+
assertEquals(begin_test_count, break_count,
'one or more tests did not enter the debugger');
assertEquals(begin_test_count, end_test_count,
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev