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

Side by Side Diff: src/scopes.cc

Issue 653603002: Try to fix cross-script global scope (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 2 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
« no previous file with comments | « src/scopes.h ('k') | src/v8natives.js » ('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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 ASSERT(info->function() != NULL); 263 ASSERT(info->function() != NULL);
264 Scope* scope = info->function()->scope(); 264 Scope* scope = info->function()->scope();
265 Scope* top = scope; 265 Scope* top = scope;
266 266
267 // Traverse the scope tree up to the first unresolved scope or the global 267 // Traverse the scope tree up to the first unresolved scope or the global
268 // scope and start scope resolution and variable allocation from that scope. 268 // scope and start scope resolution and variable allocation from that scope.
269 while (!top->is_global_scope() && 269 while (!top->is_global_scope() &&
270 !top->outer_scope()->already_resolved()) { 270 !top->outer_scope()->already_resolved()) {
271 top = top->outer_scope(); 271 top = top->outer_scope();
272 } 272 }
273 // TODO(rossberg): remove the above.
274 top = info->global_scope();
275 ASSERT(top->is_global_scope());
273 276
274 // Allocate the variables. 277 // Allocate the variables.
275 { 278 {
276 // Passing NULL as AstValueFactory is ok, because AllocateVariables doesn't 279 // Passing NULL as AstValueFactory is ok, because AllocateVariables doesn't
277 // need to create new strings or values. 280 // need to create new strings or values.
278 AstNodeFactory<AstNullVisitor> ast_node_factory(info->zone(), NULL); 281 AstNodeFactory<AstNullVisitor> ast_node_factory(info->zone(), NULL);
279 if (!top->AllocateVariables(info, &ast_node_factory)) return false; 282 if (!top->AllocateVariables(info, &ast_node_factory)) return false;
280 } 283 }
281 284
282 #ifdef DEBUG 285 #ifdef DEBUG
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
766 } 769 }
767 770
768 771
769 #ifdef DEBUG 772 #ifdef DEBUG
770 static const char* Header(ScopeType scope_type) { 773 static const char* Header(ScopeType scope_type) {
771 switch (scope_type) { 774 switch (scope_type) {
772 case EVAL_SCOPE: return "eval"; 775 case EVAL_SCOPE: return "eval";
773 case FUNCTION_SCOPE: return "function"; 776 case FUNCTION_SCOPE: return "function";
774 case MODULE_SCOPE: return "module"; 777 case MODULE_SCOPE: return "module";
775 case GLOBAL_SCOPE: return "global"; 778 case GLOBAL_SCOPE: return "global";
779 case SCRIPT_SCOPE: return "script";
776 case CATCH_SCOPE: return "catch"; 780 case CATCH_SCOPE: return "catch";
777 case BLOCK_SCOPE: return "block"; 781 case BLOCK_SCOPE: return "block";
778 case WITH_SCOPE: return "with"; 782 case WITH_SCOPE: return "with";
779 } 783 }
780 UNREACHABLE(); 784 UNREACHABLE();
781 return NULL; 785 return NULL;
782 } 786 }
783 787
784 788
785 static void Indent(int n, const char* str) { 789 static void Indent(int n, const char* str) {
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
1216 if (params_[i]->name().is_identical_to( 1220 if (params_[i]->name().is_identical_to(
1217 isolate_->factory()->arguments_string())) { 1221 isolate_->factory()->arguments_string())) {
1218 return true; 1222 return true;
1219 } 1223 }
1220 } 1224 }
1221 return false; 1225 return false;
1222 } 1226 }
1223 1227
1224 1228
1225 void Scope::AllocateStackSlot(Variable* var) { 1229 void Scope::AllocateStackSlot(Variable* var) {
1230 ASSERT(var->scope() == this);
1226 var->AllocateTo(Variable::LOCAL, num_stack_slots_++); 1231 var->AllocateTo(Variable::LOCAL, num_stack_slots_++);
1227 } 1232 }
1228 1233
1229 1234
1230 void Scope::AllocateHeapSlot(Variable* var) { 1235 void Scope::AllocateHeapSlot(Variable* var) {
1236 printf("[AllocateHeapSlot] scope=%p %s var=%.*s\n", (void*)this, Variable::Mode2 String(var->mode()), var->raw_name()->length(), var->raw_name()->raw_data());
1237 if (var->mode() == LET) base::OS::DebugBreak();
1238 ASSERT(var->scope() == this);
1231 var->AllocateTo(Variable::CONTEXT, num_heap_slots_++); 1239 var->AllocateTo(Variable::CONTEXT, num_heap_slots_++);
1232 } 1240 }
1233 1241
1234 1242
1235 void Scope::AllocateParameterLocals() { 1243 void Scope::AllocateParameterLocals() {
1236 ASSERT(is_function_scope()); 1244 ASSERT(is_function_scope());
1237 Variable* arguments = LookupLocal(ast_value_factory_->arguments_string()); 1245 Variable* arguments = LookupLocal(ast_value_factory_->arguments_string());
1238 ASSERT(arguments != NULL); // functions have 'arguments' declared implicitly 1246 ASSERT(arguments != NULL); // functions have 'arguments' declared implicitly
1239 1247
1240 bool uses_sloppy_arguments = false; 1248 bool uses_sloppy_arguments = false;
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
1394 } 1402 }
1395 1403
1396 1404
1397 int Scope::ContextLocalCount() const { 1405 int Scope::ContextLocalCount() const {
1398 if (num_heap_slots() == 0) return 0; 1406 if (num_heap_slots() == 0) return 0;
1399 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - 1407 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS -
1400 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0); 1408 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0);
1401 } 1409 }
1402 1410
1403 } } // namespace v8::internal 1411 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/scopes.h ('k') | src/v8natives.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698