Reviewers: Kevin Millikin,
Message:
PTAL.
Description:
Getting rid of ExitContextStatement for scoped blocks.
Please review this at http://codereview.chromium.org/7835027/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/full-codegen.cc
M src/parser.cc
Index: src/full-codegen.cc
diff --git a/src/full-codegen.cc b/src/full-codegen.cc
index
960b4b1aa15808c08fce252d4725c81f2768692e..4f1abbe6bece309bfa79e088856175c16f05890a
100644
--- a/src/full-codegen.cc
+++ b/src/full-codegen.cc
@@ -855,6 +855,7 @@ void FullCodeGenerator::VisitBlock(Block* stmt) {
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 @@ void FullCodeGenerator::VisitBlock(Block* stmt) {
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());
+ }
}
Index: src/parser.cc
diff --git a/src/parser.cc b/src/parser.cc
index
4371093e8669768686fd80418b886b35f6fa4494..a79d5ff3678d48472adb76d69833c051edc8b7ad
100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -1585,16 +1585,7 @@ Block* Parser::ParseScopedBlock(ZoneStringList*
labels, bool* ok) {
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;
}
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev