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

Side by Side Diff: src/scopes.cc

Issue 894683003: Introduce LanguageMode, drop StrictMode. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: . Created 5 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
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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 scope_inside_with_ = false; 158 scope_inside_with_ = false;
159 scope_contains_with_ = false; 159 scope_contains_with_ = false;
160 scope_calls_eval_ = false; 160 scope_calls_eval_ = false;
161 scope_uses_arguments_ = false; 161 scope_uses_arguments_ = false;
162 scope_uses_super_property_ = false; 162 scope_uses_super_property_ = false;
163 scope_uses_super_constructor_call_ = false; 163 scope_uses_super_constructor_call_ = false;
164 scope_uses_this_ = false; 164 scope_uses_this_ = false;
165 asm_module_ = false; 165 asm_module_ = false;
166 asm_function_ = outer_scope != NULL && outer_scope->asm_module_; 166 asm_function_ = outer_scope != NULL && outer_scope->asm_module_;
167 // Inherit the strict mode from the parent scope. 167 // Inherit the strict mode from the parent scope.
168 strict_mode_ = outer_scope != NULL ? outer_scope->strict_mode_ : SLOPPY; 168 language_mode_ = outer_scope != NULL ? outer_scope->language_mode_ : SLOPPY;
169 outer_scope_calls_sloppy_eval_ = false; 169 outer_scope_calls_sloppy_eval_ = false;
170 inner_scope_calls_eval_ = false; 170 inner_scope_calls_eval_ = false;
171 inner_scope_uses_arguments_ = false; 171 inner_scope_uses_arguments_ = false;
172 inner_scope_uses_this_ = false; 172 inner_scope_uses_this_ = false;
173 inner_scope_uses_super_property_ = false; 173 inner_scope_uses_super_property_ = false;
174 inner_scope_uses_super_constructor_call_ = false; 174 inner_scope_uses_super_constructor_call_ = false;
175 force_eager_compilation_ = false; 175 force_eager_compilation_ = false;
176 force_context_allocation_ = (outer_scope != NULL && !is_function_scope()) 176 force_context_allocation_ = (outer_scope != NULL && !is_function_scope())
177 ? outer_scope->has_forced_context_allocation() : false; 177 ? outer_scope->has_forced_context_allocation() : false;
178 num_var_or_const_ = 0; 178 num_var_or_const_ = 0;
179 num_stack_slots_ = 0; 179 num_stack_slots_ = 0;
180 num_heap_slots_ = 0; 180 num_heap_slots_ = 0;
181 num_modules_ = 0; 181 num_modules_ = 0;
182 module_var_ = NULL, 182 module_var_ = NULL,
183 rest_parameter_ = NULL; 183 rest_parameter_ = NULL;
184 rest_index_ = -1; 184 rest_index_ = -1;
185 scope_info_ = scope_info; 185 scope_info_ = scope_info;
186 start_position_ = RelocInfo::kNoPosition; 186 start_position_ = RelocInfo::kNoPosition;
187 end_position_ = RelocInfo::kNoPosition; 187 end_position_ = RelocInfo::kNoPosition;
188 if (!scope_info.is_null()) { 188 if (!scope_info.is_null()) {
189 scope_calls_eval_ = scope_info->CallsEval(); 189 scope_calls_eval_ = scope_info->CallsEval();
190 strict_mode_ = scope_info->strict_mode(); 190 language_mode_ = scope_info->language_mode();
191 } 191 }
192 } 192 }
193 193
194 194
195 Scope* Scope::DeserializeScopeChain(Isolate* isolate, Zone* zone, 195 Scope* Scope::DeserializeScopeChain(Isolate* isolate, Zone* zone,
196 Context* context, Scope* script_scope) { 196 Context* context, Scope* script_scope) {
197 // Reconstruct the outer scope chain from a closure's context chain. 197 // Reconstruct the outer scope chain from a closure's context chain.
198 Scope* current_scope = NULL; 198 Scope* current_scope = NULL;
199 Scope* innermost_scope = NULL; 199 Scope* innermost_scope = NULL;
200 bool contains_with = false; 200 bool contains_with = false;
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after
882 if (function_ != NULL) { 882 if (function_ != NULL) {
883 Indent(n1, "// (local) function name: "); 883 Indent(n1, "// (local) function name: ");
884 PrintName(function_->proxy()->raw_name()); 884 PrintName(function_->proxy()->raw_name());
885 PrintF("\n"); 885 PrintF("\n");
886 } 886 }
887 887
888 // Scope info. 888 // Scope info.
889 if (HasTrivialOuterContext()) { 889 if (HasTrivialOuterContext()) {
890 Indent(n1, "// scope has trivial outer context\n"); 890 Indent(n1, "// scope has trivial outer context\n");
891 } 891 }
892 if (strict_mode() == STRICT) { 892 if (is_strict(language_mode())) {
893 Indent(n1, "// strict mode scope\n"); 893 Indent(n1, "// strict mode scope\n");
894 } 894 }
895 if (scope_inside_with_) Indent(n1, "// scope inside 'with'\n"); 895 if (scope_inside_with_) Indent(n1, "// scope inside 'with'\n");
896 if (scope_contains_with_) Indent(n1, "// scope contains 'with'\n"); 896 if (scope_contains_with_) Indent(n1, "// scope contains 'with'\n");
897 if (scope_calls_eval_) Indent(n1, "// scope calls 'eval'\n"); 897 if (scope_calls_eval_) Indent(n1, "// scope calls 'eval'\n");
898 if (scope_uses_arguments_) Indent(n1, "// scope uses 'arguments'\n"); 898 if (scope_uses_arguments_) Indent(n1, "// scope uses 'arguments'\n");
899 if (scope_uses_super_property_) 899 if (scope_uses_super_property_)
900 Indent(n1, "// scope uses 'super' property\n"); 900 Indent(n1, "// scope uses 'super' property\n");
901 if (scope_uses_super_constructor_call_) 901 if (scope_uses_super_constructor_call_)
902 Indent(n1, "// scope uses 'super' constructor\n"); 902 Indent(n1, "// scope uses 'super' constructor\n");
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
1284 // parameters, which is why we don't need to allocate an arguments 1284 // parameters, which is why we don't need to allocate an arguments
1285 // object in that case. 1285 // object in that case.
1286 1286
1287 // We are using 'arguments'. Tell the code generator that is needs to 1287 // We are using 'arguments'. Tell the code generator that is needs to
1288 // allocate the arguments object by setting 'arguments_'. 1288 // allocate the arguments object by setting 'arguments_'.
1289 arguments_ = arguments; 1289 arguments_ = arguments;
1290 1290
1291 // In strict mode 'arguments' does not alias formal parameters. 1291 // In strict mode 'arguments' does not alias formal parameters.
1292 // Therefore in strict mode we allocate parameters as if 'arguments' 1292 // Therefore in strict mode we allocate parameters as if 'arguments'
1293 // were not used. 1293 // were not used.
1294 uses_sloppy_arguments = strict_mode() == SLOPPY; 1294 uses_sloppy_arguments = !is_strict(language_mode());
1295 } 1295 }
1296 1296
1297 if (rest_parameter_ && !MustAllocate(rest_parameter_)) { 1297 if (rest_parameter_ && !MustAllocate(rest_parameter_)) {
1298 rest_parameter_ = NULL; 1298 rest_parameter_ = NULL;
1299 } 1299 }
1300 1300
1301 // The same parameter may occur multiple times in the parameters_ list. 1301 // The same parameter may occur multiple times in the parameters_ list.
1302 // If it does, and if it is not copied into the context object, it must 1302 // If it does, and if it is not copied into the context object, it must
1303 // receive the highest parameter index for that parameter; thus iteration 1303 // receive the highest parameter index for that parameter; thus iteration
1304 // order is relevant! 1304 // order is relevant!
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
1439 } 1439 }
1440 1440
1441 1441
1442 int Scope::ContextLocalCount() const { 1442 int Scope::ContextLocalCount() const {
1443 if (num_heap_slots() == 0) return 0; 1443 if (num_heap_slots() == 0) return 0;
1444 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - 1444 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS -
1445 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0); 1445 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0);
1446 } 1446 }
1447 1447
1448 } } // namespace v8::internal 1448 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698