| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/compiler/pipeline.h" | 5 #include "src/compiler/pipeline.h" |
| 6 | 6 |
| 7 #include <fstream> // NOLINT(readability/streams) | 7 #include <fstream> // NOLINT(readability/streams) |
| 8 #include <sstream> | 8 #include <sstream> |
| 9 | 9 |
| 10 #include "src/base/adapters.h" | 10 #include "src/base/adapters.h" |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 schedule_(nullptr), | 97 schedule_(nullptr), |
| 98 instruction_zone_scope_(zone_pool_), | 98 instruction_zone_scope_(zone_pool_), |
| 99 instruction_zone_(instruction_zone_scope_.zone()), | 99 instruction_zone_(instruction_zone_scope_.zone()), |
| 100 sequence_(nullptr), | 100 sequence_(nullptr), |
| 101 frame_(nullptr), | 101 frame_(nullptr), |
| 102 register_allocation_zone_scope_(zone_pool_), | 102 register_allocation_zone_scope_(zone_pool_), |
| 103 register_allocation_zone_(register_allocation_zone_scope_.zone()), | 103 register_allocation_zone_(register_allocation_zone_scope_.zone()), |
| 104 register_allocation_data_(nullptr) { | 104 register_allocation_data_(nullptr) { |
| 105 PhaseScope scope(pipeline_statistics, "init pipeline data"); | 105 PhaseScope scope(pipeline_statistics, "init pipeline data"); |
| 106 graph_ = new (graph_zone_) Graph(graph_zone_); | 106 graph_ = new (graph_zone_) Graph(graph_zone_); |
| 107 source_positions_.Reset(new SourcePositionTable(graph_)); | 107 source_positions_ = new (graph_zone_->New(sizeof(SourcePositionTable))) |
| 108 SourcePositionTable(graph_); |
| 108 simplified_ = new (graph_zone_) SimplifiedOperatorBuilder(graph_zone_); | 109 simplified_ = new (graph_zone_) SimplifiedOperatorBuilder(graph_zone_); |
| 109 machine_ = new (graph_zone_) MachineOperatorBuilder( | 110 machine_ = new (graph_zone_) MachineOperatorBuilder( |
| 110 graph_zone_, MachineType::PointerRepresentation(), | 111 graph_zone_, MachineType::PointerRepresentation(), |
| 111 InstructionSelector::SupportedMachineOperatorFlags()); | 112 InstructionSelector::SupportedMachineOperatorFlags()); |
| 112 common_ = new (graph_zone_) CommonOperatorBuilder(graph_zone_); | 113 common_ = new (graph_zone_) CommonOperatorBuilder(graph_zone_); |
| 113 javascript_ = new (graph_zone_) JSOperatorBuilder(graph_zone_); | 114 javascript_ = new (graph_zone_) JSOperatorBuilder(graph_zone_); |
| 114 jsgraph_ = new (graph_zone_) | 115 jsgraph_ = new (graph_zone_) |
| 115 JSGraph(isolate_, graph_, common_, javascript_, simplified_, machine_); | 116 JSGraph(isolate_, graph_, common_, javascript_, simplified_, machine_); |
| 116 } | 117 } |
| 117 | 118 |
| 118 // For machine graph testing entry point. | 119 // For machine graph testing entry point. |
| 119 PipelineData(ZonePool* zone_pool, CompilationInfo* info, Graph* graph, | 120 PipelineData(ZonePool* zone_pool, CompilationInfo* info, Graph* graph, |
| 120 Schedule* schedule) | 121 Schedule* schedule) |
| 121 : isolate_(info->isolate()), | 122 : isolate_(info->isolate()), |
| 122 info_(info), | 123 info_(info), |
| 123 outer_zone_(nullptr), | 124 outer_zone_(nullptr), |
| 124 zone_pool_(zone_pool), | 125 zone_pool_(zone_pool), |
| 125 pipeline_statistics_(nullptr), | 126 pipeline_statistics_(nullptr), |
| 126 compilation_failed_(false), | 127 compilation_failed_(false), |
| 127 code_(Handle<Code>::null()), | 128 code_(Handle<Code>::null()), |
| 128 graph_zone_scope_(zone_pool_), | 129 graph_zone_scope_(zone_pool_), |
| 129 graph_zone_(nullptr), | 130 graph_zone_(nullptr), |
| 130 graph_(graph), | 131 graph_(graph), |
| 131 source_positions_(new SourcePositionTable(graph_)), | 132 source_positions_(new (info->zone()->New(sizeof(SourcePositionTable))) |
| 133 SourcePositionTable(graph_)), |
| 132 loop_assignment_(nullptr), | 134 loop_assignment_(nullptr), |
| 133 simplified_(nullptr), | 135 simplified_(nullptr), |
| 134 machine_(nullptr), | 136 machine_(nullptr), |
| 135 common_(nullptr), | 137 common_(nullptr), |
| 136 javascript_(nullptr), | 138 javascript_(nullptr), |
| 137 jsgraph_(nullptr), | 139 jsgraph_(nullptr), |
| 138 schedule_(schedule), | 140 schedule_(schedule), |
| 139 instruction_zone_scope_(zone_pool_), | 141 instruction_zone_scope_(zone_pool_), |
| 140 instruction_zone_(instruction_zone_scope_.zone()), | 142 instruction_zone_(instruction_zone_scope_.zone()), |
| 141 sequence_(nullptr), | 143 sequence_(nullptr), |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 void set_code(Handle<Code> code) { | 190 void set_code(Handle<Code> code) { |
| 189 DCHECK(code_.is_null()); | 191 DCHECK(code_.is_null()); |
| 190 code_ = code; | 192 code_ = code; |
| 191 } | 193 } |
| 192 | 194 |
| 193 // RawMachineAssembler generally produces graphs which cannot be verified. | 195 // RawMachineAssembler generally produces graphs which cannot be verified. |
| 194 bool MayHaveUnverifiableGraph() const { return outer_zone_ == nullptr; } | 196 bool MayHaveUnverifiableGraph() const { return outer_zone_ == nullptr; } |
| 195 | 197 |
| 196 Zone* graph_zone() const { return graph_zone_; } | 198 Zone* graph_zone() const { return graph_zone_; } |
| 197 Graph* graph() const { return graph_; } | 199 Graph* graph() const { return graph_; } |
| 198 SourcePositionTable* source_positions() const { | 200 SourcePositionTable* source_positions() const { return source_positions_; } |
| 199 return source_positions_.get(); | |
| 200 } | |
| 201 MachineOperatorBuilder* machine() const { return machine_; } | 201 MachineOperatorBuilder* machine() const { return machine_; } |
| 202 CommonOperatorBuilder* common() const { return common_; } | 202 CommonOperatorBuilder* common() const { return common_; } |
| 203 JSOperatorBuilder* javascript() const { return javascript_; } | 203 JSOperatorBuilder* javascript() const { return javascript_; } |
| 204 JSGraph* jsgraph() const { return jsgraph_; } | 204 JSGraph* jsgraph() const { return jsgraph_; } |
| 205 MaybeHandle<Context> native_context() const { | 205 MaybeHandle<Context> native_context() const { |
| 206 if (info()->is_native_context_specializing()) { | 206 if (info()->is_native_context_specializing()) { |
| 207 return handle(info()->native_context(), isolate()); | 207 return handle(info()->native_context(), isolate()); |
| 208 } | 208 } |
| 209 return MaybeHandle<Context>(); | 209 return MaybeHandle<Context>(); |
| 210 } | 210 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 231 Zone* instruction_zone() const { return instruction_zone_; } | 231 Zone* instruction_zone() const { return instruction_zone_; } |
| 232 InstructionSequence* sequence() const { return sequence_; } | 232 InstructionSequence* sequence() const { return sequence_; } |
| 233 Frame* frame() const { return frame_; } | 233 Frame* frame() const { return frame_; } |
| 234 | 234 |
| 235 Zone* register_allocation_zone() const { return register_allocation_zone_; } | 235 Zone* register_allocation_zone() const { return register_allocation_zone_; } |
| 236 RegisterAllocationData* register_allocation_data() const { | 236 RegisterAllocationData* register_allocation_data() const { |
| 237 return register_allocation_data_; | 237 return register_allocation_data_; |
| 238 } | 238 } |
| 239 | 239 |
| 240 void DeleteGraphZone() { | 240 void DeleteGraphZone() { |
| 241 // Destroy objects with destructors first. | |
| 242 source_positions_.Reset(nullptr); | |
| 243 if (graph_zone_ == nullptr) return; | 241 if (graph_zone_ == nullptr) return; |
| 244 // Destroy zone and clear pointers. | |
| 245 graph_zone_scope_.Destroy(); | 242 graph_zone_scope_.Destroy(); |
| 246 graph_zone_ = nullptr; | 243 graph_zone_ = nullptr; |
| 247 graph_ = nullptr; | 244 graph_ = nullptr; |
| 245 source_positions_ = nullptr; |
| 248 loop_assignment_ = nullptr; | 246 loop_assignment_ = nullptr; |
| 249 type_hint_analysis_ = nullptr; | 247 type_hint_analysis_ = nullptr; |
| 250 simplified_ = nullptr; | 248 simplified_ = nullptr; |
| 251 machine_ = nullptr; | 249 machine_ = nullptr; |
| 252 common_ = nullptr; | 250 common_ = nullptr; |
| 253 javascript_ = nullptr; | 251 javascript_ = nullptr; |
| 254 jsgraph_ = nullptr; | 252 jsgraph_ = nullptr; |
| 255 schedule_ = nullptr; | 253 schedule_ = nullptr; |
| 256 } | 254 } |
| 257 | 255 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 ZonePool* const zone_pool_; | 308 ZonePool* const zone_pool_; |
| 311 PipelineStatistics* pipeline_statistics_; | 309 PipelineStatistics* pipeline_statistics_; |
| 312 bool compilation_failed_; | 310 bool compilation_failed_; |
| 313 Handle<Code> code_; | 311 Handle<Code> code_; |
| 314 | 312 |
| 315 // All objects in the following group of fields are allocated in graph_zone_. | 313 // All objects in the following group of fields are allocated in graph_zone_. |
| 316 // They are all set to nullptr when the graph_zone_ is destroyed. | 314 // They are all set to nullptr when the graph_zone_ is destroyed. |
| 317 ZonePool::Scope graph_zone_scope_; | 315 ZonePool::Scope graph_zone_scope_; |
| 318 Zone* graph_zone_; | 316 Zone* graph_zone_; |
| 319 Graph* graph_; | 317 Graph* graph_; |
| 320 // TODO(dcarney): make this into a ZoneObject. | 318 SourcePositionTable* source_positions_; |
| 321 base::SmartPointer<SourcePositionTable> source_positions_; | |
| 322 LoopAssignmentAnalysis* loop_assignment_; | 319 LoopAssignmentAnalysis* loop_assignment_; |
| 323 TypeHintAnalysis* type_hint_analysis_ = nullptr; | 320 TypeHintAnalysis* type_hint_analysis_ = nullptr; |
| 324 SimplifiedOperatorBuilder* simplified_; | 321 SimplifiedOperatorBuilder* simplified_; |
| 325 MachineOperatorBuilder* machine_; | 322 MachineOperatorBuilder* machine_; |
| 326 CommonOperatorBuilder* common_; | 323 CommonOperatorBuilder* common_; |
| 327 JSOperatorBuilder* javascript_; | 324 JSOperatorBuilder* javascript_; |
| 328 JSGraph* jsgraph_; | 325 JSGraph* jsgraph_; |
| 329 Schedule* schedule_; | 326 Schedule* schedule_; |
| 330 | 327 |
| 331 // All objects in the following group of fields are allocated in | 328 // All objects in the following group of fields are allocated in |
| (...skipping 1260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1592 } | 1589 } |
| 1593 | 1590 |
| 1594 data->DeleteRegisterAllocationZone(); | 1591 data->DeleteRegisterAllocationZone(); |
| 1595 } | 1592 } |
| 1596 | 1593 |
| 1597 Isolate* Pipeline::isolate() const { return info()->isolate(); } | 1594 Isolate* Pipeline::isolate() const { return info()->isolate(); } |
| 1598 | 1595 |
| 1599 } // namespace compiler | 1596 } // namespace compiler |
| 1600 } // namespace internal | 1597 } // namespace internal |
| 1601 } // namespace v8 | 1598 } // namespace v8 |
| OLD | NEW |