Commit 879fac3b authored by jochen's avatar jochen Committed by Commit bot

Always use FinalizeUnoptimizedCompilationJob

Before, some code paths just invoked job->FinalizeJob() and then
manually installed the compilation result. Unify these.

BUG=v8:5394
R=mstarzinger@chromium.org

Review-Url: https://codereview.chromium.org/2399203003
Cr-Commit-Position: refs/heads/master@{#40120}
parent 67bcc7f6
......@@ -360,38 +360,6 @@ CompilationJob* GetUnoptimizedCompilationJob(CompilationInfo* info) {
}
}
bool GenerateUnoptimizedCode(CompilationInfo* info) {
if (FLAG_validate_asm && info->scope()->asm_module() &&
!info->shared_info()->is_asm_wasm_broken()) {
EnsureFeedbackMetadata(info);
MaybeHandle<FixedArray> wasm_data;
wasm_data = AsmJs::ConvertAsmToWasm(info->parse_info());
if (!wasm_data.is_null()) {
info->shared_info()->set_asm_wasm_data(*wasm_data.ToHandleChecked());
info->SetCode(info->isolate()->builtins()->InstantiateAsmJs());
return true;
}
}
std::unique_ptr<CompilationJob> job(GetUnoptimizedCompilationJob(info));
if (job->PrepareJob() != CompilationJob::SUCCEEDED) return false;
if (job->ExecuteJob() != CompilationJob::SUCCEEDED) return false;
if (job->FinalizeJob() != CompilationJob::SUCCEEDED) return false;
job->RecordUnoptimizedCompilationStats();
return true;
}
bool CompileUnoptimizedCode(CompilationInfo* info) {
DCHECK(AllowCompilation::IsAllowed(info->isolate()));
if (!Compiler::Analyze(info->parse_info()) ||
!GenerateUnoptimizedCode(info)) {
Isolate* isolate = info->isolate();
if (!isolate->has_pending_exception()) isolate->StackOverflow();
return false;
}
return true;
}
void InstallSharedScopeInfo(CompilationInfo* info,
Handle<SharedFunctionInfo> shared) {
Handle<ScopeInfo> scope_info = info->scope()->scope_info();
......@@ -426,9 +394,50 @@ void InstallUnoptimizedCode(CompilationInfo* info) {
// Install compilation result on the shared function info
InstallSharedCompilationResult(info, shared);
}
// Record the function compilation event.
RecordFunctionCompilation(CodeEventListener::LAZY_COMPILE_TAG, info);
CompilationJob::Status FinalizeUnoptimizedCompilationJob(CompilationJob* job) {
CompilationJob::Status status = job->FinalizeJob();
if (status == CompilationJob::SUCCEEDED) {
InstallUnoptimizedCode(job->info());
job->RecordUnoptimizedCompilationStats();
}
return status;
}
bool GenerateUnoptimizedCode(CompilationInfo* info) {
if (FLAG_validate_asm && info->scope()->asm_module() &&
!info->shared_info()->is_asm_wasm_broken()) {
EnsureFeedbackMetadata(info);
MaybeHandle<FixedArray> wasm_data;
wasm_data = AsmJs::ConvertAsmToWasm(info->parse_info());
if (!wasm_data.is_null()) {
info->shared_info()->set_asm_wasm_data(*wasm_data.ToHandleChecked());
info->SetCode(info->isolate()->builtins()->InstantiateAsmJs());
InstallUnoptimizedCode(info);
return true;
}
}
std::unique_ptr<CompilationJob> job(GetUnoptimizedCompilationJob(info));
if (job->PrepareJob() != CompilationJob::SUCCEEDED) return false;
if (job->ExecuteJob() != CompilationJob::SUCCEEDED) return false;
if (FinalizeUnoptimizedCompilationJob(job.get()) !=
CompilationJob::SUCCEEDED) {
return false;
}
return true;
}
bool CompileUnoptimizedCode(CompilationInfo* info) {
DCHECK(AllowCompilation::IsAllowed(info->isolate()));
if (!Compiler::Analyze(info->parse_info()) ||
!GenerateUnoptimizedCode(info)) {
Isolate* isolate = info->isolate();
if (!isolate->has_pending_exception()) isolate->StackOverflow();
return false;
}
return true;
}
MUST_USE_RESULT MaybeHandle<Code> GetUnoptimizedCode(CompilationInfo* info) {
......@@ -443,21 +452,12 @@ MUST_USE_RESULT MaybeHandle<Code> GetUnoptimizedCode(CompilationInfo* info) {
// Compile either unoptimized code or bytecode for the interpreter.
if (!CompileUnoptimizedCode(info)) return MaybeHandle<Code>();
InstallUnoptimizedCode(info);
// Record the function compilation event.
RecordFunctionCompilation(CodeEventListener::LAZY_COMPILE_TAG, info);
return info->code();
}
CompilationJob::Status FinalizeUnoptimizedCompilationJob(CompilationJob* job) {
CompilationJob::Status status = job->FinalizeJob();
if (status == CompilationJob::SUCCEEDED) {
DCHECK(!job->info()->shared_info()->is_compiled());
InstallUnoptimizedCode(job->info());
job->RecordUnoptimizedCompilationStats();
}
return status;
}
MUST_USE_RESULT MaybeHandle<Code> GetCodeFromOptimizedCodeMap(
Handle<JSFunction> function, BailoutId osr_ast_id) {
Handle<SharedFunctionInfo> shared(function->shared());
......@@ -1113,12 +1113,6 @@ Handle<SharedFunctionInfo> CompileToplevel(CompilationInfo* info) {
return Handle<SharedFunctionInfo>::null();
}
// Update the shared function info with the scope info.
InstallSharedScopeInfo(info, result);
// Install compilation result on the shared function info
InstallSharedCompilationResult(info, result);
Handle<String> script_name =
script->name()->IsString()
? Handle<String>(String::cast(script->name()))
......@@ -1776,10 +1770,6 @@ Handle<SharedFunctionInfo> Compiler::GetSharedFunctionInfo(
if (literal->should_be_used_once_hint()) {
info.code()->MarkToBeExecutedOnce(isolate);
}
// Update the shared function info with the scope info.
InstallSharedScopeInfo(&info, result);
// Install compilation result on the shared function info.
InstallSharedCompilationResult(&info, result);
} else {
return Handle<SharedFunctionInfo>::null();
}
......@@ -1850,8 +1840,13 @@ bool Compiler::FinalizeCompilationJob(CompilationJob* raw_job) {
return FinalizeOptimizedCompilationJob(job.get()) ==
CompilationJob::SUCCEEDED;
} else {
return FinalizeUnoptimizedCompilationJob(job.get()) ==
CompilationJob::SUCCEEDED;
if (FinalizeUnoptimizedCompilationJob(job.get()) ==
CompilationJob::SUCCEEDED) {
RecordFunctionCompilation(CodeEventListener::LAZY_COMPILE_TAG,
job->info());
return true;
}
return false;
}
}
......
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