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 927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
938 AddReducer(data, &graph_reducer, &escape_reducer); | 938 AddReducer(data, &graph_reducer, &escape_reducer); |
939 graph_reducer.ReduceGraph(); | 939 graph_reducer.ReduceGraph(); |
940 if (escape_reducer.compilation_failed()) { | 940 if (escape_reducer.compilation_failed()) { |
941 data->set_compilation_failed(); | 941 data->set_compilation_failed(); |
942 return; | 942 return; |
943 } | 943 } |
944 escape_reducer.VerifyReplacement(); | 944 escape_reducer.VerifyReplacement(); |
945 } | 945 } |
946 }; | 946 }; |
947 | 947 |
948 struct RepresentationSelectionPhase { | 948 struct SimplifiedLoweringPhase { |
949 static const char* phase_name() { return "representation selection"; } | 949 static const char* phase_name() { return "simplified lowering"; } |
950 | 950 |
951 void Run(PipelineData* data, Zone* temp_zone) { | 951 void Run(PipelineData* data, Zone* temp_zone) { |
952 SimplifiedLowering lowering(data->jsgraph(), temp_zone, | 952 SimplifiedLowering lowering(data->jsgraph(), temp_zone, |
953 data->source_positions()); | 953 data->source_positions()); |
954 lowering.LowerAllNodes(); | 954 lowering.LowerAllNodes(); |
955 } | 955 } |
956 }; | 956 }; |
957 | 957 |
958 struct LoopPeelingPhase { | 958 struct LoopPeelingPhase { |
959 static const char* phase_name() { return "loop peeling"; } | 959 static const char* phase_name() { return "loop peeling"; } |
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1546 if (data->compilation_failed()) { | 1546 if (data->compilation_failed()) { |
1547 info()->AbortOptimization(kCyclicObjectStateDetectedInEscapeAnalysis); | 1547 info()->AbortOptimization(kCyclicObjectStateDetectedInEscapeAnalysis); |
1548 data->EndPhaseKind(); | 1548 data->EndPhaseKind(); |
1549 return false; | 1549 return false; |
1550 } | 1550 } |
1551 RunPrintAndVerify("Escape Analysed"); | 1551 RunPrintAndVerify("Escape Analysed"); |
1552 } | 1552 } |
1553 } | 1553 } |
1554 } | 1554 } |
1555 | 1555 |
1556 // Select representations. This has to run w/o the Typer decorator, because | 1556 // Do some hacky things to prepare generic lowering. |
1557 // we cannot compute meaningful types anyways, and the computed types might | 1557 Run<GenericLoweringPrepPhase>(); |
1558 // even conflict with the representation/truncation logic. | 1558 |
1559 Run<RepresentationSelectionPhase>(); | 1559 data->EndPhaseKind(); |
1560 RunPrintAndVerify("Representations selected", true); | 1560 |
| 1561 return true; |
| 1562 } |
| 1563 |
| 1564 bool PipelineImpl::OptimizeGraph(Linkage* linkage) { |
| 1565 PipelineData* data = this->data_; |
| 1566 |
| 1567 // Perform simplified lowering. This has to run w/o the Typer decorator, |
| 1568 // because we cannot compute meaningful types anyways, and the computed types |
| 1569 // might even conflict with the representation/truncation logic. |
| 1570 Run<SimplifiedLoweringPhase>(); |
| 1571 RunPrintAndVerify("Simplified lowering", true); |
1561 | 1572 |
1562 #ifdef DEBUG | 1573 #ifdef DEBUG |
1563 // From now on it is invalid to look at types on the nodes, because: | 1574 // From now on it is invalid to look at types on the nodes, because: |
1564 // | 1575 // |
1565 // (a) The remaining passes (might) run concurrent to the main thread and | 1576 // (a) The remaining passes (might) run concurrent to the main thread and |
1566 // therefore must not access the Heap or the Isolate in an uncontrolled | 1577 // therefore must not access the Heap or the Isolate in an uncontrolled |
1567 // way (as done by the type system), and | 1578 // way (as done by the type system), and |
1568 // (b) the types on the nodes might not make sense after representation | 1579 // (b) the types on the nodes might not make sense after representation |
1569 // selection due to the way we handle truncations; if we'd want to look | 1580 // selection due to the way we handle truncations; if we'd want to look |
1570 // at types afterwards we'd essentially need to re-type (large portions | 1581 // at types afterwards we'd essentially need to re-type (large portions |
1571 // of) the graph. | 1582 // of) the graph. |
1572 // | 1583 // |
1573 // In order to catch bugs related to type access after this point we remove | 1584 // In order to catch bugs related to type access after this point we remove |
1574 // the types from the nodes at this point (currently only in Debug builds). | 1585 // the types from the nodes at this point (currently only in Debug builds). |
1575 Run<UntyperPhase>(); | 1586 Run<UntyperPhase>(); |
1576 RunPrintAndVerify("Untyped", true); | 1587 RunPrintAndVerify("Untyped", true); |
1577 #endif | 1588 #endif |
1578 | 1589 |
1579 // Do some hacky things to prepare generic lowering. | |
1580 Run<GenericLoweringPrepPhase>(); | |
1581 | |
1582 data->EndPhaseKind(); | |
1583 | |
1584 return true; | |
1585 } | |
1586 | |
1587 bool PipelineImpl::OptimizeGraph(Linkage* linkage) { | |
1588 PipelineData* data = this->data_; | |
1589 | |
1590 // Run generic lowering pass. | 1590 // Run generic lowering pass. |
1591 Run<GenericLoweringPhase>(); | 1591 Run<GenericLoweringPhase>(); |
1592 RunPrintAndVerify("Generic lowering", true); | 1592 RunPrintAndVerify("Generic lowering", true); |
1593 | 1593 |
1594 data->BeginPhaseKind("block building"); | 1594 data->BeginPhaseKind("block building"); |
1595 | 1595 |
1596 // Run early optimization pass. | 1596 // Run early optimization pass. |
1597 Run<EarlyOptimizationPhase>(); | 1597 Run<EarlyOptimizationPhase>(); |
1598 RunPrintAndVerify("Early optimized", true); | 1598 RunPrintAndVerify("Early optimized", true); |
1599 | 1599 |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1993 data->DeleteRegisterAllocationZone(); | 1993 data->DeleteRegisterAllocationZone(); |
1994 } | 1994 } |
1995 | 1995 |
1996 CompilationInfo* PipelineImpl::info() const { return data_->info(); } | 1996 CompilationInfo* PipelineImpl::info() const { return data_->info(); } |
1997 | 1997 |
1998 Isolate* PipelineImpl::isolate() const { return info()->isolate(); } | 1998 Isolate* PipelineImpl::isolate() const { return info()->isolate(); } |
1999 | 1999 |
2000 } // namespace compiler | 2000 } // namespace compiler |
2001 } // namespace internal | 2001 } // namespace internal |
2002 } // namespace v8 | 2002 } // namespace v8 |
OLD | NEW |