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

Side by Side Diff: test/cctest/compiler/test-run-native-calls.cc

Issue 1494123002: [turbofan, arm64] Fix native stack parameters on arm64. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Minor changes according to comments. Created 5 years 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/linkage.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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 // TODO(jochen): Remove this after the setting is turned on globally. 5 // TODO(jochen): Remove this after the setting is turned on globally.
6 #define V8_IMMINENT_DEPRECATION_WARNINGS 6 #define V8_IMMINENT_DEPRECATION_WARNINGS
7 7
8 #include "src/assembler.h" 8 #include "src/assembler.h"
9 #include "src/codegen.h" 9 #include "src/codegen.h"
10 #include "src/compiler/linkage.h" 10 #include "src/compiler/linkage.h"
11 #include "src/compiler/machine-type.h" 11 #include "src/compiler/machine-type.h"
12 #include "src/compiler/raw-machine-assembler.h" 12 #include "src/compiler/raw-machine-assembler.h"
13 #include "src/register-configuration.h" 13 #include "src/register-configuration.h"
14 14
15 #include "test/cctest/cctest.h" 15 #include "test/cctest/cctest.h"
16 #include "test/cctest/compiler/codegen-tester.h" 16 #include "test/cctest/compiler/codegen-tester.h"
17 #include "test/cctest/compiler/graph-builder-tester.h" 17 #include "test/cctest/compiler/graph-builder-tester.h"
18 #include "test/cctest/compiler/value-helper.h" 18 #include "test/cctest/compiler/value-helper.h"
19 19
20 namespace v8 { 20 namespace v8 {
21 namespace internal { 21 namespace internal {
22 namespace compiler { 22 namespace compiler {
23 23
24 #if V8_TARGET_ARCH_ARM64
25 // TODO(titzer): fix native stack parameters on arm64
26 #define DISABLE_NATIVE_STACK_PARAMS true
27 #else
28 #define DISABLE_NATIVE_STACK_PARAMS false
29 #endif
30
31 namespace { 24 namespace {
32 typedef float float32; 25 typedef float float32;
33 typedef double float64; 26 typedef double float64;
34 27
35 // Picks a representative pair of integers from the given range. 28 // Picks a representative pair of integers from the given range.
36 // If there are less than {max_pairs} possible pairs, do them all, otherwise try 29 // If there are less than {max_pairs} possible pairs, do them all, otherwise try
37 // to select a representative set. 30 // to select a representative set.
38 class Pairs { 31 class Pairs {
39 public: 32 public:
40 Pairs(int max_pairs, int range, const int* codes) 33 Pairs(int max_pairs, int range, const int* codes)
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 return new (zone) CallDescriptor( // -- 207 return new (zone) CallDescriptor( // --
215 CallDescriptor::kCallCodeObject, // kind 208 CallDescriptor::kCallCodeObject, // kind
216 target_type, // target MachineType 209 target_type, // target MachineType
217 target_loc, // target location 210 target_loc, // target location
218 msig, // machine_sig 211 msig, // machine_sig
219 locations.Build(), // location_sig 212 locations.Build(), // location_sig
220 stack_param_count, // stack_parameter_count 213 stack_param_count, // stack_parameter_count
221 compiler::Operator::kNoProperties, // properties 214 compiler::Operator::kNoProperties, // properties
222 kCalleeSaveRegisters, // callee-saved registers 215 kCalleeSaveRegisters, // callee-saved registers
223 kCalleeSaveFPRegisters, // callee-saved fp regs 216 kCalleeSaveFPRegisters, // callee-saved fp regs
224 CallDescriptor::kNoFlags, // flags 217 CallDescriptor::kUseNativeStack, // flags
225 "c-call"); 218 "c-call");
226 } 219 }
227 220
228 private: 221 private:
229 Allocator& params; 222 Allocator& params;
230 Allocator& rets; 223 Allocator& rets;
231 }; 224 };
232 225
233 const int kMaxParamCount = 64; 226 const int kMaxParamCount = 64;
234 227
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 int32_t expected = static_cast<int32_t>(static_cast<uint32_t>(*i) - 545 int32_t expected = static_cast<int32_t>(static_cast<uint32_t>(*i) -
553 static_cast<uint32_t>(*j)); 546 static_cast<uint32_t>(*j));
554 int32_t result = runnable.Call(*i, *j); 547 int32_t result = runnable.Call(*i, *j);
555 CHECK_EQ(expected, result); 548 CHECK_EQ(expected, result);
556 } 549 }
557 } 550 }
558 } 551 }
559 552
560 553
561 static void CopyTwentyInt32(CallDescriptor* desc) { 554 static void CopyTwentyInt32(CallDescriptor* desc) {
562 if (DISABLE_NATIVE_STACK_PARAMS) return;
563
564 const int kNumParams = 20; 555 const int kNumParams = 20;
565 int32_t input[kNumParams]; 556 int32_t input[kNumParams];
566 int32_t output[kNumParams]; 557 int32_t output[kNumParams];
567 Isolate* isolate = CcTest::InitIsolateOnce(); 558 Isolate* isolate = CcTest::InitIsolateOnce();
568 HandleScope scope(isolate); 559 HandleScope scope(isolate);
569 Handle<Code> inner = Handle<Code>::null(); 560 Handle<Code> inner = Handle<Code>::null();
570 { 561 {
571 // Writes all parameters into the output buffer. 562 // Writes all parameters into the output buffer.
572 Zone zone; 563 Zone zone;
573 Graph graph(&zone); 564 Graph graph(&zone);
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 TEST_INT32_SUB_WITH_RET(13) 656 TEST_INT32_SUB_WITH_RET(13)
666 TEST_INT32_SUB_WITH_RET(14) 657 TEST_INT32_SUB_WITH_RET(14)
667 TEST_INT32_SUB_WITH_RET(15) 658 TEST_INT32_SUB_WITH_RET(15)
668 TEST_INT32_SUB_WITH_RET(16) 659 TEST_INT32_SUB_WITH_RET(16)
669 TEST_INT32_SUB_WITH_RET(17) 660 TEST_INT32_SUB_WITH_RET(17)
670 TEST_INT32_SUB_WITH_RET(18) 661 TEST_INT32_SUB_WITH_RET(18)
671 TEST_INT32_SUB_WITH_RET(19) 662 TEST_INT32_SUB_WITH_RET(19)
672 663
673 664
674 TEST(Run_Int32Sub_all_allocatable_single) { 665 TEST(Run_Int32Sub_all_allocatable_single) {
675 if (DISABLE_NATIVE_STACK_PARAMS) return;
676 Int32Signature sig(2); 666 Int32Signature sig(2);
677 RegisterPairs pairs; 667 RegisterPairs pairs;
678 while (pairs.More()) { 668 while (pairs.More()) {
679 Zone zone; 669 Zone zone;
680 int parray[1]; 670 int parray[1];
681 int rarray[1]; 671 int rarray[1];
682 pairs.Next(&rarray[0], &parray[0], true); 672 pairs.Next(&rarray[0], &parray[0], true);
683 Allocator params(parray, 1, nullptr, 0); 673 Allocator params(parray, 1, nullptr, 0);
684 Allocator rets(rarray, 1, nullptr, 0); 674 Allocator rets(rarray, 1, nullptr, 0);
685 RegisterConfig config(params, rets); 675 RegisterConfig config(params, rets);
686 CallDescriptor* desc = config.Create(&zone, &sig); 676 CallDescriptor* desc = config.Create(&zone, &sig);
687 TestInt32Sub(desc); 677 TestInt32Sub(desc);
688 } 678 }
689 } 679 }
690 680
691 681
692 TEST(Run_CopyTwentyInt32_all_allocatable_pairs) { 682 TEST(Run_CopyTwentyInt32_all_allocatable_pairs) {
693 if (DISABLE_NATIVE_STACK_PARAMS) return;
694 Int32Signature sig(20); 683 Int32Signature sig(20);
695 RegisterPairs pairs; 684 RegisterPairs pairs;
696 while (pairs.More()) { 685 while (pairs.More()) {
697 Zone zone; 686 Zone zone;
698 int parray[2]; 687 int parray[2];
699 int rarray[] = { 688 int rarray[] = {
700 RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN) 689 RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN)
701 ->GetAllocatableGeneralCode(0)}; 690 ->GetAllocatableGeneralCode(0)};
702 pairs.Next(&parray[0], &parray[1], false); 691 pairs.Next(&parray[0], &parray[1], false);
703 Allocator params(parray, 2, nullptr, 0); 692 Allocator params(parray, 2, nullptr, 0);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 static int32_t Compute_Int32_WeightedSum(CallDescriptor* desc, int32_t* input) { 725 static int32_t Compute_Int32_WeightedSum(CallDescriptor* desc, int32_t* input) {
737 uint32_t result = 0; 726 uint32_t result = 0;
738 for (int i = 0; i < ParamCount(desc); i++) { 727 for (int i = 0; i < ParamCount(desc); i++) {
739 result += static_cast<uint32_t>(input[i]) * coeff[i]; 728 result += static_cast<uint32_t>(input[i]) * coeff[i];
740 } 729 }
741 return static_cast<int32_t>(result); 730 return static_cast<int32_t>(result);
742 } 731 }
743 732
744 733
745 static void Test_Int32_WeightedSum_of_size(int count) { 734 static void Test_Int32_WeightedSum_of_size(int count) {
746 if (DISABLE_NATIVE_STACK_PARAMS) return;
747 Int32Signature sig(count); 735 Int32Signature sig(count);
748 for (int p0 = 0; p0 < Register::kNumRegisters; p0++) { 736 for (int p0 = 0; p0 < Register::kNumRegisters; p0++) {
749 if (Register::from_code(p0).IsAllocatable()) { 737 if (Register::from_code(p0).IsAllocatable()) {
750 Zone zone; 738 Zone zone;
751 739
752 int parray[] = {p0}; 740 int parray[] = {p0};
753 int rarray[] = { 741 int rarray[] = {
754 RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN) 742 RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN)
755 ->GetAllocatableGeneralCode(0)}; 743 ->GetAllocatableGeneralCode(0)};
756 Allocator params(parray, 1, nullptr, 0); 744 Allocator params(parray, 1, nullptr, 0);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 int count = ParamCount(desc); 786 int count = ParamCount(desc);
799 if (count <= which) return; 787 if (count <= which) return;
800 Run_Computation<CType>(desc, Build_Select<which>, 788 Run_Computation<CType>(desc, Build_Select<which>,
801 Compute_Select<CType, which>, 789 Compute_Select<CType, which>,
802 1044 + which + 3 * sizeof(CType)); 790 1044 + which + 3 * sizeof(CType));
803 } 791 }
804 792
805 793
806 template <int which> 794 template <int which>
807 void Test_Int32_Select() { 795 void Test_Int32_Select() {
808 if (DISABLE_NATIVE_STACK_PARAMS) return;
809
810 int parray[] = { 796 int parray[] = {
811 RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN) 797 RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN)
812 ->GetAllocatableGeneralCode(0)}; 798 ->GetAllocatableGeneralCode(0)};
813 int rarray[] = { 799 int rarray[] = {
814 RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN) 800 RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN)
815 ->GetAllocatableGeneralCode(0)}; 801 ->GetAllocatableGeneralCode(0)};
816 Allocator params(parray, 1, nullptr, 0); 802 Allocator params(parray, 1, nullptr, 0);
817 Allocator rets(rarray, 1, nullptr, 0); 803 Allocator rets(rarray, 1, nullptr, 0);
818 RegisterConfig config(params, rets); 804 RegisterConfig config(params, rets);
819 805
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
923 RegisterConfig config(params, rets); 909 RegisterConfig config(params, rets);
924 910
925 CallDescriptor* desc = config.Create(&zone, &sig); 911 CallDescriptor* desc = config.Create(&zone, &sig);
926 RunSelect<float64, 0>(desc); 912 RunSelect<float64, 0>(desc);
927 RunSelect<float64, 1>(desc); 913 RunSelect<float64, 1>(desc);
928 } 914 }
929 } 915 }
930 916
931 917
932 TEST(Float32Select_stack_params_return_reg) { 918 TEST(Float32Select_stack_params_return_reg) {
933 if (DISABLE_NATIVE_STACK_PARAMS) return;
934 int rarray[] = { 919 int rarray[] = {
935 RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN) 920 RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN)
936 ->GetAllocatableDoubleCode(0)}; 921 ->GetAllocatableDoubleCode(0)};
937 Allocator params(nullptr, 0, nullptr, 0); 922 Allocator params(nullptr, 0, nullptr, 0);
938 Allocator rets(nullptr, 0, rarray, 1); 923 Allocator rets(nullptr, 0, rarray, 1);
939 RegisterConfig config(params, rets); 924 RegisterConfig config(params, rets);
940 925
941 Zone zone; 926 Zone zone;
942 for (int count = 1; count < 6; count++) { 927 for (int count = 1; count < 6; count++) {
943 ArgsBuffer<float32>::Sig sig(count); 928 ArgsBuffer<float32>::Sig sig(count);
944 CallDescriptor* desc = config.Create(&zone, &sig); 929 CallDescriptor* desc = config.Create(&zone, &sig);
945 RunSelect<float32, 0>(desc); 930 RunSelect<float32, 0>(desc);
946 RunSelect<float32, 1>(desc); 931 RunSelect<float32, 1>(desc);
947 RunSelect<float32, 2>(desc); 932 RunSelect<float32, 2>(desc);
948 RunSelect<float32, 3>(desc); 933 RunSelect<float32, 3>(desc);
949 RunSelect<float32, 4>(desc); 934 RunSelect<float32, 4>(desc);
950 RunSelect<float32, 5>(desc); 935 RunSelect<float32, 5>(desc);
951 } 936 }
952 } 937 }
953 938
954 939
955 TEST(Float64Select_stack_params_return_reg) { 940 TEST(Float64Select_stack_params_return_reg) {
956 if (DISABLE_NATIVE_STACK_PARAMS) return;
957 int rarray[] = { 941 int rarray[] = {
958 RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN) 942 RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN)
959 ->GetAllocatableDoubleCode(0)}; 943 ->GetAllocatableDoubleCode(0)};
960 Allocator params(nullptr, 0, nullptr, 0); 944 Allocator params(nullptr, 0, nullptr, 0);
961 Allocator rets(nullptr, 0, rarray, 1); 945 Allocator rets(nullptr, 0, rarray, 1);
962 RegisterConfig config(params, rets); 946 RegisterConfig config(params, rets);
963 947
964 Zone zone; 948 Zone zone;
965 for (int count = 1; count < 6; count++) { 949 for (int count = 1; count < 6; count++) {
966 ArgsBuffer<float64>::Sig sig(count); 950 ArgsBuffer<float64>::Sig sig(count);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1001 args[i] = raw.Parameter(i); 985 args[i] = raw.Parameter(i);
1002 } 986 }
1003 987
1004 Node* call = raw.CallN(desc, target, args); 988 Node* call = raw.CallN(desc, target, args);
1005 raw.Return(call); 989 raw.Return(call);
1006 } 990 }
1007 } 991 }
1008 992
1009 993
1010 TEST(Float64StackParamsToStackParams) { 994 TEST(Float64StackParamsToStackParams) {
1011 if (DISABLE_NATIVE_STACK_PARAMS) return;
1012
1013 int rarray[] = { 995 int rarray[] = {
1014 RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN) 996 RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN)
1015 ->GetAllocatableDoubleCode(0)}; 997 ->GetAllocatableDoubleCode(0)};
1016 Allocator params(nullptr, 0, nullptr, 0); 998 Allocator params(nullptr, 0, nullptr, 0);
1017 Allocator rets(nullptr, 0, rarray, 1); 999 Allocator rets(nullptr, 0, rarray, 1);
1018 1000
1019 Zone zone; 1001 Zone zone;
1020 ArgsBuffer<float64>::Sig sig(2); 1002 ArgsBuffer<float64>::Sig sig(2);
1021 RegisterConfig config(params, rets); 1003 RegisterConfig config(params, rets);
1022 CallDescriptor* desc = config.Create(&zone, &sig); 1004 CallDescriptor* desc = config.Create(&zone, &sig);
1023 1005
1024 Run_Computation<float64>(desc, Build_Select_With_Call<float64, 0>, 1006 Run_Computation<float64>(desc, Build_Select_With_Call<float64, 0>,
1025 Compute_Select<float64, 0>, 1098); 1007 Compute_Select<float64, 0>, 1098);
1026 1008
1027 Run_Computation<float64>(desc, Build_Select_With_Call<float64, 1>, 1009 Run_Computation<float64>(desc, Build_Select_With_Call<float64, 1>,
1028 Compute_Select<float64, 1>, 1099); 1010 Compute_Select<float64, 1>, 1099);
1029 } 1011 }
1030 1012
1031 1013
1032 void MixedParamTest(int start) { 1014 void MixedParamTest(int start) {
1033 if (DISABLE_NATIVE_STACK_PARAMS) return;
1034 if (RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN) 1015 if (RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN)
1035 ->num_double_registers() < 2) 1016 ->num_double_registers() < 2)
1036 return; 1017 return;
1037 1018
1038 // TODO(titzer): mix in 64-bit types on all platforms when supported. 1019 // TODO(titzer): mix in 64-bit types on all platforms when supported.
1039 #if V8_TARGET_ARCH_32_BIT 1020 #if V8_TARGET_ARCH_32_BIT
1040 static MachineType types[] = { 1021 static MachineType types[] = {
1041 kMachInt32, kMachFloat32, kMachFloat64, kMachInt32, kMachFloat64, 1022 kMachInt32, kMachFloat32, kMachFloat64, kMachInt32, kMachFloat64,
1042 kMachFloat32, kMachFloat32, kMachFloat64, kMachInt32, kMachFloat32, 1023 kMachFloat32, kMachFloat32, kMachFloat64, kMachInt32, kMachFloat32,
1043 kMachInt32, kMachFloat64, kMachFloat64, kMachFloat32, kMachInt32, 1024 kMachInt32, kMachFloat64, kMachFloat64, kMachFloat32, kMachInt32,
1044 kMachFloat64, kMachInt32, kMachFloat32}; 1025 kMachFloat64, kMachInt32, kMachFloat32};
1045 #else 1026 #else
1046 static MachineType types[] = { 1027 static MachineType types[] = {
1047 kMachInt32, kMachInt64, kMachFloat32, kMachFloat64, kMachInt32, 1028 kMachInt32, kMachInt64, kMachFloat32, kMachFloat64, kMachInt32,
1048 kMachFloat64, kMachFloat32, kMachInt64, kMachFloat64, kMachInt32, 1029 kMachFloat64, kMachFloat32, kMachInt64, kMachInt64, kMachFloat32,
1049 kMachFloat32, kMachInt32, kMachFloat64, kMachFloat64, kMachInt64, 1030 kMachFloat32, kMachInt32, kMachFloat64, kMachFloat64, kMachInt64,
1050 kMachInt32, kMachFloat64, kMachInt32, kMachFloat32}; 1031 kMachInt32, kMachFloat64, kMachInt32, kMachFloat32};
1051 #endif 1032 #endif
1052 1033
1053 Isolate* isolate = CcTest::InitIsolateOnce(); 1034 Isolate* isolate = CcTest::InitIsolateOnce();
1054 1035
1055 // Build machine signature 1036 // Build machine signature
1056 MachineType* params = &types[start]; 1037 MachineType* params = &types[start];
1057 const int num_params = static_cast<int>(arraysize(types) - start); 1038 const int num_params = static_cast<int>(arraysize(types) - start);
1058 1039
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1162 1143
1163 1144
1164 TEST(MixedParams_0) { MixedParamTest(0); } 1145 TEST(MixedParams_0) { MixedParamTest(0); }
1165 TEST(MixedParams_1) { MixedParamTest(1); } 1146 TEST(MixedParams_1) { MixedParamTest(1); }
1166 TEST(MixedParams_2) { MixedParamTest(2); } 1147 TEST(MixedParams_2) { MixedParamTest(2); }
1167 TEST(MixedParams_3) { MixedParamTest(3); } 1148 TEST(MixedParams_3) { MixedParamTest(3); }
1168 1149
1169 } // namespace compiler 1150 } // namespace compiler
1170 } // namespace internal 1151 } // namespace internal
1171 } // namespace v8 1152 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/linkage.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698