webruby 0.2.2 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/webruby/config.rb +4 -9
- data/lib/webruby/rake/files.rake +2 -2
- data/modules/emscripten/AUTHORS +9 -1
- data/modules/emscripten/CONTRIBUTING.markdown +5 -0
- data/modules/emscripten/ChangeLog +435 -0
- data/modules/emscripten/cmake/Modules/FindOpenAL.cmake +26 -0
- data/modules/emscripten/cmake/Platform/Emscripten.cmake +9 -2
- data/modules/emscripten/em++ +0 -2
- data/modules/emscripten/emcc +92 -32
- data/modules/emscripten/emlink.py +16 -13
- data/modules/emscripten/emmake +1 -1
- data/modules/emscripten/emrun +918 -0
- data/modules/emscripten/emrun.bat +2 -0
- data/modules/emscripten/emscripten.py +545 -20
- data/modules/emscripten/src/analyzer.js +6 -1
- data/modules/emscripten/src/compiler.js +25 -16
- data/modules/emscripten/src/emrun_postjs.js +20 -0
- data/modules/emscripten/{tests → src}/hello_world.js +0 -0
- data/modules/emscripten/src/intertyper.js +45 -16
- data/modules/emscripten/src/jsifier.js +78 -48
- data/modules/emscripten/src/library.js +381 -96
- data/modules/emscripten/src/library_browser.js +50 -53
- data/modules/emscripten/src/library_egl.js +66 -24
- data/modules/emscripten/src/library_fs.js +122 -90
- data/modules/emscripten/src/library_gl.js +739 -353
- data/modules/emscripten/src/library_glfw.js +9 -3
- data/modules/emscripten/src/library_glut.js +10 -5
- data/modules/emscripten/src/library_idbfs.js +14 -14
- data/modules/emscripten/src/library_memfs.js +65 -41
- data/modules/emscripten/src/library_nodefs.js +61 -9
- data/modules/emscripten/src/library_openal.js +4 -4
- data/modules/emscripten/src/library_path.js +9 -13
- data/modules/emscripten/src/library_sdl.js +301 -64
- data/modules/emscripten/src/library_sockfs.js +7 -5
- data/modules/emscripten/src/modules.js +62 -22
- data/modules/emscripten/src/parseTools.js +135 -102
- data/modules/emscripten/src/postamble.js +3 -4
- data/modules/emscripten/src/preamble.js +49 -29
- data/modules/emscripten/src/proxyClient.js +1 -1
- data/modules/emscripten/src/proxyWorker.js +10 -10
- data/modules/emscripten/src/relooper/Relooper.cpp +15 -4
- data/modules/emscripten/src/runtime.js +32 -8
- data/modules/emscripten/src/settings.js +25 -8
- data/modules/emscripten/src/shell.html +6 -3
- data/modules/emscripten/src/shell.js +13 -11
- data/modules/emscripten/src/simd.js +602 -432
- data/modules/emscripten/src/struct_info.json +22 -2
- data/modules/emscripten/src/utility.js +32 -17
- data/modules/emscripten/system/include/SDL/SDL_events.h +1 -0
- data/modules/emscripten/system/include/compat/ctype.h +17 -0
- data/modules/emscripten/system/include/compat/wchar.h +23 -0
- data/modules/emscripten/system/include/compat/wctype.h +23 -0
- data/modules/emscripten/system/include/emscripten/emmintrin.h +87 -0
- data/modules/emscripten/system/include/emscripten/emscripten.h +30 -4
- data/modules/emscripten/system/include/emscripten/vector.h +29 -1
- data/modules/emscripten/system/include/emscripten/xmmintrin.h +131 -0
- data/modules/emscripten/system/include/libcxx/CREDITS.TXT +9 -1
- data/modules/emscripten/system/include/libcxx/__bit_reference +8 -8
- data/modules/emscripten/system/include/libcxx/__config +95 -17
- data/modules/emscripten/system/include/libcxx/__debug +25 -4
- data/modules/emscripten/system/include/libcxx/__functional_03 +7 -7
- data/modules/emscripten/system/include/libcxx/__functional_base +169 -9
- data/modules/emscripten/system/include/libcxx/__functional_base_03 +1 -1
- data/modules/emscripten/system/include/libcxx/__hash_table +25 -25
- data/modules/emscripten/system/include/libcxx/__locale +21 -19
- data/modules/emscripten/system/include/libcxx/__mutex_base +2 -33
- data/modules/emscripten/system/include/libcxx/__split_buffer +9 -9
- data/modules/emscripten/system/include/libcxx/__std_stream +14 -0
- data/modules/emscripten/system/include/libcxx/__tree +35 -26
- data/modules/emscripten/system/include/libcxx/__tuple +15 -15
- data/modules/emscripten/system/include/libcxx/__tuple_03 +2 -2
- data/modules/emscripten/system/include/libcxx/__undef_min_max +8 -0
- data/modules/emscripten/system/include/libcxx/algorithm +121 -110
- data/modules/emscripten/system/include/libcxx/array +15 -15
- data/modules/emscripten/system/include/libcxx/bitset +4 -4
- data/modules/emscripten/system/include/libcxx/chrono +51 -17
- data/modules/emscripten/system/include/libcxx/cmath +25 -23
- data/modules/emscripten/system/include/libcxx/codecvt +21 -18
- data/modules/emscripten/system/include/libcxx/complex +48 -7
- data/modules/emscripten/system/include/libcxx/cstddef +1 -1
- data/modules/emscripten/system/include/libcxx/cstdio +8 -1
- data/modules/emscripten/system/include/libcxx/cstdlib +1 -1
- data/modules/emscripten/system/include/libcxx/cwchar +1 -1
- data/modules/emscripten/system/include/libcxx/deque +26 -12
- data/modules/emscripten/system/include/libcxx/dynarray +311 -0
- data/modules/emscripten/system/include/libcxx/exception +4 -4
- data/modules/emscripten/system/include/libcxx/ext/__hash +3 -3
- data/modules/emscripten/system/include/libcxx/ext/hash_map +19 -15
- data/modules/emscripten/system/include/libcxx/ext/hash_set +7 -3
- data/modules/emscripten/system/include/libcxx/forward_list +33 -7
- data/modules/emscripten/system/include/libcxx/fstream +4 -4
- data/modules/emscripten/system/include/libcxx/functional +200 -170
- data/modules/emscripten/system/include/libcxx/future +83 -39
- data/modules/emscripten/system/include/libcxx/initializer_list +24 -11
- data/modules/emscripten/system/include/libcxx/iomanip +147 -0
- data/modules/emscripten/system/include/libcxx/ios +24 -16
- data/modules/emscripten/system/include/libcxx/iosfwd +19 -19
- data/modules/emscripten/system/include/libcxx/istream +13 -8
- data/modules/emscripten/system/include/libcxx/iterator +108 -417
- data/modules/emscripten/system/include/libcxx/limits +8 -4
- data/modules/emscripten/system/include/libcxx/list +28 -8
- data/modules/emscripten/system/include/libcxx/locale +153 -390
- data/modules/emscripten/system/include/libcxx/map +280 -100
- data/modules/emscripten/system/include/libcxx/memory +49 -97
- data/modules/emscripten/system/include/libcxx/mutex +2 -2
- data/modules/emscripten/system/include/libcxx/new +43 -14
- data/modules/emscripten/system/include/libcxx/numeric +2 -2
- data/modules/emscripten/system/include/libcxx/optional +697 -0
- data/modules/emscripten/system/include/libcxx/ostream +17 -8
- data/modules/emscripten/system/include/libcxx/queue +5 -5
- data/modules/emscripten/system/include/libcxx/random +53 -51
- data/modules/emscripten/system/include/libcxx/ratio +11 -11
- data/modules/emscripten/system/include/libcxx/readme.txt +1 -1
- data/modules/emscripten/system/include/libcxx/regex +23 -20
- data/modules/emscripten/system/include/libcxx/scoped_allocator +1 -1
- data/modules/emscripten/system/include/libcxx/set +166 -2
- data/modules/emscripten/system/include/libcxx/shared_mutex +419 -0
- data/modules/emscripten/system/include/libcxx/sstream +4 -4
- data/modules/emscripten/system/include/libcxx/stack +3 -3
- data/modules/emscripten/system/include/libcxx/streambuf +5 -5
- data/modules/emscripten/system/include/libcxx/string +372 -324
- data/modules/emscripten/system/include/libcxx/support/ibm/limits.h +99 -0
- data/modules/emscripten/system/include/libcxx/support/ibm/support.h +54 -0
- data/modules/emscripten/system/include/libcxx/support/ibm/xlocale.h +326 -0
- data/modules/emscripten/system/include/libcxx/support/win32/limits_win32.h +6 -6
- data/modules/emscripten/system/include/libcxx/support/win32/locale_win32.h +15 -15
- data/modules/emscripten/system/include/libcxx/support/win32/math_win32.h +2 -0
- data/modules/emscripten/system/include/libcxx/support/win32/support.h +6 -1
- data/modules/emscripten/system/include/libcxx/system_error +14 -8
- data/modules/emscripten/system/include/libcxx/thread +7 -8
- data/modules/emscripten/system/include/libcxx/tuple +29 -88
- data/modules/emscripten/system/include/libcxx/type_traits +253 -209
- data/modules/emscripten/system/include/libcxx/typeindex +3 -3
- data/modules/emscripten/system/include/libcxx/unordered_map +162 -101
- data/modules/emscripten/system/include/libcxx/unordered_set +79 -2
- data/modules/emscripten/system/include/libcxx/utility +20 -20
- data/modules/emscripten/system/include/libcxx/valarray +23 -23
- data/modules/emscripten/system/include/libcxx/vector +114 -91
- data/modules/emscripten/system/lib/libc/musl/src/regex/regcomp.c +3352 -0
- data/modules/emscripten/system/lib/libc/musl/src/regex/regerror.c +35 -0
- data/modules/emscripten/system/lib/libc/musl/src/regex/regexec.c +1011 -0
- data/modules/emscripten/system/lib/libc/musl/src/regex/tre-mem.c +158 -0
- data/modules/emscripten/system/lib/libc/musl/src/regex/tre.h +231 -0
- data/modules/emscripten/system/lib/libcextra.symbols +7 -0
- data/modules/emscripten/system/lib/libcxx/CREDITS.TXT +9 -1
- data/modules/emscripten/system/lib/libcxx/algorithm.cpp +1 -0
- data/modules/emscripten/system/lib/libcxx/debug.cpp +66 -42
- data/modules/emscripten/system/lib/libcxx/exception.cpp +88 -16
- data/modules/emscripten/system/lib/libcxx/future.cpp +6 -0
- data/modules/emscripten/system/lib/libcxx/ios.cpp +7 -2
- data/modules/emscripten/system/lib/libcxx/iostream.cpp +8 -8
- data/modules/emscripten/system/lib/libcxx/locale.cpp +38 -11
- data/modules/emscripten/system/lib/libcxx/mutex.cpp +3 -0
- data/modules/emscripten/system/lib/libcxx/new.cpp +44 -10
- data/modules/emscripten/system/lib/libcxx/optional.cpp +25 -0
- data/modules/emscripten/system/lib/libcxx/random.cpp +26 -0
- data/modules/emscripten/system/lib/libcxx/readme.txt +1 -1
- data/modules/emscripten/system/lib/libcxx/shared_mutex.cpp +101 -0
- data/modules/emscripten/system/lib/libcxx/stdexcept.cpp +11 -7
- data/modules/emscripten/system/lib/libcxx/string.cpp +3 -1
- data/modules/emscripten/system/lib/libcxx/strstream.cpp +7 -7
- data/modules/emscripten/system/lib/libcxx/support/win32/locale_win32.cpp +12 -13
- data/modules/emscripten/system/lib/libcxx/support/win32/support.cpp +33 -36
- data/modules/emscripten/system/lib/libcxx/symbols +187 -168
- data/modules/emscripten/system/lib/libcxx/system_error.cpp +1 -0
- data/modules/emscripten/system/lib/libcxx/thread.cpp +7 -3
- data/modules/emscripten/system/lib/libcxx/typeinfo.cpp +9 -6
- data/modules/emscripten/system/lib/libcxx/valarray.cpp +2 -0
- data/modules/emscripten/third_party/lzma.js/doit.bat +4 -0
- data/modules/emscripten/third_party/lzma.js/doit.sh +9 -2
- data/modules/emscripten/tools/cache.py +5 -7
- data/modules/emscripten/tools/cache.pyc +0 -0
- data/modules/emscripten/tools/eliminator/asm-eliminator-test-output.js +7 -0
- data/modules/emscripten/tools/eliminator/asm-eliminator-test.js +9 -1
- data/modules/emscripten/tools/eliminator/eliminator-test-output.js +3 -0
- data/modules/emscripten/tools/eliminator/eliminator-test.js +9 -1
- data/modules/emscripten/tools/file_packager.py +93 -50
- data/modules/emscripten/tools/js-optimizer.js +98 -48
- data/modules/emscripten/tools/js_optimizer.py +4 -4
- data/modules/emscripten/tools/js_optimizer.pyc +0 -0
- data/modules/emscripten/tools/jsrun.py +1 -1
- data/modules/emscripten/tools/jsrun.pyc +0 -0
- data/modules/emscripten/tools/response_file.py +6 -0
- data/modules/emscripten/tools/response_file.pyc +0 -0
- data/modules/emscripten/tools/settings_template_readonly.py +2 -0
- data/modules/emscripten/tools/shared.py +88 -34
- data/modules/emscripten/tools/shared.pyc +0 -0
- data/modules/emscripten/tools/split.py +21 -13
- data/modules/mruby/build_config.rb +7 -1
- data/modules/mruby/doc/compile/README.md +5 -9
- data/modules/mruby/include/mrbconf.h +5 -2
- data/modules/mruby/include/mruby/array.h +1 -0
- data/modules/mruby/include/mruby/compile.h +2 -4
- data/modules/mruby/include/mruby/dump.h +7 -16
- data/modules/mruby/include/mruby/hash.h +1 -1
- data/modules/mruby/include/mruby/irep.h +14 -2
- data/modules/mruby/include/mruby/khash.h +8 -7
- data/modules/mruby/include/mruby/string.h +1 -0
- data/modules/mruby/include/mruby/value.h +5 -2
- data/modules/mruby/include/mruby.h +12 -13
- data/modules/mruby/mrbgems/mruby-bin-mirb/tools/mirb/mirb.c +16 -6
- data/modules/mruby/mrbgems/mruby-bin-mruby/tools/mruby/mruby.c +18 -30
- data/modules/mruby/mrbgems/mruby-fiber/src/fiber.c +21 -0
- data/modules/mruby/mrbgems/mruby-math/src/math.c +1 -1
- data/modules/mruby/mrbgems/mruby-random/src/random.c +144 -47
- data/modules/mruby/mrbgems/mruby-random/test/random.rb +44 -0
- data/modules/mruby/mrbgems/mruby-struct/src/struct.c +5 -5
- data/modules/mruby/mrblib/numeric.rb +99 -33
- data/modules/mruby/src/array.c +11 -4
- data/modules/mruby/src/backtrace.c +2 -2
- data/modules/mruby/src/class.c +49 -30
- data/modules/mruby/src/codegen.c +131 -79
- data/modules/mruby/src/debug.c +1 -1
- data/modules/mruby/src/dump.c +213 -163
- data/modules/mruby/src/error.c +17 -17
- data/modules/mruby/src/error.h +1 -1
- data/modules/mruby/src/etc.c +10 -0
- data/modules/mruby/src/gc.c +35 -17
- data/modules/mruby/src/hash.c +5 -5
- data/modules/mruby/src/kernel.c +36 -14
- data/modules/mruby/src/load.c +238 -296
- data/modules/mruby/src/numeric.c +18 -98
- data/modules/mruby/src/object.c +3 -5
- data/modules/mruby/src/parse.y +63 -56
- data/modules/mruby/src/proc.c +8 -5
- data/modules/mruby/src/re.h +0 -1
- data/modules/mruby/src/state.c +65 -27
- data/modules/mruby/src/string.c +3 -31
- data/modules/mruby/src/symbol.c +3 -3
- data/modules/mruby/src/variable.c +12 -5
- data/modules/mruby/src/vm.c +90 -72
- data/modules/mruby/tasks/mruby_build.rake +10 -1
- data/modules/mruby/tasks/toolchains/gcc.rake +12 -2
- data/modules/mruby/tasks/toolchains/{vs2012.rake → visualcpp.rake} +1 -1
- data/modules/mruby/test/driver.c +3 -3
- data/modules/mruby/test/t/array.rb +5 -5
- data/modules/mruby/test/t/class.rb +14 -1
- data/modules/mruby/test/t/kernel.rb +4 -0
- data/modules/mruby/test/t/module.rb +4 -4
- data/modules/mruby/test/t/nameerror.rb +1 -1
- data/modules/mruby/tools/mrbc/mrbc.c +23 -17
- data/modules/mruby/travis_config.rb +10 -1
- metadata +28 -5
- data/modules/mruby/tasks/toolchains/vs2010.rake +0 -3
@@ -20,8 +20,10 @@
|
|
20
20
|
https://github.com/johnmccutchan/ecmascript_simd/blob/master/src/ecmascript_simd.js
|
21
21
|
*/
|
22
22
|
|
23
|
+
"use strict";
|
24
|
+
|
23
25
|
/**
|
24
|
-
* Construct a new instance of
|
26
|
+
* Construct a new instance of float32x4 number.
|
25
27
|
* @param {double} value used for x lane.
|
26
28
|
* @param {double} value used for y lane.
|
27
29
|
* @param {double} value used for z lane.
|
@@ -40,7 +42,7 @@ function float32x4(x, y, z, w) {
|
|
40
42
|
}
|
41
43
|
|
42
44
|
/**
|
43
|
-
* Construct a new instance of
|
45
|
+
* Construct a new instance of float32x4 number with 0.0 in all lanes.
|
44
46
|
* @constructor
|
45
47
|
*/
|
46
48
|
float32x4.zero = function() {
|
@@ -48,7 +50,7 @@ float32x4.zero = function() {
|
|
48
50
|
}
|
49
51
|
|
50
52
|
/**
|
51
|
-
* Construct a new instance of
|
53
|
+
* Construct a new instance of float32x4 number with the same value
|
52
54
|
* in all lanes.
|
53
55
|
* @param {double} value used for all lanes.
|
54
56
|
* @constructor
|
@@ -87,18 +89,18 @@ Object.defineProperty(float32x4.prototype, 'signMask', {
|
|
87
89
|
});
|
88
90
|
|
89
91
|
/**
|
90
|
-
* Construct a new instance of
|
92
|
+
* Construct a new instance of int32x4 number.
|
91
93
|
* @param {integer} 32-bit unsigned value used for x lane.
|
92
94
|
* @param {integer} 32-bit unsigned value used for y lane.
|
93
95
|
* @param {integer} 32-bit unsigned value used for z lane.
|
94
96
|
* @param {integer} 32-bit unsigned value used for w lane.
|
95
97
|
* @constructor
|
96
98
|
*/
|
97
|
-
function
|
98
|
-
if (!(this instanceof
|
99
|
-
return new
|
99
|
+
function int32x4(x, y, z, w) {
|
100
|
+
if (!(this instanceof int32x4)) {
|
101
|
+
return new int32x4(x, y, z, w);
|
100
102
|
}
|
101
|
-
this.storage_ = new
|
103
|
+
this.storage_ = new Int32Array(4);
|
102
104
|
this.storage_[0] = x;
|
103
105
|
this.storage_[1] = y;
|
104
106
|
this.storage_[2] = z;
|
@@ -106,7 +108,7 @@ function uint32x4(x, y, z, w) {
|
|
106
108
|
}
|
107
109
|
|
108
110
|
/**
|
109
|
-
* Construct a new instance of
|
111
|
+
* Construct a new instance of int32x4 number with 0xFFFFFFFF or 0x0 in each
|
110
112
|
* lane, depending on the truth value in x, y, z, and w.
|
111
113
|
* @param {boolean} flag used for x lane.
|
112
114
|
* @param {boolean} flag used for y lane.
|
@@ -114,59 +116,59 @@ function uint32x4(x, y, z, w) {
|
|
114
116
|
* @param {boolean} flag used for w lane.
|
115
117
|
* @constructor
|
116
118
|
*/
|
117
|
-
|
118
|
-
return
|
119
|
-
y ?
|
120
|
-
z ?
|
121
|
-
w ?
|
119
|
+
int32x4.bool = function(x, y, z, w) {
|
120
|
+
return int32x4(x ? -1 : 0x0,
|
121
|
+
y ? -1 : 0x0,
|
122
|
+
z ? -1 : 0x0,
|
123
|
+
w ? -1 : 0x0);
|
122
124
|
}
|
123
125
|
|
124
126
|
/**
|
125
|
-
* Construct a new instance of
|
127
|
+
* Construct a new instance of int32x4 number with the same value
|
126
128
|
* in all lanes.
|
127
129
|
* @param {integer} value used for all lanes.
|
128
130
|
* @constructor
|
129
131
|
*/
|
130
|
-
|
131
|
-
return
|
132
|
+
int32x4.splat = function(s) {
|
133
|
+
return int32x4(s, s, s, s);
|
132
134
|
}
|
133
135
|
|
134
|
-
Object.defineProperty(
|
136
|
+
Object.defineProperty(int32x4.prototype, 'x', {
|
135
137
|
get: function() { return this.storage_[0]; }
|
136
138
|
});
|
137
139
|
|
138
|
-
Object.defineProperty(
|
140
|
+
Object.defineProperty(int32x4.prototype, 'y', {
|
139
141
|
get: function() { return this.storage_[1]; }
|
140
142
|
});
|
141
143
|
|
142
|
-
Object.defineProperty(
|
144
|
+
Object.defineProperty(int32x4.prototype, 'z', {
|
143
145
|
get: function() { return this.storage_[2]; }
|
144
146
|
});
|
145
147
|
|
146
|
-
Object.defineProperty(
|
148
|
+
Object.defineProperty(int32x4.prototype, 'w',
|
147
149
|
{ get: function() { return this.storage_[3]; }
|
148
150
|
});
|
149
151
|
|
150
|
-
Object.defineProperty(
|
152
|
+
Object.defineProperty(int32x4.prototype, 'flagX', {
|
151
153
|
get: function() { return this.storage_[0] != 0x0; }
|
152
154
|
});
|
153
155
|
|
154
|
-
Object.defineProperty(
|
156
|
+
Object.defineProperty(int32x4.prototype, 'flagY', {
|
155
157
|
get: function() { return this.storage_[1] != 0x0; }
|
156
158
|
});
|
157
159
|
|
158
|
-
Object.defineProperty(
|
160
|
+
Object.defineProperty(int32x4.prototype, 'flagZ', {
|
159
161
|
get: function() { return this.storage_[2] != 0x0; }
|
160
162
|
});
|
161
163
|
|
162
|
-
Object.defineProperty(
|
164
|
+
Object.defineProperty(int32x4.prototype, 'flagW',
|
163
165
|
{ get: function() { return this.storage_[3] != 0x0; }
|
164
166
|
});
|
165
167
|
|
166
168
|
/**
|
167
169
|
* Extract the sign bit from each lane return them in the first 4 bits.
|
168
170
|
*/
|
169
|
-
Object.defineProperty(
|
171
|
+
Object.defineProperty(int32x4.prototype, 'signMask', {
|
170
172
|
get: function() {
|
171
173
|
var mx = (this.storage_[0] & 0x80000000) >>> 31;
|
172
174
|
var my = (this.storage_[1] & 0x80000000) >>> 31;
|
@@ -287,414 +289,583 @@ Float32x4Array.prototype.setAt = function(i, v) {
|
|
287
289
|
this.storage_[i*4+3] = v.w;
|
288
290
|
}
|
289
291
|
|
292
|
+
|
293
|
+
function Int32x4Array(a, b, c) {
|
294
|
+
|
295
|
+
function isNumber(o) {
|
296
|
+
return typeof o == "number" || (typeof o == "object" && o.constructor === Number);
|
297
|
+
}
|
298
|
+
|
299
|
+
function isTypedArray(o) {
|
300
|
+
return (o instanceof Int8Array) ||
|
301
|
+
(o instanceof Uint8Array) ||
|
302
|
+
(o instanceof Uint8ClampedArray) ||
|
303
|
+
(o instanceof Int16Array) ||
|
304
|
+
(o instanceof Uint16Array) ||
|
305
|
+
(o instanceof Int32Array) ||
|
306
|
+
(o instanceof Uint32Array) ||
|
307
|
+
(o instanceof Float32Array) ||
|
308
|
+
(o instanceof Float64Array) ||
|
309
|
+
(o instanceof Int32x4Array) ||
|
310
|
+
(o instanceof Float32x4Array);
|
311
|
+
}
|
312
|
+
|
313
|
+
function isArrayBuffer(o) {
|
314
|
+
return (o instanceof ArrayBuffer);
|
315
|
+
}
|
316
|
+
|
317
|
+
if (isNumber(a)) {
|
318
|
+
this.storage_ = new Int32Array(a*4);
|
319
|
+
this.length_ = a;
|
320
|
+
this.byteOffset_ = 0;
|
321
|
+
return;
|
322
|
+
} else if (isTypedArray(a)) {
|
323
|
+
if (!(a instanceof Int32x4Array)) {
|
324
|
+
throw "Copying typed array of non-Int32x4Array is unimplemented.";
|
325
|
+
}
|
326
|
+
this.storage_ = new Int32Array(a.length * 4);
|
327
|
+
this.length_ = a.length;
|
328
|
+
this.byteOffset_ = 0;
|
329
|
+
// Copy floats.
|
330
|
+
for (var i = 0; i < a.length*4; i++) {
|
331
|
+
this.storage_[i] = a.storage_[i];
|
332
|
+
}
|
333
|
+
} else if (isArrayBuffer(a)) {
|
334
|
+
if ((b != undefined) && (b % Int32x4Array.BYTES_PER_ELEMENT) != 0) {
|
335
|
+
throw "byteOffset must be a multiple of 16.";
|
336
|
+
}
|
337
|
+
if (c != undefined) {
|
338
|
+
c *= 4;
|
339
|
+
this.storage_ = new Int32Array(a, b, c);
|
340
|
+
}
|
341
|
+
else {
|
342
|
+
// Note: new Int32Array(a, b) is NOT equivalent to new Float32Array(a, b, undefined)
|
343
|
+
this.storage_ = new Int32Array(a, b);
|
344
|
+
}
|
345
|
+
this.length_ = this.storage_.length / 4;
|
346
|
+
this.byteOffset_ = b != undefined ? b : 0;
|
347
|
+
} else {
|
348
|
+
throw "Unknown type of first argument.";
|
349
|
+
}
|
350
|
+
}
|
351
|
+
|
352
|
+
Object.defineProperty(Int32x4Array.prototype, 'length',
|
353
|
+
{ get: function() { return this.length_; }
|
354
|
+
});
|
355
|
+
|
356
|
+
Object.defineProperty(Int32x4Array.prototype, 'byteLength',
|
357
|
+
{ get: function() { return this.length_ * Int32x4Array.BYTES_PER_ELEMENT; }
|
358
|
+
});
|
359
|
+
|
360
|
+
Object.defineProperty(Int32x4Array, 'BYTES_PER_ELEMENT',
|
361
|
+
{ get: function() { return 16; }
|
362
|
+
});
|
363
|
+
|
364
|
+
Object.defineProperty(Int32x4Array.prototype, 'BYTES_PER_ELEMENT',
|
365
|
+
{ get: function() { return 16; }
|
366
|
+
});
|
367
|
+
|
368
|
+
Object.defineProperty(Int32x4Array.prototype, 'byteOffset',
|
369
|
+
{ get: function() { return this.byteOffset_; }
|
370
|
+
});
|
371
|
+
|
372
|
+
Object.defineProperty(Int32x4Array.prototype, 'buffer',
|
373
|
+
{ get: function() { return this.storage_.buffer; }
|
374
|
+
});
|
375
|
+
|
376
|
+
Int32x4Array.prototype.getAt = function(i) {
|
377
|
+
if (i < 0) {
|
378
|
+
throw "Index must be >= 0.";
|
379
|
+
}
|
380
|
+
if (i >= this.length) {
|
381
|
+
throw "Index out of bounds.";
|
382
|
+
}
|
383
|
+
var x = this.storage_[i*4+0];
|
384
|
+
var y = this.storage_[i*4+1];
|
385
|
+
var z = this.storage_[i*4+2];
|
386
|
+
var w = this.storage_[i*4+3];
|
387
|
+
return float32x4(x, y, z, w);
|
388
|
+
}
|
389
|
+
|
390
|
+
Int32x4Array.prototype.setAt = function(i, v) {
|
391
|
+
if (i < 0) {
|
392
|
+
throw "Index must be >= 0.";
|
393
|
+
}
|
394
|
+
if (i >= this.length) {
|
395
|
+
throw "Index out of bounds.";
|
396
|
+
}
|
397
|
+
if (!(v instanceof int32x4)) {
|
398
|
+
throw "Value is not a int32x4.";
|
399
|
+
}
|
400
|
+
this.storage_[i*4+0] = v.x;
|
401
|
+
this.storage_[i*4+1] = v.y;
|
402
|
+
this.storage_[i*4+2] = v.z;
|
403
|
+
this.storage_[i*4+3] = v.w;
|
404
|
+
}
|
405
|
+
|
290
406
|
var SIMD = (function () {
|
291
407
|
return {
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
408
|
+
float32x4: {
|
409
|
+
/**
|
410
|
+
* @return {float32x4} New instance of float32x4 with absolute values of
|
411
|
+
* t.
|
412
|
+
*/
|
413
|
+
abs: function(t) {
|
414
|
+
return new float32x4(Math.abs(t.x), Math.abs(t.y), Math.abs(t.z),
|
415
|
+
Math.abs(t.w));
|
416
|
+
},
|
417
|
+
/**
|
418
|
+
* @return {float32x4} New instance of float32x4 with negated values of
|
419
|
+
* t.
|
420
|
+
*/
|
421
|
+
neg: function(t) {
|
422
|
+
return new float32x4(-t.x, -t.y, -t.z, -t.w);
|
423
|
+
},
|
424
|
+
/**
|
425
|
+
* @return {float32x4} New instance of float32x4 with a + b.
|
426
|
+
*/
|
427
|
+
add: function(a, b) {
|
428
|
+
return new float32x4(a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w);
|
429
|
+
},
|
430
|
+
/**
|
431
|
+
* @return {float32x4} New instance of float32x4 with a - b.
|
432
|
+
*/
|
433
|
+
sub: function(a, b) {
|
434
|
+
return new float32x4(a.x - b.x, a.y - b.y, a.z - b.z, a.w - b.w);
|
435
|
+
},
|
436
|
+
/**
|
437
|
+
* @return {float32x4} New instance of float32x4 with a * b.
|
438
|
+
*/
|
439
|
+
mul: function(a, b) {
|
440
|
+
return new float32x4(a.x * b.x, a.y * b.y, a.z * b.z, a.w * b.w);
|
441
|
+
},
|
442
|
+
/**
|
443
|
+
* @return {float32x4} New instance of float32x4 with a / b.
|
444
|
+
*/
|
445
|
+
div: function(a, b) {
|
446
|
+
return new float32x4(a.x / b.x, a.y / b.y, a.z / b.z, a.w / b.w);
|
447
|
+
},
|
448
|
+
/**
|
449
|
+
* @return {float32x4} New instance of float32x4 with t's values clamped
|
450
|
+
* between lowerLimit and upperLimit.
|
451
|
+
*/
|
452
|
+
clamp: function(t, lowerLimit, upperLimit) {
|
453
|
+
var cx = t.x < lowerLimit.x ? lowerLimit.x : t.x;
|
454
|
+
var cy = t.y < lowerLimit.y ? lowerLimit.y : t.y;
|
455
|
+
var cz = t.z < lowerLimit.z ? lowerLimit.z : t.z;
|
456
|
+
var cw = t.w < lowerLimit.w ? lowerLimit.w : t.w;
|
457
|
+
cx = cx > upperLimit.x ? upperLimit.x : cx;
|
458
|
+
cy = cy > upperLimit.y ? upperLimit.y : cy;
|
459
|
+
cz = cz > upperLimit.z ? upperLimit.z : cz;
|
460
|
+
cw = cw > upperLimit.w ? upperLimit.w : cw;
|
461
|
+
return new float32x4(cx, cy, cz, cw);
|
462
|
+
},
|
463
|
+
/**
|
464
|
+
* @return {float32x4} New instance of float32x4 with the minimum value of
|
465
|
+
* t and other.
|
466
|
+
*/
|
467
|
+
min: function(t, other) {
|
468
|
+
var cx = t.x > other.x ? other.x : t.x;
|
469
|
+
var cy = t.y > other.y ? other.y : t.y;
|
470
|
+
var cz = t.z > other.z ? other.z : t.z;
|
471
|
+
var cw = t.w > other.w ? other.w : t.w;
|
472
|
+
return new float32x4(cx, cy, cz, cw);
|
473
|
+
},
|
474
|
+
/**
|
475
|
+
* @return {float32x4} New instance of float32x4 with the maximum value of
|
476
|
+
* t and other.
|
477
|
+
*/
|
478
|
+
max: function(t, other) {
|
479
|
+
var cx = t.x < other.x ? other.x : t.x;
|
480
|
+
var cy = t.y < other.y ? other.y : t.y;
|
481
|
+
var cz = t.z < other.z ? other.z : t.z;
|
482
|
+
var cw = t.w < other.w ? other.w : t.w;
|
483
|
+
return new float32x4(cx, cy, cz, cw);
|
484
|
+
},
|
485
|
+
/**
|
486
|
+
* @return {float32x4} New instance of float32x4 with reciprocal value of
|
487
|
+
* t.
|
488
|
+
*/
|
489
|
+
reciprocal: function(t) {
|
490
|
+
return new float32x4(1.0 / t.x, 1.0 / t.y, 1.0 / t.z, 1.0 / t.w);
|
491
|
+
},
|
492
|
+
/**
|
493
|
+
* @return {float32x4} New instance of float32x4 with square root of the
|
494
|
+
* reciprocal value of t.
|
495
|
+
*/
|
496
|
+
reciprocalSqrt: function(t) {
|
497
|
+
return new float32x4(Math.sqrt(1.0 / t.x), Math.sqrt(1.0 / t.y),
|
498
|
+
Math.sqrt(1.0 / t.z), Math.sqrt(1.0 / t.w));
|
499
|
+
},
|
500
|
+
/**
|
501
|
+
* @return {float32x4} New instance of float32x4 with values of t
|
502
|
+
* scaled by s.
|
503
|
+
*/
|
504
|
+
scale: function(t, s) {
|
505
|
+
return new float32x4(s * t.x, s * t.y, s * t.z, s * t.w);
|
506
|
+
},
|
507
|
+
/**
|
508
|
+
* @return {float32x4} New instance of float32x4 with square root of
|
509
|
+
* values of t.
|
510
|
+
*/
|
511
|
+
sqrt: function(t) {
|
512
|
+
return new float32x4(Math.sqrt(t.x), Math.sqrt(t.y),
|
513
|
+
Math.sqrt(t.z), Math.sqrt(t.w));
|
514
|
+
},
|
515
|
+
/**
|
516
|
+
* @param {float32x4} t An instance of float32x4 to be shuffled.
|
517
|
+
* @param {integer} mask One of the 256 shuffle masks, for example, SIMD.XXXX.
|
518
|
+
* @return {float32x4} New instance of float32x4 with lanes shuffled.
|
519
|
+
*/
|
520
|
+
shuffle: function(t, mask) {
|
521
|
+
var _x = (mask) & 0x3;
|
522
|
+
var _y = (mask >> 2) & 0x3;
|
523
|
+
var _z = (mask >> 4) & 0x3;
|
524
|
+
var _w = (mask >> 6) & 0x3;
|
525
|
+
return new float32x4(t.storage_[_x], t.storage_[_y], t.storage_[_z],
|
526
|
+
t.storage_[_w]);
|
527
|
+
},
|
528
|
+
/**
|
529
|
+
* @param {float32x4} t1 An instance of float32x4 to be shuffled. XY lanes in result
|
530
|
+
* @param {float32x4} t2 An instance of float32x4 to be shuffled. ZW lanes in result
|
531
|
+
* @param {integer} mask One of the 256 shuffle masks, for example, SIMD.XXXX.
|
532
|
+
* @return {float32x4} New instance of float32x4 with lanes shuffled.
|
533
|
+
*/
|
534
|
+
shuffleMix: function(t1, t2, mask) {
|
535
|
+
var _x = (mask) & 0x3;
|
536
|
+
var _y = (mask >> 2) & 0x3;
|
537
|
+
var _z = (mask >> 4) & 0x3;
|
538
|
+
var _w = (mask >> 6) & 0x3;
|
539
|
+
return new float32x4(t1.storage_[_x], t1.storage_[_y], t2.storage_[_z],
|
540
|
+
t2.storage_[_w]);
|
541
|
+
},
|
542
|
+
/**
|
543
|
+
* @param {double} value used for x lane.
|
544
|
+
* @return {float32x4} New instance of float32x4 with the values in t and
|
545
|
+
* x replaced with {x}.
|
546
|
+
*/
|
547
|
+
withX: function(t, x) {
|
548
|
+
return new float32x4(x, t.y, t.z, t.w);
|
549
|
+
},
|
550
|
+
/**
|
551
|
+
* @param {double} value used for y lane.
|
552
|
+
* @return {float32x4} New instance of float32x4 with the values in t and
|
553
|
+
* y replaced with {y}.
|
554
|
+
*/
|
555
|
+
withY: function(t, y) {
|
556
|
+
return new float32x4(t.x, y, t.z, t.w);
|
557
|
+
},
|
558
|
+
/**
|
559
|
+
* @param {double} value used for z lane.
|
560
|
+
* @return {float32x4} New instance of float32x4 with the values in t and
|
561
|
+
* z replaced with {z}.
|
562
|
+
*/
|
563
|
+
withZ: function(t, z) {
|
564
|
+
return new float32x4(t.x, t.y, z, t.w);
|
565
|
+
},
|
566
|
+
/**
|
567
|
+
* @param {double} value used for w lane.
|
568
|
+
* @return {float32x4} New instance of float32x4 with the values in t and
|
569
|
+
* w replaced with {w}.
|
570
|
+
*/
|
571
|
+
withW: function(t, w) {
|
572
|
+
return new float32x4(t.x, t.y, t.z, w);
|
573
|
+
},
|
574
|
+
/**
|
575
|
+
* @param {float32x4} t An instance of float32x4.
|
576
|
+
* @param {float32x4} other An instance of float32x4.
|
577
|
+
* @return {int32x4} 0xFFFFFFFF or 0x0 in each lane depending on
|
578
|
+
* the result of t < other.
|
579
|
+
*/
|
580
|
+
lessThan: function(t, other) {
|
581
|
+
var cx = t.x < other.x;
|
582
|
+
var cy = t.y < other.y;
|
583
|
+
var cz = t.z < other.z;
|
584
|
+
var cw = t.w < other.w;
|
585
|
+
return int32x4.bool(cx, cy, cz, cw);
|
586
|
+
},
|
587
|
+
/**
|
588
|
+
* @param {float32x4} t An instance of float32x4.
|
589
|
+
* @param {float32x4} other An instance of float32x4.
|
590
|
+
* @return {int32x4} 0xFFFFFFFF or 0x0 in each lane depending on
|
591
|
+
* the result of t <= other.
|
592
|
+
*/
|
593
|
+
lessThanOrEqual: function(t, other) {
|
594
|
+
var cx = t.x <= other.x;
|
595
|
+
var cy = t.y <= other.y;
|
596
|
+
var cz = t.z <= other.z;
|
597
|
+
var cw = t.w <= other.w;
|
598
|
+
return int32x4.bool(cx, cy, cz, cw);
|
599
|
+
},
|
600
|
+
/**
|
601
|
+
* @param {float32x4} t An instance of float32x4.
|
602
|
+
* @param {float32x4} other An instance of float32x4.
|
603
|
+
* @return {int32x4} 0xFFFFFFFF or 0x0 in each lane depending on
|
604
|
+
* the result of t == other.
|
605
|
+
*/
|
606
|
+
equal: function(t, other) {
|
607
|
+
var cx = t.x == other.x;
|
608
|
+
var cy = t.y == other.y;
|
609
|
+
var cz = t.z == other.z;
|
610
|
+
var cw = t.w == other.w;
|
611
|
+
return int32x4.bool(cx, cy, cz, cw);
|
612
|
+
},
|
613
|
+
/**
|
614
|
+
* @param {float32x4} t An instance of float32x4.
|
615
|
+
* @param {float32x4} other An instance of float32x4.
|
616
|
+
* @return {int32x4} 0xFFFFFFFF or 0x0 in each lane depending on
|
617
|
+
* the result of t != other.
|
618
|
+
*/
|
619
|
+
notEqual: function(t, other) {
|
620
|
+
var cx = t.x != other.x;
|
621
|
+
var cy = t.y != other.y;
|
622
|
+
var cz = t.z != other.z;
|
623
|
+
var cw = t.w != other.w;
|
624
|
+
return int32x4.bool(cx, cy, cz, cw);
|
625
|
+
},
|
626
|
+
/**
|
627
|
+
* @param {float32x4} t An instance of float32x4.
|
628
|
+
* @param {float32x4} other An instance of float32x4.
|
629
|
+
* @return {int32x4} 0xFFFFFFFF or 0x0 in each lane depending on
|
630
|
+
* the result of t >= other.
|
631
|
+
*/
|
632
|
+
greaterThanOrEqual: function(t, other) {
|
633
|
+
var cx = t.x >= other.x;
|
634
|
+
var cy = t.y >= other.y;
|
635
|
+
var cz = t.z >= other.z;
|
636
|
+
var cw = t.w >= other.w;
|
637
|
+
return int32x4.bool(cx, cy, cz, cw);
|
638
|
+
},
|
639
|
+
/**
|
640
|
+
* @param {float32x4} t An instance of float32x4.
|
641
|
+
* @param {float32x4} other An instance of float32x4.
|
642
|
+
* @return {int32x4} 0xFFFFFFFF or 0x0 in each lane depending on
|
643
|
+
* the result of t > other.
|
644
|
+
*/
|
645
|
+
greaterThan: function(t, other) {
|
646
|
+
var cx = t.x > other.x;
|
647
|
+
var cy = t.y > other.y;
|
648
|
+
var cz = t.z > other.z;
|
649
|
+
var cw = t.w > other.w;
|
650
|
+
return int32x4.bool(cx, cy, cz, cw);
|
651
|
+
},
|
652
|
+
/**
|
653
|
+
* @param {float32x4} t An instance of float32x4.
|
654
|
+
* @return {int32x4} a bit-wise copy of t as a int32x4.
|
655
|
+
*/
|
656
|
+
bitsToInt32x4: function(t) {
|
657
|
+
var alias = new Int32Array(t.storage_.buffer);
|
658
|
+
return new int32x4(alias[0], alias[1], alias[2], alias[3]);
|
659
|
+
},
|
660
|
+
/**
|
661
|
+
* @param {float32x4} t An instance of float32x4.
|
662
|
+
* @return {int32x4} with a integer to float conversion of t.
|
663
|
+
*/
|
664
|
+
toInt32x4: function(t) {
|
665
|
+
var a = new int32x4(t.storage_[0], t.storage_[1], t.storage_[2],
|
666
|
+
t.storage_[3]);
|
667
|
+
return a;
|
668
|
+
}
|
410
669
|
},
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
*/
|
611
|
-
withZu32: function(t, z) {
|
612
|
-
return new uint32x4(t.x, t.y, z, t.w);
|
613
|
-
},
|
614
|
-
/**
|
615
|
-
* @param {integer} 32-bit value used for w lane.
|
616
|
-
* @return {uint32x4} New instance of uint32x4 with the values in t and
|
617
|
-
* w lane replaced with {w}.
|
618
|
-
*/
|
619
|
-
withWu32: function(t, w) {
|
620
|
-
return new uint32x4(t.x, t.y, t.z, w);
|
621
|
-
},
|
622
|
-
/**
|
623
|
-
* @param {uint32x4} t An instance of a uint32x4.
|
624
|
-
* @param {boolean} x flag used for x lane.
|
625
|
-
* @return {uint32x4} New instance of uint32x4 with the values in t and
|
626
|
-
* x lane replaced with {x}.
|
627
|
-
*/
|
628
|
-
withFlagX: function(t, flagX) {
|
629
|
-
var x = flagX ? 0xFFFFFFFF : 0x0;
|
630
|
-
return new uint32x4(x, t.y, t.z, t.w);
|
631
|
-
},
|
632
|
-
/**
|
633
|
-
* @param {uint32x4} t An instance of a uint32x4.
|
634
|
-
* @param {boolean} y flag used for y lane.
|
635
|
-
* @return {uint32x4} New instance of uint32x4 with the values in t and
|
636
|
-
* y lane replaced with {y}.
|
637
|
-
*/
|
638
|
-
withFlagY: function(t, flagY) {
|
639
|
-
var y = flagY ? 0xFFFFFFFF : 0x0;
|
640
|
-
return new uint32x4(t.x, y, t.z, t.w);
|
641
|
-
},
|
642
|
-
/**
|
643
|
-
* @param {uint32x4} t An instance of a uint32x4.
|
644
|
-
* @param {boolean} z flag used for z lane.
|
645
|
-
* @return {uint32x4} New instance of uint32x4 with the values in t and
|
646
|
-
* z lane replaced with {z}.
|
647
|
-
*/
|
648
|
-
withFlagZ: function(t, flagZ) {
|
649
|
-
var z = flagZ ? 0xFFFFFFFF : 0x0;
|
650
|
-
return new uint32x4(t.x, t.y, z, t.w);
|
651
|
-
},
|
652
|
-
/**
|
653
|
-
* @param {uint32x4} t An instance of a uint32x4.
|
654
|
-
* @param {boolean} w flag used for w lane.
|
655
|
-
* @return {uint32x4} New instance of uint32x4 with the values in t and
|
656
|
-
* w lane replaced with {w}.
|
657
|
-
*/
|
658
|
-
withFlagW: function(t, flagW) {
|
659
|
-
var w = flagW ? 0xFFFFFFFF : 0x0;
|
660
|
-
return new uint32x4(t.x, t.y, t.z, w);
|
661
|
-
},
|
662
|
-
/**
|
663
|
-
* @param {float32x4} t An instance of a float32x4.
|
664
|
-
* @return {uint32x4} a bit-wise copy of t as a uint32x4.
|
665
|
-
*/
|
666
|
-
float32x4BitsToUint32x4: function(t) {
|
667
|
-
var alias = new Uint32Array(t.storage_.buffer);
|
668
|
-
return new uint32x4(alias[0], alias[1], alias[2], alias[3]);
|
669
|
-
},
|
670
|
-
/**
|
671
|
-
* @param {uint32x4} t An instance of a uint32x4.
|
672
|
-
* @return {float32x4} a bit-wise copy of t as a float32x4.
|
673
|
-
*/
|
674
|
-
uint32x4BitsToFloat32x4: function(t) {
|
675
|
-
var alias = new Float32Array(t.storage_.buffer);
|
676
|
-
return new float32x4(alias[0], alias[1], alias[2], alias[3]);
|
677
|
-
},
|
678
|
-
/**
|
679
|
-
* @param {uint32x4} t An instance of a uint32x4.
|
680
|
-
* @return {float32x4} with a float to integer conversion copy of t.
|
681
|
-
*/
|
682
|
-
uint32x4ToFloat32x4: function(t) {
|
683
|
-
var a = float32x4.zero();
|
684
|
-
a.storage_[0] = t.storage_[0];
|
685
|
-
a.storage_[1] = t.storage_[1];
|
686
|
-
a.storage_[2] = t.storage_[2];
|
687
|
-
a.storage_[3] = t.storage_[3];
|
688
|
-
return a;
|
689
|
-
},
|
690
|
-
/**
|
691
|
-
* @param {float32x4} t An instance of a float32x4.
|
692
|
-
* @return {uint32x4} with a integer to float conversion of t.
|
693
|
-
*/
|
694
|
-
float32x4ToUint32x4: function(t) {
|
695
|
-
var a = new uint32x4(t.storage_[0], t.storage_[1], t.storage_[2],
|
696
|
-
t.storage_[3]);
|
697
|
-
return a;
|
670
|
+
int32x4: {
|
671
|
+
/**
|
672
|
+
* @param {int32x4} a An instance of int32x4.
|
673
|
+
* @param {int32x4} b An instance of int32x4.
|
674
|
+
* @return {int32x4} New instance of int32x4 with values of a & b.
|
675
|
+
*/
|
676
|
+
and: function(a, b) {
|
677
|
+
return new int32x4(a.x & b.x, a.y & b.y, a.z & b.z, a.w & b.w);
|
678
|
+
},
|
679
|
+
/**
|
680
|
+
* @param {int32x4} a An instance of int32x4.
|
681
|
+
* @param {int32x4} b An instance of int32x4.
|
682
|
+
* @return {int32x4} New instance of int32x4 with values of a | b.
|
683
|
+
*/
|
684
|
+
or: function(a, b) {
|
685
|
+
return new int32x4(a.x | b.x, a.y | b.y, a.z | b.z, a.w | b.w);
|
686
|
+
},
|
687
|
+
/**
|
688
|
+
* @param {int32x4} a An instance of int32x4.
|
689
|
+
* @param {int32x4} b An instance of int32x4.
|
690
|
+
* @return {int32x4} New instance of int32x4 with values of a ^ b.
|
691
|
+
*/
|
692
|
+
xor: function(a, b) {
|
693
|
+
return new int32x4(a.x ^ b.x, a.y ^ b.y, a.z ^ b.z, a.w ^ b.w);
|
694
|
+
},
|
695
|
+
/**
|
696
|
+
* @param {int32x4} t An instance of int32x4.
|
697
|
+
* @return {int32x4} New instance of int32x4 with values of ~t
|
698
|
+
*/
|
699
|
+
not: function(t) {
|
700
|
+
return new int32x4(~t.x, ~t.y, ~t.z, ~t.w);
|
701
|
+
},
|
702
|
+
/**
|
703
|
+
* @param {int32x4} t An instance of int32x4.
|
704
|
+
* @return {int32x4} New instance of int32x4 with values of -t
|
705
|
+
*/
|
706
|
+
neg: function(t) {
|
707
|
+
return new int32x4(-t.x, -t.y, -t.z, -t.w);
|
708
|
+
},
|
709
|
+
/**
|
710
|
+
* @param {int32x4} a An instance of int32x4.
|
711
|
+
* @param {int32x4} b An instance of int32x4.
|
712
|
+
* @return {int32x4} New instance of int32x4 with values of a + b.
|
713
|
+
*/
|
714
|
+
add: function(a, b) {
|
715
|
+
return new int32x4(a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w);
|
716
|
+
},
|
717
|
+
/**
|
718
|
+
* @param {int32x4} a An instance of int32x4.
|
719
|
+
* @param {int32x4} b An instance of int32x4.
|
720
|
+
* @return {int32x4} New instance of int32x4 with values of a - b.
|
721
|
+
*/
|
722
|
+
sub: function(a, b) {
|
723
|
+
return new int32x4(a.x - b.x, a.y - b.y, a.z - b.z, a.w - b.w);
|
724
|
+
},
|
725
|
+
/**
|
726
|
+
* @param {int32x4} a An instance of int32x4.
|
727
|
+
* @param {int32x4} b An instance of int32x4.
|
728
|
+
* @return {int32x4} New instance of int32x4 with values of a * b.
|
729
|
+
*/
|
730
|
+
mul: function(a, b) {
|
731
|
+
return new int32x4(Math.imul(a.x, b.x), Math.imul(a.y, b.y),
|
732
|
+
Math.imul(a.z, b.z), Math.imul(a.w, b.w));
|
733
|
+
},
|
734
|
+
/**
|
735
|
+
* @param {int32x4} t An instance of float32x4 to be shuffled.
|
736
|
+
* @param {integer} mask One of the 256 shuffle masks, for example, SIMD.XXXX.
|
737
|
+
* @return {int32x4} New instance of float32x4 with lanes shuffled.
|
738
|
+
*/
|
739
|
+
shuffle: function(t, mask) {
|
740
|
+
var _x = (mask) & 0x3;
|
741
|
+
var _y = (mask >> 2) & 0x3;
|
742
|
+
var _z = (mask >> 4) & 0x3;
|
743
|
+
var _w = (mask >> 6) & 0x3;
|
744
|
+
return new int32x4(t.storage_[_x], t.storage_[_y], t.storage_[_z],
|
745
|
+
t.storage_[_w]);
|
746
|
+
},
|
747
|
+
/**
|
748
|
+
* @param {int32x4} t1 An instance of float32x4 to be shuffled. XY lanes in result
|
749
|
+
* @param {int32x4} t2 An instance of float32x4 to be shuffled. ZW lanes in result
|
750
|
+
* @param {integer} mask One of the 256 shuffle masks, for example, SIMD.XXXX.
|
751
|
+
* @return {int32x4} New instance of float32x4 with lanes shuffled.
|
752
|
+
*/
|
753
|
+
shuffleMix: function(t1, t2, mask) {
|
754
|
+
var _x = (mask) & 0x3;
|
755
|
+
var _y = (mask >> 2) & 0x3;
|
756
|
+
var _z = (mask >> 4) & 0x3;
|
757
|
+
var _w = (mask >> 6) & 0x3;
|
758
|
+
return new int32x4(t1.storage_[_x], t1.storage_[_y], t2.storage_[_z],
|
759
|
+
t2.storage_[_w]);
|
760
|
+
},
|
761
|
+
/**
|
762
|
+
* @param {float32x4}
|
763
|
+
*/
|
764
|
+
select: function(t, trueValue, falseValue) {
|
765
|
+
var tv = SIMD.float32x4.bitsToInt32x4(trueValue);
|
766
|
+
var fv = SIMD.float32x4.bitsToInt32x4(falseValue);
|
767
|
+
var tr = SIMD.int32x4.and(t, tv);
|
768
|
+
var fr = SIMD.int32x4.and(SIMD.int32x4.not(t), fv);
|
769
|
+
return SIMD.int32x4.bitsToFloat32x4(SIMD.int32x4.or(tr, fr));
|
770
|
+
},
|
771
|
+
/**
|
772
|
+
* @param {int32x4} t An instance of int32x4.
|
773
|
+
* @param {integer} 32-bit value used for x lane.
|
774
|
+
* @return {int32x4} New instance of int32x4 with the values in t and
|
775
|
+
* x lane replaced with {x}.
|
776
|
+
*/
|
777
|
+
withX: function(t, x) {
|
778
|
+
return new int32x4(x, t.y, t.z, t.w);
|
779
|
+
},
|
780
|
+
/**
|
781
|
+
* param {int32x4} t An instance of int32x4.
|
782
|
+
* @param {integer} 32-bit value used for y lane.
|
783
|
+
* @return {int32x4} New instance of int32x4 with the values in t and
|
784
|
+
* y lane replaced with {y}.
|
785
|
+
*/
|
786
|
+
withY: function(t, y) {
|
787
|
+
return new int32x4(t.x, y, t.z, t.w);
|
788
|
+
},
|
789
|
+
/**
|
790
|
+
* @param {int32x4} t An instance of int32x4.
|
791
|
+
* @param {integer} 32-bit value used for z lane.
|
792
|
+
* @return {int32x4} New instance of int32x4 with the values in t and
|
793
|
+
* z lane replaced with {z}.
|
794
|
+
*/
|
795
|
+
withZ: function(t, z) {
|
796
|
+
return new int32x4(t.x, t.y, z, t.w);
|
797
|
+
},
|
798
|
+
/**
|
799
|
+
* @param {integer} 32-bit value used for w lane.
|
800
|
+
* @return {int32x4} New instance of int32x4 with the values in t and
|
801
|
+
* w lane replaced with {w}.
|
802
|
+
*/
|
803
|
+
withW: function(t, w) {
|
804
|
+
return new int32x4(t.x, t.y, t.z, w);
|
805
|
+
},
|
806
|
+
/**
|
807
|
+
* @param {int32x4} t An instance of int32x4.
|
808
|
+
* @param {boolean} x flag used for x lane.
|
809
|
+
* @return {int32x4} New instance of int32x4 with the values in t and
|
810
|
+
* x lane replaced with {x}.
|
811
|
+
*/
|
812
|
+
withFlagX: function(t, flagX) {
|
813
|
+
var x = flagX ? 0xFFFFFFFF : 0x0;
|
814
|
+
return new int32x4(x, t.y, t.z, t.w);
|
815
|
+
},
|
816
|
+
/**
|
817
|
+
* @param {int32x4} t An instance of int32x4.
|
818
|
+
* @param {boolean} y flag used for y lane.
|
819
|
+
* @return {int32x4} New instance of int32x4 with the values in t and
|
820
|
+
* y lane replaced with {y}.
|
821
|
+
*/
|
822
|
+
withFlagY: function(t, flagY) {
|
823
|
+
var y = flagY ? 0xFFFFFFFF : 0x0;
|
824
|
+
return new int32x4(t.x, y, t.z, t.w);
|
825
|
+
},
|
826
|
+
/**
|
827
|
+
* @param {int32x4} t An instance of int32x4.
|
828
|
+
* @param {boolean} z flag used for z lane.
|
829
|
+
* @return {int32x4} New instance of int32x4 with the values in t and
|
830
|
+
* z lane replaced with {z}.
|
831
|
+
*/
|
832
|
+
withFlagZ: function(t, flagZ) {
|
833
|
+
var z = flagZ ? 0xFFFFFFFF : 0x0;
|
834
|
+
return new int32x4(t.x, t.y, z, t.w);
|
835
|
+
},
|
836
|
+
/**
|
837
|
+
* @param {int32x4} t An instance of int32x4.
|
838
|
+
* @param {boolean} w flag used for w lane.
|
839
|
+
* @return {int32x4} New instance of int32x4 with the values in t and
|
840
|
+
* w lane replaced with {w}.
|
841
|
+
*/
|
842
|
+
withFlagW: function(t, flagW) {
|
843
|
+
var w = flagW ? 0xFFFFFFFF : 0x0;
|
844
|
+
return new int32x4(t.x, t.y, t.z, w);
|
845
|
+
},
|
846
|
+
/**
|
847
|
+
* @param {int32x4} t An instance of int32x4.
|
848
|
+
* @return {float32x4} a bit-wise copy of t as a float32x4.
|
849
|
+
*/
|
850
|
+
bitsToFloat32x4: function(t) {
|
851
|
+
var temp_storage = new Int32Array([t.storage_[0], t.storage_[1], t.storage_[2], t.storage_[3]]);
|
852
|
+
var alias = new Float32Array(temp_storage.buffer);
|
853
|
+
var fx4 = float32x4.zero();
|
854
|
+
fx4.storage_ = alias;
|
855
|
+
return fx4;
|
856
|
+
},
|
857
|
+
/**
|
858
|
+
* @param {int32x4} t An instance of int32x4.
|
859
|
+
* @return {float32x4} with a float to integer conversion copy of t.
|
860
|
+
*/
|
861
|
+
toFloat32x4: function(t) {
|
862
|
+
var a = float32x4.zero();
|
863
|
+
a.storage_[0] = t.storage_[0];
|
864
|
+
a.storage_[1] = t.storage_[1];
|
865
|
+
a.storage_[2] = t.storage_[2];
|
866
|
+
a.storage_[3] = t.storage_[3];
|
867
|
+
return a;
|
868
|
+
}
|
698
869
|
}
|
699
870
|
}
|
700
871
|
})();
|
@@ -955,4 +1126,3 @@ Object.defineProperty(SIMD, 'WWWX', { get: function() { return 0x3F; } });
|
|
955
1126
|
Object.defineProperty(SIMD, 'WWWY', { get: function() { return 0x7F; } });
|
956
1127
|
Object.defineProperty(SIMD, 'WWWZ', { get: function() { return 0xBF; } });
|
957
1128
|
Object.defineProperty(SIMD, 'WWWW', { get: function() { return 0xFF; } });
|
958
|
-
|