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', 'Uint32x4', 'Bool32x4', | 48 var simdTypeNames = ['Float32x4', 'Int32x4', 'Bool32x4', |
49 'Int16x8', 'Uint16x8', 'Bool16x8', | 49 'Int16x8', 'Bool16x8', |
50 'Int8x16', 'Uint8x16', 'Bool8x16']; | 50 'Int8x16', '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; | |
233 case 'Int16x8': | 215 case 'Int16x8': |
234 test(Infinity, 0); | 216 test(Infinity, 0); |
235 test(-Infinity, 0); | 217 test(-Infinity, 0); |
236 test(NaN, 0); | 218 test(NaN, 0); |
237 test(0, 0); | 219 test(0, 0); |
238 test(-0, 0); | 220 test(-0, 0); |
239 test(Number.MIN_VALUE, 0); | 221 test(Number.MIN_VALUE, 0); |
240 test(-Number.MIN_VALUE, 0); | 222 test(-Number.MIN_VALUE, 0); |
241 test(0.1, 0); | 223 test(0.1, 0); |
242 test(-0.1, 0); | 224 test(-0.1, 0); |
243 test(1, 1); | 225 test(1, 1); |
244 test(1.1, 1); | 226 test(1.1, 1); |
245 test(-1, -1); | 227 test(-1, -1); |
246 test(-1.6, -1); | 228 test(-1.6, -1); |
247 test(32767, 32767); | 229 test(32767, 32767); |
248 test(32768, -32768); | 230 test(32768, -32768); |
249 test(32769, -32767); | 231 test(32769, -32767); |
250 test(65535, -1); | 232 test(65535, -1); |
251 test(65536, 0); | 233 test(65536, 0); |
252 test(65537, 1); | 234 test(65537, 1); |
253 break; | 235 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; | |
272 case 'Int8x16': | 236 case 'Int8x16': |
273 test(Infinity, 0); | 237 test(Infinity, 0); |
274 test(-Infinity, 0); | 238 test(-Infinity, 0); |
275 test(NaN, 0); | 239 test(NaN, 0); |
276 test(0, 0); | 240 test(0, 0); |
277 test(-0, 0); | 241 test(-0, 0); |
278 test(Number.MIN_VALUE, 0); | 242 test(Number.MIN_VALUE, 0); |
279 test(-Number.MIN_VALUE, 0); | 243 test(-Number.MIN_VALUE, 0); |
280 test(0.1, 0); | 244 test(0.1, 0); |
281 test(-0.1, 0); | 245 test(-0.1, 0); |
282 test(1, 1); | 246 test(1, 1); |
283 test(1.1, 1); | 247 test(1.1, 1); |
284 test(-1, -1); | 248 test(-1, -1); |
285 test(-1.6, -1); | 249 test(-1.6, -1); |
286 test(127, 127); | 250 test(127, 127); |
287 test(128, -128); | 251 test(128, -128); |
288 test(129, -127); | 252 test(129, -127); |
289 test(255, -1); | 253 test(255, -1); |
290 test(256, 0); | 254 test(256, 0); |
291 test(257, 1); | 255 test(257, 1); |
292 break; | 256 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; | |
311 case 'Bool32x4': | 257 case 'Bool32x4': |
312 case 'Bool16x8': | 258 case 'Bool16x8': |
313 case 'Bool8x16': | 259 case 'Bool8x16': |
314 test(true, true); | 260 test(true, true); |
315 test(false, false); | 261 test(false, false); |
316 test(0, false); | 262 test(0, false); |
317 test(1, true); | 263 test(1, true); |
318 test(0.1, true); | 264 test(0.1, true); |
319 test(NaN, false); | 265 test(NaN, false); |
320 test(null, false); | 266 test(null, false); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 test(1, 2.5); | 323 test(1, 2.5); |
378 test(1, 1); | 324 test(1, 1); |
379 test(0, 0); | 325 test(0, 0); |
380 test(-0, +0); | 326 test(-0, +0); |
381 test(+0, -0); | 327 test(+0, -0); |
382 test(-0, -0); | 328 test(-0, -0); |
383 test(0, NaN); | 329 test(0, NaN); |
384 test(NaN, NaN); | 330 test(NaN, NaN); |
385 break; | 331 break; |
386 case 'Int32x4': | 332 case 'Int32x4': |
387 case 'Uint32x4': | |
388 case 'Int16x8': | 333 case 'Int16x8': |
389 case 'Uint16x8': | |
390 case 'Int8x16': | 334 case 'Int8x16': |
391 case 'Uint8x16': | |
392 test(1, 2); | 335 test(1, 2); |
393 test(1, 1); | 336 test(1, 1); |
394 test(1, -1); | 337 test(1, -1); |
395 break; | 338 break; |
396 case 'Bool32x4': | 339 case 'Bool32x4': |
397 case 'Bool16x8': | 340 case 'Bool16x8': |
398 case 'Bool8x16': | 341 case 'Bool8x16': |
399 test(true, false); | 342 test(true, false); |
400 test(false, true); | 343 test(false, true); |
401 break; | 344 break; |
(...skipping 29 matching lines...) Expand all Loading... |
431 test(1, 2.5); | 374 test(1, 2.5); |
432 test(1, 1); | 375 test(1, 1); |
433 test(0, 0); | 376 test(0, 0); |
434 test(-0, +0); | 377 test(-0, +0); |
435 test(+0, -0); | 378 test(+0, -0); |
436 test(-0, -0); | 379 test(-0, -0); |
437 test(0, NaN); | 380 test(0, NaN); |
438 test(NaN, NaN); | 381 test(NaN, NaN); |
439 break; | 382 break; |
440 case 'Int32x4': | 383 case 'Int32x4': |
441 case 'Uint32x4': | |
442 case 'Int16x8': | 384 case 'Int16x8': |
443 case 'Uint16x8': | |
444 case 'Int8x16': | 385 case 'Int8x16': |
445 case 'Uint8x16': | |
446 test(1, 2); | 386 test(1, 2); |
447 test(1, 1); | 387 test(1, 1); |
448 test(1, -1); | 388 test(1, -1); |
449 break; | 389 break; |
450 case 'Bool32x4': | 390 case 'Bool32x4': |
451 case 'Bool16x8': | 391 case 'Bool16x8': |
452 case 'Bool8x16': | 392 case 'Bool8x16': |
453 test(true, false); | 393 test(true, false); |
454 test(false, true); | 394 test(false, true); |
455 break; | 395 break; |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 assertSame(Object.getPrototypeOf(SIMD), Object.prototype); | 551 assertSame(Object.getPrototypeOf(SIMD), Object.prototype); |
612 assertSame(SIMD + "", "[object SIMD]"); | 552 assertSame(SIMD + "", "[object SIMD]"); |
613 // The SIMD object is mutable. | 553 // The SIMD object is mutable. |
614 SIMD.foo = "foo"; | 554 SIMD.foo = "foo"; |
615 assertSame(SIMD.foo, "foo"); | 555 assertSame(SIMD.foo, "foo"); |
616 delete SIMD.foo; | 556 delete SIMD.foo; |
617 delete SIMD.Bool8x16; | 557 delete SIMD.Bool8x16; |
618 assertSame(SIMD.Bool8x16, undefined); | 558 assertSame(SIMD.Bool8x16, undefined); |
619 } | 559 } |
620 TestSIMDObject() | 560 TestSIMDObject() |
OLD | NEW |