diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/passes/optimize-instructions.txt | 17 | ||||
-rw-r--r-- | test/passes/optimize-instructions.wast | 16 | ||||
-rw-r--r-- | test/threads.wasm-only.asm.js | 48 | ||||
-rw-r--r-- | test/threads.wasm-only.fromasm | 70 | ||||
-rw-r--r-- | test/threads.wasm-only.fromasm.clamp | 70 | ||||
-rw-r--r-- | test/threads.wasm-only.fromasm.clamp.no-opts | 90 | ||||
-rw-r--r-- | test/threads.wasm-only.fromasm.imprecise | 69 | ||||
-rw-r--r-- | test/threads.wasm-only.fromasm.imprecise.no-opts | 90 | ||||
-rw-r--r-- | test/threads.wasm-only.fromasm.no-opts | 90 |
9 files changed, 560 insertions, 0 deletions
diff --git a/test/passes/optimize-instructions.txt b/test/passes/optimize-instructions.txt index 010d6c139..d30e8f22e 100644 --- a/test/passes/optimize-instructions.txt +++ b/test/passes/optimize-instructions.txt @@ -2199,3 +2199,20 @@ ) ) ) +(module + (type $0 (func)) + (import "env" "memory" (memory $0 (shared 256 256))) + (func $x (; 0 ;) (type $0) + (drop + (i32.shr_s + (i32.shl + (i32.atomic.load8_u + (i32.const 100) + ) + (i32.const 24) + ) + (i32.const 24) + ) + ) + ) +) diff --git a/test/passes/optimize-instructions.wast b/test/passes/optimize-instructions.wast index ff5bd9f9d..4ee2b0c86 100644 --- a/test/passes/optimize-instructions.wast +++ b/test/passes/optimize-instructions.wast @@ -2641,3 +2641,19 @@ ) ) ) +(module + (import "env" "memory" (memory $0 (shared 256 256))) + (func $x + (drop + (i32.shr_s + (i32.shl + (i32.atomic.load8_u ;; can't be signed + (i32.const 100) + ) + (i32.const 24) + ) + (i32.const 24) + ) + ) + ) +) 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 }; +} + diff --git a/test/threads.wasm-only.fromasm b/test/threads.wasm-only.fromasm new file mode 100644 index 000000000..7ad7acf49 --- /dev/null +++ b/test/threads.wasm-only.fromasm @@ -0,0 +1,70 @@ +(module + (import "env" "memory" (memory $0 (shared 256 256))) + (import "env" "table" (table 0 0 anyfunc)) + (import "env" "memoryBase" (global $memoryBase i32)) + (import "env" "tableBase" (global $tableBase i32)) + (global $tempRet0 (mut i32) (i32.const 0)) + (data (get_global $memoryBase) "threads.wasm-only.asm.js") + (export "test64" (func $legalstub$test64)) + (func $test64 (; 0 ;) (result i64) + (local $0 i64) + (local $1 i64) + (local $2 i32) + (i64.atomic.store + (i32.const 4656) + (i64.const 92) + ) + (drop + (i64.atomic.load + (i32.const 4656) + ) + ) + (drop + (i64.atomic.rmw.cmpxchg + (i32.const 1024) + (tee_local $1 + (i64.atomic.rmw.xchg + (i32.const 1024) + (tee_local $0 + (i64.atomic.rmw.xor + (i32.const 1024) + (i64.atomic.rmw.or + (i32.const 1024) + (i64.atomic.rmw.and + (i32.const 1024) + (i64.atomic.rmw.sub + (i32.const 1024) + (i64.atomic.rmw.add + (get_local $2) + (i64.const 26) + ) + ) + ) + ) + ) + ) + ) + ) + (get_local $0) + ) + ) + (get_local $1) + ) + (func $legalstub$test64 (; 1 ;) (result i32) + (local $0 i64) + (set_local $0 + (call $test64) + ) + (set_global $tempRet0 + (i32.wrap/i64 + (i64.shr_u + (get_local $0) + (i64.const 32) + ) + ) + ) + (i32.wrap/i64 + (get_local $0) + ) + ) +) diff --git a/test/threads.wasm-only.fromasm.clamp b/test/threads.wasm-only.fromasm.clamp new file mode 100644 index 000000000..7ad7acf49 --- /dev/null +++ b/test/threads.wasm-only.fromasm.clamp @@ -0,0 +1,70 @@ +(module + (import "env" "memory" (memory $0 (shared 256 256))) + (import "env" "table" (table 0 0 anyfunc)) + (import "env" "memoryBase" (global $memoryBase i32)) + (import "env" "tableBase" (global $tableBase i32)) + (global $tempRet0 (mut i32) (i32.const 0)) + (data (get_global $memoryBase) "threads.wasm-only.asm.js") + (export "test64" (func $legalstub$test64)) + (func $test64 (; 0 ;) (result i64) + (local $0 i64) + (local $1 i64) + (local $2 i32) + (i64.atomic.store + (i32.const 4656) + (i64.const 92) + ) + (drop + (i64.atomic.load + (i32.const 4656) + ) + ) + (drop + (i64.atomic.rmw.cmpxchg + (i32.const 1024) + (tee_local $1 + (i64.atomic.rmw.xchg + (i32.const 1024) + (tee_local $0 + (i64.atomic.rmw.xor + (i32.const 1024) + (i64.atomic.rmw.or + (i32.const 1024) + (i64.atomic.rmw.and + (i32.const 1024) + (i64.atomic.rmw.sub + (i32.const 1024) + (i64.atomic.rmw.add + (get_local $2) + (i64.const 26) + ) + ) + ) + ) + ) + ) + ) + ) + (get_local $0) + ) + ) + (get_local $1) + ) + (func $legalstub$test64 (; 1 ;) (result i32) + (local $0 i64) + (set_local $0 + (call $test64) + ) + (set_global $tempRet0 + (i32.wrap/i64 + (i64.shr_u + (get_local $0) + (i64.const 32) + ) + ) + ) + (i32.wrap/i64 + (get_local $0) + ) + ) +) diff --git a/test/threads.wasm-only.fromasm.clamp.no-opts b/test/threads.wasm-only.fromasm.clamp.no-opts new file mode 100644 index 000000000..abaca2010 --- /dev/null +++ b/test/threads.wasm-only.fromasm.clamp.no-opts @@ -0,0 +1,90 @@ +(module + (import "env" "STACKTOP" (global $STACKTOP$asm2wasm$import i32)) + (import "env" "memory" (memory $0 (shared 256 256))) + (import "env" "table" (table 0 0 anyfunc)) + (import "env" "memoryBase" (global $memoryBase i32)) + (import "env" "tableBase" (global $tableBase i32)) + (global $STACKTOP (mut i32) (get_global $STACKTOP$asm2wasm$import)) + (global $tempRet0 (mut i32) (i32.const 0)) + (export "test64" (func $legalstub$test64)) + (func $test64 (; 0 ;) (result i64) + (local $x i64) + (local $y i64) + (local $z i32) + (local $int32 i32) + (local $float32 f32) + (local $float64 f64) + (i64.atomic.store + (i32.const 4656) + (i64.const 92) + ) + (set_local $x + (i64.atomic.load + (i32.const 4656) + ) + ) + (set_local $y + (i64.atomic.rmw.add + (get_local $int32) + (i64.const 26) + ) + ) + (set_local $x + (i64.atomic.rmw.sub + (i32.const 1024) + (get_local $y) + ) + ) + (set_local $y + (i64.atomic.rmw.and + (i32.const 1024) + (get_local $x) + ) + ) + (set_local $x + (i64.atomic.rmw.or + (i32.const 1024) + (get_local $y) + ) + ) + (set_local $y + (i64.atomic.rmw.xor + (i32.const 1024) + (get_local $x) + ) + ) + (set_local $x + (i64.atomic.rmw.xchg + (i32.const 1024) + (get_local $y) + ) + ) + (set_local $y + (i64.atomic.rmw.cmpxchg + (i32.const 1024) + (get_local $x) + (get_local $y) + ) + ) + (return + (get_local $x) + ) + ) + (func $legalstub$test64 (; 1 ;) (result i32) + (local $0 i64) + (set_local $0 + (call $test64) + ) + (set_global $tempRet0 + (i32.wrap/i64 + (i64.shr_u + (get_local $0) + (i64.const 32) + ) + ) + ) + (i32.wrap/i64 + (get_local $0) + ) + ) +) diff --git a/test/threads.wasm-only.fromasm.imprecise b/test/threads.wasm-only.fromasm.imprecise new file mode 100644 index 000000000..672653913 --- /dev/null +++ b/test/threads.wasm-only.fromasm.imprecise @@ -0,0 +1,69 @@ +(module + (import "env" "memory" (memory $0 (shared 256 256))) + (import "env" "table" (table 0 0 anyfunc)) + (import "env" "memoryBase" (global $memoryBase i32)) + (import "env" "tableBase" (global $tableBase i32)) + (global $tempRet0 (mut i32) (i32.const 0)) + (export "test64" (func $legalstub$test64)) + (func $test64 (; 0 ;) (result i64) + (local $0 i64) + (local $1 i64) + (local $2 i32) + (i64.atomic.store + (i32.const 4656) + (i64.const 92) + ) + (drop + (i64.atomic.load + (i32.const 4656) + ) + ) + (drop + (i64.atomic.rmw.cmpxchg + (i32.const 1024) + (tee_local $1 + (i64.atomic.rmw.xchg + (i32.const 1024) + (tee_local $0 + (i64.atomic.rmw.xor + (i32.const 1024) + (i64.atomic.rmw.or + (i32.const 1024) + (i64.atomic.rmw.and + (i32.const 1024) + (i64.atomic.rmw.sub + (i32.const 1024) + (i64.atomic.rmw.add + (get_local $2) + (i64.const 26) + ) + ) + ) + ) + ) + ) + ) + ) + (get_local $0) + ) + ) + (get_local $1) + ) + (func $legalstub$test64 (; 1 ;) (result i32) + (local $0 i64) + (set_local $0 + (call $test64) + ) + (set_global $tempRet0 + (i32.wrap/i64 + (i64.shr_u + (get_local $0) + (i64.const 32) + ) + ) + ) + (i32.wrap/i64 + (get_local $0) + ) + ) +) diff --git a/test/threads.wasm-only.fromasm.imprecise.no-opts b/test/threads.wasm-only.fromasm.imprecise.no-opts new file mode 100644 index 000000000..abaca2010 --- /dev/null +++ b/test/threads.wasm-only.fromasm.imprecise.no-opts @@ -0,0 +1,90 @@ +(module + (import "env" "STACKTOP" (global $STACKTOP$asm2wasm$import i32)) + (import "env" "memory" (memory $0 (shared 256 256))) + (import "env" "table" (table 0 0 anyfunc)) + (import "env" "memoryBase" (global $memoryBase i32)) + (import "env" "tableBase" (global $tableBase i32)) + (global $STACKTOP (mut i32) (get_global $STACKTOP$asm2wasm$import)) + (global $tempRet0 (mut i32) (i32.const 0)) + (export "test64" (func $legalstub$test64)) + (func $test64 (; 0 ;) (result i64) + (local $x i64) + (local $y i64) + (local $z i32) + (local $int32 i32) + (local $float32 f32) + (local $float64 f64) + (i64.atomic.store + (i32.const 4656) + (i64.const 92) + ) + (set_local $x + (i64.atomic.load + (i32.const 4656) + ) + ) + (set_local $y + (i64.atomic.rmw.add + (get_local $int32) + (i64.const 26) + ) + ) + (set_local $x + (i64.atomic.rmw.sub + (i32.const 1024) + (get_local $y) + ) + ) + (set_local $y + (i64.atomic.rmw.and + (i32.const 1024) + (get_local $x) + ) + ) + (set_local $x + (i64.atomic.rmw.or + (i32.const 1024) + (get_local $y) + ) + ) + (set_local $y + (i64.atomic.rmw.xor + (i32.const 1024) + (get_local $x) + ) + ) + (set_local $x + (i64.atomic.rmw.xchg + (i32.const 1024) + (get_local $y) + ) + ) + (set_local $y + (i64.atomic.rmw.cmpxchg + (i32.const 1024) + (get_local $x) + (get_local $y) + ) + ) + (return + (get_local $x) + ) + ) + (func $legalstub$test64 (; 1 ;) (result i32) + (local $0 i64) + (set_local $0 + (call $test64) + ) + (set_global $tempRet0 + (i32.wrap/i64 + (i64.shr_u + (get_local $0) + (i64.const 32) + ) + ) + ) + (i32.wrap/i64 + (get_local $0) + ) + ) +) diff --git a/test/threads.wasm-only.fromasm.no-opts b/test/threads.wasm-only.fromasm.no-opts new file mode 100644 index 000000000..abaca2010 --- /dev/null +++ b/test/threads.wasm-only.fromasm.no-opts @@ -0,0 +1,90 @@ +(module + (import "env" "STACKTOP" (global $STACKTOP$asm2wasm$import i32)) + (import "env" "memory" (memory $0 (shared 256 256))) + (import "env" "table" (table 0 0 anyfunc)) + (import "env" "memoryBase" (global $memoryBase i32)) + (import "env" "tableBase" (global $tableBase i32)) + (global $STACKTOP (mut i32) (get_global $STACKTOP$asm2wasm$import)) + (global $tempRet0 (mut i32) (i32.const 0)) + (export "test64" (func $legalstub$test64)) + (func $test64 (; 0 ;) (result i64) + (local $x i64) + (local $y i64) + (local $z i32) + (local $int32 i32) + (local $float32 f32) + (local $float64 f64) + (i64.atomic.store + (i32.const 4656) + (i64.const 92) + ) + (set_local $x + (i64.atomic.load + (i32.const 4656) + ) + ) + (set_local $y + (i64.atomic.rmw.add + (get_local $int32) + (i64.const 26) + ) + ) + (set_local $x + (i64.atomic.rmw.sub + (i32.const 1024) + (get_local $y) + ) + ) + (set_local $y + (i64.atomic.rmw.and + (i32.const 1024) + (get_local $x) + ) + ) + (set_local $x + (i64.atomic.rmw.or + (i32.const 1024) + (get_local $y) + ) + ) + (set_local $y + (i64.atomic.rmw.xor + (i32.const 1024) + (get_local $x) + ) + ) + (set_local $x + (i64.atomic.rmw.xchg + (i32.const 1024) + (get_local $y) + ) + ) + (set_local $y + (i64.atomic.rmw.cmpxchg + (i32.const 1024) + (get_local $x) + (get_local $y) + ) + ) + (return + (get_local $x) + ) + ) + (func $legalstub$test64 (; 1 ;) (result i32) + (local $0 i64) + (set_local $0 + (call $test64) + ) + (set_global $tempRet0 + (i32.wrap/i64 + (i64.shr_u + (get_local $0) + (i64.const 32) + ) + ) + ) + (i32.wrap/i64 + (get_local $0) + ) + ) +) |