Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(133)

Side by Side Diff: src/simd128.js

Issue 90643003: Experimental implementation: Exposing SIMD instructions into JavaScript Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/runtime.js ('k') | src/stub-cache.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 "use strict";
29
30 // This file relies on the fact that the following declaration has been made
31 // in runtime.js:
32 // var $Array = global.Array;
33
34 var $Float32x4 = global.float32x4;
35
36 function ThrowFloat32x4TypeError() {
37 throw MakeTypeError("this is not a float32x4 value.");
38 }
39
40 function Float32x4Constructor(x, y, z, w) {
41 if (!IS_NUMBER(x)) x = NonNumberToNumber(x);
42 if (!IS_NUMBER(y)) y = NonNumberToNumber(y);
43 if (!IS_NUMBER(z)) x = NonNumberToNumber(z);
44 if (!IS_NUMBER(w)) y = NonNumberToNumber(w);
45
46 var value = %CreateFloat32x4(x, y, z, w);
47 if (%_IsConstructCall()) {
48 %_SetValueOf(this, value);
49 } else {
50 return value;
51 }
52 }
53
54 function Float32x4ZeroConstructor() {
55 if (%_IsConstructCall()) {
56 return new $Float32x4(0.0, 0.0, 0.0, 0.0);
57 } else {
58 return %CreateFloat32x4(0.0, 0.0, 0.0, 0.0);
59 }
60 }
61
62 function Float32x4SplatConstructor(s) {
63 if (!IS_NUMBER(s)) s = NonNumberToNumber(s);
64 if (%_IsConstructCall()) {
65 return new $Float32x4(s, s, s, s);
66 } else {
67 return %CreateFloat32x4(s, s, s, s);
68 }
69 }
70
71 function Float32x4GetX() {
72 var float32x4 = IS_FLOAT32x4_WRAPPER(this) ? %_ValueOf(this) : this;
73 CHECK_FLOAT32x4(float32x4);
74 return %Float32x4GetX(float32x4);
75 }
76
77 function Float32x4GetY() {
78 var float32x4 = IS_FLOAT32x4_WRAPPER(this) ? %_ValueOf(this) : this;
79 CHECK_FLOAT32x4(float32x4);
80 return %Float32x4GetY(float32x4);
81 }
82
83 function Float32x4GetZ() {
84 var float32x4 = IS_FLOAT32x4_WRAPPER(this) ? %_ValueOf(this) : this;
85 CHECK_FLOAT32x4(float32x4);
86 return %Float32x4GetZ(float32x4);
87 }
88
89 function Float32x4GetW() {
90 var float32x4 = IS_FLOAT32x4_WRAPPER(this) ? %_ValueOf(this) : this;
91 CHECK_FLOAT32x4(float32x4);
92 return %Float32x4GetW(float32x4);
93 }
94
95 function Float32x4GetSignMask() {
96 var float32x4 = IS_FLOAT32x4_WRAPPER(this) ? %_ValueOf(this) : this;
97 CHECK_FLOAT32x4(float32x4);
98 return %Float32x4GetSignMask(float32x4);
99 }
100
101 function Float32x4ToString() {
102 if (IS_FLOAT32x4_WRAPPER(this)) {
103 return ObjectToString.apply(this);
104 } else if (IS_FLOAT32x4(this)) {
105 return "float32x4(" + this.x + "," + this.y + "," + this.z + "," + this.w + ")";
106 } else {
107 throw MakeTypeError('float32x4_to_string');
108 }
109 }
110
111 function Float32x4ValueOf() {
112 if (!IS_FLOAT32x4(this) && !IS_FLOAT32x4_WRAPPER(this)) {
113 ThrowFloat32x4TypeError();
114 }
115 return %_ValueOf(this);
116 }
117
118 function SetUpFloat32x4() {
119 %CheckIsBootstrapping();
120
121 %SetCode($Float32x4, Float32x4Constructor);
122 %SetCode($Float32x4.zero, Float32x4ZeroConstructor);
123 %SetCode($Float32x4.splat, Float32x4SplatConstructor);
124
125 %FunctionSetPrototype($Float32x4, new $Float32x4(0.0, 0.0, 0.0, 0.0));
126 %FunctionSetPrototype($Float32x4.zero, $Float32x4.prototype);
127 %FunctionSetPrototype($Float32x4.splat, $Float32x4.prototype);
128 %SetProperty($Float32x4.prototype, "constructor", $Float32x4, DONT_ENUM);
129
130 InstallGetter($Float32x4.prototype, "x", Float32x4GetX);
131 InstallGetter($Float32x4.prototype, "y", Float32x4GetY);
132 InstallGetter($Float32x4.prototype, "z", Float32x4GetZ);
133 InstallGetter($Float32x4.prototype, "w", Float32x4GetW);
134 InstallGetter($Float32x4.prototype, "signMask", Float32x4GetSignMask);
135 InstallFunctions($Float32x4.prototype, DONT_ENUM, $Array(
136 "toString", Float32x4ToString,
137 "valueOf", Float32x4ValueOf
138 ));
139 }
140
141 SetUpFloat32x4();
142
143 //------------------------------------------------------------------------------
144
145 var $Int32x4 = global.int32x4;
146
147 function ThrowInt32x4TypeError() {
148 throw MakeTypeError("this is not a int32x4 value.");
149 }
150
151 function Int32x4Constructor(x, y, z, w) {
152 x = TO_INT32(x);
153 y = TO_INT32(y);
154 z = TO_INT32(z);
155 w = TO_INT32(w);
156
157 var value = %CreateInt32x4(x, y, z, w);
158 if (%_IsConstructCall()) {
159 %_SetValueOf(this, value);
160 } else {
161 return value;
162 }
163 }
164
165 function Int32x4BoolConstructor(x, y, z, w) {
166 x = x ? -1 : 0;
167 y = y ? -1 : 0;
168 z = z ? -1 : 0;
169 w = w ? -1 : 0;
170
171 if (%_IsConstructCall()) {
172 return new $Int32x4(x, y, z, w);
173 } else {
174 return %CreateInt32x4(x, y, z, w);
175 }
176 }
177
178 function Int32x4SplatConstructor(s) {
179 if (!IS_NUMBER(s)) s = NonNumberToNumber(s);
180
181 if (%_IsConstructCall()) {
182 return new $Int32x4(s, s, s,s);
183 } else {
184 return %CreateInt32x4(s, s, s, s);
185 }
186 }
187
188 function Int32x4GetX() {
189 var int32x4 = IS_INT32x4_WRAPPER(this) ? %_ValueOf(this) : this;
190 CHECK_INT32x4(int32x4);
191 return %Int32x4GetX(int32x4);
192 }
193
194 function Int32x4GetY() {
195 var int32x4 = IS_INT32x4_WRAPPER(this) ? %_ValueOf(this) : this;
196 CHECK_INT32x4(int32x4);
197 return %Int32x4GetY(int32x4);
198 }
199
200 function Int32x4GetZ() {
201 var int32x4 = IS_INT32x4_WRAPPER(this) ? %_ValueOf(this) : this;
202 CHECK_INT32x4(int32x4);
203 return %Int32x4GetZ(int32x4);
204 }
205
206 function Int32x4GetW() {
207 var int32x4 = IS_INT32x4_WRAPPER(this) ? %_ValueOf(this) : this;
208 CHECK_INT32x4(int32x4);
209 return %Int32x4GetW(int32x4);
210 }
211
212 function Int32x4GetFlagX() {
213 var int32x4 = IS_INT32x4_WRAPPER(this) ? %_ValueOf(this) : this;
214 CHECK_INT32x4(int32x4);
215 return %Int32x4GetFlagX(int32x4);
216 }
217
218 function Int32x4GetFlagY() {
219 var int32x4 = IS_INT32x4_WRAPPER(this) ? %_ValueOf(this) : this;
220 CHECK_INT32x4(int32x4);
221 return %Int32x4GetFlagY(int32x4);
222 }
223
224 function Int32x4GetFlagZ() {
225 var int32x4 = IS_INT32x4_WRAPPER(this) ? %_ValueOf(this) : this;
226 CHECK_INT32x4(int32x4);
227 return %Int32x4GetFlagZ(int32x4);
228 }
229
230 function Int32x4GetFlagW() {
231 var int32x4 = IS_INT32x4_WRAPPER(this) ? %_ValueOf(this) : this;
232 CHECK_INT32x4(int32x4);
233 return %Int32x4GetFlagW(int32x4);
234 }
235
236 function Int32x4GetSignMask() {
237 var int32x4 = IS_INT32x4_WRAPPER(this) ? %_ValueOf(this) : this;
238 CHECK_INT32x4(int32x4);
239 return %Int32x4GetSignMask(int32x4);
240 }
241
242 function Int32x4ToString() {
243 if (IS_INT32x4_WRAPPER(this)) {
244 return ObjectToString.apply(this);
245 } else if (IS_INT32x4(this)) {
246 return "int32x4(" + this.x + "," + this.y + "," + this.z + "," + this.w + ") ";
247 } else {
248 throw MakeTypeError('int32x4_to_string');
249 }
250 }
251
252 function Int32x4ValueOf() {
253 if (!IS_INT32x4(this) && !IS_INT32x4_WRAPPER(this)) {
254 ThrowInt32x4TypeError();
255 }
256 return %_ValueOf(this);
257 }
258
259 function SetUpInt32x4() {
260 %CheckIsBootstrapping();
261
262 %SetCode($Int32x4, Int32x4Constructor);
263 %SetCode($Int32x4.bool, Int32x4BoolConstructor);
264 %SetCode($Int32x4.splat, Int32x4SplatConstructor);
265
266 %FunctionSetPrototype($Int32x4, new $Int32x4(0, 0, 0, 0));
267 %FunctionSetPrototype($Int32x4.bool, $Int32x4.prototype);
268 %FunctionSetPrototype($Int32x4.splat, $Int32x4.prototype);
269 %SetProperty($Int32x4.prototype, "constructor", $Int32x4, DONT_ENUM);
270
271 InstallGetter($Int32x4.prototype, "x", Int32x4GetX);
272 InstallGetter($Int32x4.prototype, "y", Int32x4GetY);
273 InstallGetter($Int32x4.prototype, "z", Int32x4GetZ);
274 InstallGetter($Int32x4.prototype, "w", Int32x4GetW);
275 InstallGetter($Int32x4.prototype, "flagX", Int32x4GetFlagX);
276 InstallGetter($Int32x4.prototype, "flagY", Int32x4GetFlagY);
277 InstallGetter($Int32x4.prototype, "flagZ", Int32x4GetFlagZ);
278 InstallGetter($Int32x4.prototype, "flagW", Int32x4GetFlagW);
279 InstallGetter($Int32x4.prototype, "signMask", Int32x4GetSignMask);
280 InstallFunctions($Int32x4.prototype, DONT_ENUM, $Array(
281 "toString", Int32x4ToString,
282 "valueOf", Int32x4ValueOf
283 ));
284 }
285
286 SetUpInt32x4();
287
288 //------------------------------------------------------------------------------
289
290 // Instance class name can only be set on functions. That is the only
291 // purpose for SIMDConstructor.
292 function SIMDConstructor() {}
293 var $SIMD = new SIMDConstructor();
294
295 function SIMDAbs(t) {
296 t = TO_FLOAT32x4(t);
297 CHECK_FLOAT32x4(t);
298 return %SIMDAbs(t);
299 }
300
301 function SIMDNeg(t) {
302 t = TO_FLOAT32x4(t);
303 CHECK_FLOAT32x4(t);
304 return %SIMDNeg(t);
305 }
306
307 function SIMDAdd(a, b) {
308 a = TO_FLOAT32x4(a);
309 CHECK_FLOAT32x4(a);
310 b = TO_FLOAT32x4(b);
311 CHECK_FLOAT32x4(b);
312 return %SIMDAdd(a, b);
313 }
314
315 function SIMDSub(a, b) {
316 a = TO_FLOAT32x4(a);
317 CHECK_FLOAT32x4(a);
318 b = TO_FLOAT32x4(b);
319 CHECK_FLOAT32x4(b);
320 return %SIMDSub(a, b);
321 }
322
323 function SIMDMul(a, b) {
324 a = TO_FLOAT32x4(a);
325 CHECK_FLOAT32x4(a);
326 b = TO_FLOAT32x4(b);
327 CHECK_FLOAT32x4(b);
328 return %SIMDMul(a, b);
329 }
330
331 function SIMDDiv(a, b) {
332 a = TO_FLOAT32x4(a);
333 CHECK_FLOAT32x4(a);
334 b = TO_FLOAT32x4(b);
335 CHECK_FLOAT32x4(b);
336 return %SIMDDiv(a, b);
337 }
338
339 function SIMDClamp(t, lowerLimit, upperLimit) {
340 t = TO_FLOAT32x4(t);
341 CHECK_FLOAT32x4(t);
342 lowerLimit = TO_FLOAT32x4(lowerLimit);
343 CHECK_FLOAT32x4(lowerLimit);
344 upperLimit = TO_FLOAT32x4(upperLimit);
345 CHECK_FLOAT32x4(upperLimit);
346 return %SIMDClamp(t, lowerLimit, upperLimit);
347 }
348
349 function SIMDMin(t, other) {
350 t = TO_FLOAT32x4(t);
351 CHECK_FLOAT32x4(t);
352 other = TO_FLOAT32x4(other);
353 CHECK_FLOAT32x4(other);
354 return %SIMDMin(t, other);
355 }
356
357 function SIMDMax(t, other) {
358 t = TO_FLOAT32x4(t);
359 CHECK_FLOAT32x4(t);
360 other = TO_FLOAT32x4(other);
361 CHECK_FLOAT32x4(other);
362 return %SIMDMax(t, other);
363 }
364
365 function SIMDReciprocal(t) {
366 t = TO_FLOAT32x4(t);
367 CHECK_FLOAT32x4(t);
368 return %SIMDReciprocal(t);
369 }
370
371 function SIMDReciprocalSqrt(t) {
372 t = TO_FLOAT32x4(t);
373 CHECK_FLOAT32x4(t);
374 return %SIMDReciprocalSqrt(t);
375 }
376
377 function SIMDScale(t, s) {
378 t = TO_FLOAT32x4(t);
379 CHECK_FLOAT32x4(t);
380 if (!IS_NUMBER(s)) s = NonNumberToNumber(s);
381 return %SIMDScale(t, s);
382 }
383
384 function SIMDSqrt(t) {
385 t = TO_FLOAT32x4(t);
386 CHECK_FLOAT32x4(t);
387 return %SIMDSqrt(t);
388 }
389
390 function SIMDShuffle(t, mask) {
391 t = TO_FLOAT32x4(t);
392 CHECK_FLOAT32x4(t);
393 var value = TO_INT32(mask);
394 if ((value < 0) || (value > 0xFF)) {
395 throw MakeRangeError("invalid_simd_shuffle_mask");
396 }
397 return %SIMDShuffle(t, mask);
398 }
399
400 function SIMDShuffleu32(t, mask) {
401 t = TO_INT32x4(t);
402 CHECK_INT32x4(t);
403 var value = TO_INT32(mask);
404 if ((value < 0) || (value > 0xFF)) {
405 throw MakeRangeError("invalid_simd_shuffleu32_mask");
406 }
407 return %SIMDShuffleu32(t, mask);
408 }
409
410 function SIMDShuffleMix(a, b, mask) {
411 a = TO_FLOAT32x4(a);
412 b = TO_FLOAT32x4(b);
413 CHECK_FLOAT32x4(a);
414 CHECK_FLOAT32x4(b);
415 var value = TO_INT32(mask);
416 if ((value < 0) || (value > 0xFF)) {
417 throw MakeRangeError("invalid_simd_shuffleMix_mask");
418 }
419 return %SIMDShuffleMix(a, b, mask);
420 }
421
422 function SIMDWithX(t, x) {
423 t = TO_FLOAT32x4(t);
424 CHECK_FLOAT32x4(t);
425 if (!IS_NUMBER(x)) x = NonNumberToNumber(x);
426 return %SIMDWithX(t, x);
427 }
428
429 function SIMDWithY(t, y) {
430 t = TO_FLOAT32x4(t);
431 CHECK_FLOAT32x4(t);
432 if (!IS_NUMBER(y)) y = NonNumberToNumber(y);
433 return %SIMDWithY(t, y);
434 }
435
436 function SIMDWithZ(t, z) {
437 t = TO_FLOAT32x4(t);
438 CHECK_FLOAT32x4(t);
439 if (!IS_NUMBER(z)) z = NonNumberToNumber(z);
440 return %SIMDWithZ(t, z);
441 }
442
443 function SIMDWithW(t, w) {
444 t = TO_FLOAT32x4(t);
445 CHECK_FLOAT32x4(t);
446 if (!IS_NUMBER(w)) w = NonNumberToNumber(w);
447 return %SIMDWithW(t, w);
448 }
449
450 function SIMDToFloat32x4(t) {
451 t = TO_INT32x4(t);
452 CHECK_INT32x4(t);
453 return %SIMDToFloat32x4(t);
454 }
455
456 function SIMDBitsToFloat32x4(t) {
457 t = TO_INT32x4(t);
458 CHECK_INT32x4(t);
459 return %SIMDBitsToFloat32x4(t);
460 }
461
462 function SIMDToInt32x4(t) {
463 t = TO_FLOAT32x4(t);
464 CHECK_FLOAT32x4(t);
465 return %SIMDToInt32x4(t);
466 }
467
468 function SIMDBitsToInt32x4(t) {
469 t = TO_FLOAT32x4(t);
470 CHECK_FLOAT32x4(t);
471 return %SIMDBitsToInt32x4(t);
472 }
473
474 function SIMDLessThan(t, other) {
475 t = TO_FLOAT32x4(t);
476 CHECK_FLOAT32x4(t);
477 other = TO_FLOAT32x4(other);
478 CHECK_FLOAT32x4(other);
479 return %SIMDLessThan(t, other);
480 }
481
482 function SIMDLessThanOrEqual(t, other) {
483 t = TO_FLOAT32x4(t);
484 CHECK_FLOAT32x4(t);
485 other = TO_FLOAT32x4(other);
486 CHECK_FLOAT32x4(other);
487 return %SIMDLessThanOrEqual(t, other);
488 }
489
490 function SIMDEqual(t, other) {
491 t = TO_FLOAT32x4(t);
492 CHECK_FLOAT32x4(t);
493 other = TO_FLOAT32x4(other);
494 CHECK_FLOAT32x4(other);
495 return %SIMDEqual(t, other);
496 }
497
498 function SIMDNotEqual(t, other) {
499 t = TO_FLOAT32x4(t);
500 CHECK_FLOAT32x4(t);
501 other = TO_FLOAT32x4(other);
502 CHECK_FLOAT32x4(other);
503 return %SIMDNotEqual(t, other);
504 }
505
506 function SIMDGreaterThanOrEqual(t, other) {
507 t = TO_FLOAT32x4(t);
508 CHECK_FLOAT32x4(t);
509 other = TO_FLOAT32x4(other);
510 CHECK_FLOAT32x4(other);
511 return %SIMDGreaterThanOrEqual(t, other);
512 }
513
514 function SIMDGreaterThan(t, other) {
515 t = TO_FLOAT32x4(t);
516 CHECK_FLOAT32x4(t);
517 other = TO_FLOAT32x4(other);
518 CHECK_FLOAT32x4(other);
519 return %SIMDGreaterThan(t, other);
520 }
521
522 function SIMDAnd(a, b) {
523 a = TO_INT32x4(a);
524 CHECK_INT32x4(a);
525 b = TO_INT32x4(b);
526 CHECK_INT32x4(b);
527 return %SIMDAnd(a, b);
528 }
529
530 function SIMDOr(a, b) {
531 a = TO_INT32x4(a);
532 CHECK_INT32x4(a);
533 b = TO_INT32x4(b);
534 CHECK_INT32x4(b);
535 return %SIMDOr(a, b);
536 }
537
538 function SIMDXor(a, b) {
539 a = TO_INT32x4(a);
540 CHECK_INT32x4(a);
541 b = TO_INT32x4(b);
542 CHECK_INT32x4(b);
543 return %SIMDXor(a, b);
544 }
545
546 function SIMDNot(t) {
547 t = TO_INT32x4(t);
548 CHECK_INT32x4(t);
549 return %SIMDNot(t);
550 }
551
552 function SIMDNegu32(t) {
553 t = TO_INT32x4(t);
554 CHECK_INT32x4(t);
555 return %SIMDNegu32(t);
556 }
557
558 function SIMDAddu32(a, b) {
559 a = TO_INT32x4(a);
560 CHECK_INT32x4(a);
561 b = TO_INT32x4(b);
562 CHECK_INT32x4(b);
563 return %SIMDAddu32(a, b);
564 }
565
566 function SIMDSubu32(a, b) {
567 a = TO_INT32x4(a);
568 CHECK_INT32x4(a);
569 b = TO_INT32x4(b);
570 CHECK_INT32x4(b);
571 return %SIMDSubu32(a, b);
572 }
573
574 function SIMDMulu32(a, b) {
575 a = TO_INT32x4(a);
576 CHECK_INT32x4(a);
577 b = TO_INT32x4(b);
578 CHECK_INT32x4(b);
579 return %SIMDMulu32(a, b);
580 }
581
582 function SIMDSelect(t, trueValue, falseValue) {
583 t = TO_INT32x4(t);
584 CHECK_INT32x4(t);
585 trueValue = TO_FLOAT32x4(trueValue);
586 CHECK_FLOAT32x4(trueValue);
587 falseValue = TO_FLOAT32x4(falseValue);
588 CHECK_FLOAT32x4(falseValue);
589 return %SIMDSelect(t, trueValue, falseValue);
590 }
591
592 function SIMDWithXu32(t, x) {
593 t = TO_INT32x4(t);
594 CHECK_INT32x4(t);
595 x = TO_UINT32(x);
596 return %SIMDWithXu32(t, x);
597 }
598
599 function SIMDWithYu32(t, y) {
600 t = TO_INT32x4(t);
601 CHECK_INT32x4(t);
602 y = TO_UINT32(y);
603 return %SIMDWithYu32(t, y);
604 }
605
606 function SIMDWithZu32(t, z) {
607 t = TO_INT32x4(t);
608 CHECK_INT32x4(t);
609 z = TO_UINT32(z);
610 return %SIMDWithZu32(t, z);
611 }
612
613 function SIMDWithWu32(t, w) {
614 t = TO_INT32x4(t);
615 CHECK_INT32x4(t);
616 w = TO_UINT32(w);
617 return %SIMDWithWu32(t, w);
618 }
619
620 function SIMDWithFlagX(t, x) {
621 t = TO_INT32x4(t);
622 CHECK_INT32x4(t);
623 x = ToBoolean(x);
624 return %SIMDWithFlagX(t, x);
625 }
626
627 function SIMDWithFlagY(t, y) {
628 t = TO_INT32x4(t);
629 CHECK_INT32x4(t);
630 y = ToBoolean(y);
631 return %SIMDWithFlagY(t, y);
632 }
633
634 function SIMDWithFlagZ(t, z) {
635 t = TO_INT32x4(t);
636 CHECK_INT32x4(t);
637 z = ToBoolean(z);
638 return %SIMDWithFlagZ(t, z);
639 }
640
641 function SIMDWithFlagW(t, w) {
642 t = TO_INT32x4(t);
643 CHECK_INT32x4(t);
644 w = ToBoolean(w);
645 return %SIMDWithFlagW(t, w);
646 }
647
648 function SetUpSIMD() {
649 %CheckIsBootstrapping();
650
651 %SetPrototype($SIMD, $Object.prototype);
652 %SetProperty(global, "SIMD", $SIMD, DONT_ENUM);
653 %FunctionSetInstanceClassName(SIMDConstructor, 'SIMD');
654
655 %OptimizeObjectForAddingMultipleProperties($SIMD, 258);
656 %SetProperty($SIMD, "XXXX", 0x00, DONT_ENUM | DONT_DELETE | READ_ONLY);
657 %SetProperty($SIMD, "XXXY", 0x40, DONT_ENUM | DONT_DELETE | READ_ONLY);
658 %SetProperty($SIMD, "XXXZ", 0x80, DONT_ENUM | DONT_DELETE | READ_ONLY);
659 %SetProperty($SIMD, "XXXW", 0xC0, DONT_ENUM | DONT_DELETE | READ_ONLY);
660 %SetProperty($SIMD, "XXYX", 0x10, DONT_ENUM | DONT_DELETE | READ_ONLY);
661 %SetProperty($SIMD, "XXYY", 0x50, DONT_ENUM | DONT_DELETE | READ_ONLY);
662 %SetProperty($SIMD, "XXYZ", 0x90, DONT_ENUM | DONT_DELETE | READ_ONLY);
663 %SetProperty($SIMD, "XXYW", 0xD0, DONT_ENUM | DONT_DELETE | READ_ONLY);
664 %SetProperty($SIMD, "XXZX", 0x20, DONT_ENUM | DONT_DELETE | READ_ONLY);
665 %SetProperty($SIMD, "XXZY", 0x60, DONT_ENUM | DONT_DELETE | READ_ONLY);
666 %SetProperty($SIMD, "XXZZ", 0xA0, DONT_ENUM | DONT_DELETE | READ_ONLY);
667 %SetProperty($SIMD, "XXZW", 0xE0, DONT_ENUM | DONT_DELETE | READ_ONLY);
668 %SetProperty($SIMD, "XXWX", 0x30, DONT_ENUM | DONT_DELETE | READ_ONLY);
669 %SetProperty($SIMD, "XXWY", 0x70, DONT_ENUM | DONT_DELETE | READ_ONLY);
670 %SetProperty($SIMD, "XXWZ", 0xB0, DONT_ENUM | DONT_DELETE | READ_ONLY);
671 %SetProperty($SIMD, "XXWW", 0xF0, DONT_ENUM | DONT_DELETE | READ_ONLY);
672 %SetProperty($SIMD, "XYXX", 0x04, DONT_ENUM | DONT_DELETE | READ_ONLY);
673 %SetProperty($SIMD, "XYXY", 0x44, DONT_ENUM | DONT_DELETE | READ_ONLY);
674 %SetProperty($SIMD, "XYXZ", 0x84, DONT_ENUM | DONT_DELETE | READ_ONLY);
675 %SetProperty($SIMD, "XYXW", 0xC4, DONT_ENUM | DONT_DELETE | READ_ONLY);
676 %SetProperty($SIMD, "XYYX", 0x14, DONT_ENUM | DONT_DELETE | READ_ONLY);
677 %SetProperty($SIMD, "XYYY", 0x54, DONT_ENUM | DONT_DELETE | READ_ONLY);
678 %SetProperty($SIMD, "XYYZ", 0x94, DONT_ENUM | DONT_DELETE | READ_ONLY);
679 %SetProperty($SIMD, "XYYW", 0xD4, DONT_ENUM | DONT_DELETE | READ_ONLY);
680 %SetProperty($SIMD, "XYZX", 0x24, DONT_ENUM | DONT_DELETE | READ_ONLY);
681 %SetProperty($SIMD, "XYZY", 0x64, DONT_ENUM | DONT_DELETE | READ_ONLY);
682 %SetProperty($SIMD, "XYZZ", 0xA4, DONT_ENUM | DONT_DELETE | READ_ONLY);
683 %SetProperty($SIMD, "XYZW", 0xE4, DONT_ENUM | DONT_DELETE | READ_ONLY);
684 %SetProperty($SIMD, "XYWX", 0x34, DONT_ENUM | DONT_DELETE | READ_ONLY);
685 %SetProperty($SIMD, "XYWY", 0x74, DONT_ENUM | DONT_DELETE | READ_ONLY);
686 %SetProperty($SIMD, "XYWZ", 0xB4, DONT_ENUM | DONT_DELETE | READ_ONLY);
687 %SetProperty($SIMD, "XYWW", 0xF4, DONT_ENUM | DONT_DELETE | READ_ONLY);
688 %SetProperty($SIMD, "XZXX", 0x08, DONT_ENUM | DONT_DELETE | READ_ONLY);
689 %SetProperty($SIMD, "XZXY", 0x48, DONT_ENUM | DONT_DELETE | READ_ONLY);
690 %SetProperty($SIMD, "XZXZ", 0x88, DONT_ENUM | DONT_DELETE | READ_ONLY);
691 %SetProperty($SIMD, "XZXW", 0xC8, DONT_ENUM | DONT_DELETE | READ_ONLY);
692 %SetProperty($SIMD, "XZYX", 0x18, DONT_ENUM | DONT_DELETE | READ_ONLY);
693 %SetProperty($SIMD, "XZYY", 0x58, DONT_ENUM | DONT_DELETE | READ_ONLY);
694 %SetProperty($SIMD, "XZYZ", 0x98, DONT_ENUM | DONT_DELETE | READ_ONLY);
695 %SetProperty($SIMD, "XZYW", 0xD8, DONT_ENUM | DONT_DELETE | READ_ONLY);
696 %SetProperty($SIMD, "XZZX", 0x28, DONT_ENUM | DONT_DELETE | READ_ONLY);
697 %SetProperty($SIMD, "XZZY", 0x68, DONT_ENUM | DONT_DELETE | READ_ONLY);
698 %SetProperty($SIMD, "XZZZ", 0xA8, DONT_ENUM | DONT_DELETE | READ_ONLY);
699 %SetProperty($SIMD, "XZZW", 0xE8, DONT_ENUM | DONT_DELETE | READ_ONLY);
700 %SetProperty($SIMD, "XZWX", 0x38, DONT_ENUM | DONT_DELETE | READ_ONLY);
701 %SetProperty($SIMD, "XZWY", 0x78, DONT_ENUM | DONT_DELETE | READ_ONLY);
702 %SetProperty($SIMD, "XZWZ", 0xB8, DONT_ENUM | DONT_DELETE | READ_ONLY);
703 %SetProperty($SIMD, "XZWW", 0xF8, DONT_ENUM | DONT_DELETE | READ_ONLY);
704 %SetProperty($SIMD, "XWXX", 0x0C, DONT_ENUM | DONT_DELETE | READ_ONLY);
705 %SetProperty($SIMD, "XWXY", 0x4C, DONT_ENUM | DONT_DELETE | READ_ONLY);
706 %SetProperty($SIMD, "XWXZ", 0x8C, DONT_ENUM | DONT_DELETE | READ_ONLY);
707 %SetProperty($SIMD, "XWXW", 0xCC, DONT_ENUM | DONT_DELETE | READ_ONLY);
708 %SetProperty($SIMD, "XWYX", 0x1C, DONT_ENUM | DONT_DELETE | READ_ONLY);
709 %SetProperty($SIMD, "XWYY", 0x5C, DONT_ENUM | DONT_DELETE | READ_ONLY);
710 %SetProperty($SIMD, "XWYZ", 0x9C, DONT_ENUM | DONT_DELETE | READ_ONLY);
711 %SetProperty($SIMD, "XWYW", 0xDC, DONT_ENUM | DONT_DELETE | READ_ONLY);
712 %SetProperty($SIMD, "XWZX", 0x2C, DONT_ENUM | DONT_DELETE | READ_ONLY);
713 %SetProperty($SIMD, "XWZY", 0x6C, DONT_ENUM | DONT_DELETE | READ_ONLY);
714 %SetProperty($SIMD, "XWZZ", 0xAC, DONT_ENUM | DONT_DELETE | READ_ONLY);
715 %SetProperty($SIMD, "XWZW", 0xEC, DONT_ENUM | DONT_DELETE | READ_ONLY);
716 %SetProperty($SIMD, "XWWX", 0x3C, DONT_ENUM | DONT_DELETE | READ_ONLY);
717 %SetProperty($SIMD, "XWWY", 0x7C, DONT_ENUM | DONT_DELETE | READ_ONLY);
718 %SetProperty($SIMD, "XWWZ", 0xBC, DONT_ENUM | DONT_DELETE | READ_ONLY);
719 %SetProperty($SIMD, "XWWW", 0xFC, DONT_ENUM | DONT_DELETE | READ_ONLY);
720 %SetProperty($SIMD, "YXXX", 0x01, DONT_ENUM | DONT_DELETE | READ_ONLY);
721 %SetProperty($SIMD, "YXXY", 0x41, DONT_ENUM | DONT_DELETE | READ_ONLY);
722 %SetProperty($SIMD, "YXXZ", 0x81, DONT_ENUM | DONT_DELETE | READ_ONLY);
723 %SetProperty($SIMD, "YXXW", 0xC1, DONT_ENUM | DONT_DELETE | READ_ONLY);
724 %SetProperty($SIMD, "YXYX", 0x11, DONT_ENUM | DONT_DELETE | READ_ONLY);
725 %SetProperty($SIMD, "YXYY", 0x51, DONT_ENUM | DONT_DELETE | READ_ONLY);
726 %SetProperty($SIMD, "YXYZ", 0x91, DONT_ENUM | DONT_DELETE | READ_ONLY);
727 %SetProperty($SIMD, "YXYW", 0xD1, DONT_ENUM | DONT_DELETE | READ_ONLY);
728 %SetProperty($SIMD, "YXZX", 0x21, DONT_ENUM | DONT_DELETE | READ_ONLY);
729 %SetProperty($SIMD, "YXZY", 0x61, DONT_ENUM | DONT_DELETE | READ_ONLY);
730 %SetProperty($SIMD, "YXZZ", 0xA1, DONT_ENUM | DONT_DELETE | READ_ONLY);
731 %SetProperty($SIMD, "YXZW", 0xE1, DONT_ENUM | DONT_DELETE | READ_ONLY);
732 %SetProperty($SIMD, "YXWX", 0x31, DONT_ENUM | DONT_DELETE | READ_ONLY);
733 %SetProperty($SIMD, "YXWY", 0x71, DONT_ENUM | DONT_DELETE | READ_ONLY);
734 %SetProperty($SIMD, "YXWZ", 0xB1, DONT_ENUM | DONT_DELETE | READ_ONLY);
735 %SetProperty($SIMD, "YXWW", 0xF1, DONT_ENUM | DONT_DELETE | READ_ONLY);
736 %SetProperty($SIMD, "YYXX", 0x05, DONT_ENUM | DONT_DELETE | READ_ONLY);
737 %SetProperty($SIMD, "YYXY", 0x45, DONT_ENUM | DONT_DELETE | READ_ONLY);
738 %SetProperty($SIMD, "YYXZ", 0x85, DONT_ENUM | DONT_DELETE | READ_ONLY);
739 %SetProperty($SIMD, "YYXW", 0xC5, DONT_ENUM | DONT_DELETE | READ_ONLY);
740 %SetProperty($SIMD, "YYYX", 0x15, DONT_ENUM | DONT_DELETE | READ_ONLY);
741 %SetProperty($SIMD, "YYYY", 0x55, DONT_ENUM | DONT_DELETE | READ_ONLY);
742 %SetProperty($SIMD, "YYYZ", 0x95, DONT_ENUM | DONT_DELETE | READ_ONLY);
743 %SetProperty($SIMD, "YYYW", 0xD5, DONT_ENUM | DONT_DELETE | READ_ONLY);
744 %SetProperty($SIMD, "YYZX", 0x25, DONT_ENUM | DONT_DELETE | READ_ONLY);
745 %SetProperty($SIMD, "YYZY", 0x65, DONT_ENUM | DONT_DELETE | READ_ONLY);
746 %SetProperty($SIMD, "YYZZ", 0xA5, DONT_ENUM | DONT_DELETE | READ_ONLY);
747 %SetProperty($SIMD, "YYZW", 0xE5, DONT_ENUM | DONT_DELETE | READ_ONLY);
748 %SetProperty($SIMD, "YYWX", 0x35, DONT_ENUM | DONT_DELETE | READ_ONLY);
749 %SetProperty($SIMD, "YYWY", 0x75, DONT_ENUM | DONT_DELETE | READ_ONLY);
750 %SetProperty($SIMD, "YYWZ", 0xB5, DONT_ENUM | DONT_DELETE | READ_ONLY);
751 %SetProperty($SIMD, "YYWW", 0xF5, DONT_ENUM | DONT_DELETE | READ_ONLY);
752 %SetProperty($SIMD, "YZXX", 0x09, DONT_ENUM | DONT_DELETE | READ_ONLY);
753 %SetProperty($SIMD, "YZXY", 0x49, DONT_ENUM | DONT_DELETE | READ_ONLY);
754 %SetProperty($SIMD, "YZXZ", 0x89, DONT_ENUM | DONT_DELETE | READ_ONLY);
755 %SetProperty($SIMD, "YZXW", 0xC9, DONT_ENUM | DONT_DELETE | READ_ONLY);
756 %SetProperty($SIMD, "YZYX", 0x19, DONT_ENUM | DONT_DELETE | READ_ONLY);
757 %SetProperty($SIMD, "YZYY", 0x59, DONT_ENUM | DONT_DELETE | READ_ONLY);
758 %SetProperty($SIMD, "YZYZ", 0x99, DONT_ENUM | DONT_DELETE | READ_ONLY);
759 %SetProperty($SIMD, "YZYW", 0xD9, DONT_ENUM | DONT_DELETE | READ_ONLY);
760 %SetProperty($SIMD, "YZZX", 0x29, DONT_ENUM | DONT_DELETE | READ_ONLY);
761 %SetProperty($SIMD, "YZZY", 0x69, DONT_ENUM | DONT_DELETE | READ_ONLY);
762 %SetProperty($SIMD, "YZZZ", 0xA9, DONT_ENUM | DONT_DELETE | READ_ONLY);
763 %SetProperty($SIMD, "YZZW", 0xE9, DONT_ENUM | DONT_DELETE | READ_ONLY);
764 %SetProperty($SIMD, "YZWX", 0x39, DONT_ENUM | DONT_DELETE | READ_ONLY);
765 %SetProperty($SIMD, "YZWY", 0x79, DONT_ENUM | DONT_DELETE | READ_ONLY);
766 %SetProperty($SIMD, "YZWZ", 0xB9, DONT_ENUM | DONT_DELETE | READ_ONLY);
767 %SetProperty($SIMD, "YZWW", 0xF9, DONT_ENUM | DONT_DELETE | READ_ONLY);
768 %SetProperty($SIMD, "YWXX", 0x0D, DONT_ENUM | DONT_DELETE | READ_ONLY);
769 %SetProperty($SIMD, "YWXY", 0x4D, DONT_ENUM | DONT_DELETE | READ_ONLY);
770 %SetProperty($SIMD, "YWXZ", 0x8D, DONT_ENUM | DONT_DELETE | READ_ONLY);
771 %SetProperty($SIMD, "YWXW", 0xCD, DONT_ENUM | DONT_DELETE | READ_ONLY);
772 %SetProperty($SIMD, "YWYX", 0x1D, DONT_ENUM | DONT_DELETE | READ_ONLY);
773 %SetProperty($SIMD, "YWYY", 0x5D, DONT_ENUM | DONT_DELETE | READ_ONLY);
774 %SetProperty($SIMD, "YWYZ", 0x9D, DONT_ENUM | DONT_DELETE | READ_ONLY);
775 %SetProperty($SIMD, "YWYW", 0xDD, DONT_ENUM | DONT_DELETE | READ_ONLY);
776 %SetProperty($SIMD, "YWZX", 0x2D, DONT_ENUM | DONT_DELETE | READ_ONLY);
777 %SetProperty($SIMD, "YWZY", 0x6D, DONT_ENUM | DONT_DELETE | READ_ONLY);
778 %SetProperty($SIMD, "YWZZ", 0xAD, DONT_ENUM | DONT_DELETE | READ_ONLY);
779 %SetProperty($SIMD, "YWZW", 0xED, DONT_ENUM | DONT_DELETE | READ_ONLY);
780 %SetProperty($SIMD, "YWWX", 0x3D, DONT_ENUM | DONT_DELETE | READ_ONLY);
781 %SetProperty($SIMD, "YWWY", 0x7D, DONT_ENUM | DONT_DELETE | READ_ONLY);
782 %SetProperty($SIMD, "YWWZ", 0xBD, DONT_ENUM | DONT_DELETE | READ_ONLY);
783 %SetProperty($SIMD, "YWWW", 0xFD, DONT_ENUM | DONT_DELETE | READ_ONLY);
784 %SetProperty($SIMD, "ZXXX", 0x02, DONT_ENUM | DONT_DELETE | READ_ONLY);
785 %SetProperty($SIMD, "ZXXY", 0x42, DONT_ENUM | DONT_DELETE | READ_ONLY);
786 %SetProperty($SIMD, "ZXXZ", 0x82, DONT_ENUM | DONT_DELETE | READ_ONLY);
787 %SetProperty($SIMD, "ZXXW", 0xC2, DONT_ENUM | DONT_DELETE | READ_ONLY);
788 %SetProperty($SIMD, "ZXYX", 0x12, DONT_ENUM | DONT_DELETE | READ_ONLY);
789 %SetProperty($SIMD, "ZXYY", 0x52, DONT_ENUM | DONT_DELETE | READ_ONLY);
790 %SetProperty($SIMD, "ZXYZ", 0x92, DONT_ENUM | DONT_DELETE | READ_ONLY);
791 %SetProperty($SIMD, "ZXYW", 0xD2, DONT_ENUM | DONT_DELETE | READ_ONLY);
792 %SetProperty($SIMD, "ZXZX", 0x22, DONT_ENUM | DONT_DELETE | READ_ONLY);
793 %SetProperty($SIMD, "ZXZY", 0x62, DONT_ENUM | DONT_DELETE | READ_ONLY);
794 %SetProperty($SIMD, "ZXZZ", 0xA2, DONT_ENUM | DONT_DELETE | READ_ONLY);
795 %SetProperty($SIMD, "ZXZW", 0xE2, DONT_ENUM | DONT_DELETE | READ_ONLY);
796 %SetProperty($SIMD, "ZXWX", 0x32, DONT_ENUM | DONT_DELETE | READ_ONLY);
797 %SetProperty($SIMD, "ZXWY", 0x72, DONT_ENUM | DONT_DELETE | READ_ONLY);
798 %SetProperty($SIMD, "ZXWZ", 0xB2, DONT_ENUM | DONT_DELETE | READ_ONLY);
799 %SetProperty($SIMD, "ZXWW", 0xF2, DONT_ENUM | DONT_DELETE | READ_ONLY);
800 %SetProperty($SIMD, "ZYXX", 0x06, DONT_ENUM | DONT_DELETE | READ_ONLY);
801 %SetProperty($SIMD, "ZYXY", 0x46, DONT_ENUM | DONT_DELETE | READ_ONLY);
802 %SetProperty($SIMD, "ZYXZ", 0x86, DONT_ENUM | DONT_DELETE | READ_ONLY);
803 %SetProperty($SIMD, "ZYXW", 0xC6, DONT_ENUM | DONT_DELETE | READ_ONLY);
804 %SetProperty($SIMD, "ZYYX", 0x16, DONT_ENUM | DONT_DELETE | READ_ONLY);
805 %SetProperty($SIMD, "ZYYY", 0x56, DONT_ENUM | DONT_DELETE | READ_ONLY);
806 %SetProperty($SIMD, "ZYYZ", 0x96, DONT_ENUM | DONT_DELETE | READ_ONLY);
807 %SetProperty($SIMD, "ZYYW", 0xD6, DONT_ENUM | DONT_DELETE | READ_ONLY);
808 %SetProperty($SIMD, "ZYZX", 0x26, DONT_ENUM | DONT_DELETE | READ_ONLY);
809 %SetProperty($SIMD, "ZYZY", 0x66, DONT_ENUM | DONT_DELETE | READ_ONLY);
810 %SetProperty($SIMD, "ZYZZ", 0xA6, DONT_ENUM | DONT_DELETE | READ_ONLY);
811 %SetProperty($SIMD, "ZYZW", 0xE6, DONT_ENUM | DONT_DELETE | READ_ONLY);
812 %SetProperty($SIMD, "ZYWX", 0x36, DONT_ENUM | DONT_DELETE | READ_ONLY);
813 %SetProperty($SIMD, "ZYWY", 0x76, DONT_ENUM | DONT_DELETE | READ_ONLY);
814 %SetProperty($SIMD, "ZYWZ", 0xB6, DONT_ENUM | DONT_DELETE | READ_ONLY);
815 %SetProperty($SIMD, "ZYWW", 0xF6, DONT_ENUM | DONT_DELETE | READ_ONLY);
816 %SetProperty($SIMD, "ZZXX", 0x0A, DONT_ENUM | DONT_DELETE | READ_ONLY);
817 %SetProperty($SIMD, "ZZXY", 0x4A, DONT_ENUM | DONT_DELETE | READ_ONLY);
818 %SetProperty($SIMD, "ZZXZ", 0x8A, DONT_ENUM | DONT_DELETE | READ_ONLY);
819 %SetProperty($SIMD, "ZZXW", 0xCA, DONT_ENUM | DONT_DELETE | READ_ONLY);
820 %SetProperty($SIMD, "ZZYX", 0x1A, DONT_ENUM | DONT_DELETE | READ_ONLY);
821 %SetProperty($SIMD, "ZZYY", 0x5A, DONT_ENUM | DONT_DELETE | READ_ONLY);
822 %SetProperty($SIMD, "ZZYZ", 0x9A, DONT_ENUM | DONT_DELETE | READ_ONLY);
823 %SetProperty($SIMD, "ZZYW", 0xDA, DONT_ENUM | DONT_DELETE | READ_ONLY);
824 %SetProperty($SIMD, "ZZZX", 0x2A, DONT_ENUM | DONT_DELETE | READ_ONLY);
825 %SetProperty($SIMD, "ZZZY", 0x6A, DONT_ENUM | DONT_DELETE | READ_ONLY);
826 %SetProperty($SIMD, "ZZZZ", 0xAA, DONT_ENUM | DONT_DELETE | READ_ONLY);
827 %SetProperty($SIMD, "ZZZW", 0xEA, DONT_ENUM | DONT_DELETE | READ_ONLY);
828 %SetProperty($SIMD, "ZZWX", 0x3A, DONT_ENUM | DONT_DELETE | READ_ONLY);
829 %SetProperty($SIMD, "ZZWY", 0x7A, DONT_ENUM | DONT_DELETE | READ_ONLY);
830 %SetProperty($SIMD, "ZZWZ", 0xBA, DONT_ENUM | DONT_DELETE | READ_ONLY);
831 %SetProperty($SIMD, "ZZWW", 0xFA, DONT_ENUM | DONT_DELETE | READ_ONLY);
832 %SetProperty($SIMD, "ZWXX", 0x0E, DONT_ENUM | DONT_DELETE | READ_ONLY);
833 %SetProperty($SIMD, "ZWXY", 0x4E, DONT_ENUM | DONT_DELETE | READ_ONLY);
834 %SetProperty($SIMD, "ZWXZ", 0x8E, DONT_ENUM | DONT_DELETE | READ_ONLY);
835 %SetProperty($SIMD, "ZWXW", 0xCE, DONT_ENUM | DONT_DELETE | READ_ONLY);
836 %SetProperty($SIMD, "ZWYX", 0x1E, DONT_ENUM | DONT_DELETE | READ_ONLY);
837 %SetProperty($SIMD, "ZWYY", 0x5E, DONT_ENUM | DONT_DELETE | READ_ONLY);
838 %SetProperty($SIMD, "ZWYZ", 0x9E, DONT_ENUM | DONT_DELETE | READ_ONLY);
839 %SetProperty($SIMD, "ZWYW", 0xDE, DONT_ENUM | DONT_DELETE | READ_ONLY);
840 %SetProperty($SIMD, "ZWZX", 0x2E, DONT_ENUM | DONT_DELETE | READ_ONLY);
841 %SetProperty($SIMD, "ZWZY", 0x6E, DONT_ENUM | DONT_DELETE | READ_ONLY);
842 %SetProperty($SIMD, "ZWZZ", 0xAE, DONT_ENUM | DONT_DELETE | READ_ONLY);
843 %SetProperty($SIMD, "ZWZW", 0xEE, DONT_ENUM | DONT_DELETE | READ_ONLY);
844 %SetProperty($SIMD, "ZWWX", 0x3E, DONT_ENUM | DONT_DELETE | READ_ONLY);
845 %SetProperty($SIMD, "ZWWY", 0x7E, DONT_ENUM | DONT_DELETE | READ_ONLY);
846 %SetProperty($SIMD, "ZWWZ", 0xBE, DONT_ENUM | DONT_DELETE | READ_ONLY);
847 %SetProperty($SIMD, "ZWWW", 0xFE, DONT_ENUM | DONT_DELETE | READ_ONLY);
848 %SetProperty($SIMD, "WXXX", 0x03, DONT_ENUM | DONT_DELETE | READ_ONLY);
849 %SetProperty($SIMD, "WXXY", 0x43, DONT_ENUM | DONT_DELETE | READ_ONLY);
850 %SetProperty($SIMD, "WXXZ", 0x83, DONT_ENUM | DONT_DELETE | READ_ONLY);
851 %SetProperty($SIMD, "WXXW", 0xC3, DONT_ENUM | DONT_DELETE | READ_ONLY);
852 %SetProperty($SIMD, "WXYX", 0x13, DONT_ENUM | DONT_DELETE | READ_ONLY);
853 %SetProperty($SIMD, "WXYY", 0x53, DONT_ENUM | DONT_DELETE | READ_ONLY);
854 %SetProperty($SIMD, "WXYZ", 0x93, DONT_ENUM | DONT_DELETE | READ_ONLY);
855 %SetProperty($SIMD, "WXYW", 0xD3, DONT_ENUM | DONT_DELETE | READ_ONLY);
856 %SetProperty($SIMD, "WXZX", 0x23, DONT_ENUM | DONT_DELETE | READ_ONLY);
857 %SetProperty($SIMD, "WXZY", 0x63, DONT_ENUM | DONT_DELETE | READ_ONLY);
858 %SetProperty($SIMD, "WXZZ", 0xA3, DONT_ENUM | DONT_DELETE | READ_ONLY);
859 %SetProperty($SIMD, "WXZW", 0xE3, DONT_ENUM | DONT_DELETE | READ_ONLY);
860 %SetProperty($SIMD, "WXWX", 0x33, DONT_ENUM | DONT_DELETE | READ_ONLY);
861 %SetProperty($SIMD, "WXWY", 0x73, DONT_ENUM | DONT_DELETE | READ_ONLY);
862 %SetProperty($SIMD, "WXWZ", 0xB3, DONT_ENUM | DONT_DELETE | READ_ONLY);
863 %SetProperty($SIMD, "WXWW", 0xF3, DONT_ENUM | DONT_DELETE | READ_ONLY);
864 %SetProperty($SIMD, "WYXX", 0x07, DONT_ENUM | DONT_DELETE | READ_ONLY);
865 %SetProperty($SIMD, "WYXY", 0x47, DONT_ENUM | DONT_DELETE | READ_ONLY);
866 %SetProperty($SIMD, "WYXZ", 0x87, DONT_ENUM | DONT_DELETE | READ_ONLY);
867 %SetProperty($SIMD, "WYXW", 0xC7, DONT_ENUM | DONT_DELETE | READ_ONLY);
868 %SetProperty($SIMD, "WYYX", 0x17, DONT_ENUM | DONT_DELETE | READ_ONLY);
869 %SetProperty($SIMD, "WYYY", 0x57, DONT_ENUM | DONT_DELETE | READ_ONLY);
870 %SetProperty($SIMD, "WYYZ", 0x97, DONT_ENUM | DONT_DELETE | READ_ONLY);
871 %SetProperty($SIMD, "WYYW", 0xD7, DONT_ENUM | DONT_DELETE | READ_ONLY);
872 %SetProperty($SIMD, "WYZX", 0x27, DONT_ENUM | DONT_DELETE | READ_ONLY);
873 %SetProperty($SIMD, "WYZY", 0x67, DONT_ENUM | DONT_DELETE | READ_ONLY);
874 %SetProperty($SIMD, "WYZZ", 0xA7, DONT_ENUM | DONT_DELETE | READ_ONLY);
875 %SetProperty($SIMD, "WYZW", 0xE7, DONT_ENUM | DONT_DELETE | READ_ONLY);
876 %SetProperty($SIMD, "WYWX", 0x37, DONT_ENUM | DONT_DELETE | READ_ONLY);
877 %SetProperty($SIMD, "WYWY", 0x77, DONT_ENUM | DONT_DELETE | READ_ONLY);
878 %SetProperty($SIMD, "WYWZ", 0xB7, DONT_ENUM | DONT_DELETE | READ_ONLY);
879 %SetProperty($SIMD, "WYWW", 0xF7, DONT_ENUM | DONT_DELETE | READ_ONLY);
880 %SetProperty($SIMD, "WZXX", 0x0B, DONT_ENUM | DONT_DELETE | READ_ONLY);
881 %SetProperty($SIMD, "WZXY", 0x4B, DONT_ENUM | DONT_DELETE | READ_ONLY);
882 %SetProperty($SIMD, "WZXZ", 0x8B, DONT_ENUM | DONT_DELETE | READ_ONLY);
883 %SetProperty($SIMD, "WZXW", 0xCB, DONT_ENUM | DONT_DELETE | READ_ONLY);
884 %SetProperty($SIMD, "WZYX", 0x1B, DONT_ENUM | DONT_DELETE | READ_ONLY);
885 %SetProperty($SIMD, "WZYY", 0x5B, DONT_ENUM | DONT_DELETE | READ_ONLY);
886 %SetProperty($SIMD, "WZYZ", 0x9B, DONT_ENUM | DONT_DELETE | READ_ONLY);
887 %SetProperty($SIMD, "WZYW", 0xDB, DONT_ENUM | DONT_DELETE | READ_ONLY);
888 %SetProperty($SIMD, "WZZX", 0x2B, DONT_ENUM | DONT_DELETE | READ_ONLY);
889 %SetProperty($SIMD, "WZZY", 0x6B, DONT_ENUM | DONT_DELETE | READ_ONLY);
890 %SetProperty($SIMD, "WZZZ", 0xAB, DONT_ENUM | DONT_DELETE | READ_ONLY);
891 %SetProperty($SIMD, "WZZW", 0xEB, DONT_ENUM | DONT_DELETE | READ_ONLY);
892 %SetProperty($SIMD, "WZWX", 0x3B, DONT_ENUM | DONT_DELETE | READ_ONLY);
893 %SetProperty($SIMD, "WZWY", 0x7B, DONT_ENUM | DONT_DELETE | READ_ONLY);
894 %SetProperty($SIMD, "WZWZ", 0xBB, DONT_ENUM | DONT_DELETE | READ_ONLY);
895 %SetProperty($SIMD, "WZWW", 0xFB, DONT_ENUM | DONT_DELETE | READ_ONLY);
896 %SetProperty($SIMD, "WWXX", 0x0F, DONT_ENUM | DONT_DELETE | READ_ONLY);
897 %SetProperty($SIMD, "WWXY", 0x4F, DONT_ENUM | DONT_DELETE | READ_ONLY);
898 %SetProperty($SIMD, "WWXZ", 0x8F, DONT_ENUM | DONT_DELETE | READ_ONLY);
899 %SetProperty($SIMD, "WWXW", 0xCF, DONT_ENUM | DONT_DELETE | READ_ONLY);
900 %SetProperty($SIMD, "WWYX", 0x1F, DONT_ENUM | DONT_DELETE | READ_ONLY);
901 %SetProperty($SIMD, "WWYY", 0x5F, DONT_ENUM | DONT_DELETE | READ_ONLY);
902 %SetProperty($SIMD, "WWYZ", 0x9F, DONT_ENUM | DONT_DELETE | READ_ONLY);
903 %SetProperty($SIMD, "WWYW", 0xDF, DONT_ENUM | DONT_DELETE | READ_ONLY);
904 %SetProperty($SIMD, "WWZX", 0x2F, DONT_ENUM | DONT_DELETE | READ_ONLY);
905 %SetProperty($SIMD, "WWZY", 0x6F, DONT_ENUM | DONT_DELETE | READ_ONLY);
906 %SetProperty($SIMD, "WWZZ", 0xAF, DONT_ENUM | DONT_DELETE | READ_ONLY);
907 %SetProperty($SIMD, "WWZW", 0xEF, DONT_ENUM | DONT_DELETE | READ_ONLY);
908 %SetProperty($SIMD, "WWWX", 0x3F, DONT_ENUM | DONT_DELETE | READ_ONLY);
909 %SetProperty($SIMD, "WWWY", 0x7F, DONT_ENUM | DONT_DELETE | READ_ONLY);
910 %SetProperty($SIMD, "WWWZ", 0xBF, DONT_ENUM | DONT_DELETE | READ_ONLY);
911 %SetProperty($SIMD, "WWWW", 0xFF, DONT_ENUM | DONT_DELETE | READ_ONLY);
912
913 %SetProperty($SIMD, "float32x4", new $Object(), DONT_ENUM | DONT_DELETE);
914 %SetProperty($SIMD, "int32x4", new $Object(), DONT_ENUM | DONT_DELETE);
915
916 %ToFastProperties($SIMD);
917
918 // Set up non-enumerable properties of the SIMD float32x4 object.
919 InstallFunctions($SIMD.float32x4, DONT_ENUM, $Array(
920 // Float32x4 operations
921 "abs", SIMDAbs,
922 "neg", SIMDNeg,
923 "add", SIMDAdd,
924 "sub", SIMDSub,
925 "mul", SIMDMul,
926 "div", SIMDDiv,
927 "clamp", SIMDClamp,
928 "min", SIMDMin,
929 "max", SIMDMax,
930 "reciprocal", SIMDReciprocal,
931 "reciprocalSqrt", SIMDReciprocalSqrt,
932 "scale", SIMDScale,
933 "sqrt", SIMDSqrt,
934 "shuffle", SIMDShuffle,
935 "shuffleMix", SIMDShuffleMix,
936 "withX", SIMDWithX,
937 "withY", SIMDWithY,
938 "withZ", SIMDWithZ,
939 "withW", SIMDWithW,
940 "lessThan", SIMDLessThan,
941 "lessThanOrEqual", SIMDLessThanOrEqual,
942 "equal", SIMDEqual,
943 "notEqual", SIMDNotEqual,
944 "greaterThanOrEqual", SIMDGreaterThanOrEqual,
945 "greaterThan", SIMDGreaterThan,
946 "bitsToInt32x4", SIMDBitsToInt32x4,
947 "toInt32x4", SIMDToInt32x4
948 ));
949
950 // Set up non-enumerable properties of the SIMD int32x4 object.
951 InstallFunctions($SIMD.int32x4, DONT_ENUM, $Array(
952 // Int32x4 operations
953 "and", SIMDAnd,
954 "or", SIMDOr,
955 "xor", SIMDXor,
956 "not", SIMDNot,
957 "neg", SIMDNegu32,
958 "add", SIMDAddu32,
959 "sub", SIMDSubu32,
960 "mul", SIMDMulu32,
961 "select", SIMDSelect,
962 "shuffle", SIMDShuffleu32,
963 "withX", SIMDWithXu32,
964 "withY", SIMDWithYu32,
965 "withZ", SIMDWithZu32,
966 "withW", SIMDWithWu32,
967 "withFlagX", SIMDWithFlagX,
968 "withFlagY", SIMDWithFlagY,
969 "withFlagZ", SIMDWithFlagZ,
970 "withFlagW", SIMDWithFlagW,
971 "bitsToFloat32x4", SIMDBitsToFloat32x4,
972 "toFloat32x4", SIMDToFloat32x4
973 ));
974
975 }
976
977 SetUpSIMD();
978
979 //------------------------------------------------------------------------------
980
981 macro FLOAT32x4OrINT32x4_TYPED_ARRAYS(FUNCTION)
982 // arrayIds below should be synchronized with Runtime_TypedArrayInitialize.
983 FUNCTION(10, Float32x4Array, 16)
984 FUNCTION(11, Int32x4Array, 16)
985 endmacro
986
987 macro TYPED_ARRAY_CONSTRUCTOR(ARRAY_ID, NAME, ELEMENT_SIZE)
988 function NAMEConstructor(arg1, arg2, arg3) {
989 function ConstructByArrayBuffer(obj, buffer, byteOffset, length) {
990 var offset = ToPositiveInteger(byteOffset, "invalid_typed_array_length")
991
992 if (offset % ELEMENT_SIZE !== 0) {
993 throw MakeRangeError("invalid_typed_array_alignment",
994 "start offset", "NAME", ELEMENT_SIZE);
995 }
996 var bufferByteLength = %ArrayBufferGetByteLength(buffer);
997 if (offset > bufferByteLength) {
998 throw MakeRangeError("invalid_typed_array_offset");
999 }
1000
1001 var newByteLength;
1002 var newLength;
1003 if (IS_UNDEFINED(length)) {
1004 if (bufferByteLength % ELEMENT_SIZE !== 0) {
1005 throw MakeRangeError("invalid_typed_array_alignment",
1006 "byte length", "NAME", ELEMENT_SIZE);
1007 }
1008 newByteLength = bufferByteLength - offset;
1009 newLength = newByteLength / ELEMENT_SIZE;
1010 } else {
1011 var newLength = ToPositiveInteger(length, "invalid_typed_array_length");
1012 newByteLength = newLength * ELEMENT_SIZE;
1013 }
1014 if (offset + newByteLength > bufferByteLength) {
1015 throw MakeRangeError("invalid_typed_array_length");
1016 }
1017 %TypedArrayInitialize(obj, ARRAY_ID, buffer, offset, newByteLength);
1018 }
1019
1020 function ConstructByLength(obj, length) {
1021 var l = ToPositiveInteger(length, "invalid_typed_array_length");
1022 var byteLength = l * ELEMENT_SIZE;
1023 var buffer = new $ArrayBuffer(byteLength);
1024 %TypedArrayInitialize(obj, ARRAY_ID, buffer, 0, byteLength);
1025 }
1026
1027 function ConstructByArrayLike(obj, arrayLike) {
1028 var length = arrayLike.length;
1029 var l = ToPositiveInteger(length, "invalid_typed_array_length");
1030 if(!%TypedArrayInitializeFromArrayLike(obj, ARRAY_ID, arrayLike, l)) {
1031 for (var i = 0; i < l; i++) {
1032 // It is crucial that we let any execptions from arrayLike[i]
1033 // propagate outside the function.
1034 obj[i] = arrayLike[i];
1035 }
1036 }
1037 }
1038
1039 if (%_IsConstructCall()) {
1040 if (IS_ARRAYBUFFER(arg1)) {
1041 ConstructByArrayBuffer(this, arg1, arg2, arg3);
1042 } else if (IS_NUMBER(arg1) || IS_STRING(arg1) ||
1043 IS_BOOLEAN(arg1) || IS_UNDEFINED(arg1)) {
1044 ConstructByLength(this, arg1);
1045 } else {
1046 ConstructByArrayLike(this, arg1);
1047 }
1048 } else {
1049 throw MakeTypeError("constructor_not_function", ["NAME"])
1050 }
1051 }
1052 endmacro
1053
1054 FLOAT32x4OrINT32x4_TYPED_ARRAYS(TYPED_ARRAY_CONSTRUCTOR)
1055
1056 function Float32x4ArrayGet(i) {
1057 return this[i];
1058 }
1059
1060 function Float32x4ArraySet(i, v) {
1061 v = TO_FLOAT32x4(v);
1062 CHECK_FLOAT32x4(v);
1063 this[i] = v;
1064 }
1065
1066 function SetUpFloat32x4Array() {
1067 // Keep synced with typedarray.js.
1068 SetupTypedArray(global.Float32x4Array, Float32x4ArrayConstructor, 16);
1069
1070 InstallFunctions(global.Float32x4Array.prototype, DONT_ENUM, $Array(
1071 "getAt", Float32x4ArrayGet,
1072 "setAt", Float32x4ArraySet
1073 ));
1074 }
1075
1076 SetUpFloat32x4Array();
1077
1078 function Int32x4ArrayGet(i) {
1079 return this[i];
1080 }
1081
1082 function Int32x4ArraySet(i, v) {
1083 v = TO_INT32x4(v);
1084 CHECK_INT32x4(v);
1085 this[i] = v;
1086 }
1087
1088 function SetUpInt32x4Array() {
1089 // Keep synced with typedarray.js.
1090 SetupTypedArray(global.Int32x4Array, Int32x4ArrayConstructor, 16);
1091
1092 InstallFunctions(global.Int32x4Array.prototype, DONT_ENUM, $Array(
1093 "getAt", Int32x4ArrayGet,
1094 "setAt", Int32x4ArraySet
1095 ));
1096 }
1097
1098 SetUpInt32x4Array();
OLDNEW
« no previous file with comments | « src/runtime.js ('k') | src/stub-cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698