diff options
author | Alon Zakai <alonzakai@gmail.com> | 2017-03-07 13:56:35 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-07 13:56:35 -0800 |
commit | 71804e2bfd1ba49b7dd4ce82b6ad26ba13f1bca8 (patch) | |
tree | 7a91f560708b5017cf795850db94267f2cb58f62 /test/two_sides.fromasm.clamp.no-opts | |
parent | a452f92aeb96e9617a20146503720cd5acb64f29 (diff) | |
download | binaryen-71804e2bfd1ba49b7dd4ce82b6ad26ba13f1bca8.tar.gz binaryen-71804e2bfd1ba49b7dd4ce82b6ad26ba13f1bca8.tar.bz2 binaryen-71804e2bfd1ba49b7dd4ce82b6ad26ba13f1bca8.zip |
Use 3 modes for potentially trapping ops in asm2wasm (#929)
* use 3 modes for potentially trapping ops in asm2wasm: allow (just emit a potentially trapping op), js (do exactly what js does, even if it takes a slow ffi to do it), and clamp (avoid the trap by clamping as necessary)
Diffstat (limited to 'test/two_sides.fromasm.clamp.no-opts')
-rw-r--r-- | test/two_sides.fromasm.clamp.no-opts | 112 |
1 files changed, 112 insertions, 0 deletions
diff --git a/test/two_sides.fromasm.clamp.no-opts b/test/two_sides.fromasm.clamp.no-opts new file mode 100644 index 000000000..a505e4cb3 --- /dev/null +++ b/test/two_sides.fromasm.clamp.no-opts @@ -0,0 +1,112 @@ +(module + (import "env" "memory" (memory $0 256 256)) + (import "env" "table" (table 0 0 anyfunc)) + (import "env" "memoryBase" (global $memoryBase i32)) + (import "env" "tableBase" (global $tableBase i32)) + (export "_test" (func $_test)) + (func $f64-to-int (param $0 f64) (result i32) + (if i32 + (f64.ne + (get_local $0) + (get_local $0) + ) + (i32.const -2147483648) + (if i32 + (f64.ge + (get_local $0) + (f64.const 2147483648) + ) + (i32.const -2147483648) + (if i32 + (f64.le + (get_local $0) + (f64.const -2147483649) + ) + (i32.const -2147483648) + (i32.trunc_s/f64 + (get_local $0) + ) + ) + ) + ) + ) + (func $_test (param $i1 i32) (param $i2 i32) (param $i3 i32) (param $i4 i32) (param $i5 i32) (result i32) + (local $d6 f64) + (if + (i32.eqz + (get_local $i5) + ) + (block + (set_local $d6 + (f64.convert_s/i32 + (i32.mul + (get_local $i4) + (get_local $i3) + ) + ) + ) + (set_local $d6 + (f64.mul + (f64.add + (f64.convert_s/i32 + (get_local $i3) + ) + (get_local $d6) + ) + (f64.add + (f64.convert_s/i32 + (get_local $i4) + ) + (get_local $d6) + ) + ) + ) + (set_local $i5 + (call $f64-to-int + (get_local $d6) + ) + ) + (return + (get_local $i5) + ) + ) + (block + (set_local $d6 + (f64.convert_s/i32 + (i32.mul + (get_local $i2) + (get_local $i1) + ) + ) + ) + (set_local $d6 + (f64.mul + (f64.add + (f64.convert_s/i32 + (get_local $i3) + ) + (get_local $d6) + ) + (f64.add + (get_local $d6) + (f64.convert_s/i32 + (get_local $i4) + ) + ) + ) + ) + (set_local $i5 + (call $f64-to-int + (get_local $d6) + ) + ) + (return + (get_local $i5) + ) + ) + ) + (return + (i32.const 0) + ) + ) +) |