| 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 #include "src/ppc/frames-ppc.h" | 9 #include "src/ppc/frames-ppc.h" |
| 10 | 10 |
| (...skipping 1463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1474 VisitFloat64Compare(this, node, &cont); | 1474 VisitFloat64Compare(this, node, &cont); |
| 1475 } | 1475 } |
| 1476 | 1476 |
| 1477 | 1477 |
| 1478 void InstructionSelector::VisitFloat64LessThanOrEqual(Node* node) { | 1478 void InstructionSelector::VisitFloat64LessThanOrEqual(Node* node) { |
| 1479 FlagsContinuation cont(kUnsignedLessThanOrEqual, node); | 1479 FlagsContinuation cont(kUnsignedLessThanOrEqual, node); |
| 1480 VisitFloat64Compare(this, node, &cont); | 1480 VisitFloat64Compare(this, node, &cont); |
| 1481 } | 1481 } |
| 1482 | 1482 |
| 1483 | 1483 |
| 1484 void InstructionSelector::VisitCall(Node* node, BasicBlock* handler) { | 1484 void InstructionSelector::EmitPrepareArguments(NodeVector* arguments, |
| 1485 const CallDescriptor* descriptor, |
| 1486 Node* node) { |
| 1485 PPCOperandGenerator g(this); | 1487 PPCOperandGenerator g(this); |
| 1486 const CallDescriptor* descriptor = OpParameter<const CallDescriptor*>(node); | |
| 1487 | |
| 1488 FrameStateDescriptor* frame_state_descriptor = nullptr; | |
| 1489 if (descriptor->NeedsFrameState()) { | |
| 1490 frame_state_descriptor = | |
| 1491 GetFrameStateDescriptor(node->InputAt(descriptor->InputCount())); | |
| 1492 } | |
| 1493 | |
| 1494 CallBuffer buffer(zone(), descriptor, frame_state_descriptor); | |
| 1495 | |
| 1496 // Compute InstructionOperands for inputs and outputs. | |
| 1497 // TODO(turbofan): on PPC it's probably better to use the code object in a | |
| 1498 // register if there are multiple uses of it. Improve constant pool and the | |
| 1499 // heuristics in the register allocator for where to emit constants. | |
| 1500 InitializeCallBuffer(node, &buffer, true, true); | |
| 1501 | 1488 |
| 1502 // Prepare for C function call. | 1489 // Prepare for C function call. |
| 1503 if (descriptor->IsCFunctionCall()) { | 1490 if (descriptor->IsCFunctionCall()) { |
| 1504 Emit(kArchPrepareCallCFunction | | 1491 Emit(kArchPrepareCallCFunction | |
| 1505 MiscField::encode(static_cast<int>(descriptor->CParameterCount())), | 1492 MiscField::encode(static_cast<int>(descriptor->CParameterCount())), |
| 1506 0, nullptr, 0, nullptr); | 1493 0, nullptr, 0, nullptr); |
| 1507 | 1494 |
| 1508 // Poke any stack arguments. | 1495 // Poke any stack arguments. |
| 1509 int slot = kStackFrameExtraParamSlot; | 1496 int slot = kStackFrameExtraParamSlot; |
| 1510 for (Node* node : buffer.pushed_nodes) { | 1497 for (Node* node : (*arguments)) { |
| 1511 Emit(kPPC_StoreToStackSlot, g.NoOutput(), g.UseRegister(node), | 1498 Emit(kPPC_StoreToStackSlot, g.NoOutput(), g.UseRegister(node), |
| 1512 g.TempImmediate(slot)); | 1499 g.TempImmediate(slot)); |
| 1513 ++slot; | 1500 ++slot; |
| 1514 } | 1501 } |
| 1515 } else { | 1502 } else { |
| 1516 // Push any stack arguments. | 1503 // Push any stack arguments. |
| 1517 int num_slots = static_cast<int>(descriptor->StackParameterCount()); | 1504 int num_slots = static_cast<int>(descriptor->StackParameterCount()); |
| 1518 int slot = 0; | 1505 int slot = 0; |
| 1519 for (Node* input : buffer.pushed_nodes) { | 1506 for (Node* input : (*arguments)) { |
| 1520 if (slot == 0) { | 1507 if (slot == 0) { |
| 1521 DCHECK(input); | 1508 DCHECK(input); |
| 1522 Emit(kPPC_PushFrame, g.NoOutput(), g.UseRegister(input), | 1509 Emit(kPPC_PushFrame, g.NoOutput(), g.UseRegister(input), |
| 1523 g.TempImmediate(num_slots)); | 1510 g.TempImmediate(num_slots)); |
| 1524 } else { | 1511 } else { |
| 1525 // Skip any alignment holes in pushed nodes. | 1512 // Skip any alignment holes in pushed nodes. |
| 1526 if (input) { | 1513 if (input) { |
| 1527 Emit(kPPC_StoreToStackSlot, g.NoOutput(), g.UseRegister(input), | 1514 Emit(kPPC_StoreToStackSlot, g.NoOutput(), g.UseRegister(input), |
| 1528 g.TempImmediate(slot)); | 1515 g.TempImmediate(slot)); |
| 1529 } | 1516 } |
| 1530 } | 1517 } |
| 1531 ++slot; | 1518 ++slot; |
| 1532 } | 1519 } |
| 1533 } | 1520 } |
| 1534 | |
| 1535 // Pass label of exception handler block. | |
| 1536 CallDescriptor::Flags flags = descriptor->flags(); | |
| 1537 if (handler) { | |
| 1538 DCHECK_EQ(IrOpcode::kIfException, handler->front()->opcode()); | |
| 1539 IfExceptionHint hint = OpParameter<IfExceptionHint>(handler->front()); | |
| 1540 if (hint == IfExceptionHint::kLocallyCaught) { | |
| 1541 flags |= CallDescriptor::kHasLocalCatchHandler; | |
| 1542 } | |
| 1543 flags |= CallDescriptor::kHasExceptionHandler; | |
| 1544 buffer.instruction_args.push_back(g.Label(handler)); | |
| 1545 } | |
| 1546 | |
| 1547 // Select the appropriate opcode based on the call type. | |
| 1548 InstructionCode opcode = kArchNop; | |
| 1549 switch (descriptor->kind()) { | |
| 1550 case CallDescriptor::kCallAddress: | |
| 1551 opcode = | |
| 1552 kArchCallCFunction | | |
| 1553 MiscField::encode(static_cast<int>(descriptor->CParameterCount())); | |
| 1554 break; | |
| 1555 case CallDescriptor::kCallCodeObject: | |
| 1556 opcode = kArchCallCodeObject | MiscField::encode(flags); | |
| 1557 break; | |
| 1558 case CallDescriptor::kCallJSFunction: | |
| 1559 opcode = kArchCallJSFunction | MiscField::encode(flags); | |
| 1560 break; | |
| 1561 case CallDescriptor::kLazyBailout: | |
| 1562 opcode = kArchLazyBailout | MiscField::encode(flags); | |
| 1563 break; | |
| 1564 } | |
| 1565 | |
| 1566 // Emit the call instruction. | |
| 1567 size_t const output_count = buffer.outputs.size(); | |
| 1568 auto* outputs = output_count ? &buffer.outputs.front() : nullptr; | |
| 1569 Emit(opcode, output_count, outputs, buffer.instruction_args.size(), | |
| 1570 &buffer.instruction_args.front())->MarkAsCall(); | |
| 1571 } | 1521 } |
| 1572 | 1522 |
| 1573 | 1523 |
| 1574 void InstructionSelector::VisitTailCall(Node* node) { | 1524 void InstructionSelector::VisitTailCall(Node* node) { |
| 1575 PPCOperandGenerator g(this); | 1525 PPCOperandGenerator g(this); |
| 1576 CallDescriptor const* descriptor = OpParameter<CallDescriptor const*>(node); | 1526 CallDescriptor const* descriptor = OpParameter<CallDescriptor const*>(node); |
| 1577 DCHECK_NE(0, descriptor->flags() & CallDescriptor::kSupportsTailCalls); | 1527 DCHECK_NE(0, descriptor->flags() & CallDescriptor::kSupportsTailCalls); |
| 1578 DCHECK_EQ(0, descriptor->flags() & CallDescriptor::kPatchableCallSite); | 1528 DCHECK_EQ(0, descriptor->flags() & CallDescriptor::kPatchableCallSite); |
| 1579 DCHECK_EQ(0, descriptor->flags() & CallDescriptor::kNeedsNopAfterCall); | 1529 DCHECK_EQ(0, descriptor->flags() & CallDescriptor::kNeedsNopAfterCall); |
| 1580 | 1530 |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1713 return MachineOperatorBuilder::kFloat64RoundDown | | 1663 return MachineOperatorBuilder::kFloat64RoundDown | |
| 1714 MachineOperatorBuilder::kFloat64RoundTruncate | | 1664 MachineOperatorBuilder::kFloat64RoundTruncate | |
| 1715 MachineOperatorBuilder::kFloat64RoundTiesAway | | 1665 MachineOperatorBuilder::kFloat64RoundTiesAway | |
| 1716 MachineOperatorBuilder::kWord32Popcnt; | 1666 MachineOperatorBuilder::kWord32Popcnt; |
| 1717 // We omit kWord32ShiftIsSafe as s[rl]w use 0x3f as a mask rather than 0x1f. | 1667 // We omit kWord32ShiftIsSafe as s[rl]w use 0x3f as a mask rather than 0x1f. |
| 1718 } | 1668 } |
| 1719 | 1669 |
| 1720 } // namespace compiler | 1670 } // namespace compiler |
| 1721 } // namespace internal | 1671 } // namespace internal |
| 1722 } // namespace v8 | 1672 } // namespace v8 |
| OLD | NEW |