From 86999ea044946f0c6b209c71dbf23102a3ecd1dc Mon Sep 17 00:00:00 2001 From: Pierre Chambart Date: Mon, 28 Aug 2023 23:36:25 +0200 Subject: [PATCH] Update for newer binaryen --- wasm/emit_wast.ml | 6 +----- wasm/imports_binaryen.wast | 12 ++++++------ wasm/wast.ml | 4 +--- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/wasm/emit_wast.ml b/wasm/emit_wast.ml index 546b14e6e..b52279957 100644 --- a/wasm/emit_wast.ml +++ b/wasm/emit_wast.ml @@ -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 } -> diff --git a/wasm/imports_binaryen.wast b/wasm/imports_binaryen.wast index 825a63421..b3afba05d 100644 --- a/wasm/imports_binaryen.wast +++ b/wasm/imports_binaryen.wast @@ -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 @@ -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 diff --git a/wasm/wast.ml b/wasm/wast.ml index 6d5e96e3e..178e2e6a5 100644 --- a/wasm/wast.ml +++ b/wasm/wast.ml @@ -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 =