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

Side by Side Diff: src/scopes.cc

Issue 9844002: Implement rudimentary module linking. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased Created 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/scopeinfo.cc ('k') | src/x64/full-codegen-x64.cc » ('j') | 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 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1081 matching lines...) Expand 10 before | Expand all | Expand 10 after
1092 1092
1093 bool Scope::MustAllocateInContext(Variable* var) { 1093 bool Scope::MustAllocateInContext(Variable* var) {
1094 // If var is accessed from an inner scope, or if there is a possibility 1094 // If var is accessed from an inner scope, or if there is a possibility
1095 // that it might be accessed from the current or an inner scope (through 1095 // that it might be accessed from the current or an inner scope (through
1096 // an eval() call or a runtime with lookup), it must be allocated in the 1096 // an eval() call or a runtime with lookup), it must be allocated in the
1097 // context. 1097 // context.
1098 // 1098 //
1099 // Exceptions: temporary variables are never allocated in a context; 1099 // Exceptions: temporary variables are never allocated in a context;
1100 // catch-bound variables are always allocated in a context. 1100 // catch-bound variables are always allocated in a context.
1101 if (var->mode() == TEMPORARY) return false; 1101 if (var->mode() == TEMPORARY) return false;
1102 if (is_catch_scope() || is_block_scope()) return true; 1102 if (is_catch_scope() || is_block_scope() || is_module_scope()) return true;
1103 return var->has_forced_context_allocation() || 1103 return var->has_forced_context_allocation() ||
1104 scope_calls_eval_ || 1104 scope_calls_eval_ ||
1105 inner_scope_calls_eval_ || 1105 inner_scope_calls_eval_ ||
1106 scope_contains_with_ || 1106 scope_contains_with_ ||
1107 var->is_global(); 1107 var->is_global();
1108 } 1108 }
1109 1109
1110 1110
1111 bool Scope::HasArgumentsParameter() { 1111 bool Scope::HasArgumentsParameter() {
1112 for (int i = 0; i < params_.length(); i++) { 1112 for (int i = 0; i < params_.length(); i++) {
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
1236 num_heap_slots_ = Context::MIN_CONTEXT_SLOTS; 1236 num_heap_slots_ = Context::MIN_CONTEXT_SLOTS;
1237 1237
1238 // Allocate variables for this scope. 1238 // Allocate variables for this scope.
1239 // Parameters must be allocated first, if any. 1239 // Parameters must be allocated first, if any.
1240 if (is_function_scope()) AllocateParameterLocals(); 1240 if (is_function_scope()) AllocateParameterLocals();
1241 AllocateNonParameterLocals(); 1241 AllocateNonParameterLocals();
1242 1242
1243 // Force allocation of a context for this scope if necessary. For a 'with' 1243 // Force allocation of a context for this scope if necessary. For a 'with'
1244 // scope and for a function scope that makes an 'eval' call we need a context, 1244 // scope and for a function scope that makes an 'eval' call we need a context,
1245 // even if no local variables were statically allocated in the scope. 1245 // even if no local variables were statically allocated in the scope.
1246 bool must_have_context = is_with_scope() || 1246 // Likewise for modules.
1247 bool must_have_context = is_with_scope() || is_module_scope() ||
1247 (is_function_scope() && calls_eval()); 1248 (is_function_scope() && calls_eval());
1248 1249
1249 // If we didn't allocate any locals in the local context, then we only 1250 // If we didn't allocate any locals in the local context, then we only
1250 // need the minimal number of slots if we must have a context. 1251 // need the minimal number of slots if we must have a context.
1251 if (num_heap_slots_ == Context::MIN_CONTEXT_SLOTS && !must_have_context) { 1252 if (num_heap_slots_ == Context::MIN_CONTEXT_SLOTS && !must_have_context) {
1252 num_heap_slots_ = 0; 1253 num_heap_slots_ = 0;
1253 } 1254 }
1254 1255
1255 // Allocation done. 1256 // Allocation done.
1256 ASSERT(num_heap_slots_ == 0 || num_heap_slots_ >= Context::MIN_CONTEXT_SLOTS); 1257 ASSERT(num_heap_slots_ == 0 || num_heap_slots_ >= Context::MIN_CONTEXT_SLOTS);
1257 } 1258 }
1258 1259
1259 1260
1260 int Scope::StackLocalCount() const { 1261 int Scope::StackLocalCount() const {
1261 return num_stack_slots() - 1262 return num_stack_slots() -
1262 (function_ != NULL && function_->proxy()->var()->IsStackLocal() ? 1 : 0); 1263 (function_ != NULL && function_->proxy()->var()->IsStackLocal() ? 1 : 0);
1263 } 1264 }
1264 1265
1265 1266
1266 int Scope::ContextLocalCount() const { 1267 int Scope::ContextLocalCount() const {
1267 if (num_heap_slots() == 0) return 0; 1268 if (num_heap_slots() == 0) return 0;
1268 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - 1269 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS -
1269 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0); 1270 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0);
1270 } 1271 }
1271 1272
1272 } } // namespace v8::internal 1273 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/scopeinfo.cc ('k') | src/x64/full-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698