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

Unified Diff: src/hydrogen.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.cc ('k') | src/ia32/full-codegen-ia32.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index 987d60b334115809200ccec79c35c489da3ffaa6..0af3990d91ad5d3a8ab821ac6e1aeb034a97b4e0 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -4531,34 +4531,38 @@ void HOptimizedGraphBuilder::VisitBlock(Block* stmt) {
{ BreakAndContinueScope push(&break_info, this);
if (scope != NULL) {
- // Load the function object.
- Scope* declaration_scope = scope->DeclarationScope();
- HInstruction* function;
- HValue* outer_context = environment()->context();
- if (declaration_scope->is_script_scope() ||
- declaration_scope->is_eval_scope()) {
- function = new(zone()) HLoadContextSlot(
- outer_context, Context::CLOSURE_INDEX, HLoadContextSlot::kNoCheck);
- } else {
- function = New<HThisFunction>();
+ if (scope->ContextLocalCount() > 0) {
+ // Load the function object.
+ Scope* declaration_scope = scope->DeclarationScope();
+ HInstruction* function;
+ HValue* outer_context = environment()->context();
+ if (declaration_scope->is_script_scope() ||
+ declaration_scope->is_eval_scope()) {
+ function = new(zone()) HLoadContextSlot(
+ outer_context, Context::CLOSURE_INDEX, HLoadContextSlot::kNoCheck);
+ } else {
+ function = New<HThisFunction>();
+ }
+ AddInstruction(function);
+ // Allocate a block context and store it to the stack frame.
+ DCHECK(scope->GetScopeInfo()->ContextLength() > 0);
+ HInstruction* inner_context = Add<HAllocateBlockContext>(
+ outer_context, function, scope->GetScopeInfo());
+ HInstruction* instr = Add<HStoreFrameContext>(inner_context);
+ environment()->BindContext(inner_context);
+ if (instr->HasObservableSideEffects()) {
+ AddSimulate(stmt->EntryId(), REMOVABLE_SIMULATE);
+ }
}
- AddInstruction(function);
- // Allocate a block context and store it to the stack frame.
- HInstruction* inner_context = Add<HAllocateBlockContext>(
- outer_context, function, scope->GetScopeInfo());
- HInstruction* instr = Add<HStoreFrameContext>(inner_context);
set_scope(scope);
- environment()->BindContext(inner_context);
- if (instr->HasObservableSideEffects()) {
- AddSimulate(stmt->EntryId(), REMOVABLE_SIMULATE);
- }
VisitDeclarations(scope->declarations());
AddSimulate(stmt->DeclsId(), REMOVABLE_SIMULATE);
}
CHECK_BAILOUT(VisitStatements(stmt->statements()));
}
set_scope(outer_scope);
- if (scope != NULL && current_block() != NULL) {
+ if (scope != NULL && current_block() != NULL &&
+ scope->ContextLocalCount() > 0) {
HValue* inner_context = environment()->context();
HValue* outer_context = Add<HLoadNamedField>(
inner_context, nullptr,
« no previous file with comments | « src/full-codegen.cc ('k') | src/ia32/full-codegen-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698