Chromium Code Reviews| 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 var $float32x4ToString; | 5 var $float32x4ToString; |
| 6 var $int32x4ToString; | |
| 7 var $bool32x4ToString; | |
| 8 var $int16x8ToString; | |
| 9 var $bool16x8ToString; | |
| 10 var $int8x16ToString; | |
| 11 var $bool8x16ToString; | |
| 6 | 12 |
| 7 (function(global, utils) { | 13 (function(global, utils) { |
| 8 | 14 |
| 9 "use strict"; | 15 "use strict"; |
| 10 | 16 |
| 11 %CheckIsBootstrapping(); | 17 %CheckIsBootstrapping(); |
| 12 | 18 |
| 13 // ------------------------------------------------------------------- | 19 // ------------------------------------------------------------------- |
| 14 // Imports | 20 // Imports |
| 15 | 21 |
| 16 var GlobalSIMD = global.SIMD; | 22 var GlobalSIMD = global.SIMD; |
| 17 var GlobalFloat32x4 = GlobalSIMD.Float32x4; | 23 var GlobalFloat32x4 = GlobalSIMD.Float32x4; |
| 24 var GlobalInt32x4 = GlobalSIMD.Int32x4; | |
| 25 var GlobalBool32x4 = GlobalSIMD.Bool32x4; | |
| 26 var GlobalInt16x8 = GlobalSIMD.Int16x8; | |
| 27 var GlobalBool16x8 = GlobalSIMD.Bool16x8; | |
| 28 var GlobalInt8x16 = GlobalSIMD.Int8x16; | |
| 29 var GlobalBool8x16 = GlobalSIMD.Bool8x16; | |
| 18 | 30 |
| 19 //------------------------------------------------------------------- | 31 //------------------------------------------------------------------- |
| 20 | 32 |
| 21 function Float32x4Constructor(x, y, z, w) { | 33 function Float32x4Constructor(c0, c1, c2, c3) { |
| 22 if (%_IsConstructCall()) throw MakeTypeError(kNotConstructor, "Float32x4"); | 34 if (%_IsConstructCall()) throw MakeTypeError(kNotConstructor, "Float32x4"); |
| 23 if (!IS_NUMBER(x) || !IS_NUMBER(y) || !IS_NUMBER(z) || !IS_NUMBER(w)) { | 35 return %CreateFloat32x4(TO_NUMBER_INLINE(c0), TO_NUMBER_INLINE(c1), TO_NUMBER_ INLINE(c2), TO_NUMBER_INLINE(c3)); |
|
rossberg
2015/07/29 14:37:55
Nit: line length
bbudge
2015/07/30 13:46:58
Done.
| |
| 24 throw MakeTypeError(kInvalidArgument); | |
| 25 } | |
| 26 return %CreateFloat32x4(x, y, z, w); | |
| 27 } | 36 } |
| 28 | 37 |
| 29 function Float32x4Splat(s) { | 38 function Float32x4Splat(s) { |
| 30 return %CreateFloat32x4(s, s, s, s); | 39 return %CreateFloat32x4(s, s, s, s); |
| 31 } | 40 } |
| 32 | 41 |
| 33 function Float32x4CheckJS(a) { | 42 function Float32x4CheckJS(a) { |
| 34 return %Float32x4Check(a); | 43 return %Float32x4Check(a); |
| 35 } | 44 } |
| 36 | 45 |
| 37 function Float32x4ToString() { | 46 function Float32x4ToString() { |
| 38 if (!(IS_FLOAT32X4(this) || IS_FLOAT32X4_WRAPPER(this))) { | 47 if (!(IS_FLOAT32X4(this) || IS_FLOAT32X4_WRAPPER(this))) { |
| 39 throw MakeTypeError(kIncompatibleMethodReceiver, | 48 throw MakeTypeError(kIncompatibleMethodReceiver, |
| 40 "Float32x4.prototype.toString", this); | 49 "Float32x4.prototype.toString", this); |
| 41 } | 50 } |
| 42 var value = %_ValueOf(this); | 51 var value = %_ValueOf(this); |
| 43 var w = GlobalFloat32x4.extractLane(value, 0), | 52 var str = "SIMD.Float32x4("; |
| 44 x = GlobalFloat32x4.extractLane(value, 1), | 53 str += %Float32x4ExtractLane(value, 0); |
| 45 y = GlobalFloat32x4.extractLane(value, 2), | 54 for (var i = 1; i < 4; i++) { |
| 46 z = GlobalFloat32x4.extractLane(value, 3); | 55 str += ", " + %Float32x4ExtractLane(value, i); |
| 47 return "SIMD.Float32x4(" + w + ", " + x + ", " + y + ", " + z + ")"; | 56 } |
| 57 return str + ")"; | |
| 48 } | 58 } |
| 49 | 59 |
| 50 function Float32x4ToLocaleString() { | 60 function Float32x4ToLocaleString() { |
| 51 if (!(IS_FLOAT32X4(this) || IS_FLOAT32X4_WRAPPER(this))) { | 61 if (!(IS_FLOAT32X4(this) || IS_FLOAT32X4_WRAPPER(this))) { |
| 52 throw MakeTypeError(kIncompatibleMethodReceiver, | 62 throw MakeTypeError(kIncompatibleMethodReceiver, |
| 53 "Float32x4.prototype.toLocaleString", this); | 63 "Float32x4.prototype.toLocaleString", this); |
| 54 } | 64 } |
| 55 var value = %_ValueOf(this); | 65 var value = %_ValueOf(this); |
| 56 var w = GlobalFloat32x4.extractLane(value, 0).toLocaleString(), | 66 var str = "SIMD.Float32x4("; |
| 57 x = GlobalFloat32x4.extractLane(value, 1).toLocaleString(), | 67 str += %Float32x4ExtractLane(value, 0).toLocaleString(); |
| 58 y = GlobalFloat32x4.extractLane(value, 2).toLocaleString(), | 68 for (var i = 1; i < 4; i++) { |
| 59 z = GlobalFloat32x4.extractLane(value, 3).toLocaleString(); | 69 str += ", " + %Float32x4ExtractLane(value, i).toLocaleString(); |
| 60 return "SIMD.Float32x4(" + w + ", " + x + ", " + y + ", " + z + ")"; | 70 } |
| 71 return str + ")"; | |
| 61 } | 72 } |
| 62 | 73 |
| 63 function Float32x4ValueOf() { | 74 function Float32x4ValueOf() { |
| 64 if (!(IS_FLOAT32X4(this) || IS_FLOAT32X4_WRAPPER(this))) { | 75 if (!(IS_FLOAT32X4(this) || IS_FLOAT32X4_WRAPPER(this))) { |
| 65 throw MakeTypeError(kIncompatibleMethodReceiver, | 76 throw MakeTypeError(kIncompatibleMethodReceiver, |
| 66 "Float32x4.prototype.valueOf", this); | 77 "Float32x4.prototype.valueOf", this); |
| 67 } | 78 } |
| 68 return %_ValueOf(this); | 79 return %_ValueOf(this); |
| 69 } | 80 } |
| 70 | 81 |
| 71 //------------------------------------------------------------------- | 82 function Float32x4ExtractLaneJS(a, lane) { |
| 72 | 83 return %Float32x4ExtractLane(a, lane); |
| 73 function Float32x4ExtractLaneJS(value, lane) { | 84 } |
| 74 return %Float32x4ExtractLane(value, lane); | 85 |
| 86 function Float32x4ReplaceLaneJS(a, lane, value) { | |
| 87 return %Float32x4ReplaceLane(a, lane, TO_NUMBER_INLINE(value)); | |
| 88 } | |
| 89 | |
| 90 //------------------------------------------------------------------- | |
|
rossberg
2015/07/29 14:37:55
Would it be possible to avoid all the repetition b
bbudge
2015/07/30 13:46:58
Macros in JS? I didn't know! Done.
| |
| 91 | |
| 92 function Int32x4Constructor(c0, c1, c2, c3) { | |
| 93 if (%_IsConstructCall()) throw MakeTypeError(kNotConstructor, "Int32x4"); | |
| 94 return %CreateInt32x4(TO_NUMBER_INLINE(c0), TO_NUMBER_INLINE(c1), | |
| 95 TO_NUMBER_INLINE(c2), TO_NUMBER_INLINE(c3)); | |
| 96 } | |
| 97 | |
| 98 function Int32x4Splat(s) { | |
| 99 return %CreateInt32x4(s, s, s, s); | |
| 100 } | |
| 101 | |
| 102 function Int32x4CheckJS(a) { | |
| 103 return %Int32x4Check(a); | |
| 104 } | |
| 105 | |
| 106 function Int32x4ToString() { | |
| 107 if (!(IS_INT32X4(this) || IS_INT32X4_WRAPPER(this))) { | |
| 108 throw MakeTypeError(kIncompatibleMethodReceiver, | |
| 109 "Int32x4.prototype.toString", this); | |
| 110 } | |
| 111 var value = %_ValueOf(this); | |
| 112 var str = "SIMD.Int32x4("; | |
| 113 str += %Int32x4ExtractLane(value, 0); | |
| 114 for (var i = 1; i < 4; i++) { | |
| 115 str += ", " + %Int32x4ExtractLane(value, i); | |
| 116 } | |
| 117 return str + ")"; | |
| 118 } | |
| 119 | |
| 120 function Int32x4ToLocaleString() { | |
| 121 if (!(IS_INT32X4(this) || IS_INT32X4_WRAPPER(this))) { | |
| 122 throw MakeTypeError(kIncompatibleMethodReceiver, | |
| 123 "Int32x4.prototype.toLocaleString", this); | |
| 124 } | |
| 125 var value = %_ValueOf(this); | |
| 126 var str = "SIMD.Int32x4("; | |
| 127 str += %Int32x4ExtractLane(value, 0).toLocaleString(); | |
| 128 for (var i = 1; i < 4; i++) { | |
| 129 str += ", " + %Int32x4ExtractLane(value, i).toLocaleString(); | |
| 130 } | |
| 131 return str + ")"; | |
| 132 } | |
| 133 | |
| 134 function Int32x4ValueOf() { | |
| 135 if (!(IS_INT32X4(this) || IS_INT32X4_WRAPPER(this))) { | |
| 136 throw MakeTypeError(kIncompatibleMethodReceiver, | |
| 137 "Int32x4.prototype.valueOf", this); | |
| 138 } | |
| 139 return %_ValueOf(this); | |
| 140 } | |
| 141 | |
| 142 function Int32x4ExtractLaneJS(a, lane) { | |
| 143 return %Int32x4ExtractLane(a, lane); | |
| 144 } | |
| 145 | |
| 146 function Int32x4ReplaceLaneJS(a, lane, value) { | |
| 147 return %Int32x4ReplaceLane(a, lane, TO_NUMBER_INLINE(value)); | |
| 148 } | |
| 149 | |
| 150 //------------------------------------------------------------------- | |
| 151 | |
| 152 function Bool32x4Constructor(c0, c1, c2, c3) { | |
| 153 if (%_IsConstructCall()) throw MakeTypeError(kNotConstructor, "Bool32x4"); | |
| 154 return %CreateBool32x4(c0, c1, c2, c3); | |
| 155 } | |
| 156 | |
| 157 function Bool32x4Splat(s) { | |
| 158 return %CreateBool32x4(s, s, s, s); | |
| 159 } | |
| 160 | |
| 161 function Bool32x4CheckJS(a) { | |
| 162 return %Bool32x4Check(a); | |
| 163 } | |
| 164 | |
| 165 function Bool32x4ToString() { | |
| 166 if (!(IS_BOOL32X4(this) || IS_BOOL32X4_WRAPPER(this))) { | |
| 167 throw MakeTypeError(kIncompatibleMethodReceiver, | |
| 168 "Bool32x4.prototype.toString", this); | |
| 169 } | |
| 170 var value = %_ValueOf(this); | |
| 171 var str = "SIMD.Bool32x4("; | |
| 172 str += %Bool32x4ExtractLane(value, 0); | |
| 173 for (var i = 1; i < 4; i++) { | |
| 174 str += ", " + %Bool32x4ExtractLane(value, i); | |
| 175 } | |
| 176 return str + ")"; | |
| 177 } | |
| 178 | |
| 179 function Bool32x4ToLocaleString() { | |
| 180 if (!(IS_BOOL32X4(this) || IS_BOOL32X4_WRAPPER(this))) { | |
| 181 throw MakeTypeError(kIncompatibleMethodReceiver, | |
| 182 "Bool32x4.prototype.toLocaleString", this); | |
| 183 } | |
| 184 var value = %_ValueOf(this); | |
| 185 var str = "SIMD.Bool32x4("; | |
| 186 str += %Bool32x4ExtractLane(value, 0).toLocaleString(); | |
| 187 for (var i = 1; i < 4; i++) { | |
| 188 str += ", " + %Bool32x4ExtractLane(value, i).toLocaleString(); | |
| 189 } | |
| 190 return str + ")"; | |
| 191 } | |
| 192 | |
| 193 function Bool32x4ValueOf() { | |
| 194 if (!(IS_BOOL32X4(this) || IS_BOOL32X4_WRAPPER(this))) { | |
| 195 throw MakeTypeError(kIncompatibleMethodReceiver, | |
| 196 "Bool32x4.prototype.valueOf", this); | |
| 197 } | |
| 198 return %_ValueOf(this); | |
| 199 } | |
| 200 | |
| 201 function Bool32x4ExtractLaneJS(a, lane) { | |
| 202 return %Bool32x4ExtractLane(a, lane); | |
| 203 } | |
| 204 | |
| 205 function Bool32x4ReplaceLaneJS(a, lane, value) { | |
| 206 return %Bool32x4ReplaceLane(a, lane, value); | |
| 207 } | |
| 208 | |
| 209 //------------------------------------------------------------------- | |
| 210 | |
| 211 function Int16x8Constructor(c0, c1, c2, c3, c4, c5, c6, c7) { | |
| 212 if (%_IsConstructCall()) throw MakeTypeError(kNotConstructor, "Int16x8"); | |
| 213 return %CreateInt16x8(TO_NUMBER_INLINE(c0), TO_NUMBER_INLINE(c1), | |
| 214 TO_NUMBER_INLINE(c2), TO_NUMBER_INLINE(c3), | |
| 215 TO_NUMBER_INLINE(c4), TO_NUMBER_INLINE(c5), | |
| 216 TO_NUMBER_INLINE(c6), TO_NUMBER_INLINE(c7)); | |
| 217 } | |
| 218 | |
| 219 function Int16x8Splat(s) { | |
| 220 return %CreateInt16x8(s, s, s, s, s, s, s, s); | |
| 221 } | |
| 222 | |
| 223 function Int16x8CheckJS(a) { | |
| 224 return %Int16x8Check(a); | |
| 225 } | |
| 226 | |
| 227 function Int16x8ToString() { | |
| 228 if (!(IS_INT16X8(this) || IS_INT16X8_WRAPPER(this))) { | |
| 229 throw MakeTypeError(kIncompatibleMethodReceiver, | |
| 230 "Int16x8.prototype.toString", this); | |
| 231 } | |
| 232 var value = %_ValueOf(this); | |
| 233 var str = "SIMD.Int16x8("; | |
| 234 str += %Int16x8ExtractLane(value, 0); | |
| 235 for (var i = 1; i < 8; i++) { | |
| 236 str += ", " + %Int16x8ExtractLane(value, i); | |
| 237 } | |
| 238 return str + ")"; | |
| 239 } | |
| 240 | |
| 241 function Int16x8ToLocaleString() { | |
| 242 if (!(IS_INT16X8(this) || IS_INT16X8_WRAPPER(this))) { | |
| 243 throw MakeTypeError(kIncompatibleMethodReceiver, | |
| 244 "Int16x8.prototype.toLocaleString", this); | |
| 245 } | |
| 246 var value = %_ValueOf(this); | |
| 247 var str = "SIMD.Int16x8("; | |
| 248 str += %Int16x8ExtractLane(value, 0).toLocaleString(); | |
| 249 for (var i = 1; i < 8; i++) { | |
| 250 str += ", " + %Int16x8ExtractLane(value, i).toLocaleString(); | |
| 251 } | |
| 252 return str + ")"; | |
| 253 } | |
| 254 | |
| 255 function Int16x8ValueOf() { | |
| 256 if (!(IS_INT16X8(this) || IS_INT16X8_WRAPPER(this))) { | |
| 257 throw MakeTypeError(kIncompatibleMethodReceiver, | |
| 258 "Int16x8.prototype.valueOf", this); | |
| 259 } | |
| 260 return %_ValueOf(this); | |
| 261 } | |
| 262 | |
| 263 function Int16x8ExtractLaneJS(a, lane) { | |
| 264 return %Int16x8ExtractLane(a, lane); | |
| 265 } | |
| 266 | |
| 267 function Int16x8UnsignedExtractLaneJS(a, lane) { | |
| 268 return %Int16x8UnsignedExtractLane(a, lane); | |
| 269 } | |
| 270 | |
| 271 function Int16x8ReplaceLaneJS(a, lane, value) { | |
| 272 return %Int16x8ReplaceLane(a, lane, TO_NUMBER_INLINE(value)); | |
| 273 } | |
| 274 | |
| 275 //------------------------------------------------------------------- | |
| 276 | |
| 277 function Bool16x8Constructor(c0, c1, c2, c3, c4, c5, c6, c7) { | |
| 278 if (%_IsConstructCall()) throw MakeTypeError(kNotConstructor, "Bool16x8"); | |
| 279 return %CreateBool16x8(c0, c1, c2, c3, c4, c5, c6, c7); | |
| 280 } | |
| 281 | |
| 282 function Bool16x8Splat(s) { | |
| 283 return %CreateBool16x8(s, s, s, s, s, s, s, s); | |
| 284 } | |
| 285 | |
| 286 function Bool16x8CheckJS(a) { | |
| 287 return %Bool16x8Check(a); | |
| 288 } | |
| 289 | |
| 290 function Bool16x8ToString() { | |
| 291 if (!(IS_BOOL16X8(this) || IS_BOOL16X8_WRAPPER(this))) { | |
| 292 throw MakeTypeError(kIncompatibleMethodReceiver, | |
| 293 "Bool16x8.prototype.toString", this); | |
| 294 } | |
| 295 var value = %_ValueOf(this); | |
| 296 var str = "SIMD.Bool16x8("; | |
| 297 str += %Bool16x8ExtractLane(value, 0); | |
| 298 for (var i = 1; i < 8; i++) { | |
| 299 str += ", " + %Bool16x8ExtractLane(value, i); | |
| 300 } | |
| 301 return str + ")"; | |
| 302 } | |
| 303 | |
| 304 function Bool16x8ToLocaleString() { | |
| 305 if (!(IS_BOOL16X8(this) || IS_BOOL16X8_WRAPPER(this))) { | |
| 306 throw MakeTypeError(kIncompatibleMethodReceiver, | |
| 307 "Bool16x8.prototype.toLocaleString", this); | |
| 308 } | |
| 309 var value = %_ValueOf(this); | |
| 310 var str = "SIMD.Bool16x8("; | |
| 311 str += %Bool16x8ExtractLane(value, 0).toLocaleString(); | |
| 312 for (var i = 1; i < 8; i++) { | |
| 313 str += ", " + %Bool16x8ExtractLane(value, i).toLocaleString(); | |
| 314 } | |
| 315 return str + ")"; | |
| 316 } | |
| 317 | |
| 318 function Bool16x8ValueOf() { | |
| 319 if (!(IS_BOOL16X8(this) || IS_BOOL16X8_WRAPPER(this))) { | |
| 320 throw MakeTypeError(kIncompatibleMethodReceiver, | |
| 321 "Bool16x8.prototype.valueOf", this); | |
| 322 } | |
| 323 return %_ValueOf(this); | |
| 324 } | |
| 325 | |
| 326 function Bool16x8ExtractLaneJS(a, lane) { | |
| 327 return %Bool16x8ExtractLane(a, lane); | |
| 328 } | |
| 329 | |
| 330 function Bool16x8ReplaceLaneJS(a, lane, value) { | |
| 331 return %Bool16x8ReplaceLane(a, lane, value); | |
| 332 } | |
| 333 | |
| 334 //------------------------------------------------------------------- | |
| 335 | |
| 336 function Int8x16Constructor(c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, | |
| 337 c12, c13, c14, c15) { | |
| 338 if (%_IsConstructCall()) throw MakeTypeError(kNotConstructor, "Int8x16"); | |
| 339 return %CreateInt8x16(TO_NUMBER_INLINE(c0), TO_NUMBER_INLINE(c1), TO_NUMBER_IN LINE(c2), TO_NUMBER_INLINE(c3), | |
| 340 TO_NUMBER_INLINE(c4), TO_NUMBER_INLINE(c5), TO_NUMBER_INLINE(c6), TO_NUMBE R_INLINE(c7), | |
| 341 TO_NUMBER_INLINE(c8), TO_NUMBER_INLINE(c9), TO_NUMBER_INLINE(c10), TO_NUMB ER_INLINE(c11), | |
| 342 TO_NUMBER_INLINE(c12), TO_NUMBER_INLINE(c13), TO_NUMBER_INLINE(c14), TO_NU MBER_INLINE(c15)); | |
| 343 } | |
| 344 | |
| 345 function Int8x16Splat(s) { | |
| 346 return %CreateInt8x16(s, s, s, s, s, s, s, s, s, s, s, s, s, s, s, s); | |
| 347 } | |
| 348 | |
| 349 function Int8x16CheckJS(a) { | |
| 350 return %Int8x16Check(a); | |
| 351 } | |
| 352 | |
| 353 function Int8x16ToString() { | |
| 354 if (!(IS_INT8X16(this) || IS_INT8X16_WRAPPER(this))) { | |
| 355 throw MakeTypeError(kIncompatibleMethodReceiver, | |
| 356 "Int8x16.prototype.toString", this); | |
| 357 } | |
| 358 var value = %_ValueOf(this); | |
| 359 var str = "SIMD.Int8x16("; | |
| 360 str += %Int8x16ExtractLane(value, 0); | |
| 361 for (var i = 1; i < 16; i++) { | |
| 362 str += ", " + %Int8x16ExtractLane(value, i); | |
| 363 } | |
| 364 return str + ")"; | |
| 365 } | |
| 366 | |
| 367 function Int8x16ToLocaleString() { | |
| 368 if (!(IS_INT8X16(this) || IS_INT8X16_WRAPPER(this))) { | |
| 369 throw MakeTypeError(kIncompatibleMethodReceiver, | |
| 370 "Int8x16.prototype.toLocaleString", this); | |
| 371 } | |
| 372 var value = %_ValueOf(this); | |
| 373 var str = "SIMD.Int8x16("; | |
| 374 str += %Int8x16ExtractLane(value, 0).toLocaleString(); | |
| 375 for (var i = 1; i < 16; i++) { | |
| 376 str += ", " + %Int8x16ExtractLane(value, i).toLocaleString(); | |
| 377 } | |
| 378 return str + ")"; | |
| 379 } | |
| 380 | |
| 381 function Int8x16ValueOf() { | |
| 382 if (!(IS_INT8X16(this) || IS_INT8X16_WRAPPER(this))) { | |
| 383 throw MakeTypeError(kIncompatibleMethodReceiver, | |
| 384 "Int8x16.prototype.valueOf", this); | |
| 385 } | |
| 386 return %_ValueOf(this); | |
| 387 } | |
| 388 | |
| 389 function Int8x16ExtractLaneJS(a, lane) { | |
| 390 return %Int8x16ExtractLane(a, lane); | |
| 391 } | |
| 392 | |
| 393 function Int8x16UnsignedExtractLaneJS(a, lane) { | |
| 394 return %Int8x16UnsignedExtractLane(a, lane); | |
| 395 } | |
| 396 | |
| 397 function Int8x16ReplaceLaneJS(a, lane, value) { | |
| 398 return %Int8x16ReplaceLane(a, lane, TO_NUMBER_INLINE(value)); | |
| 399 } | |
| 400 | |
| 401 //------------------------------------------------------------------- | |
| 402 | |
| 403 function Bool8x16Constructor(c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, | |
| 404 c12, c13, c14, c15) { | |
| 405 if (%_IsConstructCall()) throw MakeTypeError(kNotConstructor, "Bool8x16"); | |
| 406 return %CreateBool8x16(c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, | |
| 407 c13, c14, c15); | |
| 408 } | |
| 409 | |
| 410 function Bool8x16Splat(s) { | |
| 411 return %CreateBool8x16(s, s, s, s, s, s, s, s, s, s, s, s, s, s, s, s); | |
| 412 } | |
| 413 | |
| 414 function Bool8x16CheckJS(a) { | |
| 415 return %Bool8x16Check(a); | |
| 416 } | |
| 417 | |
| 418 function Bool8x16ToString() { | |
| 419 if (!(IS_BOOL8X16(this) || IS_BOOL8X16_WRAPPER(this))) { | |
| 420 throw MakeTypeError(kIncompatibleMethodReceiver, | |
| 421 "Bool8x16.prototype.toString", this); | |
| 422 } | |
| 423 var value = %_ValueOf(this); | |
| 424 var str = "SIMD.Bool8x16("; | |
| 425 str += %Bool8x16ExtractLane(value, 0); | |
| 426 for (var i = 1; i < 16; i++) { | |
| 427 str += ", " + %Bool8x16ExtractLane(value, i); | |
| 428 } | |
| 429 return str + ")"; | |
| 430 } | |
| 431 | |
| 432 function Bool8x16ToLocaleString() { | |
| 433 if (!(IS_BOOL8X16(this) || IS_BOOL8X16_WRAPPER(this))) { | |
| 434 throw MakeTypeError(kIncompatibleMethodReceiver, | |
| 435 "Bool8x16.prototype.toString", this); | |
| 436 } | |
| 437 var value = %_ValueOf(this); | |
| 438 var str = "SIMD.Bool8x16("; | |
| 439 str += %Bool8x16ExtractLane(value, 0).toLocaleString(); | |
| 440 for (var i = 1; i < 16; i++) { | |
| 441 str += ", " + %Bool8x16ExtractLane(value, i).toLocaleString(); | |
| 442 } | |
| 443 return str + ")"; | |
| 444 } | |
| 445 | |
| 446 function Bool8x16ValueOf() { | |
| 447 if (!(IS_BOOL8X16(this) || IS_BOOL8X16_WRAPPER(this))) { | |
| 448 throw MakeTypeError(kIncompatibleMethodReceiver, | |
| 449 "Bool8x16.prototype.valueOf", this); | |
| 450 } | |
| 451 return %_ValueOf(this); | |
| 452 } | |
| 453 | |
| 454 function Bool8x16ExtractLaneJS(a, lane) { | |
| 455 return %Bool8x16ExtractLane(a, lane); | |
| 456 } | |
| 457 | |
| 458 function Bool8x16ReplaceLaneJS(a, lane, value) { | |
| 459 return %Bool8x16ReplaceLane(a, lane, value); | |
| 75 } | 460 } |
| 76 | 461 |
| 77 // ------------------------------------------------------------------- | 462 // ------------------------------------------------------------------- |
| 78 | 463 |
| 79 %AddNamedProperty(GlobalSIMD, symbolToStringTag, 'SIMD', READ_ONLY | DONT_ENUM); | 464 %AddNamedProperty(GlobalSIMD, symbolToStringTag, 'SIMD', READ_ONLY | DONT_ENUM); |
| 80 | 465 |
| 81 %SetCode(GlobalFloat32x4, Float32x4Constructor); | 466 %SetCode(GlobalFloat32x4, Float32x4Constructor); |
| 467 %SetCode(GlobalInt32x4, Int32x4Constructor); | |
| 468 %SetCode(GlobalBool32x4, Bool32x4Constructor); | |
| 469 %SetCode(GlobalInt16x8, Int16x8Constructor); | |
| 470 %SetCode(GlobalBool16x8, Bool16x8Constructor); | |
| 471 %SetCode(GlobalInt8x16, Int8x16Constructor); | |
| 472 %SetCode(GlobalBool8x16, Bool8x16Constructor); | |
| 82 %FunctionSetPrototype(GlobalFloat32x4, {}); | 473 %FunctionSetPrototype(GlobalFloat32x4, {}); |
| 83 %AddNamedProperty( | 474 %FunctionSetPrototype(GlobalInt32x4, {}); |
| 84 GlobalFloat32x4.prototype, 'constructor', GlobalFloat32x4, DONT_ENUM); | 475 %FunctionSetPrototype(GlobalBool32x4, {}); |
| 85 %AddNamedProperty( | 476 %FunctionSetPrototype(GlobalInt16x8, {}); |
| 86 GlobalFloat32x4.prototype, symbolToStringTag, 'Float32x4', | 477 %FunctionSetPrototype(GlobalBool16x8, {}); |
| 478 %FunctionSetPrototype(GlobalInt8x16, {}); | |
| 479 %FunctionSetPrototype(GlobalBool8x16, {}); | |
| 480 %AddNamedProperty(GlobalFloat32x4.prototype, 'constructor', GlobalFloat32x4, | |
| 481 DONT_ENUM); | |
| 482 %AddNamedProperty(GlobalInt32x4.prototype, 'constructor', GlobalInt32x4, | |
| 483 DONT_ENUM); | |
| 484 %AddNamedProperty(GlobalBool32x4.prototype, 'constructor', GlobalBool32x4, | |
| 485 DONT_ENUM); | |
| 486 %AddNamedProperty(GlobalInt16x8.prototype, 'constructor', GlobalInt16x8, | |
| 487 DONT_ENUM); | |
| 488 %AddNamedProperty(GlobalBool16x8.prototype, 'constructor', GlobalBool16x8, | |
| 489 DONT_ENUM); | |
| 490 %AddNamedProperty(GlobalInt8x16.prototype, 'constructor', GlobalInt8x16, | |
| 491 DONT_ENUM); | |
| 492 %AddNamedProperty(GlobalBool8x16.prototype, 'constructor', GlobalBool8x16, | |
| 493 DONT_ENUM); | |
| 494 %AddNamedProperty(GlobalFloat32x4.prototype, symbolToStringTag, 'Float32x4', | |
| 495 DONT_ENUM | READ_ONLY); | |
| 496 %AddNamedProperty(GlobalInt32x4.prototype, symbolToStringTag, 'Int32x4', | |
| 497 DONT_ENUM | READ_ONLY); | |
| 498 %AddNamedProperty(GlobalBool32x4.prototype, symbolToStringTag, 'Bool32x4', | |
| 499 DONT_ENUM | READ_ONLY); | |
| 500 %AddNamedProperty(GlobalInt16x8.prototype, symbolToStringTag, 'Int16x8', | |
| 501 DONT_ENUM | READ_ONLY); | |
| 502 %AddNamedProperty(GlobalBool16x8.prototype, symbolToStringTag, 'Bool16x8', | |
| 503 DONT_ENUM | READ_ONLY); | |
| 504 %AddNamedProperty(GlobalInt8x16.prototype, symbolToStringTag, 'Int8x16', | |
| 505 DONT_ENUM | READ_ONLY); | |
| 506 %AddNamedProperty(GlobalBool8x16.prototype, symbolToStringTag, 'Bool8x16', | |
| 87 DONT_ENUM | READ_ONLY); | 507 DONT_ENUM | READ_ONLY); |
| 88 | 508 |
| 89 utils.InstallFunctions(GlobalFloat32x4.prototype, DONT_ENUM, [ | 509 utils.InstallFunctions(GlobalFloat32x4.prototype, DONT_ENUM, [ |
| 90 'toLocaleString', Float32x4ToLocaleString, | 510 'toLocaleString', Float32x4ToLocaleString, |
| 91 'toString', Float32x4ToString, | 511 'toString', Float32x4ToString, |
| 92 'valueOf', Float32x4ValueOf, | 512 'valueOf', Float32x4ValueOf, |
| 93 ]); | 513 ]); |
| 94 | 514 |
| 515 utils.InstallFunctions(GlobalInt32x4.prototype, DONT_ENUM, [ | |
| 516 'toLocaleString', Int32x4ToLocaleString, | |
| 517 'toString', Int32x4ToString, | |
| 518 'valueOf', Int32x4ValueOf, | |
| 519 ]); | |
| 520 | |
| 521 utils.InstallFunctions(GlobalBool32x4.prototype, DONT_ENUM, [ | |
| 522 'toLocaleString', Bool32x4ToLocaleString, | |
| 523 'toString', Bool32x4ToString, | |
| 524 'valueOf', Bool32x4ValueOf, | |
| 525 ]); | |
| 526 | |
| 527 utils.InstallFunctions(GlobalInt16x8.prototype, DONT_ENUM, [ | |
| 528 'toLocaleString', Int16x8ToLocaleString, | |
| 529 'toString', Int16x8ToString, | |
| 530 'valueOf', Int16x8ValueOf, | |
| 531 ]); | |
| 532 | |
| 533 utils.InstallFunctions(GlobalBool16x8.prototype, DONT_ENUM, [ | |
| 534 'toLocaleString', Bool16x8ToLocaleString, | |
| 535 'toString', Bool16x8ToString, | |
| 536 'valueOf', Bool16x8ValueOf, | |
| 537 ]); | |
| 538 | |
| 539 utils.InstallFunctions(GlobalInt8x16.prototype, DONT_ENUM, [ | |
| 540 'toLocaleString', Int8x16ToLocaleString, | |
| 541 'toString', Int8x16ToString, | |
| 542 'valueOf', Int8x16ValueOf, | |
| 543 ]); | |
| 544 | |
| 545 utils.InstallFunctions(GlobalBool8x16.prototype, DONT_ENUM, [ | |
| 546 'toLocaleString', Bool8x16ToLocaleString, | |
| 547 'toString', Bool8x16ToString, | |
| 548 'valueOf', Bool8x16ValueOf, | |
| 549 ]); | |
| 550 | |
| 95 utils.InstallFunctions(GlobalFloat32x4, DONT_ENUM, [ | 551 utils.InstallFunctions(GlobalFloat32x4, DONT_ENUM, [ |
| 96 'splat', Float32x4Splat, | 552 'splat', Float32x4Splat, |
| 97 'check', Float32x4CheckJS, | 553 'check', Float32x4CheckJS, |
| 98 'extractLane', Float32x4ExtractLaneJS, | 554 'extractLane', Float32x4ExtractLaneJS, |
| 555 'replaceLane', Float32x4ReplaceLaneJS, | |
| 556 ]); | |
| 557 | |
| 558 utils.InstallFunctions(GlobalInt32x4, DONT_ENUM, [ | |
| 559 'splat', Int32x4Splat, | |
| 560 'check', Int32x4CheckJS, | |
| 561 'extractLane', Int32x4ExtractLaneJS, | |
| 562 'replaceLane', Int32x4ReplaceLaneJS, | |
| 563 ]); | |
| 564 | |
| 565 utils.InstallFunctions(GlobalBool32x4, DONT_ENUM, [ | |
| 566 'splat', Bool32x4Splat, | |
| 567 'check', Bool32x4CheckJS, | |
| 568 'extractLane', Bool32x4ExtractLaneJS, | |
| 569 'replaceLane', Bool32x4ReplaceLaneJS, | |
| 570 ]); | |
| 571 | |
| 572 utils.InstallFunctions(GlobalInt16x8, DONT_ENUM, [ | |
| 573 'splat', Int16x8Splat, | |
| 574 'check', Int16x8CheckJS, | |
| 575 'extractLane', Int16x8ExtractLaneJS, | |
| 576 'unsignedExtractLane', Int16x8UnsignedExtractLaneJS, | |
| 577 'replaceLane', Int16x8ReplaceLaneJS, | |
| 578 ]); | |
| 579 | |
| 580 utils.InstallFunctions(GlobalBool16x8, DONT_ENUM, [ | |
| 581 'splat', Bool16x8Splat, | |
| 582 'check', Bool16x8CheckJS, | |
| 583 'extractLane', Bool16x8ExtractLaneJS, | |
| 584 'replaceLane', Bool16x8ReplaceLaneJS, | |
| 585 ]); | |
| 586 | |
| 587 utils.InstallFunctions(GlobalInt8x16, DONT_ENUM, [ | |
| 588 'splat', Int8x16Splat, | |
| 589 'check', Int8x16CheckJS, | |
| 590 'extractLane', Int8x16ExtractLaneJS, | |
| 591 'unsignedExtractLane', Int8x16UnsignedExtractLaneJS, | |
| 592 'replaceLane', Int8x16ReplaceLaneJS, | |
| 593 ]); | |
| 594 | |
| 595 utils.InstallFunctions(GlobalBool8x16, DONT_ENUM, [ | |
| 596 'splat', Bool8x16Splat, | |
| 597 'check', Bool8x16CheckJS, | |
| 598 'extractLane', Bool8x16ExtractLaneJS, | |
| 599 'replaceLane', Bool8x16ReplaceLaneJS, | |
| 99 ]); | 600 ]); |
| 100 | 601 |
| 101 $float32x4ToString = Float32x4ToString; | 602 $float32x4ToString = Float32x4ToString; |
| 603 $int32x4ToString = Int32x4ToString; | |
| 604 $bool32x4ToString = Bool32x4ToString; | |
| 605 $int16x8ToString = Int16x8ToString; | |
| 606 $bool16x8ToString = Bool16x8ToString; | |
| 607 $int8x16ToString = Int8x16ToString; | |
| 608 $bool8x16ToString = Bool8x16ToString; | |
| 102 | 609 |
| 103 }) | 610 }) |
| OLD | NEW |