summaryrefslogtreecommitdiff
path: root/test/threads.wasm-only.asm.js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2017-11-14 16:42:25 -0800
committerGitHub <noreply@github.com>2017-11-14 16:42:25 -0800
commit4deed1eb310993391fa0e7e06a18cf2303674f98 (patch)
tree16028717e26ec439fe0e8f5b2e40988fcc92f2e9 /test/threads.wasm-only.asm.js
parent82d693b2bd23778b29bbd1019936a2857580c7ed (diff)
downloadbinaryen-4deed1eb310993391fa0e7e06a18cf2303674f98.tar.gz
binaryen-4deed1eb310993391fa0e7e06a18cf2303674f98.tar.bz2
binaryen-4deed1eb310993391fa0e7e06a18cf2303674f98.zip
add i64_atomics_* support to asm2wasm (#1262)
* add i64_atomics_* support to asm2wasm * OptimizeInstructions: atomic loads can't be signed
Diffstat (limited to 'test/threads.wasm-only.asm.js')
-rw-r--r--test/threads.wasm-only.asm.js48
1 files changed, 48 insertions, 0 deletions
diff --git a/test/threads.wasm-only.asm.js b/test/threads.wasm-only.asm.js
new file mode 100644
index 000000000..7c40665f4
--- /dev/null
+++ b/test/threads.wasm-only.asm.js
@@ -0,0 +1,48 @@
+//
+// Test wasm-only builds. In this case, fastcomp emits code that is
+// not asm.js, it will only ever run as wasm, and contains special intrinsics for
+// asm2wasm that map LLVM IR into i64s.
+//
+
+function asm(global, env, buffer) {
+ "use asm";
+
+ var HEAP8 = new global.Int8Array(buffer);
+ var HEAP16 = new global.Int16Array(buffer);
+ var HEAP32 = new global.Int32Array(buffer);
+ var HEAPU8 = new global.Uint8Array(buffer);
+ var HEAPU16 = new global.Uint16Array(buffer);
+ var HEAPU32 = new global.Uint32Array(buffer);
+ var HEAPF32 = new global.Float32Array(buffer);
+ var HEAPF64 = new global.Float64Array(buffer);
+
+ var STACKTOP = env.STACKTOP | 0;
+
+ var fround = global.Math.fround;
+ var Math_imul = global.Math.imul;
+
+ var illegalImport = env.illegalImport;
+ var illegalImportResult = env.illegalImportResult;
+
+ var _fabsf = env._fabsf;
+ var do_i64 = env.do_i64;
+ var abort = env.abort;
+
+ function test64() {
+ var x = i64(), y = i64(), z = 0; // define i64 variables using special intrinsic
+ var int32 = 0, float32 = fround(0), float64 = +0;
+ i64_atomics_store(4656, i64_const(92, 0))|0;
+ x = i64_atomics_load(4656);
+ y = i64_atomics_add(int32, i64_const(26, 0))|0;
+ x = i64_atomics_sub(1024, y)|0;
+ y = i64_atomics_and(1024, x)|0;
+ x = i64_atomics_or(1024, y)|0;
+ y = i64_atomics_xor(1024, x)|0;
+ x = i64_atomics_exchange(1024, y)|0;
+ y = i64_atomics_compareExchange(1024, x, y)|0;
+ return x;
+ }
+
+ return { test64: test64 };
+}
+