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

Unified Diff: src/compiler.cc

Issue 2637123002: Revert of [complier] Enable parallel eager inner function compilation with compiler dispatcher. (Closed)
Patch Set: Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler.h ('k') | src/compiler-dispatcher/compiler-dispatcher.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler.cc
diff --git a/src/compiler.cc b/src/compiler.cc
index 9fe7904722aefa5496270f7a451acf9976ff2739..6f123ea2b3e6ad5db98cd7ac1d048fed70ab0e6a 100644
--- a/src/compiler.cc
+++ b/src/compiler.cc
@@ -15,7 +15,6 @@
#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"
@@ -376,20 +375,6 @@
return shared->PassesFilter(FLAG_ignition_filter);
}
-bool UseAsmWasm(DeclarationScope* scope, Handle<SharedFunctionInfo> shared_info,
- bool is_debug) {
- return FLAG_validate_asm && scope->asm_module() &&
- !shared_info->is_asm_wasm_broken() && !is_debug;
-}
-
-bool UseCompilerDispatcher(CompilerDispatcher* dispatcher,
- DeclarationScope* scope,
- Handle<SharedFunctionInfo> shared_info,
- bool is_debug, bool will_serialize) {
- return dispatcher->IsEnabled() && !is_debug && !will_serialize &&
- !UseAsmWasm(scope, shared_info, is_debug);
-}
-
CompilationJob* GetUnoptimizedCompilationJob(CompilationInfo* info) {
// Function should have been parsed and analyzed before creating a compilation
// job.
@@ -442,34 +427,30 @@
CompilationJob::Status FinalizeUnoptimizedCompilationJob(CompilationJob* job) {
CompilationJob::Status status = job->FinalizeJob();
if (status == CompilationJob::SUCCEEDED) {
- CompilationInfo* info = job->info();
- EnsureFeedbackMetadata(info);
- DCHECK(!info->code().is_null());
- if (info->parse_info()->literal()->should_be_used_once_hint()) {
- info->code()->MarkToBeExecutedOnce(info->isolate());
- }
- InstallUnoptimizedCode(info);
- RecordFunctionCompilation(CodeEventListener::FUNCTION_TAG, info);
+ EnsureFeedbackMetadata(job->info());
+ InstallUnoptimizedCode(job->info());
job->RecordUnoptimizedCompilationStats();
}
return status;
}
-bool Renumber(Isolate* isolate, Zone* zone, FunctionLiteral* literal,
- Handle<SharedFunctionInfo> shared_info,
+bool Renumber(ParseInfo* parse_info,
Compiler::EagerInnerFunctionLiterals* eager_literals) {
- RuntimeCallTimerScope runtimeTimer(isolate,
+ RuntimeCallTimerScope runtimeTimer(parse_info->isolate(),
&RuntimeCallStats::CompileRenumber);
- if (!AstNumbering::Renumber(isolate->stack_guard()->real_climit(), zone,
- literal, eager_literals)) {
+ if (!AstNumbering::Renumber(
+ parse_info->isolate()->stack_guard()->real_climit(),
+ parse_info->zone(), parse_info->literal(), eager_literals)) {
return false;
}
+ Handle<SharedFunctionInfo> shared_info = parse_info->shared_info();
if (!shared_info.is_null()) {
- shared_info->set_ast_node_count(literal->ast_node_count());
- if (literal->dont_optimize_reason() != kNoReason) {
- shared_info->DisableOptimization(literal->dont_optimize_reason());
- }
- if (literal->flags() & AstProperties::kMustUseIgnitionTurbo) {
+ FunctionLiteral* lit = parse_info->literal();
+ shared_info->set_ast_node_count(lit->ast_node_count());
+ if (lit->dont_optimize_reason() != kNoReason) {
+ shared_info->DisableOptimization(lit->dont_optimize_reason());
+ }
+ if (lit->flags() & AstProperties::kMustUseIgnitionTurbo) {
shared_info->set_must_use_ignition_turbo(true);
}
}
@@ -477,7 +458,8 @@
}
bool GenerateUnoptimizedCode(CompilationInfo* info) {
- if (UseAsmWasm(info->scope(), info->shared_info(), info->is_debug())) {
+ if (FLAG_validate_asm && info->scope()->asm_module() &&
+ !info->shared_info()->is_asm_wasm_broken() && !info->is_debug()) {
EnsureFeedbackMetadata(info);
MaybeHandle<FixedArray> wasm_data;
wasm_data = AsmJs::CompileAsmViaWasm(info);
@@ -504,54 +486,54 @@
CompilationInfo* outer_info) {
Isolate* isolate = outer_info->isolate();
Handle<Script> script = outer_info->script();
- bool is_debug = outer_info->is_debug();
- bool will_serialize = outer_info->will_serialize();
RuntimeCallTimerScope runtimeTimer(isolate,
&RuntimeCallStats::CompileInnerFunction);
for (auto it : *literals) {
FunctionLiteral* literal = it->value();
- Handle<SharedFunctionInfo> shared =
- Compiler::GetSharedFunctionInfo(literal, script, outer_info);
- if (shared->is_compiled()) continue;
+
+ // Find any previously allocated shared function info for the given literal.
+ Handle<SharedFunctionInfo> shared;
+ MaybeHandle<SharedFunctionInfo> maybe_existing =
+ script->FindSharedFunctionInfo(isolate, literal);
+ if (maybe_existing.ToHandle(&shared)) {
+ DCHECK(!shared->is_toplevel());
+ // If we found an existing shared function info with compiled code,
+ // we are done.
+ if (shared->is_compiled()) continue;
+ } else {
+ shared =
+ isolate->factory()->NewSharedFunctionInfoForLiteral(literal, script);
+ shared->set_is_toplevel(false);
+ }
+
+ 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(
+ outer_info->parse_info()->ast_value_factory());
+ 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();
+
Compiler::EagerInnerFunctionLiterals inner_literals;
- if (!Renumber(isolate, outer_info->zone(), literal, shared,
- &inner_literals) ||
+ if (!Renumber(&parse_info, &inner_literals) ||
!CompileUnoptimizedInnerFunctionsRecursively(&inner_literals,
- outer_info)) {
+ outer_info) ||
+ !GenerateUnoptimizedCode(&info)) {
if (!isolate->has_pending_exception()) isolate->StackOverflow();
return false;
}
- // Try to enqueue the eager function on the compiler dispatcher.
- CompilerDispatcher* dispatcher = isolate->compiler_dispatcher();
- if (UseCompilerDispatcher(dispatcher, literal->scope(), shared, is_debug,
- will_serialize) &&
- dispatcher->EnqueueAndStep(shared, literal)) {
- // If we have successfully queued up the function for compilation on the
- // compiler dispatcher then we are done.
- continue;
- } else {
- // Otherwise generate unoptimized code now.
- Zone zone(isolate->allocator(), ZONE_NAME);
- ParseInfo parse_info(&zone, script);
- CompilationInfo info(&parse_info, 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);
-
- if (will_serialize) info.PrepareForSerializing();
- if (is_debug) info.MarkAsDebug();
-
- if (!GenerateUnoptimizedCode(&info)) {
- 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);
}
}
return true;
@@ -565,15 +547,6 @@
if (!Compiler::Analyze(info->parse_info(), &inner_literals) ||
!CompileUnoptimizedInnerFunctionsRecursively(&inner_literals, info) ||
!GenerateUnoptimizedCode(info)) {
- if (!isolate->has_pending_exception()) isolate->StackOverflow();
- return false;
- }
-
- // 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.
- if (isolate->compiler_dispatcher()->IsEnabled() &&
- !isolate->compiler_dispatcher()->FinishAllNow()) {
if (!isolate->has_pending_exception()) isolate->StackOverflow();
return false;
}
@@ -1153,10 +1126,7 @@
&RuntimeCallStats::CompileAnalyse);
if (!Rewriter::Rewrite(info)) return false;
DeclarationScope::Analyze(info, AnalyzeMode::kRegular);
- if (!Renumber(info->isolate(), info->zone(), info->literal(),
- info->shared_info(), eager_literals)) {
- return false;
- }
+ if (!Renumber(info, eager_literals)) return false;
DCHECK_NOT_NULL(info->scope());
return true;
}
@@ -1763,8 +1733,13 @@
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;
}
}
« no previous file with comments | « src/compiler.h ('k') | src/compiler-dispatcher/compiler-dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698