Skip to content

Commit

Permalink
Update for newer binaryen
Browse files Browse the repository at this point in the history
  • Loading branch information
chambart committed Aug 28, 2023
1 parent dc7303f commit 86999ea
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
6 changes: 1 addition & 5 deletions wasm/emit_wast.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2060,11 +2060,7 @@ module ToWasm = struct
| Struct_get { typ; field } -> C.struct_get typ field arg
| Struct_get_packed { typ; field; extend } ->
C.struct_get_packed extend typ field arg
| Ref_cast_i31 -> begin
match mode with
| Reference -> Cst.node "ref.cast" [ Cst.atom "i31"; arg ]
| Binarien -> Cst.node "ref.as_i31" [ arg ]
end
| Ref_cast_i31 -> Cst.node "ref.cast" [ Cst.atom "i31"; arg ]
| Is_i31 -> Cst.node "ref.test" [ Cst.atom "i31"; arg ]
| Array_len t -> C.array_len t arg
| Reinterpret { from_type; to_type } ->
Expand Down
12 changes: 6 additions & 6 deletions wasm/imports_binaryen.wast
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,14 @@
(func (export "caml_compare") (param $a (ref eq)) (param $b (ref eq)) (result (ref i31))
(local $a_block (ref $Gen_block))
(local $b_block (ref $Gen_block))
(if (result (ref i31)) (ref.is_i31 (local.get $a))
(if (result (ref i31)) (ref.test i31 (local.get $a))
(then
(if (result (ref i31)) (ref.is_i31 (local.get $b))
(if (result (ref i31)) (ref.test i31 (local.get $b))
(then (return_call $compare_int (local.get $a) (local.get $b)))
(else (i31.new (i32.const -1))))
)
(else
(if (result (ref i31)) (ref.is_i31 (local.get $b))
(if (result (ref i31)) (ref.test i31 (local.get $b))
(then (i31.new (i32.const 1)))
(else
(local.set $b_block
Expand Down Expand Up @@ -212,14 +212,14 @@
(func $caml_equal (export "caml_equal") (param $a (ref eq)) (param $b (ref eq)) (result (ref i31))
(local $a_block (ref $Gen_block))
(local $b_block (ref $Gen_block))
(if (result (ref i31)) (ref.is_i31 (local.get $a))
(if (result (ref i31)) (ref.test i31 (local.get $a))
(then
(if (result (ref i31)) (ref.is_i31 (local.get $b))
(if (result (ref i31)) (ref.test i31 (local.get $b))
(then (i31.new (ref.eq (local.get $a) (local.get $b))))
(else (i31.new (i32.const 0))))
)
(else
(if (result (ref i31)) (ref.is_i31 (local.get $b))
(if (result (ref i31)) (ref.test i31 (local.get $b))
(then (i31.new (i32.const 0)))
(else
(local.set $b_block
Expand Down
4 changes: 1 addition & 3 deletions wasm/wast.ml
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,7 @@ module C = struct
let call func args = node "call" ([ !$(Func_id.name func) ] @ args)

let ref_cast typ arg =
let name =
match mode with Binarien -> "ref.cast_static" | Reference -> "ref.cast"
in
let name = "ref.cast" in
node name ([ type_name typ ] @ arg)

let declare_func f =
Expand Down

0 comments on commit 86999ea

Please sign in to comment.