Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/compiler/ia32/instruction-selector-ia32.cc

Issue 1414223004: [turbofan] Move platform-independent bits of VisitTailCall to instruction-selector.cc (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler/arm64/instruction-selector-arm64.cc ('k') | src/compiler/instruction-selector.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 868 matching lines...) Expand 10 before | Expand all | Expand 10 after
879 : IsSupported(ATOM) || 879 : IsSupported(ATOM) ||
880 sequence()->IsFloat(GetVirtualRegister(input)) 880 sequence()->IsFloat(GetVirtualRegister(input))
881 ? g.UseRegister(input) 881 ? g.UseRegister(input)
882 : g.Use(input); 882 : g.Use(input);
883 Emit(kIA32Push, g.NoOutput(), value); 883 Emit(kIA32Push, g.NoOutput(), value);
884 } 884 }
885 } 885 }
886 } 886 }
887 887
888 888
889 void InstructionSelector::VisitTailCall(Node* node) { 889 bool InstructionSelector::IsTailCallAddressImmediate() { return true; }
890 IA32OperandGenerator g(this);
891 CallDescriptor const* descriptor = OpParameter<CallDescriptor const*>(node);
892 DCHECK_NE(0, descriptor->flags() & CallDescriptor::kSupportsTailCalls);
893 DCHECK_EQ(0, descriptor->flags() & CallDescriptor::kPatchableCallSite);
894 DCHECK_EQ(0, descriptor->flags() & CallDescriptor::kNeedsNopAfterCall);
895
896 // TODO(turbofan): Relax restriction for stack parameters.
897
898 if (linkage()->GetIncomingDescriptor()->CanTailCall(node)) {
899 CallBuffer buffer(zone(), descriptor, nullptr);
900
901 // Compute InstructionOperands for inputs and outputs.
902 InitializeCallBuffer(node, &buffer, true, true);
903
904 // Select the appropriate opcode based on the call type.
905 InstructionCode opcode;
906 switch (descriptor->kind()) {
907 case CallDescriptor::kCallCodeObject:
908 opcode = kArchTailCallCodeObject;
909 break;
910 case CallDescriptor::kCallJSFunction:
911 opcode = kArchTailCallJSFunction;
912 break;
913 default:
914 UNREACHABLE();
915 return;
916 }
917 opcode |= MiscField::encode(descriptor->flags());
918
919 // Emit the tailcall instruction.
920 Emit(opcode, 0, nullptr, buffer.instruction_args.size(),
921 &buffer.instruction_args.front());
922 } else {
923 FrameStateDescriptor* frame_state_descriptor =
924 descriptor->NeedsFrameState()
925 ? GetFrameStateDescriptor(
926 node->InputAt(static_cast<int>(descriptor->InputCount())))
927 : nullptr;
928
929 CallBuffer buffer(zone(), descriptor, frame_state_descriptor);
930
931 // Compute InstructionOperands for inputs and outputs.
932 InitializeCallBuffer(node, &buffer, true, true);
933
934 // Push any stack arguments.
935 for (Node* input : base::Reversed(buffer.pushed_nodes)) {
936 // TODO(titzer): Handle pushing double parameters.
937 InstructionOperand value =
938 g.CanBeImmediate(input)
939 ? g.UseImmediate(input)
940 : IsSupported(ATOM) ? g.UseRegister(input) : g.Use(input);
941 Emit(kIA32Push, g.NoOutput(), value);
942 }
943
944 // Select the appropriate opcode based on the call type.
945 InstructionCode opcode;
946 switch (descriptor->kind()) {
947 case CallDescriptor::kCallCodeObject:
948 opcode = kArchCallCodeObject;
949 break;
950 case CallDescriptor::kCallJSFunction:
951 opcode = kArchCallJSFunction;
952 break;
953 default:
954 UNREACHABLE();
955 return;
956 }
957 opcode |= MiscField::encode(descriptor->flags());
958
959 // Emit the call instruction.
960 size_t output_count = buffer.outputs.size();
961 auto* outputs = &buffer.outputs.front();
962 Emit(opcode, output_count, outputs, buffer.instruction_args.size(),
963 &buffer.instruction_args.front())->MarkAsCall();
964 Emit(kArchRet, 0, nullptr, output_count, outputs);
965 }
966 }
967 890
968 891
969 namespace { 892 namespace {
970 893
971 // Shared routine for multiple compare operations. 894 // Shared routine for multiple compare operations.
972 void VisitCompare(InstructionSelector* selector, InstructionCode opcode, 895 void VisitCompare(InstructionSelector* selector, InstructionCode opcode,
973 InstructionOperand left, InstructionOperand right, 896 InstructionOperand left, InstructionOperand right,
974 FlagsContinuation* cont) { 897 FlagsContinuation* cont) {
975 IA32OperandGenerator g(selector); 898 IA32OperandGenerator g(selector);
976 if (cont->IsBranch()) { 899 if (cont->IsBranch()) {
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
1330 if (CpuFeatures::IsSupported(SSE4_1)) { 1253 if (CpuFeatures::IsSupported(SSE4_1)) {
1331 flags |= MachineOperatorBuilder::kFloat64RoundDown | 1254 flags |= MachineOperatorBuilder::kFloat64RoundDown |
1332 MachineOperatorBuilder::kFloat64RoundTruncate; 1255 MachineOperatorBuilder::kFloat64RoundTruncate;
1333 } 1256 }
1334 return flags; 1257 return flags;
1335 } 1258 }
1336 1259
1337 } // namespace compiler 1260 } // namespace compiler
1338 } // namespace internal 1261 } // namespace internal
1339 } // namespace v8 1262 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/arm64/instruction-selector-arm64.cc ('k') | src/compiler/instruction-selector.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698