summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2016-03-29 21:20:33 -0700
committerAlon Zakai <alonzakai@gmail.com>2016-03-29 21:20:33 -0700
commitda01ed78f16d6793dfe09f70016efba904bcaf4f (patch)
tree05891cddf61c7696f07b64de9d31122ca7a09c5a
parent4e71858950c4d1bb7ddfac871e72e5802c2e8362 (diff)
downloadbinaryen-da01ed78f16d6793dfe09f70016efba904bcaf4f.tar.gz
binaryen-da01ed78f16d6793dfe09f70016efba904bcaf4f.tar.bz2
binaryen-da01ed78f16d6793dfe09f70016efba904bcaf4f.zip
add explicit function types for indirect call targtets in s2wasm
-rw-r--r--src/s2wasm.h6
-rw-r--r--test/dot_s/basics.wast3
-rw-r--r--test/dot_s/bcp-1.wast34
3 files changed, 25 insertions, 18 deletions
diff --git a/src/s2wasm.h b/src/s2wasm.h
index 07262d012..5460bf467 100644
--- a/src/s2wasm.h
+++ b/src/s2wasm.h
@@ -1305,6 +1305,12 @@ class S2WasmBuilder {
block->finalize();
}
}
+
+ // ensure an explicit function type for indirect call targets
+ for (auto& name : wasm.table.names) {
+ auto* func = wasm.functionsMap[name];
+ func->type = ensureFunctionType(getSig(func), &wasm, allocator)->name;
+ }
}
template<class C>
diff --git a/test/dot_s/basics.wast b/test/dot_s/basics.wast
index 8fc8c3d67..91620910c 100644
--- a/test/dot_s/basics.wast
+++ b/test/dot_s/basics.wast
@@ -6,10 +6,11 @@
)
(export "memory" memory)
(type $FUNCSIG$vi (func (param i32)))
+ (type $FUNCSIG$iii (func (param i32 i32) (result i32)))
(import $puts "env" "puts" (param i32))
(export "main" $main)
(table $main)
- (func $main (param $$0 i32) (param $$1 i32) (result i32)
+ (func $main (type $FUNCSIG$iii) (param $$0 i32) (param $$1 i32) (result i32)
(call_import $puts
(i32.const 16)
)
diff --git a/test/dot_s/bcp-1.wast b/test/dot_s/bcp-1.wast
index 76f1f49d4..091dff695 100644
--- a/test/dot_s/bcp-1.wast
+++ b/test/dot_s/bcp-1.wast
@@ -34,87 +34,87 @@
(export "opt2" $opt2)
(export "main" $main)
(table $bad0 $bad1 $bad5 $bad7 $bad8 $bad10 $bad2 $bad3 $bad6 $bad4 $bad9 $good0 $good1 $good2 $opt0 $opt1 $opt2)
- (func $bad0 (result i32)
+ (func $bad0 (type $FUNCSIG$i) (result i32)
(return
(i32.const 0)
)
)
- (func $bad1 (result i32)
+ (func $bad1 (type $FUNCSIG$i) (result i32)
(return
(i32.const 0)
)
)
- (func $bad2 (param $$0 i32) (result i32)
+ (func $bad2 (type $FUNCSIG$ii) (param $$0 i32) (result i32)
(return
(i32.const 0)
)
)
- (func $bad3 (param $$0 i32) (result i32)
+ (func $bad3 (type $FUNCSIG$ii) (param $$0 i32) (result i32)
(return
(i32.const 0)
)
)
- (func $bad4 (param $$0 i32) (result i32)
+ (func $bad4 (type $FUNCSIG$ii) (param $$0 i32) (result i32)
(return
(i32.const 0)
)
)
- (func $bad5 (result i32)
+ (func $bad5 (type $FUNCSIG$i) (result i32)
(return
(i32.const 0)
)
)
- (func $bad6 (param $$0 i32) (result i32)
+ (func $bad6 (type $FUNCSIG$ii) (param $$0 i32) (result i32)
(return
(i32.const 0)
)
)
- (func $bad7 (result i32)
+ (func $bad7 (type $FUNCSIG$i) (result i32)
(return
(i32.const 0)
)
)
- (func $bad8 (result i32)
+ (func $bad8 (type $FUNCSIG$i) (result i32)
(return
(i32.const 0)
)
)
- (func $bad9 (param $$0 i32) (result i32)
+ (func $bad9 (type $FUNCSIG$ii) (param $$0 i32) (result i32)
(return
(i32.const 0)
)
)
- (func $bad10 (result i32)
+ (func $bad10 (type $FUNCSIG$i) (result i32)
(return
(i32.const 0)
)
)
- (func $good0 (result i32)
+ (func $good0 (type $FUNCSIG$i) (result i32)
(return
(i32.const 1)
)
)
- (func $good1 (result i32)
+ (func $good1 (type $FUNCSIG$i) (result i32)
(return
(i32.const 1)
)
)
- (func $good2 (result i32)
+ (func $good2 (type $FUNCSIG$i) (result i32)
(return
(i32.const 1)
)
)
- (func $opt0 (result i32)
+ (func $opt0 (type $FUNCSIG$i) (result i32)
(return
(i32.const 0)
)
)
- (func $opt1 (result i32)
+ (func $opt1 (type $FUNCSIG$i) (result i32)
(return
(i32.const 0)
)
)
- (func $opt2 (result i32)
+ (func $opt2 (type $FUNCSIG$i) (result i32)
(return
(i32.const 1)
)