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/wasm/wasm-macro-gen.h" | 9 #include "src/wasm/wasm-macro-gen.h" |
10 | 10 |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 // kExprI64UConvertI32: | 140 // kExprI64UConvertI32: |
141 | 141 |
142 // kExprF64ReinterpretI64: | 142 // kExprF64ReinterpretI64: |
143 // kExprI64ReinterpretF64: | 143 // kExprI64ReinterpretF64: |
144 | 144 |
145 // kExprI64Clz: | 145 // kExprI64Clz: |
146 // kExprI64Ctz: | 146 // kExprI64Ctz: |
147 // kExprI64Popcnt: | 147 // kExprI64Popcnt: |
148 | 148 |
149 // kExprF32SConvertI64: | 149 // kExprF32SConvertI64: |
| 150 TEST(Run_Wasm_F32SConvertI64) { |
| 151 WasmRunner<float> r(MachineType::Int64()); |
| 152 BUILD(r, WASM_F32_SCONVERT_I64(WASM_GET_LOCAL(0))); |
| 153 FOR_INT64_INPUTS(i) { CHECK_EQ(static_cast<float>(*i), r.Call(*i)); } |
| 154 } |
| 155 |
150 // kExprF32UConvertI64: | 156 // kExprF32UConvertI64: |
| 157 TEST(Run_Wasm_F32UConvertI64) { |
| 158 struct { |
| 159 uint64_t input; |
| 160 uint32_t expected; |
| 161 } values[] = {{0x0, 0x0}, |
| 162 {0x1, 0x3f800000}, |
| 163 {0xffffffff, 0x4f800000}, |
| 164 {0x1b09788b, 0x4dd84bc4}, |
| 165 {0x4c5fce8, 0x4c98bf9d}, |
| 166 {0xcc0de5bf, 0x4f4c0de6}, |
| 167 {0x2, 0x40000000}, |
| 168 {0x3, 0x40400000}, |
| 169 {0x4, 0x40800000}, |
| 170 {0x5, 0x40a00000}, |
| 171 {0x8, 0x41000000}, |
| 172 {0x9, 0x41100000}, |
| 173 {0xffffffffffffffff, 0x5f800000}, |
| 174 {0xfffffffffffffffe, 0x5f800000}, |
| 175 {0xfffffffffffffffd, 0x5f800000}, |
| 176 {0x0, 0x0}, |
| 177 {0x100000000, 0x4f800000}, |
| 178 {0xffffffff00000000, 0x5f800000}, |
| 179 {0x1b09788b00000000, 0x5dd84bc4}, |
| 180 {0x4c5fce800000000, 0x5c98bf9d}, |
| 181 {0xcc0de5bf00000000, 0x5f4c0de6}, |
| 182 {0x200000000, 0x50000000}, |
| 183 {0x300000000, 0x50400000}, |
| 184 {0x400000000, 0x50800000}, |
| 185 {0x500000000, 0x50a00000}, |
| 186 {0x800000000, 0x51000000}, |
| 187 {0x900000000, 0x51100000}, |
| 188 {0x273a798e187937a3, 0x5e1ce9e6}, |
| 189 {0xece3af835495a16b, 0x5f6ce3b0}, |
| 190 {0xb668ecc11223344, 0x5d3668ed}, |
| 191 {0x9e, 0x431e0000}, |
| 192 {0x43, 0x42860000}, |
| 193 {0xaf73, 0x472f7300}, |
| 194 {0x116b, 0x458b5800}, |
| 195 {0x658ecc, 0x4acb1d98}, |
| 196 {0x2b3b4c, 0x4a2ced30}, |
| 197 {0x88776655, 0x4f087766}, |
| 198 {0x70000000, 0x4ee00000}, |
| 199 {0x7200000, 0x4ce40000}, |
| 200 {0x7fffffff, 0x4f000000}, |
| 201 {0x56123761, 0x4eac246f}, |
| 202 {0x7fffff00, 0x4efffffe}, |
| 203 {0x761c4761eeeeeeee, 0x5eec388f}, |
| 204 {0x80000000eeeeeeee, 0x5f000000}, |
| 205 {0x88888888dddddddd, 0x5f088889}, |
| 206 {0xa0000000dddddddd, 0x5f200000}, |
| 207 {0xddddddddaaaaaaaa, 0x5f5dddde}, |
| 208 {0xe0000000aaaaaaaa, 0x5f600000}, |
| 209 {0xeeeeeeeeeeeeeeee, 0x5f6eeeef}, |
| 210 {0xfffffffdeeeeeeee, 0x5f800000}, |
| 211 {0xf0000000dddddddd, 0x5f700000}, |
| 212 {0x7fffffdddddddd, 0x5b000000}, |
| 213 {0x3fffffaaaaaaaa, 0x5a7fffff}, |
| 214 {0x1fffffaaaaaaaa, 0x59fffffd}, |
| 215 {0xfffff, 0x497ffff0}, |
| 216 {0x7ffff, 0x48ffffe0}, |
| 217 {0x3ffff, 0x487fffc0}, |
| 218 {0x1ffff, 0x47ffff80}, |
| 219 {0xffff, 0x477fff00}, |
| 220 {0x7fff, 0x46fffe00}, |
| 221 {0x3fff, 0x467ffc00}, |
| 222 {0x1fff, 0x45fff800}, |
| 223 {0xfff, 0x457ff000}, |
| 224 {0x7ff, 0x44ffe000}, |
| 225 {0x3ff, 0x447fc000}, |
| 226 {0x1ff, 0x43ff8000}, |
| 227 {0x3fffffffffff, 0x56800000}, |
| 228 {0x1fffffffffff, 0x56000000}, |
| 229 {0xfffffffffff, 0x55800000}, |
| 230 {0x7ffffffffff, 0x55000000}, |
| 231 {0x3ffffffffff, 0x54800000}, |
| 232 {0x1ffffffffff, 0x54000000}, |
| 233 {0x8000008000000000, 0x5f000000}, |
| 234 {0x8000008000000001, 0x5f000001}, |
| 235 {0x8000000000000400, 0x5f000000}, |
| 236 {0x8000000000000401, 0x5f000000}}; |
| 237 WasmRunner<float> r(MachineType::Uint64()); |
| 238 BUILD(r, WASM_F32_UCONVERT_I64(WASM_GET_LOCAL(0))); |
| 239 for (size_t i = 0; i < arraysize(values); i++) { |
| 240 CHECK_EQ(bit_cast<float>(values[i].expected), r.Call(values[i].input)); |
| 241 } |
| 242 } |
| 243 |
151 // kExprF64SConvertI64: | 244 // kExprF64SConvertI64: |
| 245 TEST(Run_WasmF64SConvertI64) { |
| 246 WasmRunner<double> r(MachineType::Int64()); |
| 247 BUILD(r, WASM_F64_SCONVERT_I64(WASM_GET_LOCAL(0))); |
| 248 FOR_INT64_INPUTS(i) { CHECK_EQ(static_cast<double>(*i), r.Call(*i)); } |
| 249 } |
| 250 |
152 // kExprF64UConvertI64: | 251 // kExprF64UConvertI64: |
| 252 TEST(Run_Wasm_F64UConvertI64) { |
| 253 struct { |
| 254 uint64_t input; |
| 255 uint64_t expected; |
| 256 } values[] = {{0x0, 0x0}, |
| 257 {0x1, 0x3ff0000000000000}, |
| 258 {0xffffffff, 0x41efffffffe00000}, |
| 259 {0x1b09788b, 0x41bb09788b000000}, |
| 260 {0x4c5fce8, 0x419317f3a0000000}, |
| 261 {0xcc0de5bf, 0x41e981bcb7e00000}, |
| 262 {0x2, 0x4000000000000000}, |
| 263 {0x3, 0x4008000000000000}, |
| 264 {0x4, 0x4010000000000000}, |
| 265 {0x5, 0x4014000000000000}, |
| 266 {0x8, 0x4020000000000000}, |
| 267 {0x9, 0x4022000000000000}, |
| 268 {0xffffffffffffffff, 0x43f0000000000000}, |
| 269 {0xfffffffffffffffe, 0x43f0000000000000}, |
| 270 {0xfffffffffffffffd, 0x43f0000000000000}, |
| 271 {0x100000000, 0x41f0000000000000}, |
| 272 {0xffffffff00000000, 0x43efffffffe00000}, |
| 273 {0x1b09788b00000000, 0x43bb09788b000000}, |
| 274 {0x4c5fce800000000, 0x439317f3a0000000}, |
| 275 {0xcc0de5bf00000000, 0x43e981bcb7e00000}, |
| 276 {0x200000000, 0x4200000000000000}, |
| 277 {0x300000000, 0x4208000000000000}, |
| 278 {0x400000000, 0x4210000000000000}, |
| 279 {0x500000000, 0x4214000000000000}, |
| 280 {0x800000000, 0x4220000000000000}, |
| 281 {0x900000000, 0x4222000000000000}, |
| 282 {0x273a798e187937a3, 0x43c39d3cc70c3c9c}, |
| 283 {0xece3af835495a16b, 0x43ed9c75f06a92b4}, |
| 284 {0xb668ecc11223344, 0x43a6cd1d98224467}, |
| 285 {0x9e, 0x4063c00000000000}, |
| 286 {0x43, 0x4050c00000000000}, |
| 287 {0xaf73, 0x40e5ee6000000000}, |
| 288 {0x116b, 0x40b16b0000000000}, |
| 289 {0x658ecc, 0x415963b300000000}, |
| 290 {0x2b3b4c, 0x41459da600000000}, |
| 291 {0x88776655, 0x41e10eeccaa00000}, |
| 292 {0x70000000, 0x41dc000000000000}, |
| 293 {0x7200000, 0x419c800000000000}, |
| 294 {0x7fffffff, 0x41dfffffffc00000}, |
| 295 {0x56123761, 0x41d5848dd8400000}, |
| 296 {0x7fffff00, 0x41dfffffc0000000}, |
| 297 {0x761c4761eeeeeeee, 0x43dd8711d87bbbbc}, |
| 298 {0x80000000eeeeeeee, 0x43e00000001dddde}, |
| 299 {0x88888888dddddddd, 0x43e11111111bbbbc}, |
| 300 {0xa0000000dddddddd, 0x43e40000001bbbbc}, |
| 301 {0xddddddddaaaaaaaa, 0x43ebbbbbbbb55555}, |
| 302 {0xe0000000aaaaaaaa, 0x43ec000000155555}, |
| 303 {0xeeeeeeeeeeeeeeee, 0x43edddddddddddde}, |
| 304 {0xfffffffdeeeeeeee, 0x43efffffffbdddde}, |
| 305 {0xf0000000dddddddd, 0x43ee0000001bbbbc}, |
| 306 {0x7fffffdddddddd, 0x435ffffff7777777}, |
| 307 {0x3fffffaaaaaaaa, 0x434fffffd5555555}, |
| 308 {0x1fffffaaaaaaaa, 0x433fffffaaaaaaaa}, |
| 309 {0xfffff, 0x412ffffe00000000}, |
| 310 {0x7ffff, 0x411ffffc00000000}, |
| 311 {0x3ffff, 0x410ffff800000000}, |
| 312 {0x1ffff, 0x40fffff000000000}, |
| 313 {0xffff, 0x40efffe000000000}, |
| 314 {0x7fff, 0x40dfffc000000000}, |
| 315 {0x3fff, 0x40cfff8000000000}, |
| 316 {0x1fff, 0x40bfff0000000000}, |
| 317 {0xfff, 0x40affe0000000000}, |
| 318 {0x7ff, 0x409ffc0000000000}, |
| 319 {0x3ff, 0x408ff80000000000}, |
| 320 {0x1ff, 0x407ff00000000000}, |
| 321 {0x3fffffffffff, 0x42cfffffffffff80}, |
| 322 {0x1fffffffffff, 0x42bfffffffffff00}, |
| 323 {0xfffffffffff, 0x42affffffffffe00}, |
| 324 {0x7ffffffffff, 0x429ffffffffffc00}, |
| 325 {0x3ffffffffff, 0x428ffffffffff800}, |
| 326 {0x1ffffffffff, 0x427ffffffffff000}, |
| 327 {0x8000008000000000, 0x43e0000010000000}, |
| 328 {0x8000008000000001, 0x43e0000010000000}, |
| 329 {0x8000000000000400, 0x43e0000000000000}, |
| 330 {0x8000000000000401, 0x43e0000000000001}}; |
| 331 WasmRunner<double> r(MachineType::Uint64()); |
| 332 BUILD(r, WASM_F64_UCONVERT_I64(WASM_GET_LOCAL(0))); |
| 333 for (size_t i = 0; i < arraysize(values); i++) { |
| 334 CHECK_EQ(bit_cast<double>(values[i].expected), r.Call(values[i].input)); |
| 335 } |
| 336 } |
| 337 |
153 // kExprI64SConvertF32: | 338 // kExprI64SConvertF32: |
154 // kExprI64SConvertF64: | 339 // kExprI64SConvertF64: |
155 // kExprI64UConvertF32: | 340 // kExprI64UConvertF32: |
156 // kExprI64UConvertF64: | 341 // kExprI64UConvertF64: |
157 | 342 |
158 TEST(Run_WasmCallI64Parameter) { | 343 TEST(Run_WasmCallI64Parameter) { |
159 // Build the target function. | 344 // Build the target function. |
160 LocalType param_types[20]; | 345 LocalType param_types[20]; |
161 for (int i = 0; i < 20; i++) param_types[i] = kAstI64; | 346 for (int i = 0; i < 20; i++) param_types[i] = kAstI64; |
162 param_types[3] = kAstI32; | 347 param_types[3] = kAstI32; |
(...skipping 23 matching lines...) Expand all Loading... |
186 WASM_I64V_10(0xbcd1234000000013), WASM_I64V_10(0xbcd1234000000014), | 371 WASM_I64V_10(0xbcd1234000000013), WASM_I64V_10(0xbcd1234000000014), |
187 WASM_I64V_10(0xbcd1234000000015), WASM_I64V_10(0xbcd1234000000016), | 372 WASM_I64V_10(0xbcd1234000000015), WASM_I64V_10(0xbcd1234000000016), |
188 WASM_I64V_10(0xbcd1234000000017), WASM_I64V_10(0xbcd1234000000018), | 373 WASM_I64V_10(0xbcd1234000000017), WASM_I64V_10(0xbcd1234000000018), |
189 WASM_I64V_10(0xbcd1234000000019), WASM_I64V_10(0xbcd123400000001a), | 374 WASM_I64V_10(0xbcd1234000000019), WASM_I64V_10(0xbcd123400000001a), |
190 WASM_I64V_10(0xbcd123400000001b), WASM_I64V_10(0xbcd123400000001c), | 375 WASM_I64V_10(0xbcd123400000001b), WASM_I64V_10(0xbcd123400000001c), |
191 WASM_I64V_10(0xbcd123400000001d)))); | 376 WASM_I64V_10(0xbcd123400000001d)))); |
192 | 377 |
193 CHECK_EQ(i + 0xb, r.Call()); | 378 CHECK_EQ(i + 0xb, r.Call()); |
194 } | 379 } |
195 } | 380 } |
OLD | NEW |