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 <stdint.h> | 5 #include <stdint.h> |
6 #include <stdlib.h> | 6 #include <stdlib.h> |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/wasm/wasm-macro-gen.h" | 10 #include "src/wasm/wasm-macro-gen.h" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 V(I64Ror, true) \ | 83 V(I64Ror, true) \ |
84 V(I64Rol, true) | 84 V(I64Rol, true) |
85 | 85 |
86 #define DECLARE_CONST(name, cond) static const bool kSupported_##name = cond; | 86 #define DECLARE_CONST(name, cond) static const bool kSupported_##name = cond; |
87 FOREACH_I64_OPERATOR(DECLARE_CONST) | 87 FOREACH_I64_OPERATOR(DECLARE_CONST) |
88 #undef DECLARE_CONST | 88 #undef DECLARE_CONST |
89 | 89 |
90 #define REQUIRE(name) \ | 90 #define REQUIRE(name) \ |
91 if (!WASM_64 && !kSupported_##name) return | 91 if (!WASM_64 && !kSupported_##name) return |
92 | 92 |
93 TEST(Run_Wasm_I64Const) { | 93 WASM_EXEC_TEST(I64Const) { |
94 REQUIRE(I64Const); | 94 REQUIRE(I64Const); |
95 WasmRunner<int64_t> r; | 95 WasmRunner<int64_t> r; |
96 const int64_t kExpectedValue = 0x1122334455667788LL; | 96 const int64_t kExpectedValue = 0x1122334455667788LL; |
97 // return(kExpectedValue) | 97 // return(kExpectedValue) |
98 BUILD(r, WASM_I64V_9(kExpectedValue)); | 98 BUILD(r, WASM_I64V_9(kExpectedValue)); |
99 CHECK_EQ(kExpectedValue, r.Call()); | 99 CHECK_EQ(kExpectedValue, r.Call()); |
100 } | 100 } |
101 | 101 |
102 TEST(Run_Wasm_I64Const_many) { | 102 WASM_EXEC_TEST(I64Const_many) { |
103 REQUIRE(I64Const); | 103 REQUIRE(I64Const); |
104 int cntr = 0; | 104 int cntr = 0; |
105 FOR_INT32_INPUTS(i) { | 105 FOR_INT32_INPUTS(i) { |
106 WasmRunner<int64_t> r; | 106 WasmRunner<int64_t> r; |
107 const int64_t kExpectedValue = (static_cast<int64_t>(*i) << 32) | cntr; | 107 const int64_t kExpectedValue = (static_cast<int64_t>(*i) << 32) | cntr; |
108 // return(kExpectedValue) | 108 // return(kExpectedValue) |
109 BUILD(r, WASM_I64V(kExpectedValue)); | 109 BUILD(r, WASM_I64V(kExpectedValue)); |
110 CHECK_EQ(kExpectedValue, r.Call()); | 110 CHECK_EQ(kExpectedValue, r.Call()); |
111 cntr++; | 111 cntr++; |
112 } | 112 } |
113 } | 113 } |
114 | 114 |
115 TEST(Run_Wasm_Return_I64) { | 115 WASM_EXEC_TEST(Return_I64) { |
116 REQUIRE(I64Return); | 116 REQUIRE(I64Return); |
117 WasmRunner<int64_t> r(MachineType::Int64()); | 117 WasmRunner<int64_t> r(MachineType::Int64()); |
118 | 118 |
119 BUILD(r, WASM_RETURN1(WASM_GET_LOCAL(0))); | 119 BUILD(r, WASM_RETURN1(WASM_GET_LOCAL(0))); |
120 | 120 |
121 FOR_INT64_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); } | 121 FOR_INT64_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); } |
122 } | 122 } |
123 | 123 |
124 TEST(Run_WasmI64Add) { | 124 WASM_EXEC_TEST(I64Add) { |
125 REQUIRE(I64Add); | 125 REQUIRE(I64Add); |
126 WasmRunner<int64_t> r(MachineType::Int64(), MachineType::Int64()); | 126 WasmRunner<int64_t> r(MachineType::Int64(), MachineType::Int64()); |
127 BUILD(r, WASM_I64_ADD(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | 127 BUILD(r, WASM_I64_ADD(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
128 FOR_INT64_INPUTS(i) { | 128 FOR_INT64_INPUTS(i) { |
129 FOR_INT64_INPUTS(j) { CHECK_EQ(*i + *j, r.Call(*i, *j)); } | 129 FOR_INT64_INPUTS(j) { CHECK_EQ(*i + *j, r.Call(*i, *j)); } |
130 } | 130 } |
131 } | 131 } |
132 | 132 |
133 TEST(Run_Wasm_I64Sub) { | 133 WASM_EXEC_TEST(I64Sub) { |
134 REQUIRE(I64Sub); | 134 REQUIRE(I64Sub); |
135 WasmRunner<int64_t> r(MachineType::Int64(), MachineType::Int64()); | 135 WasmRunner<int64_t> r(MachineType::Int64(), MachineType::Int64()); |
136 BUILD(r, WASM_I64_SUB(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | 136 BUILD(r, WASM_I64_SUB(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
137 FOR_INT64_INPUTS(i) { | 137 FOR_INT64_INPUTS(i) { |
138 FOR_INT64_INPUTS(j) { CHECK_EQ(*i - *j, r.Call(*i, *j)); } | 138 FOR_INT64_INPUTS(j) { CHECK_EQ(*i - *j, r.Call(*i, *j)); } |
139 } | 139 } |
140 } | 140 } |
141 | 141 |
142 TEST(Run_WasmI64DivS) { | 142 WASM_EXEC_TEST(I64DivS) { |
143 REQUIRE(I64DivS); | 143 REQUIRE(I64DivS); |
144 WasmRunner<int64_t> r(MachineType::Int64(), MachineType::Int64()); | 144 WasmRunner<int64_t> r(MachineType::Int64(), MachineType::Int64()); |
145 BUILD(r, WASM_I64_DIVS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | 145 BUILD(r, WASM_I64_DIVS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
146 FOR_INT64_INPUTS(i) { | 146 FOR_INT64_INPUTS(i) { |
147 FOR_INT64_INPUTS(j) { | 147 FOR_INT64_INPUTS(j) { |
148 if (*j == 0) { | 148 if (*j == 0) { |
149 CHECK_TRAP64(r.Call(*i, *j)); | 149 CHECK_TRAP64(r.Call(*i, *j)); |
150 } else if (*j == -1 && *i == std::numeric_limits<int64_t>::min()) { | 150 } else if (*j == -1 && *i == std::numeric_limits<int64_t>::min()) { |
151 CHECK_TRAP64(r.Call(*i, *j)); | 151 CHECK_TRAP64(r.Call(*i, *j)); |
152 } else { | 152 } else { |
153 CHECK_EQ(*i / *j, r.Call(*i, *j)); | 153 CHECK_EQ(*i / *j, r.Call(*i, *j)); |
154 } | 154 } |
155 } | 155 } |
156 } | 156 } |
157 } | 157 } |
158 | 158 |
159 TEST(Run_WasmI64DivS_Trap) { | 159 WASM_EXEC_TEST(I64DivS_Trap) { |
160 REQUIRE(I64DivS); | 160 REQUIRE(I64DivS); |
161 WasmRunner<int64_t> r(MachineType::Int64(), MachineType::Int64()); | 161 WasmRunner<int64_t> r(MachineType::Int64(), MachineType::Int64()); |
162 BUILD(r, WASM_I64_DIVS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | 162 BUILD(r, WASM_I64_DIVS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
163 CHECK_EQ(0, r.Call(asi64(0), asi64(100))); | 163 CHECK_EQ(0, r.Call(asi64(0), asi64(100))); |
164 CHECK_TRAP64(r.Call(asi64(100), asi64(0))); | 164 CHECK_TRAP64(r.Call(asi64(100), asi64(0))); |
165 CHECK_TRAP64(r.Call(asi64(-1001), asi64(0))); | 165 CHECK_TRAP64(r.Call(asi64(-1001), asi64(0))); |
166 CHECK_TRAP64(r.Call(std::numeric_limits<int64_t>::min(), asi64(-1))); | 166 CHECK_TRAP64(r.Call(std::numeric_limits<int64_t>::min(), asi64(-1))); |
167 CHECK_TRAP64(r.Call(std::numeric_limits<int64_t>::min(), asi64(0))); | 167 CHECK_TRAP64(r.Call(std::numeric_limits<int64_t>::min(), asi64(0))); |
168 } | 168 } |
169 | 169 |
170 TEST(Run_WasmI64DivS_Byzero_Const) { | 170 WASM_EXEC_TEST(I64DivS_Byzero_Const) { |
171 REQUIRE(I64DivS); | 171 REQUIRE(I64DivS); |
172 for (int8_t denom = -2; denom < 8; denom++) { | 172 for (int8_t denom = -2; denom < 8; denom++) { |
173 WasmRunner<int64_t> r(MachineType::Int64()); | 173 WasmRunner<int64_t> r(MachineType::Int64()); |
174 BUILD(r, WASM_I64_DIVS(WASM_GET_LOCAL(0), WASM_I64V_1(denom))); | 174 BUILD(r, WASM_I64_DIVS(WASM_GET_LOCAL(0), WASM_I64V_1(denom))); |
175 for (int64_t val = -7; val < 8; val++) { | 175 for (int64_t val = -7; val < 8; val++) { |
176 if (denom == 0) { | 176 if (denom == 0) { |
177 CHECK_TRAP64(r.Call(val)); | 177 CHECK_TRAP64(r.Call(val)); |
178 } else { | 178 } else { |
179 CHECK_EQ(val / denom, r.Call(val)); | 179 CHECK_EQ(val / denom, r.Call(val)); |
180 } | 180 } |
181 } | 181 } |
182 } | 182 } |
183 } | 183 } |
184 | 184 |
185 TEST(Run_WasmI64DivU) { | 185 WASM_EXEC_TEST(I64DivU) { |
186 REQUIRE(I64DivU); | 186 REQUIRE(I64DivU); |
187 WasmRunner<uint64_t> r(MachineType::Uint64(), MachineType::Uint64()); | 187 WasmRunner<uint64_t> r(MachineType::Uint64(), MachineType::Uint64()); |
188 BUILD(r, WASM_I64_DIVU(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | 188 BUILD(r, WASM_I64_DIVU(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
189 FOR_UINT64_INPUTS(i) { | 189 FOR_UINT64_INPUTS(i) { |
190 FOR_UINT64_INPUTS(j) { | 190 FOR_UINT64_INPUTS(j) { |
191 if (*j == 0) { | 191 if (*j == 0) { |
192 CHECK_TRAP64(r.Call(*i, *j)); | 192 CHECK_TRAP64(r.Call(*i, *j)); |
193 } else { | 193 } else { |
194 CHECK_EQ(*i / *j, r.Call(*i, *j)); | 194 CHECK_EQ(*i / *j, r.Call(*i, *j)); |
195 } | 195 } |
196 } | 196 } |
197 } | 197 } |
198 } | 198 } |
199 | 199 |
200 TEST(Run_WasmI64DivU_Trap) { | 200 WASM_EXEC_TEST(I64DivU_Trap) { |
201 REQUIRE(I64DivU); | 201 REQUIRE(I64DivU); |
202 WasmRunner<uint64_t> r(MachineType::Uint64(), MachineType::Uint64()); | 202 WasmRunner<uint64_t> r(MachineType::Uint64(), MachineType::Uint64()); |
203 BUILD(r, WASM_I64_DIVU(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | 203 BUILD(r, WASM_I64_DIVU(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
204 CHECK_EQ(0, r.Call(asu64(0), asu64(100))); | 204 CHECK_EQ(0, r.Call(asu64(0), asu64(100))); |
205 CHECK_TRAP64(r.Call(asu64(100), asu64(0))); | 205 CHECK_TRAP64(r.Call(asu64(100), asu64(0))); |
206 CHECK_TRAP64(r.Call(asu64(1001), asu64(0))); | 206 CHECK_TRAP64(r.Call(asu64(1001), asu64(0))); |
207 CHECK_TRAP64(r.Call(std::numeric_limits<uint64_t>::max(), asu64(0))); | 207 CHECK_TRAP64(r.Call(std::numeric_limits<uint64_t>::max(), asu64(0))); |
208 } | 208 } |
209 | 209 |
210 TEST(Run_WasmI64DivU_Byzero_Const) { | 210 WASM_EXEC_TEST(I64DivU_Byzero_Const) { |
211 REQUIRE(I64DivU); | 211 REQUIRE(I64DivU); |
212 for (uint64_t denom = 0xfffffffffffffffe; denom < 8; denom++) { | 212 for (uint64_t denom = 0xfffffffffffffffe; denom < 8; denom++) { |
213 WasmRunner<uint64_t> r(MachineType::Uint64()); | 213 WasmRunner<uint64_t> r(MachineType::Uint64()); |
214 BUILD(r, WASM_I64_DIVU(WASM_GET_LOCAL(0), WASM_I64V_1(denom))); | 214 BUILD(r, WASM_I64_DIVU(WASM_GET_LOCAL(0), WASM_I64V_1(denom))); |
215 | 215 |
216 for (uint64_t val = 0xfffffffffffffff0; val < 8; val++) { | 216 for (uint64_t val = 0xfffffffffffffff0; val < 8; val++) { |
217 if (denom == 0) { | 217 if (denom == 0) { |
218 CHECK_TRAP64(r.Call(val)); | 218 CHECK_TRAP64(r.Call(val)); |
219 } else { | 219 } else { |
220 CHECK_EQ(val / denom, r.Call(val)); | 220 CHECK_EQ(val / denom, r.Call(val)); |
221 } | 221 } |
222 } | 222 } |
223 } | 223 } |
224 } | 224 } |
225 | 225 |
226 TEST(Run_WasmI64RemS) { | 226 WASM_EXEC_TEST(I64RemS) { |
227 REQUIRE(I64RemS); | 227 REQUIRE(I64RemS); |
228 WasmRunner<int64_t> r(MachineType::Int64(), MachineType::Int64()); | 228 WasmRunner<int64_t> r(MachineType::Int64(), MachineType::Int64()); |
229 BUILD(r, WASM_I64_REMS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | 229 BUILD(r, WASM_I64_REMS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
230 FOR_INT64_INPUTS(i) { | 230 FOR_INT64_INPUTS(i) { |
231 FOR_INT64_INPUTS(j) { | 231 FOR_INT64_INPUTS(j) { |
232 if (*j == 0) { | 232 if (*j == 0) { |
233 CHECK_TRAP64(r.Call(*i, *j)); | 233 CHECK_TRAP64(r.Call(*i, *j)); |
234 } else { | 234 } else { |
235 CHECK_EQ(*i % *j, r.Call(*i, *j)); | 235 CHECK_EQ(*i % *j, r.Call(*i, *j)); |
236 } | 236 } |
237 } | 237 } |
238 } | 238 } |
239 } | 239 } |
240 | 240 |
241 TEST(Run_WasmI64RemS_Trap) { | 241 WASM_EXEC_TEST(I64RemS_Trap) { |
242 REQUIRE(I64RemS); | 242 REQUIRE(I64RemS); |
243 WasmRunner<int64_t> r(MachineType::Int64(), MachineType::Int64()); | 243 WasmRunner<int64_t> r(MachineType::Int64(), MachineType::Int64()); |
244 BUILD(r, WASM_I64_REMS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | 244 BUILD(r, WASM_I64_REMS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
245 CHECK_EQ(33, r.Call(asi64(133), asi64(100))); | 245 CHECK_EQ(33, r.Call(asi64(133), asi64(100))); |
246 CHECK_EQ(0, r.Call(std::numeric_limits<int64_t>::min(), asi64(-1))); | 246 CHECK_EQ(0, r.Call(std::numeric_limits<int64_t>::min(), asi64(-1))); |
247 CHECK_TRAP64(r.Call(asi64(100), asi64(0))); | 247 CHECK_TRAP64(r.Call(asi64(100), asi64(0))); |
248 CHECK_TRAP64(r.Call(asi64(-1001), asi64(0))); | 248 CHECK_TRAP64(r.Call(asi64(-1001), asi64(0))); |
249 CHECK_TRAP64(r.Call(std::numeric_limits<int64_t>::min(), asi64(0))); | 249 CHECK_TRAP64(r.Call(std::numeric_limits<int64_t>::min(), asi64(0))); |
250 } | 250 } |
251 | 251 |
252 TEST(Run_WasmI64RemU) { | 252 WASM_EXEC_TEST(I64RemU) { |
253 REQUIRE(I64RemU); | 253 REQUIRE(I64RemU); |
254 WasmRunner<uint64_t> r(MachineType::Uint64(), MachineType::Uint64()); | 254 WasmRunner<uint64_t> r(MachineType::Uint64(), MachineType::Uint64()); |
255 BUILD(r, WASM_I64_REMU(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | 255 BUILD(r, WASM_I64_REMU(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
256 FOR_UINT64_INPUTS(i) { | 256 FOR_UINT64_INPUTS(i) { |
257 FOR_UINT64_INPUTS(j) { | 257 FOR_UINT64_INPUTS(j) { |
258 if (*j == 0) { | 258 if (*j == 0) { |
259 CHECK_TRAP64(r.Call(*i, *j)); | 259 CHECK_TRAP64(r.Call(*i, *j)); |
260 } else { | 260 } else { |
261 CHECK_EQ(*i % *j, r.Call(*i, *j)); | 261 CHECK_EQ(*i % *j, r.Call(*i, *j)); |
262 } | 262 } |
263 } | 263 } |
264 } | 264 } |
265 } | 265 } |
266 | 266 |
267 TEST(Run_Wasm_I64RemU_Trap) { | 267 WASM_EXEC_TEST(I64RemU_Trap) { |
268 REQUIRE(I64RemU); | 268 REQUIRE(I64RemU); |
269 WasmRunner<uint64_t> r(MachineType::Uint64(), MachineType::Uint64()); | 269 WasmRunner<uint64_t> r(MachineType::Uint64(), MachineType::Uint64()); |
270 BUILD(r, WASM_I64_REMU(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | 270 BUILD(r, WASM_I64_REMU(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
271 CHECK_EQ(17, r.Call(asu64(217), asu64(100))); | 271 CHECK_EQ(17, r.Call(asu64(217), asu64(100))); |
272 CHECK_TRAP64(r.Call(asu64(100), asu64(0))); | 272 CHECK_TRAP64(r.Call(asu64(100), asu64(0))); |
273 CHECK_TRAP64(r.Call(asu64(1001), asu64(0))); | 273 CHECK_TRAP64(r.Call(asu64(1001), asu64(0))); |
274 CHECK_TRAP64(r.Call(std::numeric_limits<uint64_t>::max(), asu64(0))); | 274 CHECK_TRAP64(r.Call(std::numeric_limits<uint64_t>::max(), asu64(0))); |
275 } | 275 } |
276 | 276 |
277 TEST(Run_Wasm_I64And) { | 277 WASM_EXEC_TEST(I64And) { |
278 REQUIRE(I64And); | 278 REQUIRE(I64And); |
279 WasmRunner<int64_t> r(MachineType::Int64(), MachineType::Int64()); | 279 WasmRunner<int64_t> r(MachineType::Int64(), MachineType::Int64()); |
280 BUILD(r, WASM_I64_AND(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | 280 BUILD(r, WASM_I64_AND(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
281 FOR_INT64_INPUTS(i) { | 281 FOR_INT64_INPUTS(i) { |
282 FOR_INT64_INPUTS(j) { CHECK_EQ((*i) & (*j), r.Call(*i, *j)); } | 282 FOR_INT64_INPUTS(j) { CHECK_EQ((*i) & (*j), r.Call(*i, *j)); } |
283 } | 283 } |
284 } | 284 } |
285 | 285 |
286 TEST(Run_Wasm_I64Ior) { | 286 WASM_EXEC_TEST(I64Ior) { |
287 REQUIRE(I64Ior); | 287 REQUIRE(I64Ior); |
288 WasmRunner<int64_t> r(MachineType::Int64(), MachineType::Int64()); | 288 WasmRunner<int64_t> r(MachineType::Int64(), MachineType::Int64()); |
289 BUILD(r, WASM_I64_IOR(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | 289 BUILD(r, WASM_I64_IOR(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
290 FOR_INT64_INPUTS(i) { | 290 FOR_INT64_INPUTS(i) { |
291 FOR_INT64_INPUTS(j) { CHECK_EQ((*i) | (*j), r.Call(*i, *j)); } | 291 FOR_INT64_INPUTS(j) { CHECK_EQ((*i) | (*j), r.Call(*i, *j)); } |
292 } | 292 } |
293 } | 293 } |
294 | 294 |
295 TEST(Run_Wasm_I64Xor) { | 295 WASM_EXEC_TEST(I64Xor) { |
296 REQUIRE(I64Xor); | 296 REQUIRE(I64Xor); |
297 WasmRunner<int64_t> r(MachineType::Int64(), MachineType::Int64()); | 297 WasmRunner<int64_t> r(MachineType::Int64(), MachineType::Int64()); |
298 BUILD(r, WASM_I64_XOR(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | 298 BUILD(r, WASM_I64_XOR(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
299 FOR_INT64_INPUTS(i) { | 299 FOR_INT64_INPUTS(i) { |
300 FOR_INT64_INPUTS(j) { CHECK_EQ((*i) ^ (*j), r.Call(*i, *j)); } | 300 FOR_INT64_INPUTS(j) { CHECK_EQ((*i) ^ (*j), r.Call(*i, *j)); } |
301 } | 301 } |
302 } | 302 } |
303 | 303 |
304 TEST(Run_Wasm_I64Shl) { | 304 WASM_EXEC_TEST(I64Shl) { |
305 REQUIRE(I64Shl); | 305 REQUIRE(I64Shl); |
306 { | 306 { |
307 WasmRunner<uint64_t> r(MachineType::Uint64(), MachineType::Uint64()); | 307 WasmRunner<uint64_t> r(MachineType::Uint64(), MachineType::Uint64()); |
308 BUILD(r, WASM_I64_SHL(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | 308 BUILD(r, WASM_I64_SHL(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
309 | 309 |
310 FOR_UINT64_INPUTS(i) { | 310 FOR_UINT64_INPUTS(i) { |
311 FOR_UINT64_INPUTS(j) { | 311 FOR_UINT64_INPUTS(j) { |
312 uint64_t expected = (*i) << (*j & 0x3f); | 312 uint64_t expected = (*i) << (*j & 0x3f); |
313 CHECK_EQ(expected, r.Call(*i, *j)); | 313 CHECK_EQ(expected, r.Call(*i, *j)); |
314 } | 314 } |
(...skipping 14 matching lines...) Expand all Loading... |
329 BUILD(r, WASM_I64_SHL(WASM_GET_LOCAL(0), WASM_I64V_1(20))); | 329 BUILD(r, WASM_I64_SHL(WASM_GET_LOCAL(0), WASM_I64V_1(20))); |
330 FOR_UINT64_INPUTS(i) { CHECK_EQ(*i << 20, r.Call(*i)); } | 330 FOR_UINT64_INPUTS(i) { CHECK_EQ(*i << 20, r.Call(*i)); } |
331 } | 331 } |
332 { | 332 { |
333 WasmRunner<int64_t> r(MachineType::Int64()); | 333 WasmRunner<int64_t> r(MachineType::Int64()); |
334 BUILD(r, WASM_I64_SHL(WASM_GET_LOCAL(0), WASM_I64V_1(40))); | 334 BUILD(r, WASM_I64_SHL(WASM_GET_LOCAL(0), WASM_I64V_1(40))); |
335 FOR_UINT64_INPUTS(i) { CHECK_EQ(*i << 40, r.Call(*i)); } | 335 FOR_UINT64_INPUTS(i) { CHECK_EQ(*i << 40, r.Call(*i)); } |
336 } | 336 } |
337 } | 337 } |
338 | 338 |
339 TEST(Run_Wasm_I64ShrU) { | 339 WASM_EXEC_TEST(I64ShrU) { |
340 REQUIRE(I64ShrU); | 340 REQUIRE(I64ShrU); |
341 { | 341 { |
342 WasmRunner<uint64_t> r(MachineType::Uint64(), MachineType::Uint64()); | 342 WasmRunner<uint64_t> r(MachineType::Uint64(), MachineType::Uint64()); |
343 BUILD(r, WASM_I64_SHR(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | 343 BUILD(r, WASM_I64_SHR(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
344 | 344 |
345 FOR_UINT64_INPUTS(i) { | 345 FOR_UINT64_INPUTS(i) { |
346 FOR_UINT64_INPUTS(j) { | 346 FOR_UINT64_INPUTS(j) { |
347 uint64_t expected = (*i) >> (*j & 0x3f); | 347 uint64_t expected = (*i) >> (*j & 0x3f); |
348 CHECK_EQ(expected, r.Call(*i, *j)); | 348 CHECK_EQ(expected, r.Call(*i, *j)); |
349 } | 349 } |
(...skipping 14 matching lines...) Expand all Loading... |
364 BUILD(r, WASM_I64_SHR(WASM_GET_LOCAL(0), WASM_I64V_1(20))); | 364 BUILD(r, WASM_I64_SHR(WASM_GET_LOCAL(0), WASM_I64V_1(20))); |
365 FOR_UINT64_INPUTS(i) { CHECK_EQ(*i >> 20, r.Call(*i)); } | 365 FOR_UINT64_INPUTS(i) { CHECK_EQ(*i >> 20, r.Call(*i)); } |
366 } | 366 } |
367 { | 367 { |
368 WasmRunner<int64_t> r(MachineType::Int64()); | 368 WasmRunner<int64_t> r(MachineType::Int64()); |
369 BUILD(r, WASM_I64_SHR(WASM_GET_LOCAL(0), WASM_I64V_1(40))); | 369 BUILD(r, WASM_I64_SHR(WASM_GET_LOCAL(0), WASM_I64V_1(40))); |
370 FOR_UINT64_INPUTS(i) { CHECK_EQ(*i >> 40, r.Call(*i)); } | 370 FOR_UINT64_INPUTS(i) { CHECK_EQ(*i >> 40, r.Call(*i)); } |
371 } | 371 } |
372 } | 372 } |
373 | 373 |
374 TEST(Run_Wasm_I64ShrS) { | 374 WASM_EXEC_TEST(I64ShrS) { |
375 REQUIRE(I64ShrS); | 375 REQUIRE(I64ShrS); |
376 { | 376 { |
377 WasmRunner<int64_t> r(MachineType::Int64(), MachineType::Int64()); | 377 WasmRunner<int64_t> r(MachineType::Int64(), MachineType::Int64()); |
378 BUILD(r, WASM_I64_SAR(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | 378 BUILD(r, WASM_I64_SAR(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
379 | 379 |
380 FOR_INT64_INPUTS(i) { | 380 FOR_INT64_INPUTS(i) { |
381 FOR_INT64_INPUTS(j) { | 381 FOR_INT64_INPUTS(j) { |
382 int64_t expected = (*i) >> (*j & 0x3f); | 382 int64_t expected = (*i) >> (*j & 0x3f); |
383 CHECK_EQ(expected, r.Call(*i, *j)); | 383 CHECK_EQ(expected, r.Call(*i, *j)); |
384 } | 384 } |
(...skipping 14 matching lines...) Expand all Loading... |
399 BUILD(r, WASM_I64_SAR(WASM_GET_LOCAL(0), WASM_I64V_1(20))); | 399 BUILD(r, WASM_I64_SAR(WASM_GET_LOCAL(0), WASM_I64V_1(20))); |
400 FOR_INT64_INPUTS(i) { CHECK_EQ(*i >> 20, r.Call(*i)); } | 400 FOR_INT64_INPUTS(i) { CHECK_EQ(*i >> 20, r.Call(*i)); } |
401 } | 401 } |
402 { | 402 { |
403 WasmRunner<int64_t> r(MachineType::Int64()); | 403 WasmRunner<int64_t> r(MachineType::Int64()); |
404 BUILD(r, WASM_I64_SAR(WASM_GET_LOCAL(0), WASM_I64V_1(40))); | 404 BUILD(r, WASM_I64_SAR(WASM_GET_LOCAL(0), WASM_I64V_1(40))); |
405 FOR_INT64_INPUTS(i) { CHECK_EQ(*i >> 40, r.Call(*i)); } | 405 FOR_INT64_INPUTS(i) { CHECK_EQ(*i >> 40, r.Call(*i)); } |
406 } | 406 } |
407 } | 407 } |
408 | 408 |
409 TEST(Run_Wasm_I64Eq) { | 409 WASM_EXEC_TEST(I64Eq) { |
410 REQUIRE(I64Eq); | 410 REQUIRE(I64Eq); |
411 WasmRunner<int32_t> r(MachineType::Int64(), MachineType::Int64()); | 411 WasmRunner<int32_t> r(MachineType::Int64(), MachineType::Int64()); |
412 BUILD(r, WASM_I64_EQ(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | 412 BUILD(r, WASM_I64_EQ(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
413 FOR_INT64_INPUTS(i) { | 413 FOR_INT64_INPUTS(i) { |
414 FOR_INT64_INPUTS(j) { CHECK_EQ(*i == *j ? 1 : 0, r.Call(*i, *j)); } | 414 FOR_INT64_INPUTS(j) { CHECK_EQ(*i == *j ? 1 : 0, r.Call(*i, *j)); } |
415 } | 415 } |
416 } | 416 } |
417 | 417 |
418 TEST(Run_Wasm_I64Ne) { | 418 WASM_EXEC_TEST(I64Ne) { |
419 REQUIRE(I64Ne); | 419 REQUIRE(I64Ne); |
420 WasmRunner<int32_t> r(MachineType::Int64(), MachineType::Int64()); | 420 WasmRunner<int32_t> r(MachineType::Int64(), MachineType::Int64()); |
421 BUILD(r, WASM_I64_NE(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | 421 BUILD(r, WASM_I64_NE(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
422 FOR_INT64_INPUTS(i) { | 422 FOR_INT64_INPUTS(i) { |
423 FOR_INT64_INPUTS(j) { CHECK_EQ(*i != *j ? 1 : 0, r.Call(*i, *j)); } | 423 FOR_INT64_INPUTS(j) { CHECK_EQ(*i != *j ? 1 : 0, r.Call(*i, *j)); } |
424 } | 424 } |
425 } | 425 } |
426 | 426 |
427 TEST(Run_Wasm_I64LtS) { | 427 WASM_EXEC_TEST(I64LtS) { |
428 REQUIRE(I64LtS); | 428 REQUIRE(I64LtS); |
429 WasmRunner<int32_t> r(MachineType::Int64(), MachineType::Int64()); | 429 WasmRunner<int32_t> r(MachineType::Int64(), MachineType::Int64()); |
430 BUILD(r, WASM_I64_LTS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | 430 BUILD(r, WASM_I64_LTS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
431 FOR_INT64_INPUTS(i) { | 431 FOR_INT64_INPUTS(i) { |
432 FOR_INT64_INPUTS(j) { CHECK_EQ(*i < *j ? 1 : 0, r.Call(*i, *j)); } | 432 FOR_INT64_INPUTS(j) { CHECK_EQ(*i < *j ? 1 : 0, r.Call(*i, *j)); } |
433 } | 433 } |
434 } | 434 } |
435 | 435 |
436 TEST(Run_Wasm_I64LeS) { | 436 WASM_EXEC_TEST(I64LeS) { |
437 REQUIRE(I64LeS); | 437 REQUIRE(I64LeS); |
438 WasmRunner<int32_t> r(MachineType::Int64(), MachineType::Int64()); | 438 WasmRunner<int32_t> r(MachineType::Int64(), MachineType::Int64()); |
439 BUILD(r, WASM_I64_LES(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | 439 BUILD(r, WASM_I64_LES(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
440 FOR_INT64_INPUTS(i) { | 440 FOR_INT64_INPUTS(i) { |
441 FOR_INT64_INPUTS(j) { CHECK_EQ(*i <= *j ? 1 : 0, r.Call(*i, *j)); } | 441 FOR_INT64_INPUTS(j) { CHECK_EQ(*i <= *j ? 1 : 0, r.Call(*i, *j)); } |
442 } | 442 } |
443 } | 443 } |
444 | 444 |
445 TEST(Run_Wasm_I64LtU) { | 445 WASM_EXEC_TEST(I64LtU) { |
446 REQUIRE(I64LtU); | 446 REQUIRE(I64LtU); |
447 WasmRunner<int32_t> r(MachineType::Int64(), MachineType::Int64()); | 447 WasmRunner<int32_t> r(MachineType::Int64(), MachineType::Int64()); |
448 BUILD(r, WASM_I64_LTU(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | 448 BUILD(r, WASM_I64_LTU(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
449 FOR_UINT64_INPUTS(i) { | 449 FOR_UINT64_INPUTS(i) { |
450 FOR_UINT64_INPUTS(j) { CHECK_EQ(*i < *j ? 1 : 0, r.Call(*i, *j)); } | 450 FOR_UINT64_INPUTS(j) { CHECK_EQ(*i < *j ? 1 : 0, r.Call(*i, *j)); } |
451 } | 451 } |
452 } | 452 } |
453 | 453 |
454 TEST(Run_Wasm_I64LeU) { | 454 WASM_EXEC_TEST(I64LeU) { |
455 REQUIRE(I64LeU); | 455 REQUIRE(I64LeU); |
456 WasmRunner<int32_t> r(MachineType::Int64(), MachineType::Int64()); | 456 WasmRunner<int32_t> r(MachineType::Int64(), MachineType::Int64()); |
457 BUILD(r, WASM_I64_LEU(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | 457 BUILD(r, WASM_I64_LEU(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
458 FOR_UINT64_INPUTS(i) { | 458 FOR_UINT64_INPUTS(i) { |
459 FOR_UINT64_INPUTS(j) { CHECK_EQ(*i <= *j ? 1 : 0, r.Call(*i, *j)); } | 459 FOR_UINT64_INPUTS(j) { CHECK_EQ(*i <= *j ? 1 : 0, r.Call(*i, *j)); } |
460 } | 460 } |
461 } | 461 } |
462 | 462 |
463 TEST(Run_Wasm_I64GtS) { | 463 WASM_EXEC_TEST(I64GtS) { |
464 REQUIRE(I64GtS); | 464 REQUIRE(I64GtS); |
465 WasmRunner<int32_t> r(MachineType::Int64(), MachineType::Int64()); | 465 WasmRunner<int32_t> r(MachineType::Int64(), MachineType::Int64()); |
466 BUILD(r, WASM_I64_GTS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | 466 BUILD(r, WASM_I64_GTS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
467 FOR_INT64_INPUTS(i) { | 467 FOR_INT64_INPUTS(i) { |
468 FOR_INT64_INPUTS(j) { CHECK_EQ(*i > *j ? 1 : 0, r.Call(*i, *j)); } | 468 FOR_INT64_INPUTS(j) { CHECK_EQ(*i > *j ? 1 : 0, r.Call(*i, *j)); } |
469 } | 469 } |
470 } | 470 } |
471 | 471 |
472 TEST(Run_Wasm_I64GeS) { | 472 WASM_EXEC_TEST(I64GeS) { |
473 REQUIRE(I64GeS); | 473 REQUIRE(I64GeS); |
474 WasmRunner<int32_t> r(MachineType::Int64(), MachineType::Int64()); | 474 WasmRunner<int32_t> r(MachineType::Int64(), MachineType::Int64()); |
475 BUILD(r, WASM_I64_GES(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | 475 BUILD(r, WASM_I64_GES(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
476 FOR_INT64_INPUTS(i) { | 476 FOR_INT64_INPUTS(i) { |
477 FOR_INT64_INPUTS(j) { CHECK_EQ(*i >= *j ? 1 : 0, r.Call(*i, *j)); } | 477 FOR_INT64_INPUTS(j) { CHECK_EQ(*i >= *j ? 1 : 0, r.Call(*i, *j)); } |
478 } | 478 } |
479 } | 479 } |
480 | 480 |
481 TEST(Run_Wasm_I64GtU) { | 481 WASM_EXEC_TEST(I64GtU) { |
482 REQUIRE(I64GtU); | 482 REQUIRE(I64GtU); |
483 WasmRunner<int32_t> r(MachineType::Int64(), MachineType::Int64()); | 483 WasmRunner<int32_t> r(MachineType::Int64(), MachineType::Int64()); |
484 BUILD(r, WASM_I64_GTU(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | 484 BUILD(r, WASM_I64_GTU(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
485 FOR_UINT64_INPUTS(i) { | 485 FOR_UINT64_INPUTS(i) { |
486 FOR_UINT64_INPUTS(j) { CHECK_EQ(*i > *j ? 1 : 0, r.Call(*i, *j)); } | 486 FOR_UINT64_INPUTS(j) { CHECK_EQ(*i > *j ? 1 : 0, r.Call(*i, *j)); } |
487 } | 487 } |
488 } | 488 } |
489 | 489 |
490 TEST(Run_Wasm_I64GeU) { | 490 WASM_EXEC_TEST(I64GeU) { |
491 REQUIRE(I64GeU); | 491 REQUIRE(I64GeU); |
492 WasmRunner<int32_t> r(MachineType::Int64(), MachineType::Int64()); | 492 WasmRunner<int32_t> r(MachineType::Int64(), MachineType::Int64()); |
493 BUILD(r, WASM_I64_GEU(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | 493 BUILD(r, WASM_I64_GEU(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
494 FOR_UINT64_INPUTS(i) { | 494 FOR_UINT64_INPUTS(i) { |
495 FOR_UINT64_INPUTS(j) { CHECK_EQ(*i >= *j ? 1 : 0, r.Call(*i, *j)); } | 495 FOR_UINT64_INPUTS(j) { CHECK_EQ(*i >= *j ? 1 : 0, r.Call(*i, *j)); } |
496 } | 496 } |
497 } | 497 } |
498 | 498 |
499 TEST(Run_Wasm_I32ConvertI64) { | 499 WASM_EXEC_TEST(I32ConvertI64) { |
500 REQUIRE(I32ConvertI64); | 500 REQUIRE(I32ConvertI64); |
501 FOR_INT64_INPUTS(i) { | 501 FOR_INT64_INPUTS(i) { |
502 WasmRunner<int32_t> r; | 502 WasmRunner<int32_t> r; |
503 BUILD(r, WASM_I32_CONVERT_I64(WASM_I64V(*i))); | 503 BUILD(r, WASM_I32_CONVERT_I64(WASM_I64V(*i))); |
504 CHECK_EQ(static_cast<int32_t>(*i), r.Call()); | 504 CHECK_EQ(static_cast<int32_t>(*i), r.Call()); |
505 } | 505 } |
506 } | 506 } |
507 | 507 |
508 TEST(Run_Wasm_I64SConvertI32) { | 508 WASM_EXEC_TEST(I64SConvertI32) { |
509 REQUIRE(I64SConvertI32); | 509 REQUIRE(I64SConvertI32); |
510 WasmRunner<int64_t> r(MachineType::Int32()); | 510 WasmRunner<int64_t> r(MachineType::Int32()); |
511 BUILD(r, WASM_I64_SCONVERT_I32(WASM_GET_LOCAL(0))); | 511 BUILD(r, WASM_I64_SCONVERT_I32(WASM_GET_LOCAL(0))); |
512 FOR_INT32_INPUTS(i) { CHECK_EQ(static_cast<int64_t>(*i), r.Call(*i)); } | 512 FOR_INT32_INPUTS(i) { CHECK_EQ(static_cast<int64_t>(*i), r.Call(*i)); } |
513 } | 513 } |
514 | 514 |
515 TEST(Run_Wasm_I64UConvertI32) { | 515 WASM_EXEC_TEST(I64UConvertI32) { |
516 REQUIRE(I64UConvertI32); | 516 REQUIRE(I64UConvertI32); |
517 WasmRunner<int64_t> r(MachineType::Uint32()); | 517 WasmRunner<int64_t> r(MachineType::Uint32()); |
518 BUILD(r, WASM_I64_UCONVERT_I32(WASM_GET_LOCAL(0))); | 518 BUILD(r, WASM_I64_UCONVERT_I32(WASM_GET_LOCAL(0))); |
519 FOR_UINT32_INPUTS(i) { CHECK_EQ(static_cast<uint64_t>(*i), r.Call(*i)); } | 519 FOR_UINT32_INPUTS(i) { CHECK_EQ(static_cast<uint64_t>(*i), r.Call(*i)); } |
520 } | 520 } |
521 | 521 |
522 TEST(Run_WasmI64Popcnt) { | 522 WASM_EXEC_TEST(I64Popcnt) { |
523 struct { | 523 struct { |
524 int64_t expected; | 524 int64_t expected; |
525 uint64_t input; | 525 uint64_t input; |
526 } values[] = {{64, 0xffffffffffffffff}, | 526 } values[] = {{64, 0xffffffffffffffff}, |
527 {0, 0x0000000000000000}, | 527 {0, 0x0000000000000000}, |
528 {2, 0x0000080000008000}, | 528 {2, 0x0000080000008000}, |
529 {26, 0x1123456782345678}, | 529 {26, 0x1123456782345678}, |
530 {38, 0xffedcba09edcba09}}; | 530 {38, 0xffedcba09edcba09}}; |
531 | 531 |
532 WasmRunner<int64_t> r(MachineType::Uint64()); | 532 WasmRunner<int64_t> r(MachineType::Uint64()); |
533 BUILD(r, WASM_I64_POPCNT(WASM_GET_LOCAL(0))); | 533 BUILD(r, WASM_I64_POPCNT(WASM_GET_LOCAL(0))); |
534 for (size_t i = 0; i < arraysize(values); i++) { | 534 for (size_t i = 0; i < arraysize(values); i++) { |
535 CHECK_EQ(values[i].expected, r.Call(values[i].input)); | 535 CHECK_EQ(values[i].expected, r.Call(values[i].input)); |
536 } | 536 } |
537 } | 537 } |
538 | 538 |
539 TEST(Run_WasmF32SConvertI64) { | 539 WASM_EXEC_TEST(F32SConvertI64) { |
540 REQUIRE(F32SConvertI64); | 540 REQUIRE(F32SConvertI64); |
541 WasmRunner<float> r(MachineType::Int64()); | 541 WasmRunner<float> r(MachineType::Int64()); |
542 BUILD(r, WASM_F32_SCONVERT_I64(WASM_GET_LOCAL(0))); | 542 BUILD(r, WASM_F32_SCONVERT_I64(WASM_GET_LOCAL(0))); |
543 FOR_INT64_INPUTS(i) { CHECK_FLOAT_EQ(static_cast<float>(*i), r.Call(*i)); } | 543 FOR_INT64_INPUTS(i) { CHECK_FLOAT_EQ(static_cast<float>(*i), r.Call(*i)); } |
544 } | 544 } |
545 | 545 |
546 TEST(Run_WasmF32UConvertI64) { | 546 WASM_EXEC_TEST(F32UConvertI64) { |
547 REQUIRE(F32UConvertI64); | 547 REQUIRE(F32UConvertI64); |
548 struct { | 548 struct { |
549 uint64_t input; | 549 uint64_t input; |
550 uint32_t expected; | 550 uint32_t expected; |
551 } values[] = {{0x0, 0x0}, | 551 } values[] = {{0x0, 0x0}, |
552 {0x1, 0x3f800000}, | 552 {0x1, 0x3f800000}, |
553 {0xffffffff, 0x4f800000}, | 553 {0xffffffff, 0x4f800000}, |
554 {0x1b09788b, 0x4dd84bc4}, | 554 {0x1b09788b, 0x4dd84bc4}, |
555 {0x4c5fce8, 0x4c98bf9d}, | 555 {0x4c5fce8, 0x4c98bf9d}, |
556 {0xcc0de5bf, 0x4f4c0de6}, | 556 {0xcc0de5bf, 0x4f4c0de6}, |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
624 {0x8000008000000001, 0x5f000001}, | 624 {0x8000008000000001, 0x5f000001}, |
625 {0x8000000000000400, 0x5f000000}, | 625 {0x8000000000000400, 0x5f000000}, |
626 {0x8000000000000401, 0x5f000000}}; | 626 {0x8000000000000401, 0x5f000000}}; |
627 WasmRunner<float> r(MachineType::Uint64()); | 627 WasmRunner<float> r(MachineType::Uint64()); |
628 BUILD(r, WASM_F32_UCONVERT_I64(WASM_GET_LOCAL(0))); | 628 BUILD(r, WASM_F32_UCONVERT_I64(WASM_GET_LOCAL(0))); |
629 for (size_t i = 0; i < arraysize(values); i++) { | 629 for (size_t i = 0; i < arraysize(values); i++) { |
630 CHECK_EQ(bit_cast<float>(values[i].expected), r.Call(values[i].input)); | 630 CHECK_EQ(bit_cast<float>(values[i].expected), r.Call(values[i].input)); |
631 } | 631 } |
632 } | 632 } |
633 | 633 |
634 TEST(Run_WasmF64SConvertI64) { | 634 WASM_EXEC_TEST(F64SConvertI64) { |
635 REQUIRE(F64SConvertI64); | 635 REQUIRE(F64SConvertI64); |
636 WasmRunner<double> r(MachineType::Int64()); | 636 WasmRunner<double> r(MachineType::Int64()); |
637 BUILD(r, WASM_F64_SCONVERT_I64(WASM_GET_LOCAL(0))); | 637 BUILD(r, WASM_F64_SCONVERT_I64(WASM_GET_LOCAL(0))); |
638 FOR_INT64_INPUTS(i) { CHECK_DOUBLE_EQ(static_cast<double>(*i), r.Call(*i)); } | 638 FOR_INT64_INPUTS(i) { CHECK_DOUBLE_EQ(static_cast<double>(*i), r.Call(*i)); } |
639 } | 639 } |
640 | 640 |
641 TEST(Run_Wasm_F64UConvertI64) { | 641 WASM_EXEC_TEST(F64UConvertI64) { |
642 REQUIRE(F64UConvertI64); | 642 REQUIRE(F64UConvertI64); |
643 struct { | 643 struct { |
644 uint64_t input; | 644 uint64_t input; |
645 uint64_t expected; | 645 uint64_t expected; |
646 } values[] = {{0x0, 0x0}, | 646 } values[] = {{0x0, 0x0}, |
647 {0x1, 0x3ff0000000000000}, | 647 {0x1, 0x3ff0000000000000}, |
648 {0xffffffff, 0x41efffffffe00000}, | 648 {0xffffffff, 0x41efffffffe00000}, |
649 {0x1b09788b, 0x41bb09788b000000}, | 649 {0x1b09788b, 0x41bb09788b000000}, |
650 {0x4c5fce8, 0x419317f3a0000000}, | 650 {0x4c5fce8, 0x419317f3a0000000}, |
651 {0xcc0de5bf, 0x41e981bcb7e00000}, | 651 {0xcc0de5bf, 0x41e981bcb7e00000}, |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
718 {0x8000008000000001, 0x43e0000010000000}, | 718 {0x8000008000000001, 0x43e0000010000000}, |
719 {0x8000000000000400, 0x43e0000000000000}, | 719 {0x8000000000000400, 0x43e0000000000000}, |
720 {0x8000000000000401, 0x43e0000000000001}}; | 720 {0x8000000000000401, 0x43e0000000000001}}; |
721 WasmRunner<double> r(MachineType::Uint64()); | 721 WasmRunner<double> r(MachineType::Uint64()); |
722 BUILD(r, WASM_F64_UCONVERT_I64(WASM_GET_LOCAL(0))); | 722 BUILD(r, WASM_F64_UCONVERT_I64(WASM_GET_LOCAL(0))); |
723 for (size_t i = 0; i < arraysize(values); i++) { | 723 for (size_t i = 0; i < arraysize(values); i++) { |
724 CHECK_EQ(bit_cast<double>(values[i].expected), r.Call(values[i].input)); | 724 CHECK_EQ(bit_cast<double>(values[i].expected), r.Call(values[i].input)); |
725 } | 725 } |
726 } | 726 } |
727 | 727 |
728 TEST(Run_Wasm_I64SConvertF32a) { | 728 WASM_EXEC_TEST(I64SConvertF32a) { |
729 WasmRunner<int64_t> r(MachineType::Float32()); | 729 WasmRunner<int64_t> r(MachineType::Float32()); |
730 BUILD(r, WASM_I64_SCONVERT_F32(WASM_GET_LOCAL(0))); | 730 BUILD(r, WASM_I64_SCONVERT_F32(WASM_GET_LOCAL(0))); |
731 | 731 |
732 FOR_FLOAT32_INPUTS(i) { | 732 FOR_FLOAT32_INPUTS(i) { |
733 if (*i < static_cast<float>(std::numeric_limits<int64_t>::max()) && | 733 if (*i < static_cast<float>(std::numeric_limits<int64_t>::max()) && |
734 *i >= static_cast<float>(std::numeric_limits<int64_t>::min())) { | 734 *i >= static_cast<float>(std::numeric_limits<int64_t>::min())) { |
735 CHECK_EQ(static_cast<int64_t>(*i), r.Call(*i)); | 735 CHECK_EQ(static_cast<int64_t>(*i), r.Call(*i)); |
736 } else { | 736 } else { |
737 CHECK_TRAP64(r.Call(*i)); | 737 CHECK_TRAP64(r.Call(*i)); |
738 } | 738 } |
739 } | 739 } |
740 } | 740 } |
741 | 741 |
742 TEST(Run_Wasm_I64SConvertF64a) { | 742 WASM_EXEC_TEST(I64SConvertF64a) { |
743 WasmRunner<int64_t> r(MachineType::Float64()); | 743 WasmRunner<int64_t> r(MachineType::Float64()); |
744 BUILD(r, WASM_I64_SCONVERT_F64(WASM_GET_LOCAL(0))); | 744 BUILD(r, WASM_I64_SCONVERT_F64(WASM_GET_LOCAL(0))); |
745 | 745 |
746 FOR_FLOAT64_INPUTS(i) { | 746 FOR_FLOAT64_INPUTS(i) { |
747 if (*i < static_cast<double>(std::numeric_limits<int64_t>::max()) && | 747 if (*i < static_cast<double>(std::numeric_limits<int64_t>::max()) && |
748 *i >= static_cast<double>(std::numeric_limits<int64_t>::min())) { | 748 *i >= static_cast<double>(std::numeric_limits<int64_t>::min())) { |
749 CHECK_EQ(static_cast<int64_t>(*i), r.Call(*i)); | 749 CHECK_EQ(static_cast<int64_t>(*i), r.Call(*i)); |
750 } else { | 750 } else { |
751 CHECK_TRAP64(r.Call(*i)); | 751 CHECK_TRAP64(r.Call(*i)); |
752 } | 752 } |
753 } | 753 } |
754 } | 754 } |
755 | 755 |
756 TEST(Run_Wasm_I64UConvertF32a) { | 756 WASM_EXEC_TEST(I64UConvertF32a) { |
757 WasmRunner<uint64_t> r(MachineType::Float32()); | 757 WasmRunner<uint64_t> r(MachineType::Float32()); |
758 BUILD(r, WASM_I64_UCONVERT_F32(WASM_GET_LOCAL(0))); | 758 BUILD(r, WASM_I64_UCONVERT_F32(WASM_GET_LOCAL(0))); |
759 | 759 |
760 FOR_FLOAT32_INPUTS(i) { | 760 FOR_FLOAT32_INPUTS(i) { |
761 if (*i < static_cast<float>(std::numeric_limits<uint64_t>::max()) && | 761 if (*i < static_cast<float>(std::numeric_limits<uint64_t>::max()) && |
762 *i > -1) { | 762 *i > -1) { |
763 CHECK_EQ(static_cast<uint64_t>(*i), r.Call(*i)); | 763 CHECK_EQ(static_cast<uint64_t>(*i), r.Call(*i)); |
764 } else { | 764 } else { |
765 CHECK_TRAP64(r.Call(*i)); | 765 CHECK_TRAP64(r.Call(*i)); |
766 } | 766 } |
767 } | 767 } |
768 } | 768 } |
769 | 769 |
770 TEST(Run_Wasm_I64UConvertF64a) { | 770 WASM_EXEC_TEST(I64UConvertF64a) { |
771 WasmRunner<uint64_t> r(MachineType::Float64()); | 771 WasmRunner<uint64_t> r(MachineType::Float64()); |
772 BUILD(r, WASM_I64_UCONVERT_F64(WASM_GET_LOCAL(0))); | 772 BUILD(r, WASM_I64_UCONVERT_F64(WASM_GET_LOCAL(0))); |
773 | 773 |
774 FOR_FLOAT64_INPUTS(i) { | 774 FOR_FLOAT64_INPUTS(i) { |
775 if (*i < static_cast<float>(std::numeric_limits<uint64_t>::max()) && | 775 if (*i < static_cast<float>(std::numeric_limits<uint64_t>::max()) && |
776 *i > -1) { | 776 *i > -1) { |
777 CHECK_EQ(static_cast<uint64_t>(*i), r.Call(*i)); | 777 CHECK_EQ(static_cast<uint64_t>(*i), r.Call(*i)); |
778 } else { | 778 } else { |
779 CHECK_TRAP64(r.Call(*i)); | 779 CHECK_TRAP64(r.Call(*i)); |
780 } | 780 } |
781 } | 781 } |
782 } | 782 } |
783 | 783 |
784 TEST(Run_WasmCallI64Parameter) { | 784 WASM_EXEC_TEST(CallI64Parameter) { |
785 // Build the target function. | 785 // Build the target function. |
786 LocalType param_types[20]; | 786 LocalType param_types[20]; |
787 for (int i = 0; i < 20; i++) param_types[i] = kAstI64; | 787 for (int i = 0; i < 20; i++) param_types[i] = kAstI64; |
788 param_types[3] = kAstI32; | 788 param_types[3] = kAstI32; |
789 param_types[4] = kAstI32; | 789 param_types[4] = kAstI32; |
790 FunctionSig sig(1, 19, param_types); | 790 FunctionSig sig(1, 19, param_types); |
791 for (int i = 0; i < 19; i++) { | 791 for (int i = 0; i < 19; i++) { |
792 TestingModule module; | 792 TestingModule module; |
793 WasmFunctionCompiler t(&sig, &module); | 793 WasmFunctionCompiler t(&sig, &module); |
794 if (i == 2 || i == 3) { | 794 if (i == 2 || i == 3) { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
848 CHECK_EQ(expected, r.Call(a, b)); | 848 CHECK_EQ(expected, r.Call(a, b)); |
849 } | 849 } |
850 } | 850 } |
851 | 851 |
852 #define TEST_I64_BINOP(name, expected, a, b) \ | 852 #define TEST_I64_BINOP(name, expected, a, b) \ |
853 do { \ | 853 do { \ |
854 if (WASM_64 || kSupported_##name) \ | 854 if (WASM_64 || kSupported_##name) \ |
855 TestI64Binop(kExpr##name, expected, a, b); \ | 855 TestI64Binop(kExpr##name, expected, a, b); \ |
856 } while (false) | 856 } while (false) |
857 | 857 |
858 TEST(Run_Wasm_I64Binops) { | 858 WASM_EXEC_TEST(I64Binops) { |
859 TEST_I64_BINOP(I64Add, -5586332274295447011, 0x501b72ebabc26847, | 859 TEST_I64_BINOP(I64Add, -5586332274295447011, 0x501b72ebabc26847, |
860 0x625de9793d8f79d6); | 860 0x625de9793d8f79d6); |
861 TEST_I64_BINOP(I64Sub, 9001903251710731490, 0xf24fe6474640002e, | 861 TEST_I64_BINOP(I64Sub, 9001903251710731490, 0xf24fe6474640002e, |
862 0x7562b6f711991b4c); | 862 0x7562b6f711991b4c); |
863 TEST_I64_BINOP(I64Mul, -4569547818546064176, 0x231a263c2cbc6451, | 863 TEST_I64_BINOP(I64Mul, -4569547818546064176, 0x231a263c2cbc6451, |
864 0xead44de6bd3e23d0); | 864 0xead44de6bd3e23d0); |
865 TEST_I64_BINOP(I64Mul, -25963122347507043, 0x4da1fa47c9352b73, | 865 TEST_I64_BINOP(I64Mul, -25963122347507043, 0x4da1fa47c9352b73, |
866 0x91fe82317aa035af); | 866 0x91fe82317aa035af); |
867 TEST_I64_BINOP(I64Mul, 7640290486138131960, 0x185731abe8eea47c, | 867 TEST_I64_BINOP(I64Mul, 7640290486138131960, 0x185731abe8eea47c, |
868 0x714ec59f1380d4c2); | 868 0x714ec59f1380d4c2); |
(...skipping 16 matching lines...) Expand all Loading... |
885 TEST_I64_BINOP(I64Ror, 7617662827409989779, 0xebff67cf0c126d36, 13); | 885 TEST_I64_BINOP(I64Ror, 7617662827409989779, 0xebff67cf0c126d36, 13); |
886 TEST_I64_BINOP(I64Rol, -2097714064174346012, 0x43938b8db0b0f230, 14); | 886 TEST_I64_BINOP(I64Rol, -2097714064174346012, 0x43938b8db0b0f230, 14); |
887 TEST_I64_BINOP(I64Rol, 8728493013947314237, 0xe07af243ac4d219d, 15); | 887 TEST_I64_BINOP(I64Rol, 8728493013947314237, 0xe07af243ac4d219d, 15); |
888 } | 888 } |
889 | 889 |
890 #define TEST_I64_CMP(name, expected, a, b) \ | 890 #define TEST_I64_CMP(name, expected, a, b) \ |
891 do { \ | 891 do { \ |
892 if (WASM_64 || kSupported_##name) TestI64Cmp(kExpr##name, expected, a, b); \ | 892 if (WASM_64 || kSupported_##name) TestI64Cmp(kExpr##name, expected, a, b); \ |
893 } while (false) | 893 } while (false) |
894 | 894 |
895 TEST(Run_Wasm_I64Compare) { | 895 WASM_EXEC_TEST(I64Compare) { |
896 TEST_I64_CMP(I64Eq, 0, 0xB915D8FA494064F0, 0x04D700B2536019A3); | 896 TEST_I64_CMP(I64Eq, 0, 0xB915D8FA494064F0, 0x04D700B2536019A3); |
897 TEST_I64_CMP(I64Ne, 1, 0xC2FAFAAAB0446CDC, 0x52A3328F780C97A3); | 897 TEST_I64_CMP(I64Ne, 1, 0xC2FAFAAAB0446CDC, 0x52A3328F780C97A3); |
898 TEST_I64_CMP(I64LtS, 0, 0x673636E6306B0578, 0x028EC9ECA78F7227); | 898 TEST_I64_CMP(I64LtS, 0, 0x673636E6306B0578, 0x028EC9ECA78F7227); |
899 TEST_I64_CMP(I64LeS, 1, 0xAE5214114B86A0FA, 0x7C1D21DA3DFD0CCF); | 899 TEST_I64_CMP(I64LeS, 1, 0xAE5214114B86A0FA, 0x7C1D21DA3DFD0CCF); |
900 TEST_I64_CMP(I64LtU, 0, 0x7D52166381EC1CE0, 0x59F4A6A9E78CD3D8); | 900 TEST_I64_CMP(I64LtU, 0, 0x7D52166381EC1CE0, 0x59F4A6A9E78CD3D8); |
901 TEST_I64_CMP(I64LeU, 1, 0xE4169A385C7EA0E0, 0xFBDBED2C8781E5BC); | 901 TEST_I64_CMP(I64LeU, 1, 0xE4169A385C7EA0E0, 0xFBDBED2C8781E5BC); |
902 TEST_I64_CMP(I64GtS, 0, 0x9D08FF8FB5F42E81, 0xD4E5C9D7FE09F621); | 902 TEST_I64_CMP(I64GtS, 0, 0x9D08FF8FB5F42E81, 0xD4E5C9D7FE09F621); |
903 TEST_I64_CMP(I64GeS, 1, 0x78DA3B2F73264E0F, 0x6FE5E2A67C501CBE); | 903 TEST_I64_CMP(I64GeS, 1, 0x78DA3B2F73264E0F, 0x6FE5E2A67C501CBE); |
904 TEST_I64_CMP(I64GtU, 0, 0x8F691284E44F7DA9, 0xD5EA9BC1EE149192); | 904 TEST_I64_CMP(I64GtU, 0, 0x8F691284E44F7DA9, 0xD5EA9BC1EE149192); |
905 TEST_I64_CMP(I64GeU, 0, 0x0886A0C58C7AA224, 0x5DDBE5A81FD7EE47); | 905 TEST_I64_CMP(I64GeU, 0, 0x0886A0C58C7AA224, 0x5DDBE5A81FD7EE47); |
906 } | 906 } |
907 | 907 |
908 TEST(Run_Wasm_I64Clz) { | 908 WASM_EXEC_TEST(I64Clz) { |
909 REQUIRE(I64Clz); | 909 REQUIRE(I64Clz); |
910 struct { | 910 struct { |
911 int64_t expected; | 911 int64_t expected; |
912 uint64_t input; | 912 uint64_t input; |
913 } values[] = {{0, 0x8000100000000000}, {1, 0x4000050000000000}, | 913 } values[] = {{0, 0x8000100000000000}, {1, 0x4000050000000000}, |
914 {2, 0x2000030000000000}, {3, 0x1000000300000000}, | 914 {2, 0x2000030000000000}, {3, 0x1000000300000000}, |
915 {4, 0x0805000000000000}, {5, 0x0400600000000000}, | 915 {4, 0x0805000000000000}, {5, 0x0400600000000000}, |
916 {6, 0x0200000000000000}, {7, 0x010000a000000000}, | 916 {6, 0x0200000000000000}, {7, 0x010000a000000000}, |
917 {8, 0x00800c0000000000}, {9, 0x0040000000000000}, | 917 {8, 0x00800c0000000000}, {9, 0x0040000000000000}, |
918 {10, 0x0020000d00000000}, {11, 0x00100f0000000000}, | 918 {10, 0x0020000d00000000}, {11, 0x00100f0000000000}, |
(...skipping 25 matching lines...) Expand all Loading... |
944 {62, 0x0000000000000002}, {63, 0x0000000000000001}, | 944 {62, 0x0000000000000002}, {63, 0x0000000000000001}, |
945 {64, 0x0000000000000000}}; | 945 {64, 0x0000000000000000}}; |
946 | 946 |
947 WasmRunner<int64_t> r(MachineType::Uint64()); | 947 WasmRunner<int64_t> r(MachineType::Uint64()); |
948 BUILD(r, WASM_I64_CLZ(WASM_GET_LOCAL(0))); | 948 BUILD(r, WASM_I64_CLZ(WASM_GET_LOCAL(0))); |
949 for (size_t i = 0; i < arraysize(values); i++) { | 949 for (size_t i = 0; i < arraysize(values); i++) { |
950 CHECK_EQ(values[i].expected, r.Call(values[i].input)); | 950 CHECK_EQ(values[i].expected, r.Call(values[i].input)); |
951 } | 951 } |
952 } | 952 } |
953 | 953 |
954 TEST(Run_Wasm_I64Ctz) { | 954 WASM_EXEC_TEST(I64Ctz) { |
955 REQUIRE(I64Ctz); | 955 REQUIRE(I64Ctz); |
956 struct { | 956 struct { |
957 int64_t expected; | 957 int64_t expected; |
958 uint64_t input; | 958 uint64_t input; |
959 } values[] = {{64, 0x0000000000000000}, {63, 0x8000000000000000}, | 959 } values[] = {{64, 0x0000000000000000}, {63, 0x8000000000000000}, |
960 {62, 0x4000000000000000}, {61, 0x2000000000000000}, | 960 {62, 0x4000000000000000}, {61, 0x2000000000000000}, |
961 {60, 0x1000000000000000}, {59, 0xa800000000000000}, | 961 {60, 0x1000000000000000}, {59, 0xa800000000000000}, |
962 {58, 0xf400000000000000}, {57, 0x6200000000000000}, | 962 {58, 0xf400000000000000}, {57, 0x6200000000000000}, |
963 {56, 0x9100000000000000}, {55, 0xcd80000000000000}, | 963 {56, 0x9100000000000000}, {55, 0xcd80000000000000}, |
964 {54, 0x0940000000000000}, {53, 0xaf20000000000000}, | 964 {54, 0x0940000000000000}, {53, 0xaf20000000000000}, |
(...skipping 25 matching lines...) Expand all Loading... |
990 {2, 0x000000009afdbc84}, {1, 0x000000009afdbc82}, | 990 {2, 0x000000009afdbc84}, {1, 0x000000009afdbc82}, |
991 {0, 0x000000009afdbc81}}; | 991 {0, 0x000000009afdbc81}}; |
992 | 992 |
993 WasmRunner<int64_t> r(MachineType::Uint64()); | 993 WasmRunner<int64_t> r(MachineType::Uint64()); |
994 BUILD(r, WASM_I64_CTZ(WASM_GET_LOCAL(0))); | 994 BUILD(r, WASM_I64_CTZ(WASM_GET_LOCAL(0))); |
995 for (size_t i = 0; i < arraysize(values); i++) { | 995 for (size_t i = 0; i < arraysize(values); i++) { |
996 CHECK_EQ(values[i].expected, r.Call(values[i].input)); | 996 CHECK_EQ(values[i].expected, r.Call(values[i].input)); |
997 } | 997 } |
998 } | 998 } |
999 | 999 |
1000 TEST(Run_Wasm_I64Popcnt) { | 1000 WASM_EXEC_TEST(I64Popcnt2) { |
1001 REQUIRE(I64Popcnt); | 1001 REQUIRE(I64Popcnt); |
1002 struct { | 1002 struct { |
1003 int64_t expected; | 1003 int64_t expected; |
1004 uint64_t input; | 1004 uint64_t input; |
1005 } values[] = {{64, 0xffffffffffffffff}, | 1005 } values[] = {{64, 0xffffffffffffffff}, |
1006 {0, 0x0000000000000000}, | 1006 {0, 0x0000000000000000}, |
1007 {2, 0x0000080000008000}, | 1007 {2, 0x0000080000008000}, |
1008 {26, 0x1123456782345678}, | 1008 {26, 0x1123456782345678}, |
1009 {38, 0xffedcba09edcba09}}; | 1009 {38, 0xffedcba09edcba09}}; |
1010 | 1010 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1061 FOR_INT64_INPUTS(j) { | 1061 FOR_INT64_INPUTS(j) { |
1062 CHECK_EQ(*i ^ *j ^ *j ^ *j, r.Call(*i, *j, *j, *j)); | 1062 CHECK_EQ(*i ^ *j ^ *j ^ *j, r.Call(*i, *j, *j, *j)); |
1063 CHECK_EQ(*j ^ *i ^ *j ^ *j, r.Call(*j, *i, *j, *j)); | 1063 CHECK_EQ(*j ^ *i ^ *j ^ *j, r.Call(*j, *i, *j, *j)); |
1064 CHECK_EQ(*j ^ *j ^ *i ^ *j, r.Call(*j, *j, *i, *j)); | 1064 CHECK_EQ(*j ^ *j ^ *i ^ *j, r.Call(*j, *j, *i, *j)); |
1065 CHECK_EQ(*j ^ *j ^ *j ^ *i, r.Call(*j, *j, *j, *i)); | 1065 CHECK_EQ(*j ^ *j ^ *j ^ *i, r.Call(*j, *j, *j, *i)); |
1066 } | 1066 } |
1067 } | 1067 } |
1068 } | 1068 } |
1069 } | 1069 } |
1070 | 1070 |
1071 TEST(Run_WasmCall_Int64Sub) { | 1071 WASM_EXEC_TEST(Call_Int64Sub) { |
1072 REQUIRE(I64Sub); | 1072 REQUIRE(I64Sub); |
1073 // Build the target function. | 1073 // Build the target function. |
1074 TestSignatures sigs; | 1074 TestSignatures sigs; |
1075 TestingModule module; | 1075 TestingModule module; |
1076 WasmFunctionCompiler t(sigs.l_ll(), &module); | 1076 WasmFunctionCompiler t(sigs.l_ll(), &module); |
1077 BUILD(t, WASM_I64_SUB(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | 1077 BUILD(t, WASM_I64_SUB(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
1078 uint32_t index = t.CompileAndAdd(); | 1078 uint32_t index = t.CompileAndAdd(); |
1079 | 1079 |
1080 // Build the caller function. | 1080 // Build the caller function. |
1081 WasmRunner<int64_t> r(&module, MachineType::Int64(), MachineType::Int64()); | 1081 WasmRunner<int64_t> r(&module, MachineType::Int64(), MachineType::Int64()); |
1082 BUILD(r, WASM_CALL_FUNCTION2(index, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | 1082 BUILD(r, WASM_CALL_FUNCTION2(index, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
1083 | 1083 |
1084 FOR_INT32_INPUTS(i) { | 1084 FOR_INT32_INPUTS(i) { |
1085 FOR_INT32_INPUTS(j) { | 1085 FOR_INT32_INPUTS(j) { |
1086 int64_t a = static_cast<int64_t>(*i) << 32 | | 1086 int64_t a = static_cast<int64_t>(*i) << 32 | |
1087 (static_cast<int64_t>(*j) | 0xFFFFFFFF); | 1087 (static_cast<int64_t>(*j) | 0xFFFFFFFF); |
1088 int64_t b = static_cast<int64_t>(*j) << 32 | | 1088 int64_t b = static_cast<int64_t>(*j) << 32 | |
1089 (static_cast<int64_t>(*i) | 0xFFFFFFFF); | 1089 (static_cast<int64_t>(*i) | 0xFFFFFFFF); |
1090 | 1090 |
1091 int64_t expected = static_cast<int64_t>(static_cast<uint64_t>(a) - | 1091 int64_t expected = static_cast<int64_t>(static_cast<uint64_t>(a) - |
1092 static_cast<uint64_t>(b)); | 1092 static_cast<uint64_t>(b)); |
1093 CHECK_EQ(expected, r.Call(a, b)); | 1093 CHECK_EQ(expected, r.Call(a, b)); |
1094 } | 1094 } |
1095 } | 1095 } |
1096 } | 1096 } |
1097 | 1097 |
1098 TEST(Run_Wasm_LoadStoreI64_sx) { | 1098 WASM_EXEC_TEST(LoadStoreI64_sx) { |
1099 REQUIRE(I64LoadStore); | 1099 REQUIRE(I64LoadStore); |
1100 REQUIRE(DepthFirst); | 1100 REQUIRE(DepthFirst); |
1101 byte loads[] = {kExprI64LoadMem8S, kExprI64LoadMem16S, kExprI64LoadMem32S, | 1101 byte loads[] = {kExprI64LoadMem8S, kExprI64LoadMem16S, kExprI64LoadMem32S, |
1102 kExprI64LoadMem}; | 1102 kExprI64LoadMem}; |
1103 | 1103 |
1104 for (size_t m = 0; m < arraysize(loads); m++) { | 1104 for (size_t m = 0; m < arraysize(loads); m++) { |
1105 TestingModule module; | 1105 TestingModule module; |
1106 byte* memory = module.AddMemoryElems<byte>(16); | 1106 byte* memory = module.AddMemoryElems<byte>(16); |
1107 WasmRunner<int64_t> r(&module); | 1107 WasmRunner<int64_t> r(&module); |
1108 | 1108 |
(...skipping 20 matching lines...) Expand all Loading... |
1129 | 1129 |
1130 CHECK_EQ(expected, r.Call()); | 1130 CHECK_EQ(expected, r.Call()); |
1131 CHECK_EQ(static_cast<byte>(i), memory[8 + size - 1]); | 1131 CHECK_EQ(static_cast<byte>(i), memory[8 + size - 1]); |
1132 for (int j = size; j < 8; j++) { | 1132 for (int j = size; j < 8; j++) { |
1133 CHECK_EQ(255, memory[8 + j]); | 1133 CHECK_EQ(255, memory[8 + j]); |
1134 } | 1134 } |
1135 } | 1135 } |
1136 } | 1136 } |
1137 } | 1137 } |
1138 | 1138 |
1139 TEST(Run_Wasm_I64SConvertF32b) { | 1139 WASM_EXEC_TEST(I64SConvertF32b) { |
1140 REQUIRE(I64SConvertF32); | 1140 REQUIRE(I64SConvertF32); |
1141 WasmRunner<int64_t> r(MachineType::Float32()); | 1141 WasmRunner<int64_t> r(MachineType::Float32()); |
1142 BUILD(r, WASM_I64_SCONVERT_F32(WASM_GET_LOCAL(0))); | 1142 BUILD(r, WASM_I64_SCONVERT_F32(WASM_GET_LOCAL(0))); |
1143 | 1143 |
1144 FOR_FLOAT32_INPUTS(i) { | 1144 FOR_FLOAT32_INPUTS(i) { |
1145 if (*i < static_cast<float>(INT64_MAX) && | 1145 if (*i < static_cast<float>(INT64_MAX) && |
1146 *i >= static_cast<float>(INT64_MIN)) { | 1146 *i >= static_cast<float>(INT64_MIN)) { |
1147 CHECK_EQ(static_cast<int64_t>(*i), r.Call(*i)); | 1147 CHECK_EQ(static_cast<int64_t>(*i), r.Call(*i)); |
1148 } else { | 1148 } else { |
1149 CHECK_TRAP64(r.Call(*i)); | 1149 CHECK_TRAP64(r.Call(*i)); |
1150 } | 1150 } |
1151 } | 1151 } |
1152 } | 1152 } |
1153 | 1153 |
1154 TEST(Run_Wasm_I64SConvertF64b) { | 1154 WASM_EXEC_TEST(I64SConvertF64b) { |
1155 REQUIRE(I64SConvertF64); | 1155 REQUIRE(I64SConvertF64); |
1156 WasmRunner<int64_t> r(MachineType::Float64()); | 1156 WasmRunner<int64_t> r(MachineType::Float64()); |
1157 BUILD(r, WASM_I64_SCONVERT_F64(WASM_GET_LOCAL(0))); | 1157 BUILD(r, WASM_I64_SCONVERT_F64(WASM_GET_LOCAL(0))); |
1158 | 1158 |
1159 FOR_FLOAT64_INPUTS(i) { | 1159 FOR_FLOAT64_INPUTS(i) { |
1160 if (*i < static_cast<double>(INT64_MAX) && | 1160 if (*i < static_cast<double>(INT64_MAX) && |
1161 *i >= static_cast<double>(INT64_MIN)) { | 1161 *i >= static_cast<double>(INT64_MIN)) { |
1162 CHECK_EQ(static_cast<int64_t>(*i), r.Call(*i)); | 1162 CHECK_EQ(static_cast<int64_t>(*i), r.Call(*i)); |
1163 } else { | 1163 } else { |
1164 CHECK_TRAP64(r.Call(*i)); | 1164 CHECK_TRAP64(r.Call(*i)); |
1165 } | 1165 } |
1166 } | 1166 } |
1167 } | 1167 } |
1168 | 1168 |
1169 TEST(Run_Wasm_I64UConvertF32b) { | 1169 WASM_EXEC_TEST(I64UConvertF32b) { |
1170 REQUIRE(I64UConvertF32); | 1170 REQUIRE(I64UConvertF32); |
1171 WasmRunner<uint64_t> r(MachineType::Float32()); | 1171 WasmRunner<uint64_t> r(MachineType::Float32()); |
1172 BUILD(r, WASM_I64_UCONVERT_F32(WASM_GET_LOCAL(0))); | 1172 BUILD(r, WASM_I64_UCONVERT_F32(WASM_GET_LOCAL(0))); |
1173 | 1173 |
1174 FOR_FLOAT32_INPUTS(i) { | 1174 FOR_FLOAT32_INPUTS(i) { |
1175 if (*i < static_cast<float>(UINT64_MAX) && *i > -1) { | 1175 if (*i < static_cast<float>(UINT64_MAX) && *i > -1) { |
1176 CHECK_EQ(static_cast<uint64_t>(*i), r.Call(*i)); | 1176 CHECK_EQ(static_cast<uint64_t>(*i), r.Call(*i)); |
1177 } else { | 1177 } else { |
1178 CHECK_TRAP64(r.Call(*i)); | 1178 CHECK_TRAP64(r.Call(*i)); |
1179 } | 1179 } |
1180 } | 1180 } |
1181 } | 1181 } |
1182 | 1182 |
1183 TEST(Run_Wasm_I64UConvertF64b) { | 1183 WASM_EXEC_TEST(I64UConvertF64b) { |
1184 REQUIRE(I64UConvertF64); | 1184 REQUIRE(I64UConvertF64); |
1185 WasmRunner<uint64_t> r(MachineType::Float64()); | 1185 WasmRunner<uint64_t> r(MachineType::Float64()); |
1186 BUILD(r, WASM_I64_UCONVERT_F64(WASM_GET_LOCAL(0))); | 1186 BUILD(r, WASM_I64_UCONVERT_F64(WASM_GET_LOCAL(0))); |
1187 | 1187 |
1188 FOR_FLOAT64_INPUTS(i) { | 1188 FOR_FLOAT64_INPUTS(i) { |
1189 if (*i < static_cast<float>(UINT64_MAX) && *i > -1) { | 1189 if (*i < static_cast<float>(UINT64_MAX) && *i > -1) { |
1190 CHECK_EQ(static_cast<uint64_t>(*i), r.Call(*i)); | 1190 CHECK_EQ(static_cast<uint64_t>(*i), r.Call(*i)); |
1191 } else { | 1191 } else { |
1192 CHECK_TRAP64(r.Call(*i)); | 1192 CHECK_TRAP64(r.Call(*i)); |
1193 } | 1193 } |
1194 } | 1194 } |
1195 } | 1195 } |
1196 | 1196 |
1197 TEST(Run_Wasm_I64ReinterpretF64) { | 1197 WASM_EXEC_TEST(I64ReinterpretF64) { |
1198 REQUIRE(I64ReinterpretF64); | 1198 REQUIRE(I64ReinterpretF64); |
1199 TestingModule module; | 1199 TestingModule module; |
1200 int64_t* memory = module.AddMemoryElems<int64_t>(8); | 1200 int64_t* memory = module.AddMemoryElems<int64_t>(8); |
1201 WasmRunner<int64_t> r(&module); | 1201 WasmRunner<int64_t> r(&module); |
1202 | 1202 |
1203 BUILD(r, WASM_I64_REINTERPRET_F64( | 1203 BUILD(r, WASM_I64_REINTERPRET_F64( |
1204 WASM_LOAD_MEM(MachineType::Float64(), WASM_ZERO))); | 1204 WASM_LOAD_MEM(MachineType::Float64(), WASM_ZERO))); |
1205 | 1205 |
1206 FOR_INT32_INPUTS(i) { | 1206 FOR_INT32_INPUTS(i) { |
1207 int64_t expected = static_cast<int64_t>(*i) * 0x300010001; | 1207 int64_t expected = static_cast<int64_t>(*i) * 0x300010001; |
1208 memory[0] = expected; | 1208 memory[0] = expected; |
1209 CHECK_EQ(expected, r.Call()); | 1209 CHECK_EQ(expected, r.Call()); |
1210 } | 1210 } |
1211 } | 1211 } |
1212 | 1212 |
1213 TEST(Run_Wasm_F64ReinterpretI64) { | 1213 WASM_EXEC_TEST(F64ReinterpretI64) { |
1214 REQUIRE(F64ReinterpretI64); | 1214 REQUIRE(F64ReinterpretI64); |
1215 TestingModule module; | 1215 TestingModule module; |
1216 int64_t* memory = module.AddMemoryElems<int64_t>(8); | 1216 int64_t* memory = module.AddMemoryElems<int64_t>(8); |
1217 WasmRunner<int64_t> r(&module, MachineType::Int64()); | 1217 WasmRunner<int64_t> r(&module, MachineType::Int64()); |
1218 | 1218 |
1219 BUILD(r, WASM_BLOCK( | 1219 BUILD(r, WASM_BLOCK( |
1220 2, WASM_STORE_MEM(MachineType::Float64(), WASM_ZERO, | 1220 2, WASM_STORE_MEM(MachineType::Float64(), WASM_ZERO, |
1221 WASM_F64_REINTERPRET_I64(WASM_GET_LOCAL(0))), | 1221 WASM_F64_REINTERPRET_I64(WASM_GET_LOCAL(0))), |
1222 WASM_GET_LOCAL(0))); | 1222 WASM_GET_LOCAL(0))); |
1223 | 1223 |
1224 FOR_INT32_INPUTS(i) { | 1224 FOR_INT32_INPUTS(i) { |
1225 int64_t expected = static_cast<int64_t>(*i) * 0x300010001; | 1225 int64_t expected = static_cast<int64_t>(*i) * 0x300010001; |
1226 CHECK_EQ(expected, r.Call(expected)); | 1226 CHECK_EQ(expected, r.Call(expected)); |
1227 CHECK_EQ(expected, memory[0]); | 1227 CHECK_EQ(expected, memory[0]); |
1228 } | 1228 } |
1229 } | 1229 } |
1230 | 1230 |
1231 TEST(Run_Wasm_LoadMemI64) { | 1231 WASM_EXEC_TEST(LoadMemI64) { |
1232 REQUIRE(I64LoadStore); | 1232 REQUIRE(I64LoadStore); |
1233 TestingModule module; | 1233 TestingModule module; |
1234 int64_t* memory = module.AddMemoryElems<int64_t>(8); | 1234 int64_t* memory = module.AddMemoryElems<int64_t>(8); |
1235 module.RandomizeMemory(1111); | 1235 module.RandomizeMemory(1111); |
1236 WasmRunner<int64_t> r(&module); | 1236 WasmRunner<int64_t> r(&module); |
1237 | 1237 |
1238 BUILD(r, WASM_LOAD_MEM(MachineType::Int64(), WASM_I8(0))); | 1238 BUILD(r, WASM_LOAD_MEM(MachineType::Int64(), WASM_I8(0))); |
1239 | 1239 |
1240 memory[0] = 0xaabbccdd00112233LL; | 1240 memory[0] = 0xaabbccdd00112233LL; |
1241 CHECK_EQ(0xaabbccdd00112233LL, r.Call()); | 1241 CHECK_EQ(0xaabbccdd00112233LL, r.Call()); |
1242 | 1242 |
1243 memory[0] = 0x33aabbccdd001122LL; | 1243 memory[0] = 0x33aabbccdd001122LL; |
1244 CHECK_EQ(0x33aabbccdd001122LL, r.Call()); | 1244 CHECK_EQ(0x33aabbccdd001122LL, r.Call()); |
1245 | 1245 |
1246 memory[0] = 77777777; | 1246 memory[0] = 77777777; |
1247 CHECK_EQ(77777777, r.Call()); | 1247 CHECK_EQ(77777777, r.Call()); |
1248 } | 1248 } |
1249 | 1249 |
1250 TEST(Run_Wasm_MemI64_Sum) { | 1250 WASM_EXEC_TEST(MemI64_Sum) { |
1251 REQUIRE(I64LoadStore); | 1251 REQUIRE(I64LoadStore); |
1252 REQUIRE(I64Add); | 1252 REQUIRE(I64Add); |
1253 REQUIRE(I64Sub); | 1253 REQUIRE(I64Sub); |
1254 REQUIRE(I64Phi); | 1254 REQUIRE(I64Phi); |
1255 const int kNumElems = 20; | 1255 const int kNumElems = 20; |
1256 TestingModule module; | 1256 TestingModule module; |
1257 uint64_t* memory = module.AddMemoryElems<uint64_t>(kNumElems); | 1257 uint64_t* memory = module.AddMemoryElems<uint64_t>(kNumElems); |
1258 WasmRunner<uint64_t> r(&module, MachineType::Int32()); | 1258 WasmRunner<uint64_t> r(&module, MachineType::Int32()); |
1259 const byte kSum = r.AllocateLocal(kAstI64); | 1259 const byte kSum = r.AllocateLocal(kAstI64); |
1260 | 1260 |
(...skipping 15 matching lines...) Expand all Loading... |
1276 module.RandomizeMemory(i * 33); | 1276 module.RandomizeMemory(i * 33); |
1277 uint64_t expected = 0; | 1277 uint64_t expected = 0; |
1278 for (size_t j = kNumElems - 1; j > 0; j--) { | 1278 for (size_t j = kNumElems - 1; j > 0; j--) { |
1279 expected += memory[j]; | 1279 expected += memory[j]; |
1280 } | 1280 } |
1281 uint64_t result = r.Call(8 * (kNumElems - 1)); | 1281 uint64_t result = r.Call(8 * (kNumElems - 1)); |
1282 CHECK_EQ(expected, result); | 1282 CHECK_EQ(expected, result); |
1283 } | 1283 } |
1284 } | 1284 } |
1285 | 1285 |
1286 TEST(Run_Wasm_I64Global) { | 1286 WASM_EXEC_TEST(I64Global) { |
1287 REQUIRE(I64LoadStore); | 1287 REQUIRE(I64LoadStore); |
1288 REQUIRE(I64SConvertI32); | 1288 REQUIRE(I64SConvertI32); |
1289 REQUIRE(I64And); | 1289 REQUIRE(I64And); |
1290 REQUIRE(DepthFirst); | 1290 REQUIRE(DepthFirst); |
1291 TestingModule module; | 1291 TestingModule module; |
1292 int64_t* global = module.AddGlobal<int64_t>(MachineType::Int64()); | 1292 int64_t* global = module.AddGlobal<int64_t>(MachineType::Int64()); |
1293 WasmRunner<int32_t> r(&module, MachineType::Int32()); | 1293 WasmRunner<int32_t> r(&module, MachineType::Int32()); |
1294 // global = global + p0 | 1294 // global = global + p0 |
1295 BUILD(r, B2(WASM_STORE_GLOBAL( | 1295 BUILD(r, B2(WASM_STORE_GLOBAL( |
1296 0, WASM_I64_AND(WASM_LOAD_GLOBAL(0), | 1296 0, WASM_I64_AND(WASM_LOAD_GLOBAL(0), |
1297 WASM_I64_SCONVERT_I32(WASM_GET_LOCAL(0)))), | 1297 WASM_I64_SCONVERT_I32(WASM_GET_LOCAL(0)))), |
1298 WASM_ZERO)); | 1298 WASM_ZERO)); |
1299 | 1299 |
1300 *global = 0xFFFFFFFFFFFFFFFFLL; | 1300 *global = 0xFFFFFFFFFFFFFFFFLL; |
1301 for (int i = 9; i < 444444; i += 111111) { | 1301 for (int i = 9; i < 444444; i += 111111) { |
1302 int64_t expected = *global & i; | 1302 int64_t expected = *global & i; |
1303 r.Call(i); | 1303 r.Call(i); |
1304 CHECK_EQ(expected, *global); | 1304 CHECK_EQ(expected, *global); |
1305 } | 1305 } |
1306 } | 1306 } |
1307 | 1307 |
1308 TEST(Run_Wasm_I64Eqz) { | 1308 WASM_EXEC_TEST(I64Eqz) { |
1309 REQUIRE(I64Eq); | 1309 REQUIRE(I64Eq); |
1310 | 1310 |
1311 WasmRunner<int32_t> r(MachineType::Int64()); | 1311 WasmRunner<int32_t> r(MachineType::Int64()); |
1312 BUILD(r, WASM_I64_EQZ(WASM_GET_LOCAL(0))); | 1312 BUILD(r, WASM_I64_EQZ(WASM_GET_LOCAL(0))); |
1313 | 1313 |
1314 FOR_INT64_INPUTS(i) { | 1314 FOR_INT64_INPUTS(i) { |
1315 int32_t result = *i == 0 ? 1 : 0; | 1315 int32_t result = *i == 0 ? 1 : 0; |
1316 CHECK_EQ(result, r.Call(*i)); | 1316 CHECK_EQ(result, r.Call(*i)); |
1317 } | 1317 } |
1318 } | 1318 } |
1319 | 1319 |
1320 TEST(Run_Wasm_I64Ror) { | 1320 WASM_EXEC_TEST(I64Ror) { |
1321 REQUIRE(I64Ror); | 1321 REQUIRE(I64Ror); |
1322 WasmRunner<int64_t> r(MachineType::Int64(), MachineType::Int64()); | 1322 WasmRunner<int64_t> r(MachineType::Int64(), MachineType::Int64()); |
1323 BUILD(r, WASM_I64_ROR(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | 1323 BUILD(r, WASM_I64_ROR(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
1324 | 1324 |
1325 FOR_UINT64_INPUTS(i) { | 1325 FOR_UINT64_INPUTS(i) { |
1326 FOR_UINT64_INPUTS(j) { | 1326 FOR_UINT64_INPUTS(j) { |
1327 int64_t expected = bits::RotateRight64(*i, *j & 0x3f); | 1327 int64_t expected = bits::RotateRight64(*i, *j & 0x3f); |
1328 CHECK_EQ(expected, r.Call(*i, *j)); | 1328 CHECK_EQ(expected, r.Call(*i, *j)); |
1329 } | 1329 } |
1330 } | 1330 } |
1331 } | 1331 } |
1332 | 1332 |
1333 TEST(Run_Wasm_I64Rol) { | 1333 WASM_EXEC_TEST(I64Rol) { |
1334 REQUIRE(I64Rol); | 1334 REQUIRE(I64Rol); |
1335 WasmRunner<int64_t> r(MachineType::Int64(), MachineType::Int64()); | 1335 WasmRunner<int64_t> r(MachineType::Int64(), MachineType::Int64()); |
1336 BUILD(r, WASM_I64_ROL(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | 1336 BUILD(r, WASM_I64_ROL(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
1337 | 1337 |
1338 FOR_UINT64_INPUTS(i) { | 1338 FOR_UINT64_INPUTS(i) { |
1339 FOR_UINT64_INPUTS(j) { | 1339 FOR_UINT64_INPUTS(j) { |
1340 int64_t expected = bits::RotateLeft64(*i, *j & 0x3f); | 1340 int64_t expected = bits::RotateLeft64(*i, *j & 0x3f); |
1341 CHECK_EQ(expected, r.Call(*i, *j)); | 1341 CHECK_EQ(expected, r.Call(*i, *j)); |
1342 } | 1342 } |
1343 } | 1343 } |
1344 } | 1344 } |
OLD | NEW |