OLD | NEW |
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 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
651 bool Scope::HasTrivialOuterContext() const { | 651 bool Scope::HasTrivialOuterContext() const { |
652 Scope* outer = outer_scope_; | 652 Scope* outer = outer_scope_; |
653 if (outer == NULL) return true; | 653 if (outer == NULL) return true; |
654 // Note that the outer context may be trivial in general, but the current | 654 // Note that the outer context may be trivial in general, but the current |
655 // scope may be inside a 'with' statement in which case the outer context | 655 // scope may be inside a 'with' statement in which case the outer context |
656 // for this scope is not trivial. | 656 // for this scope is not trivial. |
657 return !scope_inside_with_ && outer->HasTrivialContext(); | 657 return !scope_inside_with_ && outer->HasTrivialContext(); |
658 } | 658 } |
659 | 659 |
660 | 660 |
| 661 bool Scope::AllowsLazyRecompilation() const { |
| 662 return !force_eager_compilation_ && |
| 663 !TrivialDeclarationScopesBeforeWithScope(); |
| 664 } |
| 665 |
| 666 |
| 667 bool Scope::TrivialDeclarationScopesBeforeWithScope() const { |
| 668 Scope* outer = outer_scope_; |
| 669 if (outer == NULL) return false; |
| 670 outer = outer->DeclarationScope(); |
| 671 while (outer != NULL) { |
| 672 if (outer->is_with_scope()) return true; |
| 673 if (outer->is_declaration_scope() && outer->num_heap_slots() > 0) |
| 674 return false; |
| 675 outer = outer->outer_scope_; |
| 676 } |
| 677 return false; |
| 678 } |
| 679 |
| 680 |
661 int Scope::ContextChainLength(Scope* scope) { | 681 int Scope::ContextChainLength(Scope* scope) { |
662 int n = 0; | 682 int n = 0; |
663 for (Scope* s = this; s != scope; s = s->outer_scope_) { | 683 for (Scope* s = this; s != scope; s = s->outer_scope_) { |
664 ASSERT(s != NULL); // scope must be in the scope chain | 684 ASSERT(s != NULL); // scope must be in the scope chain |
665 if (s->num_heap_slots() > 0) n++; | 685 if (s->num_heap_slots() > 0) n++; |
666 } | 686 } |
667 return n; | 687 return n; |
668 } | 688 } |
669 | 689 |
670 | 690 |
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1264 } | 1284 } |
1265 | 1285 |
1266 | 1286 |
1267 int Scope::ContextLocalCount() const { | 1287 int Scope::ContextLocalCount() const { |
1268 if (num_heap_slots() == 0) return 0; | 1288 if (num_heap_slots() == 0) return 0; |
1269 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - | 1289 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - |
1270 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0); | 1290 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0); |
1271 } | 1291 } |
1272 | 1292 |
1273 } } // namespace v8::internal | 1293 } } // namespace v8::internal |
OLD | NEW |