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

Unified Diff: src/compiler/pipeline.cc

Issue 2229243003: [turbofan] Split CodeGenerator::GenerateCode into AssembleCode and FinishCodeObject. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Extend parallel compilation of wasm in a separate CL Created 4 years, 4 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/code-generator.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/pipeline.cc
diff --git a/src/compiler/pipeline.cc b/src/compiler/pipeline.cc
index 20a0db9813c19ee60c890d596f7eac12c1a2e670..2724dc58ff801f1e1cf2a3e09de47abb45290460 100644
--- a/src/compiler/pipeline.cc
+++ b/src/compiler/pipeline.cc
@@ -89,10 +89,13 @@ class PipelineData {
outer_zone_(info_->zone()),
zone_pool_(zone_pool),
pipeline_statistics_(pipeline_statistics),
+ code_generator_(info->zone(), info),
graph_zone_scope_(zone_pool_),
graph_zone_(graph_zone_scope_.zone()),
instruction_zone_scope_(zone_pool_),
instruction_zone_(instruction_zone_scope_.zone()),
+ sequence_(nullptr),
+ frame_(nullptr),
register_allocation_zone_scope_(zone_pool_),
register_allocation_zone_(register_allocation_zone_scope_.zone()) {
PhaseScope scope(pipeline_statistics, "init pipeline data");
@@ -116,11 +119,14 @@ class PipelineData {
info_(info),
debug_name_(info_->GetDebugName()),
zone_pool_(zone_pool),
+ code_generator_(info->zone(), info),
graph_zone_scope_(zone_pool_),
graph_(graph),
source_positions_(source_positions),
instruction_zone_scope_(zone_pool_),
instruction_zone_(instruction_zone_scope_.zone()),
+ sequence_(nullptr),
+ frame_(nullptr),
register_allocation_zone_scope_(zone_pool_),
register_allocation_zone_(register_allocation_zone_scope_.zone()) {}
@@ -131,12 +137,15 @@ class PipelineData {
info_(info),
debug_name_(info_->GetDebugName()),
zone_pool_(zone_pool),
+ code_generator_(info->zone(), info),
graph_zone_scope_(zone_pool_),
graph_(graph),
source_positions_(new (info->zone()) SourcePositionTable(graph_)),
schedule_(schedule),
instruction_zone_scope_(zone_pool_),
instruction_zone_(instruction_zone_scope_.zone()),
+ sequence_(nullptr),
+ frame_(nullptr),
register_allocation_zone_scope_(zone_pool_),
register_allocation_zone_(register_allocation_zone_scope_.zone()) {}
@@ -147,10 +156,12 @@ class PipelineData {
info_(info),
debug_name_(info_->GetDebugName()),
zone_pool_(zone_pool),
+ code_generator_(info->zone(), info),
graph_zone_scope_(zone_pool_),
instruction_zone_scope_(zone_pool_),
instruction_zone_(sequence->zone()),
sequence_(sequence),
+ frame_(nullptr),
register_allocation_zone_scope_(zone_pool_),
register_allocation_zone_(register_allocation_zone_scope_.zone()) {}
@@ -211,6 +222,10 @@ class PipelineData {
Zone* instruction_zone() const { return instruction_zone_; }
InstructionSequence* sequence() const { return sequence_; }
Frame* frame() const { return frame_; }
+ CodeGenerator* code_generator() { return &code_generator_; }
+ bool assemble_code_successful() {
+ return code_generator_.assemble_code_successful();
+ }
Zone* register_allocation_zone() const { return register_allocation_zone_; }
RegisterAllocationData* register_allocation_data() const {
@@ -313,6 +328,7 @@ class PipelineData {
PipelineStatistics* pipeline_statistics_ = nullptr;
bool compilation_failed_ = false;
Handle<Code> code_ = Handle<Code>::null();
+ CodeGenerator code_generator_;
// All objects in the following group of fields are allocated in graph_zone_.
// They are all set to nullptr when the graph_zone_ is destroyed.
@@ -331,12 +347,11 @@ class PipelineData {
// All objects in the following group of fields are allocated in
// instruction_zone_. They are all set to nullptr when the instruction_zone_
- // is
- // destroyed.
+ // is destroyed.
ZonePool::Scope instruction_zone_scope_;
Zone* instruction_zone_;
- InstructionSequence* sequence_ = nullptr;
- Frame* frame_ = nullptr;
+ InstructionSequence* sequence_;
+ Frame* frame_;
// All objects in the following group of fields are allocated in
// register_allocation_zone_. They are all set to nullptr when the zone is
@@ -383,7 +398,8 @@ class PipelineImpl final {
bool OptimizeGraph(Linkage* linkage);
// Perform the actual code generation and return handle to a code object.
- Handle<Code> GenerateCode(Linkage* linkage);
+ bool AssembleCode(Linkage* linkage);
+ Handle<Code> FinishCodeObject();
bool ScheduleAndSelectInstructions(Linkage* linkage);
void RunPrintAndVerify(const char* phase, bool untyped = false);
@@ -639,7 +655,8 @@ PipelineCompilationJob::Status PipelineCompilationJob::OptimizeGraphImpl() {
}
PipelineCompilationJob::Status PipelineCompilationJob::GenerateCodeImpl() {
- Handle<Code> code = pipeline_.GenerateCode(linkage_);
+ pipeline_.AssembleCode(linkage_);
+ Handle<Code> code = pipeline_.FinishCodeObject();
if (code.is_null()) {
if (info()->bailout_reason() == kNoReason) {
return AbortOptimization(kCodeGenerationFailed);
@@ -699,7 +716,8 @@ PipelineWasmCompilationJob::OptimizeGraphImpl() {
PipelineWasmCompilationJob::Status
PipelineWasmCompilationJob::GenerateCodeImpl() {
- pipeline_.GenerateCode(&linkage_);
+ pipeline_.AssembleCode(&linkage_);
+ pipeline_.FinishCodeObject();
return SUCCEEDED;
}
@@ -1397,17 +1415,23 @@ struct JumpThreadingPhase {
}
};
-
-struct GenerateCodePhase {
+struct AssembleCodePhase {
static const char* phase_name() { return "generate code"; }
void Run(PipelineData* data, Zone* temp_zone, Linkage* linkage) {
- CodeGenerator generator(data->frame(), linkage, data->sequence(),
- data->info());
- data->set_code(generator.GenerateCode());
+ data->code_generator()->Initialize(data->frame(), linkage,
+ data->sequence());
+ data->code_generator()->AssembleCode();
}
};
+struct FinishCodeObjectPhase {
+ static const char* phase_name() { return "generate code"; }
+
+ void Run(PipelineData* data, Zone* temp_zone) {
+ data->set_code(data->code_generator()->FinishCodeObject());
+ }
+};
struct PrintGraphPhase {
static const char* phase_name() { return nullptr; }
@@ -1660,7 +1684,8 @@ Handle<Code> Pipeline::GenerateCodeForTesting(CompilationInfo* info) {
if (!pipeline.CreateGraph()) return Handle<Code>::null();
if (!pipeline.OptimizeGraph(&linkage)) return Handle<Code>::null();
- return pipeline.GenerateCode(&linkage);
+ pipeline.AssembleCode(&linkage);
+ return pipeline.FinishCodeObject();
}
// static
@@ -1788,13 +1813,23 @@ bool PipelineImpl::ScheduleAndSelectInstructions(Linkage* linkage) {
return true;
}
-Handle<Code> PipelineImpl::GenerateCode(Linkage* linkage) {
+bool PipelineImpl::AssembleCode(Linkage* linkage) {
+ PipelineData* data = this->data_;
+
+ data->BeginPhaseKind("assemble code");
+
+ // Assemble machine code.
+ Run<AssembleCodePhase>(linkage);
+ return data->assemble_code_successful();
+}
+
+Handle<Code> PipelineImpl::FinishCodeObject() {
PipelineData* data = this->data_;
- data->BeginPhaseKind("code generation");
+ data->BeginPhaseKind("finish code generation");
- // Generate final machine code.
- Run<GenerateCodePhase>(linkage);
+ // Generate final code object.
+ Run<FinishCodeObjectPhase>();
Handle<Code> code = data->code();
if (data->profiler_data()) {
@@ -1841,7 +1876,8 @@ Handle<Code> PipelineImpl::ScheduleAndGenerateCode(
if (!ScheduleAndSelectInstructions(&linkage)) return Handle<Code>();
// Generate the final machine code.
- return GenerateCode(&linkage);
+ AssembleCode(&linkage);
+ return FinishCodeObject();
}
void PipelineImpl::AllocateRegisters(const RegisterConfiguration* config,
« no previous file with comments | « src/compiler/code-generator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698