From d3a54df47ac91fcce9b21ecd838b27ed71280643 Mon Sep 17 00:00:00 2001 From: Douglas Crosher Date: Sun, 24 Jan 2016 18:12:21 +1100 Subject: [PATCH] Add a zero argument break and return and make the expression type checking consistent with the fall-through expression. The prior code make the number of arguments to break and return operators dependent on the number of expected values, however this property does not hold in general. For example consider a single break with a single expression that returns the type (), the same type as `nop`, here the number of expected values could be zero yet there is one argument. Further the prior code appeared to make an interpretation of the arguments as a tuple constructor that would increase with multiple-value support, yet this is not consistent with the fall-through which is a single expression. The function return operator has the same issue. Even though the function expected results might be considered side-information, the number of arguments to return does not in general match the number of expected function results. Wasm currently has the start of multiple value expressions, there are single value results and the empty-values result from nop, so even now this needs some consideration to be consistent. There is some interest in exploring serializations of the AST that are not dependent on the context, and thus a need to have each operator have a defined number of arguments, not necessarily fixed but if not fixed then encoding in the operator. There is also a strong interest in having an efficient encoding for the zero argument break and return operators, even if this means exposing this at the AST level. The solution here adds separate zero expression break and return operators, which have a fixed number of arguments. These are only valid when the expected number of values is zero, but this does not add a new constraint and is still consistent with the fall-through expressions. The current break and return operators become fixed argument single expression operators for which their expression has the same semantics as the fall-through. Future multi-value expression support would be expected to add an explicit tuple or values constructor, matters yet to be decided, and these would likely be usable for the fall-through and the break or return expression so no new break or return expressions would be needed. --- ml-proto/host/lexer.mll | 4 + ml-proto/host/parser.mly | 20 ++--- ml-proto/spec/ast.ml | 12 ++- ml-proto/spec/check.ml | 25 +++--- ml-proto/spec/desugar.ml | 28 ++++--- ml-proto/spec/eval.ml | 20 ++--- ml-proto/spec/kernel.ml | 6 +- ml-proto/test/fac.wast | 12 +-- ml-proto/test/labels.wast | 163 ++++++++++++++++++++++++++++++++------ ml-proto/test/memory.wast | 8 +- ml-proto/test/switch.wast | 14 ++-- 11 files changed, 213 insertions(+), 99 deletions(-) diff --git a/ml-proto/host/lexer.mll b/ml-proto/host/lexer.mll index 0e96393989..0aee1e91da 100644 --- a/ml-proto/host/lexer.mll +++ b/ml-proto/host/lexer.mll @@ -142,9 +142,13 @@ rule token = parse | "block" { BLOCK } | "loop" { LOOP } | "br" { BR } + | "br0" { BR0 } | "br_if" { BR_IF } + | "br0_if" { BR0_IF } | "br_table" { BR_TABLE } + | "br0_table" { BR0_TABLE } | "return" { RETURN } + | "return0" { RETURN0 } | "if" { IF } | "then" { THEN } | "else" { ELSE } diff --git a/ml-proto/host/parser.mly b/ml-proto/host/parser.mly index b706a6c2e4..2aab9b1174 100644 --- a/ml-proto/host/parser.mly +++ b/ml-proto/host/parser.mly @@ -125,8 +125,8 @@ let implicit_decl c t at = %} %token INT FLOAT TEXT VAR VALUE_TYPE LPAR RPAR -%token NOP BLOCK IF THEN ELSE SELECT LOOP BR BR_IF BR_TABLE -%token CALL CALL_IMPORT CALL_INDIRECT RETURN +%token NOP BLOCK IF THEN ELSE SELECT LOOP BR BR0 BR_IF BR0_IF BR_TABLE BR0_TABLE +%token CALL CALL_IMPORT CALL_INDIRECT RETURN RETURN0 %token GET_LOCAL SET_LOCAL LOAD STORE OFFSET ALIGN %token CONST UNARY BINARY COMPARE CONVERT %token FUNC START TYPE PARAM RESULT LOCAL @@ -225,16 +225,18 @@ expr1 : { fun c -> let c' = anon_label c in let c'' = $2 c' in Loop ($3 c'') } | LOOP labeling1 labeling1 expr_list { fun c -> let c' = $2 c in let c'' = $3 c' in Loop ($4 c'') } - | BR var expr_opt { fun c -> Br ($2 c label, $3 c) } - | BR_IF var expr { fun c -> Br_if ($2 c label, None, $3 c) } - | BR_IF var expr expr { fun c -> Br_if ($2 c label, Some ($3 c), $4 c) } - | BR_TABLE var var_list expr + | BR var expr { fun c -> Br ($2 c label, $3 c) } + | BR0 var { fun c -> Br0 ($2 c label) } + | BR_IF var expr expr { fun c -> Br_if ($2 c label, $3 c, $4 c) } + | BR0_IF var expr { fun c -> Br0_if ($2 c label, $3 c) } + | BR0_TABLE var var_list expr { fun c -> let xs, x = Lib.List.split_last ($2 c label :: $3 c label) in - Br_table (xs, x, None, $4 c) } + Br0_table (xs, x, $4 c) } | BR_TABLE var var_list expr expr { fun c -> let xs, x = Lib.List.split_last ($2 c label :: $3 c label) in - Br_table (xs, x, Some ($4 c), $5 c) } - | RETURN expr_opt { fun c -> Return ($2 c) } + Br_table (xs, x, $4 c, $5 c) } + | RETURN expr { fun c -> Return ($2 c) } + | RETURN0 { fun c -> Return0 } | IF expr expr { fun c -> let c' = anon_label c in If ($2 c, [$3 c'], []) } | IF expr expr expr { fun c -> let c' = anon_label c in If ($2 c, [$3 c'], [$4 c']) } diff --git a/ml-proto/spec/ast.ml b/ml-proto/spec/ast.ml index 01a653c573..7a9d552997 100644 --- a/ml-proto/spec/ast.ml +++ b/ml-proto/spec/ast.ml @@ -15,10 +15,14 @@ and expr' = | Unreachable | Block of expr list | Loop of expr list - | Br of var * expr option - | Br_if of var * expr option * expr - | Br_table of var list * var * expr option * expr - | Return of expr option + | Br of var * expr + | Br0 of var + | Br_if of var * expr * expr + | Br0_if of var * expr + | Br_table of var list * var * expr * expr + | Br0_table of var list * var * expr + | Return of expr + | Return0 | If of expr * expr list * expr list | Select of expr * expr * expr | Call of var * expr list diff --git a/ml-proto/spec/check.ml b/ml-proto/spec/check.ml index 9280948c54..5c27e88f5d 100644 --- a/ml-proto/spec/check.ml +++ b/ml-proto/spec/check.ml @@ -104,7 +104,6 @@ let type_hostop = function * Conventions: * c : context * e : expr - * eo : expr option * v : value * t : value_type * et : expr_type @@ -127,18 +126,18 @@ let rec check_expr c et e = let c' = {c with labels = None :: c.labels} in check_expr c' et e1 - | Break (x, eo) -> - check_expr_opt c (label c x) eo e.at + | Break (x, e) -> + check_expr c (label c x) e - | BreakIf (x, eo, e1) -> - check_expr_opt c (label c x) eo e.at; - check_expr c (Some Int32Type) e1; + | BreakIf (x, e1, e2) -> + check_expr c (label c x) e1; + check_expr c (Some Int32Type) e2; check_type None et e.at - | BreakTable (xs, x, eo, e1) -> - List.iter (fun x -> check_expr_opt c (label c x) eo e.at) xs; - check_expr_opt c (label c x) eo e.at; - check_expr c (Some Int32Type) e1 + | BreakTable (xs, x, e1, e2) -> + List.iter (fun x -> check_expr c (label c x) e1) xs; + check_expr c (label c x) e2; + check_expr c (Some Int32Type) e2 | If (e1, e2, e3) -> check_expr c (Some Int32Type) e1; @@ -229,12 +228,6 @@ and check_exprs c ts es at = try List.iter2 (check_expr c) ets es with Invalid_argument _ -> error at "arity mismatch" -and check_expr_opt c et eo at = - match et, eo with - | Some t, Some e -> check_expr c et e - | None, None -> () - | _ -> error at "arity mismatch" - and check_literal c et l = check_type (Some (type_value l.it)) et l.at diff --git a/ml-proto/spec/desugar.ml b/ml-proto/spec/desugar.ml index 28e8c54a9a..bebb668730 100644 --- a/ml-proto/spec/desugar.ml +++ b/ml-proto/spec/desugar.ml @@ -14,14 +14,14 @@ and relabel' f n = function | Block (es, e) -> Block (List.map (relabel f (n + 1)) es, relabel f (n + 1) e) | Loop e -> Loop (relabel f (n + 1) e) - | Break (x, eo) -> - Break (relabel_var f n x, Lib.Option.map (relabel f n) eo) - | BreakIf (x, eo, e) -> - BreakIf (relabel_var f n x, Lib.Option.map (relabel f n) eo, relabel f n e) - | BreakTable (xs, x, eo, e) -> + | Break (x, e) -> + Break (relabel_var f n x, relabel f n e) + | BreakIf (x, e1, e2) -> + BreakIf (relabel_var f n x, relabel f n e1, relabel f n e2) + | BreakTable (xs, x, e1, e2) -> BreakTable (List.map (relabel_var f n) xs, relabel_var f n x, - Lib.Option.map (relabel f n) eo, relabel f n e) + relabel f n e1, relabel f n e2) | If (e1, e2, e3) -> If (relabel f n e1, relabel f n e2, relabel f n e3) | Select (e1, e2, e3) -> Select (relabel f n e1, relabel f n e2, relabel f n e3) @@ -65,14 +65,18 @@ and expr' at = function | Ast.Block es -> let es', e = Lib.List.split_last es in Block (List.map expr es', expr e) | Ast.Loop es -> Block ([], Loop (block es) @@ at) - | Ast.Br (x, eo) -> Break (x, Lib.Option.map expr eo) - | Ast.Br_if (x, eo, e) -> BreakIf (x, Lib.Option.map expr eo, expr e) - | Ast.Br_table (xs, x, eo, e) -> - BreakTable (xs, x, Lib.Option.map expr eo, expr e) - | Ast.Return eo -> Break (-1 @@ at, Lib.Option.map expr eo) + | Ast.Br (x, e) -> Break (x, expr e) + | Ast.Br0 (x) -> Break (x, Nop @@ Source.no_region) + | Ast.Br_if (x, e1, e2) -> BreakIf (x, expr e1, expr e2) + | Ast.Br0_if (x, e) -> BreakIf (x, Nop @@ Source.no_region, expr e) + | Ast.Br_table (xs, x, e1, e2) -> + BreakTable (xs, x, expr e1, expr e2) + | Ast.Br0_table (xs, x, e) -> + BreakTable (xs, x, Nop @@ Source.no_region, expr e) + | Ast.Return e -> Break (-1 @@ at, expr e) + | Ast.Return0 -> Break (-1 @@ at, Nop @@ Source.no_region) | Ast.If (e, es1, es2) -> If (expr e, seq es1, seq es2) | Ast.Select (e1, e2, e3) -> Select (expr e1, expr e2, expr e3) - | Ast.Call (x, es) -> Call (x, List.map expr es) | Ast.Call_import (x, es) -> CallImport (x, List.map expr es) | Ast.Call_indirect (x, e, es) -> CallIndirect (x, expr e, List.map expr es) diff --git a/ml-proto/spec/eval.ml b/ml-proto/spec/eval.ml index 459b634d59..e4dee9be81 100644 --- a/ml-proto/spec/eval.ml +++ b/ml-proto/spec/eval.ml @@ -146,17 +146,17 @@ let rec eval_expr (c : config) (e : expr) = let c' = {c with labels = L.label :: c.labels} in (try eval_expr c' e1 with L.Label _ -> eval_expr c e) - | Break (x, eo) -> - raise (label c x (eval_expr_opt c eo)) + | Break (x, e) -> + raise (label c x (eval_expr c e)) - | BreakIf (x, eo, e) -> - let v = eval_expr_opt c eo in - let i = int32 (eval_expr c e) e.at in + | BreakIf (x, e1, e2) -> + let v = eval_expr c e1 in + let i = int32 (eval_expr c e2) e.at in if i <> 0l then raise (label c x v) else None - | BreakTable (xs, x, eo, e) -> - let v = eval_expr_opt c eo in - let i = int32 (eval_expr c e) e.at in + | BreakTable (xs, x, e1, e2) -> + let v = eval_expr c e1 in + let i = int32 (eval_expr c e2) e.at in if I32.lt_u i (Int32.of_int (List.length xs)) then raise (label c (List.nth xs (Int32.to_int i)) v) else raise (label c x v) @@ -257,10 +257,6 @@ let rec eval_expr (c : config) (e : expr) = let vs = List.map (eval_expr c) es in eval_hostop c hostop vs e.at -and eval_expr_opt c = function - | Some e -> eval_expr c e - | None -> None - and eval_func instance f vs = let args = List.map ref vs in let vars = List.map (fun t -> ref (default_value t)) f.it.locals in diff --git a/ml-proto/spec/kernel.ml b/ml-proto/spec/kernel.ml index 03ab828e45..353e4b8a01 100644 --- a/ml-proto/spec/kernel.ml +++ b/ml-proto/spec/kernel.ml @@ -80,9 +80,9 @@ and expr' = | Unreachable (* trap *) | Block of expr list * expr (* execute in sequence *) | Loop of expr (* loop header *) - | Break of var * expr option (* break to n-th surrounding label *) - | BreakIf of var * expr option * expr (* conditional break *) - | BreakTable of var list * var * expr option * expr (* indexed break *) + | Break of var * expr (* break to n-th surrounding label *) + | BreakIf of var * expr * expr (* conditional break *) + | BreakTable of var list * var * expr * expr (* indexed break *) | If of expr * expr * expr (* conditional *) | Select of expr * expr * expr (* branchless conditional *) | Call of var * expr list (* call function *) diff --git a/ml-proto/test/fac.wast b/ml-proto/test/fac.wast index 6ac120b145..601877c035 100644 --- a/ml-proto/test/fac.wast +++ b/ml-proto/test/fac.wast @@ -26,13 +26,13 @@ (loop (if (i64.eq (get_local 1) (i64.const 0)) - (br 2) + (br0 2) (block (set_local 2 (i64.mul (get_local 1) (get_local 2))) (set_local 1 (i64.sub (get_local 1) (i64.const 1))) ) ) - (br 0) + (br0 0) ) (get_local 2) ) @@ -46,13 +46,13 @@ (loop $done $loop (if (i64.eq (get_local $i) (i64.const 0)) - (br $done) + (br0 $done) (block (set_local $res (i64.mul (get_local $i) (get_local $res))) (set_local $i (i64.sub (get_local $i) (i64.const 1))) ) ) - (br $loop) + (br0 $loop) ) (get_local $res) ) @@ -62,11 +62,11 @@ (local i64) (set_local 1 (i64.const 1)) (block - (br_if 0 (i64.lt_s (get_local 0) (i64.const 2))) + (br0_if 0 (i64.lt_s (get_local 0) (i64.const 2))) (loop (set_local 1 (i64.mul (get_local 1) (get_local 0))) (set_local 0 (i64.add (get_local 0) (i64.const -1))) - (br_if 0 (i64.gt_s (get_local 0) (i64.const 1))) + (br0_if 0 (i64.gt_s (get_local 0) (i64.const 1))) ) ) (get_local 1) diff --git a/ml-proto/test/labels.wast b/ml-proto/test/labels.wast index a44e412335..07681949bf 100644 --- a/ml-proto/test/labels.wast +++ b/ml-proto/test/labels.wast @@ -14,7 +14,7 @@ (if (i32.eq (get_local $i) (i32.const 5)) (br $exit (get_local $i)) ) - (br $cont) + (br0 $cont) ) ) @@ -24,13 +24,13 @@ (loop $exit $cont (set_local $i (i32.add (get_local $i) (i32.const 1))) (if (i32.eq (get_local $i) (i32.const 5)) - (br $cont) + (br0 $cont) ) (if (i32.eq (get_local $i) (i32.const 8)) (br $exit (get_local $i)) ) (set_local $i (i32.add (get_local $i) (i32.const 1))) - (br $cont) + (br0 $cont) ) ) @@ -54,7 +54,7 @@ (if (i32.gt_u (get_local $i) (get_local $max)) (br $exit (get_local $i)) ) - (br $cont) + (br0 $cont) ) ) @@ -72,31 +72,31 @@ (block (if (i32.const 1) - (then $l (br $l) (set_local $i (i32.const 666))) + (then $l (br0 $l) (set_local $i (i32.const 666))) ) (set_local $i (i32.add (get_local $i) (i32.const 1))) (if (i32.const 1) - (then $l (br $l) (set_local $i (i32.const 666))) + (then $l (br0 $l) (set_local $i (i32.const 666))) (else (set_local $i (i32.const 888))) ) (set_local $i (i32.add (get_local $i) (i32.const 1))) (if (i32.const 1) - (then $l (br $l) (set_local $i (i32.const 666))) + (then $l (br0 $l) (set_local $i (i32.const 666))) (else $l (set_local $i (i32.const 888))) ) (set_local $i (i32.add (get_local $i) (i32.const 1))) (if (i32.const 0) (then (set_local $i (i32.const 888))) - (else $l (br $l) (set_local $i (i32.const 666))) + (else $l (br0 $l) (set_local $i (i32.const 666))) ) (set_local $i (i32.add (get_local $i) (i32.const 1))) (if (i32.const 0) (then $l (set_local $i (i32.const 888))) - (else $l (br $l) (set_local $i (i32.const 666))) + (else $l (br0 $l) (set_local $i (i32.const 666))) ) (set_local $i (i32.add (get_local $i) (i32.const 1))) ) @@ -112,7 +112,7 @@ (block $3 (block $2 (block $1 - (br_table $0 $1 $2 $3 $default (get_local 0)) + (br0_table $0 $1 $2 $3 $default (get_local 0)) ) ;; 1 (i32.const 1) ) ;; 2 @@ -132,8 +132,8 @@ (block $default (block $1 (block $0 - (br_table $0 $1 (get_local 0)) - (br $default) + (br0_table $0 $1 (get_local 0)) + (br0 $default) ) ;; 0 (return (i32.const 0)) ) ;; 1 @@ -147,9 +147,9 @@ (set_local $i (i32.const 0)) (block $outer (block $inner - (br_if $inner (i32.const 0)) + (br0_if $inner (i32.const 0)) (set_local $i (i32.or (get_local $i) (i32.const 0x1))) - (br_if $inner (i32.const 1)) + (br0_if $inner (i32.const 1)) (set_local $i (i32.or (get_local $i) (i32.const 0x2))) ) (br_if $outer @@ -202,6 +202,79 @@ (br $l1 (i32.const 3))))) ) + ;; Check that the return and break expression is equivalent to the + ;; function top level and block fall-through expressions. + + ;; Supporting functions. + (func $nop) + (func $v1 (result i32) + (i32.const 1)) + + (func $nop1 + (nop)) + (func $nop1_return + (return (nop))) + (func $nop1_return0 + (return0)) + (func $nop1_block + (block $top (nop))) + (func $nop1_block_br + (block $top (br $top (nop)))) + (func $nop1_block_br0 + (block $top (br0 $top))) + + (func $nop2 + (call $nop)) + (func $nop2_return + (return (call $nop))) + (func $nop2_block + (block $top (call $nop))) + (func $nop2_block_br + (block $top (br $top (call $nop)))) + + (func $nop3 + (i32.const 1)) + (func $nop3_return + (return (i32.const 1))) + (func $nop3_block + (block $top (i32.const 1))) + (func $nop3_block_br + (block $top (br $top (i32.const 1)))) + + (func $nop4 + (call $v1)) + (func $nop4_return + (return (call $v1))) + (func $nop4_block + (block $top (call $v1))) + (func $nop4_block_br + (block $top (br $top (call $v1)))) + + (func $nop_block_br_if + (block $l1 + (br $l1 (if (i32.const 1) (i32.const 1))))) + + (func $loop_nop_br (result i32) + (local $i i32) + (set_local $i (i32.const 0)) + (loop $exit $cont + (set_local $i (i32.add (get_local $i) (i32.const 1))) + (if (i32.eq (get_local $i) (i32.const 5)) + (br $exit (get_local $i))) + (br $cont (i32.const 1)))) + + (func $nop_br0_if + (block $l0 (br0_if $l0 (i32.const 1)))) + (func $nop_br_if + (block $l0 (br_if $l0 (nop) (i32.const 1)))) + + (func $misc_nop1 (result i32) + (block $l0 + (if (i32.const 1) + (br $l0 (block $l1 (br $l1 (i32.const 1)))) + (block (block $l1 (br $l1 (i32.const 1))) (nop))) + (i32.const 1))) + (export "block" $block) (export "loop1" $loop1) (export "loop2" $loop2) @@ -218,6 +291,29 @@ (export "misc1" $misc1) (export "misc2" $misc2) (export "redefinition" $redefinition) + (export "nop1" $nop1) + (export "nop1_return" $nop1_return) + (export "nop1_return0" $nop1_return0) + (export "nop1_block" $nop1_block) + (export "nop1_block_br" $nop1_block_br) + (export "nop1_block_br0" $nop1_block_br0) + (export "nop2" $nop2) + (export "nop2_return" $nop2_return) + (export "nop2_block" $nop2_block) + (export "nop2_block_br" $nop2_block_br) + (export "nop3" $nop3) + (export "nop3_return" $nop3_return) + (export "nop3_block" $nop3_block) + (export "nop3_block_br" $nop3_block_br) + (export "nop4" $nop4) + (export "nop4_return" $nop4_return) + (export "nop4_block" $nop4_block) + (export "nop4_block_br" $nop4_block_br) + (export "nop_block_br_if" $nop_block_br_if) + (export "loop_nop_br" $loop_nop_br) + (export "nop_br0_if" $nop_br0_if) + (export "nop_br_if" $nop_br_if) + (export "misc_nop1" $misc_nop1) ) (assert_return (invoke "block") (i32.const 1)) @@ -244,22 +340,37 @@ (assert_return (invoke "misc2") (i32.const 1)) (assert_return (invoke "redefinition") (i32.const 5)) -(assert_invalid (module (func (loop $l (br $l (i32.const 0))))) "arity mismatch") -(assert_invalid (module (func (block $l (f32.neg (br_if $l (i32.const 1))) (nop)))) "type mismatch") +(assert_return (invoke "nop1")) +(assert_return (invoke "nop1_return")) +(assert_return (invoke "nop1_return0")) +(assert_return (invoke "nop1_block")) +(assert_return (invoke "nop1_block_br")) +(assert_return (invoke "nop1_block_br0")) +(assert_return (invoke "nop2")) +(assert_return (invoke "nop2_return")) +(assert_return (invoke "nop2_block")) +(assert_return (invoke "nop2_block_br")) +(assert_return (invoke "nop3")) +(assert_return (invoke "nop3_return")) +(assert_return (invoke "nop3_block")) +(assert_return (invoke "nop3_block_br")) +(assert_return (invoke "nop4")) +(assert_return (invoke "nop4_return")) +(assert_return (invoke "nop4_block")) +(assert_return (invoke "nop4_block_br")) +(assert_return (invoke "nop_block_br_if")) +(assert_return (invoke "loop_nop_br") (i32.const 5)) +(assert_return (invoke "nop_br0_if")) +(assert_return (invoke "nop_br_if")) +(assert_return (invoke "misc_nop1") (i32.const 1)) + +(assert_invalid (module (func (block $l (f32.neg (br0_if $l (i32.const 1))) (nop)))) "type mismatch") +(assert_invalid (module (func (result f32) (block $l (br_if $l (f32.const 0) (i32.const 1))))) "type mismatch") (assert_invalid (module (func (result f32) (block $l (br_if $l (f32.const 0) (i32.const 1))))) "type mismatch") (assert_invalid (module (func (result i32) (block $l (br_if $l (f32.const 0) (i32.const 1))))) "type mismatch") -(assert_invalid (module (func (block $l (f32.neg (br_if $l (f32.const 0) (i32.const 1)))))) "arity mismatch") +(assert_invalid (module (func (block $l (f32.neg (br_if $l (f32.const 0) (i32.const 1)))))) "type mismatch") (assert_invalid (module (func (param i32) (result i32) (block $l (f32.neg (br_if $l (f32.const 0) (get_local 0)))))) "type mismatch") (assert_invalid (module (func (param i32) (result f32) (block $l (f32.neg (block $i (br_if $l (f32.const 3) (get_local 0))))))) "type mismatch") -(assert_invalid (module (func (block $l0 (br_if $l0 (nop) (i32.const 1))))) - "arity mismatch") -(assert_invalid (module (func (result i32) - (block $l0 - (if (i32.const 1) - (br $l0 (block $l1 (br $l1 (i32.const 1)))) - (block (block $l1 (br $l1 (i32.const 1))) (nop)) - ) - (i32.const 1)))) "arity mismatch") diff --git a/ml-proto/test/memory.wast b/ml-proto/test/memory.wast index 0cdc8781b0..cd1536122a 100644 --- a/ml-proto/test/memory.wast +++ b/ml-proto/test/memory.wast @@ -95,7 +95,7 @@ (loop (if (i32.eq (get_local 0) (i32.const 0)) - (br 2) + (br0 2) ) (set_local 2 (i32.mul (get_local 0) (i32.const 4))) (i32.store (get_local 2) (get_local 0)) @@ -105,7 +105,7 @@ (return (i32.const 0)) ) (set_local 0 (i32.sub (get_local 0) (i32.const 1))) - (br 0) + (br0 0) ) (i32.const 1) ) @@ -117,7 +117,7 @@ (loop (if (i32.eq (get_local 0) (i32.const 0)) - (br 2) + (br0 2) ) (set_local 2 (f64.convert_s/i32 (get_local 0))) (f64.store align=1 (get_local 0) (get_local 2)) @@ -127,7 +127,7 @@ (return (i32.const 0)) ) (set_local 0 (i32.sub (get_local 0) (i32.const 1))) - (br 0) + (br0 0) ) (i32.const 1) ) diff --git a/ml-proto/test/switch.wast b/ml-proto/test/switch.wast index 9c1b0e29f9..b9d36d9918 100644 --- a/ml-proto/test/switch.wast +++ b/ml-proto/test/switch.wast @@ -13,7 +13,7 @@ (block $2 (block $1 (block $0 - (br_table $0 $1 $2 $3 $4 $5 $6 $7 $default + (br0_table $0 $1 $2 $3 $4 $5 $6 $7 $default (get_local $i) ) ) ;; 0 @@ -25,12 +25,12 @@ ;; fallthrough ) ;; 3 (set_local $j (i32.sub (i32.const 0) (get_local $i))) - (br $switch) + (br0 $switch) ) ;; 4 - (br $switch) + (br0 $switch) ) ;; 5 (set_local $j (i32.const 101)) - (br $switch) + (br0 $switch) ) ;; 6 (set_local $j (i32.const 101)) ;; fallthrough @@ -57,7 +57,7 @@ (block $2 (block $1 (block $0 - (br_table $0 $1 $2 $3 $4 $5 $6 $7 $default + (br0_table $0 $1 $2 $3 $4 $5 $6 $7 $default (i32.wrap/i64 (get_local $i)) ) ) ;; 0 @@ -111,7 +111,7 @@ ;; Corner cases (func $corner (result i32) (block - (br_table 0 (i32.const 0)) + (br0_table 0 (i32.const 0)) ) (i32.const 1) ) @@ -152,4 +152,4 @@ (assert_return (invoke "corner") (i32.const 1)) -(assert_invalid (module (func (br_table 3 (i32.const 0)))) "unknown label") +(assert_invalid (module (func (br0_table 3 (i32.const 0)))) "unknown label")