| Index: src/full-codegen.cc
|
| diff --git a/src/full-codegen.cc b/src/full-codegen.cc
|
| index cb8f4aafcd9cd7274f032f14505f5dd028725252..e64fb927898d786dbd9d2584a88fa6fe9efb2d0b 100644
|
| --- a/src/full-codegen.cc
|
| +++ b/src/full-codegen.cc
|
| @@ -1782,22 +1782,31 @@ bool BackEdgeTable::Verify(Isolate* isolate, Code* unoptimized) {
|
| FullCodeGenerator::EnterBlockScopeIfNeeded::EnterBlockScopeIfNeeded(
|
| FullCodeGenerator* codegen, Scope* scope, BailoutId entry_id,
|
| BailoutId declarations_id, BailoutId exit_id)
|
| - : codegen_(codegen), scope_(scope), exit_id_(exit_id) {
|
| + : codegen_(codegen), exit_id_(exit_id) {
|
| saved_scope_ = codegen_->scope();
|
|
|
| if (scope == NULL) {
|
| codegen_->PrepareForBailoutForId(entry_id, NO_REGISTERS);
|
| + needs_block_context_ = false;
|
| + num_stack_slots_ = 0;
|
| } else {
|
| + needs_block_context_ = scope->ContextLocalCount() > 0;
|
| codegen_->scope_ = scope;
|
| {
|
| Comment cmnt(masm(), "[ Extend block context");
|
| - __ Push(scope->GetScopeInfo());
|
| - codegen_->PushFunctionArgumentForContextAllocation();
|
| - __ CallRuntime(Runtime::kPushBlockContext, 2);
|
|
|
| - // Replace the context stored in the frame.
|
| - codegen_->StoreToFrameField(StandardFrameConstants::kContextOffset,
|
| - codegen_->context_register());
|
| + if (needs_block_context_) {
|
| + DCHECK(scope->GetScopeInfo()->ContextLength() > 0);
|
| + __ Push(scope->GetScopeInfo());
|
| + codegen_->PushFunctionArgumentForContextAllocation();
|
| + __ CallRuntime(Runtime::kPushBlockContext, 2);
|
| +
|
| + // Replace the context stored in the frame.
|
| + codegen_->StoreToFrameField(StandardFrameConstants::kContextOffset,
|
| + codegen_->context_register());
|
| + }
|
| + num_stack_slots_ = scope->num_stack_slots();
|
| + codegen_->AllocateLocals(scope->num_stack_slots());
|
| codegen_->PrepareForBailoutForId(entry_id, NO_REGISTERS);
|
| }
|
| {
|
| @@ -1810,7 +1819,7 @@ FullCodeGenerator::EnterBlockScopeIfNeeded::EnterBlockScopeIfNeeded(
|
|
|
|
|
| FullCodeGenerator::EnterBlockScopeIfNeeded::~EnterBlockScopeIfNeeded() {
|
| - if (scope_ != NULL) {
|
| + if (needs_block_context_) {
|
| codegen_->LoadContextField(codegen_->context_register(),
|
| Context::PREVIOUS_INDEX);
|
| // Update local stack frame context field.
|
| @@ -1818,6 +1827,7 @@ FullCodeGenerator::EnterBlockScopeIfNeeded::~EnterBlockScopeIfNeeded() {
|
| codegen_->context_register());
|
| }
|
| codegen_->PrepareForBailoutForId(exit_id_, NO_REGISTERS);
|
| + codegen_->DeallocateLocals(num_stack_slots_);
|
| codegen_->scope_ = saved_scope_;
|
| }
|
|
|
|
|