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

Side by Side Diff: src/scopes.cc

Issue 1216013002: Parse eagerly inside block scopes. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: simplified a lot Created 5 years, 5 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') | test/mjsunit/regress/regress-4255-1.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/accessors.h" 7 #include "src/accessors.h"
8 #include "src/bootstrapper.h" 8 #include "src/bootstrapper.h"
9 #include "src/messages.h" 9 #include "src/messages.h"
10 #include "src/parser.h" 10 #include "src/parser.h"
(...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 if (scope->is_with_scope() && !found_non_trivial_declarations) return false; 727 if (scope->is_with_scope() && !found_non_trivial_declarations) return false;
728 if (scope->is_block_scope() && !scope->decls_.is_empty()) return false; 728 if (scope->is_block_scope() && !scope->decls_.is_empty()) return false;
729 if (scope->is_declaration_scope() && scope->num_heap_slots() > 0) { 729 if (scope->is_declaration_scope() && scope->num_heap_slots() > 0) {
730 found_non_trivial_declarations = true; 730 found_non_trivial_declarations = true;
731 } 731 }
732 } 732 }
733 return true; 733 return true;
734 } 734 }
735 735
736 736
737 bool Scope::AllowsLazyParsing() const {
738 // If we are inside a block scope, we must parse eagerly to find out how
739 // to allocate variables on the block scope. At this point, declarations may
740 // not have yet been parsed.
741 for (const Scope* scope = this; scope != NULL; scope = scope->outer_scope_) {
742 if (scope->is_block_scope()) return false;
743 }
744 return AllowsLazyCompilation();
745 }
746
747
737 bool Scope::AllowsLazyCompilation() const { 748 bool Scope::AllowsLazyCompilation() const {
738 return !force_eager_compilation_ && HasLazyCompilableOuterContext(); 749 return !force_eager_compilation_ && HasLazyCompilableOuterContext();
739 } 750 }
740 751
741 752
742 bool Scope::AllowsLazyCompilationWithoutContext() const { 753 bool Scope::AllowsLazyCompilationWithoutContext() const {
743 return !force_eager_compilation_ && HasTrivialOuterContext(); 754 return !force_eager_compilation_ && HasTrivialOuterContext();
744 } 755 }
745 756
746 757
(...skipping 827 matching lines...) Expand 10 before | Expand all | Expand 10 after
1574 } 1585 }
1575 1586
1576 1587
1577 int Scope::ContextLocalCount() const { 1588 int Scope::ContextLocalCount() const {
1578 if (num_heap_slots() == 0) return 0; 1589 if (num_heap_slots() == 0) return 0;
1579 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - 1590 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS -
1580 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0); 1591 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0);
1581 } 1592 }
1582 } // namespace internal 1593 } // namespace internal
1583 } // namespace v8 1594 } // namespace v8
OLDNEW
« no previous file with comments | « src/scopes.h ('k') | test/mjsunit/regress/regress-4255-1.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698