Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/passes/Print.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ struct PrintSExpression : public Visitor<PrintSExpression> {
printCallBody(curr);
}
void visitCallIndirect(CallIndirect *curr) {
printOpening(o, "call_indirect ") << curr->fullType;
printOpening(o, "call_indirect (type ") << curr->fullType << ')';
incIndent();
for (auto operand : curr->operands) {
printFullLine(operand);
Expand Down
4 changes: 3 additions & 1 deletion src/wasm/wasm-s-parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1387,7 +1387,9 @@ Expression* SExpressionWasmBuilder::makeCallImport(Element& s) {
Expression* SExpressionWasmBuilder::makeCallIndirect(Element& s) {
if (!wasm.table.exists) throw ParseException("no table");
auto ret = allocator.alloc<CallIndirect>();
IString type = s[1]->str();
Element& typeElement = *s[1];
if (typeElement[0]->str() != "type") throw ParseException("expected 'type' in call_indirect", s.line, s.col);
IString type = typeElement[1]->str();
auto* fullType = wasm.getFunctionTypeOrNull(type);
if (!fullType) throw ParseException("invalid call_indirect type", s.line, s.col);
ret->fullType = fullType->name;
Expand Down
2 changes: 1 addition & 1 deletion test/ctor-eval/bad-indirect-call.wast
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
(elem (i32.const 0) $call-indirect)
(export "test1" $test1)
(func $test1
(call_indirect $v (i32.const 1)) ;; unsafe to call, out of range
(call_indirect (type $v) (i32.const 1)) ;; unsafe to call, out of range
(i32.store8 (i32.const 20) (i32.const 120))
)
(func $call-indirect
Expand Down
2 changes: 1 addition & 1 deletion test/ctor-eval/bad-indirect-call.wast.out
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
(data (i32.const 10) "waka waka waka waka waka")
(export "test1" (func $test1))
(func $test1 (; 0 ;) (type $v)
(call_indirect $v
(call_indirect (type $v)
(i32.const 1)
)
(i32.store8
Expand Down
2 changes: 1 addition & 1 deletion test/ctor-eval/bad-indirect-call2.wast
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
(elem (i32.const 0) $_abort $call-indirect)
(export "test1" $test1)
(func $test1
(call_indirect $v (i32.const 0)) ;; unsafe to call, imported
(call_indirect (type $v) (i32.const 0)) ;; unsafe to call, imported
(i32.store8 (i32.const 20) (i32.const 120))
)
(func $call-indirect
Expand Down
2 changes: 1 addition & 1 deletion test/ctor-eval/bad-indirect-call2.wast.out
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
(data (i32.const 10) "waka waka waka waka waka")
(export "test1" (func $test1))
(func $test1 (; 1 ;) (type $v)
(call_indirect $v
(call_indirect (type $v)
(i32.const 0)
)
(i32.store8
Expand Down
2 changes: 1 addition & 1 deletion test/ctor-eval/basics-flatten.wast
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
(func $test1
(drop (i32.const 0)) ;; no work at all, really
(call $safe-to-call) ;; safe to call
(call_indirect $v (i32.const 0)) ;; safe to call
(call_indirect (type $v) (i32.const 0)) ;; safe to call
)
(func $test2
(drop (i32.load (i32.const 12))) ;; a safe load
Expand Down
2 changes: 1 addition & 1 deletion test/ctor-eval/basics.wast
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
(func $test1
(drop (i32.const 0)) ;; no work at all, really
(call $safe-to-call) ;; safe to call
(call_indirect $v (i32.const 0)) ;; safe to call
(call_indirect (type $v) (i32.const 0)) ;; safe to call
)
(func $test2
(drop (i32.load (i32.const 12))) ;; a safe load
Expand Down
2 changes: 1 addition & 1 deletion test/ctor-eval/indirect-call3.wast
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
(elem (get_global $tableBase) $_abort $call-indirect)
(export "test1" $test1)
(func $test1
(call_indirect $v (i32.const 1)) ;; safe to call
(call_indirect (type $v) (i32.const 1)) ;; safe to call
(i32.store8 (i32.const 20) (i32.const 120))
)
(func $call-indirect
Expand Down
2 changes: 1 addition & 1 deletion test/dot_s/alias.wast
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
(unreachable)
)
(func $dynCall_v (; 6 ;) (param $fptr i32)
(call_indirect $FUNCSIG$v
(call_indirect (type $FUNCSIG$v)
(get_local $fptr)
)
)
Expand Down
2 changes: 1 addition & 1 deletion test/dot_s/basics.wast
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
(unreachable)
)
(func $dynCall_iii (; 6 ;) (param $fptr i32) (param $0 i32) (param $1 i32) (result i32)
(call_indirect $FUNCSIG$iii
(call_indirect (type $FUNCSIG$iii)
(get_local $0)
(get_local $1)
(get_local $fptr)
Expand Down
38 changes: 19 additions & 19 deletions test/dot_s/bcp-1.wast
Original file line number Diff line number Diff line change
Expand Up @@ -132,42 +132,42 @@
)
(block $label$0
(br_if $label$0
(call_indirect $FUNCSIG$i
(call_indirect (type $FUNCSIG$i)
(i32.load offset=16
(get_local $0)
)
)
)
(br_if $label$0
(call_indirect $FUNCSIG$i
(call_indirect (type $FUNCSIG$i)
(i32.load offset=20
(get_local $0)
)
)
)
(br_if $label$0
(call_indirect $FUNCSIG$i
(call_indirect (type $FUNCSIG$i)
(i32.load offset=24
(get_local $0)
)
)
)
(br_if $label$0
(call_indirect $FUNCSIG$i
(call_indirect (type $FUNCSIG$i)
(i32.load offset=28
(get_local $0)
)
)
)
(br_if $label$0
(call_indirect $FUNCSIG$i
(call_indirect (type $FUNCSIG$i)
(i32.load offset=32
(get_local $0)
)
)
)
(br_if $label$0
(call_indirect $FUNCSIG$i
(call_indirect (type $FUNCSIG$i)
(i32.load offset=36
(get_local $0)
)
Expand All @@ -183,21 +183,21 @@
)
(block $label$1
(br_if $label$1
(call_indirect $FUNCSIG$ii
(call_indirect (type $FUNCSIG$ii)
(get_local $2)
(get_local $1)
)
)
(br_if $label$1
(call_indirect $FUNCSIG$ii
(call_indirect (type $FUNCSIG$ii)
(get_local $2)
(i32.load offset=44
(get_local $0)
)
)
)
(br_if $label$1
(call_indirect $FUNCSIG$ii
(call_indirect (type $FUNCSIG$ii)
(get_local $2)
(i32.load offset=48
(get_local $0)
Expand All @@ -214,13 +214,13 @@
)
(block $label$2
(br_if $label$2
(call_indirect $FUNCSIG$ii
(call_indirect (type $FUNCSIG$ii)
(get_local $2)
(get_local $1)
)
)
(br_if $label$2
(call_indirect $FUNCSIG$ii
(call_indirect (type $FUNCSIG$ii)
(get_local $2)
(i32.load offset=56
(get_local $0)
Expand All @@ -230,7 +230,7 @@
(block $label$3
(br_if $label$3
(i32.eq
(call_indirect $FUNCSIG$i
(call_indirect (type $FUNCSIG$i)
(i32.load offset=60
(get_local $0)
)
Expand All @@ -240,7 +240,7 @@
)
(br_if $label$3
(i32.eq
(call_indirect $FUNCSIG$i
(call_indirect (type $FUNCSIG$i)
(i32.load offset=64
(get_local $0)
)
Expand All @@ -250,7 +250,7 @@
)
(br_if $label$3
(i32.eq
(call_indirect $FUNCSIG$i
(call_indirect (type $FUNCSIG$i)
(i32.load offset=68
(get_local $0)
)
Expand All @@ -261,7 +261,7 @@
(block $label$4
(br_if $label$4
(i32.eq
(call_indirect $FUNCSIG$i
(call_indirect (type $FUNCSIG$i)
(i32.load offset=72
(get_local $0)
)
Expand All @@ -271,7 +271,7 @@
)
(br_if $label$4
(i32.eq
(call_indirect $FUNCSIG$i
(call_indirect (type $FUNCSIG$i)
(i32.load offset=76
(get_local $0)
)
Expand All @@ -281,7 +281,7 @@
)
(br_if $label$4
(i32.eq
(call_indirect $FUNCSIG$i
(call_indirect (type $FUNCSIG$i)
(i32.load offset=80
(get_local $0)
)
Expand Down Expand Up @@ -343,12 +343,12 @@
(unreachable)
)
(func $dynCall_i (; 24 ;) (param $fptr i32) (result i32)
(call_indirect $FUNCSIG$i
(call_indirect (type $FUNCSIG$i)
(get_local $fptr)
)
)
(func $dynCall_ii (; 25 ;) (param $fptr i32) (param $0 i32) (result i32)
(call_indirect $FUNCSIG$ii
(call_indirect (type $FUNCSIG$ii)
(get_local $0)
(get_local $fptr)
)
Expand Down
6 changes: 3 additions & 3 deletions test/dot_s/dyncall.wast
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,18 @@
(unreachable)
)
(func $dynCall_i (; 10 ;) (param $fptr i32) (result i32)
(call_indirect $FUNCSIG$i
(call_indirect (type $FUNCSIG$i)
(get_local $fptr)
)
)
(func $dynCall_if (; 11 ;) (param $fptr i32) (param $0 f32) (result i32)
(call_indirect $FUNCSIG$if
(call_indirect (type $FUNCSIG$if)
(get_local $0)
(get_local $fptr)
)
)
(func $dynCall_vd (; 12 ;) (param $fptr i32) (param $0 f64)
(call_indirect $FUNCSIG$vd
(call_indirect (type $FUNCSIG$vd)
(get_local $0)
(get_local $fptr)
)
Expand Down
8 changes: 4 additions & 4 deletions test/dot_s/fix_em_ehsjlj_names.wast
Original file line number Diff line number Diff line change
Expand Up @@ -110,27 +110,27 @@
(unreachable)
)
(func $dynCall_v (; 14 ;) (param $fptr i32)
(call_indirect $FUNCSIG$v
(call_indirect (type $FUNCSIG$v)
(get_local $fptr)
)
)
(func $dynCall_iiii (; 15 ;) (param $fptr i32) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
(call_indirect $FUNCSIG$iiii
(call_indirect (type $FUNCSIG$iiii)
(get_local $0)
(get_local $1)
(get_local $2)
(get_local $fptr)
)
)
(func $dynCall_ffd (; 16 ;) (param $fptr i32) (param $0 f32) (param $1 f64) (result f32)
(call_indirect $FUNCSIG$ffd
(call_indirect (type $FUNCSIG$ffd)
(get_local $0)
(get_local $1)
(get_local $fptr)
)
)
(func $dynCall_iii (; 17 ;) (param $fptr i32) (param $0 i32) (param $1 i32) (result i32)
(call_indirect $FUNCSIG$iii
(call_indirect (type $FUNCSIG$iii)
(get_local $0)
(get_local $1)
(get_local $fptr)
Expand Down
4 changes: 2 additions & 2 deletions test/dot_s/indidx.wast
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
)
)
(return
(call_indirect $FUNCSIG$i
(call_indirect (type $FUNCSIG$i)
(get_local $2)
)
)
Expand Down Expand Up @@ -85,7 +85,7 @@
(unreachable)
)
(func $dynCall_i (; 10 ;) (param $fptr i32) (result i32)
(call_indirect $FUNCSIG$i
(call_indirect (type $FUNCSIG$i)
(get_local $fptr)
)
)
Expand Down
6 changes: 3 additions & 3 deletions test/dot_s/indirect-import.wast
Original file line number Diff line number Diff line change
Expand Up @@ -153,18 +153,18 @@
)
)
(func $dynCall_fd (; 18 ;) (param $fptr i32) (param $0 f64) (result f32)
(call_indirect $FUNCSIG$fd
(call_indirect (type $FUNCSIG$fd)
(get_local $0)
(get_local $fptr)
)
)
(func $dynCall_v (; 19 ;) (param $fptr i32)
(call_indirect $FUNCSIG$v
(call_indirect (type $FUNCSIG$v)
(get_local $fptr)
)
)
(func $dynCall_vi (; 20 ;) (param $fptr i32) (param $0 i32)
(call_indirect $FUNCSIG$vi
(call_indirect (type $FUNCSIG$vi)
(get_local $0)
(get_local $fptr)
)
Expand Down
Loading