From 6b89b5975f57b15b17fc328469166c23ca5c07b2 Mon Sep 17 00:00:00 2001 From: "kmillikin@chromium.org" Date: Thu, 20 Jan 2011 12:58:57 +0000 Subject: [PATCH] Revert "Make 'with' mark only variables occurring in the body as used." This reverts SVN revision 6415 due to layout test failures. TBR=ricow Review URL: http://codereview.chromium.org/6374006 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@6418 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/scopes.cc | 5 ++--- test/mjsunit/debug-evaluate-locals.js | 20 +++++++++++--------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/scopes.cc b/src/scopes.cc index 50da1fa..d3f54ad 100644 --- a/src/scopes.cc +++ b/src/scopes.cc @@ -726,7 +726,6 @@ void Scope::ResolveVariable(Scope* global_scope, // Note that we must do a lookup anyway, because if we find one, // we must mark that variable as potentially accessed from this // inner scope (the property may not be in the 'with' object). - if (var != NULL) var->set_is_used(true); var = NonLocal(proxy->name(), Variable::DYNAMIC); } else { @@ -834,8 +833,8 @@ bool Scope::MustAllocate(Variable* var) { // visible name. if ((var->is_this() || var->name()->length() > 0) && (var->is_accessed_from_inner_scope() || - scope_calls_eval_ || - inner_scope_calls_eval_)) { + scope_calls_eval_ || inner_scope_calls_eval_ || + scope_contains_with_)) { var->set_is_used(true); } // Global variables do not need to be allocated. diff --git a/test/mjsunit/debug-evaluate-locals.js b/test/mjsunit/debug-evaluate-locals.js index 8bc6a61..4b87829 100644 --- a/test/mjsunit/debug-evaluate-locals.js +++ b/test/mjsunit/debug-evaluate-locals.js @@ -34,18 +34,18 @@ exception = false; function checkFrame0(name, value) { - assertTrue(name == 'a' || name == 'b', 'check name'); + assertTrue(name == 'a' || name == 'b'); if (name == 'a') { assertEquals(1, value); - } else if (name == 'b') { + } + if (name == 'b') { assertEquals(2, value); } } function checkFrame1(name, value) { - assertTrue(name == '.arguments' || name == 'arguments' || name == 'a', - 'check name'); + assertTrue(name == '.arguments' || name == 'a'); if (name == 'a') { assertEquals(3, value); } @@ -53,7 +53,8 @@ function checkFrame1(name, value) { function checkFrame2(name, value) { - assertTrue(name == 'a' || name == 'b'); + assertTrue(name == '.arguments' || name == 'a' || + name == 'arguments' || name == 'b'); if (name == 'a') { assertEquals(5, value); } @@ -72,17 +73,18 @@ function listener(event, exec_state, event_data, data) { checkFrame0(frame0.localName(0), frame0.localValue(0).value()); checkFrame0(frame0.localName(1), frame0.localValue(1).value()); - // Frame 1 has normal variables a and arguments (and the .arguments - // variable). + // Frame 1 has normal variable a (and the .arguments variable). var frame1 = exec_state.frame(1); checkFrame1(frame1.localName(0), frame1.localValue(0).value()); checkFrame1(frame1.localName(1), frame1.localValue(1).value()); - checkFrame1(frame1.localName(2), frame1.localValue(2).value()); - // Frame 2 has normal variables a and b. + // Frame 2 has normal variables a and b (and both the .arguments and + // arguments variable). var frame2 = exec_state.frame(2); checkFrame2(frame2.localName(0), frame2.localValue(0).value()); checkFrame2(frame2.localName(1), frame2.localValue(1).value()); + checkFrame2(frame2.localName(2), frame2.localValue(2).value()); + checkFrame2(frame2.localName(3), frame2.localValue(3).value()); // Evaluating a and b on frames 0, 1 and 2 produces 1, 2, 3, 4, 5 and 6. assertEquals(1, exec_state.frame(0).evaluate('a').value()); -- 2.7.4