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 861 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
872 : IsSupported(ATOM) || | 872 : IsSupported(ATOM) || |
873 sequence()->IsFloat(GetVirtualRegister(input)) | 873 sequence()->IsFloat(GetVirtualRegister(input)) |
874 ? g.UseRegister(input) | 874 ? g.UseRegister(input) |
875 : g.Use(input); | 875 : g.Use(input); |
876 Emit(kX87Push, g.NoOutput(), value); | 876 Emit(kX87Push, g.NoOutput(), value); |
877 } | 877 } |
878 } | 878 } |
879 } | 879 } |
880 | 880 |
881 | 881 |
882 void InstructionSelector::VisitTailCall(Node* node) { | 882 bool InstructionSelector::IsTailCallAddressImmediate() { return true; } |
883 X87OperandGenerator g(this); | |
884 CallDescriptor const* descriptor = OpParameter<CallDescriptor const*>(node); | |
885 DCHECK_NE(0, descriptor->flags() & CallDescriptor::kSupportsTailCalls); | |
886 DCHECK_EQ(0, descriptor->flags() & CallDescriptor::kPatchableCallSite); | |
887 DCHECK_EQ(0, descriptor->flags() & CallDescriptor::kNeedsNopAfterCall); | |
888 | |
889 // TODO(turbofan): Relax restriction for stack parameters. | |
890 | |
891 if (linkage()->GetIncomingDescriptor()->CanTailCall(node)) { | |
892 CallBuffer buffer(zone(), descriptor, nullptr); | |
893 | |
894 // Compute InstructionOperands for inputs and outputs. | |
895 InitializeCallBuffer(node, &buffer, true, true); | |
896 | |
897 // Select the appropriate opcode based on the call type. | |
898 InstructionCode opcode; | |
899 switch (descriptor->kind()) { | |
900 case CallDescriptor::kCallCodeObject: | |
901 opcode = kArchTailCallCodeObject; | |
902 break; | |
903 case CallDescriptor::kCallJSFunction: | |
904 opcode = kArchTailCallJSFunction; | |
905 break; | |
906 default: | |
907 UNREACHABLE(); | |
908 return; | |
909 } | |
910 opcode |= MiscField::encode(descriptor->flags()); | |
911 | |
912 // Emit the tailcall instruction. | |
913 Emit(opcode, 0, nullptr, buffer.instruction_args.size(), | |
914 &buffer.instruction_args.front()); | |
915 } else { | |
916 FrameStateDescriptor* frame_state_descriptor = | |
917 descriptor->NeedsFrameState() | |
918 ? GetFrameStateDescriptor( | |
919 node->InputAt(static_cast<int>(descriptor->InputCount()))) | |
920 : nullptr; | |
921 | |
922 CallBuffer buffer(zone(), descriptor, frame_state_descriptor); | |
923 | |
924 // Compute InstructionOperands for inputs and outputs. | |
925 InitializeCallBuffer(node, &buffer, true, true); | |
926 | |
927 // Push any stack arguments. | |
928 for (Node* input : base::Reversed(buffer.pushed_nodes)) { | |
929 // TODO(titzer): Handle pushing double parameters. | |
930 InstructionOperand value = | |
931 g.CanBeImmediate(input) | |
932 ? g.UseImmediate(input) | |
933 : IsSupported(ATOM) ? g.UseRegister(input) : g.Use(input); | |
934 Emit(kX87Push, g.NoOutput(), value); | |
935 } | |
936 | |
937 // Select the appropriate opcode based on the call type. | |
938 InstructionCode opcode; | |
939 switch (descriptor->kind()) { | |
940 case CallDescriptor::kCallCodeObject: | |
941 opcode = kArchCallCodeObject; | |
942 break; | |
943 case CallDescriptor::kCallJSFunction: | |
944 opcode = kArchCallJSFunction; | |
945 break; | |
946 default: | |
947 UNREACHABLE(); | |
948 return; | |
949 } | |
950 opcode |= MiscField::encode(descriptor->flags()); | |
951 | |
952 // Emit the call instruction. | |
953 size_t output_count = buffer.outputs.size(); | |
954 auto* outputs = &buffer.outputs.front(); | |
955 Emit(opcode, output_count, outputs, buffer.instruction_args.size(), | |
956 &buffer.instruction_args.front())->MarkAsCall(); | |
957 Emit(kArchRet, 0, nullptr, output_count, outputs); | |
958 } | |
959 } | |
960 | 883 |
961 | 884 |
962 namespace { | 885 namespace { |
963 | 886 |
964 // Shared routine for multiple compare operations. | 887 // Shared routine for multiple compare operations. |
965 void VisitCompare(InstructionSelector* selector, InstructionCode opcode, | 888 void VisitCompare(InstructionSelector* selector, InstructionCode opcode, |
966 InstructionOperand left, InstructionOperand right, | 889 InstructionOperand left, InstructionOperand right, |
967 FlagsContinuation* cont) { | 890 FlagsContinuation* cont) { |
968 X87OperandGenerator g(selector); | 891 X87OperandGenerator g(selector); |
969 if (cont->IsBranch()) { | 892 if (cont->IsBranch()) { |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1329 MachineOperatorBuilder::kWord32ShiftIsSafe; | 1252 MachineOperatorBuilder::kWord32ShiftIsSafe; |
1330 if (CpuFeatures::IsSupported(POPCNT)) { | 1253 if (CpuFeatures::IsSupported(POPCNT)) { |
1331 flags |= MachineOperatorBuilder::kWord32Popcnt; | 1254 flags |= MachineOperatorBuilder::kWord32Popcnt; |
1332 } | 1255 } |
1333 return flags; | 1256 return flags; |
1334 } | 1257 } |
1335 | 1258 |
1336 } // namespace compiler | 1259 } // namespace compiler |
1337 } // namespace internal | 1260 } // namespace internal |
1338 } // namespace v8 | 1261 } // namespace v8 |
OLD | NEW |