summaryrefslogtreecommitdiff
path: root/deps/v8/test/mjsunit/asm
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/test/mjsunit/asm')
-rw-r--r--deps/v8/test/mjsunit/asm/atomics-add.js93
-rw-r--r--deps/v8/test/mjsunit/asm/atomics-and.js94
-rw-r--r--deps/v8/test/mjsunit/asm/atomics-compareexchange.js121
-rw-r--r--deps/v8/test/mjsunit/asm/atomics-exchange.js92
-rw-r--r--deps/v8/test/mjsunit/asm/atomics-load.js102
-rw-r--r--deps/v8/test/mjsunit/asm/atomics-or.js93
-rw-r--r--deps/v8/test/mjsunit/asm/atomics-store.js109
-rw-r--r--deps/v8/test/mjsunit/asm/atomics-sub.js94
-rw-r--r--deps/v8/test/mjsunit/asm/atomics-xor.js93
9 files changed, 891 insertions, 0 deletions
diff --git a/deps/v8/test/mjsunit/asm/atomics-add.js b/deps/v8/test/mjsunit/asm/atomics-add.js
new file mode 100644
index 0000000000..69400c8059
--- /dev/null
+++ b/deps/v8/test/mjsunit/asm/atomics-add.js
@@ -0,0 +1,93 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Flags: --harmony-atomics --harmony-sharedarraybuffer
+
+function Module(stdlib, foreign, heap) {
+ "use asm";
+ var MEM8 = new stdlib.Int8Array(heap);
+ var MEM16 = new stdlib.Int16Array(heap);
+ var MEM32 = new stdlib.Int32Array(heap);
+ var MEMU8 = new stdlib.Uint8Array(heap);
+ var MEMU16 = new stdlib.Uint16Array(heap);
+ var MEMU32 = new stdlib.Uint32Array(heap);
+ var add = stdlib.Atomics.add;
+ var fround = stdlib.Math.fround;
+
+ function addi8(i, x) {
+ i = i | 0;
+ x = x | 0;
+ return add(MEM8, i, x)|0;
+ }
+
+ function addi16(i, x) {
+ i = i | 0;
+ x = x | 0;
+ return add(MEM16, i, x)|0;
+ }
+
+ function addi32(i, x) {
+ i = i | 0;
+ x = x | 0;
+ return add(MEM32, i, x)|0;
+ }
+
+ function addu8(i, x) {
+ i = i | 0;
+ x = x >>> 0;
+ return add(MEMU8, i, x)>>>0;
+ }
+
+ function addu16(i, x) {
+ i = i | 0;
+ x = x >>> 0;
+ return add(MEMU16, i, x)>>>0;
+ }
+
+ function addu32(i, x) {
+ i = i | 0;
+ x = x >>> 0;
+ return add(MEMU32, i, x)>>>0;
+ }
+
+ return {
+ addi8: addi8,
+ addi16: addi16,
+ addi32: addi32,
+ addu8: addu8,
+ addu16: addu16,
+ addu32: addu32,
+ };
+}
+
+var sab = new SharedArrayBuffer(16);
+var m = Module(this, {}, sab);
+
+function clearArray() {
+ var ui8 = new Uint8Array(sab);
+ for (var i = 0; i < sab.byteLength; ++i) {
+ ui8[i] = 0;
+ }
+}
+
+function testElementType(taConstr, f) {
+ clearArray();
+
+ var ta = new taConstr(sab);
+ var name = Object.prototype.toString.call(ta);
+ assertEquals(0, f(0, 10), name);
+ assertEquals(10, ta[0]);
+ assertEquals(10, f(0, 10), name);
+ assertEquals(20, ta[0]);
+ // out of bounds
+ assertEquals(0, f(-1, 0), name);
+ assertEquals(0, f(ta.length, 0), name);
+}
+
+testElementType(Int8Array, m.addi8);
+testElementType(Int16Array, m.addi16);
+testElementType(Int32Array, m.addi32);
+testElementType(Uint8Array, m.addu8);
+testElementType(Uint16Array, m.addu16);
+testElementType(Uint32Array, m.addu32);
diff --git a/deps/v8/test/mjsunit/asm/atomics-and.js b/deps/v8/test/mjsunit/asm/atomics-and.js
new file mode 100644
index 0000000000..e60f1f6a13
--- /dev/null
+++ b/deps/v8/test/mjsunit/asm/atomics-and.js
@@ -0,0 +1,94 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Flags: --harmony-atomics --harmony-sharedarraybuffer
+
+function Module(stdlib, foreign, heap) {
+ "use asm";
+ var MEM8 = new stdlib.Int8Array(heap);
+ var MEM16 = new stdlib.Int16Array(heap);
+ var MEM32 = new stdlib.Int32Array(heap);
+ var MEMU8 = new stdlib.Uint8Array(heap);
+ var MEMU16 = new stdlib.Uint16Array(heap);
+ var MEMU32 = new stdlib.Uint32Array(heap);
+ var and = stdlib.Atomics.and;
+ var fround = stdlib.Math.fround;
+
+ function andi8(i, x) {
+ i = i | 0;
+ x = x | 0;
+ return and(MEM8, i, x)|0;
+ }
+
+ function andi16(i, x) {
+ i = i | 0;
+ x = x | 0;
+ return and(MEM16, i, x)|0;
+ }
+
+ function andi32(i, x) {
+ i = i | 0;
+ x = x | 0;
+ return and(MEM32, i, x)|0;
+ }
+
+ function andu8(i, x) {
+ i = i | 0;
+ x = x >>> 0;
+ return and(MEMU8, i, x)>>>0;
+ }
+
+ function andu16(i, x) {
+ i = i | 0;
+ x = x >>> 0;
+ return and(MEMU16, i, x)>>>0;
+ }
+
+ function andu32(i, x) {
+ i = i | 0;
+ x = x >>> 0;
+ return and(MEMU32, i, x)>>>0;
+ }
+
+ return {
+ andi8: andi8,
+ andi16: andi16,
+ andi32: andi32,
+ andu8: andu8,
+ andu16: andu16,
+ andu32: andu32,
+ };
+}
+
+var sab = new SharedArrayBuffer(16);
+var m = Module(this, {}, sab);
+
+function clearArray() {
+ var ui8 = new Uint8Array(sab);
+ for (var i = 0; i < sab.byteLength; ++i) {
+ ui8[i] = 0;
+ }
+}
+
+function testElementType(taConstr, f) {
+ clearArray();
+
+ var ta = new taConstr(sab);
+ var name = Object.prototype.toString.call(ta);
+ ta[0] = 0x7f;
+ assertEquals(0x7f, f(0, 0xf), name);
+ assertEquals(0xf, ta[0]);
+ assertEquals(0xf, f(0, 0x19), name);
+ assertEquals(0x9, ta[0]);
+ // out of bounds
+ assertEquals(0, f(-1, 0), name);
+ assertEquals(0, f(ta.length, 0), name);
+}
+
+testElementType(Int8Array, m.andi8);
+testElementType(Int16Array, m.andi16);
+testElementType(Int32Array, m.andi32);
+testElementType(Uint8Array, m.andu8);
+testElementType(Uint16Array, m.andu16);
+testElementType(Uint32Array, m.andu32);
diff --git a/deps/v8/test/mjsunit/asm/atomics-compareexchange.js b/deps/v8/test/mjsunit/asm/atomics-compareexchange.js
new file mode 100644
index 0000000000..208a06043c
--- /dev/null
+++ b/deps/v8/test/mjsunit/asm/atomics-compareexchange.js
@@ -0,0 +1,121 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Flags: --harmony-atomics --harmony-sharedarraybuffer
+
+function Module(stdlib, foreign, heap) {
+ "use asm";
+ var MEM8 = new stdlib.Int8Array(heap);
+ var MEM16 = new stdlib.Int16Array(heap);
+ var MEM32 = new stdlib.Int32Array(heap);
+ var MEMU8 = new stdlib.Uint8Array(heap);
+ var MEMU16 = new stdlib.Uint16Array(heap);
+ var MEMU32 = new stdlib.Uint32Array(heap);
+ var MEMF32 = new stdlib.Float32Array(heap);
+ var MEMF64 = new stdlib.Float64Array(heap);
+ var compareExchange = stdlib.Atomics.compareExchange;
+ var fround = stdlib.Math.fround;
+
+ function compareExchangei8(i, o, n) {
+ i = i | 0;
+ o = o | 0;
+ n = n | 0;
+ return compareExchange(MEM8, i, o, n)|0;
+ }
+
+ function compareExchangei16(i, o, n) {
+ i = i | 0;
+ o = o | 0;
+ n = n | 0;
+ return compareExchange(MEM16, i, o, n)|0;
+ }
+
+ function compareExchangei32(i, o, n) {
+ i = i | 0;
+ o = o | 0;
+ n = n | 0;
+ return compareExchange(MEM32, i, o, n)|0;
+ }
+
+ function compareExchangeu8(i, o, n) {
+ i = i | 0;
+ o = o >>> 0;
+ n = n >>> 0;
+ return compareExchange(MEMU8, i, o, n)>>>0;
+ }
+
+ function compareExchangeu16(i, o, n) {
+ i = i | 0;
+ o = o >>> 0;
+ n = n >>> 0;
+ return compareExchange(MEMU16, i, o, n)>>>0;
+ }
+
+ function compareExchangeu32(i, o, n) {
+ i = i | 0;
+ o = o >>> 0;
+ n = n >>> 0;
+ return compareExchange(MEMU32, i, o, n)>>>0;
+ }
+
+ function compareExchangef32(i, o, n) {
+ i = i | 0;
+ o = fround(o);
+ n = fround(n);
+ return fround(compareExchange(MEMF32, i, o, n));
+ }
+
+ function compareExchangef64(i, o, n) {
+ i = i | 0;
+ o = +o;
+ n = +n;
+ return +compareExchange(MEMF64, i, o, n);
+ }
+
+ return {
+ compareExchangei8: compareExchangei8,
+ compareExchangei16: compareExchangei16,
+ compareExchangei32: compareExchangei32,
+ compareExchangeu8: compareExchangeu8,
+ compareExchangeu16: compareExchangeu16,
+ compareExchangeu32: compareExchangeu32,
+ compareExchangef32: compareExchangef32,
+ compareExchangef64: compareExchangef64
+ };
+}
+
+var sab = new SharedArrayBuffer(16);
+var m = Module(this, {}, sab);
+
+function clearArray() {
+ var ui8 = new Uint8Array(sab);
+ for (var i = 0; i < sab.byteLength; ++i) {
+ ui8[i] = 0;
+ }
+}
+
+function testElementType(taConstr, f, oobValue) {
+ clearArray();
+
+ var ta = new taConstr(sab);
+ var name = Object.prototype.toString.call(ta);
+ assertEquals(0, ta[0]);
+ assertEquals(0, f(0, 0, 50), name);
+ assertEquals(50, ta[0]);
+ // Value is not equal to 0, so compareExchange won't store 100
+ assertEquals(50, f(0, 0, 100), name);
+ assertEquals(50, ta[0]);
+ // out of bounds
+ assertEquals(oobValue, f(-1, 0, 0), name);
+ assertEquals(oobValue, f(ta.length, 0, 0), name);
+}
+
+testElementType(Int8Array, m.compareExchangei8, 0);
+testElementType(Int16Array, m.compareExchangei16, 0);
+testElementType(Int32Array, m.compareExchangei32, 0);
+testElementType(Uint8Array, m.compareExchangeu8, 0);
+testElementType(Uint16Array, m.compareExchangeu16, 0);
+testElementType(Uint32Array, m.compareExchangeu32, 0);
+testElementType(Float32Array, m.compareExchangef32, NaN);
+testElementType(Float64Array, m.compareExchangef64, NaN);
diff --git a/deps/v8/test/mjsunit/asm/atomics-exchange.js b/deps/v8/test/mjsunit/asm/atomics-exchange.js
new file mode 100644
index 0000000000..bb70322c7e
--- /dev/null
+++ b/deps/v8/test/mjsunit/asm/atomics-exchange.js
@@ -0,0 +1,92 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Flags: --harmony-atomics --harmony-sharedarraybuffer
+
+function Module(stdlib, foreign, heap) {
+ "use asm";
+ var MEM8 = new stdlib.Int8Array(heap);
+ var MEM16 = new stdlib.Int16Array(heap);
+ var MEM32 = new stdlib.Int32Array(heap);
+ var MEMU8 = new stdlib.Uint8Array(heap);
+ var MEMU16 = new stdlib.Uint16Array(heap);
+ var MEMU32 = new stdlib.Uint32Array(heap);
+ var exchange = stdlib.Atomics.exchange;
+ var fround = stdlib.Math.fround;
+
+ function exchangei8(i, x) {
+ i = i | 0;
+ x = x | 0;
+ return exchange(MEM8, i, x)|0;
+ }
+
+ function exchangei16(i, x) {
+ i = i | 0;
+ x = x | 0;
+ return exchange(MEM16, i, x)|0;
+ }
+
+ function exchangei32(i, x) {
+ i = i | 0;
+ x = x | 0;
+ return exchange(MEM32, i, x)|0;
+ }
+
+ function exchangeu8(i, x) {
+ i = i | 0;
+ x = x >>> 0;
+ return exchange(MEMU8, i, x)>>>0;
+ }
+
+ function exchangeu16(i, x) {
+ i = i | 0;
+ x = x >>> 0;
+ return exchange(MEMU16, i, x)>>>0;
+ }
+
+ function exchangeu32(i, x) {
+ i = i | 0;
+ x = x >>> 0;
+ return exchange(MEMU32, i, x)>>>0;
+ }
+
+ return {
+ exchangei8: exchangei8,
+ exchangei16: exchangei16,
+ exchangei32: exchangei32,
+ exchangeu8: exchangeu8,
+ exchangeu16: exchangeu16,
+ exchangeu32: exchangeu32,
+ };
+}
+
+var sab = new SharedArrayBuffer(16);
+var m = Module(this, {}, sab);
+
+function clearArray() {
+ var ui8 = new Uint8Array(sab);
+ for (var i = 0; i < sab.byteLength; ++i) {
+ ui8[i] = 0;
+ }
+}
+
+function testElementType(taConstr, f) {
+ clearArray();
+
+ var ta = new taConstr(sab);
+ var name = Object.prototype.toString.call(ta);
+ ta[0] = 0x7f;
+ assertEquals(0x7f, f(0, 0xf), name);
+ assertEquals(0xf, ta[0]);
+ // out of bounds
+ assertEquals(0, f(-1, 0), name);
+ assertEquals(0, f(ta.length, 0), name);
+}
+
+testElementType(Int8Array, m.exchangei8);
+testElementType(Int16Array, m.exchangei16);
+testElementType(Int32Array, m.exchangei32);
+testElementType(Uint8Array, m.exchangeu8);
+testElementType(Uint16Array, m.exchangeu16);
+testElementType(Uint32Array, m.exchangeu32);
diff --git a/deps/v8/test/mjsunit/asm/atomics-load.js b/deps/v8/test/mjsunit/asm/atomics-load.js
new file mode 100644
index 0000000000..769fb40e2c
--- /dev/null
+++ b/deps/v8/test/mjsunit/asm/atomics-load.js
@@ -0,0 +1,102 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Flags: --harmony-atomics --harmony-sharedarraybuffer
+
+function Module(stdlib, foreign, heap) {
+ "use asm";
+ var MEM8 = new stdlib.Int8Array(heap);
+ var MEM16 = new stdlib.Int16Array(heap);
+ var MEM32 = new stdlib.Int32Array(heap);
+ var MEMU8 = new stdlib.Uint8Array(heap);
+ var MEMU16 = new stdlib.Uint16Array(heap);
+ var MEMU32 = new stdlib.Uint32Array(heap);
+ var MEMF32 = new stdlib.Float32Array(heap);
+ var MEMF64 = new stdlib.Float64Array(heap);
+ var load = stdlib.Atomics.load;
+ var fround = stdlib.Math.fround;
+
+ function loadi8(i) {
+ i = i | 0;
+ return load(MEM8, i)|0;
+ }
+
+ function loadi16(i) {
+ i = i | 0;
+ return load(MEM16, i)|0;
+ }
+
+ function loadi32(i) {
+ i = i | 0;
+ return load(MEM32, i)|0;
+ }
+
+ function loadu8(i) {
+ i = i | 0;
+ return load(MEMU8, i)>>>0;
+ }
+
+ function loadu16(i) {
+ i = i | 0;
+ return load(MEMU16, i)>>>0;
+ }
+
+ function loadu32(i) {
+ i = i | 0;
+ return load(MEMU32, i)>>>0;
+ }
+
+ function loadf32(i) {
+ i = i | 0;
+ return fround(load(MEMF32, i));
+ }
+
+ function loadf64(i) {
+ i = i | 0;
+ return +load(MEMF64, i);
+ }
+
+ return {
+ loadi8: loadi8,
+ loadi16: loadi16,
+ loadi32: loadi32,
+ loadu8: loadu8,
+ loadu16: loadu16,
+ loadu32: loadu32,
+ loadf32: loadf32,
+ loadf64: loadf64
+ };
+}
+
+var sab = new SharedArrayBuffer(16);
+var m = Module(this, {}, sab);
+
+function clearArray() {
+ var ui8 = new Uint8Array(sab);
+ for (var i = 0; i < sab.byteLength; ++i) {
+ ui8[i] = 0;
+ }
+}
+
+function testElementType(taConstr, f, oobValue) {
+ clearArray();
+
+ var ta = new taConstr(sab);
+ var name = Object.prototype.toString.call(ta);
+ ta[0] = 10;
+ assertEquals(10, f(0), name);
+ assertEquals(0, f(1), name);
+ // out of bounds
+ assertEquals(oobValue, f(-1), name);
+ assertEquals(oobValue, f(ta.length), name);
+}
+
+testElementType(Int8Array, m.loadi8, 0);
+testElementType(Int16Array, m.loadi16, 0);
+testElementType(Int32Array, m.loadi32, 0);
+testElementType(Uint8Array, m.loadu8, 0);
+testElementType(Uint16Array, m.loadu16, 0);
+testElementType(Uint32Array, m.loadu32, 0);
+testElementType(Float32Array, m.loadf32, NaN);
+testElementType(Float64Array, m.loadf64, NaN);
diff --git a/deps/v8/test/mjsunit/asm/atomics-or.js b/deps/v8/test/mjsunit/asm/atomics-or.js
new file mode 100644
index 0000000000..df87d24d74
--- /dev/null
+++ b/deps/v8/test/mjsunit/asm/atomics-or.js
@@ -0,0 +1,93 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Flags: --harmony-atomics --harmony-sharedarraybuffer
+
+function Module(stdlib, foreign, heap) {
+ "use asm";
+ var MEM8 = new stdlib.Int8Array(heap);
+ var MEM16 = new stdlib.Int16Array(heap);
+ var MEM32 = new stdlib.Int32Array(heap);
+ var MEMU8 = new stdlib.Uint8Array(heap);
+ var MEMU16 = new stdlib.Uint16Array(heap);
+ var MEMU32 = new stdlib.Uint32Array(heap);
+ var or = stdlib.Atomics.or;
+ var fround = stdlib.Math.fround;
+
+ function ori8(i, x) {
+ i = i | 0;
+ x = x | 0;
+ return or(MEM8, i, x)|0;
+ }
+
+ function ori16(i, x) {
+ i = i | 0;
+ x = x | 0;
+ return or(MEM16, i, x)|0;
+ }
+
+ function ori32(i, x) {
+ i = i | 0;
+ x = x | 0;
+ return or(MEM32, i, x)|0;
+ }
+
+ function oru8(i, x) {
+ i = i | 0;
+ x = x >>> 0;
+ return or(MEMU8, i, x)>>>0;
+ }
+
+ function oru16(i, x) {
+ i = i | 0;
+ x = x >>> 0;
+ return or(MEMU16, i, x)>>>0;
+ }
+
+ function oru32(i, x) {
+ i = i | 0;
+ x = x >>> 0;
+ return or(MEMU32, i, x)>>>0;
+ }
+
+ return {
+ ori8: ori8,
+ ori16: ori16,
+ ori32: ori32,
+ oru8: oru8,
+ oru16: oru16,
+ oru32: oru32,
+ };
+}
+
+var sab = new SharedArrayBuffer(16);
+var m = Module(this, {}, sab);
+
+function clearArray() {
+ var ui8 = new Uint8Array(sab);
+ for (var i = 0; i < sab.byteLength; ++i) {
+ ui8[i] = 0;
+ }
+}
+
+function testElementType(taConstr, f) {
+ clearArray();
+
+ var ta = new taConstr(sab);
+ var name = Object.prototype.toString.call(ta);
+ assertEquals(0, f(0, 0xf), name);
+ assertEquals(0xf, ta[0]);
+ assertEquals(0xf, f(0, 0x11), name);
+ assertEquals(0x1f, ta[0]);
+ // out of bounds
+ assertEquals(0, f(-1, 0), name);
+ assertEquals(0, f(ta.length, 0), name);
+}
+
+testElementType(Int8Array, m.ori8);
+testElementType(Int16Array, m.ori16);
+testElementType(Int32Array, m.ori32);
+testElementType(Uint8Array, m.oru8);
+testElementType(Uint16Array, m.oru16);
+testElementType(Uint32Array, m.oru32);
diff --git a/deps/v8/test/mjsunit/asm/atomics-store.js b/deps/v8/test/mjsunit/asm/atomics-store.js
new file mode 100644
index 0000000000..1f7a5f91c7
--- /dev/null
+++ b/deps/v8/test/mjsunit/asm/atomics-store.js
@@ -0,0 +1,109 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Flags: --harmony-atomics --harmony-sharedarraybuffer
+
+function Module(stdlib, foreign, heap) {
+ "use asm";
+ var MEM8 = new stdlib.Int8Array(heap);
+ var MEM16 = new stdlib.Int16Array(heap);
+ var MEM32 = new stdlib.Int32Array(heap);
+ var MEMU8 = new stdlib.Uint8Array(heap);
+ var MEMU16 = new stdlib.Uint16Array(heap);
+ var MEMU32 = new stdlib.Uint32Array(heap);
+ var MEMF32 = new stdlib.Float32Array(heap);
+ var MEMF64 = new stdlib.Float64Array(heap);
+ var store = stdlib.Atomics.store;
+ var fround = stdlib.Math.fround;
+
+ function storei8(i, x) {
+ i = i | 0;
+ x = x | 0;
+ return store(MEM8, i, x)|0;
+ }
+
+ function storei16(i, x) {
+ i = i | 0;
+ x = x | 0;
+ return store(MEM16, i, x)|0;
+ }
+
+ function storei32(i, x) {
+ i = i | 0;
+ x = x | 0;
+ return store(MEM32, i, x)|0;
+ }
+
+ function storeu8(i, x) {
+ i = i | 0;
+ x = x >>> 0;
+ return store(MEMU8, i, x)>>>0;
+ }
+
+ function storeu16(i, x) {
+ i = i | 0;
+ x = x >>> 0;
+ return store(MEMU16, i, x)>>>0;
+ }
+
+ function storeu32(i, x) {
+ i = i | 0;
+ x = x >>> 0;
+ return store(MEMU32, i, x)>>>0;
+ }
+
+ function storef32(i, x) {
+ i = i | 0;
+ x = fround(x);
+ return fround(store(MEMF32, i, x));
+ }
+
+ function storef64(i, x) {
+ i = i | 0;
+ x = +x;
+ return +store(MEMF64, i, x);
+ }
+
+ return {
+ storei8: storei8,
+ storei16: storei16,
+ storei32: storei32,
+ storeu8: storeu8,
+ storeu16: storeu16,
+ storeu32: storeu32,
+ storef32: storef32,
+ storef64: storef64
+ };
+}
+
+var sab = new SharedArrayBuffer(16);
+var m = Module(this, {}, sab);
+
+function clearArray() {
+ var ui8 = new Uint8Array(sab);
+ for (var i = 0; i < sab.byteLength; ++i) {
+ ui8[i] = 0;
+ }
+}
+
+function testElementType(taConstr, f, oobValue) {
+ clearArray();
+
+ var ta = new taConstr(sab);
+ var name = Object.prototype.toString.call(ta);
+ assertEquals(10, f(0, 10), name);
+ assertEquals(10, ta[0]);
+ // out of bounds
+ assertEquals(oobValue, f(-1, 0), name);
+ assertEquals(oobValue, f(ta.length, 0), name);
+}
+
+testElementType(Int8Array, m.storei8, 0);
+testElementType(Int16Array, m.storei16, 0);
+testElementType(Int32Array, m.storei32, 0);
+testElementType(Uint8Array, m.storeu8, 0);
+testElementType(Uint16Array, m.storeu16, 0);
+testElementType(Uint32Array, m.storeu32, 0);
+testElementType(Float32Array, m.storef32, NaN);
+testElementType(Float64Array, m.storef64, NaN);
diff --git a/deps/v8/test/mjsunit/asm/atomics-sub.js b/deps/v8/test/mjsunit/asm/atomics-sub.js
new file mode 100644
index 0000000000..f9e56ffa4b
--- /dev/null
+++ b/deps/v8/test/mjsunit/asm/atomics-sub.js
@@ -0,0 +1,94 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Flags: --harmony-atomics --harmony-sharedarraybuffer
+
+function Module(stdlib, foreign, heap) {
+ "use asm";
+ var MEM8 = new stdlib.Int8Array(heap);
+ var MEM16 = new stdlib.Int16Array(heap);
+ var MEM32 = new stdlib.Int32Array(heap);
+ var MEMU8 = new stdlib.Uint8Array(heap);
+ var MEMU16 = new stdlib.Uint16Array(heap);
+ var MEMU32 = new stdlib.Uint32Array(heap);
+ var sub = stdlib.Atomics.sub;
+ var fround = stdlib.Math.fround;
+
+ function subi8(i, x) {
+ i = i | 0;
+ x = x | 0;
+ return sub(MEM8, i, x)|0;
+ }
+
+ function subi16(i, x) {
+ i = i | 0;
+ x = x | 0;
+ return sub(MEM16, i, x)|0;
+ }
+
+ function subi32(i, x) {
+ i = i | 0;
+ x = x | 0;
+ return sub(MEM32, i, x)|0;
+ }
+
+ function subu8(i, x) {
+ i = i | 0;
+ x = x >>> 0;
+ return sub(MEMU8, i, x)>>>0;
+ }
+
+ function subu16(i, x) {
+ i = i | 0;
+ x = x >>> 0;
+ return sub(MEMU16, i, x)>>>0;
+ }
+
+ function subu32(i, x) {
+ i = i | 0;
+ x = x >>> 0;
+ return sub(MEMU32, i, x)>>>0;
+ }
+
+ return {
+ subi8: subi8,
+ subi16: subi16,
+ subi32: subi32,
+ subu8: subu8,
+ subu16: subu16,
+ subu32: subu32,
+ };
+}
+
+var sab = new SharedArrayBuffer(16);
+var m = Module(this, {}, sab);
+
+function clearArray() {
+ var ui8 = new Uint8Array(sab);
+ for (var i = 0; i < sab.byteLength; ++i) {
+ ui8[i] = 0;
+ }
+}
+
+function testElementType(taConstr, f) {
+ clearArray();
+
+ var ta = new taConstr(sab);
+ var name = Object.prototype.toString.call(ta);
+ ta[0] = 30;
+ assertEquals(30, f(0, 10), name);
+ assertEquals(20, ta[0]);
+ assertEquals(20, f(0, 10), name);
+ assertEquals(10, ta[0]);
+ // out of bounds
+ assertEquals(0, f(-1, 0), name);
+ assertEquals(0, f(ta.length, 0), name);
+}
+
+testElementType(Int8Array, m.subi8);
+testElementType(Int16Array, m.subi16);
+testElementType(Int32Array, m.subi32);
+testElementType(Uint8Array, m.subu8);
+testElementType(Uint16Array, m.subu16);
+testElementType(Uint32Array, m.subu32);
diff --git a/deps/v8/test/mjsunit/asm/atomics-xor.js b/deps/v8/test/mjsunit/asm/atomics-xor.js
new file mode 100644
index 0000000000..893ea013fd
--- /dev/null
+++ b/deps/v8/test/mjsunit/asm/atomics-xor.js
@@ -0,0 +1,93 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Flags: --harmony-atomics --harmony-sharedarraybuffer
+
+function Module(stdlib, foreign, heap) {
+ "use asm";
+ var MEM8 = new stdlib.Int8Array(heap);
+ var MEM16 = new stdlib.Int16Array(heap);
+ var MEM32 = new stdlib.Int32Array(heap);
+ var MEMU8 = new stdlib.Uint8Array(heap);
+ var MEMU16 = new stdlib.Uint16Array(heap);
+ var MEMU32 = new stdlib.Uint32Array(heap);
+ var xor = stdlib.Atomics.xor;
+ var fround = stdlib.Math.fround;
+
+ function xori8(i, x) {
+ i = i | 0;
+ x = x | 0;
+ return xor(MEM8, i, x)|0;
+ }
+
+ function xori16(i, x) {
+ i = i | 0;
+ x = x | 0;
+ return xor(MEM16, i, x)|0;
+ }
+
+ function xori32(i, x) {
+ i = i | 0;
+ x = x | 0;
+ return xor(MEM32, i, x)|0;
+ }
+
+ function xoru8(i, x) {
+ i = i | 0;
+ x = x >>> 0;
+ return xor(MEMU8, i, x)>>>0;
+ }
+
+ function xoru16(i, x) {
+ i = i | 0;
+ x = x >>> 0;
+ return xor(MEMU16, i, x)>>>0;
+ }
+
+ function xoru32(i, x) {
+ i = i | 0;
+ x = x >>> 0;
+ return xor(MEMU32, i, x)>>>0;
+ }
+
+ return {
+ xori8: xori8,
+ xori16: xori16,
+ xori32: xori32,
+ xoru8: xoru8,
+ xoru16: xoru16,
+ xoru32: xoru32,
+ };
+}
+
+var sab = new SharedArrayBuffer(16);
+var m = Module(this, {}, sab);
+
+function clearArray() {
+ var ui8 = new Uint8Array(sab);
+ for (var i = 0; i < sab.byteLength; ++i) {
+ ui8[i] = 0;
+ }
+}
+
+function testElementType(taConstr, f) {
+ clearArray();
+
+ var ta = new taConstr(sab);
+ var name = Object.prototype.toString.call(ta);
+ assertEquals(0, f(0, 0xf), name);
+ assertEquals(0xf, ta[0]);
+ assertEquals(0xf, f(0, 0x11), name);
+ assertEquals(0x1e, ta[0]);
+ // out of bounds
+ assertEquals(0, f(-1, 0), name);
+ assertEquals(0, f(ta.length, 0), name);
+}
+
+testElementType(Int8Array, m.xori8);
+testElementType(Int16Array, m.xori16);
+testElementType(Int32Array, m.xori32);
+testElementType(Uint8Array, m.xoru8);
+testElementType(Uint16Array, m.xoru16);
+testElementType(Uint32Array, m.xoru32);