| 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/gap-resolver.h" | 5 #include "src/compiler/gap-resolver.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <functional> | 8 #include <functional> |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 void GapResolver::Resolve(ParallelMove* moves) const { | 27 void GapResolver::Resolve(ParallelMove* moves) const { |
| 28 // Clear redundant moves. | 28 // Clear redundant moves. |
| 29 auto it = | 29 auto it = |
| 30 std::remove_if(moves->begin(), moves->end(), std::ptr_fun(IsRedundant)); | 30 std::remove_if(moves->begin(), moves->end(), std::ptr_fun(IsRedundant)); |
| 31 moves->erase(it, moves->end()); | 31 moves->erase(it, moves->end()); |
| 32 for (MoveOperands* move : *moves) { | 32 for (MoveOperands* move : *moves) { |
| 33 if (!move->IsEliminated()) PerformMove(moves, move); | 33 if (!move->IsEliminated()) PerformMove(moves, move); |
| 34 } | 34 } |
| 35 } | 35 } |
| 36 | 36 |
| 37 | |
| 38 void GapResolver::PerformMove(ParallelMove* moves, MoveOperands* move) const { | 37 void GapResolver::PerformMove(ParallelMove* moves, MoveOperands* move) const { |
| 39 // Each call to this function performs a move and deletes it from the move | 38 // Each call to this function performs a move and deletes it from the move |
| 40 // graph. We first recursively perform any move blocking this one. We mark a | 39 // graph. We first recursively perform any move blocking this one. We mark a |
| 41 // move as "pending" on entry to PerformMove in order to detect cycles in the | 40 // move as "pending" on entry to PerformMove in order to detect cycles in the |
| 42 // move graph. We use operand swaps to resolve cycles, which means that a | 41 // move graph. We use operand swaps to resolve cycles, which means that a |
| 43 // call to PerformMove could change any source operand in the move graph. | 42 // call to PerformMove could change any source operand in the move graph. |
| 44 DCHECK(!move->IsPending()); | 43 DCHECK(!move->IsPending()); |
| 45 DCHECK(!move->IsRedundant()); | 44 DCHECK(!move->IsRedundant()); |
| 46 | 45 |
| 47 // Clear this move's destination to indicate a pending move. The actual | 46 // Clear this move's destination to indicate a pending move. The actual |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 if (other->Blocks(source)) { | 106 if (other->Blocks(source)) { |
| 108 other->set_source(destination); | 107 other->set_source(destination); |
| 109 } else if (other->Blocks(destination)) { | 108 } else if (other->Blocks(destination)) { |
| 110 other->set_source(source); | 109 other->set_source(source); |
| 111 } | 110 } |
| 112 } | 111 } |
| 113 } | 112 } |
| 114 } // namespace compiler | 113 } // namespace compiler |
| 115 } // namespace internal | 114 } // namespace internal |
| 116 } // namespace v8 | 115 } // namespace v8 |
| OLD | NEW |