| 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/compiler/instruction-selector-impl.h" | 9 #include "src/compiler/instruction-selector-impl.h" |
| 10 #include "src/compiler/node-matchers.h" | 10 #include "src/compiler/node-matchers.h" |
| 11 #include "src/compiler/node-properties.h" | 11 #include "src/compiler/node-properties.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 | 15 |
| 15 namespace v8 { | 16 namespace v8 { |
| 16 namespace internal { | 17 namespace internal { |
| 17 namespace compiler { | 18 namespace compiler { |
| 18 | 19 |
| 19 InstructionSelector::InstructionSelector(Zone* zone, size_t node_count, | 20 InstructionSelector::InstructionSelector(Zone* zone, size_t node_count, |
| 20 Linkage* linkage, | 21 Linkage* linkage, |
| 21 InstructionSequence* sequence, | 22 InstructionSequence* sequence, |
| 22 Schedule* schedule, | 23 Schedule* schedule, |
| 23 SourcePositionTable* source_positions, | 24 SourcePositionTable* source_positions, |
| (...skipping 1113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1137 Emit(kArchDeoptimize, 0, nullptr, arg_count, &args.front(), 0, nullptr); | 1138 Emit(kArchDeoptimize, 0, nullptr, arg_count, &args.front(), 0, nullptr); |
| 1138 } | 1139 } |
| 1139 | 1140 |
| 1140 | 1141 |
| 1141 void InstructionSelector::VisitThrow(Node* value) { | 1142 void InstructionSelector::VisitThrow(Node* value) { |
| 1142 OperandGenerator g(this); | 1143 OperandGenerator g(this); |
| 1143 Emit(kArchNop, g.NoOutput()); // TODO(titzer) | 1144 Emit(kArchNop, g.NoOutput()); // TODO(titzer) |
| 1144 } | 1145 } |
| 1145 | 1146 |
| 1146 | 1147 |
| 1147 void InstructionSelector::FillTypeVectorFromStateValues( | |
| 1148 ZoneVector<MachineType>* types, Node* state_values) { | |
| 1149 DCHECK(state_values->opcode() == IrOpcode::kStateValues); | |
| 1150 int count = state_values->InputCount(); | |
| 1151 types->reserve(static_cast<size_t>(count)); | |
| 1152 for (int i = 0; i < count; i++) { | |
| 1153 types->push_back(GetMachineType(state_values->InputAt(i))); | |
| 1154 } | |
| 1155 } | |
| 1156 | |
| 1157 | |
| 1158 FrameStateDescriptor* InstructionSelector::GetFrameStateDescriptor( | 1148 FrameStateDescriptor* InstructionSelector::GetFrameStateDescriptor( |
| 1159 Node* state) { | 1149 Node* state) { |
| 1160 DCHECK(state->opcode() == IrOpcode::kFrameState); | 1150 DCHECK(state->opcode() == IrOpcode::kFrameState); |
| 1161 DCHECK_EQ(5, state->InputCount()); | 1151 DCHECK_EQ(5, state->InputCount()); |
| 1162 DCHECK_EQ(IrOpcode::kStateValues, state->InputAt(0)->opcode()); | 1152 DCHECK_EQ(IrOpcode::kStateValues, state->InputAt(0)->opcode()); |
| 1163 DCHECK_EQ(IrOpcode::kStateValues, state->InputAt(1)->opcode()); | 1153 DCHECK_EQ(IrOpcode::kStateValues, state->InputAt(1)->opcode()); |
| 1164 DCHECK_EQ(IrOpcode::kStateValues, state->InputAt(2)->opcode()); | 1154 DCHECK_EQ(IrOpcode::kStateValues, state->InputAt(2)->opcode()); |
| 1165 FrameStateCallInfo state_info = OpParameter<FrameStateCallInfo>(state); | 1155 FrameStateCallInfo state_info = OpParameter<FrameStateCallInfo>(state); |
| 1166 | 1156 |
| 1167 int parameters = state->InputAt(0)->InputCount(); | 1157 int parameters = |
| 1168 int locals = state->InputAt(1)->InputCount(); | 1158 static_cast<int>(StateValuesAccess(state->InputAt(0)).size()); |
| 1169 int stack = state->InputAt(2)->InputCount(); | 1159 int locals = static_cast<int>(StateValuesAccess(state->InputAt(1)).size()); |
| 1160 int stack = static_cast<int>(StateValuesAccess(state->InputAt(2)).size()); |
| 1170 | 1161 |
| 1171 FrameStateDescriptor* outer_state = NULL; | 1162 FrameStateDescriptor* outer_state = NULL; |
| 1172 Node* outer_node = state->InputAt(4); | 1163 Node* outer_node = state->InputAt(4); |
| 1173 if (outer_node->opcode() == IrOpcode::kFrameState) { | 1164 if (outer_node->opcode() == IrOpcode::kFrameState) { |
| 1174 outer_state = GetFrameStateDescriptor(outer_node); | 1165 outer_state = GetFrameStateDescriptor(outer_node); |
| 1175 } | 1166 } |
| 1176 | 1167 |
| 1177 return new (instruction_zone()) FrameStateDescriptor( | 1168 return new (instruction_zone()) FrameStateDescriptor( |
| 1178 instruction_zone(), state_info, parameters, locals, stack, outer_state); | 1169 instruction_zone(), state_info, parameters, locals, stack, outer_state); |
| 1179 } | 1170 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1203 | 1194 |
| 1204 Node* parameters = state->InputAt(0); | 1195 Node* parameters = state->InputAt(0); |
| 1205 Node* locals = state->InputAt(1); | 1196 Node* locals = state->InputAt(1); |
| 1206 Node* stack = state->InputAt(2); | 1197 Node* stack = state->InputAt(2); |
| 1207 Node* context = state->InputAt(3); | 1198 Node* context = state->InputAt(3); |
| 1208 | 1199 |
| 1209 DCHECK_EQ(IrOpcode::kStateValues, parameters->op()->opcode()); | 1200 DCHECK_EQ(IrOpcode::kStateValues, parameters->op()->opcode()); |
| 1210 DCHECK_EQ(IrOpcode::kStateValues, locals->op()->opcode()); | 1201 DCHECK_EQ(IrOpcode::kStateValues, locals->op()->opcode()); |
| 1211 DCHECK_EQ(IrOpcode::kStateValues, stack->op()->opcode()); | 1202 DCHECK_EQ(IrOpcode::kStateValues, stack->op()->opcode()); |
| 1212 | 1203 |
| 1213 DCHECK_EQ(static_cast<int>(descriptor->parameters_count()), | 1204 DCHECK_EQ(descriptor->parameters_count(), |
| 1214 parameters->InputCount()); | 1205 StateValuesAccess(parameters).size()); |
| 1215 DCHECK_EQ(static_cast<int>(descriptor->locals_count()), locals->InputCount()); | 1206 DCHECK_EQ(descriptor->locals_count(), StateValuesAccess(locals).size()); |
| 1216 DCHECK_EQ(static_cast<int>(descriptor->stack_count()), stack->InputCount()); | 1207 DCHECK_EQ(descriptor->stack_count(), StateValuesAccess(stack).size()); |
| 1217 | 1208 |
| 1218 ZoneVector<MachineType> types(instruction_zone()); | 1209 ZoneVector<MachineType> types(instruction_zone()); |
| 1219 types.reserve(descriptor->GetSize()); | 1210 types.reserve(descriptor->GetSize()); |
| 1220 | 1211 |
| 1221 OperandGenerator g(this); | 1212 OperandGenerator g(this); |
| 1222 size_t value_index = 0; | 1213 size_t value_index = 0; |
| 1223 for (int i = 0; i < static_cast<int>(descriptor->parameters_count()); i++) { | 1214 for (Node* input_node : StateValuesAccess(parameters)) { |
| 1224 Node* input_node = parameters->InputAt(i); | |
| 1225 inputs->push_back(UseOrImmediate(&g, input_node)); | 1215 inputs->push_back(UseOrImmediate(&g, input_node)); |
| 1226 descriptor->SetType(value_index++, GetMachineType(input_node)); | 1216 descriptor->SetType(value_index++, GetMachineType(input_node)); |
| 1227 } | 1217 } |
| 1228 if (descriptor->HasContext()) { | 1218 if (descriptor->HasContext()) { |
| 1229 inputs->push_back(UseOrImmediate(&g, context)); | 1219 inputs->push_back(UseOrImmediate(&g, context)); |
| 1230 descriptor->SetType(value_index++, kMachAnyTagged); | 1220 descriptor->SetType(value_index++, kMachAnyTagged); |
| 1231 } | 1221 } |
| 1232 for (int i = 0; i < static_cast<int>(descriptor->locals_count()); i++) { | 1222 for (Node* input_node : StateValuesAccess(locals)) { |
| 1233 Node* input_node = locals->InputAt(i); | |
| 1234 inputs->push_back(UseOrImmediate(&g, input_node)); | 1223 inputs->push_back(UseOrImmediate(&g, input_node)); |
| 1235 descriptor->SetType(value_index++, GetMachineType(input_node)); | 1224 descriptor->SetType(value_index++, GetMachineType(input_node)); |
| 1236 } | 1225 } |
| 1237 for (int i = 0; i < static_cast<int>(descriptor->stack_count()); i++) { | 1226 for (Node* input_node : StateValuesAccess(stack)) { |
| 1238 Node* input_node = stack->InputAt(i); | |
| 1239 inputs->push_back(UseOrImmediate(&g, input_node)); | 1227 inputs->push_back(UseOrImmediate(&g, input_node)); |
| 1240 descriptor->SetType(value_index++, GetMachineType(input_node)); | 1228 descriptor->SetType(value_index++, GetMachineType(input_node)); |
| 1241 } | 1229 } |
| 1242 DCHECK(value_index == descriptor->GetSize()); | 1230 DCHECK(value_index == descriptor->GetSize()); |
| 1243 } | 1231 } |
| 1244 | 1232 |
| 1245 | 1233 |
| 1246 #if !V8_TURBOFAN_BACKEND | 1234 #if !V8_TURBOFAN_BACKEND |
| 1247 | 1235 |
| 1248 #define DECLARE_UNIMPLEMENTED_SELECTOR(x) \ | 1236 #define DECLARE_UNIMPLEMENTED_SELECTOR(x) \ |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1274 MachineOperatorBuilder::Flags | 1262 MachineOperatorBuilder::Flags |
| 1275 InstructionSelector::SupportedMachineOperatorFlags() { | 1263 InstructionSelector::SupportedMachineOperatorFlags() { |
| 1276 return MachineOperatorBuilder::Flag::kNoFlags; | 1264 return MachineOperatorBuilder::Flag::kNoFlags; |
| 1277 } | 1265 } |
| 1278 | 1266 |
| 1279 #endif // !V8_TURBOFAN_BACKEND | 1267 #endif // !V8_TURBOFAN_BACKEND |
| 1280 | 1268 |
| 1281 } // namespace compiler | 1269 } // namespace compiler |
| 1282 } // namespace internal | 1270 } // namespace internal |
| 1283 } // namespace v8 | 1271 } // namespace v8 |
| OLD | NEW |