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

Side by Side Diff: src/scopes.cc

Issue 9310027: Do not ignore an empty context with extension when creating a scope object. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 10 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
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 // At some point we might want to provide outer scopes to 130 // At some point we might want to provide outer scopes to
131 // eval scopes (by walking the stack and reading the scope info). 131 // eval scopes (by walking the stack and reading the scope info).
132 // In that case, the ASSERT below needs to be adjusted. 132 // In that case, the ASSERT below needs to be adjusted.
133 ASSERT_EQ(type == GLOBAL_SCOPE, outer_scope == NULL); 133 ASSERT_EQ(type == GLOBAL_SCOPE, outer_scope == NULL);
134 ASSERT(!HasIllegalRedeclaration()); 134 ASSERT(!HasIllegalRedeclaration());
135 } 135 }
136 136
137 137
138 Scope::Scope(Scope* inner_scope, 138 Scope::Scope(Scope* inner_scope,
139 ScopeType type, 139 ScopeType type,
140 Handle<ScopeInfo> scope_info) 140 Handle<ScopeInfo> scope_info,
141 bool has_context_with_extension)
141 : isolate_(Isolate::Current()), 142 : isolate_(Isolate::Current()),
142 inner_scopes_(4), 143 inner_scopes_(4),
143 variables_(), 144 variables_(),
144 temps_(4), 145 temps_(4),
145 params_(4), 146 params_(4),
146 unresolved_(16), 147 unresolved_(16),
147 decls_(4), 148 decls_(4),
148 already_resolved_(true) { 149 already_resolved_(true) {
149 SetDefaults(type, NULL, scope_info); 150 SetDefaults(type, NULL, scope_info);
150 if (!scope_info.is_null()) { 151 if (!scope_info.is_null() && *scope_info != ScopeInfo::Empty()) {
Kevin Millikin (Chromium) 2012/02/02 08:36:13 As far as I can tell, there is no reason *at all*
ulan 2012/02/02 09:16:19 Indeed, this constructor is called only from Deser
151 num_heap_slots_ = scope_info_->ContextLength(); 152 num_heap_slots_ = scope_info_->ContextLength();
152 if (*scope_info != ScopeInfo::Empty()) { 153 language_mode_ = scope_info->language_mode();
Kevin Millikin (Chromium) 2012/02/02 08:36:13 As a simple cleanup, you can get rid of this compl
153 language_mode_ = scope_info->language_mode(); 154 } else if (is_with_scope() || has_context_with_extension) {
154 }
155 } else if (is_with_scope()) {
156 num_heap_slots_ = Context::MIN_CONTEXT_SLOTS; 155 num_heap_slots_ = Context::MIN_CONTEXT_SLOTS;
157 } 156 }
158 AddInnerScope(inner_scope); 157 AddInnerScope(inner_scope);
159 } 158 }
160 159
161 160
162 Scope::Scope(Scope* inner_scope, Handle<String> catch_variable_name) 161 Scope::Scope(Scope* inner_scope, Handle<String> catch_variable_name)
163 : isolate_(Isolate::Current()), 162 : isolate_(Isolate::Current()),
164 inner_scopes_(1), 163 inner_scopes_(1),
165 variables_(), 164 variables_(),
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 current_scope = with_scope; 227 current_scope = with_scope;
229 // All the inner scopes are inside a with. 228 // All the inner scopes are inside a with.
230 contains_with = true; 229 contains_with = true;
231 for (Scope* s = innermost_scope; s != NULL; s = s->outer_scope()) { 230 for (Scope* s = innermost_scope; s != NULL; s = s->outer_scope()) {
232 s->scope_inside_with_ = true; 231 s->scope_inside_with_ = true;
233 } 232 }
234 } else if (context->IsFunctionContext()) { 233 } else if (context->IsFunctionContext()) {
235 ScopeInfo* scope_info = context->closure()->shared()->scope_info(); 234 ScopeInfo* scope_info = context->closure()->shared()->scope_info();
236 current_scope = new Scope(current_scope, 235 current_scope = new Scope(current_scope,
237 FUNCTION_SCOPE, 236 FUNCTION_SCOPE,
238 Handle<ScopeInfo>(scope_info)); 237 Handle<ScopeInfo>(scope_info),
238 context->extension() != NULL);
239 } else if (context->IsBlockContext()) { 239 } else if (context->IsBlockContext()) {
240 ScopeInfo* scope_info = ScopeInfo::cast(context->extension()); 240 ScopeInfo* scope_info = ScopeInfo::cast(context->extension());
241 current_scope = new Scope(current_scope, 241 current_scope = new Scope(current_scope,
242 BLOCK_SCOPE, 242 BLOCK_SCOPE,
243 Handle<ScopeInfo>(scope_info)); 243 Handle<ScopeInfo>(scope_info));
244 } else { 244 } else {
245 ASSERT(context->IsCatchContext()); 245 ASSERT(context->IsCatchContext());
246 String* name = String::cast(context->extension()); 246 String* name = String::cast(context->extension());
247 current_scope = new Scope(current_scope, Handle<String>(name)); 247 current_scope = new Scope(current_scope, Handle<String>(name));
248 } 248 }
(...skipping 981 matching lines...) Expand 10 before | Expand all | Expand 10 after
1230 } 1230 }
1231 1231
1232 1232
1233 int Scope::ContextLocalCount() const { 1233 int Scope::ContextLocalCount() const {
1234 if (num_heap_slots() == 0) return 0; 1234 if (num_heap_slots() == 0) return 0;
1235 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - 1235 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS -
1236 (function_ != NULL && function_->var()->IsContextSlot() ? 1 : 0); 1236 (function_ != NULL && function_->var()->IsContextSlot() ? 1 : 0);
1237 } 1237 }
1238 1238
1239 } } // namespace v8::internal 1239 } } // namespace v8::internal
OLDNEW
« src/scopes.h ('K') | « src/scopes.h ('k') | test/mjsunit/regress/regress-crbug-107996.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698