Index: src/x64/lithium-x64.cc |
diff --git a/src/x64/lithium-x64.cc b/src/x64/lithium-x64.cc |
index 16248ee1792d1cbc76ec5df1d47393f7b968c79f..5f624002c589572b675673b83da077e84e5da90c 100644 |
--- a/src/x64/lithium-x64.cc |
+++ b/src/x64/lithium-x64.cc |
@@ -879,6 +879,35 @@ void LChunkBuilder::VisitInstruction(HInstruction* current) { |
LInstruction* instr = current->CompileToLithium(this); |
if (instr != NULL) { |
+#if DEBUG |
+ // Make sure that the lithium instruction has either no fixed register |
+ // constraints in temps or the result OR no uses that are only used at |
+ // start. If this invariant doesn't hold, the register allocator can decide |
+ // to insert a split of a range immediately before the instruction due to an |
+ // already allocated register needing to be used for the instruction's fixed |
+ // register constraint. In this case, The register allocator won't see an |
+ // interference between the split child and the use-at-start (it would if |
+ // the it was just a plain use), so it is free to move the split child into |
+ // the same register that is used for the use-at-start. |
+ // See https://code.google.com/p/chromium/issues/detail?id=201590 |
+ if (!(instr->ClobbersRegisters() && instr->ClobbersDoubleRegisters())) { |
+ int fixed = 0; |
+ int used_at_start = 0; |
+ for (UseIterator it(instr); !it.Done(); it.Advance()) { |
+ LUnallocated* operand = LUnallocated::cast(it.Current()); |
+ if (operand->IsUsedAtStart()) ++used_at_start; |
+ } |
+ if (instr->Output() != NULL) { |
+ if (LUnallocated::cast(instr->Output())->HasFixedPolicy()) ++fixed; |
+ } |
+ for (TempIterator it(instr); !it.Done(); it.Advance()) { |
+ LUnallocated* operand = LUnallocated::cast(it.Current()); |
+ if (operand->HasFixedPolicy()) ++fixed; |
+ } |
+ ASSERT(fixed == 0 || used_at_start == 0); |
+ } |
+#endif |
+ |
if (FLAG_stress_pointer_maps && !instr->HasPointerMap()) { |
instr = AssignPointerMap(instr); |
} |