Revision: 9158
Author:   [email protected]
Date:     Tue Sep  6 15:00:59 2011
Log:      Getting rid of ExitContextStatement for scoped blocks.

Review URL: http://codereview.chromium.org/7835027
http://code.google.com/p/v8/source/detail?r=9158

Modified:
 /branches/bleeding_edge/src/full-codegen.cc
 /branches/bleeding_edge/src/parser.cc
 /branches/bleeding_edge/test/mjsunit/harmony/debug-blockscopes.js

=======================================
--- /branches/bleeding_edge/src/full-codegen.cc Tue Sep  6 14:48:32 2011
+++ /branches/bleeding_edge/src/full-codegen.cc Tue Sep  6 15:00:59 2011
@@ -855,6 +855,7 @@
   SetStatementPosition(stmt);

   Scope* saved_scope = scope();
+ // Push a block context when entering a block with block scoped variables.
   if (stmt->block_scope() != NULL) {
     { Comment cmnt(masm_, "[ Extend block context");
       scope_ = stmt->block_scope();
@@ -873,6 +874,14 @@
   scope_ = saved_scope;
   __ bind(nested_block.break_label());
   PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS);
+
+  // Pop block context if necessary.
+  if (stmt->block_scope() != NULL) {
+    LoadContextField(context_register(), Context::PREVIOUS_INDEX);
+    // Update local stack frame context field.
+    StoreToFrameField(StandardFrameConstants::kContextOffset,
+                      context_register());
+  }
 }


=======================================
--- /branches/bleeding_edge/src/parser.cc       Tue Sep  6 14:48:32 2011
+++ /branches/bleeding_edge/src/parser.cc       Tue Sep  6 15:00:59 2011
@@ -1586,16 +1586,7 @@

   block_scope = block_scope->FinalizeBlockScope();
   body->set_block_scope(block_scope);
-
-  if (block_scope != NULL) {
-    // Rewrite the block { B } to a block: { { B } ExitContext; }
-    Block* exit = new(zone()) Block(isolate(), NULL, 2, false);
-    exit->AddStatement(body);
-    exit->AddStatement(new(zone()) ExitContextStatement());
-    return exit;
-  } else {
-    return body;
-  }
+  return body;
 }


=======================================
--- /branches/bleeding_edge/test/mjsunit/harmony/debug-blockscopes.js Tue Sep 6 14:48:32 2011 +++ /branches/bleeding_edge/test/mjsunit/harmony/debug-blockscopes.js Tue Sep 6 15:00:59 2011
@@ -418,28 +418,6 @@
 // With block and a block local variable.
 BeginTest("With block 5");

-function with_block_5() {
-  with({a:1}) {
-    let a = 2;
-    debugger;
-  }
-}
-
-listener_delegate = function(exec_state) {
-  CheckScopeChain([debug.ScopeType.Block,
-                   debug.ScopeType.With,
-                   debug.ScopeType.Local,
-                   debug.ScopeType.Global], exec_state);
-  CheckScopeContent({a:2}, 0, exec_state);
-  CheckScopeContent({a:1}, 1, exec_state);
-};
-with_block_5();
-EndTest();
-
-
-// With block and a block local variable.
-BeginTest("With block 5");
-
 function with_block_5() {
   with({a:1}) {
     let a = 2;

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

Reply via email to