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

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

Issue 1314973004: Add test-run-native-calls tests for mixed parameters. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 3 months 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 | « no previous file | 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 #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 10
(...skipping 966 matching lines...) Expand 10 before | Expand all | Expand 10 after
977 ArgsBuffer<float64>::Sig sig(2); 977 ArgsBuffer<float64>::Sig sig(2);
978 RegisterConfig config(params, rets); 978 RegisterConfig config(params, rets);
979 CallDescriptor* desc = config.Create(&zone, &sig); 979 CallDescriptor* desc = config.Create(&zone, &sig);
980 980
981 Run_Computation<float64>(desc, Build_Select_With_Call<float64, 0>, 981 Run_Computation<float64>(desc, Build_Select_With_Call<float64, 0>,
982 Compute_Select<float64, 0>, 1098); 982 Compute_Select<float64, 0>, 1098);
983 983
984 Run_Computation<float64>(desc, Build_Select_With_Call<float64, 1>, 984 Run_Computation<float64>(desc, Build_Select_With_Call<float64, 1>,
985 Compute_Select<float64, 1>, 1099); 985 Compute_Select<float64, 1>, 1099);
986 } 986 }
987
988
989 void MixedParamTest(int start) {
990 if (DISABLE_NATIVE_STACK_PARAMS) return;
991 if (RegisterConfiguration::ArchDefault()->num_double_registers() < 2) return;
992 #ifdef V8_TARGET_ARCH_MIPS64
993 // TODO(titzer): MIPS stack doubles can be misaligned.
994 if (true) return;
995 #endif
996
997 // TODO(titzer): mix in 64-bit types on all platforms when supported.
998 #if V8_TARGET_ARCH_32_BIT
999 static MachineType types[] = {
1000 kMachInt32, kMachFloat32, kMachFloat64, kMachInt32, kMachFloat64,
1001 kMachFloat32, kMachFloat32, kMachFloat64, kMachInt32, kMachFloat32,
1002 kMachInt32, kMachFloat64, kMachFloat64, kMachFloat32, kMachInt32,
1003 kMachFloat64, kMachInt32, kMachFloat32};
1004 #else
1005 static MachineType types[] = {
1006 kMachInt32, kMachInt64, kMachFloat32, kMachFloat64, kMachInt32,
1007 kMachFloat64, kMachFloat32, kMachInt64, kMachFloat64, kMachInt32,
1008 kMachFloat32, kMachInt32, kMachFloat64, kMachFloat64, kMachInt64,
1009 kMachInt32, kMachFloat64, kMachInt32, kMachFloat32};
1010 #endif
1011
1012 Isolate* isolate = CcTest::InitIsolateOnce();
1013
1014 // Build machine signature
1015 MachineType* params = &types[start];
1016 const int num_params = static_cast<int>(arraysize(types) - start);
1017
1018 // Build call descriptor
1019 int parray[] = {0, 1};
1020 int rarray[] = {0};
1021 Allocator palloc(parray, 2, parray, 2);
1022 Allocator ralloc(rarray, 1, rarray, 1);
1023 RegisterConfig config(palloc, ralloc);
1024
1025 for (int which = 0; which < num_params; which++) {
1026 Zone zone;
1027 HandleScope scope(isolate);
1028 MachineSignature::Builder builder(&zone, 1, num_params);
1029 builder.AddReturn(params[which]);
1030 for (int j = 0; j < num_params; j++) builder.AddParam(params[j]);
1031 MachineSignature* sig = builder.Build();
1032 CallDescriptor* desc = config.Create(&zone, sig);
1033
1034 Handle<Code> select;
1035 {
1036 // build the select.
1037 Zone zone;
1038 Graph graph(&zone);
1039 RawMachineAssembler raw(isolate, &graph, desc);
1040 raw.Return(raw.Parameter(which));
1041 select = CompileGraph("Compute", desc, &graph, raw.Export());
1042 }
1043
1044 {
1045 // call the select.
1046 Handle<Code> wrapper = Handle<Code>::null();
1047 int32_t expected_ret;
1048 char bytes[kDoubleSize];
1049 char output[kDoubleSize];
1050 int expected_size = 0;
1051 CSignature0<int32_t> csig;
1052 {
1053 // Wrap the select code with a callable function that passes constants.
1054 Zone zone;
1055 Graph graph(&zone);
1056 CallDescriptor* cdesc = Linkage::GetSimplifiedCDescriptor(&zone, &csig);
1057 RawMachineAssembler raw(isolate, &graph, cdesc);
1058 Unique<HeapObject> unique =
1059 Unique<HeapObject>::CreateUninitialized(select);
1060 Node* target = raw.HeapConstant(unique);
1061 Node** args = zone.NewArray<Node*>(num_params);
1062 int64_t constant = 0x0102030405060708;
1063 for (int i = 0; i < num_params; i++) {
1064 MachineType param_type = sig->GetParam(i);
1065 Node* konst = nullptr;
1066 if (param_type == kMachInt32) {
1067 int32_t value[] = {static_cast<int32_t>(constant)};
1068 konst = raw.Int32Constant(value[0]);
1069 if (i == which) memcpy(bytes, value, expected_size = 4);
1070 }
1071 if (param_type == kMachInt64) {
1072 int64_t value[] = {static_cast<int64_t>(constant)};
1073 konst = raw.Int64Constant(value[0]);
1074 if (i == which) memcpy(bytes, value, expected_size = 8);
1075 }
1076 if (param_type == kMachFloat32) {
1077 float32 value[] = {static_cast<float32>(constant)};
1078 konst = raw.Float32Constant(value[0]);
1079 if (i == which) memcpy(bytes, value, expected_size = 4);
1080 }
1081 if (param_type == kMachFloat64) {
1082 float64 value[] = {static_cast<float64>(constant)};
1083 konst = raw.Float64Constant(value[0]);
1084 if (i == which) memcpy(bytes, value, expected_size = 8);
1085 }
1086 CHECK_NOT_NULL(konst);
1087
1088 args[i] = konst;
1089 constant += 0x1010101010101010;
1090 }
1091
1092 Node* call = raw.CallN(desc, target, args);
1093 Node* store = raw.StoreToPointer(output, sig->GetReturn(), call);
1094 USE(store);
1095 expected_ret = static_cast<int32_t>(constant);
1096 raw.Return(raw.Int32Constant(expected_ret));
1097 wrapper = CompileGraph("Select-mixed-wrapper-const", cdesc, &graph,
1098 raw.Export());
1099 }
1100
1101 CodeRunner<int32_t> runnable(isolate, wrapper, &csig);
1102 CHECK_EQ(expected_ret, runnable.Call());
1103 for (int i = 0; i < expected_size; i++) {
1104 CHECK_EQ(static_cast<int>(bytes[i]), static_cast<int>(output[i]));
1105 }
1106 }
1107 }
1108 }
1109
1110
1111 TEST(MixedParams_0) { MixedParamTest(0); }
1112 TEST(MixedParams_1) { MixedParamTest(1); }
1113 TEST(MixedParams_2) { MixedParamTest(2); }
1114 TEST(MixedParams_3) { MixedParamTest(3); }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698