| 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/base/bits.h" | 6 #include "src/base/bits.h" |
| 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.h" | 9 #include "src/compiler/node-properties.h" |
| 10 | 10 |
| (...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 743 for (size_t n = 0; n < arguments->size(); ++n) { | 743 for (size_t n = 0; n < arguments->size(); ++n) { |
| 744 if (Node* input = (*arguments)[n]) { | 744 if (Node* input = (*arguments)[n]) { |
| 745 Emit(kMips64StoreToStackSlot, g.NoOutput(), g.UseRegister(input), | 745 Emit(kMips64StoreToStackSlot, g.NoOutput(), g.UseRegister(input), |
| 746 g.TempImmediate(static_cast<int>(n << kPointerSizeLog2))); | 746 g.TempImmediate(static_cast<int>(n << kPointerSizeLog2))); |
| 747 } | 747 } |
| 748 } | 748 } |
| 749 } | 749 } |
| 750 } | 750 } |
| 751 | 751 |
| 752 | 752 |
| 753 void InstructionSelector::VisitTailCall(Node* node) { | 753 bool InstructionSelector::IsTailCallAddressImmediate() { return false; } |
| 754 Mips64OperandGenerator g(this); | |
| 755 const CallDescriptor* descriptor = OpParameter<const CallDescriptor*>(node); | |
| 756 DCHECK_NE(0, descriptor->flags() & CallDescriptor::kSupportsTailCalls); | |
| 757 DCHECK_EQ(0, descriptor->flags() & CallDescriptor::kPatchableCallSite); | |
| 758 DCHECK_EQ(0, descriptor->flags() & CallDescriptor::kNeedsNopAfterCall); | |
| 759 | |
| 760 // TODO(turbofan): Relax restriction for stack parameters. | |
| 761 if (linkage()->GetIncomingDescriptor()->CanTailCall(node)) { | |
| 762 CallBuffer buffer(zone(), descriptor, nullptr); | |
| 763 | |
| 764 // Compute InstructionOperands for inputs and outputs. | |
| 765 InitializeCallBuffer(node, &buffer, true, false); | |
| 766 | |
| 767 // Select the appropriate opcode based on the call type. | |
| 768 InstructionCode opcode; | |
| 769 switch (descriptor->kind()) { | |
| 770 case CallDescriptor::kCallCodeObject: | |
| 771 opcode = kArchTailCallCodeObject; | |
| 772 break; | |
| 773 case CallDescriptor::kCallJSFunction: | |
| 774 opcode = kArchTailCallJSFunction; | |
| 775 break; | |
| 776 default: | |
| 777 UNREACHABLE(); | |
| 778 return; | |
| 779 } | |
| 780 opcode |= MiscField::encode(descriptor->flags()); | |
| 781 | |
| 782 // Emit the tailcall instruction. | |
| 783 Emit(opcode, 0, nullptr, buffer.instruction_args.size(), | |
| 784 &buffer.instruction_args.front()); | |
| 785 } else { | |
| 786 FrameStateDescriptor* frame_state_descriptor = | |
| 787 descriptor->NeedsFrameState() | |
| 788 ? GetFrameStateDescriptor( | |
| 789 node->InputAt(static_cast<int>(descriptor->InputCount()))) | |
| 790 : nullptr; | |
| 791 | |
| 792 CallBuffer buffer(zone(), descriptor, frame_state_descriptor); | |
| 793 | |
| 794 // Compute InstructionOperands for inputs and outputs. | |
| 795 InitializeCallBuffer(node, &buffer, true, false); | |
| 796 | |
| 797 const int32_t push_count = static_cast<int32_t>(buffer.pushed_nodes.size()); | |
| 798 if (push_count > 0) { | |
| 799 Emit(kMips64StackClaim, g.NoOutput(), | |
| 800 g.TempImmediate(push_count << kPointerSizeLog2)); | |
| 801 } | |
| 802 int slot = push_count - 1; | |
| 803 for (Node* input : base::Reversed(buffer.pushed_nodes)) { | |
| 804 Emit(kMips64StoreToStackSlot, g.NoOutput(), g.UseRegister(input), | |
| 805 g.TempImmediate(slot << kPointerSizeLog2)); | |
| 806 slot--; | |
| 807 } | |
| 808 | |
| 809 // Select the appropriate opcode based on the call type. | |
| 810 InstructionCode opcode; | |
| 811 switch (descriptor->kind()) { | |
| 812 case CallDescriptor::kCallCodeObject: { | |
| 813 opcode = kArchCallCodeObject; | |
| 814 break; | |
| 815 } | |
| 816 case CallDescriptor::kCallJSFunction: | |
| 817 opcode = kArchCallJSFunction; | |
| 818 break; | |
| 819 default: | |
| 820 UNREACHABLE(); | |
| 821 return; | |
| 822 } | |
| 823 opcode |= MiscField::encode(descriptor->flags()); | |
| 824 | |
| 825 // Emit the call instruction. | |
| 826 size_t const output_count = buffer.outputs.size(); | |
| 827 auto* outputs = output_count ? &buffer.outputs.front() : nullptr; | |
| 828 Emit(opcode, output_count, outputs, buffer.instruction_args.size(), | |
| 829 &buffer.instruction_args.front())->MarkAsCall(); | |
| 830 Emit(kArchRet, 0, nullptr, output_count, outputs); | |
| 831 } | |
| 832 } | |
| 833 | 754 |
| 834 | 755 |
| 835 void InstructionSelector::VisitCheckedLoad(Node* node) { | 756 void InstructionSelector::VisitCheckedLoad(Node* node) { |
| 836 MachineType rep = RepresentationOf(OpParameter<MachineType>(node)); | 757 MachineType rep = RepresentationOf(OpParameter<MachineType>(node)); |
| 837 MachineType typ = TypeOf(OpParameter<MachineType>(node)); | 758 MachineType typ = TypeOf(OpParameter<MachineType>(node)); |
| 838 Mips64OperandGenerator g(this); | 759 Mips64OperandGenerator g(this); |
| 839 Node* const buffer = node->InputAt(0); | 760 Node* const buffer = node->InputAt(0); |
| 840 Node* const offset = node->InputAt(1); | 761 Node* const offset = node->InputAt(1); |
| 841 Node* const length = node->InputAt(2); | 762 Node* const length = node->InputAt(2); |
| 842 ArchOpcode opcode; | 763 ArchOpcode opcode; |
| (...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1370 // static | 1291 // static |
| 1371 MachineOperatorBuilder::Flags | 1292 MachineOperatorBuilder::Flags |
| 1372 InstructionSelector::SupportedMachineOperatorFlags() { | 1293 InstructionSelector::SupportedMachineOperatorFlags() { |
| 1373 return MachineOperatorBuilder::kFloat64RoundDown | | 1294 return MachineOperatorBuilder::kFloat64RoundDown | |
| 1374 MachineOperatorBuilder::kFloat64RoundTruncate; | 1295 MachineOperatorBuilder::kFloat64RoundTruncate; |
| 1375 } | 1296 } |
| 1376 | 1297 |
| 1377 } // namespace compiler | 1298 } // namespace compiler |
| 1378 } // namespace internal | 1299 } // namespace internal |
| 1379 } // namespace v8 | 1300 } // namespace v8 |
| OLD | NEW |