| 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 750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 761 struct TyperPhase { | 761 struct TyperPhase { |
| 762 static const char* phase_name() { return "typer"; } | 762 static const char* phase_name() { return "typer"; } |
| 763 | 763 |
| 764 void Run(PipelineData* data, Zone* temp_zone, Typer* typer) { | 764 void Run(PipelineData* data, Zone* temp_zone, Typer* typer) { |
| 765 NodeVector roots(temp_zone); | 765 NodeVector roots(temp_zone); |
| 766 data->jsgraph()->GetCachedNodes(&roots); | 766 data->jsgraph()->GetCachedNodes(&roots); |
| 767 typer->Run(roots); | 767 typer->Run(roots); |
| 768 } | 768 } |
| 769 }; | 769 }; |
| 770 | 770 |
| 771 #ifdef DEBUG |
| 772 |
| 773 struct UntyperPhase { |
| 774 static const char* phase_name() { return "untyper"; } |
| 775 |
| 776 void Run(PipelineData* data, Zone* temp_zone) { |
| 777 class RemoveTypeReducer final : public Reducer { |
| 778 public: |
| 779 Reduction Reduce(Node* node) final { |
| 780 if (NodeProperties::IsTyped(node)) { |
| 781 NodeProperties::RemoveType(node); |
| 782 return Changed(node); |
| 783 } |
| 784 return NoChange(); |
| 785 } |
| 786 }; |
| 787 |
| 788 JSGraphReducer graph_reducer(data->jsgraph(), temp_zone); |
| 789 RemoveTypeReducer remove_type_reducer; |
| 790 AddReducer(data, &graph_reducer, &remove_type_reducer); |
| 791 graph_reducer.ReduceGraph(); |
| 792 } |
| 793 }; |
| 794 |
| 795 #endif // DEBUG |
| 771 | 796 |
| 772 struct OsrDeconstructionPhase { | 797 struct OsrDeconstructionPhase { |
| 773 static const char* phase_name() { return "OSR deconstruction"; } | 798 static const char* phase_name() { return "OSR deconstruction"; } |
| 774 | 799 |
| 775 void Run(PipelineData* data, Zone* temp_zone) { | 800 void Run(PipelineData* data, Zone* temp_zone) { |
| 776 OsrHelper osr_helper(data->info()); | 801 OsrHelper osr_helper(data->info()); |
| 777 osr_helper.Deconstruct(data->jsgraph(), data->common(), temp_zone); | 802 osr_helper.Deconstruct(data->jsgraph(), data->common(), temp_zone); |
| 778 } | 803 } |
| 779 }; | 804 }; |
| 780 | 805 |
| (...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1306 | 1331 |
| 1307 // Remove dead->live edges from the graph. | 1332 // Remove dead->live edges from the graph. |
| 1308 Run<EarlyGraphTrimmingPhase>(); | 1333 Run<EarlyGraphTrimmingPhase>(); |
| 1309 RunPrintAndVerify("Early trimmed", true); | 1334 RunPrintAndVerify("Early trimmed", true); |
| 1310 | 1335 |
| 1311 if (FLAG_print_turbo_replay) { | 1336 if (FLAG_print_turbo_replay) { |
| 1312 // Print a replay of the initial graph. | 1337 // Print a replay of the initial graph. |
| 1313 GraphReplayPrinter::PrintReplay(data->graph()); | 1338 GraphReplayPrinter::PrintReplay(data->graph()); |
| 1314 } | 1339 } |
| 1315 | 1340 |
| 1316 // Type the graph. | 1341 // Run the type-sensitive lowerings and optimizations on the graph. |
| 1317 Typer typer(isolate(), data->graph(), info()->is_deoptimization_enabled() | 1342 { |
| 1318 ? Typer::kDeoptimizationEnabled | 1343 // Type the graph and keep the Typer running on newly created nodes within |
| 1319 : Typer::kNoFlags, | 1344 // this scope; the Typer is automatically unlinked from the Graph once we |
| 1320 info()->dependencies()); | 1345 // leave this scope below. |
| 1321 Run<TyperPhase>(&typer); | 1346 Typer typer(isolate(), data->graph(), info()->is_deoptimization_enabled() |
| 1322 RunPrintAndVerify("Typed"); | 1347 ? Typer::kDeoptimizationEnabled |
| 1348 : Typer::kNoFlags, |
| 1349 info()->dependencies()); |
| 1350 Run<TyperPhase>(&typer); |
| 1351 RunPrintAndVerify("Typed"); |
| 1323 | 1352 |
| 1324 BeginPhaseKind("lowering"); | 1353 BeginPhaseKind("lowering"); |
| 1325 | 1354 |
| 1326 // Lower JSOperators where we can determine types. | 1355 // Lower JSOperators where we can determine types. |
| 1327 Run<TypedLoweringPhase>(); | 1356 Run<TypedLoweringPhase>(); |
| 1328 RunPrintAndVerify("Lowered typed"); | 1357 RunPrintAndVerify("Lowered typed"); |
| 1329 | 1358 |
| 1330 if (FLAG_turbo_stress_loop_peeling) { | 1359 if (FLAG_turbo_stress_loop_peeling) { |
| 1331 Run<StressLoopPeelingPhase>(); | 1360 Run<StressLoopPeelingPhase>(); |
| 1332 RunPrintAndVerify("Loop peeled"); | 1361 RunPrintAndVerify("Loop peeled"); |
| 1362 } |
| 1363 |
| 1364 if (FLAG_experimental_turbo_escape) { |
| 1365 Run<EscapeAnalysisPhase>(); |
| 1366 RunPrintAndVerify("Escape Analysed"); |
| 1367 } |
| 1368 |
| 1369 // Select representations. |
| 1370 Run<RepresentationSelectionPhase>(); |
| 1371 RunPrintAndVerify("Representations selected"); |
| 1372 |
| 1373 // Run early optimization pass. |
| 1374 Run<EarlyOptimizationPhase>(); |
| 1375 RunPrintAndVerify("Early optimized"); |
| 1333 } | 1376 } |
| 1334 | 1377 |
| 1335 if (FLAG_experimental_turbo_escape) { | 1378 #ifdef DEBUG |
| 1336 Run<EscapeAnalysisPhase>(); | 1379 // From now on it is invalid to look at types on the nodes, because: |
| 1337 RunPrintAndVerify("Escape Analysed"); | 1380 // |
| 1338 } | 1381 // (a) The remaining passes (might) run concurrent to the main thread and |
| 1339 | 1382 // therefore must not access the Heap or the Isolate in an uncontrolled |
| 1340 // Select representations. | 1383 // way (as done by the type system), and |
| 1341 Run<RepresentationSelectionPhase>(); | 1384 // (b) the types on the nodes might not make sense after representation |
| 1342 RunPrintAndVerify("Representations selected"); | 1385 // selection due to the way we handle truncations; if we'd want to look |
| 1343 | 1386 // at types afterwards we'd essentially need to re-type (large portions |
| 1344 // Run early optimization pass. | 1387 // of) the graph. |
| 1345 Run<EarlyOptimizationPhase>(); | 1388 // |
| 1346 RunPrintAndVerify("Early optimized"); | 1389 // In order to catch bugs related to type access after this point we remove |
| 1390 // the types from the nodes at this point (currently only in Debug builds). |
| 1391 Run<UntyperPhase>(); |
| 1392 RunPrintAndVerify("Untyped", true); |
| 1393 #endif |
| 1347 | 1394 |
| 1348 EndPhaseKind(); | 1395 EndPhaseKind(); |
| 1349 | 1396 |
| 1350 return true; | 1397 return true; |
| 1351 } | 1398 } |
| 1352 | 1399 |
| 1353 bool Pipeline::OptimizeGraph(Linkage* linkage) { | 1400 bool Pipeline::OptimizeGraph(Linkage* linkage) { |
| 1354 PipelineData* data = this->data_; | 1401 PipelineData* data = this->data_; |
| 1355 | 1402 |
| 1356 BeginPhaseKind("block building"); | 1403 BeginPhaseKind("block building"); |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1713 data->DeleteRegisterAllocationZone(); | 1760 data->DeleteRegisterAllocationZone(); |
| 1714 } | 1761 } |
| 1715 | 1762 |
| 1716 CompilationInfo* Pipeline::info() const { return data_->info(); } | 1763 CompilationInfo* Pipeline::info() const { return data_->info(); } |
| 1717 | 1764 |
| 1718 Isolate* Pipeline::isolate() const { return info()->isolate(); } | 1765 Isolate* Pipeline::isolate() const { return info()->isolate(); } |
| 1719 | 1766 |
| 1720 } // namespace compiler | 1767 } // namespace compiler |
| 1721 } // namespace internal | 1768 } // namespace internal |
| 1722 } // namespace v8 | 1769 } // namespace v8 |
| OLD | NEW |