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

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

Issue 1124813005: WIP Atomics (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix AtomicsLoad type in typer.cc Created 5 years, 7 months 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 | « src/runtime/runtime-utils.h ('k') | test/mjsunit/harmony/atomics.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/asm/atomics-load.js
diff --git a/test/mjsunit/asm/atomics-load.js b/test/mjsunit/asm/atomics-load.js
new file mode 100644
index 0000000000000000000000000000000000000000..3aa6c686b20358ea5c30729328aa042b02705c5a
--- /dev/null
+++ b/test/mjsunit/asm/atomics-load.js
@@ -0,0 +1,68 @@
+// 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-shared-typed-arrays
+
+function Module(stdlib, foreign, heap) {
+ "use asm";
+ var MEM8 = new stdlib.SharedInt8Array(heap);
+ var MEM16 = new stdlib.SharedInt16Array(heap);
+ var MEM32 = new stdlib.SharedInt32Array(heap);
+ var MEMF32 = new stdlib.SharedFloat32Array(heap);
+ var MEMF64 = new stdlib.SharedFloat64Array(heap);
+ var load = stdlib.Atomics.load;
+
+ 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 loadf32(i) {
+ i = i | 0;
+ return +load(MEMF32, i);
+ }
+
+ function loadf64(i) {
+ i = i | 0;
+ return +load(MEMF64, i);
+ }
+
+ return {
+ loadi8: loadi8,
+ loadi16: loadi16,
+ loadi32: loadi32,
+ loadf32: loadf32,
+ loadf64: loadf64
+ };
+}
+
+var sab = new SharedArrayBuffer(16);
+var m = Module(this, {}, sab);
+
+function testElementType(taConstr, f, oobValue) {
+ 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(SharedInt8Array, m.loadi8, 0);
+testElementType(SharedInt16Array, m.loadi16, 0);
+testElementType(SharedInt32Array, m.loadi32, 0);
+testElementType(SharedFloat32Array, m.loadf32, NaN);
+testElementType(SharedFloat64Array, m.loadf64, NaN);
« no previous file with comments | « src/runtime/runtime-utils.h ('k') | test/mjsunit/harmony/atomics.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698