| Index: src/compiler/pipeline.cc
|
| diff --git a/src/compiler/pipeline.cc b/src/compiler/pipeline.cc
|
| index 74847a69a88af1e3dc022dc37a36d2c27f7596ac..6bfc0ff009bf9bebf83890670431a5bba6417540 100644
|
| --- a/src/compiler/pipeline.cc
|
| +++ b/src/compiler/pipeline.cc
|
| @@ -83,28 +83,16 @@ class PipelineData {
|
| outer_zone_(info_->zone()),
|
| zone_pool_(zone_pool),
|
| pipeline_statistics_(pipeline_statistics),
|
| - compilation_failed_(false),
|
| - code_(Handle<Code>::null()),
|
| graph_zone_scope_(zone_pool_),
|
| graph_zone_(graph_zone_scope_.zone()),
|
| - graph_(nullptr),
|
| - loop_assignment_(nullptr),
|
| - simplified_(nullptr),
|
| - machine_(nullptr),
|
| - common_(nullptr),
|
| - javascript_(nullptr),
|
| - jsgraph_(nullptr),
|
| - schedule_(nullptr),
|
| 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()),
|
| - register_allocation_data_(nullptr) {
|
| + register_allocation_zone_(register_allocation_zone_scope_.zone()) {
|
| PhaseScope scope(pipeline_statistics, "init pipeline data");
|
| graph_ = new (graph_zone_) Graph(graph_zone_);
|
| - source_positions_.Reset(new SourcePositionTable(graph_));
|
| + source_positions_ = new SourcePositionTable(graph_);
|
| + source_positions_owned_ = true;
|
| simplified_ = new (graph_zone_) SimplifiedOperatorBuilder(graph_zone_);
|
| machine_ = new (graph_zone_) MachineOperatorBuilder(
|
| graph_zone_, MachineType::PointerRepresentation(),
|
| @@ -115,62 +103,48 @@ class PipelineData {
|
| JSGraph(isolate_, graph_, common_, javascript_, simplified_, machine_);
|
| }
|
|
|
| + // For WASM compile entry point.
|
| + PipelineData(ZonePool* zone_pool, CompilationInfo* info, Graph* graph,
|
| + SourcePositionTable* source_positions)
|
| + : isolate_(info->isolate()),
|
| + info_(info),
|
| + zone_pool_(zone_pool),
|
| + graph_zone_scope_(zone_pool_),
|
| + graph_(graph),
|
| + source_positions_(source_positions),
|
| + instruction_zone_scope_(zone_pool_),
|
| + instruction_zone_(instruction_zone_scope_.zone()),
|
| + register_allocation_zone_scope_(zone_pool_),
|
| + register_allocation_zone_(register_allocation_zone_scope_.zone()) {}
|
| +
|
| // For machine graph testing entry point.
|
| PipelineData(ZonePool* zone_pool, CompilationInfo* info, Graph* graph,
|
| Schedule* schedule)
|
| : isolate_(info->isolate()),
|
| info_(info),
|
| - outer_zone_(nullptr),
|
| zone_pool_(zone_pool),
|
| - pipeline_statistics_(nullptr),
|
| - compilation_failed_(false),
|
| - code_(Handle<Code>::null()),
|
| graph_zone_scope_(zone_pool_),
|
| - graph_zone_(nullptr),
|
| graph_(graph),
|
| source_positions_(new SourcePositionTable(graph_)),
|
| - loop_assignment_(nullptr),
|
| - simplified_(nullptr),
|
| - machine_(nullptr),
|
| - common_(nullptr),
|
| - javascript_(nullptr),
|
| - jsgraph_(nullptr),
|
| + source_positions_owned_(true),
|
| 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()),
|
| - register_allocation_data_(nullptr) {}
|
| + register_allocation_zone_(register_allocation_zone_scope_.zone()) {}
|
|
|
| // For register allocation testing entry point.
|
| PipelineData(ZonePool* zone_pool, CompilationInfo* info,
|
| InstructionSequence* sequence)
|
| : isolate_(info->isolate()),
|
| info_(info),
|
| - outer_zone_(nullptr),
|
| zone_pool_(zone_pool),
|
| - pipeline_statistics_(nullptr),
|
| - compilation_failed_(false),
|
| - code_(Handle<Code>::null()),
|
| graph_zone_scope_(zone_pool_),
|
| - graph_zone_(nullptr),
|
| - graph_(nullptr),
|
| - loop_assignment_(nullptr),
|
| - simplified_(nullptr),
|
| - machine_(nullptr),
|
| - common_(nullptr),
|
| - javascript_(nullptr),
|
| - jsgraph_(nullptr),
|
| - schedule_(nullptr),
|
| 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()),
|
| - register_allocation_data_(nullptr) {}
|
| + register_allocation_zone_(register_allocation_zone_scope_.zone()) {}
|
|
|
| ~PipelineData() {
|
| DeleteRegisterAllocationZone();
|
| @@ -196,7 +170,8 @@ class PipelineData {
|
| Zone* graph_zone() const { return graph_zone_; }
|
| Graph* graph() const { return graph_; }
|
| SourcePositionTable* source_positions() const {
|
| - return source_positions_.get();
|
| + DCHECK_NOT_NULL(source_positions_);
|
| + return source_positions_;
|
| }
|
| MachineOperatorBuilder* machine() const { return machine_; }
|
| CommonOperatorBuilder* common() const { return common_; }
|
| @@ -239,7 +214,9 @@ class PipelineData {
|
|
|
| void DeleteGraphZone() {
|
| // Destroy objects with destructors first.
|
| - source_positions_.Reset(nullptr);
|
| + if (source_positions_owned_ && source_positions_) delete source_positions_;
|
| + source_positions_ = nullptr;
|
| + source_positions_owned_ = false;
|
| if (graph_zone_ == nullptr) return;
|
| // Destroy zone and clear pointers.
|
| graph_zone_scope_.Destroy();
|
| @@ -306,27 +283,29 @@ class PipelineData {
|
| private:
|
| Isolate* isolate_;
|
| CompilationInfo* info_;
|
| - Zone* outer_zone_;
|
| + Zone* outer_zone_ = nullptr;
|
| ZonePool* const zone_pool_;
|
| - PipelineStatistics* pipeline_statistics_;
|
| - bool compilation_failed_;
|
| + PipelineStatistics* pipeline_statistics_ = nullptr;
|
| + bool compilation_failed_ = false;
|
| Handle<Code> code_;
|
|
|
| // 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.
|
| ZonePool::Scope graph_zone_scope_;
|
| - Zone* graph_zone_;
|
| - Graph* graph_;
|
| + Zone* graph_zone_ = nullptr;
|
| + Graph* graph_ = nullptr;
|
| // TODO(dcarney): make this into a ZoneObject.
|
| - base::SmartPointer<SourcePositionTable> source_positions_;
|
| - LoopAssignmentAnalysis* loop_assignment_;
|
| + SourcePositionTable* source_positions_ = nullptr;
|
| + // remember whether we allocated the SourcePositionTable ourselves.
|
| + bool source_positions_owned_ = false;
|
| + LoopAssignmentAnalysis* loop_assignment_ = nullptr;
|
| TypeHintAnalysis* type_hint_analysis_ = nullptr;
|
| - SimplifiedOperatorBuilder* simplified_;
|
| - MachineOperatorBuilder* machine_;
|
| - CommonOperatorBuilder* common_;
|
| - JSOperatorBuilder* javascript_;
|
| - JSGraph* jsgraph_;
|
| - Schedule* schedule_;
|
| + SimplifiedOperatorBuilder* simplified_ = nullptr;
|
| + MachineOperatorBuilder* machine_ = nullptr;
|
| + CommonOperatorBuilder* common_ = nullptr;
|
| + JSOperatorBuilder* javascript_ = nullptr;
|
| + JSGraph* jsgraph_ = nullptr;
|
| + Schedule* schedule_ = nullptr;
|
|
|
| // All objects in the following group of fields are allocated in
|
| // instruction_zone_. They are all set to nullptr when the instruction_zone_
|
| @@ -334,15 +313,15 @@ class PipelineData {
|
| // destroyed.
|
| ZonePool::Scope instruction_zone_scope_;
|
| Zone* instruction_zone_;
|
| - InstructionSequence* sequence_;
|
| - Frame* frame_;
|
| + InstructionSequence* sequence_ = nullptr;
|
| + Frame* frame_ = nullptr;
|
|
|
| // All objects in the following group of fields are allocated in
|
| // register_allocation_zone_. They are all set to nullptr when the zone is
|
| // destroyed.
|
| ZonePool::Scope register_allocation_zone_scope_;
|
| Zone* register_allocation_zone_;
|
| - RegisterAllocationData* register_allocation_data_;
|
| + RegisterAllocationData* register_allocation_data_ = nullptr;
|
|
|
| int CalculateFixedFrameSize(CallDescriptor* descriptor) {
|
| if (descriptor->IsJSFunctionCall()) {
|
| @@ -1314,6 +1293,29 @@ Handle<Code> Pipeline::GenerateCode() {
|
| Linkage::ComputeIncoming(data.instruction_zone(), info()));
|
| }
|
|
|
| +Handle<Code> Pipeline::GenerateWASMCode(CompilationInfo* info,
|
| + CallDescriptor* call_descriptor,
|
| + Graph* graph,
|
| + SourcePositionTable* source_positions) {
|
| + // Construct a pipeline for scheduling and code generation.
|
| + ZonePool zone_pool(info->isolate()->allocator());
|
| + PipelineData data(&zone_pool, info, graph, source_positions);
|
| + base::SmartPointer<PipelineStatistics> pipeline_statistics;
|
| + if (FLAG_turbo_stats) {
|
| + pipeline_statistics.Reset(new PipelineStatistics(info, &zone_pool));
|
| + pipeline_statistics->BeginPhaseKind("test codegen");
|
| + }
|
| +
|
| + Pipeline pipeline(info);
|
| + pipeline.data_ = &data;
|
| + if (data.schedule() == nullptr) {
|
| + // TODO(rossberg): Should this really be untyped?
|
| + pipeline.RunPrintAndVerify("Machine", true);
|
| + }
|
| +
|
| + Handle<Code> code = pipeline.ScheduleAndGenerateCode(call_descriptor);
|
| + return code;
|
| +}
|
|
|
| Handle<Code> Pipeline::GenerateCodeForCodeStub(Isolate* isolate,
|
| CallDescriptor* call_descriptor,
|
|
|