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 <memory> | 8 #include <memory> |
9 #include <sstream> | 9 #include <sstream> |
10 | 10 |
(...skipping 841 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
852 void Run(PipelineData* data, Zone* temp_zone, Typer* typer) { | 852 void Run(PipelineData* data, Zone* temp_zone, Typer* typer) { |
853 NodeVector roots(temp_zone); | 853 NodeVector roots(temp_zone); |
854 data->jsgraph()->GetCachedNodes(&roots); | 854 data->jsgraph()->GetCachedNodes(&roots); |
855 LoopVariableOptimizer induction_vars(data->jsgraph()->graph(), | 855 LoopVariableOptimizer induction_vars(data->jsgraph()->graph(), |
856 data->common(), temp_zone); | 856 data->common(), temp_zone); |
857 if (FLAG_turbo_loop_variable) induction_vars.Run(); | 857 if (FLAG_turbo_loop_variable) induction_vars.Run(); |
858 typer->Run(roots, &induction_vars); | 858 typer->Run(roots, &induction_vars); |
859 } | 859 } |
860 }; | 860 }; |
861 | 861 |
862 #ifdef DEBUG | 862 struct OsrTyperPhase { |
| 863 static const char* phase_name() { return "osr typer"; } |
| 864 |
| 865 void Run(PipelineData* data, Zone* temp_zone) { |
| 866 NodeVector roots(temp_zone); |
| 867 data->jsgraph()->GetCachedNodes(&roots); |
| 868 // Dummy induction variable optimizer: at the moment, we do not try |
| 869 // to compute loop variable bounds on OSR. |
| 870 LoopVariableOptimizer induction_vars(data->jsgraph()->graph(), |
| 871 data->common(), temp_zone); |
| 872 Typer typer(data->isolate(), data->graph()); |
| 873 typer.Run(roots, &induction_vars); |
| 874 } |
| 875 }; |
863 | 876 |
864 struct UntyperPhase { | 877 struct UntyperPhase { |
865 static const char* phase_name() { return "untyper"; } | 878 static const char* phase_name() { return "untyper"; } |
866 | 879 |
867 void Run(PipelineData* data, Zone* temp_zone) { | 880 void Run(PipelineData* data, Zone* temp_zone) { |
868 class RemoveTypeReducer final : public Reducer { | 881 class RemoveTypeReducer final : public Reducer { |
869 public: | 882 public: |
870 Reduction Reduce(Node* node) final { | 883 Reduction Reduce(Node* node) final { |
871 if (NodeProperties::IsTyped(node)) { | 884 if (NodeProperties::IsTyped(node)) { |
872 NodeProperties::RemoveType(node); | 885 NodeProperties::RemoveType(node); |
873 return Changed(node); | 886 return Changed(node); |
874 } | 887 } |
875 return NoChange(); | 888 return NoChange(); |
876 } | 889 } |
877 }; | 890 }; |
878 | 891 |
| 892 NodeVector roots(temp_zone); |
| 893 data->jsgraph()->GetCachedNodes(&roots); |
| 894 for (Node* node : roots) { |
| 895 NodeProperties::RemoveType(node); |
| 896 } |
| 897 |
879 JSGraphReducer graph_reducer(data->jsgraph(), temp_zone); | 898 JSGraphReducer graph_reducer(data->jsgraph(), temp_zone); |
880 RemoveTypeReducer remove_type_reducer; | 899 RemoveTypeReducer remove_type_reducer; |
881 AddReducer(data, &graph_reducer, &remove_type_reducer); | 900 AddReducer(data, &graph_reducer, &remove_type_reducer); |
882 graph_reducer.ReduceGraph(); | 901 graph_reducer.ReduceGraph(); |
883 } | 902 } |
884 }; | 903 }; |
885 | 904 |
886 #endif // DEBUG | |
887 | |
888 struct OsrDeconstructionPhase { | 905 struct OsrDeconstructionPhase { |
889 static const char* phase_name() { return "OSR deconstruction"; } | 906 static const char* phase_name() { return "OSR deconstruction"; } |
890 | 907 |
891 void Run(PipelineData* data, Zone* temp_zone) { | 908 void Run(PipelineData* data, Zone* temp_zone) { |
| 909 GraphTrimmer trimmer(temp_zone, data->graph()); |
| 910 NodeVector roots(temp_zone); |
| 911 data->jsgraph()->GetCachedNodes(&roots); |
| 912 trimmer.TrimGraph(roots.begin(), roots.end()); |
| 913 |
892 OsrHelper osr_helper(data->info()); | 914 OsrHelper osr_helper(data->info()); |
893 osr_helper.Deconstruct(data->jsgraph(), data->common(), temp_zone); | 915 osr_helper.Deconstruct(data->jsgraph(), data->common(), temp_zone); |
894 } | 916 } |
895 }; | 917 }; |
896 | 918 |
897 | 919 |
898 struct TypedLoweringPhase { | 920 struct TypedLoweringPhase { |
899 static const char* phase_name() { return "typed lowering"; } | 921 static const char* phase_name() { return "typed lowering"; } |
900 | 922 |
901 void Run(PipelineData* data, Zone* temp_zone) { | 923 void Run(PipelineData* data, Zone* temp_zone) { |
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1486 | 1508 |
1487 Run<GraphBuilderPhase>(); | 1509 Run<GraphBuilderPhase>(); |
1488 if (data->compilation_failed()) { | 1510 if (data->compilation_failed()) { |
1489 data->EndPhaseKind(); | 1511 data->EndPhaseKind(); |
1490 return false; | 1512 return false; |
1491 } | 1513 } |
1492 RunPrintAndVerify("Initial untyped", true); | 1514 RunPrintAndVerify("Initial untyped", true); |
1493 | 1515 |
1494 // Perform OSR deconstruction. | 1516 // Perform OSR deconstruction. |
1495 if (info()->is_osr()) { | 1517 if (info()->is_osr()) { |
| 1518 Run<OsrTyperPhase>(); |
| 1519 |
1496 Run<OsrDeconstructionPhase>(); | 1520 Run<OsrDeconstructionPhase>(); |
| 1521 |
| 1522 Run<UntyperPhase>(); |
1497 RunPrintAndVerify("OSR deconstruction", true); | 1523 RunPrintAndVerify("OSR deconstruction", true); |
1498 } | 1524 } |
1499 | 1525 |
1500 // Perform function context specialization and inlining (if enabled). | 1526 // Perform function context specialization and inlining (if enabled). |
1501 Run<InliningPhase>(); | 1527 Run<InliningPhase>(); |
1502 RunPrintAndVerify("Inlined", true); | 1528 RunPrintAndVerify("Inlined", true); |
1503 | 1529 |
1504 // Remove dead->live edges from the graph. | 1530 // Remove dead->live edges from the graph. |
1505 Run<EarlyGraphTrimmingPhase>(); | 1531 Run<EarlyGraphTrimmingPhase>(); |
1506 RunPrintAndVerify("Early trimmed", true); | 1532 RunPrintAndVerify("Early trimmed", true); |
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1942 data->DeleteRegisterAllocationZone(); | 1968 data->DeleteRegisterAllocationZone(); |
1943 } | 1969 } |
1944 | 1970 |
1945 CompilationInfo* PipelineImpl::info() const { return data_->info(); } | 1971 CompilationInfo* PipelineImpl::info() const { return data_->info(); } |
1946 | 1972 |
1947 Isolate* PipelineImpl::isolate() const { return info()->isolate(); } | 1973 Isolate* PipelineImpl::isolate() const { return info()->isolate(); } |
1948 | 1974 |
1949 } // namespace compiler | 1975 } // namespace compiler |
1950 } // namespace internal | 1976 } // namespace internal |
1951 } // namespace v8 | 1977 } // namespace v8 |
OLD | NEW |