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 // Flags: --harmony-simd --harmony-tostring --harmony-reflect | 5 // Flags: --harmony-simd --harmony-tostring --harmony-reflect |
6 // Flags: --allow-natives-syntax --expose-natives-as natives --noalways-opt | 6 // Flags: --allow-natives-syntax --expose-natives-as natives --noalways-opt |
7 | 7 |
8 function lanesForType(typeName) { | 8 function lanesForType(typeName) { |
9 // The lane count follows the first 'x' in the type name, which begins with | 9 // The lane count follows the first 'x' in the type name, which begins with |
10 // 'float', 'int', or 'bool'. | 10 // 'float', 'int', or 'bool'. |
(...skipping 27 matching lines...) Expand all Loading... |
38 for (var i = 0; i < lanes; i++) { | 38 for (var i = 0; i < lanes; i++) { |
39 var fromString = parseFn(laneStrings[i]), | 39 var fromString = parseFn(laneStrings[i]), |
40 fromValue = simdFn.extractLane(value, i); | 40 fromValue = simdFn.extractLane(value, i); |
41 if (Math.abs(fromString - fromValue) > Number.EPSILON) | 41 if (Math.abs(fromString - fromValue) > Number.EPSILON) |
42 return false; | 42 return false; |
43 } | 43 } |
44 return true; | 44 return true; |
45 } | 45 } |
46 | 46 |
47 | 47 |
48 var simdTypeNames = ['Float32x4', 'Int32x4', 'Bool32x4', | 48 var simdTypeNames = ['Float32x4', 'Int32x4', 'Uint32x4', 'Bool32x4', |
49 'Int16x8', 'Bool16x8', | 49 'Int16x8', 'Uint16x8', 'Bool16x8', |
50 'Int8x16', 'Bool8x16']; | 50 'Int8x16', 'Uint8x16', 'Bool8x16']; |
51 | 51 |
52 var nonSimdValues = [347, 1.275, NaN, "string", null, undefined, {}, | 52 var nonSimdValues = [347, 1.275, NaN, "string", null, undefined, {}, |
53 function() {}]; | 53 function() {}]; |
54 | 54 |
55 function checkTypeMatrix(type, fn) { | 55 function checkTypeMatrix(type, fn) { |
56 // Check against non-SIMD types. | 56 // Check against non-SIMD types. |
57 nonSimdValues.forEach(fn); | 57 nonSimdValues.forEach(fn); |
58 // Check against SIMD values of a different type. | 58 // Check against SIMD values of a different type. |
59 for (var i = 0; i < simdTypeNames.length; i++) { | 59 for (var i = 0; i < simdTypeNames.length; i++) { |
60 var otherType = simdTypeNames[i]; | 60 var otherType = simdTypeNames[i]; |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 test(1.1, 1); | 205 test(1.1, 1); |
206 test(-1, -1); | 206 test(-1, -1); |
207 test(-1.6, -1); | 207 test(-1.6, -1); |
208 test(2147483647, 2147483647); | 208 test(2147483647, 2147483647); |
209 test(2147483648, -2147483648); | 209 test(2147483648, -2147483648); |
210 test(2147483649, -2147483647); | 210 test(2147483649, -2147483647); |
211 test(4294967295, -1); | 211 test(4294967295, -1); |
212 test(4294967296, 0); | 212 test(4294967296, 0); |
213 test(4294967297, 1); | 213 test(4294967297, 1); |
214 break; | 214 break; |
| 215 case 'Uint32x4': |
| 216 test(Infinity, 0); |
| 217 test(-Infinity, 0); |
| 218 test(NaN, 0); |
| 219 test(0, 0); |
| 220 test(-0, 0); |
| 221 test(Number.MIN_VALUE, 0); |
| 222 test(-Number.MIN_VALUE, 0); |
| 223 test(0.1, 0); |
| 224 test(-0.1, 0); |
| 225 test(1, 1); |
| 226 test(1.1, 1); |
| 227 test(-1, 4294967295); |
| 228 test(-1.6, 4294967295); |
| 229 test(4294967295, 4294967295); |
| 230 test(4294967296, 0); |
| 231 test(4294967297, 1); |
| 232 break; |
215 case 'Int16x8': | 233 case 'Int16x8': |
216 test(Infinity, 0); | 234 test(Infinity, 0); |
217 test(-Infinity, 0); | 235 test(-Infinity, 0); |
218 test(NaN, 0); | 236 test(NaN, 0); |
219 test(0, 0); | 237 test(0, 0); |
220 test(-0, 0); | 238 test(-0, 0); |
221 test(Number.MIN_VALUE, 0); | 239 test(Number.MIN_VALUE, 0); |
222 test(-Number.MIN_VALUE, 0); | 240 test(-Number.MIN_VALUE, 0); |
223 test(0.1, 0); | 241 test(0.1, 0); |
224 test(-0.1, 0); | 242 test(-0.1, 0); |
225 test(1, 1); | 243 test(1, 1); |
226 test(1.1, 1); | 244 test(1.1, 1); |
227 test(-1, -1); | 245 test(-1, -1); |
228 test(-1.6, -1); | 246 test(-1.6, -1); |
229 test(32767, 32767); | 247 test(32767, 32767); |
230 test(32768, -32768); | 248 test(32768, -32768); |
231 test(32769, -32767); | 249 test(32769, -32767); |
232 test(65535, -1); | 250 test(65535, -1); |
233 test(65536, 0); | 251 test(65536, 0); |
234 test(65537, 1); | 252 test(65537, 1); |
235 break; | 253 break; |
| 254 case 'Uint16x8': |
| 255 test(Infinity, 0); |
| 256 test(-Infinity, 0); |
| 257 test(NaN, 0); |
| 258 test(0, 0); |
| 259 test(-0, 0); |
| 260 test(Number.MIN_VALUE, 0); |
| 261 test(-Number.MIN_VALUE, 0); |
| 262 test(0.1, 0); |
| 263 test(-0.1, 0); |
| 264 test(1, 1); |
| 265 test(1.1, 1); |
| 266 test(-1, 65535); |
| 267 test(-1.6, 65535); |
| 268 test(65535, 65535); |
| 269 test(65536, 0); |
| 270 test(65537, 1); |
| 271 break; |
236 case 'Int8x16': | 272 case 'Int8x16': |
237 test(Infinity, 0); | 273 test(Infinity, 0); |
238 test(-Infinity, 0); | 274 test(-Infinity, 0); |
239 test(NaN, 0); | 275 test(NaN, 0); |
240 test(0, 0); | 276 test(0, 0); |
241 test(-0, 0); | 277 test(-0, 0); |
242 test(Number.MIN_VALUE, 0); | 278 test(Number.MIN_VALUE, 0); |
243 test(-Number.MIN_VALUE, 0); | 279 test(-Number.MIN_VALUE, 0); |
244 test(0.1, 0); | 280 test(0.1, 0); |
245 test(-0.1, 0); | 281 test(-0.1, 0); |
246 test(1, 1); | 282 test(1, 1); |
247 test(1.1, 1); | 283 test(1.1, 1); |
248 test(-1, -1); | 284 test(-1, -1); |
249 test(-1.6, -1); | 285 test(-1.6, -1); |
250 test(127, 127); | 286 test(127, 127); |
251 test(128, -128); | 287 test(128, -128); |
252 test(129, -127); | 288 test(129, -127); |
253 test(255, -1); | 289 test(255, -1); |
254 test(256, 0); | 290 test(256, 0); |
255 test(257, 1); | 291 test(257, 1); |
256 break; | 292 break; |
| 293 case 'Uint8x16': |
| 294 test(Infinity, 0); |
| 295 test(-Infinity, 0); |
| 296 test(NaN, 0); |
| 297 test(0, 0); |
| 298 test(-0, 0); |
| 299 test(Number.MIN_VALUE, 0); |
| 300 test(-Number.MIN_VALUE, 0); |
| 301 test(0.1, 0); |
| 302 test(-0.1, 0); |
| 303 test(1, 1); |
| 304 test(1.1, 1); |
| 305 test(-1, 255); |
| 306 test(-1.6, 255); |
| 307 test(255, 255); |
| 308 test(256, 0); |
| 309 test(257, 1); |
| 310 break; |
257 case 'Bool32x4': | 311 case 'Bool32x4': |
258 case 'Bool16x8': | 312 case 'Bool16x8': |
259 case 'Bool8x16': | 313 case 'Bool8x16': |
260 test(true, true); | 314 test(true, true); |
261 test(false, false); | 315 test(false, false); |
262 test(0, false); | 316 test(0, false); |
263 test(1, true); | 317 test(1, true); |
264 test(0.1, true); | 318 test(0.1, true); |
265 test(NaN, false); | 319 test(NaN, false); |
266 test(null, false); | 320 test(null, false); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 test(1, 2.5); | 377 test(1, 2.5); |
324 test(1, 1); | 378 test(1, 1); |
325 test(0, 0); | 379 test(0, 0); |
326 test(-0, +0); | 380 test(-0, +0); |
327 test(+0, -0); | 381 test(+0, -0); |
328 test(-0, -0); | 382 test(-0, -0); |
329 test(0, NaN); | 383 test(0, NaN); |
330 test(NaN, NaN); | 384 test(NaN, NaN); |
331 break; | 385 break; |
332 case 'Int32x4': | 386 case 'Int32x4': |
| 387 case 'Uint32x4': |
333 case 'Int16x8': | 388 case 'Int16x8': |
| 389 case 'Uint16x8': |
334 case 'Int8x16': | 390 case 'Int8x16': |
| 391 case 'Uint8x16': |
335 test(1, 2); | 392 test(1, 2); |
336 test(1, 1); | 393 test(1, 1); |
337 test(1, -1); | 394 test(1, -1); |
338 break; | 395 break; |
339 case 'Bool32x4': | 396 case 'Bool32x4': |
340 case 'Bool16x8': | 397 case 'Bool16x8': |
341 case 'Bool8x16': | 398 case 'Bool8x16': |
342 test(true, false); | 399 test(true, false); |
343 test(false, true); | 400 test(false, true); |
344 break; | 401 break; |
(...skipping 29 matching lines...) Expand all Loading... |
374 test(1, 2.5); | 431 test(1, 2.5); |
375 test(1, 1); | 432 test(1, 1); |
376 test(0, 0); | 433 test(0, 0); |
377 test(-0, +0); | 434 test(-0, +0); |
378 test(+0, -0); | 435 test(+0, -0); |
379 test(-0, -0); | 436 test(-0, -0); |
380 test(0, NaN); | 437 test(0, NaN); |
381 test(NaN, NaN); | 438 test(NaN, NaN); |
382 break; | 439 break; |
383 case 'Int32x4': | 440 case 'Int32x4': |
| 441 case 'Uint32x4': |
384 case 'Int16x8': | 442 case 'Int16x8': |
| 443 case 'Uint16x8': |
385 case 'Int8x16': | 444 case 'Int8x16': |
| 445 case 'Uint8x16': |
386 test(1, 2); | 446 test(1, 2); |
387 test(1, 1); | 447 test(1, 1); |
388 test(1, -1); | 448 test(1, -1); |
389 break; | 449 break; |
390 case 'Bool32x4': | 450 case 'Bool32x4': |
391 case 'Bool16x8': | 451 case 'Bool16x8': |
392 case 'Bool8x16': | 452 case 'Bool8x16': |
393 test(true, false); | 453 test(true, false); |
394 test(false, true); | 454 test(false, true); |
395 break; | 455 break; |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 assertSame(Object.getPrototypeOf(SIMD), Object.prototype); | 611 assertSame(Object.getPrototypeOf(SIMD), Object.prototype); |
552 assertSame(SIMD + "", "[object SIMD]"); | 612 assertSame(SIMD + "", "[object SIMD]"); |
553 // The SIMD object is mutable. | 613 // The SIMD object is mutable. |
554 SIMD.foo = "foo"; | 614 SIMD.foo = "foo"; |
555 assertSame(SIMD.foo, "foo"); | 615 assertSame(SIMD.foo, "foo"); |
556 delete SIMD.foo; | 616 delete SIMD.foo; |
557 delete SIMD.Bool8x16; | 617 delete SIMD.Bool8x16; |
558 assertSame(SIMD.Bool8x16, undefined); | 618 assertSame(SIMD.Bool8x16, undefined); |
559 } | 619 } |
560 TestSIMDObject() | 620 TestSIMDObject() |
OLD | NEW |