Commit d7e59efa authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

Revert "Reland: [Compiler] Use CompilationCache for StreamedScript compilation."

This reverts commit 25427203.

Reason for revert: code-coverage failures on gc-stress bot: https://build.chromium.org/p/client.v8/builders/V8%20Linux64%20GC%20Stress%20-%20custom%20snapshot/builds/17956

Original change's description:
> Reland: [Compiler] Use CompilationCache for StreamedScript compilation.
> 
> Previously GetSharedFunctionInfoForStreamedScript didn't either check the
> compilation cache or put the result of compilation into the compilation
> cache. This would mean future compiles would need to re-parse / compile
> the same script even if the isolate had already seen it. This CL
> fixes this.
> 
> Also refactors the compilation pipelines to ensure we call debug->OnAfterCompile()
> for all script compiles even when loading from a cache.
> 
> BUG=v8:5203
> Cq-Include-Trybots: master.tryserver.chromium.linux:linux_chromium_rel_ng
> 
> Change-Id: I0a74c5b67bfaca5e50511d5f72da0ab53d8457f6
> Reviewed-on: https://chromium-review.googlesource.com/937724
> Commit-Queue: Ross McIlroy <rmcilroy@chromium.org>
> Reviewed-by: Mythri Alle <mythria@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#51594}

TBR=rmcilroy@chromium.org,yangguo@chromium.org,mythria@chromium.org

