Chromium Code Reviews| 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/instruction-selector.h" | 5 #include "src/compiler/instruction-selector.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "src/base/adapters.h" | 9 #include "src/base/adapters.h" |
| 10 #include "src/compiler/instruction-selector-impl.h" | 10 #include "src/compiler/instruction-selector-impl.h" |
| 11 #include "src/compiler/node-matchers.h" | 11 #include "src/compiler/node-matchers.h" |
| 12 #include "src/compiler/pipeline.h" | 12 #include "src/compiler/pipeline.h" |
| 13 #include "src/compiler/schedule.h" | 13 #include "src/compiler/schedule.h" |
| 14 #include "src/compiler/state-values-utils.h" | 14 #include "src/compiler/state-values-utils.h" |
| 15 #include "src/deoptimizer.h" | 15 #include "src/deoptimizer.h" |
| 16 | 16 |
| 17 namespace v8 { | 17 namespace v8 { |
| 18 namespace internal { | 18 namespace internal { |
| 19 namespace compiler { | 19 namespace compiler { |
| 20 | 20 |
| 21 InstructionSelector::InstructionSelector( | 21 InstructionSelector::InstructionSelector( |
| 22 Zone* zone, size_t node_count, Linkage* linkage, | 22 Zone* zone, size_t node_count, Linkage* linkage, |
| 23 InstructionSequence* sequence, Schedule* schedule, | 23 InstructionSequence* sequence, Schedule* schedule, |
| 24 SourcePositionTable* source_positions, | 24 SourcePositionTable* source_positions, Frame* frame, |
| 25 SourcePositionMode source_position_mode, Features features) | 25 SourcePositionMode source_position_mode, Features features) |
| 26 : zone_(zone), | 26 : zone_(zone), |
| 27 linkage_(linkage), | 27 linkage_(linkage), |
| 28 sequence_(sequence), | 28 sequence_(sequence), |
| 29 source_positions_(source_positions), | 29 source_positions_(source_positions), |
| 30 source_position_mode_(source_position_mode), | 30 source_position_mode_(source_position_mode), |
| 31 features_(features), | 31 features_(features), |
| 32 schedule_(schedule), | 32 schedule_(schedule), |
| 33 current_block_(nullptr), | 33 current_block_(nullptr), |
| 34 instructions_(zone), | 34 instructions_(zone), |
| 35 defined_(node_count, false, zone), | 35 defined_(node_count, false, zone), |
| 36 used_(node_count, false, zone), | 36 used_(node_count, false, zone), |
| 37 virtual_registers_(node_count, | 37 virtual_registers_(node_count, |
| 38 InstructionOperand::kInvalidVirtualRegister, zone), | 38 InstructionOperand::kInvalidVirtualRegister, zone), |
| 39 scheduler_(nullptr) { | 39 scheduler_(nullptr), |
| 40 frame_(frame) { | |
| 40 instructions_.reserve(node_count); | 41 instructions_.reserve(node_count); |
| 41 } | 42 } |
| 42 | 43 |
| 43 | 44 |
| 44 void InstructionSelector::SelectInstructions() { | 45 void InstructionSelector::SelectInstructions() { |
| 45 // Mark the inputs of all phis in loop headers as used. | 46 // Mark the inputs of all phis in loop headers as used. |
| 46 BasicBlockVector* blocks = schedule()->rpo_order(); | 47 BasicBlockVector* blocks = schedule()->rpo_order(); |
| 47 for (auto const block : *blocks) { | 48 for (auto const block : *blocks) { |
| 48 if (!block->IsLoopHeader()) continue; | 49 if (!block->IsLoopHeader()) continue; |
| 49 DCHECK_LE(2u, block->PredecessorCount()); | 50 DCHECK_LE(2u, block->PredecessorCount()); |
| (...skipping 1009 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1059 case IrOpcode::kFloat64RoundTiesEven: | 1060 case IrOpcode::kFloat64RoundTiesEven: |
| 1060 return MarkAsFloat64(node), VisitFloat64RoundTiesEven(node); | 1061 return MarkAsFloat64(node), VisitFloat64RoundTiesEven(node); |
| 1061 case IrOpcode::kFloat64ExtractLowWord32: | 1062 case IrOpcode::kFloat64ExtractLowWord32: |
| 1062 return MarkAsWord32(node), VisitFloat64ExtractLowWord32(node); | 1063 return MarkAsWord32(node), VisitFloat64ExtractLowWord32(node); |
| 1063 case IrOpcode::kFloat64ExtractHighWord32: | 1064 case IrOpcode::kFloat64ExtractHighWord32: |
| 1064 return MarkAsWord32(node), VisitFloat64ExtractHighWord32(node); | 1065 return MarkAsWord32(node), VisitFloat64ExtractHighWord32(node); |
| 1065 case IrOpcode::kFloat64InsertLowWord32: | 1066 case IrOpcode::kFloat64InsertLowWord32: |
| 1066 return MarkAsFloat64(node), VisitFloat64InsertLowWord32(node); | 1067 return MarkAsFloat64(node), VisitFloat64InsertLowWord32(node); |
| 1067 case IrOpcode::kFloat64InsertHighWord32: | 1068 case IrOpcode::kFloat64InsertHighWord32: |
| 1068 return MarkAsFloat64(node), VisitFloat64InsertHighWord32(node); | 1069 return MarkAsFloat64(node), VisitFloat64InsertHighWord32(node); |
| 1070 case IrOpcode::kStackSlot: | |
| 1071 return VisitStackSlot(node); | |
| 1069 case IrOpcode::kLoadStackPointer: | 1072 case IrOpcode::kLoadStackPointer: |
| 1070 return VisitLoadStackPointer(node); | 1073 return VisitLoadStackPointer(node); |
| 1071 case IrOpcode::kLoadFramePointer: | 1074 case IrOpcode::kLoadFramePointer: |
| 1072 return VisitLoadFramePointer(node); | 1075 return VisitLoadFramePointer(node); |
| 1073 case IrOpcode::kCheckedLoad: { | 1076 case IrOpcode::kCheckedLoad: { |
| 1074 MachineRepresentation rep = | 1077 MachineRepresentation rep = |
| 1075 CheckedLoadRepresentationOf(node->op()).representation(); | 1078 CheckedLoadRepresentationOf(node->op()).representation(); |
| 1076 MarkAsRepresentation(rep, node); | 1079 MarkAsRepresentation(rep, node); |
| 1077 return VisitCheckedLoad(node); | 1080 return VisitCheckedLoad(node); |
| 1078 } | 1081 } |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1126 inputs[1] = g.Label(sw.default_branch); | 1129 inputs[1] = g.Label(sw.default_branch); |
| 1127 for (size_t index = 0; index < sw.case_count; ++index) { | 1130 for (size_t index = 0; index < sw.case_count; ++index) { |
| 1128 int32_t value = sw.case_values[index]; | 1131 int32_t value = sw.case_values[index]; |
| 1129 BasicBlock* branch = sw.case_branches[index]; | 1132 BasicBlock* branch = sw.case_branches[index]; |
| 1130 inputs[index * 2 + 2 + 0] = g.TempImmediate(value); | 1133 inputs[index * 2 + 2 + 0] = g.TempImmediate(value); |
| 1131 inputs[index * 2 + 2 + 1] = g.Label(branch); | 1134 inputs[index * 2 + 2 + 1] = g.Label(branch); |
| 1132 } | 1135 } |
| 1133 Emit(kArchLookupSwitch, 0, nullptr, input_count, inputs, 0, nullptr); | 1136 Emit(kArchLookupSwitch, 0, nullptr, input_count, inputs, 0, nullptr); |
| 1134 } | 1137 } |
| 1135 | 1138 |
| 1139 void InstructionSelector::VisitStackSlot(Node* node) { | |
| 1140 MachineRepresentation rep = StackSlotRepresentationOf(node->op()); | |
|
titzer
2016/01/28 09:02:18
You should probably use ElemSizeLog2Of(MachineRepr
ahaas
2016/01/28 14:55:44
Done.
| |
| 1141 int size; | |
| 1142 if (rep == MachineRepresentation::kFloat64) { | |
| 1143 size = kDoubleSize; | |
| 1144 } else if (rep == MachineRepresentation::kWord64) { | |
| 1145 size = kInt64Size; | |
| 1146 } else { | |
| 1147 size = kPointerSize; | |
| 1148 } | |
| 1149 int slot = frame_->AllocateSpillSlot(size); | |
| 1150 OperandGenerator g(this); | |
| 1151 | |
| 1152 Emit(kArchStackSlot, g.DefineAsRegister(node), | |
| 1153 sequence()->AddImmediate(Constant(slot)), 0, nullptr); | |
| 1154 } | |
| 1136 | 1155 |
| 1137 // 32 bit targets do not implement the following instructions. | 1156 // 32 bit targets do not implement the following instructions. |
| 1138 #if V8_TARGET_ARCH_32_BIT | 1157 #if V8_TARGET_ARCH_32_BIT |
| 1139 | 1158 |
| 1140 void InstructionSelector::VisitWord64And(Node* node) { UNIMPLEMENTED(); } | 1159 void InstructionSelector::VisitWord64And(Node* node) { UNIMPLEMENTED(); } |
| 1141 | 1160 |
| 1142 | 1161 |
| 1143 void InstructionSelector::VisitWord64Or(Node* node) { UNIMPLEMENTED(); } | 1162 void InstructionSelector::VisitWord64Or(Node* node) { UNIMPLEMENTED(); } |
| 1144 | 1163 |
| 1145 | 1164 |
| (...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1625 return new (instruction_zone()) FrameStateDescriptor( | 1644 return new (instruction_zone()) FrameStateDescriptor( |
| 1626 instruction_zone(), state_info.type(), state_info.bailout_id(), | 1645 instruction_zone(), state_info.type(), state_info.bailout_id(), |
| 1627 state_info.state_combine(), parameters, locals, stack, | 1646 state_info.state_combine(), parameters, locals, stack, |
| 1628 state_info.shared_info(), outer_state); | 1647 state_info.shared_info(), outer_state); |
| 1629 } | 1648 } |
| 1630 | 1649 |
| 1631 | 1650 |
| 1632 } // namespace compiler | 1651 } // namespace compiler |
| 1633 } // namespace internal | 1652 } // namespace internal |
| 1634 } // namespace v8 | 1653 } // namespace v8 |
| OLD | NEW |