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

Side by Side Diff: src/compiler.cc

Issue 1804433004: [serializer] add options to compile eagerly and pre-age for code cache. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 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/compiler.h ('k') | src/flag-definitions.h » ('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/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 1392 matching lines...) Expand 10 before | Expand all | Expand 10 after
1403 if (parse_info->literal() == NULL) { 1403 if (parse_info->literal() == NULL) {
1404 // Parse the script if needed (if it's already parsed, literal() is 1404 // Parse the script if needed (if it's already parsed, literal() is
1405 // non-NULL). If compiling for debugging, we may eagerly compile inner 1405 // non-NULL). If compiling for debugging, we may eagerly compile inner
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.
1414 parse_allow_lazy &= !(FLAG_serialize_eager && info->will_serialize());
1415
1413 parse_info->set_allow_lazy_parsing(parse_allow_lazy); 1416 parse_info->set_allow_lazy_parsing(parse_allow_lazy);
1414 if (!parse_allow_lazy && 1417 if (!parse_allow_lazy &&
1415 (options == ScriptCompiler::kProduceParserCache || 1418 (options == ScriptCompiler::kProduceParserCache ||
1416 options == ScriptCompiler::kConsumeParserCache)) { 1419 options == ScriptCompiler::kConsumeParserCache)) {
1417 // We are going to parse eagerly, but we either 1) have cached data 1420 // We are going to parse eagerly, but we either 1) have cached data
1418 // produced by lazy parsing or 2) are asked to generate cached data. 1421 // produced by lazy parsing or 2) are asked to generate cached data.
1419 // Eager parsing cannot benefit from cached data, and producing cached 1422 // Eager parsing cannot benefit from cached data, and producing cached
1420 // data while parsing eagerly is not implemented. 1423 // data while parsing eagerly is not implemented.
1421 parse_info->set_cached_data(nullptr); 1424 parse_info->set_cached_data(nullptr);
1422 parse_info->set_compile_options(ScriptCompiler::kNoCompileOptions); 1425 parse_info->set_compile_options(ScriptCompiler::kNoCompileOptions);
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
1763 // Debug::FindSharedFunctionInfoInScript. 1766 // Debug::FindSharedFunctionInfoInScript.
1764 bool allow_lazy_without_ctx = literal->AllowsLazyCompilationWithoutContext(); 1767 bool allow_lazy_without_ctx = literal->AllowsLazyCompilationWithoutContext();
1765 // Compile eagerly for live edit. When compiling debug code, eagerly compile 1768 // Compile eagerly for live edit. When compiling debug code, eagerly compile
1766 // unless we can lazily compile without the context. 1769 // unless we can lazily compile without the context.
1767 bool allow_lazy = literal->AllowsLazyCompilation() && 1770 bool allow_lazy = literal->AllowsLazyCompilation() &&
1768 !LiveEditFunctionTracker::IsActive(isolate) && 1771 !LiveEditFunctionTracker::IsActive(isolate) &&
1769 (!info.is_debug() || allow_lazy_without_ctx); 1772 (!info.is_debug() || allow_lazy_without_ctx);
1770 1773
1771 bool lazy = FLAG_lazy && allow_lazy && !literal->should_eager_compile(); 1774 bool lazy = FLAG_lazy && allow_lazy && !literal->should_eager_compile();
1772 1775
1776 // Consider compiling eagerly when targeting the code cache.
1777 lazy &= !(FLAG_serialize_eager && info.will_serialize());
1778
1773 // Generate code 1779 // Generate code
1774 TimerEventScope<TimerEventCompileCode> timer(isolate); 1780 TimerEventScope<TimerEventCompileCode> timer(isolate);
1775 TRACE_EVENT0("v8", "V8.CompileCode"); 1781 TRACE_EVENT0("v8", "V8.CompileCode");
1776 Handle<ScopeInfo> scope_info; 1782 Handle<ScopeInfo> scope_info;
1777 if (lazy) { 1783 if (lazy) {
1778 Handle<Code> code = isolate->builtins()->CompileLazy(); 1784 Handle<Code> code = isolate->builtins()->CompileLazy();
1779 info.SetCode(code); 1785 info.SetCode(code);
1780 // There's no need in theory for a lazy-compiled function to have a type 1786 // There's no need in theory for a lazy-compiled function to have a type
1781 // feedback vector, but some parts of the system expect all 1787 // feedback vector, but some parts of the system expect all
1782 // SharedFunctionInfo instances to have one. The size of the vector depends 1788 // SharedFunctionInfo instances to have one. The size of the vector depends
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
1966 1972
1967 #if DEBUG 1973 #if DEBUG
1968 void CompilationInfo::PrintAstForTesting() { 1974 void CompilationInfo::PrintAstForTesting() {
1969 PrintF("--- Source from AST ---\n%s\n", 1975 PrintF("--- Source from AST ---\n%s\n",
1970 PrettyPrinter(isolate()).PrintProgram(literal())); 1976 PrettyPrinter(isolate()).PrintProgram(literal()));
1971 } 1977 }
1972 #endif 1978 #endif
1973 1979
1974 } // namespace internal 1980 } // namespace internal
1975 } // namespace v8 1981 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler.h ('k') | src/flag-definitions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698