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

Side by Side Diff: src/scopes.cc

Issue 1124233002: Remove Scope::scope_uses_arguments_ flag (Closed) Base URL: https://chromium.googlesource.com/v8/v8@master
Patch Set: Created 5 years, 7 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 | « src/scopes.h ('k') | test/cctest/test-parsing.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 // 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/accessors.h" 7 #include "src/accessors.h"
8 #include "src/bootstrapper.h" 8 #include "src/bootstrapper.h"
9 #include "src/messages.h" 9 #include "src/messages.h"
10 #include "src/parser.h" 10 #include "src/parser.h"
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 scope_name_ = ast_value_factory_->empty_string(); 156 scope_name_ = ast_value_factory_->empty_string();
157 dynamics_ = NULL; 157 dynamics_ = NULL;
158 receiver_ = NULL; 158 receiver_ = NULL;
159 new_target_ = nullptr; 159 new_target_ = nullptr;
160 function_ = NULL; 160 function_ = NULL;
161 arguments_ = NULL; 161 arguments_ = NULL;
162 illegal_redecl_ = NULL; 162 illegal_redecl_ = NULL;
163 scope_inside_with_ = false; 163 scope_inside_with_ = false;
164 scope_contains_with_ = false; 164 scope_contains_with_ = false;
165 scope_calls_eval_ = false; 165 scope_calls_eval_ = false;
166 scope_uses_arguments_ = false;
167 scope_uses_super_property_ = false; 166 scope_uses_super_property_ = false;
168 asm_module_ = false; 167 asm_module_ = false;
169 asm_function_ = outer_scope != NULL && outer_scope->asm_module_; 168 asm_function_ = outer_scope != NULL && outer_scope->asm_module_;
170 // Inherit the language mode from the parent scope. 169 // Inherit the language mode from the parent scope.
171 language_mode_ = outer_scope != NULL ? outer_scope->language_mode_ : SLOPPY; 170 language_mode_ = outer_scope != NULL ? outer_scope->language_mode_ : SLOPPY;
172 outer_scope_calls_sloppy_eval_ = false; 171 outer_scope_calls_sloppy_eval_ = false;
173 inner_scope_calls_eval_ = false; 172 inner_scope_calls_eval_ = false;
174 inner_scope_uses_arguments_ = false;
175 inner_scope_uses_super_property_ = false; 173 inner_scope_uses_super_property_ = false;
176 force_eager_compilation_ = false; 174 force_eager_compilation_ = false;
177 force_context_allocation_ = (outer_scope != NULL && !is_function_scope()) 175 force_context_allocation_ = (outer_scope != NULL && !is_function_scope())
178 ? outer_scope->has_forced_context_allocation() : false; 176 ? outer_scope->has_forced_context_allocation() : false;
179 num_var_or_const_ = 0; 177 num_var_or_const_ = 0;
180 num_stack_slots_ = 0; 178 num_stack_slots_ = 0;
181 num_heap_slots_ = 0; 179 num_heap_slots_ = 0;
182 num_modules_ = 0; 180 num_modules_ = 0;
183 module_var_ = NULL, 181 module_var_ = NULL,
184 rest_parameter_ = NULL; 182 rest_parameter_ = NULL;
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 for (int i = 0; i < inner_scopes_.length(); i++) { 358 for (int i = 0; i < inner_scopes_.length(); i++) {
361 outer_scope()->AddInnerScope(inner_scopes_[i]); 359 outer_scope()->AddInnerScope(inner_scopes_[i]);
362 } 360 }
363 361
364 // Move unresolved variables 362 // Move unresolved variables
365 for (int i = 0; i < unresolved_.length(); i++) { 363 for (int i = 0; i < unresolved_.length(); i++) {
366 outer_scope()->unresolved_.Add(unresolved_[i], zone()); 364 outer_scope()->unresolved_.Add(unresolved_[i], zone());
367 } 365 }
368 366
369 // Propagate usage flags to outer scope. 367 // Propagate usage flags to outer scope.
370 if (uses_arguments()) outer_scope_->RecordArgumentsUsage();
371 if (uses_super_property()) outer_scope_->RecordSuperPropertyUsage(); 368 if (uses_super_property()) outer_scope_->RecordSuperPropertyUsage();
372 if (scope_calls_eval_) outer_scope_->RecordEvalCall(); 369 if (scope_calls_eval_) outer_scope_->RecordEvalCall();
373 370
374 return NULL; 371 return NULL;
375 } 372 }
376 373
377 374
378 Variable* Scope::LookupLocal(const AstRawString* name) { 375 Variable* Scope::LookupLocal(const AstRawString* name) {
379 Variable* result = variables_.Lookup(name); 376 Variable* result = variables_.Lookup(name);
380 if (result != NULL || scope_info_.is_null()) { 377 if (result != NULL || scope_info_.is_null()) {
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after
908 Indent(n1, "// scope has trivial outer context\n"); 905 Indent(n1, "// scope has trivial outer context\n");
909 } 906 }
910 if (is_strong(language_mode())) { 907 if (is_strong(language_mode())) {
911 Indent(n1, "// strong mode scope\n"); 908 Indent(n1, "// strong mode scope\n");
912 } else if (is_strict(language_mode())) { 909 } else if (is_strict(language_mode())) {
913 Indent(n1, "// strict mode scope\n"); 910 Indent(n1, "// strict mode scope\n");
914 } 911 }
915 if (scope_inside_with_) Indent(n1, "// scope inside 'with'\n"); 912 if (scope_inside_with_) Indent(n1, "// scope inside 'with'\n");
916 if (scope_contains_with_) Indent(n1, "// scope contains 'with'\n"); 913 if (scope_contains_with_) Indent(n1, "// scope contains 'with'\n");
917 if (scope_calls_eval_) Indent(n1, "// scope calls 'eval'\n"); 914 if (scope_calls_eval_) Indent(n1, "// scope calls 'eval'\n");
918 if (scope_uses_arguments_) Indent(n1, "// scope uses 'arguments'\n");
919 if (scope_uses_super_property_) 915 if (scope_uses_super_property_)
920 Indent(n1, "// scope uses 'super' property\n"); 916 Indent(n1, "// scope uses 'super' property\n");
921 if (inner_scope_uses_arguments_) {
922 Indent(n1, "// inner scope uses 'arguments'\n");
923 }
924 if (inner_scope_uses_super_property_) 917 if (inner_scope_uses_super_property_)
925 Indent(n1, "// inner scope uses 'super' property\n"); 918 Indent(n1, "// inner scope uses 'super' property\n");
926 if (outer_scope_calls_sloppy_eval_) { 919 if (outer_scope_calls_sloppy_eval_) {
927 Indent(n1, "// outer scope calls 'eval' in sloppy context\n"); 920 Indent(n1, "// outer scope calls 'eval' in sloppy context\n");
928 } 921 }
929 if (inner_scope_calls_eval_) Indent(n1, "// inner scope calls 'eval'\n"); 922 if (inner_scope_calls_eval_) Indent(n1, "// inner scope calls 'eval'\n");
930 if (num_stack_slots_ > 0) { Indent(n1, "// "); 923 if (num_stack_slots_ > 0) { Indent(n1, "// ");
931 PrintF("%d stack slots\n", num_stack_slots_); } 924 PrintF("%d stack slots\n", num_stack_slots_); }
932 if (num_heap_slots_ > 0) { Indent(n1, "// "); 925 if (num_heap_slots_ > 0) { Indent(n1, "// ");
933 PrintF("%d heap slots\n", num_heap_slots_); } 926 PrintF("%d heap slots\n", num_heap_slots_); }
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
1264 for (int i = 0; i < inner_scopes_.length(); i++) { 1257 for (int i = 0; i < inner_scopes_.length(); i++) {
1265 Scope* inner = inner_scopes_[i]; 1258 Scope* inner = inner_scopes_[i];
1266 inner->PropagateScopeInfo(calls_sloppy_eval); 1259 inner->PropagateScopeInfo(calls_sloppy_eval);
1267 if (inner->scope_calls_eval_ || inner->inner_scope_calls_eval_) { 1260 if (inner->scope_calls_eval_ || inner->inner_scope_calls_eval_) {
1268 inner_scope_calls_eval_ = true; 1261 inner_scope_calls_eval_ = true;
1269 } 1262 }
1270 // If the inner scope is an arrow function, propagate the flags tracking 1263 // If the inner scope is an arrow function, propagate the flags tracking
1271 // usage of arguments/super/this, but do not propagate them out from normal 1264 // usage of arguments/super/this, but do not propagate them out from normal
1272 // functions. 1265 // functions.
1273 if (!inner->is_function_scope() || inner->is_arrow_scope()) { 1266 if (!inner->is_function_scope() || inner->is_arrow_scope()) {
1274 if (inner->scope_uses_arguments_ || inner->inner_scope_uses_arguments_) {
1275 inner_scope_uses_arguments_ = true;
1276 }
1277 if (inner->scope_uses_super_property_ || 1267 if (inner->scope_uses_super_property_ ||
1278 inner->inner_scope_uses_super_property_) { 1268 inner->inner_scope_uses_super_property_) {
1279 inner_scope_uses_super_property_ = true; 1269 inner_scope_uses_super_property_ = true;
1280 } 1270 }
1281 } 1271 }
1282 if (inner->force_eager_compilation_) { 1272 if (inner->force_eager_compilation_) {
1283 force_eager_compilation_ = true; 1273 force_eager_compilation_ = true;
1284 } 1274 }
1285 if (asm_module_ && inner->scope_type() == FUNCTION_SCOPE) { 1275 if (asm_module_ && inner->scope_type() == FUNCTION_SCOPE) {
1286 inner->asm_function_ = true; 1276 inner->asm_function_ = true;
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
1543 (function_ != NULL && function_->proxy()->var()->IsStackLocal() ? 1 : 0); 1533 (function_ != NULL && function_->proxy()->var()->IsStackLocal() ? 1 : 0);
1544 } 1534 }
1545 1535
1546 1536
1547 int Scope::ContextLocalCount() const { 1537 int Scope::ContextLocalCount() const {
1548 if (num_heap_slots() == 0) return 0; 1538 if (num_heap_slots() == 0) return 0;
1549 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - 1539 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS -
1550 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0); 1540 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0);
1551 } 1541 }
1552 } } // namespace v8::internal 1542 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/scopes.h ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698