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

Side by Side Diff: src/scopes.cc

Issue 10448006: Merged r11592 into 3.9 branch. (Closed) Base URL: https://v8.googlecode.com/svn/branches/3.9
Patch Set: Add missing test Created 8 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 | « src/scopes.h ('k') | src/version.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 // 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 631 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 bool Scope::HasTrivialOuterContext() const { 642 bool Scope::HasTrivialOuterContext() const {
643 Scope* outer = outer_scope_; 643 Scope* outer = outer_scope_;
644 if (outer == NULL) return true; 644 if (outer == NULL) return true;
645 // Note that the outer context may be trivial in general, but the current 645 // Note that the outer context may be trivial in general, but the current
646 // scope may be inside a 'with' statement in which case the outer context 646 // scope may be inside a 'with' statement in which case the outer context
647 // for this scope is not trivial. 647 // for this scope is not trivial.
648 return !scope_inside_with_ && outer->HasTrivialContext(); 648 return !scope_inside_with_ && outer->HasTrivialContext();
649 } 649 }
650 650
651 651
652 bool Scope::AllowsLazyRecompilation() const {
653 return !force_eager_compilation_ &&
654 !TrivialDeclarationScopesBeforeWithScope();
655 }
656
657
658 bool Scope::TrivialDeclarationScopesBeforeWithScope() const {
659 Scope* outer = outer_scope_;
660 if (outer == NULL) return false;
661 outer = outer->DeclarationScope();
662 while (outer != NULL) {
663 if (outer->is_with_scope()) return true;
664 if (outer->is_declaration_scope() && outer->num_heap_slots() > 0)
665 return false;
666 outer = outer->outer_scope_;
667 }
668 return false;
669 }
670
671
652 int Scope::ContextChainLength(Scope* scope) { 672 int Scope::ContextChainLength(Scope* scope) {
653 int n = 0; 673 int n = 0;
654 for (Scope* s = this; s != scope; s = s->outer_scope_) { 674 for (Scope* s = this; s != scope; s = s->outer_scope_) {
655 ASSERT(s != NULL); // scope must be in the scope chain 675 ASSERT(s != NULL); // scope must be in the scope chain
656 if (s->num_heap_slots() > 0) n++; 676 if (s->num_heap_slots() > 0) n++;
657 } 677 }
658 return n; 678 return n;
659 } 679 }
660 680
661 681
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after
1250 } 1270 }
1251 1271
1252 1272
1253 int Scope::ContextLocalCount() const { 1273 int Scope::ContextLocalCount() const {
1254 if (num_heap_slots() == 0) return 0; 1274 if (num_heap_slots() == 0) return 0;
1255 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - 1275 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS -
1256 (function_ != NULL && function_->var()->IsContextSlot() ? 1 : 0); 1276 (function_ != NULL && function_->var()->IsContextSlot() ? 1 : 0);
1257 } 1277 }
1258 1278
1259 } } // namespace v8::internal 1279 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/scopes.h ('k') | src/version.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698