diff options
author | Alon Zakai <alonzakai@gmail.com> | 2015-11-21 22:20:00 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2015-11-21 22:20:52 -0800 |
commit | 9b5be208da3c32658c5aa6487c5f6d91039b063d (patch) | |
tree | 7154eb4369b92f76543d778352f999d360c2bf0d | |
parent | 14ad84c09bd93958cc8fcfa4a38bbcc7e7267169 (diff) | |
download | binaryen-9b5be208da3c32658c5aa6487c5f6d91039b063d.tar.gz binaryen-9b5be208da3c32658c5aa6487c5f6d91039b063d.tar.bz2 binaryen-9b5be208da3c32658c5aa6487c5f6d91039b063d.zip |
handle indirect calls with floats
-rw-r--r-- | src/asm2wasm.h | 1 | ||||
-rw-r--r-- | test/unit.asm.js | 2 | ||||
-rw-r--r-- | test/unit.wast | 19 |
3 files changed, 19 insertions, 3 deletions
diff --git a/src/asm2wasm.h b/src/asm2wasm.h index ac9732e68..118e5d662 100644 --- a/src/asm2wasm.h +++ b/src/asm2wasm.h @@ -179,6 +179,7 @@ private: char getSigFromType(WasmType type) { switch (type) { case i32: return 'i'; + case f32: return 'f'; case f64: return 'd'; case none: return 'v'; default: abort(); diff --git a/test/unit.asm.js b/test/unit.asm.js index 0a664ca3f..02e607208 100644 --- a/test/unit.asm.js +++ b/test/unit.asm.js @@ -109,6 +109,7 @@ function () { function neg() { var x = Math_fround(0); x = -x; + FUNCTION_TABLE_c[1 & 7](x); } function z() { @@ -118,6 +119,7 @@ function () { var FUNCTION_TABLE_a = [ z, big_negative, z, z ]; var FUNCTION_TABLE_b = [ w, w, importedDoubles, w ]; + var FUNCTION_TABLE_c = [ z, neg ]; return { big_negative: big_negative }; } diff --git a/test/unit.wast b/test/unit.wast index dd1f59d2d..5f68ef57a 100644 --- a/test/unit.wast +++ b/test/unit.wast @@ -1,9 +1,10 @@ (module (memory 16777216 16777216) + (type $FUNCSIG$vf (func (param f32))) (import $f64-to-int "asm2wasm" "f64-to-int" (param f64) (result i32)) (import $f64-rem "asm2wasm" "f64-rem" (param f64 f64) (result f64)) (export "big_negative" $big_negative) - (table $z $big_negative $z $z $w $w $importedDoubles $w) + (table $z $big_negative $z $z $w $w $importedDoubles $w $z $neg) (func $big_negative (local $temp f64) (block @@ -329,8 +330,20 @@ ) (func $neg (local $x f32) - (set_local $x - (f32.neg + (block + (set_local $x + (f32.neg + (get_local $x) + ) + ) + (call_indirect $FUNCSIG$vf + (i32.add + (i32.and + (i32.const 1) + (i32.const 7) + ) + (i32.const 8) + ) (get_local $x) ) ) |