OLD | NEW |
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/compiler.h" | 5 #include "src/compiler.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "src/ast-numbering.h" | 9 #include "src/ast-numbering.h" |
10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
(...skipping 1552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1563 // aggressive about lazy compilation, because it might trigger compilation | 1563 // aggressive about lazy compilation, because it might trigger compilation |
1564 // of functions without an outer context when setting a breakpoint through | 1564 // of functions without an outer context when setting a breakpoint through |
1565 // Debug::FindSharedFunctionInfoInScript. | 1565 // Debug::FindSharedFunctionInfoInScript. |
1566 bool allow_lazy_without_ctx = literal->AllowsLazyCompilationWithoutContext(); | 1566 bool allow_lazy_without_ctx = literal->AllowsLazyCompilationWithoutContext(); |
1567 // Compile eagerly for live edit. When compiling debug code, eagerly compile | 1567 // Compile eagerly for live edit. When compiling debug code, eagerly compile |
1568 // unless we can lazily compile without the context. | 1568 // unless we can lazily compile without the context. |
1569 bool allow_lazy = literal->AllowsLazyCompilation() && | 1569 bool allow_lazy = literal->AllowsLazyCompilation() && |
1570 !LiveEditFunctionTracker::IsActive(isolate) && | 1570 !LiveEditFunctionTracker::IsActive(isolate) && |
1571 (!info.is_debug() || allow_lazy_without_ctx); | 1571 (!info.is_debug() || allow_lazy_without_ctx); |
1572 | 1572 |
1573 if (outer_info->parse_info()->is_toplevel() && outer_info->will_serialize()) { | |
1574 // Make sure that if the toplevel code (possibly to be serialized), | |
1575 // the inner function must be allowed to be compiled lazily. | |
1576 // This is necessary to serialize toplevel code without inner functions. | |
1577 DCHECK(allow_lazy); | |
1578 } | |
1579 | |
1580 bool lazy = FLAG_lazy && allow_lazy && !literal->should_eager_compile(); | 1573 bool lazy = FLAG_lazy && allow_lazy && !literal->should_eager_compile(); |
1581 | 1574 |
1582 // Generate code | 1575 // Generate code |
1583 Handle<ScopeInfo> scope_info; | 1576 Handle<ScopeInfo> scope_info; |
1584 if (lazy) { | 1577 if (lazy) { |
1585 Handle<Code> code = isolate->builtins()->CompileLazy(); | 1578 Handle<Code> code = isolate->builtins()->CompileLazy(); |
1586 info.SetCode(code); | 1579 info.SetCode(code); |
1587 // There's no need in theory for a lazy-compiled function to have a type | 1580 // There's no need in theory for a lazy-compiled function to have a type |
1588 // feedback vector, but some parts of the system expect all | 1581 // feedback vector, but some parts of the system expect all |
1589 // SharedFunctionInfo instances to have one. The size of the vector depends | 1582 // SharedFunctionInfo instances to have one. The size of the vector depends |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1797 } | 1790 } |
1798 | 1791 |
1799 #if DEBUG | 1792 #if DEBUG |
1800 void CompilationInfo::PrintAstForTesting() { | 1793 void CompilationInfo::PrintAstForTesting() { |
1801 PrintF("--- Source from AST ---\n%s\n", | 1794 PrintF("--- Source from AST ---\n%s\n", |
1802 PrettyPrinter(isolate(), zone()).PrintProgram(literal())); | 1795 PrettyPrinter(isolate(), zone()).PrintProgram(literal())); |
1803 } | 1796 } |
1804 #endif | 1797 #endif |
1805 } // namespace internal | 1798 } // namespace internal |
1806 } // namespace v8 | 1799 } // namespace v8 |
OLD | NEW |