OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 (function(global, utils) { | |
6 | |
7 "use strict"; | |
8 | |
9 %CheckIsBootstrapping(); | |
10 | |
11 // ------------------------------------------------------------------- | |
12 // Imports | |
13 | |
14 var GlobalSIMD = global.SIMD; | |
15 var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol"); | |
16 | |
17 macro SIMD_FLOAT_TYPES(FUNCTION) | |
18 FUNCTION(Float32x4, float32x4, 4) | |
19 endmacro | |
20 | |
21 macro SIMD_INT_TYPES(FUNCTION) | |
22 FUNCTION(Int32x4, int32x4, 4) | |
23 FUNCTION(Int16x8, int16x8, 8) | |
24 FUNCTION(Int8x16, int8x16, 16) | |
25 endmacro | |
26 | |
27 macro SIMD_UINT_TYPES(FUNCTION) | |
28 FUNCTION(Uint32x4, uint32x4, 4) | |
29 FUNCTION(Uint16x8, uint16x8, 8) | |
30 FUNCTION(Uint8x16, uint8x16, 16) | |
31 endmacro | |
32 | |
33 macro SIMD_BOOL_TYPES(FUNCTION) | |
34 FUNCTION(Bool32x4, bool32x4, 4) | |
35 FUNCTION(Bool16x8, bool16x8, 8) | |
36 FUNCTION(Bool8x16, bool8x16, 16) | |
37 endmacro | |
38 | |
39 macro SIMD_ALL_TYPES(FUNCTION) | |
40 SIMD_FLOAT_TYPES(FUNCTION) | |
41 SIMD_INT_TYPES(FUNCTION) | |
42 SIMD_UINT_TYPES(FUNCTION) | |
43 SIMD_BOOL_TYPES(FUNCTION) | |
44 endmacro | |
45 | |
46 macro DECLARE_GLOBALS(NAME, TYPE, LANES) | |
47 var GlobalNAME = GlobalSIMD.NAME; | |
48 endmacro | |
49 | |
50 SIMD_ALL_TYPES(DECLARE_GLOBALS) | |
51 | |
52 macro DECLARE_COMMON_FUNCTIONS(NAME, TYPE, LANES) | |
53 function NAMECheckJS(a) { | |
54 return %NAMECheck(a); | |
55 } | |
56 | |
57 function NAMEToString() { | |
58 if (typeof(this) !== 'TYPE' && %_ClassOf(this) !== 'NAME') { | |
59 throw MakeTypeError(kIncompatibleMethodReceiver, | |
60 "NAME.prototype.toString", this); | |
61 } | |
62 var value = %_ValueOf(this); | |
63 var str = "SIMD.NAME("; | |
64 str += %NAMEExtractLane(value, 0); | |
65 for (var i = 1; i < LANES; i++) { | |
66 str += ", " + %NAMEExtractLane(value, i); | |
67 } | |
68 return str + ")"; | |
69 } | |
70 | |
71 function NAMEToLocaleString() { | |
72 if (typeof(this) !== 'TYPE' && %_ClassOf(this) !== 'NAME') { | |
73 throw MakeTypeError(kIncompatibleMethodReceiver, | |
74 "NAME.prototype.toLocaleString", this); | |
75 } | |
76 var value = %_ValueOf(this); | |
77 var str = "SIMD.NAME("; | |
78 str += %NAMEExtractLane(value, 0).toLocaleString(); | |
79 for (var i = 1; i < LANES; i++) { | |
80 str += ", " + %NAMEExtractLane(value, i).toLocaleString(); | |
81 } | |
82 return str + ")"; | |
83 } | |
84 | |
85 function NAMEValueOf() { | |
86 if (typeof(this) !== 'TYPE' && %_ClassOf(this) !== 'NAME') { | |
87 throw MakeTypeError(kIncompatibleMethodReceiver, | |
88 "NAME.prototype.valueOf", this); | |
89 } | |
90 return %_ValueOf(this); | |
91 } | |
92 | |
93 function NAMEExtractLaneJS(instance, lane) { | |
94 return %NAMEExtractLane(instance, lane); | |
95 } | |
96 endmacro | |
97 | |
98 SIMD_ALL_TYPES(DECLARE_COMMON_FUNCTIONS) | |
99 | |
100 macro DECLARE_SHIFT_FUNCTIONS(NAME, TYPE, LANES) | |
101 function NAMEShiftLeftByScalarJS(instance, shift) { | |
102 return %NAMEShiftLeftByScalar(instance, shift); | |
103 } | |
104 | |
105 function NAMEShiftRightByScalarJS(instance, shift) { | |
106 return %NAMEShiftRightByScalar(instance, shift); | |
107 } | |
108 endmacro | |
109 | |
110 SIMD_INT_TYPES(DECLARE_SHIFT_FUNCTIONS) | |
111 SIMD_UINT_TYPES(DECLARE_SHIFT_FUNCTIONS) | |
112 | |
113 macro SIMD_SMALL_INT_TYPES(FUNCTION) | |
114 FUNCTION(Int16x8) | |
115 FUNCTION(Int8x16) | |
116 FUNCTION(Uint8x16) | |
117 FUNCTION(Uint16x8) | |
118 endmacro | |
119 | |
120 macro DECLARE_SMALL_INT_FUNCTIONS(NAME) | |
121 function NAMEAddSaturateJS(a, b) { | |
122 return %NAMEAddSaturate(a, b); | |
123 } | |
124 | |
125 function NAMESubSaturateJS(a, b) { | |
126 return %NAMESubSaturate(a, b); | |
127 } | |
128 endmacro | |
129 | |
130 SIMD_SMALL_INT_TYPES(DECLARE_SMALL_INT_FUNCTIONS) | |
131 | |
132 macro DECLARE_SIGNED_FUNCTIONS(NAME, TYPE, LANES) | |
133 function NAMENegJS(a) { | |
134 return %NAMENeg(a); | |
135 } | |
136 endmacro | |
137 | |
138 SIMD_FLOAT_TYPES(DECLARE_SIGNED_FUNCTIONS) | |
139 SIMD_INT_TYPES(DECLARE_SIGNED_FUNCTIONS) | |
140 | |
141 macro DECLARE_BOOL_FUNCTIONS(NAME, TYPE, LANES) | |
142 function NAMEReplaceLaneJS(instance, lane, value) { | |
143 return %NAMEReplaceLane(instance, lane, value); | |
144 } | |
145 | |
146 function NAMEAnyTrueJS(s) { | |
147 return %NAMEAnyTrue(s); | |
148 } | |
149 | |
150 function NAMEAllTrueJS(s) { | |
151 return %NAMEAllTrue(s); | |
152 } | |
153 endmacro | |
154 | |
155 SIMD_BOOL_TYPES(DECLARE_BOOL_FUNCTIONS) | |
156 | |
157 macro SIMD_NUMERIC_TYPES(FUNCTION) | |
158 SIMD_FLOAT_TYPES(FUNCTION) | |
159 SIMD_INT_TYPES(FUNCTION) | |
160 SIMD_UINT_TYPES(FUNCTION) | |
161 endmacro | |
162 | |
163 macro DECLARE_NUMERIC_FUNCTIONS(NAME, TYPE, LANES) | |
164 function NAMEReplaceLaneJS(instance, lane, value) { | |
165 return %NAMEReplaceLane(instance, lane, TO_NUMBER(value)); | |
166 } | |
167 | |
168 function NAMESelectJS(selector, a, b) { | |
169 return %NAMESelect(selector, a, b); | |
170 } | |
171 | |
172 function NAMEAddJS(a, b) { | |
173 return %NAMEAdd(a, b); | |
174 } | |
175 | |
176 function NAMESubJS(a, b) { | |
177 return %NAMESub(a, b); | |
178 } | |
179 | |
180 function NAMEMulJS(a, b) { | |
181 return %NAMEMul(a, b); | |
182 } | |
183 | |
184 function NAMEMinJS(a, b) { | |
185 return %NAMEMin(a, b); | |
186 } | |
187 | |
188 function NAMEMaxJS(a, b) { | |
189 return %NAMEMax(a, b); | |
190 } | |
191 | |
192 function NAMEEqualJS(a, b) { | |
193 return %NAMEEqual(a, b); | |
194 } | |
195 | |
196 function NAMENotEqualJS(a, b) { | |
197 return %NAMENotEqual(a, b); | |
198 } | |
199 | |
200 function NAMELessThanJS(a, b) { | |
201 return %NAMELessThan(a, b); | |
202 } | |
203 | |
204 function NAMELessThanOrEqualJS(a, b) { | |
205 return %NAMELessThanOrEqual(a, b); | |
206 } | |
207 | |
208 function NAMEGreaterThanJS(a, b) { | |
209 return %NAMEGreaterThan(a, b); | |
210 } | |
211 | |
212 function NAMEGreaterThanOrEqualJS(a, b) { | |
213 return %NAMEGreaterThanOrEqual(a, b); | |
214 } | |
215 | |
216 function NAMELoadJS(tarray, index) { | |
217 return %NAMELoad(tarray, index); | |
218 } | |
219 | |
220 function NAMEStoreJS(tarray, index, a) { | |
221 return %NAMEStore(tarray, index, a); | |
222 } | |
223 endmacro | |
224 | |
225 SIMD_NUMERIC_TYPES(DECLARE_NUMERIC_FUNCTIONS) | |
226 | |
227 macro SIMD_LOGICAL_TYPES(FUNCTION) | |
228 SIMD_INT_TYPES(FUNCTION) | |
229 SIMD_UINT_TYPES(FUNCTION) | |
230 SIMD_BOOL_TYPES(FUNCTION) | |
231 endmacro | |
232 | |
233 macro DECLARE_LOGICAL_FUNCTIONS(NAME, TYPE, LANES) | |
234 function NAMEAndJS(a, b) { | |
235 return %NAMEAnd(a, b); | |
236 } | |
237 | |
238 function NAMEOrJS(a, b) { | |
239 return %NAMEOr(a, b); | |
240 } | |
241 | |
242 function NAMEXorJS(a, b) { | |
243 return %NAMEXor(a, b); | |
244 } | |
245 | |
246 function NAMENotJS(a) { | |
247 return %NAMENot(a); | |
248 } | |
249 endmacro | |
250 | |
251 SIMD_LOGICAL_TYPES(DECLARE_LOGICAL_FUNCTIONS) | |
252 | |
253 macro SIMD_FROM_TYPES(FUNCTION) | |
254 FUNCTION(Float32x4, Int32x4) | |
255 FUNCTION(Float32x4, Uint32x4) | |
256 FUNCTION(Int32x4, Float32x4) | |
257 FUNCTION(Int32x4, Uint32x4) | |
258 FUNCTION(Uint32x4, Float32x4) | |
259 FUNCTION(Uint32x4, Int32x4) | |
260 FUNCTION(Int16x8, Uint16x8) | |
261 FUNCTION(Uint16x8, Int16x8) | |
262 FUNCTION(Int8x16, Uint8x16) | |
263 FUNCTION(Uint8x16, Int8x16) | |
264 endmacro | |
265 | |
266 macro DECLARE_FROM_FUNCTIONS(TO, FROM) | |
267 function TOFromFROMJS(a) { | |
268 return %TOFromFROM(a); | |
269 } | |
270 endmacro | |
271 | |
272 SIMD_FROM_TYPES(DECLARE_FROM_FUNCTIONS) | |
273 | |
274 macro SIMD_FROM_BITS_TYPES(FUNCTION) | |
275 FUNCTION(Float32x4, Int32x4) | |
276 FUNCTION(Float32x4, Uint32x4) | |
277 FUNCTION(Float32x4, Int16x8) | |
278 FUNCTION(Float32x4, Uint16x8) | |
279 FUNCTION(Float32x4, Int8x16) | |
280 FUNCTION(Float32x4, Uint8x16) | |
281 FUNCTION(Int32x4, Float32x4) | |
282 FUNCTION(Int32x4, Uint32x4) | |
283 FUNCTION(Int32x4, Int16x8) | |
284 FUNCTION(Int32x4, Uint16x8) | |
285 FUNCTION(Int32x4, Int8x16) | |
286 FUNCTION(Int32x4, Uint8x16) | |
287 FUNCTION(Uint32x4, Float32x4) | |
288 FUNCTION(Uint32x4, Int32x4) | |
289 FUNCTION(Uint32x4, Int16x8) | |
290 FUNCTION(Uint32x4, Uint16x8) | |
291 FUNCTION(Uint32x4, Int8x16) | |
292 FUNCTION(Uint32x4, Uint8x16) | |
293 FUNCTION(Int16x8, Float32x4) | |
294 FUNCTION(Int16x8, Int32x4) | |
295 FUNCTION(Int16x8, Uint32x4) | |
296 FUNCTION(Int16x8, Uint16x8) | |
297 FUNCTION(Int16x8, Int8x16) | |
298 FUNCTION(Int16x8, Uint8x16) | |
299 FUNCTION(Uint16x8, Float32x4) | |
300 FUNCTION(Uint16x8, Int32x4) | |
301 FUNCTION(Uint16x8, Uint32x4) | |
302 FUNCTION(Uint16x8, Int16x8) | |
303 FUNCTION(Uint16x8, Int8x16) | |
304 FUNCTION(Uint16x8, Uint8x16) | |
305 FUNCTION(Int8x16, Float32x4) | |
306 FUNCTION(Int8x16, Int32x4) | |
307 FUNCTION(Int8x16, Uint32x4) | |
308 FUNCTION(Int8x16, Int16x8) | |
309 FUNCTION(Int8x16, Uint16x8) | |
310 FUNCTION(Int8x16, Uint8x16) | |
311 FUNCTION(Uint8x16, Float32x4) | |
312 FUNCTION(Uint8x16, Int32x4) | |
313 FUNCTION(Uint8x16, Uint32x4) | |
314 FUNCTION(Uint8x16, Int16x8) | |
315 FUNCTION(Uint8x16, Uint16x8) | |
316 FUNCTION(Uint8x16, Int8x16) | |
317 endmacro | |
318 | |
319 macro DECLARE_FROM_BITS_FUNCTIONS(TO, FROM) | |
320 function TOFromFROMBitsJS(a) { | |
321 return %TOFromFROMBits(a); | |
322 } | |
323 endmacro | |
324 | |
325 SIMD_FROM_BITS_TYPES(DECLARE_FROM_BITS_FUNCTIONS) | |
326 | |
327 | |
328 macro SIMD_LOADN_STOREN_TYPES(FUNCTION) | |
329 FUNCTION(Float32x4, 1) | |
330 FUNCTION(Float32x4, 2) | |
331 FUNCTION(Float32x4, 3) | |
332 FUNCTION(Int32x4, 1) | |
333 FUNCTION(Int32x4, 2) | |
334 FUNCTION(Int32x4, 3) | |
335 FUNCTION(Uint32x4, 1) | |
336 FUNCTION(Uint32x4, 2) | |
337 FUNCTION(Uint32x4, 3) | |
338 endmacro | |
339 | |
340 macro DECLARE_LOADN_STOREN_FUNCTIONS(NAME, COUNT) | |
341 function NAMELoadCOUNTJS(tarray, index) { | |
342 return %NAMELoadCOUNT(tarray, index); | |
343 } | |
344 | |
345 function NAMEStoreCOUNTJS(tarray, index, a) { | |
346 return %NAMEStoreCOUNT(tarray, index, a); | |
347 } | |
348 endmacro | |
349 | |
350 SIMD_LOADN_STOREN_TYPES(DECLARE_LOADN_STOREN_FUNCTIONS) | |
351 | |
352 //------------------------------------------------------------------- | |
353 | |
354 macro SIMD_X4_TYPES(FUNCTION) | |
355 FUNCTION(Float32x4) | |
356 FUNCTION(Int32x4) | |
357 FUNCTION(Uint32x4) | |
358 FUNCTION(Bool32x4) | |
359 endmacro | |
360 | |
361 macro DECLARE_X4_FUNCTIONS(NAME) | |
362 function NAMESplat(s) { | |
363 return %CreateNAME(s, s, s, s); | |
364 } | |
365 | |
366 function NAMESwizzleJS(a, c0, c1, c2, c3) { | |
367 return %NAMESwizzle(a, c0, c1, c2, c3); | |
368 } | |
369 | |
370 function NAMEShuffleJS(a, b, c0, c1, c2, c3) { | |
371 return %NAMEShuffle(a, b, c0, c1, c2, c3); | |
372 } | |
373 endmacro | |
374 | |
375 SIMD_X4_TYPES(DECLARE_X4_FUNCTIONS) | |
376 | |
377 macro SIMD_X8_TYPES(FUNCTION) | |
378 FUNCTION(Int16x8) | |
379 FUNCTION(Uint16x8) | |
380 FUNCTION(Bool16x8) | |
381 endmacro | |
382 | |
383 macro DECLARE_X8_FUNCTIONS(NAME) | |
384 function NAMESplat(s) { | |
385 return %CreateNAME(s, s, s, s, s, s, s, s); | |
386 } | |
387 | |
388 function NAMESwizzleJS(a, c0, c1, c2, c3, c4, c5, c6, c7) { | |
389 return %NAMESwizzle(a, c0, c1, c2, c3, c4, c5, c6, c7); | |
390 } | |
391 | |
392 function NAMEShuffleJS(a, b, c0, c1, c2, c3, c4, c5, c6, c7) { | |
393 return %NAMEShuffle(a, b, c0, c1, c2, c3, c4, c5, c6, c7); | |
394 } | |
395 endmacro | |
396 | |
397 SIMD_X8_TYPES(DECLARE_X8_FUNCTIONS) | |
398 | |
399 macro SIMD_X16_TYPES(FUNCTION) | |
400 FUNCTION(Int8x16) | |
401 FUNCTION(Uint8x16) | |
402 FUNCTION(Bool8x16) | |
403 endmacro | |
404 | |
405 macro DECLARE_X16_FUNCTIONS(NAME) | |
406 function NAMESplat(s) { | |
407 return %CreateNAME(s, s, s, s, s, s, s, s, s, s, s, s, s, s, s, s); | |
408 } | |
409 | |
410 function NAMESwizzleJS(a, c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, | |
411 c12, c13, c14, c15) { | |
412 return %NAMESwizzle(a, c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, | |
413 c12, c13, c14, c15); | |
414 } | |
415 | |
416 function NAMEShuffleJS(a, b, c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, | |
417 c11, c12, c13, c14, c15) { | |
418 return %NAMEShuffle(a, b, c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, | |
419 c11, c12, c13, c14, c15); | |
420 } | |
421 endmacro | |
422 | |
423 SIMD_X16_TYPES(DECLARE_X16_FUNCTIONS) | |
424 | |
425 //------------------------------------------------------------------- | |
426 | |
427 function Float32x4Constructor(c0, c1, c2, c3) { | |
428 if (%_IsConstructCall()) throw MakeTypeError(kNotConstructor, "Float32x4"); | |
429 return %CreateFloat32x4(TO_NUMBER(c0), TO_NUMBER(c1), | |
430 TO_NUMBER(c2), TO_NUMBER(c3)); | |
431 } | |
432 | |
433 | |
434 function Int32x4Constructor(c0, c1, c2, c3) { | |
435 if (%_IsConstructCall()) throw MakeTypeError(kNotConstructor, "Int32x4"); | |
436 return %CreateInt32x4(TO_NUMBER(c0), TO_NUMBER(c1), | |
437 TO_NUMBER(c2), TO_NUMBER(c3)); | |
438 } | |
439 | |
440 | |
441 function Uint32x4Constructor(c0, c1, c2, c3) { | |
442 if (%_IsConstructCall()) throw MakeTypeError(kNotConstructor, "Uint32x4"); | |
443 return %CreateUint32x4(TO_NUMBER(c0), TO_NUMBER(c1), | |
444 TO_NUMBER(c2), TO_NUMBER(c3)); | |
445 } | |
446 | |
447 | |
448 function Bool32x4Constructor(c0, c1, c2, c3) { | |
449 if (%_IsConstructCall()) throw MakeTypeError(kNotConstructor, "Bool32x4"); | |
450 return %CreateBool32x4(c0, c1, c2, c3); | |
451 } | |
452 | |
453 | |
454 function Int16x8Constructor(c0, c1, c2, c3, c4, c5, c6, c7) { | |
455 if (%_IsConstructCall()) throw MakeTypeError(kNotConstructor, "Int16x8"); | |
456 return %CreateInt16x8(TO_NUMBER(c0), TO_NUMBER(c1), | |
457 TO_NUMBER(c2), TO_NUMBER(c3), | |
458 TO_NUMBER(c4), TO_NUMBER(c5), | |
459 TO_NUMBER(c6), TO_NUMBER(c7)); | |
460 } | |
461 | |
462 | |
463 function Uint16x8Constructor(c0, c1, c2, c3, c4, c5, c6, c7) { | |
464 if (%_IsConstructCall()) throw MakeTypeError(kNotConstructor, "Uint16x8"); | |
465 return %CreateUint16x8(TO_NUMBER(c0), TO_NUMBER(c1), | |
466 TO_NUMBER(c2), TO_NUMBER(c3), | |
467 TO_NUMBER(c4), TO_NUMBER(c5), | |
468 TO_NUMBER(c6), TO_NUMBER(c7)); | |
469 } | |
470 | |
471 | |
472 function Bool16x8Constructor(c0, c1, c2, c3, c4, c5, c6, c7) { | |
473 if (%_IsConstructCall()) throw MakeTypeError(kNotConstructor, "Bool16x8"); | |
474 return %CreateBool16x8(c0, c1, c2, c3, c4, c5, c6, c7); | |
475 } | |
476 | |
477 | |
478 function Int8x16Constructor(c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, | |
479 c12, c13, c14, c15) { | |
480 if (%_IsConstructCall()) throw MakeTypeError(kNotConstructor, "Int8x16"); | |
481 return %CreateInt8x16(TO_NUMBER(c0), TO_NUMBER(c1), | |
482 TO_NUMBER(c2), TO_NUMBER(c3), | |
483 TO_NUMBER(c4), TO_NUMBER(c5), | |
484 TO_NUMBER(c6), TO_NUMBER(c7), | |
485 TO_NUMBER(c8), TO_NUMBER(c9), | |
486 TO_NUMBER(c10), TO_NUMBER(c11), | |
487 TO_NUMBER(c12), TO_NUMBER(c13), | |
488 TO_NUMBER(c14), TO_NUMBER(c15)); | |
489 } | |
490 | |
491 | |
492 function Uint8x16Constructor(c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, | |
493 c12, c13, c14, c15) { | |
494 if (%_IsConstructCall()) throw MakeTypeError(kNotConstructor, "Uint8x16"); | |
495 return %CreateUint8x16(TO_NUMBER(c0), TO_NUMBER(c1), | |
496 TO_NUMBER(c2), TO_NUMBER(c3), | |
497 TO_NUMBER(c4), TO_NUMBER(c5), | |
498 TO_NUMBER(c6), TO_NUMBER(c7), | |
499 TO_NUMBER(c8), TO_NUMBER(c9), | |
500 TO_NUMBER(c10), TO_NUMBER(c11), | |
501 TO_NUMBER(c12), TO_NUMBER(c13), | |
502 TO_NUMBER(c14), TO_NUMBER(c15)); | |
503 } | |
504 | |
505 | |
506 function Bool8x16Constructor(c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, | |
507 c12, c13, c14, c15) { | |
508 if (%_IsConstructCall()) throw MakeTypeError(kNotConstructor, "Bool8x16"); | |
509 return %CreateBool8x16(c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, | |
510 c13, c14, c15); | |
511 } | |
512 | |
513 | |
514 function Float32x4AbsJS(a) { | |
515 return %Float32x4Abs(a); | |
516 } | |
517 | |
518 | |
519 function Float32x4SqrtJS(a) { | |
520 return %Float32x4Sqrt(a); | |
521 } | |
522 | |
523 | |
524 function Float32x4RecipApproxJS(a) { | |
525 return %Float32x4RecipApprox(a); | |
526 } | |
527 | |
528 | |
529 function Float32x4RecipSqrtApproxJS(a) { | |
530 return %Float32x4RecipSqrtApprox(a); | |
531 } | |
532 | |
533 | |
534 function Float32x4DivJS(a, b) { | |
535 return %Float32x4Div(a, b); | |
536 } | |
537 | |
538 | |
539 function Float32x4MinNumJS(a, b) { | |
540 return %Float32x4MinNum(a, b); | |
541 } | |
542 | |
543 | |
544 function Float32x4MaxNumJS(a, b) { | |
545 return %Float32x4MaxNum(a, b); | |
546 } | |
547 | |
548 | |
549 %AddNamedProperty(GlobalSIMD, toStringTagSymbol, 'SIMD', READ_ONLY | DONT_ENUM); | |
550 | |
551 macro SETUP_SIMD_TYPE(NAME, TYPE, LANES) | |
552 %SetCode(GlobalNAME, NAMEConstructor); | |
553 %FunctionSetPrototype(GlobalNAME, {}); | |
554 %AddNamedProperty(GlobalNAME.prototype, 'constructor', GlobalNAME, | |
555 DONT_ENUM); | |
556 %AddNamedProperty(GlobalNAME.prototype, toStringTagSymbol, 'NAME', | |
557 DONT_ENUM | READ_ONLY); | |
558 utils.InstallFunctions(GlobalNAME.prototype, DONT_ENUM, [ | |
559 'toLocaleString', NAMEToLocaleString, | |
560 'toString', NAMEToString, | |
561 'valueOf', NAMEValueOf, | |
562 ]); | |
563 endmacro | |
564 | |
565 SIMD_ALL_TYPES(SETUP_SIMD_TYPE) | |
566 | |
567 //------------------------------------------------------------------- | |
568 | |
569 utils.InstallFunctions(GlobalFloat32x4, DONT_ENUM, [ | |
570 'splat', Float32x4Splat, | |
571 'check', Float32x4CheckJS, | |
572 'extractLane', Float32x4ExtractLaneJS, | |
573 'replaceLane', Float32x4ReplaceLaneJS, | |
574 'neg', Float32x4NegJS, | |
575 'abs', Float32x4AbsJS, | |
576 'sqrt', Float32x4SqrtJS, | |
577 'reciprocalApproximation', Float32x4RecipApproxJS, | |
578 'reciprocalSqrtApproximation', Float32x4RecipSqrtApproxJS, | |
579 'add', Float32x4AddJS, | |
580 'sub', Float32x4SubJS, | |
581 'mul', Float32x4MulJS, | |
582 'div', Float32x4DivJS, | |
583 'min', Float32x4MinJS, | |
584 'max', Float32x4MaxJS, | |
585 'minNum', Float32x4MinNumJS, | |
586 'maxNum', Float32x4MaxNumJS, | |
587 'lessThan', Float32x4LessThanJS, | |
588 'lessThanOrEqual', Float32x4LessThanOrEqualJS, | |
589 'greaterThan', Float32x4GreaterThanJS, | |
590 'greaterThanOrEqual', Float32x4GreaterThanOrEqualJS, | |
591 'equal', Float32x4EqualJS, | |
592 'notEqual', Float32x4NotEqualJS, | |
593 'select', Float32x4SelectJS, | |
594 'swizzle', Float32x4SwizzleJS, | |
595 'shuffle', Float32x4ShuffleJS, | |
596 'fromInt32x4', Float32x4FromInt32x4JS, | |
597 'fromUint32x4', Float32x4FromUint32x4JS, | |
598 'fromInt32x4Bits', Float32x4FromInt32x4BitsJS, | |
599 'fromUint32x4Bits', Float32x4FromUint32x4BitsJS, | |
600 'fromInt16x8Bits', Float32x4FromInt16x8BitsJS, | |
601 'fromUint16x8Bits', Float32x4FromUint16x8BitsJS, | |
602 'fromInt8x16Bits', Float32x4FromInt8x16BitsJS, | |
603 'fromUint8x16Bits', Float32x4FromUint8x16BitsJS, | |
604 'load', Float32x4LoadJS, | |
605 'load1', Float32x4Load1JS, | |
606 'load2', Float32x4Load2JS, | |
607 'load3', Float32x4Load3JS, | |
608 'store', Float32x4StoreJS, | |
609 'store1', Float32x4Store1JS, | |
610 'store2', Float32x4Store2JS, | |
611 'store3', Float32x4Store3JS, | |
612 ]); | |
613 | |
614 utils.InstallFunctions(GlobalInt32x4, DONT_ENUM, [ | |
615 'splat', Int32x4Splat, | |
616 'check', Int32x4CheckJS, | |
617 'extractLane', Int32x4ExtractLaneJS, | |
618 'replaceLane', Int32x4ReplaceLaneJS, | |
619 'neg', Int32x4NegJS, | |
620 'add', Int32x4AddJS, | |
621 'sub', Int32x4SubJS, | |
622 'mul', Int32x4MulJS, | |
623 'min', Int32x4MinJS, | |
624 'max', Int32x4MaxJS, | |
625 'and', Int32x4AndJS, | |
626 'or', Int32x4OrJS, | |
627 'xor', Int32x4XorJS, | |
628 'not', Int32x4NotJS, | |
629 'shiftLeftByScalar', Int32x4ShiftLeftByScalarJS, | |
630 'shiftRightByScalar', Int32x4ShiftRightByScalarJS, | |
631 'lessThan', Int32x4LessThanJS, | |
632 'lessThanOrEqual', Int32x4LessThanOrEqualJS, | |
633 'greaterThan', Int32x4GreaterThanJS, | |
634 'greaterThanOrEqual', Int32x4GreaterThanOrEqualJS, | |
635 'equal', Int32x4EqualJS, | |
636 'notEqual', Int32x4NotEqualJS, | |
637 'select', Int32x4SelectJS, | |
638 'swizzle', Int32x4SwizzleJS, | |
639 'shuffle', Int32x4ShuffleJS, | |
640 'fromFloat32x4', Int32x4FromFloat32x4JS, | |
641 'fromUint32x4', Int32x4FromUint32x4JS, | |
642 'fromFloat32x4Bits', Int32x4FromFloat32x4BitsJS, | |
643 'fromUint32x4Bits', Int32x4FromUint32x4BitsJS, | |
644 'fromInt16x8Bits', Int32x4FromInt16x8BitsJS, | |
645 'fromUint16x8Bits', Int32x4FromUint16x8BitsJS, | |
646 'fromInt8x16Bits', Int32x4FromInt8x16BitsJS, | |
647 'fromUint8x16Bits', Int32x4FromUint8x16BitsJS, | |
648 'load', Int32x4LoadJS, | |
649 'load1', Int32x4Load1JS, | |
650 'load2', Int32x4Load2JS, | |
651 'load3', Int32x4Load3JS, | |
652 'store', Int32x4StoreJS, | |
653 'store1', Int32x4Store1JS, | |
654 'store2', Int32x4Store2JS, | |
655 'store3', Int32x4Store3JS, | |
656 ]); | |
657 | |
658 utils.InstallFunctions(GlobalUint32x4, DONT_ENUM, [ | |
659 'splat', Uint32x4Splat, | |
660 'check', Uint32x4CheckJS, | |
661 'extractLane', Uint32x4ExtractLaneJS, | |
662 'replaceLane', Uint32x4ReplaceLaneJS, | |
663 'add', Uint32x4AddJS, | |
664 'sub', Uint32x4SubJS, | |
665 'mul', Uint32x4MulJS, | |
666 'min', Uint32x4MinJS, | |
667 'max', Uint32x4MaxJS, | |
668 'and', Uint32x4AndJS, | |
669 'or', Uint32x4OrJS, | |
670 'xor', Uint32x4XorJS, | |
671 'not', Uint32x4NotJS, | |
672 'shiftLeftByScalar', Uint32x4ShiftLeftByScalarJS, | |
673 'shiftRightByScalar', Uint32x4ShiftRightByScalarJS, | |
674 'lessThan', Uint32x4LessThanJS, | |
675 'lessThanOrEqual', Uint32x4LessThanOrEqualJS, | |
676 'greaterThan', Uint32x4GreaterThanJS, | |
677 'greaterThanOrEqual', Uint32x4GreaterThanOrEqualJS, | |
678 'equal', Uint32x4EqualJS, | |
679 'notEqual', Uint32x4NotEqualJS, | |
680 'select', Uint32x4SelectJS, | |
681 'swizzle', Uint32x4SwizzleJS, | |
682 'shuffle', Uint32x4ShuffleJS, | |
683 'fromFloat32x4', Uint32x4FromFloat32x4JS, | |
684 'fromInt32x4', Uint32x4FromInt32x4JS, | |
685 'fromFloat32x4Bits', Uint32x4FromFloat32x4BitsJS, | |
686 'fromInt32x4Bits', Uint32x4FromInt32x4BitsJS, | |
687 'fromInt16x8Bits', Uint32x4FromInt16x8BitsJS, | |
688 'fromUint16x8Bits', Uint32x4FromUint16x8BitsJS, | |
689 'fromInt8x16Bits', Uint32x4FromInt8x16BitsJS, | |
690 'fromUint8x16Bits', Uint32x4FromUint8x16BitsJS, | |
691 'load', Uint32x4LoadJS, | |
692 'load1', Uint32x4Load1JS, | |
693 'load2', Uint32x4Load2JS, | |
694 'load3', Uint32x4Load3JS, | |
695 'store', Uint32x4StoreJS, | |
696 'store1', Uint32x4Store1JS, | |
697 'store2', Uint32x4Store2JS, | |
698 'store3', Uint32x4Store3JS, | |
699 ]); | |
700 | |
701 utils.InstallFunctions(GlobalBool32x4, DONT_ENUM, [ | |
702 'splat', Bool32x4Splat, | |
703 'check', Bool32x4CheckJS, | |
704 'extractLane', Bool32x4ExtractLaneJS, | |
705 'replaceLane', Bool32x4ReplaceLaneJS, | |
706 'and', Bool32x4AndJS, | |
707 'or', Bool32x4OrJS, | |
708 'xor', Bool32x4XorJS, | |
709 'not', Bool32x4NotJS, | |
710 'anyTrue', Bool32x4AnyTrueJS, | |
711 'allTrue', Bool32x4AllTrueJS, | |
712 'swizzle', Bool32x4SwizzleJS, | |
713 'shuffle', Bool32x4ShuffleJS, | |
714 ]); | |
715 | |
716 utils.InstallFunctions(GlobalInt16x8, DONT_ENUM, [ | |
717 'splat', Int16x8Splat, | |
718 'check', Int16x8CheckJS, | |
719 'extractLane', Int16x8ExtractLaneJS, | |
720 'replaceLane', Int16x8ReplaceLaneJS, | |
721 'neg', Int16x8NegJS, | |
722 'add', Int16x8AddJS, | |
723 'sub', Int16x8SubJS, | |
724 'addSaturate', Int16x8AddSaturateJS, | |
725 'subSaturate', Int16x8SubSaturateJS, | |
726 'mul', Int16x8MulJS, | |
727 'min', Int16x8MinJS, | |
728 'max', Int16x8MaxJS, | |
729 'and', Int16x8AndJS, | |
730 'or', Int16x8OrJS, | |
731 'xor', Int16x8XorJS, | |
732 'not', Int16x8NotJS, | |
733 'shiftLeftByScalar', Int16x8ShiftLeftByScalarJS, | |
734 'shiftRightByScalar', Int16x8ShiftRightByScalarJS, | |
735 'lessThan', Int16x8LessThanJS, | |
736 'lessThanOrEqual', Int16x8LessThanOrEqualJS, | |
737 'greaterThan', Int16x8GreaterThanJS, | |
738 'greaterThanOrEqual', Int16x8GreaterThanOrEqualJS, | |
739 'equal', Int16x8EqualJS, | |
740 'notEqual', Int16x8NotEqualJS, | |
741 'select', Int16x8SelectJS, | |
742 'swizzle', Int16x8SwizzleJS, | |
743 'shuffle', Int16x8ShuffleJS, | |
744 'fromUint16x8', Int16x8FromUint16x8JS, | |
745 'fromFloat32x4Bits', Int16x8FromFloat32x4BitsJS, | |
746 'fromInt32x4Bits', Int16x8FromInt32x4BitsJS, | |
747 'fromUint32x4Bits', Int16x8FromUint32x4BitsJS, | |
748 'fromUint16x8Bits', Int16x8FromUint16x8BitsJS, | |
749 'fromInt8x16Bits', Int16x8FromInt8x16BitsJS, | |
750 'fromUint8x16Bits', Int16x8FromUint8x16BitsJS, | |
751 'load', Int16x8LoadJS, | |
752 'store', Int16x8StoreJS, | |
753 ]); | |
754 | |
755 utils.InstallFunctions(GlobalUint16x8, DONT_ENUM, [ | |
756 'splat', Uint16x8Splat, | |
757 'check', Uint16x8CheckJS, | |
758 'extractLane', Uint16x8ExtractLaneJS, | |
759 'replaceLane', Uint16x8ReplaceLaneJS, | |
760 'add', Uint16x8AddJS, | |
761 'sub', Uint16x8SubJS, | |
762 'addSaturate', Uint16x8AddSaturateJS, | |
763 'subSaturate', Uint16x8SubSaturateJS, | |
764 'mul', Uint16x8MulJS, | |
765 'min', Uint16x8MinJS, | |
766 'max', Uint16x8MaxJS, | |
767 'and', Uint16x8AndJS, | |
768 'or', Uint16x8OrJS, | |
769 'xor', Uint16x8XorJS, | |
770 'not', Uint16x8NotJS, | |
771 'shiftLeftByScalar', Uint16x8ShiftLeftByScalarJS, | |
772 'shiftRightByScalar', Uint16x8ShiftRightByScalarJS, | |
773 'lessThan', Uint16x8LessThanJS, | |
774 'lessThanOrEqual', Uint16x8LessThanOrEqualJS, | |
775 'greaterThan', Uint16x8GreaterThanJS, | |
776 'greaterThanOrEqual', Uint16x8GreaterThanOrEqualJS, | |
777 'equal', Uint16x8EqualJS, | |
778 'notEqual', Uint16x8NotEqualJS, | |
779 'select', Uint16x8SelectJS, | |
780 'swizzle', Uint16x8SwizzleJS, | |
781 'shuffle', Uint16x8ShuffleJS, | |
782 'fromInt16x8', Uint16x8FromInt16x8JS, | |
783 'fromFloat32x4Bits', Uint16x8FromFloat32x4BitsJS, | |
784 'fromInt32x4Bits', Uint16x8FromInt32x4BitsJS, | |
785 'fromUint32x4Bits', Uint16x8FromUint32x4BitsJS, | |
786 'fromInt16x8Bits', Uint16x8FromInt16x8BitsJS, | |
787 'fromInt8x16Bits', Uint16x8FromInt8x16BitsJS, | |
788 'fromUint8x16Bits', Uint16x8FromUint8x16BitsJS, | |
789 'load', Uint16x8LoadJS, | |
790 'store', Uint16x8StoreJS, | |
791 ]); | |
792 | |
793 utils.InstallFunctions(GlobalBool16x8, DONT_ENUM, [ | |
794 'splat', Bool16x8Splat, | |
795 'check', Bool16x8CheckJS, | |
796 'extractLane', Bool16x8ExtractLaneJS, | |
797 'replaceLane', Bool16x8ReplaceLaneJS, | |
798 'and', Bool16x8AndJS, | |
799 'or', Bool16x8OrJS, | |
800 'xor', Bool16x8XorJS, | |
801 'not', Bool16x8NotJS, | |
802 'anyTrue', Bool16x8AnyTrueJS, | |
803 'allTrue', Bool16x8AllTrueJS, | |
804 'swizzle', Bool16x8SwizzleJS, | |
805 'shuffle', Bool16x8ShuffleJS, | |
806 ]); | |
807 | |
808 utils.InstallFunctions(GlobalInt8x16, DONT_ENUM, [ | |
809 'splat', Int8x16Splat, | |
810 'check', Int8x16CheckJS, | |
811 'extractLane', Int8x16ExtractLaneJS, | |
812 'replaceLane', Int8x16ReplaceLaneJS, | |
813 'neg', Int8x16NegJS, | |
814 'add', Int8x16AddJS, | |
815 'sub', Int8x16SubJS, | |
816 'addSaturate', Int8x16AddSaturateJS, | |
817 'subSaturate', Int8x16SubSaturateJS, | |
818 'mul', Int8x16MulJS, | |
819 'min', Int8x16MinJS, | |
820 'max', Int8x16MaxJS, | |
821 'and', Int8x16AndJS, | |
822 'or', Int8x16OrJS, | |
823 'xor', Int8x16XorJS, | |
824 'not', Int8x16NotJS, | |
825 'shiftLeftByScalar', Int8x16ShiftLeftByScalarJS, | |
826 'shiftRightByScalar', Int8x16ShiftRightByScalarJS, | |
827 'lessThan', Int8x16LessThanJS, | |
828 'lessThanOrEqual', Int8x16LessThanOrEqualJS, | |
829 'greaterThan', Int8x16GreaterThanJS, | |
830 'greaterThanOrEqual', Int8x16GreaterThanOrEqualJS, | |
831 'equal', Int8x16EqualJS, | |
832 'notEqual', Int8x16NotEqualJS, | |
833 'select', Int8x16SelectJS, | |
834 'swizzle', Int8x16SwizzleJS, | |
835 'shuffle', Int8x16ShuffleJS, | |
836 'fromUint8x16', Int8x16FromUint8x16JS, | |
837 'fromFloat32x4Bits', Int8x16FromFloat32x4BitsJS, | |
838 'fromInt32x4Bits', Int8x16FromInt32x4BitsJS, | |
839 'fromUint32x4Bits', Int8x16FromUint32x4BitsJS, | |
840 'fromInt16x8Bits', Int8x16FromInt16x8BitsJS, | |
841 'fromUint16x8Bits', Int8x16FromUint16x8BitsJS, | |
842 'fromUint8x16Bits', Int8x16FromUint8x16BitsJS, | |
843 'load', Int8x16LoadJS, | |
844 'store', Int8x16StoreJS, | |
845 ]); | |
846 | |
847 utils.InstallFunctions(GlobalUint8x16, DONT_ENUM, [ | |
848 'splat', Uint8x16Splat, | |
849 'check', Uint8x16CheckJS, | |
850 'extractLane', Uint8x16ExtractLaneJS, | |
851 'replaceLane', Uint8x16ReplaceLaneJS, | |
852 'add', Uint8x16AddJS, | |
853 'sub', Uint8x16SubJS, | |
854 'addSaturate', Uint8x16AddSaturateJS, | |
855 'subSaturate', Uint8x16SubSaturateJS, | |
856 'mul', Uint8x16MulJS, | |
857 'min', Uint8x16MinJS, | |
858 'max', Uint8x16MaxJS, | |
859 'and', Uint8x16AndJS, | |
860 'or', Uint8x16OrJS, | |
861 'xor', Uint8x16XorJS, | |
862 'not', Uint8x16NotJS, | |
863 'shiftLeftByScalar', Uint8x16ShiftLeftByScalarJS, | |
864 'shiftRightByScalar', Uint8x16ShiftRightByScalarJS, | |
865 'lessThan', Uint8x16LessThanJS, | |
866 'lessThanOrEqual', Uint8x16LessThanOrEqualJS, | |
867 'greaterThan', Uint8x16GreaterThanJS, | |
868 'greaterThanOrEqual', Uint8x16GreaterThanOrEqualJS, | |
869 'equal', Uint8x16EqualJS, | |
870 'notEqual', Uint8x16NotEqualJS, | |
871 'select', Uint8x16SelectJS, | |
872 'swizzle', Uint8x16SwizzleJS, | |
873 'shuffle', Uint8x16ShuffleJS, | |
874 'fromInt8x16', Uint8x16FromInt8x16JS, | |
875 'fromFloat32x4Bits', Uint8x16FromFloat32x4BitsJS, | |
876 'fromInt32x4Bits', Uint8x16FromInt32x4BitsJS, | |
877 'fromUint32x4Bits', Uint8x16FromUint32x4BitsJS, | |
878 'fromInt16x8Bits', Uint8x16FromInt16x8BitsJS, | |
879 'fromUint16x8Bits', Uint8x16FromUint16x8BitsJS, | |
880 'fromInt8x16Bits', Uint8x16FromInt8x16BitsJS, | |
881 'load', Uint8x16LoadJS, | |
882 'store', Uint8x16StoreJS, | |
883 ]); | |
884 | |
885 utils.InstallFunctions(GlobalBool8x16, DONT_ENUM, [ | |
886 'splat', Bool8x16Splat, | |
887 'check', Bool8x16CheckJS, | |
888 'extractLane', Bool8x16ExtractLaneJS, | |
889 'replaceLane', Bool8x16ReplaceLaneJS, | |
890 'and', Bool8x16AndJS, | |
891 'or', Bool8x16OrJS, | |
892 'xor', Bool8x16XorJS, | |
893 'not', Bool8x16NotJS, | |
894 'anyTrue', Bool8x16AnyTrueJS, | |
895 'allTrue', Bool8x16AllTrueJS, | |
896 'swizzle', Bool8x16SwizzleJS, | |
897 'shuffle', Bool8x16ShuffleJS, | |
898 ]); | |
899 | |
900 utils.Export(function(to) { | |
901 to.Float32x4ToString = Float32x4ToString; | |
902 to.Int32x4ToString = Int32x4ToString; | |
903 to.Uint32x4ToString = Uint32x4ToString; | |
904 to.Bool32x4ToString = Bool32x4ToString; | |
905 to.Int16x8ToString = Int16x8ToString; | |
906 to.Uint16x8ToString = Uint16x8ToString; | |
907 to.Bool16x8ToString = Bool16x8ToString; | |
908 to.Int8x16ToString = Int8x16ToString; | |
909 to.Uint8x16ToString = Uint8x16ToString; | |
910 to.Bool8x16ToString = Bool8x16ToString; | |
911 }); | |
912 | |
913 }) | |
OLD | NEW |