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

Unified Diff: test/mjsunit/asm/atomics-compareexchange.js

Issue 1422533009: Support SAB atomics for offset-TypedArray (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: add a test case Created 5 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/mjsunit/asm/atomics-and.js ('k') | test/mjsunit/asm/atomics-exchange.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/asm/atomics-compareexchange.js
diff --git a/test/mjsunit/asm/atomics-compareexchange.js b/test/mjsunit/asm/atomics-compareexchange.js
index edcd7f908c7f97007d19b6143ff8dd3bfdfec736..84d38504b32933c51ee8c5049d3e49975c9fd6f2 100644
--- a/test/mjsunit/asm/atomics-compareexchange.js
+++ b/test/mjsunit/asm/atomics-compareexchange.js
@@ -4,14 +4,14 @@
// Flags: --harmony-sharedarraybuffer
-function Module(stdlib, foreign, heap) {
+function Module(stdlib, foreign, heap, offset) {
"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 MEM8 = new stdlib.Int8Array(heap, offset);
+ var MEM16 = new stdlib.Int16Array(heap, offset);
+ var MEM32 = new stdlib.Int32Array(heap, offset);
+ var MEMU8 = new stdlib.Uint8Array(heap, offset);
+ var MEMU16 = new stdlib.Uint16Array(heap, offset);
+ var MEMU32 = new stdlib.Uint32Array(heap, offset);
var compareExchange = stdlib.Atomics.compareExchange;
var fround = stdlib.Math.fround;
@@ -67,9 +67,6 @@ function Module(stdlib, foreign, heap) {
};
}
-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) {
@@ -77,10 +74,10 @@ function clearArray() {
}
}
-function testElementType(taConstr, f, oobValue) {
+function testElementType(taConstr, f, oobValue, offset) {
clearArray();
- var ta = new taConstr(sab);
+ var ta = new taConstr(sab, offset);
var name = Object.prototype.toString.call(ta);
assertEquals(0, ta[0]);
assertEquals(0, f(0, 0, 50), name);
@@ -93,9 +90,21 @@ function testElementType(taConstr, f, oobValue) {
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);
+function testElement(m, offset) {
+ testElementType(Int8Array, m.compareExchangei8, 0, offset);
+ testElementType(Int16Array, m.compareExchangei16, 0, offset);
+ testElementType(Int32Array, m.compareExchangei32, 0, offset);
+ testElementType(Uint8Array, m.compareExchangeu8, 0, offset);
+ testElementType(Uint16Array, m.compareExchangeu16, 0, offset);
+ testElementType(Uint32Array, m.compareExchangeu32, 0, offset);
+}
+
+var offset = 0;
+var sab = new SharedArrayBuffer(16);
+var m1 = Module(this, {}, sab, offset);
+testElement(m1, offset);
+
+offset = 32;
+sab = new SharedArrayBuffer(64);
+var m2 = Module(this, {}, sab, offset);
+testElement(m2, offset);
« no previous file with comments | « test/mjsunit/asm/atomics-and.js ('k') | test/mjsunit/asm/atomics-exchange.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698