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

Side by Side Diff: src/scopes.cc

Issue 718473002: ES6: Add support for super in object literals (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix remaining code review issues Created 6 years, 1 month 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
« no previous file with comments | « src/scopes.h ('k') | src/x64/full-codegen-x64.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/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_arguments_ = false;
164 scope_uses_super_ = false;
163 scope_uses_this_ = false; 165 scope_uses_this_ = false;
164 scope_uses_arguments_ = false;
165 asm_module_ = false; 166 asm_module_ = false;
166 asm_function_ = outer_scope != NULL && outer_scope->asm_module_; 167 asm_function_ = outer_scope != NULL && outer_scope->asm_module_;
167 // Inherit the strict mode from the parent scope. 168 // Inherit the strict mode from the parent scope.
168 strict_mode_ = outer_scope != NULL ? outer_scope->strict_mode_ : SLOPPY; 169 strict_mode_ = outer_scope != NULL ? outer_scope->strict_mode_ : SLOPPY;
169 outer_scope_calls_sloppy_eval_ = false; 170 outer_scope_calls_sloppy_eval_ = false;
170 inner_scope_calls_eval_ = false; 171 inner_scope_calls_eval_ = false;
172 inner_scope_uses_arguments_ = false;
171 inner_scope_uses_this_ = false; 173 inner_scope_uses_this_ = false;
172 inner_scope_uses_arguments_ = false; 174 inner_scope_uses_super_ = false;
173 force_eager_compilation_ = false; 175 force_eager_compilation_ = false;
174 force_context_allocation_ = (outer_scope != NULL && !is_function_scope()) 176 force_context_allocation_ = (outer_scope != NULL && !is_function_scope())
175 ? outer_scope->has_forced_context_allocation() : false; 177 ? outer_scope->has_forced_context_allocation() : false;
176 num_var_or_const_ = 0; 178 num_var_or_const_ = 0;
177 num_stack_slots_ = 0; 179 num_stack_slots_ = 0;
178 num_heap_slots_ = 0; 180 num_heap_slots_ = 0;
179 num_modules_ = 0; 181 num_modules_ = 0;
180 module_var_ = NULL, 182 module_var_ = NULL,
181 scope_info_ = scope_info; 183 scope_info_ = scope_info;
182 start_position_ = RelocInfo::kNoPosition; 184 start_position_ = RelocInfo::kNoPosition;
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after
882 // Scope info. 884 // Scope info.
883 if (HasTrivialOuterContext()) { 885 if (HasTrivialOuterContext()) {
884 Indent(n1, "// scope has trivial outer context\n"); 886 Indent(n1, "// scope has trivial outer context\n");
885 } 887 }
886 if (strict_mode() == STRICT) { 888 if (strict_mode() == STRICT) {
887 Indent(n1, "// strict mode scope\n"); 889 Indent(n1, "// strict mode scope\n");
888 } 890 }
889 if (scope_inside_with_) Indent(n1, "// scope inside 'with'\n"); 891 if (scope_inside_with_) Indent(n1, "// scope inside 'with'\n");
890 if (scope_contains_with_) Indent(n1, "// scope contains 'with'\n"); 892 if (scope_contains_with_) Indent(n1, "// scope contains 'with'\n");
891 if (scope_calls_eval_) Indent(n1, "// scope calls 'eval'\n"); 893 if (scope_calls_eval_) Indent(n1, "// scope calls 'eval'\n");
894 if (scope_uses_arguments_) Indent(n1, "// scope uses 'arguments'\n");
895 if (scope_uses_super_) Indent(n1, "// scope uses 'super'\n");
892 if (scope_uses_this_) Indent(n1, "// scope uses 'this'\n"); 896 if (scope_uses_this_) Indent(n1, "// scope uses 'this'\n");
893 if (scope_uses_arguments_) Indent(n1, "// scope uses 'arguments'\n");
894 if (inner_scope_uses_this_) Indent(n1, "// inner scope uses 'this'\n");
895 if (inner_scope_uses_arguments_) { 897 if (inner_scope_uses_arguments_) {
896 Indent(n1, "// inner scope uses 'arguments'\n"); 898 Indent(n1, "// inner scope uses 'arguments'\n");
897 } 899 }
900 if (inner_scope_uses_super_) Indent(n1, "// inner scope uses 'super'\n");
901 if (inner_scope_uses_this_) Indent(n1, "// inner scope uses 'this'\n");
898 if (outer_scope_calls_sloppy_eval_) { 902 if (outer_scope_calls_sloppy_eval_) {
899 Indent(n1, "// outer scope calls 'eval' in sloppy context\n"); 903 Indent(n1, "// outer scope calls 'eval' in sloppy context\n");
900 } 904 }
901 if (inner_scope_calls_eval_) Indent(n1, "// inner scope calls 'eval'\n"); 905 if (inner_scope_calls_eval_) Indent(n1, "// inner scope calls 'eval'\n");
902 if (num_stack_slots_ > 0) { Indent(n1, "// "); 906 if (num_stack_slots_ > 0) { Indent(n1, "// ");
903 PrintF("%d stack slots\n", num_stack_slots_); } 907 PrintF("%d stack slots\n", num_stack_slots_); }
904 if (num_heap_slots_ > 0) { Indent(n1, "// "); 908 if (num_heap_slots_ > 0) { Indent(n1, "// ");
905 PrintF("%d heap slots\n", num_heap_slots_); } 909 PrintF("%d heap slots\n", num_heap_slots_); }
906 910
907 // Print locals. 911 // Print locals.
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
1170 1174
1171 bool calls_sloppy_eval = 1175 bool calls_sloppy_eval =
1172 this->calls_sloppy_eval() || outer_scope_calls_sloppy_eval_; 1176 this->calls_sloppy_eval() || outer_scope_calls_sloppy_eval_;
1173 for (int i = 0; i < inner_scopes_.length(); i++) { 1177 for (int i = 0; i < inner_scopes_.length(); i++) {
1174 Scope* inner = inner_scopes_[i]; 1178 Scope* inner = inner_scopes_[i];
1175 inner->PropagateScopeInfo(calls_sloppy_eval); 1179 inner->PropagateScopeInfo(calls_sloppy_eval);
1176 if (inner->scope_calls_eval_ || inner->inner_scope_calls_eval_) { 1180 if (inner->scope_calls_eval_ || inner->inner_scope_calls_eval_) {
1177 inner_scope_calls_eval_ = true; 1181 inner_scope_calls_eval_ = true;
1178 } 1182 }
1179 // If the inner scope is an arrow function, propagate the flags tracking 1183 // If the inner scope is an arrow function, propagate the flags tracking
1180 // usage of this/arguments, but do not propagate them out from normal 1184 // usage of arguments/super/this, but do not propagate them out from normal
1181 // functions. 1185 // functions.
1182 if (!inner->is_function_scope() || inner->is_arrow_scope()) { 1186 if (!inner->is_function_scope() || inner->is_arrow_scope()) {
1187 if (inner->scope_uses_arguments_ || inner->inner_scope_uses_arguments_) {
1188 inner_scope_uses_arguments_ = true;
1189 }
1190 if (inner->scope_uses_super_ || inner->inner_scope_uses_super_) {
1191 inner_scope_uses_super_ = true;
1192 }
1183 if (inner->scope_uses_this_ || inner->inner_scope_uses_this_) { 1193 if (inner->scope_uses_this_ || inner->inner_scope_uses_this_) {
1184 inner_scope_uses_this_ = true; 1194 inner_scope_uses_this_ = true;
1185 } 1195 }
1186 if (inner->scope_uses_arguments_ || inner->inner_scope_uses_arguments_) {
1187 inner_scope_uses_arguments_ = true;
1188 }
1189 } 1196 }
1190 if (inner->force_eager_compilation_) { 1197 if (inner->force_eager_compilation_) {
1191 force_eager_compilation_ = true; 1198 force_eager_compilation_ = true;
1192 } 1199 }
1193 if (asm_module_ && inner->scope_type() == FUNCTION_SCOPE) { 1200 if (asm_module_ && inner->scope_type() == FUNCTION_SCOPE) {
1194 inner->asm_function_ = true; 1201 inner->asm_function_ = true;
1195 } 1202 }
1196 } 1203 }
1197 } 1204 }
1198 1205
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
1423 } 1430 }
1424 1431
1425 1432
1426 int Scope::ContextLocalCount() const { 1433 int Scope::ContextLocalCount() const {
1427 if (num_heap_slots() == 0) return 0; 1434 if (num_heap_slots() == 0) return 0;
1428 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - 1435 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS -
1429 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0); 1436 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0);
1430 } 1437 }
1431 1438
1432 } } // namespace v8::internal 1439 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/scopes.h ('k') | src/x64/full-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698