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

Side by Side Diff: src/compiler.cc

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

Powered by Google App Engine
This is Rietveld 408576698