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 "src/compiler/instruction-selector-impl.h" | 7 #include "src/compiler/instruction-selector-impl.h" |
8 #include "src/compiler/node-matchers.h" | 8 #include "src/compiler/node-matchers.h" |
9 #include "src/compiler/node-properties-inl.h" | 9 #include "src/compiler/node-properties-inl.h" |
10 #include "src/compiler/pipeline.h" | 10 #include "src/compiler/pipeline.h" |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 } | 212 } |
213 | 213 |
214 | 214 |
215 void InstructionSelector::MarkAsReference(Node* node) { | 215 void InstructionSelector::MarkAsReference(Node* node) { |
216 DCHECK_NOT_NULL(node); | 216 DCHECK_NOT_NULL(node); |
217 DCHECK(!IsDouble(node)); | 217 DCHECK(!IsDouble(node)); |
218 sequence()->MarkAsReference(sequence()->GetVirtualRegister(node)); | 218 sequence()->MarkAsReference(sequence()->GetVirtualRegister(node)); |
219 } | 219 } |
220 | 220 |
221 | 221 |
| 222 void InstructionSelector::MarkAsRepresentation(MachineType rep, |
| 223 InstructionOperand* op) { |
| 224 UnallocatedOperand* unalloc = UnallocatedOperand::cast(op); |
| 225 switch (RepresentationOf(rep)) { |
| 226 case kRepFloat32: |
| 227 case kRepFloat64: |
| 228 sequence()->MarkAsDouble(unalloc->virtual_register()); |
| 229 break; |
| 230 case kRepTagged: |
| 231 sequence()->MarkAsReference(unalloc->virtual_register()); |
| 232 break; |
| 233 default: |
| 234 break; |
| 235 } |
| 236 } |
| 237 |
| 238 |
222 void InstructionSelector::MarkAsRepresentation(MachineType rep, Node* node) { | 239 void InstructionSelector::MarkAsRepresentation(MachineType rep, Node* node) { |
223 DCHECK_NOT_NULL(node); | 240 DCHECK_NOT_NULL(node); |
224 switch (RepresentationOf(rep)) { | 241 switch (RepresentationOf(rep)) { |
225 case kRepFloat32: | 242 case kRepFloat32: |
226 case kRepFloat64: | 243 case kRepFloat64: |
227 MarkAsDouble(node); | 244 MarkAsDouble(node); |
228 break; | 245 break; |
229 case kRepTagged: | 246 case kRepTagged: |
230 MarkAsReference(node); | 247 MarkAsReference(node); |
231 break; | 248 break; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 if (buffer->descriptor->ReturnCount() > 0) { | 284 if (buffer->descriptor->ReturnCount() > 0) { |
268 // Collect the projections that represent multiple outputs from this call. | 285 // Collect the projections that represent multiple outputs from this call. |
269 if (buffer->descriptor->ReturnCount() == 1) { | 286 if (buffer->descriptor->ReturnCount() == 1) { |
270 buffer->output_nodes.push_back(call); | 287 buffer->output_nodes.push_back(call); |
271 } else { | 288 } else { |
272 buffer->output_nodes.resize(buffer->descriptor->ReturnCount(), NULL); | 289 buffer->output_nodes.resize(buffer->descriptor->ReturnCount(), NULL); |
273 call->CollectProjections(&buffer->output_nodes); | 290 call->CollectProjections(&buffer->output_nodes); |
274 } | 291 } |
275 | 292 |
276 // Filter out the outputs that aren't live because no projection uses them. | 293 // Filter out the outputs that aren't live because no projection uses them. |
| 294 size_t outputs_needed_by_framestate = |
| 295 buffer->frame_state_descriptor == NULL |
| 296 ? 0 |
| 297 : buffer->frame_state_descriptor->state_combine() |
| 298 .ConsumedOutputCount(); |
277 for (size_t i = 0; i < buffer->output_nodes.size(); i++) { | 299 for (size_t i = 0; i < buffer->output_nodes.size(); i++) { |
278 if (buffer->output_nodes[i] != NULL) { | 300 bool output_is_live = |
279 Node* output = buffer->output_nodes[i]; | 301 buffer->output_nodes[i] != NULL || i < outputs_needed_by_framestate; |
| 302 if (output_is_live) { |
280 MachineType type = | 303 MachineType type = |
281 buffer->descriptor->GetReturnType(static_cast<int>(i)); | 304 buffer->descriptor->GetReturnType(static_cast<int>(i)); |
282 LinkageLocation location = | 305 LinkageLocation location = |
283 buffer->descriptor->GetReturnLocation(static_cast<int>(i)); | 306 buffer->descriptor->GetReturnLocation(static_cast<int>(i)); |
284 MarkAsRepresentation(type, output); | 307 |
285 buffer->outputs.push_back(g.DefineAsLocation(output, location, type)); | 308 Node* output = buffer->output_nodes[i]; |
| 309 InstructionOperand* op = |
| 310 output == NULL ? g.TempLocation(location, type) |
| 311 : g.DefineAsLocation(output, location, type); |
| 312 MarkAsRepresentation(type, op); |
| 313 |
| 314 buffer->outputs.push_back(op); |
286 } | 315 } |
287 } | 316 } |
288 } | 317 } |
289 | 318 |
290 // The first argument is always the callee code. | 319 // The first argument is always the callee code. |
291 Node* callee = call->InputAt(0); | 320 Node* callee = call->InputAt(0); |
292 switch (buffer->descriptor->kind()) { | 321 switch (buffer->descriptor->kind()) { |
293 case CallDescriptor::kCallCodeObject: | 322 case CallDescriptor::kCallCodeObject: |
294 buffer->instruction_args.push_back( | 323 buffer->instruction_args.push_back( |
295 (call_code_immediate && callee->opcode() == IrOpcode::kHeapConstant) | 324 (call_code_immediate && callee->opcode() == IrOpcode::kHeapConstant) |
(...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1040 void InstructionSelector::VisitBranch(Node* branch, BasicBlock* tbranch, | 1069 void InstructionSelector::VisitBranch(Node* branch, BasicBlock* tbranch, |
1041 BasicBlock* fbranch) { | 1070 BasicBlock* fbranch) { |
1042 UNIMPLEMENTED(); | 1071 UNIMPLEMENTED(); |
1043 } | 1072 } |
1044 | 1073 |
1045 #endif // !V8_TURBOFAN_BACKEND | 1074 #endif // !V8_TURBOFAN_BACKEND |
1046 | 1075 |
1047 } // namespace compiler | 1076 } // namespace compiler |
1048 } // namespace internal | 1077 } // namespace internal |
1049 } // namespace v8 | 1078 } // namespace v8 |
OLD | NEW |