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 <algorithm> | 5 #include <algorithm> |
6 | 6 |
7 #include "src/base/adapters.h" | 7 #include "src/base/adapters.h" |
8 #include "src/compiler/instruction-selector-impl.h" | 8 #include "src/compiler/instruction-selector-impl.h" |
9 #include "src/compiler/node-matchers.h" | 9 #include "src/compiler/node-matchers.h" |
10 #include "src/compiler/node-properties.h" | 10 #include "src/compiler/node-properties.h" |
(...skipping 1093 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1104 : IsSupported(ATOM) || | 1104 : IsSupported(ATOM) || |
1105 sequence()->IsFloat(GetVirtualRegister(input)) | 1105 sequence()->IsFloat(GetVirtualRegister(input)) |
1106 ? g.UseRegister(input) | 1106 ? g.UseRegister(input) |
1107 : g.Use(input); | 1107 : g.Use(input); |
1108 Emit(kX64Push, g.NoOutput(), value); | 1108 Emit(kX64Push, g.NoOutput(), value); |
1109 } | 1109 } |
1110 } | 1110 } |
1111 } | 1111 } |
1112 | 1112 |
1113 | 1113 |
1114 void InstructionSelector::VisitTailCall(Node* node) { | 1114 bool InstructionSelector::IsTailCallAddressImmediate() { return true; } |
1115 X64OperandGenerator g(this); | |
1116 CallDescriptor const* descriptor = OpParameter<CallDescriptor const*>(node); | |
1117 DCHECK_NE(0, descriptor->flags() & CallDescriptor::kSupportsTailCalls); | |
1118 DCHECK_EQ(0, descriptor->flags() & CallDescriptor::kPatchableCallSite); | |
1119 DCHECK_EQ(0, descriptor->flags() & CallDescriptor::kNeedsNopAfterCall); | |
1120 | |
1121 // TODO(turbofan): Relax restriction for stack parameters. | |
1122 if (linkage()->GetIncomingDescriptor()->CanTailCall(node)) { | |
1123 CallBuffer buffer(zone(), descriptor, nullptr); | |
1124 | |
1125 // Compute InstructionOperands for inputs and outputs. | |
1126 InitializeCallBuffer(node, &buffer, true, true); | |
1127 | |
1128 // Select the appropriate opcode based on the call type. | |
1129 InstructionCode opcode; | |
1130 switch (descriptor->kind()) { | |
1131 case CallDescriptor::kCallCodeObject: | |
1132 opcode = kArchTailCallCodeObject; | |
1133 break; | |
1134 case CallDescriptor::kCallJSFunction: | |
1135 opcode = kArchTailCallJSFunction; | |
1136 break; | |
1137 default: | |
1138 UNREACHABLE(); | |
1139 return; | |
1140 } | |
1141 opcode |= MiscField::encode(descriptor->flags()); | |
1142 | |
1143 // Emit the tailcall instruction. | |
1144 Emit(opcode, 0, nullptr, buffer.instruction_args.size(), | |
1145 &buffer.instruction_args.front()); | |
1146 } else { | |
1147 FrameStateDescriptor* frame_state_descriptor = | |
1148 descriptor->NeedsFrameState() | |
1149 ? GetFrameStateDescriptor( | |
1150 node->InputAt(static_cast<int>(descriptor->InputCount()))) | |
1151 : nullptr; | |
1152 | |
1153 CallBuffer buffer(zone(), descriptor, frame_state_descriptor); | |
1154 | |
1155 // Compute InstructionOperands for inputs and outputs. | |
1156 InitializeCallBuffer(node, &buffer, true, true); | |
1157 | |
1158 // Push any stack arguments. | |
1159 for (Node* input : base::Reversed(buffer.pushed_nodes)) { | |
1160 // TODO(titzer): Handle pushing double parameters. | |
1161 InstructionOperand value = | |
1162 g.CanBeImmediate(input) | |
1163 ? g.UseImmediate(input) | |
1164 : IsSupported(ATOM) ? g.UseRegister(input) : g.Use(input); | |
1165 Emit(kX64Push, g.NoOutput(), value); | |
1166 } | |
1167 | |
1168 // Select the appropriate opcode based on the call type. | |
1169 InstructionCode opcode; | |
1170 switch (descriptor->kind()) { | |
1171 case CallDescriptor::kCallCodeObject: | |
1172 opcode = kArchCallCodeObject; | |
1173 break; | |
1174 case CallDescriptor::kCallJSFunction: | |
1175 opcode = kArchCallJSFunction; | |
1176 break; | |
1177 default: | |
1178 UNREACHABLE(); | |
1179 return; | |
1180 } | |
1181 opcode |= MiscField::encode(descriptor->flags()); | |
1182 | |
1183 // Emit the call instruction. | |
1184 size_t output_count = buffer.outputs.size(); | |
1185 auto* outputs = &buffer.outputs.front(); | |
1186 Emit(opcode, output_count, outputs, buffer.instruction_args.size(), | |
1187 &buffer.instruction_args.front())->MarkAsCall(); | |
1188 Emit(kArchRet, 0, nullptr, output_count, outputs); | |
1189 } | |
1190 } | |
1191 | 1115 |
1192 | 1116 |
1193 namespace { | 1117 namespace { |
1194 | 1118 |
1195 // Shared routine for multiple compare operations. | 1119 // Shared routine for multiple compare operations. |
1196 void VisitCompare(InstructionSelector* selector, InstructionCode opcode, | 1120 void VisitCompare(InstructionSelector* selector, InstructionCode opcode, |
1197 InstructionOperand left, InstructionOperand right, | 1121 InstructionOperand left, InstructionOperand right, |
1198 FlagsContinuation* cont) { | 1122 FlagsContinuation* cont) { |
1199 X64OperandGenerator g(selector); | 1123 X64OperandGenerator g(selector); |
1200 opcode = cont->Encode(opcode); | 1124 opcode = cont->Encode(opcode); |
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1677 if (CpuFeatures::IsSupported(SSE4_1)) { | 1601 if (CpuFeatures::IsSupported(SSE4_1)) { |
1678 flags |= MachineOperatorBuilder::kFloat64RoundDown | | 1602 flags |= MachineOperatorBuilder::kFloat64RoundDown | |
1679 MachineOperatorBuilder::kFloat64RoundTruncate; | 1603 MachineOperatorBuilder::kFloat64RoundTruncate; |
1680 } | 1604 } |
1681 return flags; | 1605 return flags; |
1682 } | 1606 } |
1683 | 1607 |
1684 } // namespace compiler | 1608 } // namespace compiler |
1685 } // namespace internal | 1609 } // namespace internal |
1686 } // namespace v8 | 1610 } // namespace v8 |
OLD | NEW |