diff --git a/src/lib_scoru_wasm/init_encodings.ml b/src/lib_scoru_wasm/init_encodings.ml index e900555e2a525ab087d075b7e45dfa8e2ebcd7ed..f8b40b971a24ccf65e471f6371f15dfc9cacbb4e 100644 --- a/src/lib_scoru_wasm/init_encodings.ml +++ b/src/lib_scoru_wasm/init_encodings.ml @@ -75,6 +75,7 @@ let init_section_eq : | Func, Func -> Some Eq | Global, Global -> Some Eq | Table, Table -> Some Eq + | Memory, Memory -> Some Eq | _, _ -> None let aggregate_cases : @@ -162,6 +163,11 @@ let init_kont_encoding = Table (value [] Interpreter_encodings.Ast.table_encoding) Wasm_encoding.table_encoding + @ aggregate_cases + "memory" + Memory + (value [] Interpreter_encodings.Ast.memory_encoding) + Wasm_encoding.memory_encoding @ [ case "IK_Remaining" diff --git a/src/lib_webassembly/exec/eval.ml b/src/lib_webassembly/exec/eval.ml index 95961d237d3bf91d31a2a86ed203fa8c9fcf36e9..a7f9e5f159c4e3266fd25be850179c3944036e54 100644 --- a/src/lib_webassembly/exec/eval.ml +++ b/src/lib_webassembly/exec/eval.ml @@ -1096,6 +1096,7 @@ type (_, _) init_section = | Func : (func, func_inst) init_section | Global : (global, global_inst) init_section | Table : (table, table_inst) init_section + | Memory : (memory, memory_inst) init_section let section_fetch_vec : type a b. module_inst -> (a, b) init_section -> b Vector.t = @@ -1104,6 +1105,7 @@ let section_fetch_vec : | Func -> inst.funcs | Global -> inst.globals | Table -> inst.tables + | Memory -> inst.memories let section_set_vec : type a b. module_inst -> (a, b) init_section -> b Vector.t -> module_inst = @@ -1112,6 +1114,7 @@ let section_set_vec : | Func, funcs -> {inst with funcs} | Global, globals -> {inst with globals} | Table, tables -> {inst with tables} + | Memory, memories -> {inst with memories} type init_kont = | IK_Start @@ -1132,7 +1135,8 @@ let section_next_init_kont : match sec with | Func -> IK_Aggregate (inst0, Global, map_kont m.it.globals) | Global -> IK_Aggregate (inst0, Table, map_kont m.it.tables) - | Table -> IK_Remaining inst0 + | Table -> IK_Aggregate (inst0, Memory, map_kont m.it.memories) + | Memory -> IK_Remaining inst0 let section_step : type a b. @@ -1142,11 +1146,13 @@ let section_step : | Func -> create_func module_reg self | Global -> create_global module_reg self | Table -> fun x -> Lwt.return (create_table x) + | Memory -> fun x -> Lwt.return (create_memory x) let section_update_module_ref : type a b. (a, b) init_section -> bool = function | Func -> true | Global -> false | Table -> false + | Memory -> true let init_step ~module_reg ~self host_funcs (m : module_) (exts : extern list) = function @@ -1194,28 +1200,16 @@ let init_step ~module_reg ~self host_funcs (m : module_) (exts : extern list) = | IK_Aggregate_concat (inst0, sec, tick) -> let+ tick = concat_step tick in IK_Aggregate_concat (inst0, sec, tick) - | IK_Remaining inst1 -> - let {memories; exports; elems; datas; start; _} = m.it in + | IK_Remaining inst2 -> + let {exports; elems; datas; start; _} = m.it in (* TODO: https://gitlab.com/tezos/tezos/-/issues/3076 These transformations should be refactored and abadoned during the tickification, to avoid the roundtrip vector -> list -> vector. *) - let* memories = Vector.to_list memories in let* elems = Vector.to_list elems in let* datas = Vector.to_list datas in let* exports = Vector.to_list exports in - (* TODO: https://gitlab.com/tezos/tezos/-/issues/3076 - [memories] should be a lazy structure. *) - let* memories = - Vector.concat - inst1.memories - (Vector.of_list (List.map create_memory memories)) - in - - let inst2 = {inst1 with memories} in - update_module_ref module_reg self inst2 ; - let* new_exports = TzStdLib.List.map_s (create_export inst2) exports in let* new_elems = TzStdLib.List.map_s (create_elem module_reg self) elems diff --git a/src/lib_webassembly/exec/eval.mli b/src/lib_webassembly/exec/eval.mli index c87f1354809e021925c089b5ed9809011dbb4d35..989ec1467079aa488475dbe3381b0a0d74875307 100644 --- a/src/lib_webassembly/exec/eval.mli +++ b/src/lib_webassembly/exec/eval.mli @@ -33,6 +33,7 @@ type (_, _) init_section = | Func : (Ast.func, func_inst) init_section | Global : (Ast.global, global_inst) init_section | Table : (Ast.table, table_inst) init_section + | Memory : (Ast.memory, memory_inst) init_section type init_kont = | IK_Start (** Very first tick of the [init] function *)