Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(207)

Unified Diff: src/full-codegen.cc

Issue 804463002: Stack-allocate block variables (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: moar progress Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/full-codegen.h ('k') | src/hydrogen.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_;
}
« no previous file with comments | « src/full-codegen.h ('k') | src/hydrogen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698