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

Side by Side Diff: src/compiler.cc

Issue 2405813002: Allow lazy parsing of functions nested in eager compiled functions (Closed)
Patch Set: Rebase Created 4 years, 2 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/ast/scopes.cc ('k') | src/parsing/parse-info.cc » ('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 #include <memory> 8 #include <memory>
9 9
10 #include "src/asmjs/asm-js.h" 10 #include "src/asmjs/asm-js.h"
(...skipping 1037 matching lines...) Expand 10 before | Expand all | Expand 10 after
1048 parse_info->set_toplevel(); 1048 parse_info->set_toplevel();
1049 1049
1050 Handle<SharedFunctionInfo> result; 1050 Handle<SharedFunctionInfo> result;
1051 1051
1052 { VMState<COMPILER> state(info->isolate()); 1052 { VMState<COMPILER> state(info->isolate());
1053 if (parse_info->literal() == NULL) { 1053 if (parse_info->literal() == NULL) {
1054 // Parse the script if needed (if it's already parsed, literal() is 1054 // Parse the script if needed (if it's already parsed, literal() is
1055 // non-NULL). If compiling for debugging, we may eagerly compile inner 1055 // non-NULL). If compiling for debugging, we may eagerly compile inner
1056 // functions, so do not parse lazily in that case. 1056 // functions, so do not parse lazily in that case.
1057 ScriptCompiler::CompileOptions options = parse_info->compile_options(); 1057 ScriptCompiler::CompileOptions options = parse_info->compile_options();
1058 bool parse_allow_lazy = (options == ScriptCompiler::kConsumeParserCache || 1058 bool parse_allow_lazy =
1059 String::cast(script->source())->length() > 1059 options == ScriptCompiler::kConsumeParserCache ||
1060 FLAG_min_preparse_length) && 1060 String::cast(script->source())->length() > FLAG_min_preparse_length;
1061 !info->is_debug();
1062
1063 // Consider parsing eagerly when targeting the code cache.
1064 parse_allow_lazy &= !(FLAG_serialize_eager && info->will_serialize());
1065
1066 // Consider parsing eagerly when targeting Ignition.
1067 parse_allow_lazy &= !(FLAG_ignition && FLAG_ignition_eager &&
1068 !isolate->serializer_enabled());
1069 1061
1070 parse_info->set_allow_lazy_parsing(parse_allow_lazy); 1062 parse_info->set_allow_lazy_parsing(parse_allow_lazy);
1071 if (!parse_allow_lazy && 1063 if (!parse_allow_lazy &&
1072 (options == ScriptCompiler::kProduceParserCache || 1064 (options == ScriptCompiler::kProduceParserCache ||
1073 options == ScriptCompiler::kConsumeParserCache)) { 1065 options == ScriptCompiler::kConsumeParserCache)) {
1074 // We are going to parse eagerly, but we either 1) have cached data 1066 // We are going to parse eagerly, but we either 1) have cached data
1075 // produced by lazy parsing or 2) are asked to generate cached data. 1067 // produced by lazy parsing or 2) are asked to generate cached data.
1076 // Eager parsing cannot benefit from cached data, and producing cached 1068 // Eager parsing cannot benefit from cached data, and producing cached
1077 // data while parsing eagerly is not implemented. 1069 // data while parsing eagerly is not implemented.
1078 parse_info->set_cached_data(nullptr); 1070 parse_info->set_cached_data(nullptr);
1079 parse_info->set_compile_options(ScriptCompiler::kNoCompileOptions); 1071 parse_info->set_compile_options(ScriptCompiler::kNoCompileOptions);
1080 } 1072 }
1081 1073
1082 if (!Parse(parse_info)) { 1074 if (!Parse(parse_info)) {
1083 return Handle<SharedFunctionInfo>::null(); 1075 return Handle<SharedFunctionInfo>::null();
1084 } 1076 }
1085 } 1077 }
1086 1078
1087 DCHECK(!info->is_debug() || !parse_info->allow_lazy_parsing());
1088
1089 FunctionLiteral* lit = parse_info->literal(); 1079 FunctionLiteral* lit = parse_info->literal();
1090 1080
1091 // Measure how long it takes to do the compilation; only take the 1081 // Measure how long it takes to do the compilation; only take the
1092 // rest of the function into account to avoid overlap with the 1082 // rest of the function into account to avoid overlap with the
1093 // parsing statistics. 1083 // parsing statistics.
1094 RuntimeCallTimerScope runtimeTimer( 1084 RuntimeCallTimerScope runtimeTimer(
1095 isolate, parse_info->is_eval() ? &RuntimeCallStats::CompileEval 1085 isolate, parse_info->is_eval() ? &RuntimeCallStats::CompileEval
1096 : &RuntimeCallStats::Compile); 1086 : &RuntimeCallStats::Compile);
1097 HistogramTimer* rate = parse_info->is_eval() 1087 HistogramTimer* rate = parse_info->is_eval()
1098 ? info->isolate()->counters()->compile_eval() 1088 ? info->isolate()->counters()->compile_eval()
(...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after
1868 DCHECK(shared->is_compiled()); 1858 DCHECK(shared->is_compiled());
1869 function->set_literals(cached.literals); 1859 function->set_literals(cached.literals);
1870 } else if (shared->is_compiled()) { 1860 } else if (shared->is_compiled()) {
1871 // TODO(mvstanton): pass pretenure flag to EnsureLiterals. 1861 // TODO(mvstanton): pass pretenure flag to EnsureLiterals.
1872 JSFunction::EnsureLiterals(function); 1862 JSFunction::EnsureLiterals(function);
1873 } 1863 }
1874 } 1864 }
1875 1865
1876 } // namespace internal 1866 } // namespace internal
1877 } // namespace v8 1867 } // namespace v8
OLDNEW
« no previous file with comments | « src/ast/scopes.cc ('k') | src/parsing/parse-info.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698