| 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/move-optimizer.h" | 5 #include "src/compiler/move-optimizer.h" | 
| 6 | 6 | 
| 7 namespace v8 { | 7 namespace v8 { | 
| 8 namespace internal { | 8 namespace internal { | 
| 9 namespace compiler { | 9 namespace compiler { | 
| 10 | 10 | 
| 11 namespace { | 11 namespace { | 
| 12 | 12 | 
| 13 typedef std::pair<InstructionOperand, InstructionOperand> MoveKey; | 13 typedef std::pair<InstructionOperand, InstructionOperand> MoveKey; | 
| 14 typedef ZoneMap<MoveKey, unsigned> MoveMap; | 14 typedef ZoneMap<MoveKey, unsigned> MoveMap; | 
| 15 typedef ZoneSet<InstructionOperand> OperandSet; | 15 typedef ZoneSet<InstructionOperand> OperandSet; | 
| 16 | 16 | 
| 17 | 17 | 
| 18 bool GapsCanMoveOver(Instruction* instr) { | 18 bool GapsCanMoveOver(Instruction* instr) { return instr->IsNop(); } | 
| 19   return instr->IsSourcePosition() || instr->IsNop(); |  | 
| 20 } |  | 
| 21 | 19 | 
| 22 | 20 | 
| 23 int FindFirstNonEmptySlot(Instruction* instr) { | 21 int FindFirstNonEmptySlot(Instruction* instr) { | 
| 24   int i = Instruction::FIRST_GAP_POSITION; | 22   int i = Instruction::FIRST_GAP_POSITION; | 
| 25   for (; i <= Instruction::LAST_GAP_POSITION; i++) { | 23   for (; i <= Instruction::LAST_GAP_POSITION; i++) { | 
| 26     auto move = instr->parallel_moves()[i]; | 24     auto move = instr->parallel_moves()[i]; | 
| 27     if (move == nullptr) continue; | 25     if (move == nullptr) continue; | 
| 28     auto move_ops = move->move_operands(); | 26     auto move_ops = move->move_operands(); | 
| 29     auto op = move_ops->begin(); | 27     auto op = move_ops->begin(); | 
| 30     for (; op != move_ops->end(); ++op) { | 28     for (; op != move_ops->end(); ++op) { | 
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 138 } | 136 } | 
| 139 | 137 | 
| 140 | 138 | 
| 141 void MoveOptimizer::OptimizeMerge(InstructionBlock* block) { | 139 void MoveOptimizer::OptimizeMerge(InstructionBlock* block) { | 
| 142   DCHECK(block->PredecessorCount() > 1); | 140   DCHECK(block->PredecessorCount() > 1); | 
| 143   // Ensure that the last instruction in all incoming blocks don't contain | 141   // Ensure that the last instruction in all incoming blocks don't contain | 
| 144   // things that would prevent moving gap moves across them. | 142   // things that would prevent moving gap moves across them. | 
| 145   for (auto pred_index : block->predecessors()) { | 143   for (auto pred_index : block->predecessors()) { | 
| 146     auto pred = code()->InstructionBlockAt(pred_index); | 144     auto pred = code()->InstructionBlockAt(pred_index); | 
| 147     auto last_instr = code()->instructions()[pred->last_instruction_index()]; | 145     auto last_instr = code()->instructions()[pred->last_instruction_index()]; | 
| 148     if (last_instr->IsSourcePosition()) continue; |  | 
| 149     if (last_instr->IsCall()) return; | 146     if (last_instr->IsCall()) return; | 
| 150     if (last_instr->TempCount() != 0) return; | 147     if (last_instr->TempCount() != 0) return; | 
| 151     if (last_instr->OutputCount() != 0) return; | 148     if (last_instr->OutputCount() != 0) return; | 
| 152     for (size_t i = 0; i < last_instr->InputCount(); ++i) { | 149     for (size_t i = 0; i < last_instr->InputCount(); ++i) { | 
| 153       auto op = last_instr->InputAt(i); | 150       auto op = last_instr->InputAt(i); | 
| 154       if (!op->IsConstant() && !op->IsImmediate()) return; | 151       if (!op->IsConstant() && !op->IsImmediate()) return; | 
| 155     } | 152     } | 
| 156   } | 153   } | 
| 157   // TODO(dcarney): pass a ZonePool down for this? | 154   // TODO(dcarney): pass a ZonePool down for this? | 
| 158   MoveMap move_map(local_zone()); | 155   MoveMap move_map(local_zone()); | 
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 289     std::swap(*new_move, *it); | 286     std::swap(*new_move, *it); | 
| 290     ++it; | 287     ++it; | 
| 291   } | 288   } | 
| 292   DCHECK_EQ(it, slot_1->move_operands()->end()); | 289   DCHECK_EQ(it, slot_1->move_operands()->end()); | 
| 293   new_moves.clear(); | 290   new_moves.clear(); | 
| 294 } | 291 } | 
| 295 | 292 | 
| 296 }  // namespace compiler | 293 }  // namespace compiler | 
| 297 }  // namespace internal | 294 }  // namespace internal | 
| 298 }  // namespace v8 | 295 }  // namespace v8 | 
| OLD | NEW | 
|---|