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

Side by Side Diff: src/scopes.cc

Issue 14513002: Add assertion about module scopes to Scope::ContextChainLength. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 7 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 | « no previous file | no next file » | 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 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 bool Scope::AllowsLazyCompilationWithoutContext() const { 720 bool Scope::AllowsLazyCompilationWithoutContext() const {
721 return !force_eager_compilation_ && HasTrivialOuterContext(); 721 return !force_eager_compilation_ && HasTrivialOuterContext();
722 } 722 }
723 723
724 724
725 int Scope::ContextChainLength(Scope* scope) { 725 int Scope::ContextChainLength(Scope* scope) {
726 int n = 0; 726 int n = 0;
727 for (Scope* s = this; s != scope; s = s->outer_scope_) { 727 for (Scope* s = this; s != scope; s = s->outer_scope_) {
728 ASSERT(s != NULL); // scope must be in the scope chain 728 ASSERT(s != NULL); // scope must be in the scope chain
729 if (s->is_with_scope() || s->num_heap_slots() > 0) n++; 729 if (s->is_with_scope() || s->num_heap_slots() > 0) n++;
730 // Catch scopes always have heap slots. 730 // Catch and module scopes always have heap slots.
731 ASSERT(!s->is_catch_scope() || s->num_heap_slots() > 0); 731 ASSERT(!s->is_catch_scope() || s->num_heap_slots() > 0);
732 ASSERT(!s->is_module_scope() || s->num_heap_slots() > 0);
732 } 733 }
733 return n; 734 return n;
734 } 735 }
735 736
736 737
737 Scope* Scope::GlobalScope() { 738 Scope* Scope::GlobalScope() {
738 Scope* scope = this; 739 Scope* scope = this;
739 while (!scope->is_global_scope()) { 740 while (!scope->is_global_scope()) {
740 scope = scope->outer_scope(); 741 scope = scope->outer_scope();
741 } 742 }
(...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after
1392 } 1393 }
1393 1394
1394 1395
1395 int Scope::ContextLocalCount() const { 1396 int Scope::ContextLocalCount() const {
1396 if (num_heap_slots() == 0) return 0; 1397 if (num_heap_slots() == 0) return 0;
1397 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - 1398 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS -
1398 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0); 1399 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0);
1399 } 1400 }
1400 1401
1401 } } // namespace v8::internal 1402 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698