| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 // Each call to this function performs a move and deletes it from the move | 58 // Each call to this function performs a move and deletes it from the move |
| 59 // graph. We first recursively perform any move blocking this one. We mark a | 59 // graph. We first recursively perform any move blocking this one. We mark a |
| 60 // move as "pending" on entry to PerformMove in order to detect cycles in the | 60 // move as "pending" on entry to PerformMove in order to detect cycles in the |
| 61 // move graph. We use operand swaps to resolve cycles, which means that a | 61 // move graph. We use operand swaps to resolve cycles, which means that a |
| 62 // call to PerformMove could change any source operand in the move graph. | 62 // call to PerformMove could change any source operand in the move graph. |
| 63 DCHECK(!move->IsPending()); | 63 DCHECK(!move->IsPending()); |
| 64 DCHECK(!move->IsRedundant()); | 64 DCHECK(!move->IsRedundant()); |
| 65 | 65 |
| 66 // Clear this move's destination to indicate a pending move. The actual | 66 // Clear this move's destination to indicate a pending move. The actual |
| 67 // destination is saved on the side. | 67 // destination is saved on the side. |
| 68 DCHECK_NOT_NULL(move->source()); // Or else it will look eliminated. | 68 DCHECK(move->source()); // Or else it will look eliminated. |
| 69 InstructionOperand* destination = move->destination(); | 69 InstructionOperand* destination = move->destination(); |
| 70 move->set_destination(NULL); | 70 move->set_destination(NULL); |
| 71 | 71 |
| 72 // Perform a depth-first traversal of the move graph to resolve dependencies. | 72 // Perform a depth-first traversal of the move graph to resolve dependencies. |
| 73 // Any unperformed, unpending move with a source the same as this one's | 73 // Any unperformed, unpending move with a source the same as this one's |
| 74 // destination blocks this one so recursively perform all such moves. | 74 // destination blocks this one so recursively perform all such moves. |
| 75 for (op_iterator other = moves->begin(); other != moves->end(); ++other) { | 75 for (op_iterator other = moves->begin(); other != moves->end(); ++other) { |
| 76 if (other->Blocks(destination) && !other->IsPending()) { | 76 if (other->Blocks(destination) && !other->IsPending()) { |
| 77 // Though PerformMove can change any source operand in the move graph, | 77 // Though PerformMove can change any source operand in the move graph, |
| 78 // this call cannot create a blocking move via a swap (this loop does not | 78 // this call cannot create a blocking move via a swap (this loop does not |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 if (other->Blocks(source)) { | 127 if (other->Blocks(source)) { |
| 128 other->set_source(destination); | 128 other->set_source(destination); |
| 129 } else if (other->Blocks(destination)) { | 129 } else if (other->Blocks(destination)) { |
| 130 other->set_source(source); | 130 other->set_source(source); |
| 131 } | 131 } |
| 132 } | 132 } |
| 133 } | 133 } |
| 134 } | 134 } |
| 135 } | 135 } |
| 136 } // namespace v8::internal::compiler | 136 } // namespace v8::internal::compiler |
| OLD | NEW |