| 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 (function(global, utils) { | 5 (function(global, utils) { | 
| 6 | 6 | 
| 7 "use strict"; | 7 "use strict"; | 
| 8 | 8 | 
| 9 %CheckIsBootstrapping(); | 9 %CheckIsBootstrapping(); | 
| 10 | 10 | 
| 11 // ------------------------------------------------------------------- | 11 // ------------------------------------------------------------------- | 
| 12 // Imports | 12 // Imports | 
| 13 | 13 | 
| 14 var GlobalSIMD = global.SIMD; | 14 var GlobalSIMD = global.SIMD; | 
| 15 var MakeTypeError; |  | 
| 16 var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol"); | 15 var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol"); | 
| 17 | 16 | 
| 18 utils.Import(function(from) { |  | 
| 19   MakeTypeError = from.MakeTypeError; |  | 
| 20 }); |  | 
| 21 |  | 
| 22 // ------------------------------------------------------------------- | 17 // ------------------------------------------------------------------- | 
| 23 | 18 | 
| 24 macro SIMD_FLOAT_TYPES(FUNCTION) | 19 macro SIMD_FLOAT_TYPES(FUNCTION) | 
| 25 FUNCTION(Float32x4, float32x4, 4) | 20 FUNCTION(Float32x4, float32x4, 4) | 
| 26 endmacro | 21 endmacro | 
| 27 | 22 | 
| 28 macro SIMD_INT_TYPES(FUNCTION) | 23 macro SIMD_INT_TYPES(FUNCTION) | 
| 29 FUNCTION(Int32x4, int32x4, 4) | 24 FUNCTION(Int32x4, int32x4, 4) | 
| 30 FUNCTION(Int16x8, int16x8, 8) | 25 FUNCTION(Int16x8, int16x8, 8) | 
| 31 FUNCTION(Int8x16, int8x16, 16) | 26 FUNCTION(Int8x16, int8x16, 16) | 
| (...skipping 25 matching lines...) Expand all  Loading... | 
| 57 SIMD_ALL_TYPES(DECLARE_GLOBALS) | 52 SIMD_ALL_TYPES(DECLARE_GLOBALS) | 
| 58 | 53 | 
| 59 macro DECLARE_COMMON_FUNCTIONS(NAME, TYPE, LANES) | 54 macro DECLARE_COMMON_FUNCTIONS(NAME, TYPE, LANES) | 
| 60 function NAMECheckJS(a) { | 55 function NAMECheckJS(a) { | 
| 61   return %NAMECheck(a); | 56   return %NAMECheck(a); | 
| 62 } | 57 } | 
| 63 | 58 | 
| 64 function NAMEToString() { | 59 function NAMEToString() { | 
| 65   var value = %ValueOf(this); | 60   var value = %ValueOf(this); | 
| 66   if (typeof(value) !== 'TYPE') { | 61   if (typeof(value) !== 'TYPE') { | 
| 67     throw MakeTypeError(kIncompatibleMethodReceiver, | 62     throw %make_type_error(kIncompatibleMethodReceiver, | 
| 68                         "NAME.prototype.toString", this); | 63                         "NAME.prototype.toString", this); | 
| 69   } | 64   } | 
| 70   var str = "SIMD.NAME("; | 65   var str = "SIMD.NAME("; | 
| 71   str += %NAMEExtractLane(value, 0); | 66   str += %NAMEExtractLane(value, 0); | 
| 72   for (var i = 1; i < LANES; i++) { | 67   for (var i = 1; i < LANES; i++) { | 
| 73     str += ", " + %NAMEExtractLane(value, i); | 68     str += ", " + %NAMEExtractLane(value, i); | 
| 74   } | 69   } | 
| 75   return str + ")"; | 70   return str + ")"; | 
| 76 } | 71 } | 
| 77 | 72 | 
| 78 function NAMEToLocaleString() { | 73 function NAMEToLocaleString() { | 
| 79   var value = %ValueOf(this); | 74   var value = %ValueOf(this); | 
| 80   if (typeof(value) !== 'TYPE') { | 75   if (typeof(value) !== 'TYPE') { | 
| 81     throw MakeTypeError(kIncompatibleMethodReceiver, | 76     throw %make_type_error(kIncompatibleMethodReceiver, | 
| 82                         "NAME.prototype.toLocaleString", this); | 77                         "NAME.prototype.toLocaleString", this); | 
| 83   } | 78   } | 
| 84   var str = "SIMD.NAME("; | 79   var str = "SIMD.NAME("; | 
| 85   str += %NAMEExtractLane(value, 0).toLocaleString(); | 80   str += %NAMEExtractLane(value, 0).toLocaleString(); | 
| 86   for (var i = 1; i < LANES; i++) { | 81   for (var i = 1; i < LANES; i++) { | 
| 87     str += ", " + %NAMEExtractLane(value, i).toLocaleString(); | 82     str += ", " + %NAMEExtractLane(value, i).toLocaleString(); | 
| 88   } | 83   } | 
| 89   return str + ")"; | 84   return str + ")"; | 
| 90 } | 85 } | 
| 91 | 86 | 
| 92 function NAMEValueOf() { | 87 function NAMEValueOf() { | 
| 93   var value = %ValueOf(this); | 88   var value = %ValueOf(this); | 
| 94   if (typeof(value) !== 'TYPE') { | 89   if (typeof(value) !== 'TYPE') { | 
| 95     throw MakeTypeError(kIncompatibleMethodReceiver, | 90     throw %make_type_error(kIncompatibleMethodReceiver, | 
| 96                         "NAME.prototype.valueOf", this); | 91                         "NAME.prototype.valueOf", this); | 
| 97   } | 92   } | 
| 98   return value; | 93   return value; | 
| 99 } | 94 } | 
| 100 | 95 | 
| 101 function NAMEExtractLaneJS(instance, lane) { | 96 function NAMEExtractLaneJS(instance, lane) { | 
| 102   return %NAMEExtractLane(instance, lane); | 97   return %NAMEExtractLane(instance, lane); | 
| 103 } | 98 } | 
| 104 endmacro | 99 endmacro | 
| 105 | 100 | 
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 427                             c11, c12, c13, c14, c15); | 422                             c11, c12, c13, c14, c15); | 
| 428 } | 423 } | 
| 429 endmacro | 424 endmacro | 
| 430 | 425 | 
| 431 SIMD_X16_TYPES(DECLARE_X16_FUNCTIONS) | 426 SIMD_X16_TYPES(DECLARE_X16_FUNCTIONS) | 
| 432 | 427 | 
| 433 //------------------------------------------------------------------- | 428 //------------------------------------------------------------------- | 
| 434 | 429 | 
| 435 function Float32x4Constructor(c0, c1, c2, c3) { | 430 function Float32x4Constructor(c0, c1, c2, c3) { | 
| 436   if (!IS_UNDEFINED(new.target)) { | 431   if (!IS_UNDEFINED(new.target)) { | 
| 437     throw MakeTypeError(kNotConstructor, "Float32x4"); | 432     throw %make_type_error(kNotConstructor, "Float32x4"); | 
| 438   } | 433   } | 
| 439   return %CreateFloat32x4(TO_NUMBER(c0), TO_NUMBER(c1), | 434   return %CreateFloat32x4(TO_NUMBER(c0), TO_NUMBER(c1), | 
| 440                           TO_NUMBER(c2), TO_NUMBER(c3)); | 435                           TO_NUMBER(c2), TO_NUMBER(c3)); | 
| 441 } | 436 } | 
| 442 | 437 | 
| 443 | 438 | 
| 444 function Int32x4Constructor(c0, c1, c2, c3) { | 439 function Int32x4Constructor(c0, c1, c2, c3) { | 
| 445   if (!IS_UNDEFINED(new.target)) { | 440   if (!IS_UNDEFINED(new.target)) { | 
| 446     throw MakeTypeError(kNotConstructor, "Int32x4"); | 441     throw %make_type_error(kNotConstructor, "Int32x4"); | 
| 447   } | 442   } | 
| 448   return %CreateInt32x4(TO_NUMBER(c0), TO_NUMBER(c1), | 443   return %CreateInt32x4(TO_NUMBER(c0), TO_NUMBER(c1), | 
| 449                         TO_NUMBER(c2), TO_NUMBER(c3)); | 444                         TO_NUMBER(c2), TO_NUMBER(c3)); | 
| 450 } | 445 } | 
| 451 | 446 | 
| 452 | 447 | 
| 453 function Uint32x4Constructor(c0, c1, c2, c3) { | 448 function Uint32x4Constructor(c0, c1, c2, c3) { | 
| 454   if (!IS_UNDEFINED(new.target)) { | 449   if (!IS_UNDEFINED(new.target)) { | 
| 455     throw MakeTypeError(kNotConstructor, "Uint32x4"); | 450     throw %make_type_error(kNotConstructor, "Uint32x4"); | 
| 456   } | 451   } | 
| 457   return %CreateUint32x4(TO_NUMBER(c0), TO_NUMBER(c1), | 452   return %CreateUint32x4(TO_NUMBER(c0), TO_NUMBER(c1), | 
| 458                          TO_NUMBER(c2), TO_NUMBER(c3)); | 453                          TO_NUMBER(c2), TO_NUMBER(c3)); | 
| 459 } | 454 } | 
| 460 | 455 | 
| 461 | 456 | 
| 462 function Bool32x4Constructor(c0, c1, c2, c3) { | 457 function Bool32x4Constructor(c0, c1, c2, c3) { | 
| 463   if (!IS_UNDEFINED(new.target)) { | 458   if (!IS_UNDEFINED(new.target)) { | 
| 464     throw MakeTypeError(kNotConstructor, "Bool32x4"); | 459     throw %make_type_error(kNotConstructor, "Bool32x4"); | 
| 465   } | 460   } | 
| 466   return %CreateBool32x4(c0, c1, c2, c3); | 461   return %CreateBool32x4(c0, c1, c2, c3); | 
| 467 } | 462 } | 
| 468 | 463 | 
| 469 | 464 | 
| 470 function Int16x8Constructor(c0, c1, c2, c3, c4, c5, c6, c7) { | 465 function Int16x8Constructor(c0, c1, c2, c3, c4, c5, c6, c7) { | 
| 471   if (!IS_UNDEFINED(new.target)) { | 466   if (!IS_UNDEFINED(new.target)) { | 
| 472     throw MakeTypeError(kNotConstructor, "Int16x8"); | 467     throw %make_type_error(kNotConstructor, "Int16x8"); | 
| 473   } | 468   } | 
| 474   return %CreateInt16x8(TO_NUMBER(c0), TO_NUMBER(c1), | 469   return %CreateInt16x8(TO_NUMBER(c0), TO_NUMBER(c1), | 
| 475                         TO_NUMBER(c2), TO_NUMBER(c3), | 470                         TO_NUMBER(c2), TO_NUMBER(c3), | 
| 476                         TO_NUMBER(c4), TO_NUMBER(c5), | 471                         TO_NUMBER(c4), TO_NUMBER(c5), | 
| 477                         TO_NUMBER(c6), TO_NUMBER(c7)); | 472                         TO_NUMBER(c6), TO_NUMBER(c7)); | 
| 478 } | 473 } | 
| 479 | 474 | 
| 480 | 475 | 
| 481 function Uint16x8Constructor(c0, c1, c2, c3, c4, c5, c6, c7) { | 476 function Uint16x8Constructor(c0, c1, c2, c3, c4, c5, c6, c7) { | 
| 482   if (!IS_UNDEFINED(new.target)) { | 477   if (!IS_UNDEFINED(new.target)) { | 
| 483     throw MakeTypeError(kNotConstructor, "Uint16x8"); | 478     throw %make_type_error(kNotConstructor, "Uint16x8"); | 
| 484   } | 479   } | 
| 485   return %CreateUint16x8(TO_NUMBER(c0), TO_NUMBER(c1), | 480   return %CreateUint16x8(TO_NUMBER(c0), TO_NUMBER(c1), | 
| 486                          TO_NUMBER(c2), TO_NUMBER(c3), | 481                          TO_NUMBER(c2), TO_NUMBER(c3), | 
| 487                          TO_NUMBER(c4), TO_NUMBER(c5), | 482                          TO_NUMBER(c4), TO_NUMBER(c5), | 
| 488                          TO_NUMBER(c6), TO_NUMBER(c7)); | 483                          TO_NUMBER(c6), TO_NUMBER(c7)); | 
| 489 } | 484 } | 
| 490 | 485 | 
| 491 | 486 | 
| 492 function Bool16x8Constructor(c0, c1, c2, c3, c4, c5, c6, c7) { | 487 function Bool16x8Constructor(c0, c1, c2, c3, c4, c5, c6, c7) { | 
| 493   if (!IS_UNDEFINED(new.target)) { | 488   if (!IS_UNDEFINED(new.target)) { | 
| 494     throw MakeTypeError(kNotConstructor, "Bool16x8"); | 489     throw %make_type_error(kNotConstructor, "Bool16x8"); | 
| 495   } | 490   } | 
| 496   return %CreateBool16x8(c0, c1, c2, c3, c4, c5, c6, c7); | 491   return %CreateBool16x8(c0, c1, c2, c3, c4, c5, c6, c7); | 
| 497 } | 492 } | 
| 498 | 493 | 
| 499 | 494 | 
| 500 function Int8x16Constructor(c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, | 495 function Int8x16Constructor(c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, | 
| 501                             c12, c13, c14, c15) { | 496                             c12, c13, c14, c15) { | 
| 502   if (!IS_UNDEFINED(new.target)) { | 497   if (!IS_UNDEFINED(new.target)) { | 
| 503     throw MakeTypeError(kNotConstructor, "Int8x16"); | 498     throw %make_type_error(kNotConstructor, "Int8x16"); | 
| 504   } | 499   } | 
| 505   return %CreateInt8x16(TO_NUMBER(c0), TO_NUMBER(c1), | 500   return %CreateInt8x16(TO_NUMBER(c0), TO_NUMBER(c1), | 
| 506                         TO_NUMBER(c2), TO_NUMBER(c3), | 501                         TO_NUMBER(c2), TO_NUMBER(c3), | 
| 507                         TO_NUMBER(c4), TO_NUMBER(c5), | 502                         TO_NUMBER(c4), TO_NUMBER(c5), | 
| 508                         TO_NUMBER(c6), TO_NUMBER(c7), | 503                         TO_NUMBER(c6), TO_NUMBER(c7), | 
| 509                         TO_NUMBER(c8), TO_NUMBER(c9), | 504                         TO_NUMBER(c8), TO_NUMBER(c9), | 
| 510                         TO_NUMBER(c10), TO_NUMBER(c11), | 505                         TO_NUMBER(c10), TO_NUMBER(c11), | 
| 511                         TO_NUMBER(c12), TO_NUMBER(c13), | 506                         TO_NUMBER(c12), TO_NUMBER(c13), | 
| 512                         TO_NUMBER(c14), TO_NUMBER(c15)); | 507                         TO_NUMBER(c14), TO_NUMBER(c15)); | 
| 513 } | 508 } | 
| 514 | 509 | 
| 515 | 510 | 
| 516 function Uint8x16Constructor(c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, | 511 function Uint8x16Constructor(c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, | 
| 517                              c12, c13, c14, c15) { | 512                              c12, c13, c14, c15) { | 
| 518   if (!IS_UNDEFINED(new.target)) { | 513   if (!IS_UNDEFINED(new.target)) { | 
| 519     throw MakeTypeError(kNotConstructor, "Uint8x16"); | 514     throw %make_type_error(kNotConstructor, "Uint8x16"); | 
| 520   } | 515   } | 
| 521   return %CreateUint8x16(TO_NUMBER(c0), TO_NUMBER(c1), | 516   return %CreateUint8x16(TO_NUMBER(c0), TO_NUMBER(c1), | 
| 522                          TO_NUMBER(c2), TO_NUMBER(c3), | 517                          TO_NUMBER(c2), TO_NUMBER(c3), | 
| 523                          TO_NUMBER(c4), TO_NUMBER(c5), | 518                          TO_NUMBER(c4), TO_NUMBER(c5), | 
| 524                          TO_NUMBER(c6), TO_NUMBER(c7), | 519                          TO_NUMBER(c6), TO_NUMBER(c7), | 
| 525                          TO_NUMBER(c8), TO_NUMBER(c9), | 520                          TO_NUMBER(c8), TO_NUMBER(c9), | 
| 526                          TO_NUMBER(c10), TO_NUMBER(c11), | 521                          TO_NUMBER(c10), TO_NUMBER(c11), | 
| 527                          TO_NUMBER(c12), TO_NUMBER(c13), | 522                          TO_NUMBER(c12), TO_NUMBER(c13), | 
| 528                          TO_NUMBER(c14), TO_NUMBER(c15)); | 523                          TO_NUMBER(c14), TO_NUMBER(c15)); | 
| 529 } | 524 } | 
| 530 | 525 | 
| 531 | 526 | 
| 532 function Bool8x16Constructor(c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, | 527 function Bool8x16Constructor(c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, | 
| 533                              c12, c13, c14, c15) { | 528                              c12, c13, c14, c15) { | 
| 534   if (!IS_UNDEFINED(new.target)) { | 529   if (!IS_UNDEFINED(new.target)) { | 
| 535     throw MakeTypeError(kNotConstructor, "Bool8x16"); | 530     throw %make_type_error(kNotConstructor, "Bool8x16"); | 
| 536   } | 531   } | 
| 537   return %CreateBool8x16(c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, | 532   return %CreateBool8x16(c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, | 
| 538                          c13, c14, c15); | 533                          c13, c14, c15); | 
| 539 } | 534 } | 
| 540 | 535 | 
| 541 | 536 | 
| 542 function Float32x4AbsJS(a) { | 537 function Float32x4AbsJS(a) { | 
| 543   return %Float32x4Abs(a); | 538   return %Float32x4Abs(a); | 
| 544 } | 539 } | 
| 545 | 540 | 
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 919   'or', Bool8x16OrJS, | 914   'or', Bool8x16OrJS, | 
| 920   'xor', Bool8x16XorJS, | 915   'xor', Bool8x16XorJS, | 
| 921   'not', Bool8x16NotJS, | 916   'not', Bool8x16NotJS, | 
| 922   'anyTrue', Bool8x16AnyTrueJS, | 917   'anyTrue', Bool8x16AnyTrueJS, | 
| 923   'allTrue', Bool8x16AllTrueJS, | 918   'allTrue', Bool8x16AllTrueJS, | 
| 924   'swizzle', Bool8x16SwizzleJS, | 919   'swizzle', Bool8x16SwizzleJS, | 
| 925   'shuffle', Bool8x16ShuffleJS, | 920   'shuffle', Bool8x16ShuffleJS, | 
| 926 ]); | 921 ]); | 
| 927 | 922 | 
| 928 }) | 923 }) | 
| OLD | NEW | 
|---|