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/base/adapters.h" | 5 #include "src/base/adapters.h" |
6 #include "src/compiler/instruction-selector-impl.h" | 6 #include "src/compiler/instruction-selector-impl.h" |
7 #include "src/compiler/node-matchers.h" | 7 #include "src/compiler/node-matchers.h" |
8 #include "src/compiler/node-properties.h" | 8 #include "src/compiler/node-properties.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
(...skipping 1416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1427 VisitFloat64Compare(this, node, &cont); | 1427 VisitFloat64Compare(this, node, &cont); |
1428 } | 1428 } |
1429 | 1429 |
1430 | 1430 |
1431 void InstructionSelector::VisitFloat64LessThanOrEqual(Node* node) { | 1431 void InstructionSelector::VisitFloat64LessThanOrEqual(Node* node) { |
1432 FlagsContinuation cont(kUnsignedLessThanOrEqual, node); | 1432 FlagsContinuation cont(kUnsignedLessThanOrEqual, node); |
1433 VisitFloat64Compare(this, node, &cont); | 1433 VisitFloat64Compare(this, node, &cont); |
1434 } | 1434 } |
1435 | 1435 |
1436 | 1436 |
1437 void InstructionSelector::VisitCall(Node* node, BasicBlock* handler) { | 1437 void InstructionSelector::VisitCall(Node* node, BasicBlock* handler, |
| 1438 CallMode call_mode) { |
1438 PPCOperandGenerator g(this); | 1439 PPCOperandGenerator g(this); |
1439 const CallDescriptor* descriptor = OpParameter<CallDescriptor*>(node); | 1440 const CallDescriptor* descriptor = OpParameter<const CallDescriptor*>(node); |
1440 | 1441 |
1441 FrameStateDescriptor* frame_state_descriptor = NULL; | 1442 FrameStateDescriptor* frame_state_descriptor = NULL; |
1442 if (descriptor->NeedsFrameState()) { | 1443 if (descriptor->NeedsFrameState()) { |
1443 frame_state_descriptor = | 1444 frame_state_descriptor = |
1444 GetFrameStateDescriptor(node->InputAt(descriptor->InputCount())); | 1445 GetFrameStateDescriptor(node->InputAt(descriptor->InputCount())); |
1445 } | 1446 } |
1446 | 1447 |
1447 CallBuffer buffer(zone(), descriptor, frame_state_descriptor); | 1448 CallBuffer buffer(zone(), descriptor, frame_state_descriptor); |
1448 | 1449 |
1449 // Compute InstructionOperands for inputs and outputs. | 1450 // Compute InstructionOperands for inputs and outputs. |
1450 // TODO(turbofan): on PPC it's probably better to use the code object in a | 1451 // TODO(turbofan): on PPC it's probably better to use the code object in a |
1451 // register if there are multiple uses of it. Improve constant pool and the | 1452 // register if there are multiple uses of it. Improve constant pool and the |
1452 // heuristics in the register allocator for where to emit constants. | 1453 // heuristics in the register allocator for where to emit constants. |
1453 InitializeCallBuffer(node, &buffer, true, false); | 1454 InitializeCallBuffer(node, &buffer, true, false); |
1454 | 1455 |
1455 // Push any stack arguments. | 1456 // Push any stack arguments. |
1456 // TODO(mbrandy): reverse order and use push only for first | 1457 // TODO(mbrandy): reverse order and use push only for first |
1457 for (Node* node : base::Reversed(buffer.pushed_nodes)) { | 1458 for (Node* node : base::Reversed(buffer.pushed_nodes)) { |
1458 Emit(kPPC_Push, g.NoOutput(), g.UseRegister(node)); | 1459 Emit(kPPC_Push, g.NoOutput(), g.UseRegister(node)); |
1459 } | 1460 } |
1460 | 1461 |
1461 // Pass label of exception handler block. | 1462 // Pass label of exception handler block. |
1462 CallDescriptor::Flags flags = descriptor->flags(); | 1463 CallDescriptor::Flags flags = descriptor->flags(); |
1463 if (handler != nullptr) { | 1464 if (handler != nullptr) { |
1464 flags |= CallDescriptor::kHasExceptionHandler; | 1465 flags |= CallDescriptor::kHasExceptionHandler; |
1465 buffer.instruction_args.push_back(g.Label(handler)); | 1466 buffer.instruction_args.push_back(g.Label(handler)); |
1466 } | 1467 } |
1467 | 1468 |
1468 // Select the appropriate opcode based on the call type. | 1469 // Select the appropriate opcode based on the call type. |
| 1470 bool is_tail_call = call_mode == TAIL_CALL; |
1469 InstructionCode opcode; | 1471 InstructionCode opcode; |
1470 switch (descriptor->kind()) { | 1472 switch (descriptor->kind()) { |
1471 case CallDescriptor::kCallCodeObject: { | 1473 case CallDescriptor::kCallCodeObject: { |
1472 opcode = kArchCallCodeObject; | 1474 opcode = is_tail_call ? kArchTailCallCodeObject : kArchCallCodeObject; |
1473 break; | 1475 break; |
1474 } | 1476 } |
1475 case CallDescriptor::kCallJSFunction: | 1477 case CallDescriptor::kCallJSFunction: |
1476 opcode = kArchCallJSFunction; | 1478 opcode = is_tail_call ? kArchTailCallJSFunction : kArchCallJSFunction; |
1477 break; | 1479 break; |
1478 default: | 1480 default: |
1479 UNREACHABLE(); | 1481 UNREACHABLE(); |
1480 return; | 1482 return; |
1481 } | 1483 } |
1482 opcode |= MiscField::encode(flags); | 1484 opcode |= MiscField::encode(flags); |
1483 | 1485 |
1484 // Emit the call instruction. | 1486 // Emit the call instruction. |
| 1487 size_t size = is_tail_call ? 0 : buffer.outputs.size(); |
1485 InstructionOperand* first_output = | 1488 InstructionOperand* first_output = |
1486 buffer.outputs.size() > 0 ? &buffer.outputs.front() : NULL; | 1489 size > 0 ? &buffer.outputs.front() : nullptr; |
1487 Instruction* call_instr = | 1490 Instruction* call_instr = |
1488 Emit(opcode, buffer.outputs.size(), first_output, | 1491 Emit(opcode, size, first_output, buffer.instruction_args.size(), |
1489 buffer.instruction_args.size(), &buffer.instruction_args.front()); | 1492 &buffer.instruction_args.front()); |
1490 call_instr->MarkAsCall(); | 1493 call_instr->MarkAsCall(); |
1491 } | 1494 } |
1492 | 1495 |
1493 | 1496 |
1494 void InstructionSelector::VisitFloat64ExtractLowWord32(Node* node) { | 1497 void InstructionSelector::VisitFloat64ExtractLowWord32(Node* node) { |
1495 PPCOperandGenerator g(this); | 1498 PPCOperandGenerator g(this); |
1496 Emit(kPPC_DoubleExtractLowWord32, g.DefineAsRegister(node), | 1499 Emit(kPPC_DoubleExtractLowWord32, g.DefineAsRegister(node), |
1497 g.UseRegister(node->InputAt(0))); | 1500 g.UseRegister(node->InputAt(0))); |
1498 } | 1501 } |
1499 | 1502 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1548 MachineOperatorBuilder::kFloat64Min | | 1551 MachineOperatorBuilder::kFloat64Min | |
1549 MachineOperatorBuilder::kFloat64RoundDown | | 1552 MachineOperatorBuilder::kFloat64RoundDown | |
1550 MachineOperatorBuilder::kFloat64RoundTruncate | | 1553 MachineOperatorBuilder::kFloat64RoundTruncate | |
1551 MachineOperatorBuilder::kFloat64RoundTiesAway; | 1554 MachineOperatorBuilder::kFloat64RoundTiesAway; |
1552 // We omit kWord32ShiftIsSafe as s[rl]w use 0x3f as a mask rather than 0x1f. | 1555 // We omit kWord32ShiftIsSafe as s[rl]w use 0x3f as a mask rather than 0x1f. |
1553 } | 1556 } |
1554 | 1557 |
1555 } // namespace compiler | 1558 } // namespace compiler |
1556 } // namespace internal | 1559 } // namespace internal |
1557 } // namespace v8 | 1560 } // namespace v8 |
OLD | NEW |