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