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 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
565 } | 565 } |
566 info()->dependencies()->Commit(code); | 566 info()->dependencies()->Commit(code); |
567 info()->SetCode(code); | 567 info()->SetCode(code); |
568 if (info()->is_deoptimization_enabled()) { | 568 if (info()->is_deoptimization_enabled()) { |
569 info()->context()->native_context()->AddOptimizedCode(*code); | 569 info()->context()->native_context()->AddOptimizedCode(*code); |
570 RegisterWeakObjectsInOptimizedCode(code); | 570 RegisterWeakObjectsInOptimizedCode(code); |
571 } | 571 } |
572 return SUCCEEDED; | 572 return SUCCEEDED; |
573 } | 573 } |
574 | 574 |
| 575 } // namespace |
| 576 |
575 class PipelineWasmCompilationJob final : public CompilationJob { | 577 class PipelineWasmCompilationJob final : public CompilationJob { |
576 public: | 578 public: |
577 explicit PipelineWasmCompilationJob(CompilationInfo* info, Graph* graph, | 579 explicit PipelineWasmCompilationJob(CompilationInfo* info, Graph* graph, |
578 CallDescriptor* descriptor, | 580 CallDescriptor* descriptor, |
579 SourcePositionTable* source_positions) | 581 SourcePositionTable* source_positions) |
580 : CompilationJob(info, "TurboFan"), | 582 : CompilationJob(info, "TurboFan"), |
581 zone_pool_(info->isolate()->allocator()), | 583 zone_pool_(info->isolate()->allocator()), |
582 data_(&zone_pool_, info, graph, source_positions), | 584 data_(&zone_pool_, info, graph, source_positions), |
583 pipeline_(&data_), | 585 pipeline_(&data_), |
584 linkage_(descriptor) {} | 586 linkage_(descriptor) {} |
(...skipping 10 matching lines...) Expand all Loading... |
595 Linkage linkage_; | 597 Linkage linkage_; |
596 }; | 598 }; |
597 | 599 |
598 PipelineWasmCompilationJob::Status | 600 PipelineWasmCompilationJob::Status |
599 PipelineWasmCompilationJob::CreateGraphImpl() { | 601 PipelineWasmCompilationJob::CreateGraphImpl() { |
600 return SUCCEEDED; | 602 return SUCCEEDED; |
601 } | 603 } |
602 | 604 |
603 PipelineWasmCompilationJob::Status | 605 PipelineWasmCompilationJob::Status |
604 PipelineWasmCompilationJob::OptimizeGraphImpl() { | 606 PipelineWasmCompilationJob::OptimizeGraphImpl() { |
| 607 if (FLAG_trace_turbo) { |
| 608 FILE* json_file = OpenVisualizerLogFile(info(), nullptr, "json", "w+"); |
| 609 if (json_file != nullptr) { |
| 610 OFStream json_of(json_file); |
| 611 json_of << "{\"function\":\"" << info()->GetDebugName().get() |
| 612 << "\", \"source\":\"\",\n\"phases\":["; |
| 613 fclose(json_file); |
| 614 } |
| 615 } |
| 616 |
| 617 pipeline_.RunPrintAndVerify("Machine", true); |
| 618 |
605 if (!pipeline_.ScheduleAndSelectInstructions(&linkage_)) return FAILED; | 619 if (!pipeline_.ScheduleAndSelectInstructions(&linkage_)) return FAILED; |
606 return SUCCEEDED; | 620 return SUCCEEDED; |
607 } | 621 } |
608 | 622 |
609 PipelineWasmCompilationJob::Status | 623 PipelineWasmCompilationJob::Status |
610 PipelineWasmCompilationJob::GenerateCodeImpl() { | 624 PipelineWasmCompilationJob::GenerateCodeImpl() { |
611 pipeline_.GenerateCode(&linkage_); | 625 pipeline_.GenerateCode(&linkage_); |
612 return SUCCEEDED; | 626 return SUCCEEDED; |
613 } | 627 } |
614 | 628 |
615 } // namespace | |
616 | |
617 | 629 |
618 template <typename Phase> | 630 template <typename Phase> |
619 void Pipeline::Run() { | 631 void Pipeline::Run() { |
620 PipelineRunScope scope(this->data_, Phase::phase_name()); | 632 PipelineRunScope scope(this->data_, Phase::phase_name()); |
621 Phase phase; | 633 Phase phase; |
622 phase.Run(this->data_, scope.zone()); | 634 phase.Run(this->data_, scope.zone()); |
623 } | 635 } |
624 | 636 |
625 | 637 |
626 template <typename Phase, typename Arg0> | 638 template <typename Phase, typename Arg0> |
(...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1445 // Construct a pipeline for scheduling and code generation. | 1457 // Construct a pipeline for scheduling and code generation. |
1446 ZonePool zone_pool(info->isolate()->allocator()); | 1458 ZonePool zone_pool(info->isolate()->allocator()); |
1447 PipelineData data(&zone_pool, info, graph, schedule); | 1459 PipelineData data(&zone_pool, info, graph, schedule); |
1448 base::SmartPointer<PipelineStatistics> pipeline_statistics; | 1460 base::SmartPointer<PipelineStatistics> pipeline_statistics; |
1449 if (FLAG_turbo_stats) { | 1461 if (FLAG_turbo_stats) { |
1450 pipeline_statistics.Reset(new PipelineStatistics(info, &zone_pool)); | 1462 pipeline_statistics.Reset(new PipelineStatistics(info, &zone_pool)); |
1451 pipeline_statistics->BeginPhaseKind("test codegen"); | 1463 pipeline_statistics->BeginPhaseKind("test codegen"); |
1452 } | 1464 } |
1453 | 1465 |
1454 Pipeline pipeline(&data); | 1466 Pipeline pipeline(&data); |
1455 if (data.schedule() == nullptr) { | 1467 |
1456 // TODO(rossberg): Should this really be untyped? | 1468 if (FLAG_trace_turbo) { |
1457 pipeline.RunPrintAndVerify("Machine", true); | 1469 FILE* json_file = OpenVisualizerLogFile(info, nullptr, "json", "w+"); |
| 1470 if (json_file != nullptr) { |
| 1471 OFStream json_of(json_file); |
| 1472 json_of << "{\"function\":\"" << info->GetDebugName().get() |
| 1473 << "\", \"source\":\"\",\n\"phases\":["; |
| 1474 fclose(json_file); |
| 1475 } |
1458 } | 1476 } |
| 1477 // TODO(rossberg): Should this really be untyped? |
| 1478 pipeline.RunPrintAndVerify("Machine", true); |
1459 | 1479 |
1460 return pipeline.ScheduleAndGenerateCode(call_descriptor); | 1480 return pipeline.ScheduleAndGenerateCode(call_descriptor); |
1461 } | 1481 } |
1462 | 1482 |
1463 // static | 1483 // static |
1464 CompilationJob* Pipeline::NewCompilationJob(CompilationInfo* info) { | 1484 CompilationJob* Pipeline::NewCompilationJob(CompilationInfo* info) { |
1465 return new PipelineCompilationJob(info); | 1485 return new PipelineCompilationJob(info); |
1466 } | 1486 } |
1467 | 1487 |
1468 // static | 1488 // static |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1698 data->DeleteRegisterAllocationZone(); | 1718 data->DeleteRegisterAllocationZone(); |
1699 } | 1719 } |
1700 | 1720 |
1701 CompilationInfo* Pipeline::info() const { return data_->info(); } | 1721 CompilationInfo* Pipeline::info() const { return data_->info(); } |
1702 | 1722 |
1703 Isolate* Pipeline::isolate() const { return info()->isolate(); } | 1723 Isolate* Pipeline::isolate() const { return info()->isolate(); } |
1704 | 1724 |
1705 } // namespace compiler | 1725 } // namespace compiler |
1706 } // namespace internal | 1726 } // namespace internal |
1707 } // namespace v8 | 1727 } // namespace v8 |
OLD | NEW |