Chromium Code Reviews| Index: src/compiler.cc |
| diff --git a/src/compiler.cc b/src/compiler.cc |
| index 6f6f9bf9d2d96ec6400cff2acd5ad702f23666a3..0124fe32c7f4899d4f91e01810f14c369897a874 100644 |
| --- a/src/compiler.cc |
| +++ b/src/compiler.cc |
| @@ -15,6 +15,7 @@ |
| #include "src/bootstrapper.h" |
| #include "src/codegen.h" |
| #include "src/compilation-cache.h" |
| +#include "src/compiler-dispatcher/compiler-dispatcher.h" |
| #include "src/compiler-dispatcher/optimizing-compile-dispatcher.h" |
| #include "src/compiler/pipeline.h" |
| #include "src/crankshaft/hydrogen.h" |
| @@ -375,6 +376,11 @@ bool ShouldUseIgnition(CompilationInfo* info) { |
| return shared->PassesFilter(FLAG_ignition_filter); |
| } |
| +bool UseAsmWasm(CompilationInfo* info) { |
| + return FLAG_validate_asm && info->scope()->asm_module() && |
| + !info->shared_info()->is_asm_wasm_broken() && !info->is_debug(); |
| +} |
| + |
| CompilationJob* GetUnoptimizedCompilationJob(CompilationInfo* info) { |
| // Function should have been parsed and analyzed before creating a compilation |
| // job. |
| @@ -428,7 +434,12 @@ void InstallUnoptimizedCode(CompilationInfo* info) { |
| CompilationJob::Status FinalizeUnoptimizedCompilationJob(CompilationJob* job) { |
| CompilationJob::Status status = job->FinalizeJob(); |
| if (status == CompilationJob::SUCCEEDED) { |
| - InstallUnoptimizedCode(job->info()); |
| + CompilationInfo* info = job->info(); |
|
marja
2017/01/10 09:58:54
I'm confused; why is this kind of change needed in
rmcilroy
2017/01/12 12:31:55
The reason is that the MarkToBeExecutedOnce used t
|
| + DCHECK(!info->code().is_null()); |
| + if (info->parse_info()->literal()->should_be_used_once_hint()) { |
| + info->code()->MarkToBeExecutedOnce(info->isolate()); |
| + } |
| + InstallUnoptimizedCode(info); |
| job->RecordUnoptimizedCompilationStats(); |
| } |
| return status; |
| @@ -455,8 +466,7 @@ bool Renumber(ParseInfo* parse_info) { |
| } |
| bool GenerateUnoptimizedCode(CompilationInfo* info) { |
| - if (FLAG_validate_asm && info->scope()->asm_module() && |
| - !info->shared_info()->is_asm_wasm_broken() && !info->is_debug()) { |
| + if (UseAsmWasm(info)) { |
| EnsureFeedbackMetadata(info); |
| MaybeHandle<FixedArray> wasm_data; |
| wasm_data = AsmJs::CompileAsmViaWasm(info); |
| @@ -499,34 +509,51 @@ bool CompileUnoptimizedInnerFunctionsRecursively( |
| shared = |
| isolate->factory()->NewSharedFunctionInfoForLiteral(literal, script); |
| shared->set_is_toplevel(false); |
| + Scope* outer_scope = literal->scope()->GetOuterScopeWithContext(); |
| + if (outer_scope) { |
| + shared->set_outer_scope_info(*outer_scope->scope_info()); |
| + } |
| } |
| - Zone zone(isolate->allocator(), ZONE_NAME); |
| - ParseInfo parse_info(&zone, script); |
| - parse_info.set_literal(literal); |
| - parse_info.set_shared_info(shared); |
| - parse_info.set_function_literal_id(shared->function_literal_id()); |
| - parse_info.set_language_mode(literal->scope()->language_mode()); |
| - parse_info.set_ast_value_factory( |
| + std::unique_ptr<Zone> zone(new Zone(isolate->allocator(), ZONE_NAME)); |
| + std::unique_ptr<ParseInfo> parse_info(new ParseInfo(zone.get(), script)); |
| + std::unique_ptr<CompilationInfo> info( |
| + new CompilationInfo(parse_info.get(), Handle<JSFunction>::null())); |
| + |
| + parse_info->set_literal(literal); |
| + parse_info->set_shared_info(shared); |
| + parse_info->set_function_literal_id(shared->function_literal_id()); |
| + parse_info->set_language_mode(literal->scope()->language_mode()); |
| + parse_info->set_ast_value_factory( |
| outer_info->parse_info()->ast_value_factory()); |
| - parse_info.set_ast_value_factory_owned(false); |
| + parse_info->set_ast_value_factory_owned(false); |
| - CompilationInfo info(&parse_info, Handle<JSFunction>::null()); |
| - if (outer_info->will_serialize()) info.PrepareForSerializing(); |
| - if (outer_info->is_debug()) info.MarkAsDebug(); |
| + if (outer_info->will_serialize()) info->PrepareForSerializing(); |
| + if (outer_info->is_debug()) info->MarkAsDebug(); |
| - if (!Renumber(&parse_info) || |
| + if (!Renumber(parse_info.get()) || |
| !CompileUnoptimizedInnerFunctionsRecursively( |
| - parse_info.eager_inner_function_literals(), &info) || |
| - !GenerateUnoptimizedCode(&info)) { |
| + parse_info->eager_inner_function_literals(), info.get())) { |
| if (!isolate->has_pending_exception()) isolate->StackOverflow(); |
| return false; |
| } |
| - DCHECK(!info.code().is_null()); |
| - RecordFunctionCompilation(CodeEventListener::FUNCTION_TAG, &info); |
| - if (literal->should_be_used_once_hint()) { |
| - info.code()->MarkToBeExecutedOnce(isolate); |
| + if (isolate->compiler_dispatcher()->IsEnabled() && |
| + !UseAsmWasm(info.get())) { |
| + std::unique_ptr<CompilationJob> job( |
| + Compiler::PrepareUnoptimizedCompilationJob(info.get())); |
| + if (!job || |
| + !isolate->compiler_dispatcher()->Enqueue( |
| + zone.release(), parse_info.release(), info.release(), |
| + job.release())) { |
| + if (!isolate->has_pending_exception()) isolate->StackOverflow(); |
|
marja
2017/01/10 09:58:54
This logic ("if isolate doesn't have a pending exc
rmcilroy
2017/01/12 12:31:55
I agree this is getting scattered everywhere. I've
|
| + return false; |
| + } |
| + } else { |
| + if (!GenerateUnoptimizedCode(info.get())) { |
| + if (!isolate->has_pending_exception()) isolate->StackOverflow(); |
| + return false; |
| + } |
| } |
| } |
| return true; |
| @@ -544,6 +571,13 @@ bool CompileUnoptimizedCode(CompilationInfo* info) { |
| return false; |
| } |
| + if (isolate->compiler_dispatcher()->IsEnabled()) { |
| + // TODO(rmcilroy): Remove this once the enqueued tasks can keep the parsed |
| + // zone and handles alive and replace with a check in CompileLazy to finish |
| + // the task itself. |
| + isolate->compiler_dispatcher()->FinishAllNow(); |
| + } |
| + |
| return true; |
| } |