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/base/adapters.h" | 5 #include "src/base/adapters.h" |
6 #include "src/compiler/linkage.h" | 6 #include "src/compiler/linkage.h" |
7 #include "src/compiler/register-allocator.h" | 7 #include "src/compiler/register-allocator.h" |
8 #include "src/string-stream.h" | 8 #include "src/string-stream.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
(...skipping 2166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2177 } | 2177 } |
2178 | 2178 |
2179 | 2179 |
2180 void LiveRangeBuilder::ProcessPhis(const InstructionBlock* block, | 2180 void LiveRangeBuilder::ProcessPhis(const InstructionBlock* block, |
2181 BitVector* live) { | 2181 BitVector* live) { |
2182 for (PhiInstruction* phi : block->phis()) { | 2182 for (PhiInstruction* phi : block->phis()) { |
2183 // The live range interval already ends at the first instruction of the | 2183 // The live range interval already ends at the first instruction of the |
2184 // block. | 2184 // block. |
2185 int phi_vreg = phi->virtual_register(); | 2185 int phi_vreg = phi->virtual_register(); |
2186 live->Remove(phi_vreg); | 2186 live->Remove(phi_vreg); |
2187 InstructionOperand* hint = nullptr; | 2187 // Select the hint from the first predecessor block that preceeds this block |
| 2188 // in the rpo ordering. Prefer non-deferred blocks. The enforcement of |
| 2189 // hinting in rpo order is required because hint resolution that happens |
| 2190 // later in the compiler pipeline visits instructions in reverse rpo, |
| 2191 // relying on the fact that phis are encountered before their hints. |
| 2192 const Instruction* instr = nullptr; |
2188 const InstructionBlock::Predecessors& predecessors = block->predecessors(); | 2193 const InstructionBlock::Predecessors& predecessors = block->predecessors(); |
2189 const InstructionBlock* predecessor_block = | 2194 for (size_t i = 0; i < predecessors.size(); ++i) { |
2190 code()->InstructionBlockAt(predecessors[0]); | 2195 const InstructionBlock* predecessor_block = |
2191 const Instruction* instr = GetLastInstruction(code(), predecessor_block); | 2196 code()->InstructionBlockAt(predecessors[i]); |
2192 if (predecessor_block->IsDeferred()) { | 2197 if (predecessor_block->rpo_number() < block->rpo_number()) { |
2193 // "Prefer the hint from the first non-deferred predecessor, if any. | 2198 instr = GetLastInstruction(code(), predecessor_block); |
2194 for (size_t i = 1; i < predecessors.size(); ++i) { | 2199 if (!predecessor_block->IsDeferred()) break; |
2195 predecessor_block = code()->InstructionBlockAt(predecessors[i]); | |
2196 if (!predecessor_block->IsDeferred()) { | |
2197 instr = GetLastInstruction(code(), predecessor_block); | |
2198 break; | |
2199 } | |
2200 } | 2200 } |
2201 } | 2201 } |
2202 DCHECK_NOT_NULL(instr); | 2202 DCHECK_NOT_NULL(instr); |
2203 | 2203 |
| 2204 InstructionOperand* hint = nullptr; |
2204 for (MoveOperands* move : *instr->GetParallelMove(Instruction::END)) { | 2205 for (MoveOperands* move : *instr->GetParallelMove(Instruction::END)) { |
2205 InstructionOperand& to = move->destination(); | 2206 InstructionOperand& to = move->destination(); |
2206 if (to.IsUnallocated() && | 2207 if (to.IsUnallocated() && |
2207 UnallocatedOperand::cast(to).virtual_register() == phi_vreg) { | 2208 UnallocatedOperand::cast(to).virtual_register() == phi_vreg) { |
2208 hint = &move->source(); | 2209 hint = &move->source(); |
2209 break; | 2210 break; |
2210 } | 2211 } |
2211 } | 2212 } |
2212 DCHECK(hint != nullptr); | 2213 DCHECK(hint != nullptr); |
2213 LifetimePosition block_start = LifetimePosition::GapFromInstructionIndex( | 2214 LifetimePosition block_start = LifetimePosition::GapFromInstructionIndex( |
(...skipping 1443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3657 } | 3658 } |
3658 } | 3659 } |
3659 } | 3660 } |
3660 } | 3661 } |
3661 } | 3662 } |
3662 | 3663 |
3663 | 3664 |
3664 } // namespace compiler | 3665 } // namespace compiler |
3665 } // namespace internal | 3666 } // namespace internal |
3666 } // namespace v8 | 3667 } // namespace v8 |
OLD | NEW |