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 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 Reducer* const reducer_; | 400 Reducer* const reducer_; |
401 SourcePositionTable* const table_; | 401 SourcePositionTable* const table_; |
402 | 402 |
403 DISALLOW_COPY_AND_ASSIGN(SourcePositionWrapper); | 403 DISALLOW_COPY_AND_ASSIGN(SourcePositionWrapper); |
404 }; | 404 }; |
405 | 405 |
406 | 406 |
407 class JSGraphReducer final : public GraphReducer { | 407 class JSGraphReducer final : public GraphReducer { |
408 public: | 408 public: |
409 JSGraphReducer(JSGraph* jsgraph, Zone* zone) | 409 JSGraphReducer(JSGraph* jsgraph, Zone* zone) |
410 : GraphReducer(zone, jsgraph->graph(), jsgraph->TheHoleConstant(), | 410 : GraphReducer(zone, jsgraph->graph(), jsgraph->Dead()) {} |
411 jsgraph->Dead()) {} | |
412 ~JSGraphReducer() final {} | 411 ~JSGraphReducer() final {} |
413 }; | 412 }; |
414 | 413 |
415 | 414 |
416 void AddReducer(PipelineData* data, GraphReducer* graph_reducer, | 415 void AddReducer(PipelineData* data, GraphReducer* graph_reducer, |
417 Reducer* reducer) { | 416 Reducer* reducer) { |
418 if (data->info()->is_source_positions_enabled()) { | 417 if (data->info()->is_source_positions_enabled()) { |
419 void* const buffer = data->graph_zone()->New(sizeof(SourcePositionWrapper)); | 418 void* const buffer = data->graph_zone()->New(sizeof(SourcePositionWrapper)); |
420 SourcePositionWrapper* const wrapper = | 419 SourcePositionWrapper* const wrapper = |
421 new (buffer) SourcePositionWrapper(reducer, data->source_positions()); | 420 new (buffer) SourcePositionWrapper(reducer, data->source_positions()); |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
558 graph_reducer.ReduceGraph(); | 557 graph_reducer.ReduceGraph(); |
559 } | 558 } |
560 }; | 559 }; |
561 | 560 |
562 | 561 |
563 struct TypedLoweringPhase { | 562 struct TypedLoweringPhase { |
564 static const char* phase_name() { return "typed lowering"; } | 563 static const char* phase_name() { return "typed lowering"; } |
565 | 564 |
566 void Run(PipelineData* data, Zone* temp_zone) { | 565 void Run(PipelineData* data, Zone* temp_zone) { |
567 JSGraphReducer graph_reducer(data->jsgraph(), temp_zone); | 566 JSGraphReducer graph_reducer(data->jsgraph(), temp_zone); |
| 567 DeadCodeElimination dead_code_elimination(&graph_reducer, data->graph(), |
| 568 data->common()); |
568 LoadElimination load_elimination(&graph_reducer); | 569 LoadElimination load_elimination(&graph_reducer); |
569 JSBuiltinReducer builtin_reducer(&graph_reducer, data->jsgraph()); | 570 JSBuiltinReducer builtin_reducer(&graph_reducer, data->jsgraph()); |
570 JSTypedLowering typed_lowering(&graph_reducer, data->jsgraph(), temp_zone); | 571 JSTypedLowering typed_lowering(&graph_reducer, data->jsgraph(), temp_zone); |
571 JSIntrinsicLowering intrinsic_lowering( | 572 JSIntrinsicLowering intrinsic_lowering( |
572 &graph_reducer, data->jsgraph(), | 573 &graph_reducer, data->jsgraph(), |
573 data->info()->is_deoptimization_enabled() | 574 data->info()->is_deoptimization_enabled() |
574 ? JSIntrinsicLowering::kDeoptimizationEnabled | 575 ? JSIntrinsicLowering::kDeoptimizationEnabled |
575 : JSIntrinsicLowering::kDeoptimizationDisabled); | 576 : JSIntrinsicLowering::kDeoptimizationDisabled); |
576 CommonOperatorReducer common_reducer(&graph_reducer, data->graph(), | 577 CommonOperatorReducer common_reducer(&graph_reducer, data->graph(), |
577 data->common(), data->machine()); | 578 data->common(), data->machine()); |
| 579 AddReducer(data, &graph_reducer, &dead_code_elimination); |
578 AddReducer(data, &graph_reducer, &builtin_reducer); | 580 AddReducer(data, &graph_reducer, &builtin_reducer); |
579 AddReducer(data, &graph_reducer, &typed_lowering); | 581 AddReducer(data, &graph_reducer, &typed_lowering); |
580 AddReducer(data, &graph_reducer, &intrinsic_lowering); | 582 AddReducer(data, &graph_reducer, &intrinsic_lowering); |
581 AddReducer(data, &graph_reducer, &load_elimination); | 583 AddReducer(data, &graph_reducer, &load_elimination); |
582 AddReducer(data, &graph_reducer, &common_reducer); | 584 AddReducer(data, &graph_reducer, &common_reducer); |
583 graph_reducer.ReduceGraph(); | 585 graph_reducer.ReduceGraph(); |
584 } | 586 } |
585 }; | 587 }; |
586 | 588 |
587 | 589 |
588 struct SimplifiedLoweringPhase { | 590 struct SimplifiedLoweringPhase { |
589 static const char* phase_name() { return "simplified lowering"; } | 591 static const char* phase_name() { return "simplified lowering"; } |
590 | 592 |
591 void Run(PipelineData* data, Zone* temp_zone) { | 593 void Run(PipelineData* data, Zone* temp_zone) { |
592 SimplifiedLowering lowering(data->jsgraph(), temp_zone, | 594 SimplifiedLowering lowering(data->jsgraph(), temp_zone, |
593 data->source_positions()); | 595 data->source_positions()); |
594 lowering.LowerAllNodes(); | 596 lowering.LowerAllNodes(); |
595 JSGraphReducer graph_reducer(data->jsgraph(), temp_zone); | 597 JSGraphReducer graph_reducer(data->jsgraph(), temp_zone); |
| 598 DeadCodeElimination dead_code_elimination(&graph_reducer, data->graph(), |
| 599 data->common()); |
596 ValueNumberingReducer vn_reducer(temp_zone); | 600 ValueNumberingReducer vn_reducer(temp_zone); |
597 MachineOperatorReducer machine_reducer(data->jsgraph()); | 601 MachineOperatorReducer machine_reducer(data->jsgraph()); |
598 CommonOperatorReducer common_reducer(&graph_reducer, data->graph(), | 602 CommonOperatorReducer common_reducer(&graph_reducer, data->graph(), |
599 data->common(), data->machine()); | 603 data->common(), data->machine()); |
| 604 AddReducer(data, &graph_reducer, &dead_code_elimination); |
600 AddReducer(data, &graph_reducer, &vn_reducer); | 605 AddReducer(data, &graph_reducer, &vn_reducer); |
601 AddReducer(data, &graph_reducer, &machine_reducer); | 606 AddReducer(data, &graph_reducer, &machine_reducer); |
602 AddReducer(data, &graph_reducer, &common_reducer); | 607 AddReducer(data, &graph_reducer, &common_reducer); |
603 graph_reducer.ReduceGraph(); | 608 graph_reducer.ReduceGraph(); |
604 } | 609 } |
605 }; | 610 }; |
606 | 611 |
607 | 612 |
608 struct ControlFlowOptimizationPhase { | 613 struct ControlFlowOptimizationPhase { |
609 static const char* phase_name() { return "control flow optimization"; } | 614 static const char* phase_name() { return "control flow optimization"; } |
610 | 615 |
611 void Run(PipelineData* data, Zone* temp_zone) { | 616 void Run(PipelineData* data, Zone* temp_zone) { |
612 ControlFlowOptimizer optimizer(data->graph(), data->common(), | 617 ControlFlowOptimizer optimizer(data->graph(), data->common(), |
613 data->machine(), temp_zone); | 618 data->machine(), temp_zone); |
614 optimizer.Optimize(); | 619 optimizer.Optimize(); |
615 } | 620 } |
616 }; | 621 }; |
617 | 622 |
618 | 623 |
619 struct ChangeLoweringPhase { | 624 struct ChangeLoweringPhase { |
620 static const char* phase_name() { return "change lowering"; } | 625 static const char* phase_name() { return "change lowering"; } |
621 | 626 |
622 void Run(PipelineData* data, Zone* temp_zone) { | 627 void Run(PipelineData* data, Zone* temp_zone) { |
623 JSGraphReducer graph_reducer(data->jsgraph(), temp_zone); | 628 JSGraphReducer graph_reducer(data->jsgraph(), temp_zone); |
| 629 DeadCodeElimination dead_code_elimination(&graph_reducer, data->graph(), |
| 630 data->common()); |
624 ValueNumberingReducer vn_reducer(temp_zone); | 631 ValueNumberingReducer vn_reducer(temp_zone); |
625 ChangeLowering lowering(data->jsgraph()); | 632 ChangeLowering lowering(data->jsgraph()); |
626 MachineOperatorReducer machine_reducer(data->jsgraph()); | 633 MachineOperatorReducer machine_reducer(data->jsgraph()); |
627 CommonOperatorReducer common_reducer(&graph_reducer, data->graph(), | 634 CommonOperatorReducer common_reducer(&graph_reducer, data->graph(), |
628 data->common(), data->machine()); | 635 data->common(), data->machine()); |
| 636 AddReducer(data, &graph_reducer, &dead_code_elimination); |
629 AddReducer(data, &graph_reducer, &vn_reducer); | 637 AddReducer(data, &graph_reducer, &vn_reducer); |
630 AddReducer(data, &graph_reducer, &lowering); | 638 AddReducer(data, &graph_reducer, &lowering); |
631 AddReducer(data, &graph_reducer, &machine_reducer); | 639 AddReducer(data, &graph_reducer, &machine_reducer); |
632 AddReducer(data, &graph_reducer, &common_reducer); | 640 AddReducer(data, &graph_reducer, &common_reducer); |
633 graph_reducer.ReduceGraph(); | 641 graph_reducer.ReduceGraph(); |
634 } | 642 } |
635 }; | 643 }; |
636 | 644 |
637 | 645 |
638 struct LateControlReductionPhase { | |
639 static const char* phase_name() { return "late control reduction"; } | |
640 void Run(PipelineData* data, Zone* temp_zone) { | |
641 GraphReducer graph_reducer(temp_zone, data->graph()); | |
642 DeadCodeElimination dce(&graph_reducer, data->graph(), data->common()); | |
643 CommonOperatorReducer common(&graph_reducer, data->graph(), data->common(), | |
644 data->machine()); | |
645 graph_reducer.AddReducer(&dce); | |
646 graph_reducer.AddReducer(&common); | |
647 graph_reducer.ReduceGraph(); | |
648 } | |
649 }; | |
650 | |
651 | |
652 struct EarlyGraphTrimmingPhase { | 646 struct EarlyGraphTrimmingPhase { |
653 static const char* phase_name() { return "early graph trimming"; } | 647 static const char* phase_name() { return "early graph trimming"; } |
654 void Run(PipelineData* data, Zone* temp_zone) { | 648 void Run(PipelineData* data, Zone* temp_zone) { |
655 GraphTrimmer trimmer(temp_zone, data->graph()); | 649 GraphTrimmer trimmer(temp_zone, data->graph()); |
656 NodeVector roots(temp_zone); | 650 NodeVector roots(temp_zone); |
657 data->jsgraph()->GetCachedNodes(&roots); | 651 data->jsgraph()->GetCachedNodes(&roots); |
658 trimmer.TrimGraph(roots.begin(), roots.end()); | 652 trimmer.TrimGraph(roots.begin(), roots.end()); |
659 } | 653 } |
660 }; | 654 }; |
661 | 655 |
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1357 tcf << AsC1VRegisterAllocationData("CodeGen", | 1351 tcf << AsC1VRegisterAllocationData("CodeGen", |
1358 data->register_allocation_data()); | 1352 data->register_allocation_data()); |
1359 } | 1353 } |
1360 | 1354 |
1361 data->DeleteRegisterAllocationZone(); | 1355 data->DeleteRegisterAllocationZone(); |
1362 } | 1356 } |
1363 | 1357 |
1364 } // namespace compiler | 1358 } // namespace compiler |
1365 } // namespace internal | 1359 } // namespace internal |
1366 } // namespace v8 | 1360 } // namespace v8 |
OLD | NEW |