OLD | NEW |
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 #include "src/assembler.h" | 5 #include "src/assembler.h" |
6 #include "src/codegen.h" | 6 #include "src/codegen.h" |
7 #include "src/compiler/linkage.h" | 7 #include "src/compiler/linkage.h" |
8 #include "src/compiler/machine-type.h" | 8 #include "src/compiler/machine-type.h" |
9 #include "src/compiler/raw-machine-assembler.h" | 9 #include "src/compiler/raw-machine-assembler.h" |
10 #include "src/register-configuration.h" | 10 #include "src/register-configuration.h" |
(...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
682 } | 682 } |
683 | 683 |
684 | 684 |
685 TEST(Run_CopyTwentyInt32_all_allocatable_pairs) { | 685 TEST(Run_CopyTwentyInt32_all_allocatable_pairs) { |
686 if (DISABLE_NATIVE_STACK_PARAMS) return; | 686 if (DISABLE_NATIVE_STACK_PARAMS) return; |
687 Int32Signature sig(20); | 687 Int32Signature sig(20); |
688 RegisterPairs pairs; | 688 RegisterPairs pairs; |
689 while (pairs.More()) { | 689 while (pairs.More()) { |
690 Zone zone; | 690 Zone zone; |
691 int parray[2]; | 691 int parray[2]; |
692 int rarray[] = {0}; | 692 int rarray[] = { |
| 693 RegisterConfiguration::ArchDefault()->GetAllocatableGeneralCode(0)}; |
693 pairs.Next(&parray[0], &parray[1], false); | 694 pairs.Next(&parray[0], &parray[1], false); |
694 Allocator params(parray, 2, nullptr, 0); | 695 Allocator params(parray, 2, nullptr, 0); |
695 Allocator rets(rarray, 1, nullptr, 0); | 696 Allocator rets(rarray, 1, nullptr, 0); |
696 RegisterConfig config(params, rets); | 697 RegisterConfig config(params, rets); |
697 CallDescriptor* desc = config.Create(&zone, &sig); | 698 CallDescriptor* desc = config.Create(&zone, &sig); |
698 CopyTwentyInt32(desc); | 699 CopyTwentyInt32(desc); |
699 } | 700 } |
700 } | 701 } |
701 | 702 |
702 | 703 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
734 | 735 |
735 | 736 |
736 static void Test_Int32_WeightedSum_of_size(int count) { | 737 static void Test_Int32_WeightedSum_of_size(int count) { |
737 if (DISABLE_NATIVE_STACK_PARAMS) return; | 738 if (DISABLE_NATIVE_STACK_PARAMS) return; |
738 Int32Signature sig(count); | 739 Int32Signature sig(count); |
739 for (int p0 = 0; p0 < Register::kNumRegisters; p0++) { | 740 for (int p0 = 0; p0 < Register::kNumRegisters; p0++) { |
740 if (Register::from_code(p0).IsAllocatable()) { | 741 if (Register::from_code(p0).IsAllocatable()) { |
741 Zone zone; | 742 Zone zone; |
742 | 743 |
743 int parray[] = {p0}; | 744 int parray[] = {p0}; |
744 int rarray[] = {0}; | 745 int rarray[] = { |
| 746 RegisterConfiguration::ArchDefault()->GetAllocatableGeneralCode(0)}; |
745 Allocator params(parray, 1, nullptr, 0); | 747 Allocator params(parray, 1, nullptr, 0); |
746 Allocator rets(rarray, 1, nullptr, 0); | 748 Allocator rets(rarray, 1, nullptr, 0); |
747 RegisterConfig config(params, rets); | 749 RegisterConfig config(params, rets); |
748 CallDescriptor* desc = config.Create(&zone, &sig); | 750 CallDescriptor* desc = config.Create(&zone, &sig); |
749 Run_Computation<int32_t>(desc, Build_Int32_WeightedSum, | 751 Run_Computation<int32_t>(desc, Build_Int32_WeightedSum, |
750 Compute_Int32_WeightedSum, 257 + count); | 752 Compute_Int32_WeightedSum, 257 + count); |
751 } | 753 } |
752 } | 754 } |
753 } | 755 } |
754 | 756 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
789 Run_Computation<CType>(desc, Build_Select<which>, | 791 Run_Computation<CType>(desc, Build_Select<which>, |
790 Compute_Select<CType, which>, | 792 Compute_Select<CType, which>, |
791 1044 + which + 3 * sizeof(CType)); | 793 1044 + which + 3 * sizeof(CType)); |
792 } | 794 } |
793 | 795 |
794 | 796 |
795 template <int which> | 797 template <int which> |
796 void Test_Int32_Select() { | 798 void Test_Int32_Select() { |
797 if (DISABLE_NATIVE_STACK_PARAMS) return; | 799 if (DISABLE_NATIVE_STACK_PARAMS) return; |
798 | 800 |
799 int parray[] = {0}; | 801 int parray[] = { |
800 int rarray[] = {0}; | 802 RegisterConfiguration::ArchDefault()->GetAllocatableGeneralCode(0)}; |
| 803 int rarray[] = { |
| 804 RegisterConfiguration::ArchDefault()->GetAllocatableGeneralCode(0)}; |
801 Allocator params(parray, 1, nullptr, 0); | 805 Allocator params(parray, 1, nullptr, 0); |
802 Allocator rets(rarray, 1, nullptr, 0); | 806 Allocator rets(rarray, 1, nullptr, 0); |
803 RegisterConfig config(params, rets); | 807 RegisterConfig config(params, rets); |
804 | 808 |
805 Zone zone; | 809 Zone zone; |
806 | 810 |
807 for (int i = which + 1; i <= 64; i++) { | 811 for (int i = which + 1; i <= 64; i++) { |
808 Int32Signature sig(i); | 812 Int32Signature sig(i); |
809 CallDescriptor* desc = config.Create(&zone, &sig); | 813 CallDescriptor* desc = config.Create(&zone, &sig); |
810 RunSelect<int32_t, which>(desc); | 814 RunSelect<int32_t, which>(desc); |
(...skipping 20 matching lines...) Expand all Loading... |
831 TEST_INT32_SELECT(62) | 835 TEST_INT32_SELECT(62) |
832 TEST_INT32_SELECT(63) | 836 TEST_INT32_SELECT(63) |
833 | 837 |
834 | 838 |
835 TEST(Int64Select_registers) { | 839 TEST(Int64Select_registers) { |
836 if (RegisterConfiguration::ArchDefault() | 840 if (RegisterConfiguration::ArchDefault() |
837 ->num_allocatable_general_registers() < 2) | 841 ->num_allocatable_general_registers() < 2) |
838 return; | 842 return; |
839 if (kPointerSize < 8) return; // TODO(titzer): int64 on 32-bit platforms | 843 if (kPointerSize < 8) return; // TODO(titzer): int64 on 32-bit platforms |
840 | 844 |
841 int rarray[] = {0}; | 845 int rarray[] = { |
| 846 RegisterConfiguration::ArchDefault()->GetAllocatableGeneralCode(0)}; |
842 ArgsBuffer<int64_t>::Sig sig(2); | 847 ArgsBuffer<int64_t>::Sig sig(2); |
843 | 848 |
844 RegisterPairs pairs; | 849 RegisterPairs pairs; |
845 Zone zone; | 850 Zone zone; |
846 while (pairs.More()) { | 851 while (pairs.More()) { |
847 int parray[2]; | 852 int parray[2]; |
848 pairs.Next(&parray[0], &parray[1], false); | 853 pairs.Next(&parray[0], &parray[1], false); |
849 Allocator params(parray, 2, nullptr, 0); | 854 Allocator params(parray, 2, nullptr, 0); |
850 Allocator rets(rarray, 1, nullptr, 0); | 855 Allocator rets(rarray, 1, nullptr, 0); |
851 RegisterConfig config(params, rets); | 856 RegisterConfig config(params, rets); |
852 | 857 |
853 CallDescriptor* desc = config.Create(&zone, &sig); | 858 CallDescriptor* desc = config.Create(&zone, &sig); |
854 RunSelect<int64_t, 0>(desc); | 859 RunSelect<int64_t, 0>(desc); |
855 RunSelect<int64_t, 1>(desc); | 860 RunSelect<int64_t, 1>(desc); |
856 } | 861 } |
857 } | 862 } |
858 | 863 |
859 | 864 |
860 TEST(Float32Select_registers) { | 865 TEST(Float32Select_registers) { |
861 if (RegisterConfiguration::ArchDefault()->num_allocatable_double_registers() < | 866 if (RegisterConfiguration::ArchDefault()->num_allocatable_double_registers() < |
862 2) { | 867 2) { |
863 return; | 868 return; |
864 } | 869 } |
865 | 870 |
866 int rarray[] = {0}; | 871 int rarray[] = { |
| 872 RegisterConfiguration::ArchDefault()->GetAllocatableDoubleCode(0)}; |
867 ArgsBuffer<float32>::Sig sig(2); | 873 ArgsBuffer<float32>::Sig sig(2); |
868 | 874 |
869 Float32RegisterPairs pairs; | 875 Float32RegisterPairs pairs; |
870 Zone zone; | 876 Zone zone; |
871 while (pairs.More()) { | 877 while (pairs.More()) { |
872 int parray[2]; | 878 int parray[2]; |
873 pairs.Next(&parray[0], &parray[1], false); | 879 pairs.Next(&parray[0], &parray[1], false); |
874 Allocator params(nullptr, 0, parray, 2); | 880 Allocator params(nullptr, 0, parray, 2); |
875 Allocator rets(nullptr, 0, rarray, 1); | 881 Allocator rets(nullptr, 0, rarray, 1); |
876 RegisterConfig config(params, rets); | 882 RegisterConfig config(params, rets); |
877 | 883 |
878 CallDescriptor* desc = config.Create(&zone, &sig); | 884 CallDescriptor* desc = config.Create(&zone, &sig); |
879 RunSelect<float32, 0>(desc); | 885 RunSelect<float32, 0>(desc); |
880 RunSelect<float32, 1>(desc); | 886 RunSelect<float32, 1>(desc); |
881 } | 887 } |
882 } | 888 } |
883 | 889 |
884 | 890 |
885 TEST(Float64Select_registers) { | 891 TEST(Float64Select_registers) { |
886 if (RegisterConfiguration::ArchDefault()->num_allocatable_double_registers() < | 892 if (RegisterConfiguration::ArchDefault()->num_allocatable_double_registers() < |
887 2) | 893 2) |
888 return; | 894 return; |
889 if (RegisterConfiguration::ArchDefault() | 895 if (RegisterConfiguration::ArchDefault() |
890 ->num_allocatable_general_registers() < 2) | 896 ->num_allocatable_general_registers() < 2) |
891 return; | 897 return; |
892 int rarray[] = {0}; | 898 int rarray[] = { |
| 899 RegisterConfiguration::ArchDefault()->GetAllocatableDoubleCode(0)}; |
893 ArgsBuffer<float64>::Sig sig(2); | 900 ArgsBuffer<float64>::Sig sig(2); |
894 | 901 |
895 Float64RegisterPairs pairs; | 902 Float64RegisterPairs pairs; |
896 Zone zone; | 903 Zone zone; |
897 while (pairs.More()) { | 904 while (pairs.More()) { |
898 int parray[2]; | 905 int parray[2]; |
899 pairs.Next(&parray[0], &parray[1], false); | 906 pairs.Next(&parray[0], &parray[1], false); |
900 Allocator params(nullptr, 0, parray, 2); | 907 Allocator params(nullptr, 0, parray, 2); |
901 Allocator rets(nullptr, 0, rarray, 1); | 908 Allocator rets(nullptr, 0, rarray, 1); |
902 RegisterConfig config(params, rets); | 909 RegisterConfig config(params, rets); |
903 | 910 |
904 CallDescriptor* desc = config.Create(&zone, &sig); | 911 CallDescriptor* desc = config.Create(&zone, &sig); |
905 RunSelect<float64, 0>(desc); | 912 RunSelect<float64, 0>(desc); |
906 RunSelect<float64, 1>(desc); | 913 RunSelect<float64, 1>(desc); |
907 } | 914 } |
908 } | 915 } |
909 | 916 |
910 | 917 |
911 TEST(Float32Select_stack_params_return_reg) { | 918 TEST(Float32Select_stack_params_return_reg) { |
912 if (DISABLE_NATIVE_STACK_PARAMS) return; | 919 if (DISABLE_NATIVE_STACK_PARAMS) return; |
913 int rarray[] = {0}; | 920 int rarray[] = { |
| 921 RegisterConfiguration::ArchDefault()->GetAllocatableDoubleCode(0)}; |
914 Allocator params(nullptr, 0, nullptr, 0); | 922 Allocator params(nullptr, 0, nullptr, 0); |
915 Allocator rets(nullptr, 0, rarray, 1); | 923 Allocator rets(nullptr, 0, rarray, 1); |
916 RegisterConfig config(params, rets); | 924 RegisterConfig config(params, rets); |
917 | 925 |
918 Zone zone; | 926 Zone zone; |
919 for (int count = 1; count < 6; count++) { | 927 for (int count = 1; count < 6; count++) { |
920 ArgsBuffer<float32>::Sig sig(count); | 928 ArgsBuffer<float32>::Sig sig(count); |
921 CallDescriptor* desc = config.Create(&zone, &sig); | 929 CallDescriptor* desc = config.Create(&zone, &sig); |
922 RunSelect<float32, 0>(desc); | 930 RunSelect<float32, 0>(desc); |
923 RunSelect<float32, 1>(desc); | 931 RunSelect<float32, 1>(desc); |
924 RunSelect<float32, 2>(desc); | 932 RunSelect<float32, 2>(desc); |
925 RunSelect<float32, 3>(desc); | 933 RunSelect<float32, 3>(desc); |
926 RunSelect<float32, 4>(desc); | 934 RunSelect<float32, 4>(desc); |
927 RunSelect<float32, 5>(desc); | 935 RunSelect<float32, 5>(desc); |
928 } | 936 } |
929 } | 937 } |
930 | 938 |
931 | 939 |
932 TEST(Float64Select_stack_params_return_reg) { | 940 TEST(Float64Select_stack_params_return_reg) { |
933 if (DISABLE_NATIVE_STACK_PARAMS) return; | 941 if (DISABLE_NATIVE_STACK_PARAMS) return; |
934 int rarray[] = {0}; | 942 int rarray[] = { |
| 943 RegisterConfiguration::ArchDefault()->GetAllocatableDoubleCode(0)}; |
935 Allocator params(nullptr, 0, nullptr, 0); | 944 Allocator params(nullptr, 0, nullptr, 0); |
936 Allocator rets(nullptr, 0, rarray, 1); | 945 Allocator rets(nullptr, 0, rarray, 1); |
937 RegisterConfig config(params, rets); | 946 RegisterConfig config(params, rets); |
938 | 947 |
939 Zone zone; | 948 Zone zone; |
940 for (int count = 1; count < 6; count++) { | 949 for (int count = 1; count < 6; count++) { |
941 ArgsBuffer<float64>::Sig sig(count); | 950 ArgsBuffer<float64>::Sig sig(count); |
942 CallDescriptor* desc = config.Create(&zone, &sig); | 951 CallDescriptor* desc = config.Create(&zone, &sig); |
943 RunSelect<float64, 0>(desc); | 952 RunSelect<float64, 0>(desc); |
944 RunSelect<float64, 1>(desc); | 953 RunSelect<float64, 1>(desc); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
978 | 987 |
979 Node* call = raw.CallN(desc, target, args); | 988 Node* call = raw.CallN(desc, target, args); |
980 raw.Return(call); | 989 raw.Return(call); |
981 } | 990 } |
982 } | 991 } |
983 | 992 |
984 | 993 |
985 TEST(Float64StackParamsToStackParams) { | 994 TEST(Float64StackParamsToStackParams) { |
986 if (DISABLE_NATIVE_STACK_PARAMS) return; | 995 if (DISABLE_NATIVE_STACK_PARAMS) return; |
987 | 996 |
988 int rarray[] = {0}; | 997 int rarray[] = { |
| 998 RegisterConfiguration::ArchDefault()->GetAllocatableDoubleCode(0)}; |
989 Allocator params(nullptr, 0, nullptr, 0); | 999 Allocator params(nullptr, 0, nullptr, 0); |
990 Allocator rets(nullptr, 0, rarray, 1); | 1000 Allocator rets(nullptr, 0, rarray, 1); |
991 | 1001 |
992 Zone zone; | 1002 Zone zone; |
993 ArgsBuffer<float64>::Sig sig(2); | 1003 ArgsBuffer<float64>::Sig sig(2); |
994 RegisterConfig config(params, rets); | 1004 RegisterConfig config(params, rets); |
995 CallDescriptor* desc = config.Create(&zone, &sig); | 1005 CallDescriptor* desc = config.Create(&zone, &sig); |
996 | 1006 |
997 Run_Computation<float64>(desc, Build_Select_With_Call<float64, 0>, | 1007 Run_Computation<float64>(desc, Build_Select_With_Call<float64, 0>, |
998 Compute_Select<float64, 0>, 1098); | 1008 Compute_Select<float64, 0>, 1098); |
(...skipping 22 matching lines...) Expand all Loading... |
1021 kMachInt32, kMachFloat64, kMachInt32, kMachFloat32}; | 1031 kMachInt32, kMachFloat64, kMachInt32, kMachFloat32}; |
1022 #endif | 1032 #endif |
1023 | 1033 |
1024 Isolate* isolate = CcTest::InitIsolateOnce(); | 1034 Isolate* isolate = CcTest::InitIsolateOnce(); |
1025 | 1035 |
1026 // Build machine signature | 1036 // Build machine signature |
1027 MachineType* params = &types[start]; | 1037 MachineType* params = &types[start]; |
1028 const int num_params = static_cast<int>(arraysize(types) - start); | 1038 const int num_params = static_cast<int>(arraysize(types) - start); |
1029 | 1039 |
1030 // Build call descriptor | 1040 // Build call descriptor |
1031 int parray[] = {0, 1}; | 1041 int parray_gp[] = { |
1032 int rarray[] = {0}; | 1042 RegisterConfiguration::ArchDefault()->GetAllocatableGeneralCode(0), |
1033 Allocator palloc(parray, 2, parray, 2); | 1043 RegisterConfiguration::ArchDefault()->GetAllocatableGeneralCode(1)}; |
1034 Allocator ralloc(rarray, 1, rarray, 1); | 1044 int rarray_gp[] = { |
| 1045 RegisterConfiguration::ArchDefault()->GetAllocatableGeneralCode(0)}; |
| 1046 int parray_fp[] = { |
| 1047 RegisterConfiguration::ArchDefault()->GetAllocatableDoubleCode(0), |
| 1048 RegisterConfiguration::ArchDefault()->GetAllocatableDoubleCode(1)}; |
| 1049 int rarray_fp[] = { |
| 1050 RegisterConfiguration::ArchDefault()->GetAllocatableDoubleCode(0)}; |
| 1051 Allocator palloc(parray_gp, 2, parray_fp, 2); |
| 1052 Allocator ralloc(rarray_gp, 1, rarray_fp, 1); |
1035 RegisterConfig config(palloc, ralloc); | 1053 RegisterConfig config(palloc, ralloc); |
1036 | 1054 |
1037 for (int which = 0; which < num_params; which++) { | 1055 for (int which = 0; which < num_params; which++) { |
1038 Zone zone; | 1056 Zone zone; |
1039 HandleScope scope(isolate); | 1057 HandleScope scope(isolate); |
1040 MachineSignature::Builder builder(&zone, 1, num_params); | 1058 MachineSignature::Builder builder(&zone, 1, num_params); |
1041 builder.AddReturn(params[which]); | 1059 builder.AddReturn(params[which]); |
1042 for (int j = 0; j < num_params; j++) builder.AddParam(params[j]); | 1060 for (int j = 0; j < num_params; j++) builder.AddParam(params[j]); |
1043 MachineSignature* sig = builder.Build(); | 1061 MachineSignature* sig = builder.Build(); |
1044 CallDescriptor* desc = config.Create(&zone, sig); | 1062 CallDescriptor* desc = config.Create(&zone, sig); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1115 } | 1133 } |
1116 } | 1134 } |
1117 } | 1135 } |
1118 } | 1136 } |
1119 | 1137 |
1120 | 1138 |
1121 TEST(MixedParams_0) { MixedParamTest(0); } | 1139 TEST(MixedParams_0) { MixedParamTest(0); } |
1122 TEST(MixedParams_1) { MixedParamTest(1); } | 1140 TEST(MixedParams_1) { MixedParamTest(1); } |
1123 TEST(MixedParams_2) { MixedParamTest(2); } | 1141 TEST(MixedParams_2) { MixedParamTest(2); } |
1124 TEST(MixedParams_3) { MixedParamTest(3); } | 1142 TEST(MixedParams_3) { MixedParamTest(3); } |
OLD | NEW |