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

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: rebased (w/ conflicts) 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
« no previous file with comments | « src/scopes.h ('k') | src/token.h » ('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/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 680 matching lines...) Expand 10 before | Expand all | Expand 10 after
881 if (function_ != NULL) { 881 if (function_ != NULL) {
882 Indent(n1, "// (local) function name: "); 882 Indent(n1, "// (local) function name: ");
883 PrintName(function_->proxy()->raw_name()); 883 PrintName(function_->proxy()->raw_name());
884 PrintF("\n"); 884 PrintF("\n");
885 } 885 }
886 886
887 // Scope info. 887 // Scope info.
888 if (HasTrivialOuterContext()) { 888 if (HasTrivialOuterContext()) {
889 Indent(n1, "// scope has trivial outer context\n"); 889 Indent(n1, "// scope has trivial outer context\n");
890 } 890 }
891 if (strict_mode() == STRICT) { 891 if (is_strict(language_mode())) {
892 Indent(n1, "// strict mode scope\n"); 892 Indent(n1, "// strict mode scope\n");
893 } 893 }
894 if (scope_inside_with_) Indent(n1, "// scope inside 'with'\n"); 894 if (scope_inside_with_) Indent(n1, "// scope inside 'with'\n");
895 if (scope_contains_with_) Indent(n1, "// scope contains 'with'\n"); 895 if (scope_contains_with_) Indent(n1, "// scope contains 'with'\n");
896 if (scope_calls_eval_) Indent(n1, "// scope calls 'eval'\n"); 896 if (scope_calls_eval_) Indent(n1, "// scope calls 'eval'\n");
897 if (scope_uses_arguments_) Indent(n1, "// scope uses 'arguments'\n"); 897 if (scope_uses_arguments_) Indent(n1, "// scope uses 'arguments'\n");
898 if (scope_uses_super_property_) 898 if (scope_uses_super_property_)
899 Indent(n1, "// scope uses 'super' property\n"); 899 Indent(n1, "// scope uses 'super' property\n");
900 if (scope_uses_super_constructor_call_) 900 if (scope_uses_super_constructor_call_)
901 Indent(n1, "// scope uses 'super' constructor\n"); 901 Indent(n1, "// scope uses 'super' constructor\n");
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
1283 // parameters, which is why we don't need to allocate an arguments 1283 // parameters, which is why we don't need to allocate an arguments
1284 // object in that case. 1284 // object in that case.
1285 1285
1286 // We are using 'arguments'. Tell the code generator that is needs to 1286 // We are using 'arguments'. Tell the code generator that is needs to
1287 // allocate the arguments object by setting 'arguments_'. 1287 // allocate the arguments object by setting 'arguments_'.
1288 arguments_ = arguments; 1288 arguments_ = arguments;
1289 1289
1290 // In strict mode 'arguments' does not alias formal parameters. 1290 // In strict mode 'arguments' does not alias formal parameters.
1291 // Therefore in strict mode we allocate parameters as if 'arguments' 1291 // Therefore in strict mode we allocate parameters as if 'arguments'
1292 // were not used. 1292 // were not used.
1293 uses_sloppy_arguments = strict_mode() == SLOPPY; 1293 uses_sloppy_arguments = is_sloppy(language_mode());
1294 } 1294 }
1295 1295
1296 if (rest_parameter_ && !MustAllocate(rest_parameter_)) { 1296 if (rest_parameter_ && !MustAllocate(rest_parameter_)) {
1297 rest_parameter_ = NULL; 1297 rest_parameter_ = NULL;
1298 } 1298 }
1299 1299
1300 // The same parameter may occur multiple times in the parameters_ list. 1300 // The same parameter may occur multiple times in the parameters_ list.
1301 // If it does, and if it is not copied into the context object, it must 1301 // If it does, and if it is not copied into the context object, it must
1302 // receive the highest parameter index for that parameter; thus iteration 1302 // receive the highest parameter index for that parameter; thus iteration
1303 // order is relevant! 1303 // order is relevant!
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
1438 } 1438 }
1439 1439
1440 1440
1441 int Scope::ContextLocalCount() const { 1441 int Scope::ContextLocalCount() const {
1442 if (num_heap_slots() == 0) return 0; 1442 if (num_heap_slots() == 0) return 0;
1443 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - 1443 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS -
1444 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0); 1444 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0);
1445 } 1445 }
1446 1446
1447 } } // namespace v8::internal 1447 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/scopes.h ('k') | src/token.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698