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

Side by Side Diff: src/scopes.cc

Issue 422923004: Track usage of "this" and "arguments" in Scope (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebase and fix parser instantiation after r23600 Created 6 years, 3 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 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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 scope_type_ = scope_type; 153 scope_type_ = scope_type;
154 scope_name_ = ast_value_factory_->empty_string(); 154 scope_name_ = ast_value_factory_->empty_string();
155 dynamics_ = NULL; 155 dynamics_ = NULL;
156 receiver_ = NULL; 156 receiver_ = NULL;
157 function_ = NULL; 157 function_ = NULL;
158 arguments_ = NULL; 158 arguments_ = NULL;
159 illegal_redecl_ = NULL; 159 illegal_redecl_ = NULL;
160 scope_inside_with_ = false; 160 scope_inside_with_ = false;
161 scope_contains_with_ = false; 161 scope_contains_with_ = false;
162 scope_calls_eval_ = false; 162 scope_calls_eval_ = false;
163 scope_uses_this_ = false;
164 scope_uses_arguments_ = false;
163 // Inherit the strict mode from the parent scope. 165 // Inherit the strict mode from the parent scope.
164 strict_mode_ = outer_scope != NULL ? outer_scope->strict_mode_ : SLOPPY; 166 strict_mode_ = outer_scope != NULL ? outer_scope->strict_mode_ : SLOPPY;
165 outer_scope_calls_sloppy_eval_ = false; 167 outer_scope_calls_sloppy_eval_ = false;
166 inner_scope_calls_eval_ = false; 168 inner_scope_calls_eval_ = false;
169 inner_scope_uses_this_ = false;
170 inner_scope_uses_arguments_ = false;
167 force_eager_compilation_ = false; 171 force_eager_compilation_ = false;
168 force_context_allocation_ = (outer_scope != NULL && !is_function_scope()) 172 force_context_allocation_ = (outer_scope != NULL && !is_function_scope())
169 ? outer_scope->has_forced_context_allocation() : false; 173 ? outer_scope->has_forced_context_allocation() : false;
170 num_var_or_const_ = 0; 174 num_var_or_const_ = 0;
171 num_stack_slots_ = 0; 175 num_stack_slots_ = 0;
172 num_heap_slots_ = 0; 176 num_heap_slots_ = 0;
173 num_modules_ = 0; 177 num_modules_ = 0;
174 module_var_ = NULL, 178 module_var_ = NULL,
175 scope_info_ = scope_info; 179 scope_info_ = scope_info;
176 start_position_ = RelocInfo::kNoPosition; 180 start_position_ = RelocInfo::kNoPosition;
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after
874 // Scope info. 878 // Scope info.
875 if (HasTrivialOuterContext()) { 879 if (HasTrivialOuterContext()) {
876 Indent(n1, "// scope has trivial outer context\n"); 880 Indent(n1, "// scope has trivial outer context\n");
877 } 881 }
878 if (strict_mode() == STRICT) { 882 if (strict_mode() == STRICT) {
879 Indent(n1, "// strict mode scope\n"); 883 Indent(n1, "// strict mode scope\n");
880 } 884 }
881 if (scope_inside_with_) Indent(n1, "// scope inside 'with'\n"); 885 if (scope_inside_with_) Indent(n1, "// scope inside 'with'\n");
882 if (scope_contains_with_) Indent(n1, "// scope contains 'with'\n"); 886 if (scope_contains_with_) Indent(n1, "// scope contains 'with'\n");
883 if (scope_calls_eval_) Indent(n1, "// scope calls 'eval'\n"); 887 if (scope_calls_eval_) Indent(n1, "// scope calls 'eval'\n");
888 if (scope_uses_this_) Indent(n1, "// scope uses 'this'\n");
889 if (scope_uses_arguments_) Indent(n1, "// scope uses 'arguments'\n");
890 if (inner_scope_uses_this_) Indent(n1, "// inner scope uses 'this'\n");
891 if (inner_scope_uses_arguments_) {
892 Indent(n1, "// inner scope uses 'arguments'\n");
893 }
884 if (outer_scope_calls_sloppy_eval_) { 894 if (outer_scope_calls_sloppy_eval_) {
885 Indent(n1, "// outer scope calls 'eval' in sloppy context\n"); 895 Indent(n1, "// outer scope calls 'eval' in sloppy context\n");
886 } 896 }
887 if (inner_scope_calls_eval_) Indent(n1, "// inner scope calls 'eval'\n"); 897 if (inner_scope_calls_eval_) Indent(n1, "// inner scope calls 'eval'\n");
888 if (num_stack_slots_ > 0) { Indent(n1, "// "); 898 if (num_stack_slots_ > 0) { Indent(n1, "// ");
889 PrintF("%d stack slots\n", num_stack_slots_); } 899 PrintF("%d stack slots\n", num_stack_slots_); }
890 if (num_heap_slots_ > 0) { Indent(n1, "// "); 900 if (num_heap_slots_ > 0) { Indent(n1, "// ");
891 PrintF("%d heap slots\n", num_heap_slots_); } 901 PrintF("%d heap slots\n", num_heap_slots_); }
892 902
893 // Print locals. 903 // Print locals.
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
1155 } 1165 }
1156 1166
1157 bool calls_sloppy_eval = 1167 bool calls_sloppy_eval =
1158 this->calls_sloppy_eval() || outer_scope_calls_sloppy_eval_; 1168 this->calls_sloppy_eval() || outer_scope_calls_sloppy_eval_;
1159 for (int i = 0; i < inner_scopes_.length(); i++) { 1169 for (int i = 0; i < inner_scopes_.length(); i++) {
1160 Scope* inner = inner_scopes_[i]; 1170 Scope* inner = inner_scopes_[i];
1161 inner->PropagateScopeInfo(calls_sloppy_eval); 1171 inner->PropagateScopeInfo(calls_sloppy_eval);
1162 if (inner->scope_calls_eval_ || inner->inner_scope_calls_eval_) { 1172 if (inner->scope_calls_eval_ || inner->inner_scope_calls_eval_) {
1163 inner_scope_calls_eval_ = true; 1173 inner_scope_calls_eval_ = true;
1164 } 1174 }
1175 if (inner->scope_uses_this_ || inner->inner_scope_uses_this_) {
rossberg 2014/09/10 06:33:56 If inner is a function scope and not an arrow func
1176 inner_scope_uses_this_ = true;
1177 }
1178 if (inner->scope_uses_arguments_ || inner->inner_scope_uses_arguments_) {
1179 inner_scope_uses_arguments_ = true;
1180 }
1165 if (inner->force_eager_compilation_) { 1181 if (inner->force_eager_compilation_) {
1166 force_eager_compilation_ = true; 1182 force_eager_compilation_ = true;
1167 } 1183 }
1168 } 1184 }
1169 } 1185 }
1170 1186
1171 1187
1172 bool Scope::MustAllocate(Variable* var) { 1188 bool Scope::MustAllocate(Variable* var) {
1173 // Give var a read/write use if there is a chance it might be accessed 1189 // Give var a read/write use if there is a chance it might be accessed
1174 // via an eval() call. This is only possible if the variable has a 1190 // via an eval() call. This is only possible if the variable has a
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
1395 } 1411 }
1396 1412
1397 1413
1398 int Scope::ContextLocalCount() const { 1414 int Scope::ContextLocalCount() const {
1399 if (num_heap_slots() == 0) return 0; 1415 if (num_heap_slots() == 0) return 0;
1400 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - 1416 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS -
1401 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0); 1417 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0);
1402 } 1418 }
1403 1419
1404 } } // namespace v8::internal 1420 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698