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

Side by Side Diff: src/scopes.cc

Issue 345573002: Infer whether a variable is assigned (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: A few more tests Created 6 years, 6 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/scopes.h ('k') | src/variables.h » ('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 // 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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 function_ = NULL; 163 function_ = NULL;
164 arguments_ = NULL; 164 arguments_ = NULL;
165 illegal_redecl_ = NULL; 165 illegal_redecl_ = NULL;
166 scope_inside_with_ = false; 166 scope_inside_with_ = false;
167 scope_contains_with_ = false; 167 scope_contains_with_ = false;
168 scope_calls_eval_ = false; 168 scope_calls_eval_ = false;
169 // Inherit the strict mode from the parent scope. 169 // Inherit the strict mode from the parent scope.
170 strict_mode_ = outer_scope != NULL ? outer_scope->strict_mode_ : SLOPPY; 170 strict_mode_ = outer_scope != NULL ? outer_scope->strict_mode_ : SLOPPY;
171 outer_scope_calls_sloppy_eval_ = false; 171 outer_scope_calls_sloppy_eval_ = false;
172 inner_scope_calls_eval_ = false; 172 inner_scope_calls_eval_ = false;
173 inner_scope_contains_with_ = false;
173 force_eager_compilation_ = false; 174 force_eager_compilation_ = false;
174 force_context_allocation_ = (outer_scope != NULL && !is_function_scope()) 175 force_context_allocation_ = (outer_scope != NULL && !is_function_scope())
175 ? outer_scope->has_forced_context_allocation() : false; 176 ? outer_scope->has_forced_context_allocation() : false;
176 num_var_or_const_ = 0; 177 num_var_or_const_ = 0;
177 num_stack_slots_ = 0; 178 num_stack_slots_ = 0;
178 num_heap_slots_ = 0; 179 num_heap_slots_ = 0;
179 num_modules_ = 0; 180 num_modules_ = 0;
180 module_var_ = NULL, 181 module_var_ = NULL,
181 scope_info_ = scope_info; 182 scope_info_ = scope_info;
182 start_position_ = RelocInfo::kNoPosition; 183 start_position_ = RelocInfo::kNoPosition;
183 end_position_ = RelocInfo::kNoPosition; 184 end_position_ = RelocInfo::kNoPosition;
184 if (!scope_info.is_null()) { 185 if (!scope_info.is_null()) {
185 scope_calls_eval_ = scope_info->CallsEval(); 186 scope_calls_eval_ = scope_info->CallsEval();
186 strict_mode_ = scope_info->strict_mode(); 187 strict_mode_ = scope_info->strict_mode();
187 } 188 }
188 } 189 }
189 190
190 191
191 Scope* Scope::DeserializeScopeChain(Context* context, Scope* global_scope, 192 Scope* Scope::DeserializeScopeChain(Context* context, Scope* global_scope,
192 Zone* zone) { 193 Zone* zone) {
193 // Reconstruct the outer scope chain from a closure's context chain. 194 // Reconstruct the outer scope chain from a closure's context chain.
194 Scope* current_scope = NULL; 195 Scope* current_scope = NULL;
195 Scope* innermost_scope = NULL; 196 Scope* innermost_scope = NULL;
196 bool contains_with = false; 197 bool contains_with = false;
198 bool inner_contains_with = false;
197 while (!context->IsNativeContext()) { 199 while (!context->IsNativeContext()) {
198 if (context->IsWithContext()) { 200 if (context->IsWithContext()) {
199 Scope* with_scope = new(zone) Scope(current_scope, 201 Scope* with_scope = new(zone) Scope(current_scope,
200 WITH_SCOPE, 202 WITH_SCOPE,
201 Handle<ScopeInfo>::null(), 203 Handle<ScopeInfo>::null(),
202 zone); 204 zone);
203 current_scope = with_scope; 205 current_scope = with_scope;
204 // All the inner scopes are inside a with. 206 // All the inner scopes are inside a with.
205 contains_with = true; 207 contains_with = true;
206 for (Scope* s = innermost_scope; s != NULL; s = s->outer_scope()) { 208 for (Scope* s = innermost_scope; s != NULL; s = s->outer_scope()) {
(...skipping 22 matching lines...) Expand all
229 current_scope = new(zone) Scope(current_scope, 231 current_scope = new(zone) Scope(current_scope,
230 BLOCK_SCOPE, 232 BLOCK_SCOPE,
231 Handle<ScopeInfo>(scope_info), 233 Handle<ScopeInfo>(scope_info),
232 zone); 234 zone);
233 } else { 235 } else {
234 ASSERT(context->IsCatchContext()); 236 ASSERT(context->IsCatchContext());
235 String* name = String::cast(context->extension()); 237 String* name = String::cast(context->extension());
236 current_scope = new(zone) Scope( 238 current_scope = new(zone) Scope(
237 current_scope, Handle<String>(name), zone); 239 current_scope, Handle<String>(name), zone);
238 } 240 }
239 if (contains_with) current_scope->RecordWithStatement(); 241 if (inner_contains_with) current_scope->inner_scope_contains_with_ = true;
242 if (contains_with) {
243 current_scope->RecordWithStatement();
244 inner_contains_with = true;
245 }
240 if (innermost_scope == NULL) innermost_scope = current_scope; 246 if (innermost_scope == NULL) innermost_scope = current_scope;
241 247
242 // Forget about a with when we move to a context for a different function. 248 // Forget about a with when we move to a context for a different function.
243 if (context->previous()->closure() != context->closure()) { 249 if (context->previous()->closure() != context->closure()) {
244 contains_with = false; 250 contains_with = false;
245 } 251 }
246 context = context->previous(); 252 context = context->previous();
247 } 253 }
248 254
249 global_scope->AddInnerScope(current_scope); 255 global_scope->AddInnerScope(current_scope);
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after
799 } 805 }
800 806
801 807
802 static void PrintVar(int indent, Variable* var) { 808 static void PrintVar(int indent, Variable* var) {
803 if (var->is_used() || !var->IsUnallocated()) { 809 if (var->is_used() || !var->IsUnallocated()) {
804 Indent(indent, Variable::Mode2String(var->mode())); 810 Indent(indent, Variable::Mode2String(var->mode()));
805 PrintF(" "); 811 PrintF(" ");
806 PrintName(var->name()); 812 PrintName(var->name());
807 PrintF("; // "); 813 PrintF("; // ");
808 PrintLocation(var); 814 PrintLocation(var);
815 bool comma = !var->IsUnallocated();
809 if (var->has_forced_context_allocation()) { 816 if (var->has_forced_context_allocation()) {
810 if (!var->IsUnallocated()) PrintF(", "); 817 if (comma) PrintF(", ");
811 PrintF("forced context allocation"); 818 PrintF("forced context allocation");
819 comma = true;
820 }
821 if (var->is_assigned_in_inner_function()) {
822 if (comma) PrintF(", ");
823 PrintF("inner assignment");
812 } 824 }
813 PrintF("\n"); 825 PrintF("\n");
814 } 826 }
815 } 827 }
816 828
817 829
818 static void PrintMap(int indent, VariableMap* map) { 830 static void PrintMap(int indent, VariableMap* map) {
819 for (VariableMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) { 831 for (VariableMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) {
820 Variable* var = reinterpret_cast<Variable*>(p->value); 832 Variable* var = reinterpret_cast<Variable*>(p->value);
821 PrintVar(indent, var); 833 PrintVar(indent, var);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
855 867
856 // Scope info. 868 // Scope info.
857 if (HasTrivialOuterContext()) { 869 if (HasTrivialOuterContext()) {
858 Indent(n1, "// scope has trivial outer context\n"); 870 Indent(n1, "// scope has trivial outer context\n");
859 } 871 }
860 if (strict_mode() == STRICT) { 872 if (strict_mode() == STRICT) {
861 Indent(n1, "// strict mode scope\n"); 873 Indent(n1, "// strict mode scope\n");
862 } 874 }
863 if (scope_inside_with_) Indent(n1, "// scope inside 'with'\n"); 875 if (scope_inside_with_) Indent(n1, "// scope inside 'with'\n");
864 if (scope_contains_with_) Indent(n1, "// scope contains 'with'\n"); 876 if (scope_contains_with_) Indent(n1, "// scope contains 'with'\n");
877 if (inner_scope_contains_with_) {
878 Indent(n1, "// inner scope contains 'with'\n");
879 }
865 if (scope_calls_eval_) Indent(n1, "// scope calls 'eval'\n"); 880 if (scope_calls_eval_) Indent(n1, "// scope calls 'eval'\n");
866 if (outer_scope_calls_sloppy_eval_) { 881 if (outer_scope_calls_sloppy_eval_) {
867 Indent(n1, "// outer scope calls 'eval' in sloppy context\n"); 882 Indent(n1, "// outer scope calls 'eval' in sloppy context\n");
868 } 883 }
869 if (inner_scope_calls_eval_) Indent(n1, "// inner scope calls 'eval'\n"); 884 if (inner_scope_calls_eval_) Indent(n1, "// inner scope calls 'eval'\n");
870 if (num_stack_slots_ > 0) { Indent(n1, "// "); 885 if (num_stack_slots_ > 0) { Indent(n1, "// ");
871 PrintF("%d stack slots\n", num_stack_slots_); } 886 PrintF("%d stack slots\n", num_stack_slots_); }
872 if (num_heap_slots_ > 0) { Indent(n1, "// "); 887 if (num_heap_slots_ > 0) { Indent(n1, "// ");
873 PrintF("%d heap slots\n", num_heap_slots_); } 888 PrintF("%d heap slots\n", num_heap_slots_); }
874 889
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
931 true, 946 true,
932 Variable::NORMAL, 947 Variable::NORMAL,
933 init_flag); 948 init_flag);
934 // Allocate it by giving it a dynamic lookup. 949 // Allocate it by giving it a dynamic lookup.
935 var->AllocateTo(Variable::LOOKUP, -1); 950 var->AllocateTo(Variable::LOOKUP, -1);
936 } 951 }
937 return var; 952 return var;
938 } 953 }
939 954
940 955
941 Variable* Scope::LookupRecursive(Handle<String> name, 956 Variable* Scope::LookupRecursive(VariableProxy* proxy,
942 BindingKind* binding_kind, 957 BindingKind* binding_kind,
943 AstNodeFactory<AstNullVisitor>* factory) { 958 AstNodeFactory<AstNullVisitor>* factory) {
944 ASSERT(binding_kind != NULL); 959 ASSERT(binding_kind != NULL);
945 if (already_resolved() && is_with_scope()) { 960 if (already_resolved() && is_with_scope()) {
946 // Short-cut: if the scope is deserialized from a scope info, variable 961 // Short-cut: if the scope is deserialized from a scope info, variable
947 // allocation is already fixed. We can simply return with dynamic lookup. 962 // allocation is already fixed. We can simply return with dynamic lookup.
948 *binding_kind = DYNAMIC_LOOKUP; 963 *binding_kind = DYNAMIC_LOOKUP;
949 return NULL; 964 return NULL;
950 } 965 }
951 966
952 // Try to find the variable in this scope. 967 // Try to find the variable in this scope.
953 Variable* var = LookupLocal(name); 968 Variable* var = LookupLocal(proxy->name());
954 969
955 // We found a variable and we are done. (Even if there is an 'eval' in 970 // We found a variable and we are done. (Even if there is an 'eval' in
956 // this scope which introduces the same variable again, the resulting 971 // this scope which introduces the same variable again, the resulting
957 // variable remains the same.) 972 // variable remains the same.)
958 if (var != NULL) { 973 if (var != NULL) {
959 *binding_kind = BOUND; 974 *binding_kind = BOUND;
960 return var; 975 return var;
961 } 976 }
962 977
963 // We did not find a variable locally. Check against the function variable, 978 // We did not find a variable locally. Check against the function variable,
964 // if any. We can do this for all scopes, since the function variable is 979 // if any. We can do this for all scopes, since the function variable is
965 // only present - if at all - for function scopes. 980 // only present - if at all - for function scopes.
966 *binding_kind = UNBOUND; 981 *binding_kind = UNBOUND;
967 var = LookupFunctionVar(name, factory); 982 var = LookupFunctionVar(proxy->name(), factory);
968 if (var != NULL) { 983 if (var != NULL) {
969 *binding_kind = BOUND; 984 *binding_kind = BOUND;
970 } else if (outer_scope_ != NULL) { 985 } else if (outer_scope_ != NULL) {
971 var = outer_scope_->LookupRecursive(name, binding_kind, factory); 986 var = outer_scope_->LookupRecursive(proxy, binding_kind, factory);
972 if (*binding_kind == BOUND && (is_function_scope() || is_with_scope())) { 987 if (*binding_kind == BOUND && (is_function_scope() || is_with_scope())) {
973 var->ForceContextAllocation(); 988 var->ForceContextAllocation();
974 } 989 }
975 } else { 990 } else {
976 ASSERT(is_global_scope()); 991 ASSERT(is_global_scope());
977 } 992 }
978 993
979 if (is_with_scope()) { 994 if (is_with_scope()) {
980 ASSERT(!already_resolved()); 995 ASSERT(!already_resolved());
981 // The current scope is a with scope, so the variable binding can not be 996 // The current scope is a with scope, so the variable binding can not be
982 // statically resolved. However, note that it was necessary to do a lookup 997 // statically resolved. However, note that it was necessary to do a lookup
983 // in the outer scope anyway, because if a binding exists in an outer scope, 998 // in the outer scope anyway, because if a binding exists in an outer scope,
984 // the associated variable has to be marked as potentially being accessed 999 // the associated variable has to be marked as potentially being accessed
985 // from inside of an inner with scope (the property may not be in the 'with' 1000 // from inside of an inner with scope (the property may not be in the 'with'
986 // object). 1001 // object).
1002 if (proxy->is_assigned()) var->set_maybe_assigned();
987 *binding_kind = DYNAMIC_LOOKUP; 1003 *binding_kind = DYNAMIC_LOOKUP;
988 return NULL; 1004 return NULL;
989 } else if (calls_sloppy_eval()) { 1005 } else if (calls_sloppy_eval()) {
990 // A variable binding may have been found in an outer scope, but the current 1006 // A variable binding may have been found in an outer scope, but the current
991 // scope makes a sloppy 'eval' call, so the found variable may not be 1007 // scope makes a sloppy 'eval' call, so the found variable may not be
992 // the correct one (the 'eval' may introduce a binding with the same name). 1008 // the correct one (the 'eval' may introduce a binding with the same name).
993 // In that case, change the lookup result to reflect this situation. 1009 // In that case, change the lookup result to reflect this situation.
994 if (*binding_kind == BOUND) { 1010 if (*binding_kind == BOUND) {
995 *binding_kind = BOUND_EVAL_SHADOWED; 1011 *binding_kind = BOUND_EVAL_SHADOWED;
996 } else if (*binding_kind == UNBOUND) { 1012 } else if (*binding_kind == UNBOUND) {
997 *binding_kind = UNBOUND_EVAL_SHADOWED; 1013 *binding_kind = UNBOUND_EVAL_SHADOWED;
998 } 1014 }
999 } 1015 }
1000 return var; 1016 return var;
1001 } 1017 }
1002 1018
1003 1019
1004 bool Scope::ResolveVariable(CompilationInfo* info, 1020 bool Scope::ResolveVariable(CompilationInfo* info,
1005 VariableProxy* proxy, 1021 VariableProxy* proxy,
1006 AstNodeFactory<AstNullVisitor>* factory) { 1022 AstNodeFactory<AstNullVisitor>* factory) {
1007 ASSERT(info->global_scope()->is_global_scope()); 1023 ASSERT(info->global_scope()->is_global_scope());
1008 1024
1009 // If the proxy is already resolved there's nothing to do 1025 // If the proxy is already resolved there's nothing to do
1010 // (functions and consts may be resolved by the parser). 1026 // (functions and consts may be resolved by the parser).
1011 if (proxy->var() != NULL) return true; 1027 if (proxy->var() != NULL) return true;
1012 1028
1013 // Otherwise, try to resolve the variable. 1029 // Otherwise, try to resolve the variable.
1014 BindingKind binding_kind; 1030 BindingKind binding_kind;
1015 Variable* var = LookupRecursive(proxy->name(), &binding_kind, factory); 1031 Variable* var = LookupRecursive(proxy, &binding_kind, factory);
1016 switch (binding_kind) { 1032 switch (binding_kind) {
1017 case BOUND: 1033 case BOUND:
1018 // We found a variable binding. 1034 // We found a variable binding.
1019 break; 1035 break;
1020 1036
1021 case BOUND_EVAL_SHADOWED: 1037 case BOUND_EVAL_SHADOWED:
1022 // We either found a variable binding that might be shadowed by eval or 1038 // We either found a variable binding that might be shadowed by eval or
1023 // gave up on it (e.g. by encountering a local with the same in the outer 1039 // gave up on it (e.g. by encountering a local with the same in the outer
1024 // scope which was not promoted to a context, this can happen if we use 1040 // scope which was not promoted to a context, this can happen if we use
1025 // debugger to evaluate arbitrary expressions at a break point). 1041 // debugger to evaluate arbitrary expressions at a break point).
(...skipping 18 matching lines...) Expand all
1044 var = NonLocal(proxy->name(), DYNAMIC_GLOBAL); 1060 var = NonLocal(proxy->name(), DYNAMIC_GLOBAL);
1045 break; 1061 break;
1046 1062
1047 case DYNAMIC_LOOKUP: 1063 case DYNAMIC_LOOKUP:
1048 // The variable could not be resolved statically. 1064 // The variable could not be resolved statically.
1049 var = NonLocal(proxy->name(), DYNAMIC); 1065 var = NonLocal(proxy->name(), DYNAMIC);
1050 break; 1066 break;
1051 } 1067 }
1052 1068
1053 ASSERT(var != NULL); 1069 ASSERT(var != NULL);
1070 if (proxy->is_assigned()) var->set_maybe_assigned();
1054 1071
1055 if (FLAG_harmony_scoping && strict_mode() == STRICT && 1072 if (FLAG_harmony_scoping && strict_mode() == STRICT &&
1056 var->is_const_mode() && proxy->IsLValue()) { 1073 var->is_const_mode() && proxy->is_assigned()) {
1057 // Assignment to const. Throw a syntax error. 1074 // Assignment to const. Throw a syntax error.
1058 MessageLocation location( 1075 MessageLocation location(
1059 info->script(), proxy->position(), proxy->position()); 1076 info->script(), proxy->position(), proxy->position());
1060 Isolate* isolate = info->isolate(); 1077 Isolate* isolate = info->isolate();
1061 Factory* factory = isolate->factory(); 1078 Factory* factory = isolate->factory();
1062 Handle<JSArray> array = factory->NewJSArray(0); 1079 Handle<JSArray> array = factory->NewJSArray(0);
1063 Handle<Object> result = 1080 Handle<Object> result =
1064 factory->NewSyntaxError("harmony_const_assign", array); 1081 factory->NewSyntaxError("harmony_const_assign", array);
1065 isolate->Throw(*result, &location); 1082 isolate->Throw(*result, &location);
1066 return false; 1083 return false;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1118 // Resolve unresolved variables for inner scopes. 1135 // Resolve unresolved variables for inner scopes.
1119 for (int i = 0; i < inner_scopes_.length(); i++) { 1136 for (int i = 0; i < inner_scopes_.length(); i++) {
1120 if (!inner_scopes_[i]->ResolveVariablesRecursively(info, factory)) 1137 if (!inner_scopes_[i]->ResolveVariablesRecursively(info, factory))
1121 return false; 1138 return false;
1122 } 1139 }
1123 1140
1124 return true; 1141 return true;
1125 } 1142 }
1126 1143
1127 1144
1128 bool Scope::PropagateScopeInfo(bool outer_scope_calls_sloppy_eval ) { 1145 void Scope::PropagateScopeInfo(bool outer_scope_calls_sloppy_eval ) {
1129 if (outer_scope_calls_sloppy_eval) { 1146 if (outer_scope_calls_sloppy_eval) {
1130 outer_scope_calls_sloppy_eval_ = true; 1147 outer_scope_calls_sloppy_eval_ = true;
1131 } 1148 }
1132 1149
1133 bool calls_sloppy_eval = 1150 bool calls_sloppy_eval =
1134 this->calls_sloppy_eval() || outer_scope_calls_sloppy_eval_; 1151 this->calls_sloppy_eval() || outer_scope_calls_sloppy_eval_;
1135 for (int i = 0; i < inner_scopes_.length(); i++) { 1152 for (int i = 0; i < inner_scopes_.length(); i++) {
1136 Scope* inner_scope = inner_scopes_[i]; 1153 Scope* inner = inner_scopes_[i];
1137 if (inner_scope->PropagateScopeInfo(calls_sloppy_eval)) { 1154 inner->PropagateScopeInfo(calls_sloppy_eval);
1155 if (inner->scope_calls_eval_ || inner->inner_scope_calls_eval_) {
1138 inner_scope_calls_eval_ = true; 1156 inner_scope_calls_eval_ = true;
1139 } 1157 }
1140 if (inner_scope->force_eager_compilation_) { 1158 if (inner->scope_contains_with_ || inner->inner_scope_contains_with_) {
1159 inner_scope_contains_with_ = true;
1160 }
1161 if (inner->force_eager_compilation_) {
1141 force_eager_compilation_ = true; 1162 force_eager_compilation_ = true;
1142 } 1163 }
1143 } 1164 }
1144
1145 return scope_calls_eval_ || inner_scope_calls_eval_;
1146 } 1165 }
1147 1166
1148 1167
1149 bool Scope::MustAllocate(Variable* var) { 1168 bool Scope::MustAllocate(Variable* var) {
1150 // Give var a read/write use if there is a chance it might be accessed 1169 // Give var a read/write use if there is a chance it might be accessed
1151 // via an eval() call. This is only possible if the variable has a 1170 // via an eval() call. This is only possible if the variable has a
1152 // visible name. 1171 // visible name.
1153 if ((var->is_this() || var->name()->length() > 0) && 1172 if ((var->is_this() || var->name()->length() > 0) &&
1154 (var->has_forced_context_allocation() || 1173 (var->has_forced_context_allocation() ||
1155 scope_calls_eval_ || 1174 scope_calls_eval_ ||
1156 inner_scope_calls_eval_ || 1175 inner_scope_calls_eval_ ||
1157 scope_contains_with_ || 1176 scope_contains_with_ ||
1158 is_catch_scope() || 1177 is_catch_scope() ||
1159 is_block_scope() || 1178 is_block_scope() ||
1160 is_module_scope() || 1179 is_module_scope() ||
1161 is_global_scope())) { 1180 is_global_scope())) {
1162 var->set_is_used(true); 1181 var->set_is_used();
1182 if (scope_calls_eval_ || inner_scope_calls_eval_) var->set_maybe_assigned();
1163 } 1183 }
1164 // Global variables do not need to be allocated. 1184 // Global variables do not need to be allocated.
1165 return !var->IsGlobalObjectProperty() && var->is_used(); 1185 return !var->IsGlobalObjectProperty() && var->is_used();
1166 } 1186 }
1167 1187
1168 1188
1169 bool Scope::MustAllocateInContext(Variable* var) { 1189 bool Scope::MustAllocateInContext(Variable* var) {
1170 // If var is accessed from an inner scope, or if there is a possibility 1190 // If var is accessed from an inner scope, or if there is a possibility
1171 // that it might be accessed from the current or an inner scope (through 1191 // that it might be accessed from the current or an inner scope (through
1172 // an eval() call or a runtime with lookup), it must be allocated in the 1192 // an eval() call or a runtime with lookup), it must be allocated in the
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
1372 } 1392 }
1373 1393
1374 1394
1375 int Scope::ContextLocalCount() const { 1395 int Scope::ContextLocalCount() const {
1376 if (num_heap_slots() == 0) return 0; 1396 if (num_heap_slots() == 0) return 0;
1377 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - 1397 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS -
1378 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0); 1398 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0);
1379 } 1399 }
1380 1400
1381 } } // namespace v8::internal 1401 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/scopes.h ('k') | src/variables.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698