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/ast-numbering.h" | 9 #include "src/ast/ast-numbering.h" |
10 #include "src/ast/prettyprinter.h" | 10 #include "src/ast/prettyprinter.h" |
(...skipping 1395 matching lines...) Loading... | |
1406 // functions, so do not parse lazily in that case. | 1406 // functions, so do not parse lazily in that case. |
1407 ScriptCompiler::CompileOptions options = parse_info->compile_options(); | 1407 ScriptCompiler::CompileOptions options = parse_info->compile_options(); |
1408 bool parse_allow_lazy = (options == ScriptCompiler::kConsumeParserCache || | 1408 bool parse_allow_lazy = (options == ScriptCompiler::kConsumeParserCache || |
1409 String::cast(script->source())->length() > | 1409 String::cast(script->source())->length() > |
1410 FLAG_min_preparse_length) && | 1410 FLAG_min_preparse_length) && |
1411 !info->is_debug(); | 1411 !info->is_debug(); |
1412 | 1412 |
1413 // Consider parsing eagerly when targeting the code cache. | 1413 // Consider parsing eagerly when targeting the code cache. |
1414 parse_allow_lazy &= !(FLAG_serialize_eager && info->will_serialize()); | 1414 parse_allow_lazy &= !(FLAG_serialize_eager && info->will_serialize()); |
1415 | 1415 |
1416 // Consider compiling eagerly when compiling bytecode for Ignition. | |
Michael Starzinger
2016/03/17 18:58:51
nit: s/compiling/parsing/
rmcilroy
2016/03/21 15:21:55
Done.
| |
1417 parse_allow_lazy &= !(FLAG_ignition && !isolate->serializer_enabled()); | |
1418 | |
1416 parse_info->set_allow_lazy_parsing(parse_allow_lazy); | 1419 parse_info->set_allow_lazy_parsing(parse_allow_lazy); |
1417 if (!parse_allow_lazy && | 1420 if (!parse_allow_lazy && |
1418 (options == ScriptCompiler::kProduceParserCache || | 1421 (options == ScriptCompiler::kProduceParserCache || |
1419 options == ScriptCompiler::kConsumeParserCache)) { | 1422 options == ScriptCompiler::kConsumeParserCache)) { |
1420 // We are going to parse eagerly, but we either 1) have cached data | 1423 // We are going to parse eagerly, but we either 1) have cached data |
1421 // produced by lazy parsing or 2) are asked to generate cached data. | 1424 // produced by lazy parsing or 2) are asked to generate cached data. |
1422 // Eager parsing cannot benefit from cached data, and producing cached | 1425 // Eager parsing cannot benefit from cached data, and producing cached |
1423 // data while parsing eagerly is not implemented. | 1426 // data while parsing eagerly is not implemented. |
1424 parse_info->set_cached_data(nullptr); | 1427 parse_info->set_cached_data(nullptr); |
1425 parse_info->set_compile_options(ScriptCompiler::kNoCompileOptions); | 1428 parse_info->set_compile_options(ScriptCompiler::kNoCompileOptions); |
(...skipping 343 matching lines...) Loading... | |
1769 // unless we can lazily compile without the context. | 1772 // unless we can lazily compile without the context. |
1770 bool allow_lazy = literal->AllowsLazyCompilation() && | 1773 bool allow_lazy = literal->AllowsLazyCompilation() && |
1771 !LiveEditFunctionTracker::IsActive(isolate) && | 1774 !LiveEditFunctionTracker::IsActive(isolate) && |
1772 (!info.is_debug() || allow_lazy_without_ctx); | 1775 (!info.is_debug() || allow_lazy_without_ctx); |
1773 | 1776 |
1774 bool lazy = FLAG_lazy && allow_lazy && !literal->should_eager_compile(); | 1777 bool lazy = FLAG_lazy && allow_lazy && !literal->should_eager_compile(); |
1775 | 1778 |
1776 // Consider compiling eagerly when targeting the code cache. | 1779 // Consider compiling eagerly when targeting the code cache. |
1777 lazy &= !(FLAG_serialize_eager && info.will_serialize()); | 1780 lazy &= !(FLAG_serialize_eager && info.will_serialize()); |
1778 | 1781 |
1782 // Consider compiling eagerly when compiling bytecode for Ignition. | |
1783 lazy &= !(FLAG_ignition && !isolate->serializer_enabled()); | |
1784 | |
1779 // Generate code | 1785 // Generate code |
1780 TimerEventScope<TimerEventCompileCode> timer(isolate); | 1786 TimerEventScope<TimerEventCompileCode> timer(isolate); |
1781 TRACE_EVENT0("v8", "V8.CompileCode"); | 1787 TRACE_EVENT0("v8", "V8.CompileCode"); |
1782 Handle<ScopeInfo> scope_info; | 1788 Handle<ScopeInfo> scope_info; |
1783 if (lazy) { | 1789 if (lazy) { |
1784 Handle<Code> code = isolate->builtins()->CompileLazy(); | 1790 Handle<Code> code = isolate->builtins()->CompileLazy(); |
1785 info.SetCode(code); | 1791 info.SetCode(code); |
1786 // There's no need in theory for a lazy-compiled function to have a type | 1792 // There's no need in theory for a lazy-compiled function to have a type |
1787 // feedback vector, but some parts of the system expect all | 1793 // feedback vector, but some parts of the system expect all |
1788 // SharedFunctionInfo instances to have one. The size of the vector depends | 1794 // SharedFunctionInfo instances to have one. The size of the vector depends |
(...skipping 183 matching lines...) Loading... | |
1972 | 1978 |
1973 #if DEBUG | 1979 #if DEBUG |
1974 void CompilationInfo::PrintAstForTesting() { | 1980 void CompilationInfo::PrintAstForTesting() { |
1975 PrintF("--- Source from AST ---\n%s\n", | 1981 PrintF("--- Source from AST ---\n%s\n", |
1976 PrettyPrinter(isolate()).PrintProgram(literal())); | 1982 PrettyPrinter(isolate()).PrintProgram(literal())); |
1977 } | 1983 } |
1978 #endif | 1984 #endif |
1979 | 1985 |
1980 } // namespace internal | 1986 } // namespace internal |
1981 } // namespace v8 | 1987 } // namespace v8 |
OLD | NEW |