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

Side by Side Diff: src/scopeinfo.cc

Issue 1093183003: Function scopes only must have a context if they call sloppy eval (Closed) Base URL: https://chromium.googlesource.com/v8/v8@master
Patch Set: Fix ScopeInfo context slot calculation 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 unified diff | Download patch
« no previous file with comments | « no previous file | src/scopes.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 <stdlib.h> 5 #include <stdlib.h>
6 6
7 #include "src/v8.h" 7 #include "src/v8.h"
8 8
9 #include "src/scopeinfo.h" 9 #include "src/scopeinfo.h"
10 #include "src/scopes.h" 10 #include "src/scopes.h"
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 } 201 }
202 202
203 203
204 int ScopeInfo::ContextLength() { 204 int ScopeInfo::ContextLength() {
205 if (length() > 0) { 205 if (length() > 0) {
206 int context_locals = ContextLocalCount(); 206 int context_locals = ContextLocalCount();
207 bool function_name_context_slot = 207 bool function_name_context_slot =
208 FunctionVariableField::decode(Flags()) == CONTEXT; 208 FunctionVariableField::decode(Flags()) == CONTEXT;
209 bool has_context = context_locals > 0 || function_name_context_slot || 209 bool has_context = context_locals > 0 || function_name_context_slot ||
210 scope_type() == WITH_SCOPE || 210 scope_type() == WITH_SCOPE ||
211 (scope_type() == ARROW_SCOPE && CallsEval()) || 211 (scope_type() == ARROW_SCOPE && CallsSloppyEval()) ||
212 (scope_type() == FUNCTION_SCOPE && CallsEval()) || 212 (scope_type() == FUNCTION_SCOPE && CallsSloppyEval()) ||
213 scope_type() == MODULE_SCOPE; 213 scope_type() == MODULE_SCOPE;
214 if (has_context) { 214 if (has_context) {
215 return Context::MIN_CONTEXT_SLOTS + context_locals + 215 return Context::MIN_CONTEXT_SLOTS + context_locals +
216 (function_name_context_slot ? 1 : 0); 216 (function_name_context_slot ? 1 : 0);
217 } 217 }
218 } 218 }
219 return 0; 219 return 0;
220 } 220 }
221 221
222 222
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 info->set_name(i, *(it.export_name()->string())); 659 info->set_name(i, *(it.export_name()->string()));
660 info->set_mode(i, var->mode()); 660 info->set_mode(i, var->mode());
661 DCHECK(var->index() >= 0); 661 DCHECK(var->index() >= 0);
662 info->set_index(i, var->index()); 662 info->set_index(i, var->index());
663 } 663 }
664 DCHECK(i == info->length()); 664 DCHECK(i == info->length());
665 return info; 665 return info;
666 } 666 }
667 667
668 } } // namespace v8::internal 668 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/scopes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698