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

Side by Side Diff: src/scopes.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 unified diff | Download patch
« no previous file with comments | « src/ia32/full-codegen-ia32.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/scopes.h" 7 #include "src/scopes.h"
8 8
9 #include "src/accessors.h" 9 #include "src/accessors.h"
10 #include "src/bootstrapper.h" 10 #include "src/bootstrapper.h"
(...skipping 1223 matching lines...) Expand 10 before | Expand all | Expand 10 after
1234 // an eval() call or a runtime with lookup), it must be allocated in the 1234 // an eval() call or a runtime with lookup), it must be allocated in the
1235 // context. 1235 // context.
1236 // 1236 //
1237 // Exceptions: If the scope as a whole has forced context allocation, all 1237 // Exceptions: If the scope as a whole has forced context allocation, all
1238 // variables will have context allocation, even temporaries. Otherwise 1238 // variables will have context allocation, even temporaries. Otherwise
1239 // temporary variables are always stack-allocated. Catch-bound variables are 1239 // temporary variables are always stack-allocated. Catch-bound variables are
1240 // always context-allocated. 1240 // always context-allocated.
1241 if (has_forced_context_allocation()) return true; 1241 if (has_forced_context_allocation()) return true;
1242 if (var->mode() == TEMPORARY) return false; 1242 if (var->mode() == TEMPORARY) return false;
1243 if (var->mode() == INTERNAL) return true; 1243 if (var->mode() == INTERNAL) return true;
1244 if (is_catch_scope() || is_block_scope() || is_module_scope()) return true; 1244 if (is_catch_scope() || is_module_scope()) return true;
1245 if (is_script_scope() && IsLexicalVariableMode(var->mode())) return true; 1245 if (is_script_scope() && IsLexicalVariableMode(var->mode())) return true;
1246 return var->has_forced_context_allocation() || 1246 return var->has_forced_context_allocation() ||
1247 scope_calls_eval_ || 1247 scope_calls_eval_ ||
1248 inner_scope_calls_eval_ || 1248 inner_scope_calls_eval_ ||
1249 scope_contains_with_; 1249 scope_contains_with_;
1250 } 1250 }
1251 1251
1252 1252
1253 bool Scope::HasArgumentsParameter() { 1253 bool Scope::HasArgumentsParameter() {
1254 for (int i = 0; i < params_.length(); i++) { 1254 for (int i = 0; i < params_.length(); i++) {
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
1433 } 1433 }
1434 1434
1435 1435
1436 int Scope::ContextLocalCount() const { 1436 int Scope::ContextLocalCount() const {
1437 if (num_heap_slots() == 0) return 0; 1437 if (num_heap_slots() == 0) return 0;
1438 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - 1438 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS -
1439 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0); 1439 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0);
1440 } 1440 }
1441 1441
1442 } } // namespace v8::internal 1442 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ia32/full-codegen-ia32.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698