Commit 85a5b6d3 authored by keuchel@chromium.org's avatar keuchel@chromium.org

Getting rid of ExitContextStatement for scoped blocks.

Review URL: http://codereview.chromium.org/7835027

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@9158 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent edd893a1
......@@ -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());
}
}
......
......@@ -1586,16 +1586,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;
}
......
......@@ -437,28 +437,6 @@ 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;
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();
// Simple closure formed by returning an inner function referering to an outer
// block local variable and an outer function's parameter.
BeginTest("Closure 1");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment