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

Unified Diff: src/hydrogen.cc

Issue 981203003: Stack allocate lexical locals + hoist stack slots (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Feedback + rebased Created 5 years, 8 months 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/objects.h » ('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 74434cd528b9dbc95bdb7e7f17fd1acbe57981dd..0faa4af6ffd2c4edf0b007b89363623a77f58e31 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -4512,26 +4512,29 @@ 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>();
- }
- AddInstruction(function);
- // Allocate a block context and store it to the stack frame.
- HInstruction* inner_context = Add<HAllocateBlockContext>(
- outer_context, function, scope->GetScopeInfo(isolate()));
- HInstruction* instr = Add<HStoreFrameContext>(inner_context);
- set_scope(scope);
- environment()->BindContext(inner_context);
- if (instr->HasObservableSideEffects()) {
- AddSimulate(stmt->EntryId(), REMOVABLE_SIMULATE);
+ 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.
+ HInstruction* inner_context = Add<HAllocateBlockContext>(
+ outer_context, function, scope->GetScopeInfo(isolate()));
+ 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);
@@ -4539,7 +4542,8 @@ void HOptimizedGraphBuilder::VisitBlock(Block* stmt) {
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/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698