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