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 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 | 270 |
271 void InitializeInstructionSequence() { | 271 void InitializeInstructionSequence() { |
272 DCHECK(sequence_ == nullptr); | 272 DCHECK(sequence_ == nullptr); |
273 InstructionBlocks* instruction_blocks = | 273 InstructionBlocks* instruction_blocks = |
274 InstructionSequence::InstructionBlocksFor(instruction_zone(), | 274 InstructionSequence::InstructionBlocksFor(instruction_zone(), |
275 schedule()); | 275 schedule()); |
276 sequence_ = new (instruction_zone()) InstructionSequence( | 276 sequence_ = new (instruction_zone()) InstructionSequence( |
277 info()->isolate(), instruction_zone(), instruction_blocks); | 277 info()->isolate(), instruction_zone(), instruction_blocks); |
278 } | 278 } |
279 | 279 |
280 void InitializeFrameData(CallDescriptor* descriptor) { | 280 void InitializeFrameData(const CallDescriptor* descriptor) { |
281 DCHECK(frame_ == nullptr); | 281 DCHECK(frame_ == nullptr); |
282 int fixed_frame_size = 0; | 282 int fixed_frame_size = 0; |
283 if (descriptor != nullptr) { | 283 if (descriptor != nullptr) { |
284 fixed_frame_size = (descriptor->IsCFunctionCall()) | 284 fixed_frame_size = (descriptor->IsCFunctionCall()) |
285 ? StandardFrameConstants::kFixedSlotCountAboveFp + | 285 ? StandardFrameConstants::kFixedSlotCountAboveFp + |
286 StandardFrameConstants::kCPSlotCount | 286 StandardFrameConstants::kCPSlotCount |
287 : StandardFrameConstants::kFixedSlotCount; | 287 : StandardFrameConstants::kFixedSlotCount; |
288 } | 288 } |
289 frame_ = new (instruction_zone()) Frame(fixed_frame_size, descriptor); | 289 frame_ = new (instruction_zone()) Frame(fixed_frame_size, descriptor); |
290 } | 290 } |
291 | 291 |
292 void InitializeRegisterAllocationData(const RegisterConfiguration* config, | 292 void InitializeRegisterAllocationData(const RegisterConfiguration* config, |
293 CallDescriptor* descriptor, | 293 const CallDescriptor* descriptor, |
294 const char* debug_name) { | 294 const char* debug_name) { |
295 DCHECK(register_allocation_data_ == nullptr); | 295 DCHECK(register_allocation_data_ == nullptr); |
296 register_allocation_data_ = new (register_allocation_zone()) | 296 register_allocation_data_ = new (register_allocation_zone()) |
297 RegisterAllocationData(config, register_allocation_zone(), frame(), | 297 RegisterAllocationData(config, register_allocation_zone(), frame(), |
298 sequence(), debug_name); | 298 sequence(), debug_name); |
299 } | 299 } |
300 | 300 |
301 private: | 301 private: |
302 Isolate* isolate_; | 302 Isolate* isolate_; |
303 CompilationInfo* info_; | 303 CompilationInfo* info_; |
(...skipping 947 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1251 pipeline.Run<PrintGraphPhase>("Machine"); | 1251 pipeline.Run<PrintGraphPhase>("Machine"); |
1252 } | 1252 } |
1253 | 1253 |
1254 return pipeline.ScheduleAndGenerateCode(call_descriptor); | 1254 return pipeline.ScheduleAndGenerateCode(call_descriptor); |
1255 } | 1255 } |
1256 | 1256 |
1257 | 1257 |
1258 Handle<Code> Pipeline::GenerateCodeForTesting(CompilationInfo* info, | 1258 Handle<Code> Pipeline::GenerateCodeForTesting(CompilationInfo* info, |
1259 Graph* graph, | 1259 Graph* graph, |
1260 Schedule* schedule) { | 1260 Schedule* schedule) { |
1261 CallDescriptor* call_descriptor = | 1261 const CallDescriptor* call_descriptor = |
1262 Linkage::ComputeIncoming(info->zone(), info); | 1262 Linkage::ComputeIncoming(info->zone(), info); |
1263 return GenerateCodeForTesting(info, call_descriptor, graph, schedule); | 1263 return GenerateCodeForTesting(info, call_descriptor, graph, schedule); |
1264 } | 1264 } |
1265 | 1265 |
1266 | 1266 Handle<Code> Pipeline::GenerateCodeForTesting( |
1267 Handle<Code> Pipeline::GenerateCodeForTesting(CompilationInfo* info, | 1267 CompilationInfo* info, const CallDescriptor* call_descriptor, Graph* graph, |
1268 CallDescriptor* call_descriptor, | 1268 Schedule* schedule) { |
1269 Graph* graph, | |
1270 Schedule* schedule) { | |
1271 // Construct a pipeline for scheduling and code generation. | 1269 // Construct a pipeline for scheduling and code generation. |
1272 ZonePool zone_pool; | 1270 ZonePool zone_pool; |
1273 PipelineData data(&zone_pool, info, graph, schedule); | 1271 PipelineData data(&zone_pool, info, graph, schedule); |
1274 base::SmartPointer<PipelineStatistics> pipeline_statistics; | 1272 base::SmartPointer<PipelineStatistics> pipeline_statistics; |
1275 if (FLAG_turbo_stats) { | 1273 if (FLAG_turbo_stats) { |
1276 pipeline_statistics.Reset(new PipelineStatistics(info, &zone_pool)); | 1274 pipeline_statistics.Reset(new PipelineStatistics(info, &zone_pool)); |
1277 pipeline_statistics->BeginPhaseKind("test codegen"); | 1275 pipeline_statistics->BeginPhaseKind("test codegen"); |
1278 } | 1276 } |
1279 | 1277 |
1280 Pipeline pipeline(info); | 1278 Pipeline pipeline(info); |
(...skipping 13 matching lines...) Expand all Loading... |
1294 CompilationInfo info("testing", sequence->isolate(), sequence->zone()); | 1292 CompilationInfo info("testing", sequence->isolate(), sequence->zone()); |
1295 ZonePool zone_pool; | 1293 ZonePool zone_pool; |
1296 PipelineData data(&zone_pool, &info, sequence); | 1294 PipelineData data(&zone_pool, &info, sequence); |
1297 Pipeline pipeline(&info); | 1295 Pipeline pipeline(&info); |
1298 pipeline.data_ = &data; | 1296 pipeline.data_ = &data; |
1299 pipeline.data_->InitializeFrameData(nullptr); | 1297 pipeline.data_->InitializeFrameData(nullptr); |
1300 pipeline.AllocateRegisters(config, nullptr, run_verifier); | 1298 pipeline.AllocateRegisters(config, nullptr, run_verifier); |
1301 return !data.compilation_failed(); | 1299 return !data.compilation_failed(); |
1302 } | 1300 } |
1303 | 1301 |
1304 | |
1305 Handle<Code> Pipeline::ScheduleAndGenerateCode( | 1302 Handle<Code> Pipeline::ScheduleAndGenerateCode( |
1306 CallDescriptor* call_descriptor) { | 1303 const CallDescriptor* call_descriptor) { |
1307 PipelineData* data = this->data_; | 1304 PipelineData* data = this->data_; |
1308 | 1305 |
1309 DCHECK_NOT_NULL(data->graph()); | 1306 DCHECK_NOT_NULL(data->graph()); |
1310 | 1307 |
1311 if (data->schedule() == nullptr) Run<ComputeSchedulePhase>(); | 1308 if (data->schedule() == nullptr) Run<ComputeSchedulePhase>(); |
1312 TraceSchedule(data->info(), data->schedule()); | 1309 TraceSchedule(data->info(), data->schedule()); |
1313 | 1310 |
1314 BasicBlockProfiler::Data* profiler_data = nullptr; | 1311 BasicBlockProfiler::Data* profiler_data = nullptr; |
1315 if (FLAG_turbo_profiling) { | 1312 if (FLAG_turbo_profiling) { |
1316 profiler_data = BasicBlockInstrumentor::Instrument(info(), data->graph(), | 1313 profiler_data = BasicBlockInstrumentor::Instrument(info(), data->graph(), |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1401 } | 1398 } |
1402 OFStream os(stdout); | 1399 OFStream os(stdout); |
1403 os << "---------------------------------------------------\n" | 1400 os << "---------------------------------------------------\n" |
1404 << "Finished compiling method " << info()->GetDebugName().get() | 1401 << "Finished compiling method " << info()->GetDebugName().get() |
1405 << " using Turbofan" << std::endl; | 1402 << " using Turbofan" << std::endl; |
1406 } | 1403 } |
1407 | 1404 |
1408 return code; | 1405 return code; |
1409 } | 1406 } |
1410 | 1407 |
1411 | |
1412 void Pipeline::AllocateRegisters(const RegisterConfiguration* config, | 1408 void Pipeline::AllocateRegisters(const RegisterConfiguration* config, |
1413 CallDescriptor* descriptor, | 1409 const CallDescriptor* descriptor, |
1414 bool run_verifier) { | 1410 bool run_verifier) { |
1415 PipelineData* data = this->data_; | 1411 PipelineData* data = this->data_; |
1416 | 1412 |
1417 // Don't track usage for this zone in compiler stats. | 1413 // Don't track usage for this zone in compiler stats. |
1418 base::SmartPointer<Zone> verifier_zone; | 1414 base::SmartPointer<Zone> verifier_zone; |
1419 RegisterAllocatorVerifier* verifier = nullptr; | 1415 RegisterAllocatorVerifier* verifier = nullptr; |
1420 if (run_verifier) { | 1416 if (run_verifier) { |
1421 verifier_zone.Reset(new Zone()); | 1417 verifier_zone.Reset(new Zone()); |
1422 verifier = new (verifier_zone.get()) RegisterAllocatorVerifier( | 1418 verifier = new (verifier_zone.get()) RegisterAllocatorVerifier( |
1423 verifier_zone.get(), config, data->sequence()); | 1419 verifier_zone.get(), config, data->sequence()); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1500 } | 1496 } |
1501 | 1497 |
1502 data->DeleteRegisterAllocationZone(); | 1498 data->DeleteRegisterAllocationZone(); |
1503 } | 1499 } |
1504 | 1500 |
1505 Isolate* Pipeline::isolate() const { return info()->isolate(); } | 1501 Isolate* Pipeline::isolate() const { return info()->isolate(); } |
1506 | 1502 |
1507 } // namespace compiler | 1503 } // namespace compiler |
1508 } // namespace internal | 1504 } // namespace internal |
1509 } // namespace v8 | 1505 } // namespace v8 |
OLD | NEW |