Change-Id: I784b9eeff75a677b9f2276fa05a0d1af09772baa
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: v8:5203
Cq-Include-Trybots: master.tryserver.chromium.linux:linux_chromium_rel_ng
Reviewed-on: https://chromium-review.googlesource.com/939401Reviewed-by: 's avatarClemens Hammacher <clemensh@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#51596}
parent bd2c9d56
...@@ -1690,14 +1690,14 @@ MaybeHandle<SharedFunctionInfo> Compiler::GetSharedFunctionInfoForScript( ...@@ -1690,14 +1690,14 @@ MaybeHandle<SharedFunctionInfo> Compiler::GetSharedFunctionInfoForScript(
compilation_cache->PutScript(source, isolate->native_context(), compilation_cache->PutScript(source, isolate->native_context(),
language_mode, inner_result); language_mode, inner_result);
Handle<Script> script(Script::cast(inner_result->script()), isolate); Handle<Script> script(Script::cast(inner_result->script()), isolate);
isolate->debug()->OnAfterCompile(script);
if (isolate->NeedsSourcePositionsForProfiling()) { if (isolate->NeedsSourcePositionsForProfiling()) {
Script::InitLineEnds(script); Script::InitLineEnds(script);
} }
maybe_result = inner_result; return inner_result;
} else {
// Deserializer failed. Fall through to compile.
compile_timer.set_consuming_code_cache_failed();
} }
// Deserializer failed. Fall through to compile.
compile_timer.set_consuming_code_cache_failed();
} }
} }
...@@ -1721,18 +1721,16 @@ MaybeHandle<SharedFunctionInfo> Compiler::GetSharedFunctionInfoForScript( ...@@ -1721,18 +1721,16 @@ MaybeHandle<SharedFunctionInfo> Compiler::GetSharedFunctionInfoForScript(
DCHECK(result->is_compiled()); DCHECK(result->is_compiled());
compilation_cache->PutScript(source, isolate->native_context(), compilation_cache->PutScript(source, isolate->native_context(),
language_mode, result); language_mode, result);
} else if (maybe_result.is_null() && natives != EXTENSION_CODE &&
natives != NATIVES_CODE) {
isolate->ReportPendingMessages();
} }
}
// On success, report script compilation to debugger. if (maybe_result.is_null()) {
Handle<SharedFunctionInfo> result; if (natives != EXTENSION_CODE && natives != NATIVES_CODE) {
if (maybe_result.ToHandle(&result)) { isolate->ReportPendingMessages();
isolate->debug()->OnAfterCompile(handle(Script::cast(result->script()))); }
} else {
isolate->debug()->OnAfterCompile(script);
}
} }
return maybe_result; return maybe_result;
} }
...@@ -1757,67 +1755,43 @@ Compiler::GetSharedFunctionInfoForStreamedScript( ...@@ -1757,67 +1755,43 @@ Compiler::GetSharedFunctionInfoForStreamedScript(
ParseInfo* parse_info = streaming_data->info.get(); ParseInfo* parse_info = streaming_data->info.get();
parse_info->UpdateBackgroundParseStatisticsOnMainThread(isolate); parse_info->UpdateBackgroundParseStatisticsOnMainThread(isolate);
// Check if compile cache already holds the SFI, if so no need to finalize Handle<Script> script = NewScript(isolate, source, script_details,
// the code compiled on the background thread. origin_options, NOT_NATIVES_CODE);
CompilationCache* compilation_cache = isolate->compilation_cache(); parse_info->set_script(script);
MaybeHandle<SharedFunctionInfo> maybe_result = streaming_data->parser->UpdateStatistics(isolate, script);
compilation_cache->LookupScript( streaming_data->parser->HandleSourceURLComments(isolate, script);
source, script_details.name_obj, script_details.line_offset,
script_details.column_offset, origin_options, if (parse_info->literal() == nullptr) {
isolate->native_context(), parse_info->language_mode()); // Parsing has failed - report error messages.
if (!maybe_result.is_null()) { parse_info->pending_error_handler()->ReportErrors(
compile_timer.set_hit_isolate_cache(); isolate, script, parse_info->ast_value_factory());
streaming_data->Release();
return MaybeHandle<SharedFunctionInfo>();
} }
if (maybe_result.is_null()) { // Parsing has succeeded - finalize compilation.
// No cache entry found, finalize compilation of the script and add it to MaybeHandle<SharedFunctionInfo> result;
// the isolate cache. if (i::FLAG_background_compile) {
Handle<Script> script = NewScript(isolate, source, script_details, // Finalize background compilation.
origin_options, NOT_NATIVES_CODE); if (streaming_data->outer_function_job) {
parse_info->set_script(script); result = FinalizeTopLevel(parse_info, isolate,
streaming_data->parser->UpdateStatistics(isolate, script); streaming_data->outer_function_job.get(),
streaming_data->parser->HandleSourceURLComments(isolate, script); &streaming_data->inner_function_jobs);
if (parse_info->literal() == nullptr) {
// Parsing has failed - report error messages.
parse_info->pending_error_handler()->ReportErrors(
isolate, script, parse_info->ast_value_factory());
} else { } else {
// Parsing has succeeded - finalize compilation. // Compilation failed on background thread - throw an exception.
if (i::FLAG_background_compile) { FailWithPendingException(isolate, parse_info,
// Finalize background compilation. Compiler::ClearExceptionFlag::KEEP_EXCEPTION);
if (streaming_data->outer_function_job) {
maybe_result = FinalizeTopLevel(
parse_info, isolate, streaming_data->outer_function_job.get(),
&streaming_data->inner_function_jobs);
} else {
// Compilation failed on background thread - throw an exception.
FailWithPendingException(
isolate, parse_info,
Compiler::ClearExceptionFlag::KEEP_EXCEPTION);
}
} else {
// Compilation on main thread.
maybe_result = CompileToplevel(parse_info, isolate);
}
}
// Add compiled code to the isolate cache.
Handle<SharedFunctionInfo> result;
if (maybe_result.ToHandle(&result)) {
compilation_cache->PutScript(source, isolate->native_context(),
parse_info->language_mode(), result);
} }
} else {
// Compilation on main thread.
result = CompileToplevel(parse_info, isolate);
} }
// On success, report script compilation to debugger. if (!result.is_null()) {
Handle<SharedFunctionInfo> result; isolate->debug()->OnAfterCompile(script);
if (maybe_result.ToHandle(&result)) {
isolate->debug()->OnAfterCompile(handle(Script::cast(result->script())));
} }
streaming_data->Release(); streaming_data->Release();
return maybe_result; return result;
} }
Handle<SharedFunctionInfo> Compiler::GetSharedFunctionInfo( Handle<SharedFunctionInfo> Compiler::GetSharedFunctionInfo(
......
...@@ -18,11 +18,8 @@ function store(description) { ...@@ -18,11 +18,8 @@ function store(description) {
} }
//# sourceURL=utils.js`; //# sourceURL=utils.js`;
// TODO(rmcilroy): This has to be in this order since the i::Script object gets
// reused via the CompilationCache, and we want OnAfterCompile to be called
// for contextGroup1 last on this script.
contextGroup2.addScript(utilsScript);
contextGroup1.addScript(utilsScript); contextGroup1.addScript(utilsScript);
contextGroup2.addScript(utilsScript);
let frameworkScript = ` let frameworkScript = `
function call(id, f) { function call(id, f) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment