commit 02f4899044e546f903403cbeb086aade7aed8918
parent 6196956d8d92147bed38e49d0fd6300c6c306ac7
Author: William Casarin <jb55@jb55.com>
Date: Sun, 18 Jul 2021 21:19:10 -0700
fix find_label bug
Signed-off-by: William Casarin <jb55@jb55.com>
Diffstat:
2 files changed, 36 insertions(+), 1 deletion(-)
diff --git a/src/wasm.c b/src/wasm.c
@@ -2884,7 +2884,7 @@ static int upsert_label(struct wasm_interp *interp, int fn,
num_labels = func_num_labels(interp, fn);
- if (*num_labels > 0 && ((*ind = find_label(interp, fn, instr_pos)) == 0)) {
+ if (*num_labels > 0 && ((*ind = find_label(interp, fn, instr_pos)) != -1)) {
// we already have the label
return 1;
}
diff --git a/wasm/unresolved_br.wat b/wasm/unresolved_br.wat
@@ -0,0 +1,35 @@
+
+(module
+ (func $add (param $lhs i32) (param $rhs i32) (result i32)
+ local.get $lhs
+ local.get $rhs
+ i32.add)
+ (func $sub (param $lhs i32) (param $rhs i32) (result i32)
+ local.get $lhs
+ local.get $rhs
+ i32.sub
+ loop
+ local.get 0
+ i32.const 1
+ i32.add
+ block
+ block
+ br 1
+ end
+ end
+ local.set 0
+ local.get 0
+ i32.const 4
+ i32.gt_u
+ br_if 0
+ end
+ )
+ (func $start (result i32)
+ (local i32 i32)
+ i32.const 0
+ i32.const 1
+ call $sub
+ )
+ (export "start" (func $start))
+ (export "add" (func $add))
+ (export "sub" (func $sub)))