diff --git a/spectec/spec/1-syntax.watsup b/spectec/spec/1-syntax.watsup index 1ef353c052..9b13a6c93f 100644 --- a/spectec/spec/1-syntax.watsup +++ b/spectec/spec/1-syntax.watsup @@ -198,7 +198,7 @@ syntax mem hint(desc "memory") = syntax elem hint(desc "table segment") = ELEM reftype expr* elemmode? syntax data hint(desc "memory segment") = - DATA (byte*)* datamode? + DATA byte* datamode? syntax start hint(desc "start function") = START funcidx diff --git a/spectec/spec/3-typing.watsup b/spectec/spec/3-typing.watsup index 8aab87931a..f4a79988c9 100644 --- a/spectec/spec/3-typing.watsup +++ b/spectec/spec/3-typing.watsup @@ -431,7 +431,7 @@ rule Elem_ok: -- (Elemmode_ok: C |- elemmode : rt)? rule Data_ok: - C |- DATA (b*)* datamode? : OK + C |- DATA b* datamode? : OK -- (Datamode_ok: C |- datamode : OK)? rule Elemmode_ok/active: diff --git a/spectec/spec/4-runtime.watsup b/spectec/spec/4-runtime.watsup index e613e36527..8d6d7af442 100644 --- a/spectec/spec/4-runtime.watsup +++ b/spectec/spec/4-runtime.watsup @@ -116,7 +116,18 @@ def $funcaddr(state) : funcaddr* hint(show %.MODULE.FUNC) def $funcaddr((s; f)) = f.MODULE.FUNC def $funcinst(state) : funcinst* hint(show %.FUNC) +def $globalinst(state) : globalinst* hint(show %.GLOBAL) +def $tableinst(state) : tableinst* hint(show %.TABLE) +def $meminst(state) : meminst* hint(show %.MEM) +def $eleminst(state) : eleminst* hint(show %.ELEM) +def $datainst(state) : datainst* hint(show %.DATA) + def $funcinst((s; f)) = s.FUNC +def $globalinst((s; f)) = s.GLOBAL +def $tableinst((s; f)) = s.TABLE +def $meminst((s; f)) = s.MEM +def $eleminst((s; f)) = s.ELEM +def $datainst((s; f)) = s.DATA def $func(state, funcidx) : funcinst hint(show %.FUNC#`[%]) def $global(state, globalidx) : globalinst hint(show %.GLOBAL#`[%]) diff --git a/spectec/spec/7-module.watsup b/spectec/spec/7-module.watsup new file mode 100644 index 0000000000..72e8027d6a --- /dev/null +++ b/spectec/spec/7-module.watsup @@ -0,0 +1,196 @@ +;; Allocation + + +def $funcs(externval*) : funcaddr* +def $funcs(epsilon) = epsilon +def $funcs((FUNC fa) externval'*) = fa $funcs(externval'*) +def $funcs(externval externval'*) = $funcs(externval'*) + -- otherwise + +def $globals(externval*) : globaladdr* +def $globals(epsilon) = epsilon +def $globals((GLOBAL ga) externval'*) = ga $globals(externval'*) +def $globals(externval externval'*) = $globals(externval'*) + -- otherwise + +def $tables(externval*) : tableaddr* +def $tables(epsilon) = epsilon +def $tables((TABLE ta) externval'*) = ta $tables(externval'*) +def $tables(externval externval'*) = $tables(externval'*) + -- otherwise + +def $mems(externval*) : memaddr* +def $mems(epsilon) = epsilon +def $mems((MEM ma) externval'*) = ma $mems(externval'*) +def $mems(externval externval'*) = $mems(externval'*) + -- otherwise + + +def $instexport(funcaddr*, globaladdr*, tableaddr*, memaddr*, export) : exportinst +def $instexport(fa*, ga*, ta*, ma*, EXPORT name (FUNC x)) = { NAME name, VALUE (FUNC fa*[x]) } +def $instexport(fa*, ga*, ta*, ma*, EXPORT name (GLOBAL x)) = { NAME name, VALUE (GLOBAL ga*[x]) } +def $instexport(fa*, ga*, ta*, ma*, EXPORT name (TABLE x)) = { NAME name, VALUE (TABLE ta*[x]) } +def $instexport(fa*, ga*, ta*, ma*, EXPORT name (MEM x)) = { NAME name, VALUE (MEM ma*[x]) } + + +def $allocfunc(store, moduleinst, func) : (store, funcaddr) +def $allocfunc(s, m, func) = (s[.FUNC =.. fi], |s.FUNC|) + -- if fi = { MODULE m, CODE func } + +def $allocfuncs(store, moduleinst, func*) : (store, funcaddr*) +def $allocfuncs(s, m, epsilon) = (s, epsilon) +def $allocfuncs(s, m, func func'*) = (s_2, fa fa'*) + -- if (s_1, fa) = $allocfunc(s, m, func) + -- if (s_2, fa'*) = $allocfuncs(s_1, m, func'*) + +def $allocglobal(store, globaltype, val) : (store, globaladdr) +def $allocglobal(s, globaltype, val) = (s[.GLOBAL =.. gi], |s.GLOBAL|) + -- if gi = { TYPE globaltype, VALUE val } + +def $allocglobals(store, globaltype*, val*) : (store, globaladdr*) +def $allocglobals(s, epsilon, epsilon) = (s, epsilon) +def $allocglobals(s, globaltype globaltype'*, val val'*) = (s_2, ga ga'*) + -- if (s_1, ga) = $allocglobal(s, globaltype, val) + -- if (s_2, ga'*) = $allocglobals(s_1, globaltype'*, val'*) + +def $alloctable(store, tabletype) : (store, tableaddr) +def $alloctable(s, `[i .. j] rt) = (s[.TABLE =.. ti], |s.TABLE|) + -- if ti = { TYPE (`[i .. j] rt), ELEM (REF.NULL rt)^i } + +def $alloctables(store, tabletype*) : (store, tableaddr*) +def $alloctables(s, epsilon) = (s, epsilon) +def $alloctables(s, tabletype tabletype'*) = (s_2, ta ta'*) + -- if (s_1, ta) = $alloctable(s, tabletype) + -- if (s_2, ta'*) = $alloctables(s_1, tabletype'*) + +def $allocmem(store, memtype) : (store, memaddr) +def $allocmem(s, `[i .. j] I8) = (s[.MEM =.. mi], |s.MEM|) + -- if mi = { TYPE (`[i .. j] I8), DATA 0^(i * 64 * $Ki()) } + +def $allocmems(store, memtype*) : (store, memaddr*) +def $allocmems(s, epsilon) = (s, epsilon) +def $allocmems(s, memtype memtype'*) = (s_2, ma ma'*) + -- if (s_1, ma) = $allocmem(s, memtype) + -- if (s_2, ma'*) = $allocmems(s_1, memtype'*) + +def $allocelem(store, reftype, ref*) : (store, elemaddr) +def $allocelem(s, rt, ref*) = (s[.ELEM =.. ei], |s.ELEM|) + -- if ei = { TYPE rt, ELEM ref* } + +def $allocelems(store, reftype*, (ref*)*) : (store, elemaddr*) +def $allocelems(s, epsilon, epsilon) = (s, epsilon) +def $allocelems(s, rt rt'*, ref* ref'**) = (s_2, ea ea'*) + -- if (s_1, ea) = $allocelem(s, rt, ref*) + -- if (s_2, ea'*) = $allocelems(s_2, rt'*, ref'**) + +def $allocdata(store, byte*) : (store, dataaddr) +def $allocdata(s, byte*) = (s[.DATA =.. di], |s.DATA|) + -- if di = { DATA byte* } + +def $allocdatas(store, byte**) : (store, dataaddr*) +def $allocdatas(s, epsilon) = (s, epsilon) +def $allocdatas(s, byte* byte'**) = (s_2, da da'*) + -- if (s_1, da) = $allocdata(s, byte*) + -- if (s_2, da'*) = $allocdatas(s_1, byte'**) + + +def $allocmodule(store, module, externval*, val*, (ref*)*) : (store, moduleinst) +def $allocmodule(s, module, externval*, val*, (ref*)*) = (s_6, m) + -- if module = + MODULE + import* + func^n_func + (GLOBAL globaltype expr_1)^n_global + (TABLE tabletype)^n_table + (MEMORY memtype)^n_mem + (ELEM rt expr_2* elemmode?)^n_elem + (DATA byte* datamode?)^n_data + start? + export* + -- if fa_ex* = $funcs(externval*) + -- if ga_ex* = $globals(externval*) + -- if ta_ex* = $tables(externval*) + -- if ma_ex* = $mems(externval*) + -- if fa* = $(|s.FUNC|+i_func)^(i_func val)* + -- if elem* = (ELEM reftype (instr_2*)* elemmode?)* + -- (Step_read : s; f_init; instr_2* ~> ref)** + -- if (s', m) = $allocmodule(s, module, externval*, val*, (ref*)*) + -- if f = { LOCAL epsilon, MODULE m } + -- if n_elem = |elem*| + -- if instr_elem* = $concat_instr($runelem(elem*[i], i)^(i valtype_res^k diff --git a/spectec/src/backend-latex/render.ml b/spectec/src/backend-latex/render.ml index 80e1097be3..29fd1840f2 100644 --- a/spectec/src/backend-latex/render.ml +++ b/spectec/src/backend-latex/render.ml @@ -327,7 +327,7 @@ exception Arity_mismatch let rec expand_iter args iter = match iter with | Opt | List | List1 -> iter - | ListN e -> ListN (expand_exp args e) + | ListN (e, id_opt) -> ListN (expand_exp args e, id_opt) and expand_exp args e = expand_exp' args e.it $ e.at and expand_exp' args e' = @@ -441,7 +441,10 @@ and render_iter env = function | Opt -> "^?" | List -> "^\\ast" | List1 -> "^{+}" - | ListN {it = ParenE (e, _); _} | ListN e -> "^{" ^ render_exp env e ^ "}" + | ListN ({it = ParenE (e, _); _}, None) | ListN (e, None) -> + "^{" ^ render_exp env e ^ "}" + | ListN (e, Some id) -> + "^(" ^ id.it ^ "<" ^ render_exp env e ^ ")" (* Types *) @@ -684,25 +687,16 @@ let render_ruledef env d = render_rule_deco env " \\, " id1 id2 "" | _ -> failwith "render_ruledef" -let render_red_conditions env = function +let render_conditions env tabs = function | [] -> " & " | [Elem {it = ElsePr; _}] -> " &\\quad\n " ^ word "otherwise" | (Elem {it = ElsePr; _})::prems -> " &\\quad\n " ^ word "otherwise, if" ^ "~" ^ - concat_map_nl " \\\\\n &&&&\\quad {\\land}~" "" (render_prem env) prems + concat_map_nl (" \\\\\n " ^ tabs ^ "\\quad {\\land}~") "" (render_prem env) prems | prems -> " &\\quad\n " ^ word "if" ^ "~" ^ - concat_map_nl " \\\\\n &&&&\\quad {\\land}~" "" (render_prem env) prems + concat_map_nl (" \\\\\n " ^ tabs ^ "\\quad {\\land}~") "" (render_prem env) prems -let render_func_conditions env = function - | [] -> " & " - | [Elem {it = ElsePr; _}] -> " &\\quad\n " ^ word "otherwise" - | (Elem {it = ElsePr; _})::prems -> - " &\\quad\n " ^ word "otherwise, if" ^ "~" ^ - concat_map_nl " \\\\\n &&&\\quad {\\land}~" "" (render_prem env) prems - | prems -> - " &\\quad\n " ^ word "if" ^ "~" ^ - concat_map_nl " \\\\\n &&&\\quad {\\land}~" "" (render_prem env) prems let render_reddef env d = match d.it with @@ -714,14 +708,14 @@ let render_reddef env d = in render_rule_deco env "" id1 id2 " \\quad " ^ "& " ^ render_exp env e1 ^ " &" ^ render_atom env SqArrow ^ "& " ^ - render_exp env e2 ^ render_red_conditions env prems + render_exp env e2 ^ render_conditions env "&&&&" prems | _ -> failwith "render_reddef" let render_funcdef env d = match d.it with | DefD (id1, e1, e2, prems) -> render_exp env (CallE (id1, e1) $ d.at) ^ " &=& " ^ - render_exp env e2 ^ render_func_conditions env prems + render_exp env e2 ^ render_conditions env "&&&" prems | _ -> failwith "render_funcdef" let rec render_sep_defs ?(sep = " \\\\\n") ?(br = " \\\\[0.8ex]\n") f = function diff --git a/spectec/src/el/ast.ml b/spectec/src/el/ast.ml index e2c082c30a..eca3a9ebab 100644 --- a/spectec/src/el/ast.ml +++ b/spectec/src/el/ast.ml @@ -44,7 +44,7 @@ type iter = | Opt (* `?` *) | List (* `*` *) | List1 (* `+` *) - | ListN of exp (* `^` exp *) + | ListN of exp * id option (* `^` exp *) (* Types *) diff --git a/spectec/src/el/eq.ml b/spectec/src/el/eq.ml index f5cf97f0d0..5d57318b09 100644 --- a/spectec/src/el/eq.ml +++ b/spectec/src/el/eq.ml @@ -20,7 +20,9 @@ let eq_nl_list eq_x xs1 xs2 = eq_list (eq_nl_elem eq_x) xs1 xs2 let rec eq_iter iter1 iter2 = iter1 = iter2 || match iter1, iter2 with - | ListN e1, ListN e2 -> eq_exp e1 e2 + | ListN (e1, None), ListN (e2, None) -> eq_exp e1 e2 + | ListN (e1, Some id1), ListN (e2, Some id2) -> + eq_exp e1 e2 && id1.it = id2.it | _, _ -> false diff --git a/spectec/src/el/free.ml b/spectec/src/el/free.ml index 8ca0e1ff15..bb5d3e0af0 100644 --- a/spectec/src/el/free.ml +++ b/spectec/src/el/free.ml @@ -18,6 +18,7 @@ let union sets1 sets2 = defid = Set.union sets1.defid sets2.defid; } +let free_opt free_x xo = Option.(value (map free_x xo) ~default:empty) let free_list free_x xs = List.(fold_left union empty (map free_x xs)) let free_nl_elem free_x = function Nl -> empty | Elem x -> free_x x @@ -37,7 +38,7 @@ let free_defid id = {empty with defid = Set.singleton id.it} let rec free_iter iter = match iter with | Opt | List | List1 -> empty - | ListN e -> free_exp e + | ListN (e, id_opt) -> union (free_exp e) (free_opt free_varid id_opt) (* Types *) diff --git a/spectec/src/el/print.ml b/spectec/src/el/print.ml index 6a4f6683e6..67373fe75c 100644 --- a/spectec/src/el/print.ml +++ b/spectec/src/el/print.ml @@ -70,7 +70,8 @@ let rec string_of_iter iter = | Opt -> "?" | List -> "*" | List1 -> "+" - | ListN e -> "^" ^ string_of_exp e + | ListN (e, None) -> "^" ^ string_of_exp e + | ListN (e, Some id) -> "^(" ^ id.it ^ "<" ^ string_of_exp e ^ ")" (* Types *) diff --git a/spectec/src/frontend/elab.ml b/spectec/src/frontend/elab.ml index 4cebbc6ecd..e8ebdef00d 100644 --- a/spectec/src/frontend/elab.ml +++ b/spectec/src/frontend/elab.ml @@ -336,7 +336,13 @@ let rec elab_iter env iter : Il.iter = | Opt -> Il.Opt | List -> Il.List | List1 -> Il.List1 - | ListN e -> Il.ListN (elab_exp env e (NatT $ e.at)) + | ListN (e, id_opt) -> + Option.iter (fun id -> + let t = find "variable" env.vars (prefix_id id) in + if not (equiv_typ env t (NatT $ id.at)) then + error_typ e.at "iteration index" (NatT $ id.at) + ) id_opt; + Il.ListN (elab_exp env e (NatT $ e.at), id_opt) (* Types *) @@ -762,7 +768,7 @@ and elab_exp_notation' env e t : Il.exp list = | (EpsE | SeqE _), IterT (t1, iter) -> [elab_exp_notation_iter env (unseq_exp e) (t1, iter) t e.at] | IterE (e1, iter1), IterT (t1, iter) -> - if (iter = Opt) <> (iter1 = Opt) then + if (iter = Opt) && (iter1 <> Opt) then error_typ e.at "iteration expression" t; let es1' = elab_exp_notation' env e1 t1 in let iter1' = elab_iter env iter1 in diff --git a/spectec/src/frontend/multiplicity.ml b/spectec/src/frontend/multiplicity.ml index 175b58c9ad..6fb9dae19f 100644 --- a/spectec/src/frontend/multiplicity.ml +++ b/spectec/src/frontend/multiplicity.ml @@ -65,10 +65,16 @@ let check_id env ctx id = let iter_nl_list f xs = List.iter (function Nl -> () | Elem x -> f x) xs +let strip_index = function + | ListN (e, Some _) -> ListN (e, None) + | iter -> iter + let rec check_iter env ctx iter = match iter with | Opt | List | List1 -> () - | ListN e -> check_exp env ctx e + | ListN (e, id_opt) -> + Option.iter (fun id -> check_id env (strip_index iter::ctx) id) id_opt; + check_exp env ctx e and check_exp env ctx e = match e.it with @@ -108,7 +114,7 @@ and check_exp env ctx e = | StrE efs -> iter_nl_list (fun ef -> check_exp env ctx (snd ef)) efs | IterE (e1, iter) -> check_iter env ctx iter; - check_exp env (iter::ctx) e1 + check_exp env (strip_index iter::ctx) e1 and check_path env ctx p = match p.it with @@ -130,7 +136,7 @@ let rec check_prem env ctx prem = | ElsePr -> () | IterPr (prem', iter) -> check_iter env ctx iter; - check_prem env (iter::ctx) prem' + check_prem env (strip_index iter::ctx) prem' let check_def d : env = match d.it with @@ -158,12 +164,18 @@ type occur = Il.Ast.iter list Env.t let union = Env.union (fun _ ctx1 ctx2 -> assert (ctx1 = ctx2); Some ctx1) +let strip_index = function + | ListN (e, Some _) -> ListN (e, None) + | iter -> iter + let rec annot_iter env iter : Il.Ast.iter * occur = match iter with | Opt | List | List1 -> iter, Env.empty - | ListN e -> - let e', occur = annot_exp env e in - ListN e', occur + | ListN (e, id_opt) -> + let e', occur1 = annot_exp env e in + let occur2 = + match id_opt with None -> Env.empty | Some id -> Env.singleton id.it [] in + ListN (e', id_opt), union occur1 occur2 and annot_exp env e : Il.Ast.exp * occur = let it, occur = @@ -280,7 +292,8 @@ and annot_iterexp env occur1 (iter, ids) at : Il.Ast.iterexp * occur = Env.filter_map (fun _ iters -> match iters with | [] -> None - | iter1::iters' -> assert (Il.Eq.eq_iter iter iter1); Some iters' + | iter1::iters' -> + assert (Il.Eq.eq_iter (strip_index iter) iter1); Some iters' ) occur1 in let ids' = List.map (fun (x, _) -> x $ at) (Env.bindings occur1') in diff --git a/spectec/src/frontend/parser.mly b/spectec/src/frontend/parser.mly index 236a80586e..6b9660526b 100644 --- a/spectec/src/frontend/parser.mly +++ b/spectec/src/frontend/parser.mly @@ -135,12 +135,16 @@ check_atom : (* Iteration *) - iter : | QUEST { Opt } | PLUS { List1 } | STAR { List } - | UP arith_prim { ListN $2 } + | UP arith_prim + { match $2.it with + | ParenE ({it = CmpE({it = VarE id; _}, LtOp, e); _}, false) -> + ListN (e, Some id) + | _ -> ListN ($2, None) + } (* Types *) diff --git a/spectec/src/il/ast.ml b/spectec/src/il/ast.ml index 18cafd638e..73b58558de 100644 --- a/spectec/src/il/ast.ml +++ b/spectec/src/il/ast.ml @@ -41,7 +41,7 @@ type iter = | Opt (* `?` *) | List (* `*` *) | List1 (* `+` *) - | ListN of exp (* `^` exp *) + | ListN of exp * id option (* `^` exp *) (* Types *) diff --git a/spectec/src/il/eq.ml b/spectec/src/il/eq.ml index 61fb22f964..47bdae7f62 100644 --- a/spectec/src/il/eq.ml +++ b/spectec/src/il/eq.ml @@ -24,7 +24,9 @@ let eq_id i1 i2 = let rec eq_iter iter1 iter2 = iter1 = iter2 || match iter1, iter2 with - | ListN e1, ListN e2 -> eq_exp e1 e2 + | ListN (e1, None), ListN (e2, None) -> eq_exp e1 e2 + | ListN (e1, Some id1), ListN (e2, Some id2) -> + eq_exp e1 e2 && id1.it = id2.it | _, _ -> false diff --git a/spectec/src/il/free.ml b/spectec/src/il/free.ml index 43bcd12d49..f27b533e48 100644 --- a/spectec/src/il/free.ml +++ b/spectec/src/il/free.ml @@ -55,7 +55,7 @@ let free_defid id = {empty with defid = Set.singleton id.it} let rec free_iter iter = match iter with | Opt | List | List1 -> empty - | ListN e -> free_exp e + | ListN (e, id_opt) -> union (free_exp e) (free_opt free_varid id_opt) (* Types *) diff --git a/spectec/src/il/print.ml b/spectec/src/il/print.ml index e33beff47a..a2fb91d5f7 100644 --- a/spectec/src/il/print.ml +++ b/spectec/src/il/print.ml @@ -76,7 +76,9 @@ let rec string_of_iter iter = | Opt -> "?" | List -> "*" | List1 -> "+" - | ListN e -> "^" ^ string_of_exp e + | ListN (e, None) -> "^" ^ string_of_exp e + | ListN (e, Some id) -> + "^(" ^ id.it ^ "<" ^ string_of_exp e ^ ")" and string_of_typ t = match t.it with diff --git a/spectec/src/il/validation.ml b/spectec/src/il/validation.ml index 7703a0f951..b151d7c2e9 100644 --- a/spectec/src/il/validation.ml +++ b/spectec/src/il/validation.ml @@ -241,7 +241,17 @@ let valid_list valid_x_y env xs ys at = let rec valid_iter env iter = match iter with | Opt | List | List1 -> () - | ListN e -> valid_exp env e (NatT $ e.at) + | ListN (e, None) -> valid_exp env e (NatT $ e.at) + | ListN (e, Some id) -> + valid_exp env e (NatT $ e.at); + let t', dim = find "variable" env.vars id in + equiv_typ env t' (NatT $ e.at) e.at; + match dim with + | [ListN (e', None)] when Eq.eq_exp e e' -> () + | _ -> + error e.at ("use of iterated variable `" ^ + id.it ^ String.concat "" (List.map string_of_iter dim) ^ + "` outside suitable iteraton context") (* Types *) @@ -259,7 +269,7 @@ and valid_typ env t = List.iter (valid_typ env) ts | IterT (t1, iter) -> match iter with - | ListN e -> error e.at "definite iterator not allowed in type" + | ListN (e, _) -> error e.at "definite iterator not allowed in type" | _ -> valid_typ env t1; valid_iter env iter and valid_deftyp env dt = @@ -471,17 +481,22 @@ and valid_path env p t : typ = and valid_iterexp env (iter, ids) : env = valid_iter env iter; + let iter' = + match iter with + | ListN (e, Some _) -> ListN (e, None) + | iter -> iter + in List.fold_left (fun env id -> match find "variable" env.vars id with | t, iter1::iters - when Eq.eq_iter (snd (Lib.List.split_last (iter1::iters))) iter -> + when Eq.eq_iter (snd (Lib.List.split_last (iter1::iters))) iter' -> {env with vars = Env.add id.it (t, fst (Lib.List.split_last (iter1::iters))) env.vars} | _, iters -> error id.at ("iteration variable `" ^ id.it ^ "` has incompatible dimension `" ^ id.it ^ String.concat "" (List.map string_of_iter iters) ^ - "` in iteration `_" ^ string_of_iter iter ^ "`") + "` in iteration `_" ^ string_of_iter iter' ^ "`") ) env ids diff --git a/spectec/src/middlend/sideconditions.ml b/spectec/src/middlend/sideconditions.ml index 2efc16feab..ff1aa2d02b 100644 --- a/spectec/src/middlend/sideconditions.ml +++ b/spectec/src/middlend/sideconditions.ml @@ -22,7 +22,7 @@ module Env = Map.Make(String) (* Smart constructor for LenE that optimizes |x^n| into n *) let lenE e = match e.it with -| IterE (_, (ListN ne, _)) -> ne +| IterE (_, (ListN (ne, _), _)) -> ne | _ -> LenE e $$ no_region % (NatT $ no_region) let is_null e = CmpE (EqOp, e, OptE None $$ no_region % e.note) $$ no_region % (BoolT $ e.at) @@ -39,7 +39,7 @@ let iter_side_conditions env ((iter, vs) : iterexp) : premise list = | _, [] -> [] | Opt, (e::es) -> List.map (fun e' -> iffE (is_null e) (is_null e')) es | (List|List1), (e::es) -> List.map (same_len e) es - | ListN ne, es -> List.map (has_len ne) es + | ListN (ne, _), es -> List.map (has_len ne) es (* Expr traversal *) let rec t_exp env e : premise list = @@ -87,7 +87,7 @@ let rec t_exp env e : premise list = and t_iterexp env (iter, _) = t_iter env iter and t_iter env = function - | ListN e -> t_exp env e + | ListN (e, _) -> t_exp env e | _ -> [] and t_path env path = match path.it with diff --git a/spectec/src/middlend/sub.ml b/spectec/src/middlend/sub.ml index 8950a17f54..a2c4d82655 100644 --- a/spectec/src/middlend/sub.ml +++ b/spectec/src/middlend/sub.ml @@ -119,7 +119,7 @@ and t_exp' env = function | SubE (e, t1, t2) -> SubE (e, t1, t2) and t_iter env = function - | ListN e -> ListN (t_exp env e) + | ListN (e, id_opt) -> ListN (t_exp env e, id_opt) | i -> i and t_iterexp env (iter, vs) = (t_iter env iter, vs) diff --git a/spectec/src/middlend/totalize.ml b/spectec/src/middlend/totalize.ml index 53bc54d322..4c8c98e787 100644 --- a/spectec/src/middlend/totalize.ml +++ b/spectec/src/middlend/totalize.ml @@ -78,7 +78,7 @@ and t_exp' env = function | SubE (e, t1, t2) -> SubE (e, t1, t2) and t_iter env = function - | ListN e -> ListN (t_exp env e) + | ListN (e, id_opt) -> ListN (t_exp env e, id_opt) | i -> i and t_iterexp env (iter, vs) = (t_iter env iter, vs) diff --git a/spectec/src/middlend/unthe.ml b/spectec/src/middlend/unthe.ml index a272bdb753..3ed9ef98b3 100644 --- a/spectec/src/middlend/unthe.ml +++ b/spectec/src/middlend/unthe.ml @@ -156,7 +156,7 @@ and t_iterexp n (iter, vs) = unary t_iter n iter (fun iter' -> (iter', vs)) and t_iter n iter = match iter with - | ListN e -> unary t_exp n e (fun e' -> ListN e') + | ListN (e, id_opt) -> unary t_exp n e (fun e' -> ListN (e', id_opt)) | _ -> [], iter and t_path n = phrase t_path' n diff --git a/spectec/src/middlend/wild.ml b/spectec/src/middlend/wild.ml index e79b15a8e5..f2b395555f 100644 --- a/spectec/src/middlend/wild.ml +++ b/spectec/src/middlend/wild.ml @@ -180,7 +180,7 @@ and t_iterexp env (iter, vs) = unary t_iter env iter (fun iter' -> (iter', vs)) and t_iter env iter = match iter with - | ListN e -> unary t_exp env e (fun e' -> ListN e') + | ListN (e, id_opt) -> unary t_exp env e (fun e' -> ListN (e', id_opt)) | _ -> [], iter and t_path env = phrase t_path' env diff --git a/spectec/test-frontend/TEST.md b/spectec/test-frontend/TEST.md index c40b2f5373..ee2a1007e3 100644 --- a/spectec/test-frontend/TEST.md +++ b/spectec/test-frontend/TEST.md @@ -297,8 +297,8 @@ syntax mem = MEMORY(memtype) ;; 1-syntax.watsup:198.1-199.31 syntax elem = `ELEM%%*%?`(reftype, expr*, elemmode?) -;; 1-syntax.watsup:200.1-201.26 -syntax data = `DATA(*)%*%?`(byte**, datamode?) +;; 1-syntax.watsup:200.1-201.23 +syntax data = `DATA%*%?`(byte*, datamode?) ;; 1-syntax.watsup:202.1-203.16 syntax start = START(funcidx) @@ -886,8 +886,8 @@ relation Datamode_ok: `%|-%:OK`(context, datamode) ;; 3-typing.watsup:402.1-402.73 relation Data_ok: `%|-%:OK`(context, data) ;; 3-typing.watsup:433.1-435.40 - rule _ {C : context, b** : byte**, datamode? : datamode?}: - `%|-%:OK`(C, `DATA(*)%*%?`(b*{b}*{b}, datamode?{datamode})) + rule _ {C : context, b* : byte*, datamode? : datamode?}: + `%|-%:OK`(C, `DATA%*%?`(b*{b}, datamode?{datamode})) -- (Datamode_ok: `%|-%:OK`(C, datamode))?{datamode} ;; 3-typing.watsup:405.1-405.74 @@ -1052,10 +1052,10 @@ syntax frame = {LOCAL val*, MODULE moduleinst} ;; 4-runtime.watsup:96.1-96.47 syntax state = `%;%`(store, frame) -;; 4-runtime.watsup:172.1-179.5 +;; 4-runtime.watsup:183.1-190.5 rec { -;; 4-runtime.watsup:172.1-179.5 +;; 4-runtime.watsup:183.1-190.5 syntax admininstr = | UNREACHABLE | NOP @@ -1119,106 +1119,131 @@ def funcaddr : state -> funcaddr* ;; 4-runtime.watsup:118.1-118.52 def funcinst : state -> funcinst* - ;; 4-runtime.watsup:119.1-119.31 + ;; 4-runtime.watsup:125.1-125.31 def {f : frame, s : store} funcinst(`%;%`(s, f)) = s.FUNC_store -;; 4-runtime.watsup:121.1-121.67 +;; 4-runtime.watsup:119.1-119.58 +def globalinst : state -> globalinst* + ;; 4-runtime.watsup:126.1-126.35 + def {f : frame, s : store} globalinst(`%;%`(s, f)) = s.GLOBAL_store + +;; 4-runtime.watsup:120.1-120.55 +def tableinst : state -> tableinst* + ;; 4-runtime.watsup:127.1-127.33 + def {f : frame, s : store} tableinst(`%;%`(s, f)) = s.TABLE_store + +;; 4-runtime.watsup:121.1-121.49 +def meminst : state -> meminst* + ;; 4-runtime.watsup:128.1-128.29 + def {f : frame, s : store} meminst(`%;%`(s, f)) = s.MEM_store + +;; 4-runtime.watsup:122.1-122.52 +def eleminst : state -> eleminst* + ;; 4-runtime.watsup:129.1-129.31 + def {f : frame, s : store} eleminst(`%;%`(s, f)) = s.ELEM_store + +;; 4-runtime.watsup:123.1-123.52 +def datainst : state -> datainst* + ;; 4-runtime.watsup:130.1-130.31 + def {f : frame, s : store} datainst(`%;%`(s, f)) = s.DATA_store + +;; 4-runtime.watsup:132.1-132.67 def func : (state, funcidx) -> funcinst - ;; 4-runtime.watsup:129.1-129.48 + ;; 4-runtime.watsup:140.1-140.48 def {f : frame, s : store, x : idx} func(`%;%`(s, f), x) = s.FUNC_store[f.MODULE_frame.FUNC_moduleinst[x]] -;; 4-runtime.watsup:122.1-122.69 +;; 4-runtime.watsup:133.1-133.69 def global : (state, globalidx) -> globalinst - ;; 4-runtime.watsup:130.1-130.54 + ;; 4-runtime.watsup:141.1-141.54 def {f : frame, s : store, x : idx} global(`%;%`(s, f), x) = s.GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]] -;; 4-runtime.watsup:123.1-123.68 +;; 4-runtime.watsup:134.1-134.68 def table : (state, tableidx) -> tableinst - ;; 4-runtime.watsup:131.1-131.51 + ;; 4-runtime.watsup:142.1-142.51 def {f : frame, s : store, x : idx} table(`%;%`(s, f), x) = s.TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]] -;; 4-runtime.watsup:124.1-124.66 +;; 4-runtime.watsup:135.1-135.66 def mem : (state, memidx) -> meminst - ;; 4-runtime.watsup:132.1-132.45 + ;; 4-runtime.watsup:143.1-143.45 def {f : frame, s : store, x : idx} mem(`%;%`(s, f), x) = s.MEM_store[f.MODULE_frame.MEM_moduleinst[x]] -;; 4-runtime.watsup:125.1-125.67 +;; 4-runtime.watsup:136.1-136.67 def elem : (state, tableidx) -> eleminst - ;; 4-runtime.watsup:133.1-133.48 + ;; 4-runtime.watsup:144.1-144.48 def {f : frame, s : store, x : idx} elem(`%;%`(s, f), x) = s.ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]] -;; 4-runtime.watsup:126.1-126.67 +;; 4-runtime.watsup:137.1-137.67 def data : (state, dataidx) -> datainst - ;; 4-runtime.watsup:134.1-134.48 + ;; 4-runtime.watsup:145.1-145.48 def {f : frame, s : store, x : idx} data(`%;%`(s, f), x) = s.DATA_store[f.MODULE_frame.DATA_moduleinst[x]] -;; 4-runtime.watsup:127.1-127.68 +;; 4-runtime.watsup:138.1-138.68 def local : (state, localidx) -> val - ;; 4-runtime.watsup:135.1-135.35 + ;; 4-runtime.watsup:146.1-146.35 def {f : frame, s : store, x : idx} local(`%;%`(s, f), x) = f.LOCAL_frame[x] -;; 4-runtime.watsup:138.1-138.78 +;; 4-runtime.watsup:149.1-149.78 def with_local : (state, localidx, val) -> state - ;; 4-runtime.watsup:147.1-147.52 + ;; 4-runtime.watsup:158.1-158.52 def {f : frame, s : store, v : val, x : idx} with_local(`%;%`(s, f), x, v) = `%;%`(s, f[LOCAL_frame[x] = v]) -;; 4-runtime.watsup:139.1-139.85 +;; 4-runtime.watsup:150.1-150.85 def with_global : (state, globalidx, val) -> state - ;; 4-runtime.watsup:148.1-148.77 + ;; 4-runtime.watsup:159.1-159.77 def {f : frame, s : store, v : val, x : idx} with_global(`%;%`(s, f), x, v) = `%;%`(s[GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]].VALUE_globalinst = v], f) -;; 4-runtime.watsup:140.1-140.88 +;; 4-runtime.watsup:151.1-151.88 def with_table : (state, tableidx, nat, ref) -> state - ;; 4-runtime.watsup:149.1-149.79 + ;; 4-runtime.watsup:160.1-160.79 def {f : frame, i : nat, r : ref, s : store, x : idx} with_table(`%;%`(s, f), x, i, r) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]].ELEM_tableinst[i] = r], f) -;; 4-runtime.watsup:141.1-141.84 +;; 4-runtime.watsup:152.1-152.84 def with_tableinst : (state, tableidx, tableinst) -> state - ;; 4-runtime.watsup:150.1-150.74 + ;; 4-runtime.watsup:161.1-161.74 def {f : frame, s : store, ti : tableinst, x : idx} with_tableinst(`%;%`(s, f), x, ti) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]] = ti], f) -;; 4-runtime.watsup:142.1-142.93 +;; 4-runtime.watsup:153.1-153.93 def with_mem : (state, memidx, nat, nat, byte*) -> state - ;; 4-runtime.watsup:151.1-151.82 + ;; 4-runtime.watsup:162.1-162.82 def {b* : byte*, f : frame, i : nat, j : nat, s : store, x : idx} with_mem(`%;%`(s, f), x, i, j, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]].DATA_meminst[i : j] = b*{b}], f) -;; 4-runtime.watsup:143.1-143.77 +;; 4-runtime.watsup:154.1-154.77 def with_meminst : (state, memidx, meminst) -> state - ;; 4-runtime.watsup:152.1-152.68 + ;; 4-runtime.watsup:163.1-163.68 def {f : frame, mi : meminst, s : store, x : idx} with_meminst(`%;%`(s, f), x, mi) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]] = mi], f) -;; 4-runtime.watsup:144.1-144.82 +;; 4-runtime.watsup:155.1-155.82 def with_elem : (state, elemidx, ref*) -> state - ;; 4-runtime.watsup:153.1-153.72 + ;; 4-runtime.watsup:164.1-164.72 def {f : frame, r* : ref*, s : store, x : idx} with_elem(`%;%`(s, f), x, r*{r}) = `%;%`(s[ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]].ELEM_eleminst = r*{r}], f) -;; 4-runtime.watsup:145.1-145.82 +;; 4-runtime.watsup:156.1-156.82 def with_data : (state, dataidx, byte*) -> state - ;; 4-runtime.watsup:154.1-154.72 + ;; 4-runtime.watsup:165.1-165.72 def {b* : byte*, f : frame, s : store, x : idx} with_data(`%;%`(s, f), x, b*{b}) = `%;%`(s[DATA_store[f.MODULE_frame.DATA_moduleinst[x]].DATA_datainst = b*{b}], f) -;; 4-runtime.watsup:156.1-156.63 +;; 4-runtime.watsup:167.1-167.63 def grow_table : (tableinst, nat, ref) -> tableinst - ;; 4-runtime.watsup:159.1-163.36 + ;; 4-runtime.watsup:170.1-174.36 def {i : nat, i' : nat, j : nat, n : n, r : ref, r'* : ref*, rt : reftype, ti : tableinst, ti' : tableinst} grow_table(ti, n, r) = ti' -- if (ti = {TYPE `%%`(`[%..%]`(i, j), rt), ELEM r'*{r'}}) -- if (i' = (|r'*{r'}| + n)) -- if (ti' = {TYPE `%%`(`[%..%]`(i', j), rt), ELEM r'*{r'} :: r^n{}}) -- Tabletype_ok: `|-%:OK`(ti'.TYPE_tableinst) -;; 4-runtime.watsup:157.1-157.55 +;; 4-runtime.watsup:168.1-168.55 def grow_memory : (meminst, nat) -> meminst - ;; 4-runtime.watsup:164.1-168.34 + ;; 4-runtime.watsup:175.1-179.34 def {b* : byte*, i : nat, i' : nat, j : nat, mi : meminst, mi' : meminst, n : n} grow_memory(mi, n) = mi' -- if (mi = {TYPE `%I8`(`[%..%]`(i, j)), DATA b*{b}}) -- if (i' = ((|b*{b}| / (64 * $Ki)) + n)) -- if (mi' = {TYPE `%I8`(`[%..%]`(i', j)), DATA b*{b} :: 0^((n * 64) * $Ki){}}) -- Memtype_ok: `|-%:OK`(mi'.TYPE_meminst) -;; 4-runtime.watsup:181.1-184.21 +;; 4-runtime.watsup:192.1-195.21 rec { -;; 4-runtime.watsup:181.1-184.21 +;; 4-runtime.watsup:192.1-195.21 syntax E = | _HOLE | _SEQ(val*, E, instr*) @@ -1656,6 +1681,268 @@ relation Step: `%~>%`(config, config) rule data.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [DATA.DROP_admininstr(x)]), `%;%*`($with_data(z, x, []), [])) +;; 7-module.watsup:4.1-4.35 +rec { + +;; 7-module.watsup:4.1-4.35 +def funcs : externval* -> funcaddr* + ;; 7-module.watsup:5.1-5.30 + def funcs([]) = [] + ;; 7-module.watsup:6.1-6.59 + def {externval'* : externval*, fa : funcaddr} funcs([FUNC_externval(fa)] :: externval'*{externval'}) = [fa] :: $funcs(externval'*{externval'}) + ;; 7-module.watsup:7.1-8.15 + def {externval : externval, externval'* : externval*} funcs([externval] :: externval'*{externval'}) = $funcs(externval'*{externval'}) + -- otherwise +} + +;; 7-module.watsup:10.1-10.39 +rec { + +;; 7-module.watsup:10.1-10.39 +def globals : externval* -> globaladdr* + ;; 7-module.watsup:11.1-11.32 + def globals([]) = [] + ;; 7-module.watsup:12.1-12.65 + def {externval'* : externval*, ga : globaladdr} globals([GLOBAL_externval(ga)] :: externval'*{externval'}) = [ga] :: $globals(externval'*{externval'}) + ;; 7-module.watsup:13.1-14.15 + def {externval : externval, externval'* : externval*} globals([externval] :: externval'*{externval'}) = $globals(externval'*{externval'}) + -- otherwise +} + +;; 7-module.watsup:16.1-16.37 +rec { + +;; 7-module.watsup:16.1-16.37 +def tables : externval* -> tableaddr* + ;; 7-module.watsup:17.1-17.31 + def tables([]) = [] + ;; 7-module.watsup:18.1-18.62 + def {externval'* : externval*, ta : tableaddr} tables([TABLE_externval(ta)] :: externval'*{externval'}) = [ta] :: $tables(externval'*{externval'}) + ;; 7-module.watsup:19.1-20.15 + def {externval : externval, externval'* : externval*} tables([externval] :: externval'*{externval'}) = $tables(externval'*{externval'}) + -- otherwise +} + +;; 7-module.watsup:22.1-22.33 +rec { + +;; 7-module.watsup:22.1-22.33 +def mems : externval* -> memaddr* + ;; 7-module.watsup:23.1-23.29 + def mems([]) = [] + ;; 7-module.watsup:24.1-24.56 + def {externval'* : externval*, ma : memaddr} mems([MEM_externval(ma)] :: externval'*{externval'}) = [ma] :: $mems(externval'*{externval'}) + ;; 7-module.watsup:25.1-26.15 + def {externval : externval, externval'* : externval*} mems([externval] :: externval'*{externval'}) = $mems(externval'*{externval'}) + -- otherwise +} + +;; 7-module.watsup:29.1-29.83 +def instexport : (funcaddr*, globaladdr*, tableaddr*, memaddr*, export) -> exportinst + ;; 7-module.watsup:30.1-30.95 + def {fa* : funcaddr*, ga* : globaladdr*, ma* : memaddr*, name : name, ta* : tableaddr*, x : idx} instexport(fa*{fa}, ga*{ga}, ta*{ta}, ma*{ma}, EXPORT(name, FUNC_externuse(x))) = {NAME name, VALUE FUNC_externval(fa*{fa}[x])} + ;; 7-module.watsup:31.1-31.99 + def {fa* : funcaddr*, ga* : globaladdr*, ma* : memaddr*, name : name, ta* : tableaddr*, x : idx} instexport(fa*{fa}, ga*{ga}, ta*{ta}, ma*{ma}, EXPORT(name, GLOBAL_externuse(x))) = {NAME name, VALUE GLOBAL_externval(ga*{ga}[x])} + ;; 7-module.watsup:32.1-32.97 + def {fa* : funcaddr*, ga* : globaladdr*, ma* : memaddr*, name : name, ta* : tableaddr*, x : idx} instexport(fa*{fa}, ga*{ga}, ta*{ta}, ma*{ma}, EXPORT(name, TABLE_externuse(x))) = {NAME name, VALUE TABLE_externval(ta*{ta}[x])} + ;; 7-module.watsup:33.1-33.93 + def {fa* : funcaddr*, ga* : globaladdr*, ma* : memaddr*, name : name, ta* : tableaddr*, x : idx} instexport(fa*{fa}, ga*{ga}, ta*{ta}, ma*{ma}, EXPORT(name, MEM_externuse(x))) = {NAME name, VALUE MEM_externval(ma*{ma}[x])} + +;; 7-module.watsup:36.1-36.60 +def allocfunc : (store, moduleinst, func) -> (store, funcaddr) + ;; 7-module.watsup:37.1-38.37 + def {fi : funcinst, func : func, m : moduleinst, s : store} allocfunc(s, m, func) = (s[FUNC_store =.. [fi]], |s.FUNC_store|) + -- if (fi = {MODULE m, CODE func}) + +;; 7-module.watsup:40.1-40.63 +rec { + +;; 7-module.watsup:40.1-40.63 +def allocfuncs : (store, moduleinst, func*) -> (store, funcaddr*) + ;; 7-module.watsup:41.1-41.46 + def {m : moduleinst, s : store} allocfuncs(s, m, []) = (s, []) + ;; 7-module.watsup:42.1-44.50 + def {fa : funcaddr, fa'* : funcaddr*, func : func, func'* : func*, m : moduleinst, s : store, s_1 : store, s_2 : store} allocfuncs(s, m, [func] :: func'*{func'}) = (s_2, [fa] :: fa'*{fa'}) + -- if ((s_1, fa) = $allocfunc(s, m, func)) + -- if ((s_2, fa'*{fa'}) = $allocfuncs(s_1, m, func'*{func'})) +} + +;; 7-module.watsup:46.1-46.63 +def allocglobal : (store, globaltype, val) -> (store, globaladdr) + ;; 7-module.watsup:47.1-48.44 + def {gi : globalinst, globaltype : globaltype, s : store, val : val} allocglobal(s, globaltype, val) = (s[GLOBAL_store =.. [gi]], |s.GLOBAL_store|) + -- if (gi = {TYPE globaltype, VALUE val}) + +;; 7-module.watsup:50.1-50.67 +rec { + +;; 7-module.watsup:50.1-50.67 +def allocglobals : (store, globaltype*, val*) -> (store, globaladdr*) + ;; 7-module.watsup:51.1-51.54 + def {s : store} allocglobals(s, [], []) = (s, []) + ;; 7-module.watsup:52.1-54.62 + def {ga : globaladdr, ga'* : globaladdr*, globaltype : globaltype, globaltype'* : globaltype*, s : store, s_1 : store, s_2 : store, val : val, val'* : val*} allocglobals(s, [globaltype] :: globaltype'*{globaltype'}, [val] :: val'*{val'}) = (s_2, [ga] :: ga'*{ga'}) + -- if ((s_1, ga) = $allocglobal(s, globaltype, val)) + -- if ((s_2, ga'*{ga'}) = $allocglobals(s_1, globaltype'*{globaltype'}, val'*{val'})) +} + +;; 7-module.watsup:56.1-56.55 +def alloctable : (store, tabletype) -> (store, tableaddr) + ;; 7-module.watsup:57.1-58.59 + def {i : nat, j : nat, rt : reftype, s : store, ti : tableinst} alloctable(s, `%%`(`[%..%]`(i, j), rt)) = (s[TABLE_store =.. [ti]], |s.TABLE_store|) + -- if (ti = {TYPE `%%`(`[%..%]`(i, j), rt), ELEM REF.NULL_ref(rt)^i{}}) + +;; 7-module.watsup:60.1-60.58 +rec { + +;; 7-module.watsup:60.1-60.58 +def alloctables : (store, tabletype*) -> (store, tableaddr*) + ;; 7-module.watsup:61.1-61.44 + def {s : store} alloctables(s, []) = (s, []) + ;; 7-module.watsup:62.1-64.53 + def {s : store, s_1 : store, s_2 : store, ta : tableaddr, ta'* : tableaddr*, tabletype : tabletype, tabletype'* : tabletype*} alloctables(s, [tabletype] :: tabletype'*{tabletype'}) = (s_2, [ta] :: ta'*{ta'}) + -- if ((s_1, ta) = $alloctable(s, tabletype)) + -- if ((s_2, ta'*{ta'}) = $alloctables(s_1, tabletype'*{tabletype'})) +} + +;; 7-module.watsup:66.1-66.49 +def allocmem : (store, memtype) -> (store, memaddr) + ;; 7-module.watsup:67.1-68.62 + def {i : nat, j : nat, mi : meminst, s : store} allocmem(s, `%I8`(`[%..%]`(i, j))) = (s[MEM_store =.. [mi]], |s.MEM_store|) + -- if (mi = {TYPE `%I8`(`[%..%]`(i, j)), DATA 0^((i * 64) * $Ki){}}) + +;; 7-module.watsup:70.1-70.52 +rec { + +;; 7-module.watsup:70.1-70.52 +def allocmems : (store, memtype*) -> (store, memaddr*) + ;; 7-module.watsup:71.1-71.42 + def {s : store} allocmems(s, []) = (s, []) + ;; 7-module.watsup:72.1-74.49 + def {ma : memaddr, ma'* : memaddr*, memtype : memtype, memtype'* : memtype*, s : store, s_1 : store, s_2 : store} allocmems(s, [memtype] :: memtype'*{memtype'}) = (s_2, [ma] :: ma'*{ma'}) + -- if ((s_1, ma) = $allocmem(s, memtype)) + -- if ((s_2, ma'*{ma'}) = $allocmems(s_1, memtype'*{memtype'})) +} + +;; 7-module.watsup:76.1-76.57 +def allocelem : (store, reftype, ref*) -> (store, elemaddr) + ;; 7-module.watsup:77.1-78.36 + def {ei : eleminst, ref* : ref*, rt : reftype, s : store} allocelem(s, rt, ref*{ref}) = (s[ELEM_store =.. [ei]], |s.ELEM_store|) + -- if (ei = {TYPE rt, ELEM ref*{ref}}) + +;; 7-module.watsup:80.1-80.63 +rec { + +;; 7-module.watsup:80.1-80.63 +def allocelems : (store, reftype*, ref**) -> (store, elemaddr*) + ;; 7-module.watsup:81.1-81.52 + def {s : store} allocelems(s, [], []) = (s, []) + ;; 7-module.watsup:82.1-84.53 + def {ea : elemaddr, ea'* : elemaddr*, ref* : ref*, ref'** : ref**, rt : reftype, rt'* : reftype*, s : store, s_1 : store, s_2 : store} allocelems(s, [rt] :: rt'*{rt'}, [ref]*{ref} :: ref'*{ref'}*{ref'}) = (s_2, [ea] :: ea'*{ea'}) + -- if ((s_1, ea) = $allocelem(s, rt, ref*{ref})) + -- if ((s_2, ea'*{ea'}) = $allocelems(s_2, rt'*{rt'}, ref'*{ref'}*{ref'})) +} + +;; 7-module.watsup:86.1-86.49 +def allocdata : (store, byte*) -> (store, dataaddr) + ;; 7-module.watsup:87.1-88.28 + def {byte* : byte*, di : datainst, s : store} allocdata(s, byte*{byte}) = (s[DATA_store =.. [di]], |s.DATA_store|) + -- if (di = {DATA byte*{byte}}) + +;; 7-module.watsup:90.1-90.52 +rec { + +;; 7-module.watsup:90.1-90.52 +def allocdatas : (store, byte**) -> (store, dataaddr*) + ;; 7-module.watsup:91.1-91.43 + def {s : store} allocdatas(s, []) = (s, []) + ;; 7-module.watsup:92.1-94.48 + def {byte* : byte*, byte'** : byte**, da : dataaddr, da'* : dataaddr*, s : store, s_1 : store, s_2 : store} allocdatas(s, [byte]*{byte} :: byte'*{byte'}*{byte'}) = (s_2, [da] :: da'*{da'}) + -- if ((s_1, da) = $allocdata(s, byte*{byte})) + -- if ((s_2, da'*{da'}) = $allocdatas(s_1, byte'*{byte'}*{byte'})) +} + +;; 7-module.watsup:97.1-97.81 +def allocmodule : (store, module, externval*, val*, ref**) -> (store, moduleinst) + ;; 7-module.watsup:98.1-135.54 + def {byte*^n_data : byte*^n_data, da* : dataaddr*, datamode?^n_data : datamode?^n_data, ea* : elemaddr*, elemmode?^n_elem : elemmode?^n_elem, export* : export*, expr_1^n_global : expr^n_global, expr_2*^n_elem : expr*^n_elem, externval* : externval*, fa* : funcaddr*, fa_ex* : funcaddr*, func^n_func : func^n_func, ga* : globaladdr*, ga_ex* : globaladdr*, globaltype^n_global : globaltype^n_global, i_data^n_data : nat^n_data, i_elem^n_elem : nat^n_elem, i_func^n_func : nat^n_func, i_global^n_global : nat^n_global, i_mem^n_mem : nat^n_mem, i_table^n_table : nat^n_table, import* : import*, m : moduleinst, ma* : memaddr*, ma_ex* : memaddr*, memtype^n_mem : memtype^n_mem, module : module, n_data : n, n_elem : n, n_func : n, n_global : n, n_mem : n, n_table : n, ref** : ref**, rt^n_elem : reftype^n_elem, s : store, s_1 : store, s_2 : store, s_3 : store, s_4 : store, s_5 : store, s_6 : store, start? : start?, ta* : tableaddr*, ta_ex* : tableaddr*, tabletype^n_table : tabletype^n_table, val* : val*, xi* : exportinst*} allocmodule(s, module, externval*{externval}, val*{val}, ref*{ref}*{ref}) = (s_6, m) + -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func^n_func{func}, GLOBAL(globaltype, expr_1)^n_global{expr_1 globaltype}, TABLE(tabletype)^n_table{tabletype}, MEMORY(memtype)^n_mem{memtype}, `ELEM%%*%?`(rt, expr_2*{expr_2}, elemmode?{elemmode})^n_elem{elemmode expr_2 rt}, `DATA%*%?`(byte*{byte}, datamode?{datamode})^n_data{byte datamode}, start?{start}, export*{export})) + -- if (fa_ex*{fa_ex} = $funcs(externval*{externval})) + -- if (ga_ex*{ga_ex} = $globals(externval*{externval})) + -- if (ta_ex*{ta_ex} = $tables(externval*{externval})) + -- if (ma_ex*{ma_ex} = $mems(externval*{externval})) + -- if (fa*{fa} = (|s.FUNC_store| + i_func)^(i_func instr* + ;; 7-module.watsup:139.1-139.46 + def {expr* : expr*, i : nat, reftype : reftype} runelem(`ELEM%%*%?`(reftype, expr*{expr}, ?()), i) = [] + ;; 7-module.watsup:140.1-140.62 + def {expr* : expr*, i : nat, reftype : reftype} runelem(`ELEM%%*%?`(reftype, expr*{expr}, ?(DECLARE_elemmode)), i) = [ELEM.DROP_instr(i)] + ;; 7-module.watsup:141.1-143.20 + def {expr* : expr*, i : nat, instr* : instr*, n : n, reftype : reftype, x : idx} runelem(`ELEM%%*%?`(reftype, expr*{expr}, ?(TABLE_elemmode(x, instr*{instr}))), i) = instr*{instr} :: [CONST_instr(I32_numtype, 0) CONST_instr(I32_numtype, n) TABLE.INIT_instr(x, i) ELEM.DROP_instr(i)] + -- if (n = |expr*{expr}|) + +;; 7-module.watsup:145.1-145.33 +def rundata : (data, idx) -> instr* + ;; 7-module.watsup:146.1-146.38 + def {byte* : byte*, i : nat} rundata(`DATA%*%?`(byte*{byte}, ?()), i) = [] + ;; 7-module.watsup:147.1-149.20 + def {byte* : byte*, i : nat, instr* : instr*, n : n} rundata(`DATA%*%?`(byte*{byte}, ?(MEMORY_datamode(0, instr*{instr}))), i) = instr*{instr} :: [CONST_instr(I32_numtype, 0) CONST_instr(I32_numtype, n) MEMORY.INIT_instr(i) DATA.DROP_instr(i)] + -- if (n = |byte*{byte}|) + +;; 7-module.watsup:152.1-152.36 +rec { + +;; 7-module.watsup:152.1-152.36 +def concat_instr : instr** -> instr* + ;; 7-module.watsup:153.1-153.37 + def concat_instr([]) = [] + ;; 7-module.watsup:154.1-154.68 + def {instr* : instr*, instr'** : instr**} concat_instr([instr]*{instr} :: instr'*{instr'}*{instr'}) = instr*{instr} :: $concat_instr(instr'*{instr'}*{instr'}) +} + +;; 7-module.watsup:157.1-157.55 +def instantiation : (store, module, externval*) -> config + ;; 7-module.watsup:158.1-180.28 + def {data* : data*, elem* : elem*, elemmode?* : elemmode?*, export* : export*, externval* : externval*, f : frame, f_init : frame, func* : func*, global* : global*, globaltype* : globaltype*, i^n_elem : nat^n_elem, import* : import*, instr_1** : instr**, instr_2*** : instr***, instr_data* : instr*, instr_elem* : instr*, j^n_data : nat^n_data, m : moduleinst, m_init : moduleinst, mem* : mem*, module : module, n_data : n, n_elem : n, ref** : ref**, reftype* : reftype*, s : store, s' : store, start? : start?, table* : table*, val* : val*, x? : idx?} instantiation(s, module, externval*{externval}) = `%;%*`(`%;%`(s', f), (instr_elem <: admininstr)*{instr_elem} :: (instr_data <: admininstr)*{instr_data} :: CALL_admininstr(x)?{x}) + -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, start?{start}, export*{export})) + -- if (m_init = {FUNC $funcs(externval*{externval}), GLOBAL $globals(externval*{externval}), TABLE [], MEM [], ELEM [], DATA [], EXPORT []}) + -- if (f_init = {LOCAL [], MODULE m_init}) + -- if (global*{global} = GLOBAL(globaltype, instr_1*{instr_1})*{globaltype instr_1}) + -- (Step_read: `%~>%*`(`%;%*`(`%;%`(s, f_init), (instr_1 <: admininstr)*{instr_1}), [(val <: admininstr)]))*{instr_1 val} + -- if (elem*{elem} = `ELEM%%*%?`(reftype, instr_2*{instr_2}*{instr_2}, elemmode?{elemmode})*{elemmode instr_2 reftype}) + -- (Step_read: `%~>%*`(`%;%*`(`%;%`(s, f_init), (instr_2 <: admininstr)*{instr_2}), [(ref <: admininstr)]))*{instr_2 ref}*{instr_2 ref} + -- if ((s', m) = $allocmodule(s, module, externval*{externval}, val*{val}, ref*{ref}*{ref})) + -- if (f = {LOCAL [], MODULE m}) + -- if (n_elem = |elem*{elem}|) + -- if (instr_elem*{instr_elem} = $concat_instr($runelem(elem*{elem}[i], i)^(i config + ;; 7-module.watsup:184.1-196.52 + def {expr : expr, f : frame, fa : funcaddr, functype : functype, k : nat, m : moduleinst, n : n, s : store, val^n : val^n, valtype* : valtype*, valtype_param^n : valtype^n, valtype_res^k : valtype^k} invocation(s, fa, val^n{val}) = `%;%*`(`%;%`(s, f), (val <: admininstr)^n{val} :: [CALL_ADDR_admininstr(fa)]) + -- if (m = {FUNC [], GLOBAL [], TABLE [], MEM [], ELEM [], DATA [], EXPORT []}) + -- if (f = {LOCAL [], MODULE m}) + -- if ($funcinst(`%;%`(s, f))[fa].CODE_funcinst = `FUNC%%*%`(functype, valtype*{valtype}, expr)) + -- if (functype = `%->%`(valtype_param^n{valtype_param}, valtype_res^k{valtype_res})) + == IL Validation... == Latex Generation... $$ @@ -1820,7 +2107,7 @@ $$ \mbox{(table)} & \mathit{table} &::=& \mathsf{table}~\mathit{tabletype} \\ \mbox{(memory)} & \mathit{mem} &::=& \mathsf{memory}~\mathit{memtype} \\ \mbox{(table segment)} & \mathit{elem} &::=& \mathsf{elem}~\mathit{reftype}~{\mathit{expr}^\ast}~{\mathit{elemmode}^?} \\ -\mbox{(memory segment)} & \mathit{data} &::=& \mathsf{data}~{({\mathit{byte}^\ast})^\ast}~{\mathit{datamode}^?} \\ +\mbox{(memory segment)} & \mathit{data} &::=& \mathsf{data}~{\mathit{byte}^\ast}~{\mathit{datamode}^?} \\ \mbox{(start function)} & \mathit{start} &::=& \mathsf{start}~\mathit{funcidx} \\ \mbox{(external use)} & \mathit{externuse} &::=& \mathsf{func}~\mathit{funcidx} ~|~ \mathsf{global}~\mathit{globalidx} ~|~ \mathsf{table}~\mathit{tableidx} ~|~ \mathsf{mem}~\mathit{memidx} \\ \mbox{(export)} & \mathit{export} &::=& \mathsf{export}~\mathit{name}~\mathit{externuse} \\ @@ -2978,7 +3265,7 @@ $$ \frac{ (\mathit{C} \vdash \mathit{datamode} : \mathsf{ok})^? }{ -\mathit{C} \vdash \mathsf{data}~{({\mathit{b}^\ast})^\ast}~{\mathit{datamode}^?} : \mathsf{ok} +\mathit{C} \vdash \mathsf{data}~{\mathit{b}^\ast}~{\mathit{datamode}^?} : \mathsf{ok} } \, {[\textsc{\scriptsize T{-}data}]} \qquad \end{array} @@ -3244,6 +3531,36 @@ $$ \end{array} $$ +$$ +\begin{array}{@{}lcl@{}l@{}} +(\mathit{s} ; \mathit{f}).\mathsf{global} &=& \mathit{s}.\mathsf{global} & \\ +\end{array} +$$ + +$$ +\begin{array}{@{}lcl@{}l@{}} +(\mathit{s} ; \mathit{f}).\mathsf{table} &=& \mathit{s}.\mathsf{table} & \\ +\end{array} +$$ + +$$ +\begin{array}{@{}lcl@{}l@{}} +(\mathit{s} ; \mathit{f}).\mathsf{mem} &=& \mathit{s}.\mathsf{mem} & \\ +\end{array} +$$ + +$$ +\begin{array}{@{}lcl@{}l@{}} +(\mathit{s} ; \mathit{f}).\mathsf{elem} &=& \mathit{s}.\mathsf{elem} & \\ +\end{array} +$$ + +$$ +\begin{array}{@{}lcl@{}l@{}} +(\mathit{s} ; \mathit{f}).\mathsf{data} &=& \mathit{s}.\mathsf{data} & \\ +\end{array} +$$ + $$ \begin{array}{@{}lcl@{}l@{}} {(\mathit{s} ; \mathit{f}).\mathsf{func}}{[\mathit{x}]} &=& \mathit{s}.\mathsf{func}[\mathit{f}.\mathsf{module}.\mathsf{func}[\mathit{x}]] & \\ @@ -3786,6 +4103,276 @@ $$ \end{array} $$ +\vspace{1ex} + +$$ +\begin{array}{@{}lcl@{}l@{}} +\mathrm{funcs}(\epsilon) &=& \epsilon & \\ +\mathrm{funcs}((\mathsf{func}~\mathit{fa})~{{\mathit{externval}'}^\ast}) &=& \mathit{fa}~\mathrm{funcs}({{\mathit{externval}'}^\ast}) & \\ +\mathrm{funcs}(\mathit{externval}~{{\mathit{externval}'}^\ast}) &=& \mathrm{funcs}({{\mathit{externval}'}^\ast}) &\quad + \mbox{otherwise} \\ +\end{array} +$$ + +$$ +\begin{array}{@{}lcl@{}l@{}} +\mathrm{globals}(\epsilon) &=& \epsilon & \\ +\mathrm{globals}((\mathsf{global}~\mathit{ga})~{{\mathit{externval}'}^\ast}) &=& \mathit{ga}~\mathrm{globals}({{\mathit{externval}'}^\ast}) & \\ +\mathrm{globals}(\mathit{externval}~{{\mathit{externval}'}^\ast}) &=& \mathrm{globals}({{\mathit{externval}'}^\ast}) &\quad + \mbox{otherwise} \\ +\end{array} +$$ + +$$ +\begin{array}{@{}lcl@{}l@{}} +\mathrm{tables}(\epsilon) &=& \epsilon & \\ +\mathrm{tables}((\mathsf{table}~\mathit{ta})~{{\mathit{externval}'}^\ast}) &=& \mathit{ta}~\mathrm{tables}({{\mathit{externval}'}^\ast}) & \\ +\mathrm{tables}(\mathit{externval}~{{\mathit{externval}'}^\ast}) &=& \mathrm{tables}({{\mathit{externval}'}^\ast}) &\quad + \mbox{otherwise} \\ +\end{array} +$$ + +$$ +\begin{array}{@{}lcl@{}l@{}} +\mathrm{mems}(\epsilon) &=& \epsilon & \\ +\mathrm{mems}((\mathsf{mem}~\mathit{ma})~{{\mathit{externval}'}^\ast}) &=& \mathit{ma}~\mathrm{mems}({{\mathit{externval}'}^\ast}) & \\ +\mathrm{mems}(\mathit{externval}~{{\mathit{externval}'}^\ast}) &=& \mathrm{mems}({{\mathit{externval}'}^\ast}) &\quad + \mbox{otherwise} \\ +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}lcl@{}l@{}} +\mathrm{instexport}({\mathit{fa}^\ast},\, {\mathit{ga}^\ast},\, {\mathit{ta}^\ast},\, {\mathit{ma}^\ast},\, \mathsf{export}~\mathit{name}~(\mathsf{func}~\mathit{x})) &=& \{ \begin{array}[t]{@{}l@{}} +\mathsf{name}~\mathit{name},\; \mathsf{value}~(\mathsf{func}~{\mathit{fa}^\ast}[\mathit{x}]) \}\end{array} & \\ +\mathrm{instexport}({\mathit{fa}^\ast},\, {\mathit{ga}^\ast},\, {\mathit{ta}^\ast},\, {\mathit{ma}^\ast},\, \mathsf{export}~\mathit{name}~(\mathsf{global}~\mathit{x})) &=& \{ \begin{array}[t]{@{}l@{}} +\mathsf{name}~\mathit{name},\; \mathsf{value}~(\mathsf{global}~{\mathit{ga}^\ast}[\mathit{x}]) \}\end{array} & \\ +\mathrm{instexport}({\mathit{fa}^\ast},\, {\mathit{ga}^\ast},\, {\mathit{ta}^\ast},\, {\mathit{ma}^\ast},\, \mathsf{export}~\mathit{name}~(\mathsf{table}~\mathit{x})) &=& \{ \begin{array}[t]{@{}l@{}} +\mathsf{name}~\mathit{name},\; \mathsf{value}~(\mathsf{table}~{\mathit{ta}^\ast}[\mathit{x}]) \}\end{array} & \\ +\mathrm{instexport}({\mathit{fa}^\ast},\, {\mathit{ga}^\ast},\, {\mathit{ta}^\ast},\, {\mathit{ma}^\ast},\, \mathsf{export}~\mathit{name}~(\mathsf{mem}~\mathit{x})) &=& \{ \begin{array}[t]{@{}l@{}} +\mathsf{name}~\mathit{name},\; \mathsf{value}~(\mathsf{mem}~{\mathit{ma}^\ast}[\mathit{x}]) \}\end{array} & \\ +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}lcl@{}l@{}} +\mathrm{allocfunc}(\mathit{s},\, \mathit{m},\, \mathit{func}) &=& (\mathit{s}[\mathsf{func} = ..\mathit{fi}],\, {|\mathit{s}.\mathsf{func}|}) &\quad + \mbox{if}~\mathit{fi} = \{ \begin{array}[t]{@{}l@{}} +\mathsf{module}~\mathit{m},\; \mathsf{code}~\mathit{func} \}\end{array} \\ +\end{array} +$$ + +$$ +\begin{array}{@{}lcl@{}l@{}} +\mathrm{allocfuncs}(\mathit{s},\, \mathit{m},\, \epsilon) &=& (\mathit{s},\, \epsilon) & \\ +\mathrm{allocfuncs}(\mathit{s},\, \mathit{m},\, \mathit{func}~{{\mathit{func}'}^\ast}) &=& (\mathit{s}_{2},\, \mathit{fa}~{{\mathit{fa}'}^\ast}) &\quad + \mbox{if}~(\mathit{s}_{1},\, \mathit{fa}) = \mathrm{allocfunc}(\mathit{s},\, \mathit{m},\, \mathit{func}) \\ + &&&\quad {\land}~(\mathit{s}_{2},\, {{\mathit{fa}'}^\ast}) = \mathrm{allocfuncs}(\mathit{s}_{1},\, \mathit{m},\, {{\mathit{func}'}^\ast}) \\ +\end{array} +$$ + +$$ +\begin{array}{@{}lcl@{}l@{}} +\mathrm{allocglobal}(\mathit{s},\, \mathit{globaltype},\, \mathit{val}) &=& (\mathit{s}[\mathsf{global} = ..\mathit{gi}],\, {|\mathit{s}.\mathsf{global}|}) &\quad + \mbox{if}~\mathit{gi} = \{ \begin{array}[t]{@{}l@{}} +\mathsf{type}~\mathit{globaltype},\; \mathsf{value}~\mathit{val} \}\end{array} \\ +\end{array} +$$ + +$$ +\begin{array}{@{}lcl@{}l@{}} +\mathrm{allocglobals}(\mathit{s},\, \epsilon,\, \epsilon) &=& (\mathit{s},\, \epsilon) & \\ +\mathrm{allocglobals}(\mathit{s},\, \mathit{globaltype}~{{\mathit{globaltype}'}^\ast},\, \mathit{val}~{{\mathit{val}'}^\ast}) &=& (\mathit{s}_{2},\, \mathit{ga}~{{\mathit{ga}'}^\ast}) &\quad + \mbox{if}~(\mathit{s}_{1},\, \mathit{ga}) = \mathrm{allocglobal}(\mathit{s},\, \mathit{globaltype},\, \mathit{val}) \\ + &&&\quad {\land}~(\mathit{s}_{2},\, {{\mathit{ga}'}^\ast}) = \mathrm{allocglobals}(\mathit{s}_{1},\, {{\mathit{globaltype}'}^\ast},\, {{\mathit{val}'}^\ast}) \\ +\end{array} +$$ + +$$ +\begin{array}{@{}lcl@{}l@{}} +\mathrm{alloctable}(\mathit{s},\, [\mathit{i} .. \mathit{j}]~\mathit{rt}) &=& (\mathit{s}[\mathsf{table} = ..\mathit{ti}],\, {|\mathit{s}.\mathsf{table}|}) &\quad + \mbox{if}~\mathit{ti} = \{ \begin{array}[t]{@{}l@{}} +\mathsf{type}~([\mathit{i} .. \mathit{j}]~\mathit{rt}),\; \mathsf{elem}~{(\mathsf{ref.null}~\mathit{rt})^{\mathit{i}}} \}\end{array} \\ +\end{array} +$$ + +$$ +\begin{array}{@{}lcl@{}l@{}} +\mathrm{alloctables}(\mathit{s},\, \epsilon) &=& (\mathit{s},\, \epsilon) & \\ +\mathrm{alloctables}(\mathit{s},\, \mathit{tabletype}~{{\mathit{tabletype}'}^\ast}) &=& (\mathit{s}_{2},\, \mathit{ta}~{{\mathit{ta}'}^\ast}) &\quad + \mbox{if}~(\mathit{s}_{1},\, \mathit{ta}) = \mathrm{alloctable}(\mathit{s},\, \mathit{tabletype}) \\ + &&&\quad {\land}~(\mathit{s}_{2},\, {{\mathit{ta}'}^\ast}) = \mathrm{alloctables}(\mathit{s}_{1},\, {{\mathit{tabletype}'}^\ast}) \\ +\end{array} +$$ + +$$ +\begin{array}{@{}lcl@{}l@{}} +\mathrm{allocmem}(\mathit{s},\, [\mathit{i} .. \mathit{j}]~\mathsf{i{\scriptstyle8}}) &=& (\mathit{s}[\mathsf{mem} = ..\mathit{mi}],\, {|\mathit{s}.\mathsf{mem}|}) &\quad + \mbox{if}~\mathit{mi} = \{ \begin{array}[t]{@{}l@{}} +\mathsf{type}~([\mathit{i} .. \mathit{j}]~\mathsf{i{\scriptstyle8}}),\; \mathsf{data}~{0^{\mathit{i} \cdot 64 \cdot \mathrm{Ki}}} \}\end{array} \\ +\end{array} +$$ + +$$ +\begin{array}{@{}lcl@{}l@{}} +\mathrm{allocmems}(\mathit{s},\, \epsilon) &=& (\mathit{s},\, \epsilon) & \\ +\mathrm{allocmems}(\mathit{s},\, \mathit{memtype}~{{\mathit{memtype}'}^\ast}) &=& (\mathit{s}_{2},\, \mathit{ma}~{{\mathit{ma}'}^\ast}) &\quad + \mbox{if}~(\mathit{s}_{1},\, \mathit{ma}) = \mathrm{allocmem}(\mathit{s},\, \mathit{memtype}) \\ + &&&\quad {\land}~(\mathit{s}_{2},\, {{\mathit{ma}'}^\ast}) = \mathrm{allocmems}(\mathit{s}_{1},\, {{\mathit{memtype}'}^\ast}) \\ +\end{array} +$$ + +$$ +\begin{array}{@{}lcl@{}l@{}} +\mathrm{allocelem}(\mathit{s},\, \mathit{rt},\, {\mathit{ref}^\ast}) &=& (\mathit{s}[\mathsf{elem} = ..\mathit{ei}],\, {|\mathit{s}.\mathsf{elem}|}) &\quad + \mbox{if}~\mathit{ei} = \{ \begin{array}[t]{@{}l@{}} +\mathsf{type}~\mathit{rt},\; \mathsf{elem}~{\mathit{ref}^\ast} \}\end{array} \\ +\end{array} +$$ + +$$ +\begin{array}{@{}lcl@{}l@{}} +\mathrm{allocelems}(\mathit{s},\, \epsilon,\, \epsilon) &=& (\mathit{s},\, \epsilon) & \\ +\mathrm{allocelems}(\mathit{s},\, \mathit{rt}~{{\mathit{rt}'}^\ast},\, {\mathit{ref}^\ast}~{{{\mathit{ref}'}^\ast}^\ast}) &=& (\mathit{s}_{2},\, \mathit{ea}~{{\mathit{ea}'}^\ast}) &\quad + \mbox{if}~(\mathit{s}_{1},\, \mathit{ea}) = \mathrm{allocelem}(\mathit{s},\, \mathit{rt},\, {\mathit{ref}^\ast}) \\ + &&&\quad {\land}~(\mathit{s}_{2},\, {{\mathit{ea}'}^\ast}) = \mathrm{allocelems}(\mathit{s}_{2},\, {{\mathit{rt}'}^\ast},\, {{{\mathit{ref}'}^\ast}^\ast}) \\ +\end{array} +$$ + +$$ +\begin{array}{@{}lcl@{}l@{}} +\mathrm{allocdata}(\mathit{s},\, {\mathit{byte}^\ast}) &=& (\mathit{s}[\mathsf{data} = ..\mathit{di}],\, {|\mathit{s}.\mathsf{data}|}) &\quad + \mbox{if}~\mathit{di} = \{ \begin{array}[t]{@{}l@{}} +\mathsf{data}~{\mathit{byte}^\ast} \}\end{array} \\ +\end{array} +$$ + +$$ +\begin{array}{@{}lcl@{}l@{}} +\mathrm{allocdatas}(\mathit{s},\, \epsilon) &=& (\mathit{s},\, \epsilon) & \\ +\mathrm{allocdatas}(\mathit{s},\, {\mathit{byte}^\ast}~{{{\mathit{byte}'}^\ast}^\ast}) &=& (\mathit{s}_{2},\, \mathit{da}~{{\mathit{da}'}^\ast}) &\quad + \mbox{if}~(\mathit{s}_{1},\, \mathit{da}) = \mathrm{allocdata}(\mathit{s},\, {\mathit{byte}^\ast}) \\ + &&&\quad {\land}~(\mathit{s}_{2},\, {{\mathit{da}'}^\ast}) = \mathrm{allocdatas}(\mathit{s}_{1},\, {{{\mathit{byte}'}^\ast}^\ast}) \\ +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}lcl@{}l@{}} +\mathrm{allocmodule}(\mathit{s},\, \mathit{module},\, {\mathit{externval}^\ast},\, {\mathit{val}^\ast},\, {({\mathit{ref}^\ast})^\ast}) &=& (\mathit{s}_{6},\, \mathit{m}) &\quad + \mbox{if}~\mathit{module} = \mathsf{module}~{\mathit{import}^\ast}~{\mathit{func}^{\mathit{n}_{\mathit{func}}}}~{(\mathsf{global}~\mathit{globaltype}~\mathit{expr}_{1})^{\mathit{n}_{\mathit{global}}}}~{(\mathsf{table}~\mathit{tabletype})^{\mathit{n}_{\mathit{table}}}}~{(\mathsf{memory}~\mathit{memtype})^{\mathit{n}_{\mathit{mem}}}}~{(\mathsf{elem}~\mathit{rt}~{\mathit{expr}_{2}^\ast}~{\mathit{elemmode}^?})^{\mathit{n}_{\mathit{elem}}}}~{(\mathsf{data}~{\mathit{byte}^\ast}~{\mathit{datamode}^?})^{\mathit{n}_{\mathit{data}}}}~{\mathit{start}^?}~{\mathit{export}^\ast} \\ + &&&\quad {\land}~{\mathit{fa}_{\mathit{ex}}^\ast} = \mathrm{funcs}({\mathit{externval}^\ast}) \\ + &&&\quad {\land}~{\mathit{ga}_{\mathit{ex}}^\ast} = \mathrm{globals}({\mathit{externval}^\ast}) \\ + &&&\quad {\land}~{\mathit{ta}_{\mathit{ex}}^\ast} = \mathrm{tables}({\mathit{externval}^\ast}) \\ + &&&\quad {\land}~{\mathit{ma}_{\mathit{ex}}^\ast} = \mathrm{mems}({\mathit{externval}^\ast}) \\ + &&&\quad {\land}~{\mathit{fa}^\ast} = {{|\mathit{s}.\mathsf{func}|} + \mathit{i}_{\mathit{func}}^(i_func<\mathit{n}_{\mathit{func}})} \\ + &&&\quad {\land}~{\mathit{ga}^\ast} = {{|\mathit{s}.\mathsf{global}|} + \mathit{i}_{\mathit{global}}^(i_global<\mathit{n}_{\mathit{global}})} \\ + &&&\quad {\land}~{\mathit{ta}^\ast} = {{|\mathit{s}.\mathsf{table}|} + \mathit{i}_{\mathit{table}}^(i_table<\mathit{n}_{\mathit{table}})} \\ + &&&\quad {\land}~{\mathit{ma}^\ast} = {{|\mathit{s}.\mathsf{mem}|} + \mathit{i}_{\mathit{mem}}^(i_mem<\mathit{n}_{\mathit{mem}})} \\ + &&&\quad {\land}~{\mathit{ea}^\ast} = {{|\mathit{s}.\mathsf{elem}|} + \mathit{i}_{\mathit{elem}}^(i_elem<\mathit{n}_{\mathit{elem}})} \\ + &&&\quad {\land}~{\mathit{da}^\ast} = {{|\mathit{s}.\mathsf{data}|} + \mathit{i}_{\mathit{data}}^(i_data<\mathit{n}_{\mathit{data}})} \\ + &&&\quad {\land}~{\mathit{xi}^\ast} = {\mathrm{instexport}({\mathit{fa}_{\mathit{ex}}^\ast}~{\mathit{fa}^\ast},\, {\mathit{ga}_{\mathit{ex}}^\ast}~{\mathit{ga}^\ast},\, {\mathit{ta}_{\mathit{ex}}^\ast}~{\mathit{ta}^\ast},\, {\mathit{ma}_{\mathit{ex}}^\ast}~{\mathit{ma}^\ast},\, \mathit{export})^\ast} \\ + &&&\quad {\land}~\mathit{m} = \{ \begin{array}[t]{@{}l@{}} +\mathsf{func}~{\mathit{fa}_{\mathit{ex}}^\ast}~{\mathit{fa}^\ast},\; \\ + \mathsf{global}~{\mathit{ga}_{\mathit{ex}}^\ast}~{\mathit{ga}^\ast},\; \\ + \mathsf{table}~{\mathit{ta}_{\mathit{ex}}^\ast}~{\mathit{ta}^\ast},\; \\ + \mathsf{mem}~{\mathit{ma}_{\mathit{ex}}^\ast}~{\mathit{ma}^\ast},\; \\ + \mathsf{elem}~{\mathit{ea}^\ast},\; \\ + \mathsf{data}~{\mathit{da}^\ast},\; \\ + \mathsf{export}~{\mathit{xi}^\ast} \}\end{array} \\ + &&&\quad {\land}~(\mathit{s}_{1},\, {\mathit{fa}^\ast}) = \mathrm{allocfuncs}(\mathit{s},\, \mathit{m},\, {\mathit{func}^{\mathit{n}_{\mathit{func}}}}) \\ + &&&\quad {\land}~(\mathit{s}_{2},\, {\mathit{ga}^\ast}) = \mathrm{allocglobals}(\mathit{s}_{1},\, {\mathit{globaltype}^{\mathit{n}_{\mathit{global}}}},\, {\mathit{val}^\ast}) \\ + &&&\quad {\land}~(\mathit{s}_{3},\, {\mathit{ta}^\ast}) = \mathrm{alloctables}(\mathit{s}_{2},\, {\mathit{tabletype}^{\mathit{n}_{\mathit{table}}}}) \\ + &&&\quad {\land}~(\mathit{s}_{4},\, {\mathit{ma}^\ast}) = \mathrm{allocmems}(\mathit{s}_{3},\, {\mathit{memtype}^{\mathit{n}_{\mathit{mem}}}}) \\ + &&&\quad {\land}~(\mathit{s}_{5},\, {\mathit{ea}^\ast}) = \mathrm{allocelems}(\mathit{s}_{4},\, {\mathit{rt}^{\mathit{n}_{\mathit{elem}}}},\, {({\mathit{ref}^\ast})^\ast}) \\ + &&&\quad {\land}~(\mathit{s}_{6},\, {\mathit{da}^\ast}) = \mathrm{allocdatas}(\mathit{s}_{5},\, {({\mathit{byte}^\ast})^{\mathit{n}_{\mathit{data}}}}) \\ +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}lcl@{}l@{}} +\mathrm{runelem}(\mathsf{elem}~\mathit{reftype}~{\mathit{expr}^\ast},\, \mathit{i}) &=& \epsilon & \\ +\mathrm{runelem}(\mathsf{elem}~\mathit{reftype}~{\mathit{expr}^\ast}~(\mathsf{declare}),\, \mathit{i}) &=& (\mathsf{elem.drop}~\mathit{i}) & \\ +\mathrm{runelem}(\mathsf{elem}~\mathit{reftype}~{\mathit{expr}^\ast}~(\mathsf{table}~\mathit{x}~{\mathit{instr}^\ast}),\, \mathit{i}) &=& {\mathit{instr}^\ast}~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~0)~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{table.init}~\mathit{x}~\mathit{i})~(\mathsf{elem.drop}~\mathit{i}) &\quad + \mbox{if}~\mathit{n} = {|{\mathit{expr}^\ast}|} \\ +\end{array} +$$ + +$$ +\begin{array}{@{}lcl@{}l@{}} +\mathrm{rundata}(\mathsf{data}~{\mathit{byte}^\ast},\, \mathit{i}) &=& \epsilon & \\ +\mathrm{rundata}(\mathsf{data}~{\mathit{byte}^\ast}~(\mathsf{memory}~0~{\mathit{instr}^\ast}),\, \mathit{i}) &=& {\mathit{instr}^\ast}~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~0)~(\mathsf{i{\scriptstyle32}}.\mathsf{const}~\mathit{n})~(\mathsf{memory.init}~\mathit{i})~(\mathsf{data.drop}~\mathit{i}) &\quad + \mbox{if}~\mathit{n} = {|{\mathit{byte}^\ast}|} \\ +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}lcl@{}l@{}} +\mathrm{concat}_{\mathit{instr}}(\epsilon) &=& \epsilon & \\ +\mathrm{concat}_{\mathit{instr}}({\mathit{instr}^\ast}~{{{\mathit{instr}'}^\ast}^\ast}) &=& {\mathit{instr}^\ast}~\mathrm{concat}_{\mathit{instr}}({{{\mathit{instr}'}^\ast}^\ast}) & \\ +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}lcl@{}l@{}} +\mathrm{instantiation}(\mathit{s},\, \mathit{module},\, {\mathit{externval}^\ast}) &=& {\mathit{s}'} ; \mathit{f} ; {\mathit{instr}_{\mathit{elem}}^\ast}~{\mathit{instr}_{\mathit{data}}^\ast}~{(\mathsf{call}~\mathit{x})^?} &\quad + \mbox{if}~\mathit{module} = \mathsf{module}~{\mathit{import}^\ast}~{\mathit{func}^\ast}~{\mathit{global}^\ast}~{\mathit{table}^\ast}~{\mathit{mem}^\ast}~{\mathit{elem}^\ast}~{\mathit{data}^\ast}~{\mathit{start}^?}~{\mathit{export}^\ast} \\ + &&&\quad {\land}~\mathit{m}_{\mathit{init}} = \{ \begin{array}[t]{@{}l@{}} +\mathsf{func}~\mathrm{funcs}({\mathit{externval}^\ast}),\; \\ + \mathsf{global}~\mathrm{globals}({\mathit{externval}^\ast}),\; \\ + \mathsf{table}~\epsilon,\; \\ + \mathsf{mem}~\epsilon,\; \\ + \mathsf{elem}~\epsilon,\; \\ + \mathsf{data}~\epsilon,\; \\ + \mathsf{export}~\epsilon \}\end{array} \\ + &&&\quad {\land}~\mathit{f}_{\mathit{init}} = \{ \begin{array}[t]{@{}l@{}} +\mathsf{local}~\epsilon,\; \mathsf{module}~\mathit{m}_{\mathit{init}} \}\end{array} \\ + &&&\quad {\land}~{\mathit{global}^\ast} = {(\mathsf{global}~\mathit{globaltype}~{\mathit{instr}_{1}^\ast})^\ast} \\ + &&&\quad {\land}~(\mathit{s} ; \mathit{f}_{\mathit{init}} ; {\mathit{instr}_{1}^\ast} \hookrightarrow \mathit{val})^\ast \\ + &&&\quad {\land}~{\mathit{elem}^\ast} = {(\mathsf{elem}~\mathit{reftype}~{({\mathit{instr}_{2}^\ast})^\ast}~{\mathit{elemmode}^?})^\ast} \\ + &&&\quad {\land}~{(\mathit{s} ; \mathit{f}_{\mathit{init}} ; {\mathit{instr}_{2}^\ast} \hookrightarrow \mathit{ref})^\ast}^\ast \\ + &&&\quad {\land}~({\mathit{s}'},\, \mathit{m}) = \mathrm{allocmodule}(\mathit{s},\, \mathit{module},\, {\mathit{externval}^\ast},\, {\mathit{val}^\ast},\, {({\mathit{ref}^\ast})^\ast}) \\ + &&&\quad {\land}~\mathit{f} = \{ \begin{array}[t]{@{}l@{}} +\mathsf{local}~\epsilon,\; \mathsf{module}~\mathit{m} \}\end{array} \\ + &&&\quad {\land}~\mathit{n}_{\mathit{elem}} = {|{\mathit{elem}^\ast}|} \\ + &&&\quad {\land}~{\mathit{instr}_{\mathit{elem}}^\ast} = \mathrm{concat}_{\mathit{instr}}({\mathrm{runelem}({\mathit{elem}^\ast}[\mathit{i}],\, \mathit{i})^(i<\mathit{n}_{\mathit{elem}})}) \\ + &&&\quad {\land}~\mathit{n}_{\mathit{data}} = {|{\mathit{data}^\ast}|} \\ + &&&\quad {\land}~{\mathit{instr}_{\mathit{data}}^\ast} = \mathrm{concat}_{\mathit{instr}}({\mathrm{rundata}({\mathit{data}^\ast}[\mathit{j}],\, \mathit{j})^(j<\mathit{n}_{\mathit{data}})}) \\ + &&&\quad {\land}~{\mathit{start}^?} = {(\mathsf{start}~\mathit{x})^?} \\ +\end{array} +$$ + +\vspace{1ex} + +$$ +\begin{array}{@{}lcl@{}l@{}} +\mathrm{invocation}(\mathit{s},\, \mathit{fa},\, {\mathit{val}^{\mathit{n}}}) &=& \mathit{s} ; \mathit{f} ; {\mathit{val}^{\mathit{n}}}~(\mathsf{call}~\mathit{fa}) &\quad + \mbox{if}~\mathit{m} = \{ \begin{array}[t]{@{}l@{}} +\mathsf{func}~\epsilon,\; \\ + \mathsf{global}~\epsilon,\; \\ + \mathsf{table}~\epsilon,\; \\ + \mathsf{mem}~\epsilon,\; \\ + \mathsf{elem}~\epsilon,\; \\ + \mathsf{data}~\epsilon,\; \\ + \mathsf{export}~\epsilon \}\end{array} \\ + &&&\quad {\land}~\mathit{f} = \{ \begin{array}[t]{@{}l@{}} +\mathsf{local}~\epsilon,\; \mathsf{module}~\mathit{m} \}\end{array} \\ + &&&\quad {\land}~(\mathit{s} ; \mathit{f}).\mathsf{func}[\mathit{fa}].\mathsf{code} = \mathsf{func}~\mathit{functype}~{\mathit{valtype}^\ast}~\mathit{expr} \\ + &&&\quad {\land}~\mathit{functype} = {\mathit{valtype}_{\mathit{param}}^{\mathit{n}}} \rightarrow {\mathit{valtype}_{\mathit{res}}^{\mathit{k}}} \\ +\end{array} +$$ + == Complete. ``` diff --git a/spectec/test-latex/TEST.md b/spectec/test-latex/TEST.md index 14c2a410b7..590adcd858 100644 --- a/spectec/test-latex/TEST.md +++ b/spectec/test-latex/TEST.md @@ -250,19 +250,47 @@ warning: rule `Tabletype_sub` was never spliced warning: rule `Valtype_sub/refl` was never spliced warning: rule `Valtype_sub/bot` was never spliced warning: definition `Ki` was never spliced +warning: definition `allocdata` was never spliced +warning: definition `allocdatas` was never spliced +warning: definition `allocelem` was never spliced +warning: definition `allocelems` was never spliced +warning: definition `allocfunc` was never spliced +warning: definition `allocfuncs` was never spliced +warning: definition `allocglobal` was never spliced +warning: definition `allocglobals` was never spliced +warning: definition `allocmem` was never spliced +warning: definition `allocmems` was never spliced +warning: definition `allocmodule` was never spliced +warning: definition `alloctable` was never spliced +warning: definition `alloctables` was never spliced warning: definition `binop` was never spliced warning: definition `bytes_` was never spliced +warning: definition `concat_instr` was never spliced warning: definition `cvtop` was never spliced warning: definition `data` was never spliced +warning: definition `datainst` was never spliced warning: definition `elem` was never spliced +warning: definition `eleminst` was never spliced warning: definition `ext` was never spliced +warning: definition `funcs` was never spliced warning: definition `global` was never spliced +warning: definition `globalinst` was never spliced +warning: definition `globals` was never spliced warning: definition `grow_memory` was never spliced warning: definition `grow_table` was never spliced +warning: definition `instantiation` was never spliced +warning: definition `instexport` was never spliced +warning: definition `invocation` was never spliced warning: definition `local` was never spliced warning: definition `mem` was never spliced +warning: definition `meminst` was never spliced +warning: definition `mems` was never spliced warning: definition `min` was never spliced warning: definition `relop` was never spliced +warning: definition `rundata` was never spliced +warning: definition `runelem` was never spliced +warning: definition `tableinst` was never spliced +warning: definition `tables` was never spliced warning: definition `testop` was never spliced warning: definition `unop` was never spliced warning: definition `with_data` was never spliced diff --git a/spectec/test-middlend/TEST.md b/spectec/test-middlend/TEST.md index 4d5de8aa52..d1f5f95297 100644 --- a/spectec/test-middlend/TEST.md +++ b/spectec/test-middlend/TEST.md @@ -296,8 +296,8 @@ syntax mem = MEMORY(memtype) ;; 1-syntax.watsup:198.1-199.31 syntax elem = `ELEM%%*%?`(reftype, expr*, elemmode?) -;; 1-syntax.watsup:200.1-201.26 -syntax data = `DATA(*)%*%?`(byte**, datamode?) +;; 1-syntax.watsup:200.1-201.23 +syntax data = `DATA%*%?`(byte*, datamode?) ;; 1-syntax.watsup:202.1-203.16 syntax start = START(funcidx) @@ -885,8 +885,8 @@ relation Datamode_ok: `%|-%:OK`(context, datamode) ;; 3-typing.watsup:402.1-402.73 relation Data_ok: `%|-%:OK`(context, data) ;; 3-typing.watsup:433.1-435.40 - rule _ {C : context, b** : byte**, datamode? : datamode?}: - `%|-%:OK`(C, `DATA(*)%*%?`(b*{b}*{b}, datamode?{datamode})) + rule _ {C : context, b* : byte*, datamode? : datamode?}: + `%|-%:OK`(C, `DATA%*%?`(b*{b}, datamode?{datamode})) -- (Datamode_ok: `%|-%:OK`(C, datamode))?{datamode} ;; 3-typing.watsup:405.1-405.74 @@ -1051,10 +1051,10 @@ syntax frame = {LOCAL val*, MODULE moduleinst} ;; 4-runtime.watsup:96.1-96.47 syntax state = `%;%`(store, frame) -;; 4-runtime.watsup:172.1-179.5 +;; 4-runtime.watsup:183.1-190.5 rec { -;; 4-runtime.watsup:172.1-179.5 +;; 4-runtime.watsup:183.1-190.5 syntax admininstr = | UNREACHABLE | NOP @@ -1118,106 +1118,131 @@ def funcaddr : state -> funcaddr* ;; 4-runtime.watsup:118.1-118.52 def funcinst : state -> funcinst* - ;; 4-runtime.watsup:119.1-119.31 + ;; 4-runtime.watsup:125.1-125.31 def {f : frame, s : store} funcinst(`%;%`(s, f)) = s.FUNC_store -;; 4-runtime.watsup:121.1-121.67 +;; 4-runtime.watsup:119.1-119.58 +def globalinst : state -> globalinst* + ;; 4-runtime.watsup:126.1-126.35 + def {f : frame, s : store} globalinst(`%;%`(s, f)) = s.GLOBAL_store + +;; 4-runtime.watsup:120.1-120.55 +def tableinst : state -> tableinst* + ;; 4-runtime.watsup:127.1-127.33 + def {f : frame, s : store} tableinst(`%;%`(s, f)) = s.TABLE_store + +;; 4-runtime.watsup:121.1-121.49 +def meminst : state -> meminst* + ;; 4-runtime.watsup:128.1-128.29 + def {f : frame, s : store} meminst(`%;%`(s, f)) = s.MEM_store + +;; 4-runtime.watsup:122.1-122.52 +def eleminst : state -> eleminst* + ;; 4-runtime.watsup:129.1-129.31 + def {f : frame, s : store} eleminst(`%;%`(s, f)) = s.ELEM_store + +;; 4-runtime.watsup:123.1-123.52 +def datainst : state -> datainst* + ;; 4-runtime.watsup:130.1-130.31 + def {f : frame, s : store} datainst(`%;%`(s, f)) = s.DATA_store + +;; 4-runtime.watsup:132.1-132.67 def func : (state, funcidx) -> funcinst - ;; 4-runtime.watsup:129.1-129.48 + ;; 4-runtime.watsup:140.1-140.48 def {f : frame, s : store, x : idx} func(`%;%`(s, f), x) = s.FUNC_store[f.MODULE_frame.FUNC_moduleinst[x]] -;; 4-runtime.watsup:122.1-122.69 +;; 4-runtime.watsup:133.1-133.69 def global : (state, globalidx) -> globalinst - ;; 4-runtime.watsup:130.1-130.54 + ;; 4-runtime.watsup:141.1-141.54 def {f : frame, s : store, x : idx} global(`%;%`(s, f), x) = s.GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]] -;; 4-runtime.watsup:123.1-123.68 +;; 4-runtime.watsup:134.1-134.68 def table : (state, tableidx) -> tableinst - ;; 4-runtime.watsup:131.1-131.51 + ;; 4-runtime.watsup:142.1-142.51 def {f : frame, s : store, x : idx} table(`%;%`(s, f), x) = s.TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]] -;; 4-runtime.watsup:124.1-124.66 +;; 4-runtime.watsup:135.1-135.66 def mem : (state, memidx) -> meminst - ;; 4-runtime.watsup:132.1-132.45 + ;; 4-runtime.watsup:143.1-143.45 def {f : frame, s : store, x : idx} mem(`%;%`(s, f), x) = s.MEM_store[f.MODULE_frame.MEM_moduleinst[x]] -;; 4-runtime.watsup:125.1-125.67 +;; 4-runtime.watsup:136.1-136.67 def elem : (state, tableidx) -> eleminst - ;; 4-runtime.watsup:133.1-133.48 + ;; 4-runtime.watsup:144.1-144.48 def {f : frame, s : store, x : idx} elem(`%;%`(s, f), x) = s.ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]] -;; 4-runtime.watsup:126.1-126.67 +;; 4-runtime.watsup:137.1-137.67 def data : (state, dataidx) -> datainst - ;; 4-runtime.watsup:134.1-134.48 + ;; 4-runtime.watsup:145.1-145.48 def {f : frame, s : store, x : idx} data(`%;%`(s, f), x) = s.DATA_store[f.MODULE_frame.DATA_moduleinst[x]] -;; 4-runtime.watsup:127.1-127.68 +;; 4-runtime.watsup:138.1-138.68 def local : (state, localidx) -> val - ;; 4-runtime.watsup:135.1-135.35 + ;; 4-runtime.watsup:146.1-146.35 def {f : frame, s : store, x : idx} local(`%;%`(s, f), x) = f.LOCAL_frame[x] -;; 4-runtime.watsup:138.1-138.78 +;; 4-runtime.watsup:149.1-149.78 def with_local : (state, localidx, val) -> state - ;; 4-runtime.watsup:147.1-147.52 + ;; 4-runtime.watsup:158.1-158.52 def {f : frame, s : store, v : val, x : idx} with_local(`%;%`(s, f), x, v) = `%;%`(s, f[LOCAL_frame[x] = v]) -;; 4-runtime.watsup:139.1-139.85 +;; 4-runtime.watsup:150.1-150.85 def with_global : (state, globalidx, val) -> state - ;; 4-runtime.watsup:148.1-148.77 + ;; 4-runtime.watsup:159.1-159.77 def {f : frame, s : store, v : val, x : idx} with_global(`%;%`(s, f), x, v) = `%;%`(s[GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]].VALUE_globalinst = v], f) -;; 4-runtime.watsup:140.1-140.88 +;; 4-runtime.watsup:151.1-151.88 def with_table : (state, tableidx, nat, ref) -> state - ;; 4-runtime.watsup:149.1-149.79 + ;; 4-runtime.watsup:160.1-160.79 def {f : frame, i : nat, r : ref, s : store, x : idx} with_table(`%;%`(s, f), x, i, r) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]].ELEM_tableinst[i] = r], f) -;; 4-runtime.watsup:141.1-141.84 +;; 4-runtime.watsup:152.1-152.84 def with_tableinst : (state, tableidx, tableinst) -> state - ;; 4-runtime.watsup:150.1-150.74 + ;; 4-runtime.watsup:161.1-161.74 def {f : frame, s : store, ti : tableinst, x : idx} with_tableinst(`%;%`(s, f), x, ti) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]] = ti], f) -;; 4-runtime.watsup:142.1-142.93 +;; 4-runtime.watsup:153.1-153.93 def with_mem : (state, memidx, nat, nat, byte*) -> state - ;; 4-runtime.watsup:151.1-151.82 + ;; 4-runtime.watsup:162.1-162.82 def {b* : byte*, f : frame, i : nat, j : nat, s : store, x : idx} with_mem(`%;%`(s, f), x, i, j, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]].DATA_meminst[i : j] = b*{b}], f) -;; 4-runtime.watsup:143.1-143.77 +;; 4-runtime.watsup:154.1-154.77 def with_meminst : (state, memidx, meminst) -> state - ;; 4-runtime.watsup:152.1-152.68 + ;; 4-runtime.watsup:163.1-163.68 def {f : frame, mi : meminst, s : store, x : idx} with_meminst(`%;%`(s, f), x, mi) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]] = mi], f) -;; 4-runtime.watsup:144.1-144.82 +;; 4-runtime.watsup:155.1-155.82 def with_elem : (state, elemidx, ref*) -> state - ;; 4-runtime.watsup:153.1-153.72 + ;; 4-runtime.watsup:164.1-164.72 def {f : frame, r* : ref*, s : store, x : idx} with_elem(`%;%`(s, f), x, r*{r}) = `%;%`(s[ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]].ELEM_eleminst = r*{r}], f) -;; 4-runtime.watsup:145.1-145.82 +;; 4-runtime.watsup:156.1-156.82 def with_data : (state, dataidx, byte*) -> state - ;; 4-runtime.watsup:154.1-154.72 + ;; 4-runtime.watsup:165.1-165.72 def {b* : byte*, f : frame, s : store, x : idx} with_data(`%;%`(s, f), x, b*{b}) = `%;%`(s[DATA_store[f.MODULE_frame.DATA_moduleinst[x]].DATA_datainst = b*{b}], f) -;; 4-runtime.watsup:156.1-156.63 +;; 4-runtime.watsup:167.1-167.63 def grow_table : (tableinst, nat, ref) -> tableinst - ;; 4-runtime.watsup:159.1-163.36 + ;; 4-runtime.watsup:170.1-174.36 def {i : nat, i' : nat, j : nat, n : n, r : ref, r'* : ref*, rt : reftype, ti : tableinst, ti' : tableinst} grow_table(ti, n, r) = ti' -- if (ti = {TYPE `%%`(`[%..%]`(i, j), rt), ELEM r'*{r'}}) -- if (i' = (|r'*{r'}| + n)) -- if (ti' = {TYPE `%%`(`[%..%]`(i', j), rt), ELEM r'*{r'} :: r^n{}}) -- Tabletype_ok: `|-%:OK`(ti'.TYPE_tableinst) -;; 4-runtime.watsup:157.1-157.55 +;; 4-runtime.watsup:168.1-168.55 def grow_memory : (meminst, nat) -> meminst - ;; 4-runtime.watsup:164.1-168.34 + ;; 4-runtime.watsup:175.1-179.34 def {b* : byte*, i : nat, i' : nat, j : nat, mi : meminst, mi' : meminst, n : n} grow_memory(mi, n) = mi' -- if (mi = {TYPE `%I8`(`[%..%]`(i, j)), DATA b*{b}}) -- if (i' = ((|b*{b}| / (64 * $Ki)) + n)) -- if (mi' = {TYPE `%I8`(`[%..%]`(i', j)), DATA b*{b} :: 0^((n * 64) * $Ki){}}) -- Memtype_ok: `|-%:OK`(mi'.TYPE_meminst) -;; 4-runtime.watsup:181.1-184.21 +;; 4-runtime.watsup:192.1-195.21 rec { -;; 4-runtime.watsup:181.1-184.21 +;; 4-runtime.watsup:192.1-195.21 syntax E = | _HOLE | _SEQ(val*, E, instr*) @@ -1655,6 +1680,268 @@ relation Step: `%~>%`(config, config) rule data.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [DATA.DROP_admininstr(x)]), `%;%*`($with_data(z, x, []), [])) +;; 7-module.watsup:4.1-4.35 +rec { + +;; 7-module.watsup:4.1-4.35 +def funcs : externval* -> funcaddr* + ;; 7-module.watsup:5.1-5.30 + def funcs([]) = [] + ;; 7-module.watsup:6.1-6.59 + def {externval'* : externval*, fa : funcaddr} funcs([FUNC_externval(fa)] :: externval'*{externval'}) = [fa] :: $funcs(externval'*{externval'}) + ;; 7-module.watsup:7.1-8.15 + def {externval : externval, externval'* : externval*} funcs([externval] :: externval'*{externval'}) = $funcs(externval'*{externval'}) + -- otherwise +} + +;; 7-module.watsup:10.1-10.39 +rec { + +;; 7-module.watsup:10.1-10.39 +def globals : externval* -> globaladdr* + ;; 7-module.watsup:11.1-11.32 + def globals([]) = [] + ;; 7-module.watsup:12.1-12.65 + def {externval'* : externval*, ga : globaladdr} globals([GLOBAL_externval(ga)] :: externval'*{externval'}) = [ga] :: $globals(externval'*{externval'}) + ;; 7-module.watsup:13.1-14.15 + def {externval : externval, externval'* : externval*} globals([externval] :: externval'*{externval'}) = $globals(externval'*{externval'}) + -- otherwise +} + +;; 7-module.watsup:16.1-16.37 +rec { + +;; 7-module.watsup:16.1-16.37 +def tables : externval* -> tableaddr* + ;; 7-module.watsup:17.1-17.31 + def tables([]) = [] + ;; 7-module.watsup:18.1-18.62 + def {externval'* : externval*, ta : tableaddr} tables([TABLE_externval(ta)] :: externval'*{externval'}) = [ta] :: $tables(externval'*{externval'}) + ;; 7-module.watsup:19.1-20.15 + def {externval : externval, externval'* : externval*} tables([externval] :: externval'*{externval'}) = $tables(externval'*{externval'}) + -- otherwise +} + +;; 7-module.watsup:22.1-22.33 +rec { + +;; 7-module.watsup:22.1-22.33 +def mems : externval* -> memaddr* + ;; 7-module.watsup:23.1-23.29 + def mems([]) = [] + ;; 7-module.watsup:24.1-24.56 + def {externval'* : externval*, ma : memaddr} mems([MEM_externval(ma)] :: externval'*{externval'}) = [ma] :: $mems(externval'*{externval'}) + ;; 7-module.watsup:25.1-26.15 + def {externval : externval, externval'* : externval*} mems([externval] :: externval'*{externval'}) = $mems(externval'*{externval'}) + -- otherwise +} + +;; 7-module.watsup:29.1-29.83 +def instexport : (funcaddr*, globaladdr*, tableaddr*, memaddr*, export) -> exportinst + ;; 7-module.watsup:30.1-30.95 + def {fa* : funcaddr*, ga* : globaladdr*, ma* : memaddr*, name : name, ta* : tableaddr*, x : idx} instexport(fa*{fa}, ga*{ga}, ta*{ta}, ma*{ma}, EXPORT(name, FUNC_externuse(x))) = {NAME name, VALUE FUNC_externval(fa*{fa}[x])} + ;; 7-module.watsup:31.1-31.99 + def {fa* : funcaddr*, ga* : globaladdr*, ma* : memaddr*, name : name, ta* : tableaddr*, x : idx} instexport(fa*{fa}, ga*{ga}, ta*{ta}, ma*{ma}, EXPORT(name, GLOBAL_externuse(x))) = {NAME name, VALUE GLOBAL_externval(ga*{ga}[x])} + ;; 7-module.watsup:32.1-32.97 + def {fa* : funcaddr*, ga* : globaladdr*, ma* : memaddr*, name : name, ta* : tableaddr*, x : idx} instexport(fa*{fa}, ga*{ga}, ta*{ta}, ma*{ma}, EXPORT(name, TABLE_externuse(x))) = {NAME name, VALUE TABLE_externval(ta*{ta}[x])} + ;; 7-module.watsup:33.1-33.93 + def {fa* : funcaddr*, ga* : globaladdr*, ma* : memaddr*, name : name, ta* : tableaddr*, x : idx} instexport(fa*{fa}, ga*{ga}, ta*{ta}, ma*{ma}, EXPORT(name, MEM_externuse(x))) = {NAME name, VALUE MEM_externval(ma*{ma}[x])} + +;; 7-module.watsup:36.1-36.60 +def allocfunc : (store, moduleinst, func) -> (store, funcaddr) + ;; 7-module.watsup:37.1-38.37 + def {fi : funcinst, func : func, m : moduleinst, s : store} allocfunc(s, m, func) = (s[FUNC_store =.. [fi]], |s.FUNC_store|) + -- if (fi = {MODULE m, CODE func}) + +;; 7-module.watsup:40.1-40.63 +rec { + +;; 7-module.watsup:40.1-40.63 +def allocfuncs : (store, moduleinst, func*) -> (store, funcaddr*) + ;; 7-module.watsup:41.1-41.46 + def {m : moduleinst, s : store} allocfuncs(s, m, []) = (s, []) + ;; 7-module.watsup:42.1-44.50 + def {fa : funcaddr, fa'* : funcaddr*, func : func, func'* : func*, m : moduleinst, s : store, s_1 : store, s_2 : store} allocfuncs(s, m, [func] :: func'*{func'}) = (s_2, [fa] :: fa'*{fa'}) + -- if ((s_1, fa) = $allocfunc(s, m, func)) + -- if ((s_2, fa'*{fa'}) = $allocfuncs(s_1, m, func'*{func'})) +} + +;; 7-module.watsup:46.1-46.63 +def allocglobal : (store, globaltype, val) -> (store, globaladdr) + ;; 7-module.watsup:47.1-48.44 + def {gi : globalinst, globaltype : globaltype, s : store, val : val} allocglobal(s, globaltype, val) = (s[GLOBAL_store =.. [gi]], |s.GLOBAL_store|) + -- if (gi = {TYPE globaltype, VALUE val}) + +;; 7-module.watsup:50.1-50.67 +rec { + +;; 7-module.watsup:50.1-50.67 +def allocglobals : (store, globaltype*, val*) -> (store, globaladdr*) + ;; 7-module.watsup:51.1-51.54 + def {s : store} allocglobals(s, [], []) = (s, []) + ;; 7-module.watsup:52.1-54.62 + def {ga : globaladdr, ga'* : globaladdr*, globaltype : globaltype, globaltype'* : globaltype*, s : store, s_1 : store, s_2 : store, val : val, val'* : val*} allocglobals(s, [globaltype] :: globaltype'*{globaltype'}, [val] :: val'*{val'}) = (s_2, [ga] :: ga'*{ga'}) + -- if ((s_1, ga) = $allocglobal(s, globaltype, val)) + -- if ((s_2, ga'*{ga'}) = $allocglobals(s_1, globaltype'*{globaltype'}, val'*{val'})) +} + +;; 7-module.watsup:56.1-56.55 +def alloctable : (store, tabletype) -> (store, tableaddr) + ;; 7-module.watsup:57.1-58.59 + def {i : nat, j : nat, rt : reftype, s : store, ti : tableinst} alloctable(s, `%%`(`[%..%]`(i, j), rt)) = (s[TABLE_store =.. [ti]], |s.TABLE_store|) + -- if (ti = {TYPE `%%`(`[%..%]`(i, j), rt), ELEM REF.NULL_ref(rt)^i{}}) + +;; 7-module.watsup:60.1-60.58 +rec { + +;; 7-module.watsup:60.1-60.58 +def alloctables : (store, tabletype*) -> (store, tableaddr*) + ;; 7-module.watsup:61.1-61.44 + def {s : store} alloctables(s, []) = (s, []) + ;; 7-module.watsup:62.1-64.53 + def {s : store, s_1 : store, s_2 : store, ta : tableaddr, ta'* : tableaddr*, tabletype : tabletype, tabletype'* : tabletype*} alloctables(s, [tabletype] :: tabletype'*{tabletype'}) = (s_2, [ta] :: ta'*{ta'}) + -- if ((s_1, ta) = $alloctable(s, tabletype)) + -- if ((s_2, ta'*{ta'}) = $alloctables(s_1, tabletype'*{tabletype'})) +} + +;; 7-module.watsup:66.1-66.49 +def allocmem : (store, memtype) -> (store, memaddr) + ;; 7-module.watsup:67.1-68.62 + def {i : nat, j : nat, mi : meminst, s : store} allocmem(s, `%I8`(`[%..%]`(i, j))) = (s[MEM_store =.. [mi]], |s.MEM_store|) + -- if (mi = {TYPE `%I8`(`[%..%]`(i, j)), DATA 0^((i * 64) * $Ki){}}) + +;; 7-module.watsup:70.1-70.52 +rec { + +;; 7-module.watsup:70.1-70.52 +def allocmems : (store, memtype*) -> (store, memaddr*) + ;; 7-module.watsup:71.1-71.42 + def {s : store} allocmems(s, []) = (s, []) + ;; 7-module.watsup:72.1-74.49 + def {ma : memaddr, ma'* : memaddr*, memtype : memtype, memtype'* : memtype*, s : store, s_1 : store, s_2 : store} allocmems(s, [memtype] :: memtype'*{memtype'}) = (s_2, [ma] :: ma'*{ma'}) + -- if ((s_1, ma) = $allocmem(s, memtype)) + -- if ((s_2, ma'*{ma'}) = $allocmems(s_1, memtype'*{memtype'})) +} + +;; 7-module.watsup:76.1-76.57 +def allocelem : (store, reftype, ref*) -> (store, elemaddr) + ;; 7-module.watsup:77.1-78.36 + def {ei : eleminst, ref* : ref*, rt : reftype, s : store} allocelem(s, rt, ref*{ref}) = (s[ELEM_store =.. [ei]], |s.ELEM_store|) + -- if (ei = {TYPE rt, ELEM ref*{ref}}) + +;; 7-module.watsup:80.1-80.63 +rec { + +;; 7-module.watsup:80.1-80.63 +def allocelems : (store, reftype*, ref**) -> (store, elemaddr*) + ;; 7-module.watsup:81.1-81.52 + def {s : store} allocelems(s, [], []) = (s, []) + ;; 7-module.watsup:82.1-84.53 + def {ea : elemaddr, ea'* : elemaddr*, ref* : ref*, ref'** : ref**, rt : reftype, rt'* : reftype*, s : store, s_1 : store, s_2 : store} allocelems(s, [rt] :: rt'*{rt'}, [ref]*{ref} :: ref'*{ref'}*{ref'}) = (s_2, [ea] :: ea'*{ea'}) + -- if ((s_1, ea) = $allocelem(s, rt, ref*{ref})) + -- if ((s_2, ea'*{ea'}) = $allocelems(s_2, rt'*{rt'}, ref'*{ref'}*{ref'})) +} + +;; 7-module.watsup:86.1-86.49 +def allocdata : (store, byte*) -> (store, dataaddr) + ;; 7-module.watsup:87.1-88.28 + def {byte* : byte*, di : datainst, s : store} allocdata(s, byte*{byte}) = (s[DATA_store =.. [di]], |s.DATA_store|) + -- if (di = {DATA byte*{byte}}) + +;; 7-module.watsup:90.1-90.52 +rec { + +;; 7-module.watsup:90.1-90.52 +def allocdatas : (store, byte**) -> (store, dataaddr*) + ;; 7-module.watsup:91.1-91.43 + def {s : store} allocdatas(s, []) = (s, []) + ;; 7-module.watsup:92.1-94.48 + def {byte* : byte*, byte'** : byte**, da : dataaddr, da'* : dataaddr*, s : store, s_1 : store, s_2 : store} allocdatas(s, [byte]*{byte} :: byte'*{byte'}*{byte'}) = (s_2, [da] :: da'*{da'}) + -- if ((s_1, da) = $allocdata(s, byte*{byte})) + -- if ((s_2, da'*{da'}) = $allocdatas(s_1, byte'*{byte'}*{byte'})) +} + +;; 7-module.watsup:97.1-97.81 +def allocmodule : (store, module, externval*, val*, ref**) -> (store, moduleinst) + ;; 7-module.watsup:98.1-135.54 + def {byte*^n_data : byte*^n_data, da* : dataaddr*, datamode?^n_data : datamode?^n_data, ea* : elemaddr*, elemmode?^n_elem : elemmode?^n_elem, export* : export*, expr_1^n_global : expr^n_global, expr_2*^n_elem : expr*^n_elem, externval* : externval*, fa* : funcaddr*, fa_ex* : funcaddr*, func^n_func : func^n_func, ga* : globaladdr*, ga_ex* : globaladdr*, globaltype^n_global : globaltype^n_global, i_data^n_data : nat^n_data, i_elem^n_elem : nat^n_elem, i_func^n_func : nat^n_func, i_global^n_global : nat^n_global, i_mem^n_mem : nat^n_mem, i_table^n_table : nat^n_table, import* : import*, m : moduleinst, ma* : memaddr*, ma_ex* : memaddr*, memtype^n_mem : memtype^n_mem, module : module, n_data : n, n_elem : n, n_func : n, n_global : n, n_mem : n, n_table : n, ref** : ref**, rt^n_elem : reftype^n_elem, s : store, s_1 : store, s_2 : store, s_3 : store, s_4 : store, s_5 : store, s_6 : store, start? : start?, ta* : tableaddr*, ta_ex* : tableaddr*, tabletype^n_table : tabletype^n_table, val* : val*, xi* : exportinst*} allocmodule(s, module, externval*{externval}, val*{val}, ref*{ref}*{ref}) = (s_6, m) + -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func^n_func{func}, GLOBAL(globaltype, expr_1)^n_global{expr_1 globaltype}, TABLE(tabletype)^n_table{tabletype}, MEMORY(memtype)^n_mem{memtype}, `ELEM%%*%?`(rt, expr_2*{expr_2}, elemmode?{elemmode})^n_elem{elemmode expr_2 rt}, `DATA%*%?`(byte*{byte}, datamode?{datamode})^n_data{byte datamode}, start?{start}, export*{export})) + -- if (fa_ex*{fa_ex} = $funcs(externval*{externval})) + -- if (ga_ex*{ga_ex} = $globals(externval*{externval})) + -- if (ta_ex*{ta_ex} = $tables(externval*{externval})) + -- if (ma_ex*{ma_ex} = $mems(externval*{externval})) + -- if (fa*{fa} = (|s.FUNC_store| + i_func)^(i_func instr* + ;; 7-module.watsup:139.1-139.46 + def {expr* : expr*, i : nat, reftype : reftype} runelem(`ELEM%%*%?`(reftype, expr*{expr}, ?()), i) = [] + ;; 7-module.watsup:140.1-140.62 + def {expr* : expr*, i : nat, reftype : reftype} runelem(`ELEM%%*%?`(reftype, expr*{expr}, ?(DECLARE_elemmode)), i) = [ELEM.DROP_instr(i)] + ;; 7-module.watsup:141.1-143.20 + def {expr* : expr*, i : nat, instr* : instr*, n : n, reftype : reftype, x : idx} runelem(`ELEM%%*%?`(reftype, expr*{expr}, ?(TABLE_elemmode(x, instr*{instr}))), i) = instr*{instr} :: [CONST_instr(I32_numtype, 0) CONST_instr(I32_numtype, n) TABLE.INIT_instr(x, i) ELEM.DROP_instr(i)] + -- if (n = |expr*{expr}|) + +;; 7-module.watsup:145.1-145.33 +def rundata : (data, idx) -> instr* + ;; 7-module.watsup:146.1-146.38 + def {byte* : byte*, i : nat} rundata(`DATA%*%?`(byte*{byte}, ?()), i) = [] + ;; 7-module.watsup:147.1-149.20 + def {byte* : byte*, i : nat, instr* : instr*, n : n} rundata(`DATA%*%?`(byte*{byte}, ?(MEMORY_datamode(0, instr*{instr}))), i) = instr*{instr} :: [CONST_instr(I32_numtype, 0) CONST_instr(I32_numtype, n) MEMORY.INIT_instr(i) DATA.DROP_instr(i)] + -- if (n = |byte*{byte}|) + +;; 7-module.watsup:152.1-152.36 +rec { + +;; 7-module.watsup:152.1-152.36 +def concat_instr : instr** -> instr* + ;; 7-module.watsup:153.1-153.37 + def concat_instr([]) = [] + ;; 7-module.watsup:154.1-154.68 + def {instr* : instr*, instr'** : instr**} concat_instr([instr]*{instr} :: instr'*{instr'}*{instr'}) = instr*{instr} :: $concat_instr(instr'*{instr'}*{instr'}) +} + +;; 7-module.watsup:157.1-157.55 +def instantiation : (store, module, externval*) -> config + ;; 7-module.watsup:158.1-180.28 + def {data* : data*, elem* : elem*, elemmode?* : elemmode?*, export* : export*, externval* : externval*, f : frame, f_init : frame, func* : func*, global* : global*, globaltype* : globaltype*, i^n_elem : nat^n_elem, import* : import*, instr_1** : instr**, instr_2*** : instr***, instr_data* : instr*, instr_elem* : instr*, j^n_data : nat^n_data, m : moduleinst, m_init : moduleinst, mem* : mem*, module : module, n_data : n, n_elem : n, ref** : ref**, reftype* : reftype*, s : store, s' : store, start? : start?, table* : table*, val* : val*, x? : idx?} instantiation(s, module, externval*{externval}) = `%;%*`(`%;%`(s', f), (instr_elem <: admininstr)*{instr_elem} :: (instr_data <: admininstr)*{instr_data} :: CALL_admininstr(x)?{x}) + -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, start?{start}, export*{export})) + -- if (m_init = {FUNC $funcs(externval*{externval}), GLOBAL $globals(externval*{externval}), TABLE [], MEM [], ELEM [], DATA [], EXPORT []}) + -- if (f_init = {LOCAL [], MODULE m_init}) + -- if (global*{global} = GLOBAL(globaltype, instr_1*{instr_1})*{globaltype instr_1}) + -- (Step_read: `%~>%*`(`%;%*`(`%;%`(s, f_init), (instr_1 <: admininstr)*{instr_1}), [(val <: admininstr)]))*{instr_1 val} + -- if (elem*{elem} = `ELEM%%*%?`(reftype, instr_2*{instr_2}*{instr_2}, elemmode?{elemmode})*{elemmode instr_2 reftype}) + -- (Step_read: `%~>%*`(`%;%*`(`%;%`(s, f_init), (instr_2 <: admininstr)*{instr_2}), [(ref <: admininstr)]))*{instr_2 ref}*{instr_2 ref} + -- if ((s', m) = $allocmodule(s, module, externval*{externval}, val*{val}, ref*{ref}*{ref})) + -- if (f = {LOCAL [], MODULE m}) + -- if (n_elem = |elem*{elem}|) + -- if (instr_elem*{instr_elem} = $concat_instr($runelem(elem*{elem}[i], i)^(i config + ;; 7-module.watsup:184.1-196.52 + def {expr : expr, f : frame, fa : funcaddr, functype : functype, k : nat, m : moduleinst, n : n, s : store, val^n : val^n, valtype* : valtype*, valtype_param^n : valtype^n, valtype_res^k : valtype^k} invocation(s, fa, val^n{val}) = `%;%*`(`%;%`(s, f), (val <: admininstr)^n{val} :: [CALL_ADDR_admininstr(fa)]) + -- if (m = {FUNC [], GLOBAL [], TABLE [], MEM [], ELEM [], DATA [], EXPORT []}) + -- if (f = {LOCAL [], MODULE m}) + -- if ($funcinst(`%;%`(s, f))[fa].CODE_funcinst = `FUNC%%*%`(functype, valtype*{valtype}, expr)) + -- if (functype = `%->%`(valtype_param^n{valtype_param}, valtype_res^k{valtype_res})) + == IL Validation... == Running pass sub @@ -1978,8 +2265,8 @@ syntax mem = MEMORY(memtype) ;; 1-syntax.watsup:198.1-199.31 syntax elem = `ELEM%%*%?`(reftype, expr*, elemmode?) -;; 1-syntax.watsup:200.1-201.26 -syntax data = `DATA(*)%*%?`(byte**, datamode?) +;; 1-syntax.watsup:200.1-201.23 +syntax data = `DATA%*%?`(byte*, datamode?) ;; 1-syntax.watsup:202.1-203.16 syntax start = START(funcidx) @@ -2567,8 +2854,8 @@ relation Datamode_ok: `%|-%:OK`(context, datamode) ;; 3-typing.watsup:402.1-402.73 relation Data_ok: `%|-%:OK`(context, data) ;; 3-typing.watsup:433.1-435.40 - rule _ {C : context, b** : byte**, datamode? : datamode?}: - `%|-%:OK`(C, `DATA(*)%*%?`(b*{b}*{b}, datamode?{datamode})) + rule _ {C : context, b* : byte*, datamode? : datamode?}: + `%|-%:OK`(C, `DATA%*%?`(b*{b}, datamode?{datamode})) -- (Datamode_ok: `%|-%:OK`(C, datamode))?{datamode} ;; 3-typing.watsup:405.1-405.74 @@ -2733,10 +3020,10 @@ syntax frame = {LOCAL val*, MODULE moduleinst} ;; 4-runtime.watsup:96.1-96.47 syntax state = `%;%`(store, frame) -;; 4-runtime.watsup:172.1-179.5 +;; 4-runtime.watsup:183.1-190.5 rec { -;; 4-runtime.watsup:172.1-179.5 +;; 4-runtime.watsup:183.1-190.5 syntax admininstr = | UNREACHABLE | NOP @@ -2857,106 +3144,131 @@ def funcaddr : state -> funcaddr* ;; 4-runtime.watsup:118.1-118.52 def funcinst : state -> funcinst* - ;; 4-runtime.watsup:119.1-119.31 + ;; 4-runtime.watsup:125.1-125.31 def {f : frame, s : store} funcinst(`%;%`(s, f)) = s.FUNC_store -;; 4-runtime.watsup:121.1-121.67 +;; 4-runtime.watsup:119.1-119.58 +def globalinst : state -> globalinst* + ;; 4-runtime.watsup:126.1-126.35 + def {f : frame, s : store} globalinst(`%;%`(s, f)) = s.GLOBAL_store + +;; 4-runtime.watsup:120.1-120.55 +def tableinst : state -> tableinst* + ;; 4-runtime.watsup:127.1-127.33 + def {f : frame, s : store} tableinst(`%;%`(s, f)) = s.TABLE_store + +;; 4-runtime.watsup:121.1-121.49 +def meminst : state -> meminst* + ;; 4-runtime.watsup:128.1-128.29 + def {f : frame, s : store} meminst(`%;%`(s, f)) = s.MEM_store + +;; 4-runtime.watsup:122.1-122.52 +def eleminst : state -> eleminst* + ;; 4-runtime.watsup:129.1-129.31 + def {f : frame, s : store} eleminst(`%;%`(s, f)) = s.ELEM_store + +;; 4-runtime.watsup:123.1-123.52 +def datainst : state -> datainst* + ;; 4-runtime.watsup:130.1-130.31 + def {f : frame, s : store} datainst(`%;%`(s, f)) = s.DATA_store + +;; 4-runtime.watsup:132.1-132.67 def func : (state, funcidx) -> funcinst - ;; 4-runtime.watsup:129.1-129.48 + ;; 4-runtime.watsup:140.1-140.48 def {f : frame, s : store, x : idx} func(`%;%`(s, f), x) = s.FUNC_store[f.MODULE_frame.FUNC_moduleinst[x]] -;; 4-runtime.watsup:122.1-122.69 +;; 4-runtime.watsup:133.1-133.69 def global : (state, globalidx) -> globalinst - ;; 4-runtime.watsup:130.1-130.54 + ;; 4-runtime.watsup:141.1-141.54 def {f : frame, s : store, x : idx} global(`%;%`(s, f), x) = s.GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]] -;; 4-runtime.watsup:123.1-123.68 +;; 4-runtime.watsup:134.1-134.68 def table : (state, tableidx) -> tableinst - ;; 4-runtime.watsup:131.1-131.51 + ;; 4-runtime.watsup:142.1-142.51 def {f : frame, s : store, x : idx} table(`%;%`(s, f), x) = s.TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]] -;; 4-runtime.watsup:124.1-124.66 +;; 4-runtime.watsup:135.1-135.66 def mem : (state, memidx) -> meminst - ;; 4-runtime.watsup:132.1-132.45 + ;; 4-runtime.watsup:143.1-143.45 def {f : frame, s : store, x : idx} mem(`%;%`(s, f), x) = s.MEM_store[f.MODULE_frame.MEM_moduleinst[x]] -;; 4-runtime.watsup:125.1-125.67 +;; 4-runtime.watsup:136.1-136.67 def elem : (state, tableidx) -> eleminst - ;; 4-runtime.watsup:133.1-133.48 + ;; 4-runtime.watsup:144.1-144.48 def {f : frame, s : store, x : idx} elem(`%;%`(s, f), x) = s.ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]] -;; 4-runtime.watsup:126.1-126.67 +;; 4-runtime.watsup:137.1-137.67 def data : (state, dataidx) -> datainst - ;; 4-runtime.watsup:134.1-134.48 + ;; 4-runtime.watsup:145.1-145.48 def {f : frame, s : store, x : idx} data(`%;%`(s, f), x) = s.DATA_store[f.MODULE_frame.DATA_moduleinst[x]] -;; 4-runtime.watsup:127.1-127.68 +;; 4-runtime.watsup:138.1-138.68 def local : (state, localidx) -> val - ;; 4-runtime.watsup:135.1-135.35 + ;; 4-runtime.watsup:146.1-146.35 def {f : frame, s : store, x : idx} local(`%;%`(s, f), x) = f.LOCAL_frame[x] -;; 4-runtime.watsup:138.1-138.78 +;; 4-runtime.watsup:149.1-149.78 def with_local : (state, localidx, val) -> state - ;; 4-runtime.watsup:147.1-147.52 + ;; 4-runtime.watsup:158.1-158.52 def {f : frame, s : store, v : val, x : idx} with_local(`%;%`(s, f), x, v) = `%;%`(s, f[LOCAL_frame[x] = v]) -;; 4-runtime.watsup:139.1-139.85 +;; 4-runtime.watsup:150.1-150.85 def with_global : (state, globalidx, val) -> state - ;; 4-runtime.watsup:148.1-148.77 + ;; 4-runtime.watsup:159.1-159.77 def {f : frame, s : store, v : val, x : idx} with_global(`%;%`(s, f), x, v) = `%;%`(s[GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]].VALUE_globalinst = v], f) -;; 4-runtime.watsup:140.1-140.88 +;; 4-runtime.watsup:151.1-151.88 def with_table : (state, tableidx, nat, ref) -> state - ;; 4-runtime.watsup:149.1-149.79 + ;; 4-runtime.watsup:160.1-160.79 def {f : frame, i : nat, r : ref, s : store, x : idx} with_table(`%;%`(s, f), x, i, r) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]].ELEM_tableinst[i] = r], f) -;; 4-runtime.watsup:141.1-141.84 +;; 4-runtime.watsup:152.1-152.84 def with_tableinst : (state, tableidx, tableinst) -> state - ;; 4-runtime.watsup:150.1-150.74 + ;; 4-runtime.watsup:161.1-161.74 def {f : frame, s : store, ti : tableinst, x : idx} with_tableinst(`%;%`(s, f), x, ti) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]] = ti], f) -;; 4-runtime.watsup:142.1-142.93 +;; 4-runtime.watsup:153.1-153.93 def with_mem : (state, memidx, nat, nat, byte*) -> state - ;; 4-runtime.watsup:151.1-151.82 + ;; 4-runtime.watsup:162.1-162.82 def {b* : byte*, f : frame, i : nat, j : nat, s : store, x : idx} with_mem(`%;%`(s, f), x, i, j, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]].DATA_meminst[i : j] = b*{b}], f) -;; 4-runtime.watsup:143.1-143.77 +;; 4-runtime.watsup:154.1-154.77 def with_meminst : (state, memidx, meminst) -> state - ;; 4-runtime.watsup:152.1-152.68 + ;; 4-runtime.watsup:163.1-163.68 def {f : frame, mi : meminst, s : store, x : idx} with_meminst(`%;%`(s, f), x, mi) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]] = mi], f) -;; 4-runtime.watsup:144.1-144.82 +;; 4-runtime.watsup:155.1-155.82 def with_elem : (state, elemidx, ref*) -> state - ;; 4-runtime.watsup:153.1-153.72 + ;; 4-runtime.watsup:164.1-164.72 def {f : frame, r* : ref*, s : store, x : idx} with_elem(`%;%`(s, f), x, r*{r}) = `%;%`(s[ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]].ELEM_eleminst = r*{r}], f) -;; 4-runtime.watsup:145.1-145.82 +;; 4-runtime.watsup:156.1-156.82 def with_data : (state, dataidx, byte*) -> state - ;; 4-runtime.watsup:154.1-154.72 + ;; 4-runtime.watsup:165.1-165.72 def {b* : byte*, f : frame, s : store, x : idx} with_data(`%;%`(s, f), x, b*{b}) = `%;%`(s[DATA_store[f.MODULE_frame.DATA_moduleinst[x]].DATA_datainst = b*{b}], f) -;; 4-runtime.watsup:156.1-156.63 +;; 4-runtime.watsup:167.1-167.63 def grow_table : (tableinst, nat, ref) -> tableinst - ;; 4-runtime.watsup:159.1-163.36 + ;; 4-runtime.watsup:170.1-174.36 def {i : nat, i' : nat, j : nat, n : n, r : ref, r'* : ref*, rt : reftype, ti : tableinst, ti' : tableinst} grow_table(ti, n, r) = ti' -- if (ti = {TYPE `%%`(`[%..%]`(i, j), rt), ELEM r'*{r'}}) -- if (i' = (|r'*{r'}| + n)) -- if (ti' = {TYPE `%%`(`[%..%]`(i', j), rt), ELEM r'*{r'} :: r^n{}}) -- Tabletype_ok: `|-%:OK`(ti'.TYPE_tableinst) -;; 4-runtime.watsup:157.1-157.55 +;; 4-runtime.watsup:168.1-168.55 def grow_memory : (meminst, nat) -> meminst - ;; 4-runtime.watsup:164.1-168.34 + ;; 4-runtime.watsup:175.1-179.34 def {b* : byte*, i : nat, i' : nat, j : nat, mi : meminst, mi' : meminst, n : n} grow_memory(mi, n) = mi' -- if (mi = {TYPE `%I8`(`[%..%]`(i, j)), DATA b*{b}}) -- if (i' = ((|b*{b}| / (64 * $Ki)) + n)) -- if (mi' = {TYPE `%I8`(`[%..%]`(i', j)), DATA b*{b} :: 0^((n * 64) * $Ki){}}) -- Memtype_ok: `|-%:OK`(mi'.TYPE_meminst) -;; 4-runtime.watsup:181.1-184.21 +;; 4-runtime.watsup:192.1-195.21 rec { -;; 4-runtime.watsup:181.1-184.21 +;; 4-runtime.watsup:192.1-195.21 syntax E = | _HOLE | _SEQ(val*, E, instr*) @@ -3394,6 +3706,268 @@ relation Step: `%~>%`(config, config) rule data.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [DATA.DROP_admininstr(x)]), `%;%*`($with_data(z, x, []), [])) +;; 7-module.watsup:4.1-4.35 +rec { + +;; 7-module.watsup:4.1-4.35 +def funcs : externval* -> funcaddr* + ;; 7-module.watsup:5.1-5.30 + def funcs([]) = [] + ;; 7-module.watsup:6.1-6.59 + def {externval'* : externval*, fa : funcaddr} funcs([FUNC_externval(fa)] :: externval'*{externval'}) = [fa] :: $funcs(externval'*{externval'}) + ;; 7-module.watsup:7.1-8.15 + def {externval : externval, externval'* : externval*} funcs([externval] :: externval'*{externval'}) = $funcs(externval'*{externval'}) + -- otherwise +} + +;; 7-module.watsup:10.1-10.39 +rec { + +;; 7-module.watsup:10.1-10.39 +def globals : externval* -> globaladdr* + ;; 7-module.watsup:11.1-11.32 + def globals([]) = [] + ;; 7-module.watsup:12.1-12.65 + def {externval'* : externval*, ga : globaladdr} globals([GLOBAL_externval(ga)] :: externval'*{externval'}) = [ga] :: $globals(externval'*{externval'}) + ;; 7-module.watsup:13.1-14.15 + def {externval : externval, externval'* : externval*} globals([externval] :: externval'*{externval'}) = $globals(externval'*{externval'}) + -- otherwise +} + +;; 7-module.watsup:16.1-16.37 +rec { + +;; 7-module.watsup:16.1-16.37 +def tables : externval* -> tableaddr* + ;; 7-module.watsup:17.1-17.31 + def tables([]) = [] + ;; 7-module.watsup:18.1-18.62 + def {externval'* : externval*, ta : tableaddr} tables([TABLE_externval(ta)] :: externval'*{externval'}) = [ta] :: $tables(externval'*{externval'}) + ;; 7-module.watsup:19.1-20.15 + def {externval : externval, externval'* : externval*} tables([externval] :: externval'*{externval'}) = $tables(externval'*{externval'}) + -- otherwise +} + +;; 7-module.watsup:22.1-22.33 +rec { + +;; 7-module.watsup:22.1-22.33 +def mems : externval* -> memaddr* + ;; 7-module.watsup:23.1-23.29 + def mems([]) = [] + ;; 7-module.watsup:24.1-24.56 + def {externval'* : externval*, ma : memaddr} mems([MEM_externval(ma)] :: externval'*{externval'}) = [ma] :: $mems(externval'*{externval'}) + ;; 7-module.watsup:25.1-26.15 + def {externval : externval, externval'* : externval*} mems([externval] :: externval'*{externval'}) = $mems(externval'*{externval'}) + -- otherwise +} + +;; 7-module.watsup:29.1-29.83 +def instexport : (funcaddr*, globaladdr*, tableaddr*, memaddr*, export) -> exportinst + ;; 7-module.watsup:30.1-30.95 + def {fa* : funcaddr*, ga* : globaladdr*, ma* : memaddr*, name : name, ta* : tableaddr*, x : idx} instexport(fa*{fa}, ga*{ga}, ta*{ta}, ma*{ma}, EXPORT(name, FUNC_externuse(x))) = {NAME name, VALUE FUNC_externval(fa*{fa}[x])} + ;; 7-module.watsup:31.1-31.99 + def {fa* : funcaddr*, ga* : globaladdr*, ma* : memaddr*, name : name, ta* : tableaddr*, x : idx} instexport(fa*{fa}, ga*{ga}, ta*{ta}, ma*{ma}, EXPORT(name, GLOBAL_externuse(x))) = {NAME name, VALUE GLOBAL_externval(ga*{ga}[x])} + ;; 7-module.watsup:32.1-32.97 + def {fa* : funcaddr*, ga* : globaladdr*, ma* : memaddr*, name : name, ta* : tableaddr*, x : idx} instexport(fa*{fa}, ga*{ga}, ta*{ta}, ma*{ma}, EXPORT(name, TABLE_externuse(x))) = {NAME name, VALUE TABLE_externval(ta*{ta}[x])} + ;; 7-module.watsup:33.1-33.93 + def {fa* : funcaddr*, ga* : globaladdr*, ma* : memaddr*, name : name, ta* : tableaddr*, x : idx} instexport(fa*{fa}, ga*{ga}, ta*{ta}, ma*{ma}, EXPORT(name, MEM_externuse(x))) = {NAME name, VALUE MEM_externval(ma*{ma}[x])} + +;; 7-module.watsup:36.1-36.60 +def allocfunc : (store, moduleinst, func) -> (store, funcaddr) + ;; 7-module.watsup:37.1-38.37 + def {fi : funcinst, func : func, m : moduleinst, s : store} allocfunc(s, m, func) = (s[FUNC_store =.. [fi]], |s.FUNC_store|) + -- if (fi = {MODULE m, CODE func}) + +;; 7-module.watsup:40.1-40.63 +rec { + +;; 7-module.watsup:40.1-40.63 +def allocfuncs : (store, moduleinst, func*) -> (store, funcaddr*) + ;; 7-module.watsup:41.1-41.46 + def {m : moduleinst, s : store} allocfuncs(s, m, []) = (s, []) + ;; 7-module.watsup:42.1-44.50 + def {fa : funcaddr, fa'* : funcaddr*, func : func, func'* : func*, m : moduleinst, s : store, s_1 : store, s_2 : store} allocfuncs(s, m, [func] :: func'*{func'}) = (s_2, [fa] :: fa'*{fa'}) + -- if ((s_1, fa) = $allocfunc(s, m, func)) + -- if ((s_2, fa'*{fa'}) = $allocfuncs(s_1, m, func'*{func'})) +} + +;; 7-module.watsup:46.1-46.63 +def allocglobal : (store, globaltype, val) -> (store, globaladdr) + ;; 7-module.watsup:47.1-48.44 + def {gi : globalinst, globaltype : globaltype, s : store, val : val} allocglobal(s, globaltype, val) = (s[GLOBAL_store =.. [gi]], |s.GLOBAL_store|) + -- if (gi = {TYPE globaltype, VALUE val}) + +;; 7-module.watsup:50.1-50.67 +rec { + +;; 7-module.watsup:50.1-50.67 +def allocglobals : (store, globaltype*, val*) -> (store, globaladdr*) + ;; 7-module.watsup:51.1-51.54 + def {s : store} allocglobals(s, [], []) = (s, []) + ;; 7-module.watsup:52.1-54.62 + def {ga : globaladdr, ga'* : globaladdr*, globaltype : globaltype, globaltype'* : globaltype*, s : store, s_1 : store, s_2 : store, val : val, val'* : val*} allocglobals(s, [globaltype] :: globaltype'*{globaltype'}, [val] :: val'*{val'}) = (s_2, [ga] :: ga'*{ga'}) + -- if ((s_1, ga) = $allocglobal(s, globaltype, val)) + -- if ((s_2, ga'*{ga'}) = $allocglobals(s_1, globaltype'*{globaltype'}, val'*{val'})) +} + +;; 7-module.watsup:56.1-56.55 +def alloctable : (store, tabletype) -> (store, tableaddr) + ;; 7-module.watsup:57.1-58.59 + def {i : nat, j : nat, rt : reftype, s : store, ti : tableinst} alloctable(s, `%%`(`[%..%]`(i, j), rt)) = (s[TABLE_store =.. [ti]], |s.TABLE_store|) + -- if (ti = {TYPE `%%`(`[%..%]`(i, j), rt), ELEM REF.NULL_ref(rt)^i{}}) + +;; 7-module.watsup:60.1-60.58 +rec { + +;; 7-module.watsup:60.1-60.58 +def alloctables : (store, tabletype*) -> (store, tableaddr*) + ;; 7-module.watsup:61.1-61.44 + def {s : store} alloctables(s, []) = (s, []) + ;; 7-module.watsup:62.1-64.53 + def {s : store, s_1 : store, s_2 : store, ta : tableaddr, ta'* : tableaddr*, tabletype : tabletype, tabletype'* : tabletype*} alloctables(s, [tabletype] :: tabletype'*{tabletype'}) = (s_2, [ta] :: ta'*{ta'}) + -- if ((s_1, ta) = $alloctable(s, tabletype)) + -- if ((s_2, ta'*{ta'}) = $alloctables(s_1, tabletype'*{tabletype'})) +} + +;; 7-module.watsup:66.1-66.49 +def allocmem : (store, memtype) -> (store, memaddr) + ;; 7-module.watsup:67.1-68.62 + def {i : nat, j : nat, mi : meminst, s : store} allocmem(s, `%I8`(`[%..%]`(i, j))) = (s[MEM_store =.. [mi]], |s.MEM_store|) + -- if (mi = {TYPE `%I8`(`[%..%]`(i, j)), DATA 0^((i * 64) * $Ki){}}) + +;; 7-module.watsup:70.1-70.52 +rec { + +;; 7-module.watsup:70.1-70.52 +def allocmems : (store, memtype*) -> (store, memaddr*) + ;; 7-module.watsup:71.1-71.42 + def {s : store} allocmems(s, []) = (s, []) + ;; 7-module.watsup:72.1-74.49 + def {ma : memaddr, ma'* : memaddr*, memtype : memtype, memtype'* : memtype*, s : store, s_1 : store, s_2 : store} allocmems(s, [memtype] :: memtype'*{memtype'}) = (s_2, [ma] :: ma'*{ma'}) + -- if ((s_1, ma) = $allocmem(s, memtype)) + -- if ((s_2, ma'*{ma'}) = $allocmems(s_1, memtype'*{memtype'})) +} + +;; 7-module.watsup:76.1-76.57 +def allocelem : (store, reftype, ref*) -> (store, elemaddr) + ;; 7-module.watsup:77.1-78.36 + def {ei : eleminst, ref* : ref*, rt : reftype, s : store} allocelem(s, rt, ref*{ref}) = (s[ELEM_store =.. [ei]], |s.ELEM_store|) + -- if (ei = {TYPE rt, ELEM ref*{ref}}) + +;; 7-module.watsup:80.1-80.63 +rec { + +;; 7-module.watsup:80.1-80.63 +def allocelems : (store, reftype*, ref**) -> (store, elemaddr*) + ;; 7-module.watsup:81.1-81.52 + def {s : store} allocelems(s, [], []) = (s, []) + ;; 7-module.watsup:82.1-84.53 + def {ea : elemaddr, ea'* : elemaddr*, ref* : ref*, ref'** : ref**, rt : reftype, rt'* : reftype*, s : store, s_1 : store, s_2 : store} allocelems(s, [rt] :: rt'*{rt'}, [ref]*{ref} :: ref'*{ref'}*{ref'}) = (s_2, [ea] :: ea'*{ea'}) + -- if ((s_1, ea) = $allocelem(s, rt, ref*{ref})) + -- if ((s_2, ea'*{ea'}) = $allocelems(s_2, rt'*{rt'}, ref'*{ref'}*{ref'})) +} + +;; 7-module.watsup:86.1-86.49 +def allocdata : (store, byte*) -> (store, dataaddr) + ;; 7-module.watsup:87.1-88.28 + def {byte* : byte*, di : datainst, s : store} allocdata(s, byte*{byte}) = (s[DATA_store =.. [di]], |s.DATA_store|) + -- if (di = {DATA byte*{byte}}) + +;; 7-module.watsup:90.1-90.52 +rec { + +;; 7-module.watsup:90.1-90.52 +def allocdatas : (store, byte**) -> (store, dataaddr*) + ;; 7-module.watsup:91.1-91.43 + def {s : store} allocdatas(s, []) = (s, []) + ;; 7-module.watsup:92.1-94.48 + def {byte* : byte*, byte'** : byte**, da : dataaddr, da'* : dataaddr*, s : store, s_1 : store, s_2 : store} allocdatas(s, [byte]*{byte} :: byte'*{byte'}*{byte'}) = (s_2, [da] :: da'*{da'}) + -- if ((s_1, da) = $allocdata(s, byte*{byte})) + -- if ((s_2, da'*{da'}) = $allocdatas(s_1, byte'*{byte'}*{byte'})) +} + +;; 7-module.watsup:97.1-97.81 +def allocmodule : (store, module, externval*, val*, ref**) -> (store, moduleinst) + ;; 7-module.watsup:98.1-135.54 + def {byte*^n_data : byte*^n_data, da* : dataaddr*, datamode?^n_data : datamode?^n_data, ea* : elemaddr*, elemmode?^n_elem : elemmode?^n_elem, export* : export*, expr_1^n_global : expr^n_global, expr_2*^n_elem : expr*^n_elem, externval* : externval*, fa* : funcaddr*, fa_ex* : funcaddr*, func^n_func : func^n_func, ga* : globaladdr*, ga_ex* : globaladdr*, globaltype^n_global : globaltype^n_global, i_data^n_data : nat^n_data, i_elem^n_elem : nat^n_elem, i_func^n_func : nat^n_func, i_global^n_global : nat^n_global, i_mem^n_mem : nat^n_mem, i_table^n_table : nat^n_table, import* : import*, m : moduleinst, ma* : memaddr*, ma_ex* : memaddr*, memtype^n_mem : memtype^n_mem, module : module, n_data : n, n_elem : n, n_func : n, n_global : n, n_mem : n, n_table : n, ref** : ref**, rt^n_elem : reftype^n_elem, s : store, s_1 : store, s_2 : store, s_3 : store, s_4 : store, s_5 : store, s_6 : store, start? : start?, ta* : tableaddr*, ta_ex* : tableaddr*, tabletype^n_table : tabletype^n_table, val* : val*, xi* : exportinst*} allocmodule(s, module, externval*{externval}, val*{val}, ref*{ref}*{ref}) = (s_6, m) + -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func^n_func{func}, GLOBAL(globaltype, expr_1)^n_global{expr_1 globaltype}, TABLE(tabletype)^n_table{tabletype}, MEMORY(memtype)^n_mem{memtype}, `ELEM%%*%?`(rt, expr_2*{expr_2}, elemmode?{elemmode})^n_elem{elemmode expr_2 rt}, `DATA%*%?`(byte*{byte}, datamode?{datamode})^n_data{byte datamode}, start?{start}, export*{export})) + -- if (fa_ex*{fa_ex} = $funcs(externval*{externval})) + -- if (ga_ex*{ga_ex} = $globals(externval*{externval})) + -- if (ta_ex*{ta_ex} = $tables(externval*{externval})) + -- if (ma_ex*{ma_ex} = $mems(externval*{externval})) + -- if (fa*{fa} = (|s.FUNC_store| + i_func)^(i_func instr* + ;; 7-module.watsup:139.1-139.46 + def {expr* : expr*, i : nat, reftype : reftype} runelem(`ELEM%%*%?`(reftype, expr*{expr}, ?()), i) = [] + ;; 7-module.watsup:140.1-140.62 + def {expr* : expr*, i : nat, reftype : reftype} runelem(`ELEM%%*%?`(reftype, expr*{expr}, ?(DECLARE_elemmode)), i) = [ELEM.DROP_instr(i)] + ;; 7-module.watsup:141.1-143.20 + def {expr* : expr*, i : nat, instr* : instr*, n : n, reftype : reftype, x : idx} runelem(`ELEM%%*%?`(reftype, expr*{expr}, ?(TABLE_elemmode(x, instr*{instr}))), i) = instr*{instr} :: [CONST_instr(I32_numtype, 0) CONST_instr(I32_numtype, n) TABLE.INIT_instr(x, i) ELEM.DROP_instr(i)] + -- if (n = |expr*{expr}|) + +;; 7-module.watsup:145.1-145.33 +def rundata : (data, idx) -> instr* + ;; 7-module.watsup:146.1-146.38 + def {byte* : byte*, i : nat} rundata(`DATA%*%?`(byte*{byte}, ?()), i) = [] + ;; 7-module.watsup:147.1-149.20 + def {byte* : byte*, i : nat, instr* : instr*, n : n} rundata(`DATA%*%?`(byte*{byte}, ?(MEMORY_datamode(0, instr*{instr}))), i) = instr*{instr} :: [CONST_instr(I32_numtype, 0) CONST_instr(I32_numtype, n) MEMORY.INIT_instr(i) DATA.DROP_instr(i)] + -- if (n = |byte*{byte}|) + +;; 7-module.watsup:152.1-152.36 +rec { + +;; 7-module.watsup:152.1-152.36 +def concat_instr : instr** -> instr* + ;; 7-module.watsup:153.1-153.37 + def concat_instr([]) = [] + ;; 7-module.watsup:154.1-154.68 + def {instr* : instr*, instr'** : instr**} concat_instr([instr]*{instr} :: instr'*{instr'}*{instr'}) = instr*{instr} :: $concat_instr(instr'*{instr'}*{instr'}) +} + +;; 7-module.watsup:157.1-157.55 +def instantiation : (store, module, externval*) -> config + ;; 7-module.watsup:158.1-180.28 + def {data* : data*, elem* : elem*, elemmode?* : elemmode?*, export* : export*, externval* : externval*, f : frame, f_init : frame, func* : func*, global* : global*, globaltype* : globaltype*, i^n_elem : nat^n_elem, import* : import*, instr_1** : instr**, instr_2*** : instr***, instr_data* : instr*, instr_elem* : instr*, j^n_data : nat^n_data, m : moduleinst, m_init : moduleinst, mem* : mem*, module : module, n_data : n, n_elem : n, ref** : ref**, reftype* : reftype*, s : store, s' : store, start? : start?, table* : table*, val* : val*, x? : idx?} instantiation(s, module, externval*{externval}) = `%;%*`(`%;%`(s', f), $admininstr_instr(instr_elem)*{instr_elem} :: $admininstr_instr(instr_data)*{instr_data} :: CALL_admininstr(x)?{x}) + -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, start?{start}, export*{export})) + -- if (m_init = {FUNC $funcs(externval*{externval}), GLOBAL $globals(externval*{externval}), TABLE [], MEM [], ELEM [], DATA [], EXPORT []}) + -- if (f_init = {LOCAL [], MODULE m_init}) + -- if (global*{global} = GLOBAL(globaltype, instr_1*{instr_1})*{globaltype instr_1}) + -- (Step_read: `%~>%*`(`%;%*`(`%;%`(s, f_init), $admininstr_instr(instr_1)*{instr_1}), [$admininstr_val(val)]))*{instr_1 val} + -- if (elem*{elem} = `ELEM%%*%?`(reftype, instr_2*{instr_2}*{instr_2}, elemmode?{elemmode})*{elemmode instr_2 reftype}) + -- (Step_read: `%~>%*`(`%;%*`(`%;%`(s, f_init), $admininstr_instr(instr_2)*{instr_2}), [$admininstr_ref(ref)]))*{instr_2 ref}*{instr_2 ref} + -- if ((s', m) = $allocmodule(s, module, externval*{externval}, val*{val}, ref*{ref}*{ref})) + -- if (f = {LOCAL [], MODULE m}) + -- if (n_elem = |elem*{elem}|) + -- if (instr_elem*{instr_elem} = $concat_instr($runelem(elem*{elem}[i], i)^(i config + ;; 7-module.watsup:184.1-196.52 + def {expr : expr, f : frame, fa : funcaddr, functype : functype, k : nat, m : moduleinst, n : n, s : store, val^n : val^n, valtype* : valtype*, valtype_param^n : valtype^n, valtype_res^k : valtype^k} invocation(s, fa, val^n{val}) = `%;%*`(`%;%`(s, f), $admininstr_val(val)^n{val} :: [CALL_ADDR_admininstr(fa)]) + -- if (m = {FUNC [], GLOBAL [], TABLE [], MEM [], ELEM [], DATA [], EXPORT []}) + -- if (f = {LOCAL [], MODULE m}) + -- if ($funcinst(`%;%`(s, f))[fa].CODE_funcinst = `FUNC%%*%`(functype, valtype*{valtype}, expr)) + -- if (functype = `%->%`(valtype_param^n{valtype_param}, valtype_res^k{valtype_res})) + == IL Validation... == Running pass totalize @@ -3717,8 +4291,8 @@ syntax mem = MEMORY(memtype) ;; 1-syntax.watsup:198.1-199.31 syntax elem = `ELEM%%*%?`(reftype, expr*, elemmode?) -;; 1-syntax.watsup:200.1-201.26 -syntax data = `DATA(*)%*%?`(byte**, datamode?) +;; 1-syntax.watsup:200.1-201.23 +syntax data = `DATA%*%?`(byte*, datamode?) ;; 1-syntax.watsup:202.1-203.16 syntax start = START(funcidx) @@ -4307,8 +4881,8 @@ relation Datamode_ok: `%|-%:OK`(context, datamode) ;; 3-typing.watsup:402.1-402.73 relation Data_ok: `%|-%:OK`(context, data) ;; 3-typing.watsup:433.1-435.40 - rule _ {C : context, b** : byte**, datamode? : datamode?}: - `%|-%:OK`(C, `DATA(*)%*%?`(b*{b}*{b}, datamode?{datamode})) + rule _ {C : context, b* : byte*, datamode? : datamode?}: + `%|-%:OK`(C, `DATA%*%?`(b*{b}, datamode?{datamode})) -- (Datamode_ok: `%|-%:OK`(C, datamode))?{datamode} ;; 3-typing.watsup:405.1-405.74 @@ -4474,10 +5048,10 @@ syntax frame = {LOCAL val*, MODULE moduleinst} ;; 4-runtime.watsup:96.1-96.47 syntax state = `%;%`(store, frame) -;; 4-runtime.watsup:172.1-179.5 +;; 4-runtime.watsup:183.1-190.5 rec { -;; 4-runtime.watsup:172.1-179.5 +;; 4-runtime.watsup:183.1-190.5 syntax admininstr = | UNREACHABLE | NOP @@ -4598,87 +5172,112 @@ def funcaddr : state -> funcaddr* ;; 4-runtime.watsup:118.1-118.52 def funcinst : state -> funcinst* - ;; 4-runtime.watsup:119.1-119.31 + ;; 4-runtime.watsup:125.1-125.31 def {f : frame, s : store} funcinst(`%;%`(s, f)) = s.FUNC_store -;; 4-runtime.watsup:121.1-121.67 +;; 4-runtime.watsup:119.1-119.58 +def globalinst : state -> globalinst* + ;; 4-runtime.watsup:126.1-126.35 + def {f : frame, s : store} globalinst(`%;%`(s, f)) = s.GLOBAL_store + +;; 4-runtime.watsup:120.1-120.55 +def tableinst : state -> tableinst* + ;; 4-runtime.watsup:127.1-127.33 + def {f : frame, s : store} tableinst(`%;%`(s, f)) = s.TABLE_store + +;; 4-runtime.watsup:121.1-121.49 +def meminst : state -> meminst* + ;; 4-runtime.watsup:128.1-128.29 + def {f : frame, s : store} meminst(`%;%`(s, f)) = s.MEM_store + +;; 4-runtime.watsup:122.1-122.52 +def eleminst : state -> eleminst* + ;; 4-runtime.watsup:129.1-129.31 + def {f : frame, s : store} eleminst(`%;%`(s, f)) = s.ELEM_store + +;; 4-runtime.watsup:123.1-123.52 +def datainst : state -> datainst* + ;; 4-runtime.watsup:130.1-130.31 + def {f : frame, s : store} datainst(`%;%`(s, f)) = s.DATA_store + +;; 4-runtime.watsup:132.1-132.67 def func : (state, funcidx) -> funcinst - ;; 4-runtime.watsup:129.1-129.48 + ;; 4-runtime.watsup:140.1-140.48 def {f : frame, s : store, x : idx} func(`%;%`(s, f), x) = s.FUNC_store[f.MODULE_frame.FUNC_moduleinst[x]] -;; 4-runtime.watsup:122.1-122.69 +;; 4-runtime.watsup:133.1-133.69 def global : (state, globalidx) -> globalinst - ;; 4-runtime.watsup:130.1-130.54 + ;; 4-runtime.watsup:141.1-141.54 def {f : frame, s : store, x : idx} global(`%;%`(s, f), x) = s.GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]] -;; 4-runtime.watsup:123.1-123.68 +;; 4-runtime.watsup:134.1-134.68 def table : (state, tableidx) -> tableinst - ;; 4-runtime.watsup:131.1-131.51 + ;; 4-runtime.watsup:142.1-142.51 def {f : frame, s : store, x : idx} table(`%;%`(s, f), x) = s.TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]] -;; 4-runtime.watsup:124.1-124.66 +;; 4-runtime.watsup:135.1-135.66 def mem : (state, memidx) -> meminst - ;; 4-runtime.watsup:132.1-132.45 + ;; 4-runtime.watsup:143.1-143.45 def {f : frame, s : store, x : idx} mem(`%;%`(s, f), x) = s.MEM_store[f.MODULE_frame.MEM_moduleinst[x]] -;; 4-runtime.watsup:125.1-125.67 +;; 4-runtime.watsup:136.1-136.67 def elem : (state, tableidx) -> eleminst - ;; 4-runtime.watsup:133.1-133.48 + ;; 4-runtime.watsup:144.1-144.48 def {f : frame, s : store, x : idx} elem(`%;%`(s, f), x) = s.ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]] -;; 4-runtime.watsup:126.1-126.67 +;; 4-runtime.watsup:137.1-137.67 def data : (state, dataidx) -> datainst - ;; 4-runtime.watsup:134.1-134.48 + ;; 4-runtime.watsup:145.1-145.48 def {f : frame, s : store, x : idx} data(`%;%`(s, f), x) = s.DATA_store[f.MODULE_frame.DATA_moduleinst[x]] -;; 4-runtime.watsup:127.1-127.68 +;; 4-runtime.watsup:138.1-138.68 def local : (state, localidx) -> val - ;; 4-runtime.watsup:135.1-135.35 + ;; 4-runtime.watsup:146.1-146.35 def {f : frame, s : store, x : idx} local(`%;%`(s, f), x) = f.LOCAL_frame[x] -;; 4-runtime.watsup:138.1-138.78 +;; 4-runtime.watsup:149.1-149.78 def with_local : (state, localidx, val) -> state - ;; 4-runtime.watsup:147.1-147.52 + ;; 4-runtime.watsup:158.1-158.52 def {f : frame, s : store, v : val, x : idx} with_local(`%;%`(s, f), x, v) = `%;%`(s, f[LOCAL_frame[x] = v]) -;; 4-runtime.watsup:139.1-139.85 +;; 4-runtime.watsup:150.1-150.85 def with_global : (state, globalidx, val) -> state - ;; 4-runtime.watsup:148.1-148.77 + ;; 4-runtime.watsup:159.1-159.77 def {f : frame, s : store, v : val, x : idx} with_global(`%;%`(s, f), x, v) = `%;%`(s[GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]].VALUE_globalinst = v], f) -;; 4-runtime.watsup:140.1-140.88 +;; 4-runtime.watsup:151.1-151.88 def with_table : (state, tableidx, nat, ref) -> state - ;; 4-runtime.watsup:149.1-149.79 + ;; 4-runtime.watsup:160.1-160.79 def {f : frame, i : nat, r : ref, s : store, x : idx} with_table(`%;%`(s, f), x, i, r) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]].ELEM_tableinst[i] = r], f) -;; 4-runtime.watsup:141.1-141.84 +;; 4-runtime.watsup:152.1-152.84 def with_tableinst : (state, tableidx, tableinst) -> state - ;; 4-runtime.watsup:150.1-150.74 + ;; 4-runtime.watsup:161.1-161.74 def {f : frame, s : store, ti : tableinst, x : idx} with_tableinst(`%;%`(s, f), x, ti) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]] = ti], f) -;; 4-runtime.watsup:142.1-142.93 +;; 4-runtime.watsup:153.1-153.93 def with_mem : (state, memidx, nat, nat, byte*) -> state - ;; 4-runtime.watsup:151.1-151.82 + ;; 4-runtime.watsup:162.1-162.82 def {b* : byte*, f : frame, i : nat, j : nat, s : store, x : idx} with_mem(`%;%`(s, f), x, i, j, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]].DATA_meminst[i : j] = b*{b}], f) -;; 4-runtime.watsup:143.1-143.77 +;; 4-runtime.watsup:154.1-154.77 def with_meminst : (state, memidx, meminst) -> state - ;; 4-runtime.watsup:152.1-152.68 + ;; 4-runtime.watsup:163.1-163.68 def {f : frame, mi : meminst, s : store, x : idx} with_meminst(`%;%`(s, f), x, mi) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]] = mi], f) -;; 4-runtime.watsup:144.1-144.82 +;; 4-runtime.watsup:155.1-155.82 def with_elem : (state, elemidx, ref*) -> state - ;; 4-runtime.watsup:153.1-153.72 + ;; 4-runtime.watsup:164.1-164.72 def {f : frame, r* : ref*, s : store, x : idx} with_elem(`%;%`(s, f), x, r*{r}) = `%;%`(s[ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]].ELEM_eleminst = r*{r}], f) -;; 4-runtime.watsup:145.1-145.82 +;; 4-runtime.watsup:156.1-156.82 def with_data : (state, dataidx, byte*) -> state - ;; 4-runtime.watsup:154.1-154.72 + ;; 4-runtime.watsup:165.1-165.72 def {b* : byte*, f : frame, s : store, x : idx} with_data(`%;%`(s, f), x, b*{b}) = `%;%`(s[DATA_store[f.MODULE_frame.DATA_moduleinst[x]].DATA_datainst = b*{b}], f) -;; 4-runtime.watsup:156.1-156.63 +;; 4-runtime.watsup:167.1-167.63 def grow_table : (tableinst, nat, ref) -> tableinst? - ;; 4-runtime.watsup:159.1-163.36 + ;; 4-runtime.watsup:170.1-174.36 def {i : nat, i' : nat, j : nat, n : n, r : ref, r'* : ref*, rt : reftype, ti : tableinst, ti' : tableinst} grow_table(ti, n, r) = ?(ti') -- if (ti = {TYPE `%%`(`[%..%]`(i, j), rt), ELEM r'*{r'}}) -- if (i' = (|r'*{r'}| + n)) @@ -4686,9 +5285,9 @@ def grow_table : (tableinst, nat, ref) -> tableinst? -- Tabletype_ok: `|-%:OK`(ti'.TYPE_tableinst) def {x : (tableinst, nat, ref)} grow_table(x) = ?() -;; 4-runtime.watsup:157.1-157.55 +;; 4-runtime.watsup:168.1-168.55 def grow_memory : (meminst, nat) -> meminst? - ;; 4-runtime.watsup:164.1-168.34 + ;; 4-runtime.watsup:175.1-179.34 def {b* : byte*, i : nat, i' : nat, j : nat, mi : meminst, mi' : meminst, n : n} grow_memory(mi, n) = ?(mi') -- if (mi = {TYPE `%I8`(`[%..%]`(i, j)), DATA b*{b}}) -- if (i' = ((|b*{b}| / (64 * $Ki)) + n)) @@ -4696,10 +5295,10 @@ def grow_memory : (meminst, nat) -> meminst? -- Memtype_ok: `|-%:OK`(mi'.TYPE_meminst) def {x : (meminst, nat)} grow_memory(x) = ?() -;; 4-runtime.watsup:181.1-184.21 +;; 4-runtime.watsup:192.1-195.21 rec { -;; 4-runtime.watsup:181.1-184.21 +;; 4-runtime.watsup:192.1-195.21 syntax E = | _HOLE | _SEQ(val*, E, instr*) @@ -5137,6 +5736,268 @@ relation Step: `%~>%`(config, config) rule data.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [DATA.DROP_admininstr(x)]), `%;%*`($with_data(z, x, []), [])) +;; 7-module.watsup:4.1-4.35 +rec { + +;; 7-module.watsup:4.1-4.35 +def funcs : externval* -> funcaddr* + ;; 7-module.watsup:5.1-5.30 + def funcs([]) = [] + ;; 7-module.watsup:6.1-6.59 + def {externval'* : externval*, fa : funcaddr} funcs([FUNC_externval(fa)] :: externval'*{externval'}) = [fa] :: $funcs(externval'*{externval'}) + ;; 7-module.watsup:7.1-8.15 + def {externval : externval, externval'* : externval*} funcs([externval] :: externval'*{externval'}) = $funcs(externval'*{externval'}) + -- otherwise +} + +;; 7-module.watsup:10.1-10.39 +rec { + +;; 7-module.watsup:10.1-10.39 +def globals : externval* -> globaladdr* + ;; 7-module.watsup:11.1-11.32 + def globals([]) = [] + ;; 7-module.watsup:12.1-12.65 + def {externval'* : externval*, ga : globaladdr} globals([GLOBAL_externval(ga)] :: externval'*{externval'}) = [ga] :: $globals(externval'*{externval'}) + ;; 7-module.watsup:13.1-14.15 + def {externval : externval, externval'* : externval*} globals([externval] :: externval'*{externval'}) = $globals(externval'*{externval'}) + -- otherwise +} + +;; 7-module.watsup:16.1-16.37 +rec { + +;; 7-module.watsup:16.1-16.37 +def tables : externval* -> tableaddr* + ;; 7-module.watsup:17.1-17.31 + def tables([]) = [] + ;; 7-module.watsup:18.1-18.62 + def {externval'* : externval*, ta : tableaddr} tables([TABLE_externval(ta)] :: externval'*{externval'}) = [ta] :: $tables(externval'*{externval'}) + ;; 7-module.watsup:19.1-20.15 + def {externval : externval, externval'* : externval*} tables([externval] :: externval'*{externval'}) = $tables(externval'*{externval'}) + -- otherwise +} + +;; 7-module.watsup:22.1-22.33 +rec { + +;; 7-module.watsup:22.1-22.33 +def mems : externval* -> memaddr* + ;; 7-module.watsup:23.1-23.29 + def mems([]) = [] + ;; 7-module.watsup:24.1-24.56 + def {externval'* : externval*, ma : memaddr} mems([MEM_externval(ma)] :: externval'*{externval'}) = [ma] :: $mems(externval'*{externval'}) + ;; 7-module.watsup:25.1-26.15 + def {externval : externval, externval'* : externval*} mems([externval] :: externval'*{externval'}) = $mems(externval'*{externval'}) + -- otherwise +} + +;; 7-module.watsup:29.1-29.83 +def instexport : (funcaddr*, globaladdr*, tableaddr*, memaddr*, export) -> exportinst + ;; 7-module.watsup:30.1-30.95 + def {fa* : funcaddr*, ga* : globaladdr*, ma* : memaddr*, name : name, ta* : tableaddr*, x : idx} instexport(fa*{fa}, ga*{ga}, ta*{ta}, ma*{ma}, EXPORT(name, FUNC_externuse(x))) = {NAME name, VALUE FUNC_externval(fa*{fa}[x])} + ;; 7-module.watsup:31.1-31.99 + def {fa* : funcaddr*, ga* : globaladdr*, ma* : memaddr*, name : name, ta* : tableaddr*, x : idx} instexport(fa*{fa}, ga*{ga}, ta*{ta}, ma*{ma}, EXPORT(name, GLOBAL_externuse(x))) = {NAME name, VALUE GLOBAL_externval(ga*{ga}[x])} + ;; 7-module.watsup:32.1-32.97 + def {fa* : funcaddr*, ga* : globaladdr*, ma* : memaddr*, name : name, ta* : tableaddr*, x : idx} instexport(fa*{fa}, ga*{ga}, ta*{ta}, ma*{ma}, EXPORT(name, TABLE_externuse(x))) = {NAME name, VALUE TABLE_externval(ta*{ta}[x])} + ;; 7-module.watsup:33.1-33.93 + def {fa* : funcaddr*, ga* : globaladdr*, ma* : memaddr*, name : name, ta* : tableaddr*, x : idx} instexport(fa*{fa}, ga*{ga}, ta*{ta}, ma*{ma}, EXPORT(name, MEM_externuse(x))) = {NAME name, VALUE MEM_externval(ma*{ma}[x])} + +;; 7-module.watsup:36.1-36.60 +def allocfunc : (store, moduleinst, func) -> (store, funcaddr) + ;; 7-module.watsup:37.1-38.37 + def {fi : funcinst, func : func, m : moduleinst, s : store} allocfunc(s, m, func) = (s[FUNC_store =.. [fi]], |s.FUNC_store|) + -- if (fi = {MODULE m, CODE func}) + +;; 7-module.watsup:40.1-40.63 +rec { + +;; 7-module.watsup:40.1-40.63 +def allocfuncs : (store, moduleinst, func*) -> (store, funcaddr*) + ;; 7-module.watsup:41.1-41.46 + def {m : moduleinst, s : store} allocfuncs(s, m, []) = (s, []) + ;; 7-module.watsup:42.1-44.50 + def {fa : funcaddr, fa'* : funcaddr*, func : func, func'* : func*, m : moduleinst, s : store, s_1 : store, s_2 : store} allocfuncs(s, m, [func] :: func'*{func'}) = (s_2, [fa] :: fa'*{fa'}) + -- if ((s_1, fa) = $allocfunc(s, m, func)) + -- if ((s_2, fa'*{fa'}) = $allocfuncs(s_1, m, func'*{func'})) +} + +;; 7-module.watsup:46.1-46.63 +def allocglobal : (store, globaltype, val) -> (store, globaladdr) + ;; 7-module.watsup:47.1-48.44 + def {gi : globalinst, globaltype : globaltype, s : store, val : val} allocglobal(s, globaltype, val) = (s[GLOBAL_store =.. [gi]], |s.GLOBAL_store|) + -- if (gi = {TYPE globaltype, VALUE val}) + +;; 7-module.watsup:50.1-50.67 +rec { + +;; 7-module.watsup:50.1-50.67 +def allocglobals : (store, globaltype*, val*) -> (store, globaladdr*) + ;; 7-module.watsup:51.1-51.54 + def {s : store} allocglobals(s, [], []) = (s, []) + ;; 7-module.watsup:52.1-54.62 + def {ga : globaladdr, ga'* : globaladdr*, globaltype : globaltype, globaltype'* : globaltype*, s : store, s_1 : store, s_2 : store, val : val, val'* : val*} allocglobals(s, [globaltype] :: globaltype'*{globaltype'}, [val] :: val'*{val'}) = (s_2, [ga] :: ga'*{ga'}) + -- if ((s_1, ga) = $allocglobal(s, globaltype, val)) + -- if ((s_2, ga'*{ga'}) = $allocglobals(s_1, globaltype'*{globaltype'}, val'*{val'})) +} + +;; 7-module.watsup:56.1-56.55 +def alloctable : (store, tabletype) -> (store, tableaddr) + ;; 7-module.watsup:57.1-58.59 + def {i : nat, j : nat, rt : reftype, s : store, ti : tableinst} alloctable(s, `%%`(`[%..%]`(i, j), rt)) = (s[TABLE_store =.. [ti]], |s.TABLE_store|) + -- if (ti = {TYPE `%%`(`[%..%]`(i, j), rt), ELEM REF.NULL_ref(rt)^i{}}) + +;; 7-module.watsup:60.1-60.58 +rec { + +;; 7-module.watsup:60.1-60.58 +def alloctables : (store, tabletype*) -> (store, tableaddr*) + ;; 7-module.watsup:61.1-61.44 + def {s : store} alloctables(s, []) = (s, []) + ;; 7-module.watsup:62.1-64.53 + def {s : store, s_1 : store, s_2 : store, ta : tableaddr, ta'* : tableaddr*, tabletype : tabletype, tabletype'* : tabletype*} alloctables(s, [tabletype] :: tabletype'*{tabletype'}) = (s_2, [ta] :: ta'*{ta'}) + -- if ((s_1, ta) = $alloctable(s, tabletype)) + -- if ((s_2, ta'*{ta'}) = $alloctables(s_1, tabletype'*{tabletype'})) +} + +;; 7-module.watsup:66.1-66.49 +def allocmem : (store, memtype) -> (store, memaddr) + ;; 7-module.watsup:67.1-68.62 + def {i : nat, j : nat, mi : meminst, s : store} allocmem(s, `%I8`(`[%..%]`(i, j))) = (s[MEM_store =.. [mi]], |s.MEM_store|) + -- if (mi = {TYPE `%I8`(`[%..%]`(i, j)), DATA 0^((i * 64) * $Ki){}}) + +;; 7-module.watsup:70.1-70.52 +rec { + +;; 7-module.watsup:70.1-70.52 +def allocmems : (store, memtype*) -> (store, memaddr*) + ;; 7-module.watsup:71.1-71.42 + def {s : store} allocmems(s, []) = (s, []) + ;; 7-module.watsup:72.1-74.49 + def {ma : memaddr, ma'* : memaddr*, memtype : memtype, memtype'* : memtype*, s : store, s_1 : store, s_2 : store} allocmems(s, [memtype] :: memtype'*{memtype'}) = (s_2, [ma] :: ma'*{ma'}) + -- if ((s_1, ma) = $allocmem(s, memtype)) + -- if ((s_2, ma'*{ma'}) = $allocmems(s_1, memtype'*{memtype'})) +} + +;; 7-module.watsup:76.1-76.57 +def allocelem : (store, reftype, ref*) -> (store, elemaddr) + ;; 7-module.watsup:77.1-78.36 + def {ei : eleminst, ref* : ref*, rt : reftype, s : store} allocelem(s, rt, ref*{ref}) = (s[ELEM_store =.. [ei]], |s.ELEM_store|) + -- if (ei = {TYPE rt, ELEM ref*{ref}}) + +;; 7-module.watsup:80.1-80.63 +rec { + +;; 7-module.watsup:80.1-80.63 +def allocelems : (store, reftype*, ref**) -> (store, elemaddr*) + ;; 7-module.watsup:81.1-81.52 + def {s : store} allocelems(s, [], []) = (s, []) + ;; 7-module.watsup:82.1-84.53 + def {ea : elemaddr, ea'* : elemaddr*, ref* : ref*, ref'** : ref**, rt : reftype, rt'* : reftype*, s : store, s_1 : store, s_2 : store} allocelems(s, [rt] :: rt'*{rt'}, [ref]*{ref} :: ref'*{ref'}*{ref'}) = (s_2, [ea] :: ea'*{ea'}) + -- if ((s_1, ea) = $allocelem(s, rt, ref*{ref})) + -- if ((s_2, ea'*{ea'}) = $allocelems(s_2, rt'*{rt'}, ref'*{ref'}*{ref'})) +} + +;; 7-module.watsup:86.1-86.49 +def allocdata : (store, byte*) -> (store, dataaddr) + ;; 7-module.watsup:87.1-88.28 + def {byte* : byte*, di : datainst, s : store} allocdata(s, byte*{byte}) = (s[DATA_store =.. [di]], |s.DATA_store|) + -- if (di = {DATA byte*{byte}}) + +;; 7-module.watsup:90.1-90.52 +rec { + +;; 7-module.watsup:90.1-90.52 +def allocdatas : (store, byte**) -> (store, dataaddr*) + ;; 7-module.watsup:91.1-91.43 + def {s : store} allocdatas(s, []) = (s, []) + ;; 7-module.watsup:92.1-94.48 + def {byte* : byte*, byte'** : byte**, da : dataaddr, da'* : dataaddr*, s : store, s_1 : store, s_2 : store} allocdatas(s, [byte]*{byte} :: byte'*{byte'}*{byte'}) = (s_2, [da] :: da'*{da'}) + -- if ((s_1, da) = $allocdata(s, byte*{byte})) + -- if ((s_2, da'*{da'}) = $allocdatas(s_1, byte'*{byte'}*{byte'})) +} + +;; 7-module.watsup:97.1-97.81 +def allocmodule : (store, module, externval*, val*, ref**) -> (store, moduleinst) + ;; 7-module.watsup:98.1-135.54 + def {byte*^n_data : byte*^n_data, da* : dataaddr*, datamode?^n_data : datamode?^n_data, ea* : elemaddr*, elemmode?^n_elem : elemmode?^n_elem, export* : export*, expr_1^n_global : expr^n_global, expr_2*^n_elem : expr*^n_elem, externval* : externval*, fa* : funcaddr*, fa_ex* : funcaddr*, func^n_func : func^n_func, ga* : globaladdr*, ga_ex* : globaladdr*, globaltype^n_global : globaltype^n_global, i_data^n_data : nat^n_data, i_elem^n_elem : nat^n_elem, i_func^n_func : nat^n_func, i_global^n_global : nat^n_global, i_mem^n_mem : nat^n_mem, i_table^n_table : nat^n_table, import* : import*, m : moduleinst, ma* : memaddr*, ma_ex* : memaddr*, memtype^n_mem : memtype^n_mem, module : module, n_data : n, n_elem : n, n_func : n, n_global : n, n_mem : n, n_table : n, ref** : ref**, rt^n_elem : reftype^n_elem, s : store, s_1 : store, s_2 : store, s_3 : store, s_4 : store, s_5 : store, s_6 : store, start? : start?, ta* : tableaddr*, ta_ex* : tableaddr*, tabletype^n_table : tabletype^n_table, val* : val*, xi* : exportinst*} allocmodule(s, module, externval*{externval}, val*{val}, ref*{ref}*{ref}) = (s_6, m) + -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func^n_func{func}, GLOBAL(globaltype, expr_1)^n_global{expr_1 globaltype}, TABLE(tabletype)^n_table{tabletype}, MEMORY(memtype)^n_mem{memtype}, `ELEM%%*%?`(rt, expr_2*{expr_2}, elemmode?{elemmode})^n_elem{elemmode expr_2 rt}, `DATA%*%?`(byte*{byte}, datamode?{datamode})^n_data{byte datamode}, start?{start}, export*{export})) + -- if (fa_ex*{fa_ex} = $funcs(externval*{externval})) + -- if (ga_ex*{ga_ex} = $globals(externval*{externval})) + -- if (ta_ex*{ta_ex} = $tables(externval*{externval})) + -- if (ma_ex*{ma_ex} = $mems(externval*{externval})) + -- if (fa*{fa} = (|s.FUNC_store| + i_func)^(i_func instr* + ;; 7-module.watsup:139.1-139.46 + def {expr* : expr*, i : nat, reftype : reftype} runelem(`ELEM%%*%?`(reftype, expr*{expr}, ?()), i) = [] + ;; 7-module.watsup:140.1-140.62 + def {expr* : expr*, i : nat, reftype : reftype} runelem(`ELEM%%*%?`(reftype, expr*{expr}, ?(DECLARE_elemmode)), i) = [ELEM.DROP_instr(i)] + ;; 7-module.watsup:141.1-143.20 + def {expr* : expr*, i : nat, instr* : instr*, n : n, reftype : reftype, x : idx} runelem(`ELEM%%*%?`(reftype, expr*{expr}, ?(TABLE_elemmode(x, instr*{instr}))), i) = instr*{instr} :: [CONST_instr(I32_numtype, 0) CONST_instr(I32_numtype, n) TABLE.INIT_instr(x, i) ELEM.DROP_instr(i)] + -- if (n = |expr*{expr}|) + +;; 7-module.watsup:145.1-145.33 +def rundata : (data, idx) -> instr* + ;; 7-module.watsup:146.1-146.38 + def {byte* : byte*, i : nat} rundata(`DATA%*%?`(byte*{byte}, ?()), i) = [] + ;; 7-module.watsup:147.1-149.20 + def {byte* : byte*, i : nat, instr* : instr*, n : n} rundata(`DATA%*%?`(byte*{byte}, ?(MEMORY_datamode(0, instr*{instr}))), i) = instr*{instr} :: [CONST_instr(I32_numtype, 0) CONST_instr(I32_numtype, n) MEMORY.INIT_instr(i) DATA.DROP_instr(i)] + -- if (n = |byte*{byte}|) + +;; 7-module.watsup:152.1-152.36 +rec { + +;; 7-module.watsup:152.1-152.36 +def concat_instr : instr** -> instr* + ;; 7-module.watsup:153.1-153.37 + def concat_instr([]) = [] + ;; 7-module.watsup:154.1-154.68 + def {instr* : instr*, instr'** : instr**} concat_instr([instr]*{instr} :: instr'*{instr'}*{instr'}) = instr*{instr} :: $concat_instr(instr'*{instr'}*{instr'}) +} + +;; 7-module.watsup:157.1-157.55 +def instantiation : (store, module, externval*) -> config + ;; 7-module.watsup:158.1-180.28 + def {data* : data*, elem* : elem*, elemmode?* : elemmode?*, export* : export*, externval* : externval*, f : frame, f_init : frame, func* : func*, global* : global*, globaltype* : globaltype*, i^n_elem : nat^n_elem, import* : import*, instr_1** : instr**, instr_2*** : instr***, instr_data* : instr*, instr_elem* : instr*, j^n_data : nat^n_data, m : moduleinst, m_init : moduleinst, mem* : mem*, module : module, n_data : n, n_elem : n, ref** : ref**, reftype* : reftype*, s : store, s' : store, start? : start?, table* : table*, val* : val*, x? : idx?} instantiation(s, module, externval*{externval}) = `%;%*`(`%;%`(s', f), $admininstr_instr(instr_elem)*{instr_elem} :: $admininstr_instr(instr_data)*{instr_data} :: CALL_admininstr(x)?{x}) + -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, start?{start}, export*{export})) + -- if (m_init = {FUNC $funcs(externval*{externval}), GLOBAL $globals(externval*{externval}), TABLE [], MEM [], ELEM [], DATA [], EXPORT []}) + -- if (f_init = {LOCAL [], MODULE m_init}) + -- if (global*{global} = GLOBAL(globaltype, instr_1*{instr_1})*{globaltype instr_1}) + -- (Step_read: `%~>%*`(`%;%*`(`%;%`(s, f_init), $admininstr_instr(instr_1)*{instr_1}), [$admininstr_val(val)]))*{instr_1 val} + -- if (elem*{elem} = `ELEM%%*%?`(reftype, instr_2*{instr_2}*{instr_2}, elemmode?{elemmode})*{elemmode instr_2 reftype}) + -- (Step_read: `%~>%*`(`%;%*`(`%;%`(s, f_init), $admininstr_instr(instr_2)*{instr_2}), [$admininstr_ref(ref)]))*{instr_2 ref}*{instr_2 ref} + -- if ((s', m) = $allocmodule(s, module, externval*{externval}, val*{val}, ref*{ref}*{ref})) + -- if (f = {LOCAL [], MODULE m}) + -- if (n_elem = |elem*{elem}|) + -- if (instr_elem*{instr_elem} = $concat_instr($runelem(elem*{elem}[i], i)^(i config + ;; 7-module.watsup:184.1-196.52 + def {expr : expr, f : frame, fa : funcaddr, functype : functype, k : nat, m : moduleinst, n : n, s : store, val^n : val^n, valtype* : valtype*, valtype_param^n : valtype^n, valtype_res^k : valtype^k} invocation(s, fa, val^n{val}) = `%;%*`(`%;%`(s, f), $admininstr_val(val)^n{val} :: [CALL_ADDR_admininstr(fa)]) + -- if (m = {FUNC [], GLOBAL [], TABLE [], MEM [], ELEM [], DATA [], EXPORT []}) + -- if (f = {LOCAL [], MODULE m}) + -- if ($funcinst(`%;%`(s, f))[fa].CODE_funcinst = `FUNC%%*%`(functype, valtype*{valtype}, expr)) + -- if (functype = `%->%`(valtype_param^n{valtype_param}, valtype_res^k{valtype_res})) + == IL Validation... == Running pass the-elimination @@ -5460,8 +6321,8 @@ syntax mem = MEMORY(memtype) ;; 1-syntax.watsup:198.1-199.31 syntax elem = `ELEM%%*%?`(reftype, expr*, elemmode?) -;; 1-syntax.watsup:200.1-201.26 -syntax data = `DATA(*)%*%?`(byte**, datamode?) +;; 1-syntax.watsup:200.1-201.23 +syntax data = `DATA%*%?`(byte*, datamode?) ;; 1-syntax.watsup:202.1-203.16 syntax start = START(funcidx) @@ -6059,8 +6920,8 @@ relation Datamode_ok: `%|-%:OK`(context, datamode) ;; 3-typing.watsup:402.1-402.73 relation Data_ok: `%|-%:OK`(context, data) ;; 3-typing.watsup:433.1-435.40 - rule _ {C : context, b** : byte**, datamode? : datamode?}: - `%|-%:OK`(C, `DATA(*)%*%?`(b*{b}*{b}, datamode?{datamode})) + rule _ {C : context, b* : byte*, datamode? : datamode?}: + `%|-%:OK`(C, `DATA%*%?`(b*{b}, datamode?{datamode})) -- (Datamode_ok: `%|-%:OK`(C, datamode))?{datamode} ;; 3-typing.watsup:405.1-405.74 @@ -6226,10 +7087,10 @@ syntax frame = {LOCAL val*, MODULE moduleinst} ;; 4-runtime.watsup:96.1-96.47 syntax state = `%;%`(store, frame) -;; 4-runtime.watsup:172.1-179.5 +;; 4-runtime.watsup:183.1-190.5 rec { -;; 4-runtime.watsup:172.1-179.5 +;; 4-runtime.watsup:183.1-190.5 syntax admininstr = | UNREACHABLE | NOP @@ -6350,87 +7211,112 @@ def funcaddr : state -> funcaddr* ;; 4-runtime.watsup:118.1-118.52 def funcinst : state -> funcinst* - ;; 4-runtime.watsup:119.1-119.31 + ;; 4-runtime.watsup:125.1-125.31 def {f : frame, s : store} funcinst(`%;%`(s, f)) = s.FUNC_store -;; 4-runtime.watsup:121.1-121.67 +;; 4-runtime.watsup:119.1-119.58 +def globalinst : state -> globalinst* + ;; 4-runtime.watsup:126.1-126.35 + def {f : frame, s : store} globalinst(`%;%`(s, f)) = s.GLOBAL_store + +;; 4-runtime.watsup:120.1-120.55 +def tableinst : state -> tableinst* + ;; 4-runtime.watsup:127.1-127.33 + def {f : frame, s : store} tableinst(`%;%`(s, f)) = s.TABLE_store + +;; 4-runtime.watsup:121.1-121.49 +def meminst : state -> meminst* + ;; 4-runtime.watsup:128.1-128.29 + def {f : frame, s : store} meminst(`%;%`(s, f)) = s.MEM_store + +;; 4-runtime.watsup:122.1-122.52 +def eleminst : state -> eleminst* + ;; 4-runtime.watsup:129.1-129.31 + def {f : frame, s : store} eleminst(`%;%`(s, f)) = s.ELEM_store + +;; 4-runtime.watsup:123.1-123.52 +def datainst : state -> datainst* + ;; 4-runtime.watsup:130.1-130.31 + def {f : frame, s : store} datainst(`%;%`(s, f)) = s.DATA_store + +;; 4-runtime.watsup:132.1-132.67 def func : (state, funcidx) -> funcinst - ;; 4-runtime.watsup:129.1-129.48 + ;; 4-runtime.watsup:140.1-140.48 def {f : frame, s : store, x : idx} func(`%;%`(s, f), x) = s.FUNC_store[f.MODULE_frame.FUNC_moduleinst[x]] -;; 4-runtime.watsup:122.1-122.69 +;; 4-runtime.watsup:133.1-133.69 def global : (state, globalidx) -> globalinst - ;; 4-runtime.watsup:130.1-130.54 + ;; 4-runtime.watsup:141.1-141.54 def {f : frame, s : store, x : idx} global(`%;%`(s, f), x) = s.GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]] -;; 4-runtime.watsup:123.1-123.68 +;; 4-runtime.watsup:134.1-134.68 def table : (state, tableidx) -> tableinst - ;; 4-runtime.watsup:131.1-131.51 + ;; 4-runtime.watsup:142.1-142.51 def {f : frame, s : store, x : idx} table(`%;%`(s, f), x) = s.TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]] -;; 4-runtime.watsup:124.1-124.66 +;; 4-runtime.watsup:135.1-135.66 def mem : (state, memidx) -> meminst - ;; 4-runtime.watsup:132.1-132.45 + ;; 4-runtime.watsup:143.1-143.45 def {f : frame, s : store, x : idx} mem(`%;%`(s, f), x) = s.MEM_store[f.MODULE_frame.MEM_moduleinst[x]] -;; 4-runtime.watsup:125.1-125.67 +;; 4-runtime.watsup:136.1-136.67 def elem : (state, tableidx) -> eleminst - ;; 4-runtime.watsup:133.1-133.48 + ;; 4-runtime.watsup:144.1-144.48 def {f : frame, s : store, x : idx} elem(`%;%`(s, f), x) = s.ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]] -;; 4-runtime.watsup:126.1-126.67 +;; 4-runtime.watsup:137.1-137.67 def data : (state, dataidx) -> datainst - ;; 4-runtime.watsup:134.1-134.48 + ;; 4-runtime.watsup:145.1-145.48 def {f : frame, s : store, x : idx} data(`%;%`(s, f), x) = s.DATA_store[f.MODULE_frame.DATA_moduleinst[x]] -;; 4-runtime.watsup:127.1-127.68 +;; 4-runtime.watsup:138.1-138.68 def local : (state, localidx) -> val - ;; 4-runtime.watsup:135.1-135.35 + ;; 4-runtime.watsup:146.1-146.35 def {f : frame, s : store, x : idx} local(`%;%`(s, f), x) = f.LOCAL_frame[x] -;; 4-runtime.watsup:138.1-138.78 +;; 4-runtime.watsup:149.1-149.78 def with_local : (state, localidx, val) -> state - ;; 4-runtime.watsup:147.1-147.52 + ;; 4-runtime.watsup:158.1-158.52 def {f : frame, s : store, v : val, x : idx} with_local(`%;%`(s, f), x, v) = `%;%`(s, f[LOCAL_frame[x] = v]) -;; 4-runtime.watsup:139.1-139.85 +;; 4-runtime.watsup:150.1-150.85 def with_global : (state, globalidx, val) -> state - ;; 4-runtime.watsup:148.1-148.77 + ;; 4-runtime.watsup:159.1-159.77 def {f : frame, s : store, v : val, x : idx} with_global(`%;%`(s, f), x, v) = `%;%`(s[GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]].VALUE_globalinst = v], f) -;; 4-runtime.watsup:140.1-140.88 +;; 4-runtime.watsup:151.1-151.88 def with_table : (state, tableidx, nat, ref) -> state - ;; 4-runtime.watsup:149.1-149.79 + ;; 4-runtime.watsup:160.1-160.79 def {f : frame, i : nat, r : ref, s : store, x : idx} with_table(`%;%`(s, f), x, i, r) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]].ELEM_tableinst[i] = r], f) -;; 4-runtime.watsup:141.1-141.84 +;; 4-runtime.watsup:152.1-152.84 def with_tableinst : (state, tableidx, tableinst) -> state - ;; 4-runtime.watsup:150.1-150.74 + ;; 4-runtime.watsup:161.1-161.74 def {f : frame, s : store, ti : tableinst, x : idx} with_tableinst(`%;%`(s, f), x, ti) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]] = ti], f) -;; 4-runtime.watsup:142.1-142.93 +;; 4-runtime.watsup:153.1-153.93 def with_mem : (state, memidx, nat, nat, byte*) -> state - ;; 4-runtime.watsup:151.1-151.82 + ;; 4-runtime.watsup:162.1-162.82 def {b* : byte*, f : frame, i : nat, j : nat, s : store, x : idx} with_mem(`%;%`(s, f), x, i, j, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]].DATA_meminst[i : j] = b*{b}], f) -;; 4-runtime.watsup:143.1-143.77 +;; 4-runtime.watsup:154.1-154.77 def with_meminst : (state, memidx, meminst) -> state - ;; 4-runtime.watsup:152.1-152.68 + ;; 4-runtime.watsup:163.1-163.68 def {f : frame, mi : meminst, s : store, x : idx} with_meminst(`%;%`(s, f), x, mi) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]] = mi], f) -;; 4-runtime.watsup:144.1-144.82 +;; 4-runtime.watsup:155.1-155.82 def with_elem : (state, elemidx, ref*) -> state - ;; 4-runtime.watsup:153.1-153.72 + ;; 4-runtime.watsup:164.1-164.72 def {f : frame, r* : ref*, s : store, x : idx} with_elem(`%;%`(s, f), x, r*{r}) = `%;%`(s[ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]].ELEM_eleminst = r*{r}], f) -;; 4-runtime.watsup:145.1-145.82 +;; 4-runtime.watsup:156.1-156.82 def with_data : (state, dataidx, byte*) -> state - ;; 4-runtime.watsup:154.1-154.72 + ;; 4-runtime.watsup:165.1-165.72 def {b* : byte*, f : frame, s : store, x : idx} with_data(`%;%`(s, f), x, b*{b}) = `%;%`(s[DATA_store[f.MODULE_frame.DATA_moduleinst[x]].DATA_datainst = b*{b}], f) -;; 4-runtime.watsup:156.1-156.63 +;; 4-runtime.watsup:167.1-167.63 def grow_table : (tableinst, nat, ref) -> tableinst? - ;; 4-runtime.watsup:159.1-163.36 + ;; 4-runtime.watsup:170.1-174.36 def {i : nat, i' : nat, j : nat, n : n, r : ref, r'* : ref*, rt : reftype, ti : tableinst, ti' : tableinst} grow_table(ti, n, r) = ?(ti') -- if (ti = {TYPE `%%`(`[%..%]`(i, j), rt), ELEM r'*{r'}}) -- if (i' = (|r'*{r'}| + n)) @@ -6438,9 +7324,9 @@ def grow_table : (tableinst, nat, ref) -> tableinst? -- Tabletype_ok: `|-%:OK`(ti'.TYPE_tableinst) def {x : (tableinst, nat, ref)} grow_table(x) = ?() -;; 4-runtime.watsup:157.1-157.55 +;; 4-runtime.watsup:168.1-168.55 def grow_memory : (meminst, nat) -> meminst? - ;; 4-runtime.watsup:164.1-168.34 + ;; 4-runtime.watsup:175.1-179.34 def {b* : byte*, i : nat, i' : nat, j : nat, mi : meminst, mi' : meminst, n : n} grow_memory(mi, n) = ?(mi') -- if (mi = {TYPE `%I8`(`[%..%]`(i, j)), DATA b*{b}}) -- if (i' = ((|b*{b}| / (64 * $Ki)) + n)) @@ -6448,10 +7334,10 @@ def grow_memory : (meminst, nat) -> meminst? -- Memtype_ok: `|-%:OK`(mi'.TYPE_meminst) def {x : (meminst, nat)} grow_memory(x) = ?() -;; 4-runtime.watsup:181.1-184.21 +;; 4-runtime.watsup:192.1-195.21 rec { -;; 4-runtime.watsup:181.1-184.21 +;; 4-runtime.watsup:192.1-195.21 syntax E = | _HOLE | _SEQ(val*, E, instr*) @@ -6901,6 +7787,268 @@ relation Step: `%~>%`(config, config) rule data.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [DATA.DROP_admininstr(x)]), `%;%*`($with_data(z, x, []), [])) +;; 7-module.watsup:4.1-4.35 +rec { + +;; 7-module.watsup:4.1-4.35 +def funcs : externval* -> funcaddr* + ;; 7-module.watsup:5.1-5.30 + def funcs([]) = [] + ;; 7-module.watsup:6.1-6.59 + def {externval'* : externval*, fa : funcaddr} funcs([FUNC_externval(fa)] :: externval'*{externval'}) = [fa] :: $funcs(externval'*{externval'}) + ;; 7-module.watsup:7.1-8.15 + def {externval : externval, externval'* : externval*} funcs([externval] :: externval'*{externval'}) = $funcs(externval'*{externval'}) + -- otherwise +} + +;; 7-module.watsup:10.1-10.39 +rec { + +;; 7-module.watsup:10.1-10.39 +def globals : externval* -> globaladdr* + ;; 7-module.watsup:11.1-11.32 + def globals([]) = [] + ;; 7-module.watsup:12.1-12.65 + def {externval'* : externval*, ga : globaladdr} globals([GLOBAL_externval(ga)] :: externval'*{externval'}) = [ga] :: $globals(externval'*{externval'}) + ;; 7-module.watsup:13.1-14.15 + def {externval : externval, externval'* : externval*} globals([externval] :: externval'*{externval'}) = $globals(externval'*{externval'}) + -- otherwise +} + +;; 7-module.watsup:16.1-16.37 +rec { + +;; 7-module.watsup:16.1-16.37 +def tables : externval* -> tableaddr* + ;; 7-module.watsup:17.1-17.31 + def tables([]) = [] + ;; 7-module.watsup:18.1-18.62 + def {externval'* : externval*, ta : tableaddr} tables([TABLE_externval(ta)] :: externval'*{externval'}) = [ta] :: $tables(externval'*{externval'}) + ;; 7-module.watsup:19.1-20.15 + def {externval : externval, externval'* : externval*} tables([externval] :: externval'*{externval'}) = $tables(externval'*{externval'}) + -- otherwise +} + +;; 7-module.watsup:22.1-22.33 +rec { + +;; 7-module.watsup:22.1-22.33 +def mems : externval* -> memaddr* + ;; 7-module.watsup:23.1-23.29 + def mems([]) = [] + ;; 7-module.watsup:24.1-24.56 + def {externval'* : externval*, ma : memaddr} mems([MEM_externval(ma)] :: externval'*{externval'}) = [ma] :: $mems(externval'*{externval'}) + ;; 7-module.watsup:25.1-26.15 + def {externval : externval, externval'* : externval*} mems([externval] :: externval'*{externval'}) = $mems(externval'*{externval'}) + -- otherwise +} + +;; 7-module.watsup:29.1-29.83 +def instexport : (funcaddr*, globaladdr*, tableaddr*, memaddr*, export) -> exportinst + ;; 7-module.watsup:30.1-30.95 + def {fa* : funcaddr*, ga* : globaladdr*, ma* : memaddr*, name : name, ta* : tableaddr*, x : idx} instexport(fa*{fa}, ga*{ga}, ta*{ta}, ma*{ma}, EXPORT(name, FUNC_externuse(x))) = {NAME name, VALUE FUNC_externval(fa*{fa}[x])} + ;; 7-module.watsup:31.1-31.99 + def {fa* : funcaddr*, ga* : globaladdr*, ma* : memaddr*, name : name, ta* : tableaddr*, x : idx} instexport(fa*{fa}, ga*{ga}, ta*{ta}, ma*{ma}, EXPORT(name, GLOBAL_externuse(x))) = {NAME name, VALUE GLOBAL_externval(ga*{ga}[x])} + ;; 7-module.watsup:32.1-32.97 + def {fa* : funcaddr*, ga* : globaladdr*, ma* : memaddr*, name : name, ta* : tableaddr*, x : idx} instexport(fa*{fa}, ga*{ga}, ta*{ta}, ma*{ma}, EXPORT(name, TABLE_externuse(x))) = {NAME name, VALUE TABLE_externval(ta*{ta}[x])} + ;; 7-module.watsup:33.1-33.93 + def {fa* : funcaddr*, ga* : globaladdr*, ma* : memaddr*, name : name, ta* : tableaddr*, x : idx} instexport(fa*{fa}, ga*{ga}, ta*{ta}, ma*{ma}, EXPORT(name, MEM_externuse(x))) = {NAME name, VALUE MEM_externval(ma*{ma}[x])} + +;; 7-module.watsup:36.1-36.60 +def allocfunc : (store, moduleinst, func) -> (store, funcaddr) + ;; 7-module.watsup:37.1-38.37 + def {fi : funcinst, func : func, m : moduleinst, s : store} allocfunc(s, m, func) = (s[FUNC_store =.. [fi]], |s.FUNC_store|) + -- if (fi = {MODULE m, CODE func}) + +;; 7-module.watsup:40.1-40.63 +rec { + +;; 7-module.watsup:40.1-40.63 +def allocfuncs : (store, moduleinst, func*) -> (store, funcaddr*) + ;; 7-module.watsup:41.1-41.46 + def {m : moduleinst, s : store} allocfuncs(s, m, []) = (s, []) + ;; 7-module.watsup:42.1-44.50 + def {fa : funcaddr, fa'* : funcaddr*, func : func, func'* : func*, m : moduleinst, s : store, s_1 : store, s_2 : store} allocfuncs(s, m, [func] :: func'*{func'}) = (s_2, [fa] :: fa'*{fa'}) + -- if ((s_1, fa) = $allocfunc(s, m, func)) + -- if ((s_2, fa'*{fa'}) = $allocfuncs(s_1, m, func'*{func'})) +} + +;; 7-module.watsup:46.1-46.63 +def allocglobal : (store, globaltype, val) -> (store, globaladdr) + ;; 7-module.watsup:47.1-48.44 + def {gi : globalinst, globaltype : globaltype, s : store, val : val} allocglobal(s, globaltype, val) = (s[GLOBAL_store =.. [gi]], |s.GLOBAL_store|) + -- if (gi = {TYPE globaltype, VALUE val}) + +;; 7-module.watsup:50.1-50.67 +rec { + +;; 7-module.watsup:50.1-50.67 +def allocglobals : (store, globaltype*, val*) -> (store, globaladdr*) + ;; 7-module.watsup:51.1-51.54 + def {s : store} allocglobals(s, [], []) = (s, []) + ;; 7-module.watsup:52.1-54.62 + def {ga : globaladdr, ga'* : globaladdr*, globaltype : globaltype, globaltype'* : globaltype*, s : store, s_1 : store, s_2 : store, val : val, val'* : val*} allocglobals(s, [globaltype] :: globaltype'*{globaltype'}, [val] :: val'*{val'}) = (s_2, [ga] :: ga'*{ga'}) + -- if ((s_1, ga) = $allocglobal(s, globaltype, val)) + -- if ((s_2, ga'*{ga'}) = $allocglobals(s_1, globaltype'*{globaltype'}, val'*{val'})) +} + +;; 7-module.watsup:56.1-56.55 +def alloctable : (store, tabletype) -> (store, tableaddr) + ;; 7-module.watsup:57.1-58.59 + def {i : nat, j : nat, rt : reftype, s : store, ti : tableinst} alloctable(s, `%%`(`[%..%]`(i, j), rt)) = (s[TABLE_store =.. [ti]], |s.TABLE_store|) + -- if (ti = {TYPE `%%`(`[%..%]`(i, j), rt), ELEM REF.NULL_ref(rt)^i{}}) + +;; 7-module.watsup:60.1-60.58 +rec { + +;; 7-module.watsup:60.1-60.58 +def alloctables : (store, tabletype*) -> (store, tableaddr*) + ;; 7-module.watsup:61.1-61.44 + def {s : store} alloctables(s, []) = (s, []) + ;; 7-module.watsup:62.1-64.53 + def {s : store, s_1 : store, s_2 : store, ta : tableaddr, ta'* : tableaddr*, tabletype : tabletype, tabletype'* : tabletype*} alloctables(s, [tabletype] :: tabletype'*{tabletype'}) = (s_2, [ta] :: ta'*{ta'}) + -- if ((s_1, ta) = $alloctable(s, tabletype)) + -- if ((s_2, ta'*{ta'}) = $alloctables(s_1, tabletype'*{tabletype'})) +} + +;; 7-module.watsup:66.1-66.49 +def allocmem : (store, memtype) -> (store, memaddr) + ;; 7-module.watsup:67.1-68.62 + def {i : nat, j : nat, mi : meminst, s : store} allocmem(s, `%I8`(`[%..%]`(i, j))) = (s[MEM_store =.. [mi]], |s.MEM_store|) + -- if (mi = {TYPE `%I8`(`[%..%]`(i, j)), DATA 0^((i * 64) * $Ki){}}) + +;; 7-module.watsup:70.1-70.52 +rec { + +;; 7-module.watsup:70.1-70.52 +def allocmems : (store, memtype*) -> (store, memaddr*) + ;; 7-module.watsup:71.1-71.42 + def {s : store} allocmems(s, []) = (s, []) + ;; 7-module.watsup:72.1-74.49 + def {ma : memaddr, ma'* : memaddr*, memtype : memtype, memtype'* : memtype*, s : store, s_1 : store, s_2 : store} allocmems(s, [memtype] :: memtype'*{memtype'}) = (s_2, [ma] :: ma'*{ma'}) + -- if ((s_1, ma) = $allocmem(s, memtype)) + -- if ((s_2, ma'*{ma'}) = $allocmems(s_1, memtype'*{memtype'})) +} + +;; 7-module.watsup:76.1-76.57 +def allocelem : (store, reftype, ref*) -> (store, elemaddr) + ;; 7-module.watsup:77.1-78.36 + def {ei : eleminst, ref* : ref*, rt : reftype, s : store} allocelem(s, rt, ref*{ref}) = (s[ELEM_store =.. [ei]], |s.ELEM_store|) + -- if (ei = {TYPE rt, ELEM ref*{ref}}) + +;; 7-module.watsup:80.1-80.63 +rec { + +;; 7-module.watsup:80.1-80.63 +def allocelems : (store, reftype*, ref**) -> (store, elemaddr*) + ;; 7-module.watsup:81.1-81.52 + def {s : store} allocelems(s, [], []) = (s, []) + ;; 7-module.watsup:82.1-84.53 + def {ea : elemaddr, ea'* : elemaddr*, ref* : ref*, ref'** : ref**, rt : reftype, rt'* : reftype*, s : store, s_1 : store, s_2 : store} allocelems(s, [rt] :: rt'*{rt'}, [ref]*{ref} :: ref'*{ref'}*{ref'}) = (s_2, [ea] :: ea'*{ea'}) + -- if ((s_1, ea) = $allocelem(s, rt, ref*{ref})) + -- if ((s_2, ea'*{ea'}) = $allocelems(s_2, rt'*{rt'}, ref'*{ref'}*{ref'})) +} + +;; 7-module.watsup:86.1-86.49 +def allocdata : (store, byte*) -> (store, dataaddr) + ;; 7-module.watsup:87.1-88.28 + def {byte* : byte*, di : datainst, s : store} allocdata(s, byte*{byte}) = (s[DATA_store =.. [di]], |s.DATA_store|) + -- if (di = {DATA byte*{byte}}) + +;; 7-module.watsup:90.1-90.52 +rec { + +;; 7-module.watsup:90.1-90.52 +def allocdatas : (store, byte**) -> (store, dataaddr*) + ;; 7-module.watsup:91.1-91.43 + def {s : store} allocdatas(s, []) = (s, []) + ;; 7-module.watsup:92.1-94.48 + def {byte* : byte*, byte'** : byte**, da : dataaddr, da'* : dataaddr*, s : store, s_1 : store, s_2 : store} allocdatas(s, [byte]*{byte} :: byte'*{byte'}*{byte'}) = (s_2, [da] :: da'*{da'}) + -- if ((s_1, da) = $allocdata(s, byte*{byte})) + -- if ((s_2, da'*{da'}) = $allocdatas(s_1, byte'*{byte'}*{byte'})) +} + +;; 7-module.watsup:97.1-97.81 +def allocmodule : (store, module, externval*, val*, ref**) -> (store, moduleinst) + ;; 7-module.watsup:98.1-135.54 + def {byte*^n_data : byte*^n_data, da* : dataaddr*, datamode?^n_data : datamode?^n_data, ea* : elemaddr*, elemmode?^n_elem : elemmode?^n_elem, export* : export*, expr_1^n_global : expr^n_global, expr_2*^n_elem : expr*^n_elem, externval* : externval*, fa* : funcaddr*, fa_ex* : funcaddr*, func^n_func : func^n_func, ga* : globaladdr*, ga_ex* : globaladdr*, globaltype^n_global : globaltype^n_global, i_data^n_data : nat^n_data, i_elem^n_elem : nat^n_elem, i_func^n_func : nat^n_func, i_global^n_global : nat^n_global, i_mem^n_mem : nat^n_mem, i_table^n_table : nat^n_table, import* : import*, m : moduleinst, ma* : memaddr*, ma_ex* : memaddr*, memtype^n_mem : memtype^n_mem, module : module, n_data : n, n_elem : n, n_func : n, n_global : n, n_mem : n, n_table : n, ref** : ref**, rt^n_elem : reftype^n_elem, s : store, s_1 : store, s_2 : store, s_3 : store, s_4 : store, s_5 : store, s_6 : store, start? : start?, ta* : tableaddr*, ta_ex* : tableaddr*, tabletype^n_table : tabletype^n_table, val* : val*, xi* : exportinst*} allocmodule(s, module, externval*{externval}, val*{val}, ref*{ref}*{ref}) = (s_6, m) + -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func^n_func{func}, GLOBAL(globaltype, expr_1)^n_global{expr_1 globaltype}, TABLE(tabletype)^n_table{tabletype}, MEMORY(memtype)^n_mem{memtype}, `ELEM%%*%?`(rt, expr_2*{expr_2}, elemmode?{elemmode})^n_elem{elemmode expr_2 rt}, `DATA%*%?`(byte*{byte}, datamode?{datamode})^n_data{byte datamode}, start?{start}, export*{export})) + -- if (fa_ex*{fa_ex} = $funcs(externval*{externval})) + -- if (ga_ex*{ga_ex} = $globals(externval*{externval})) + -- if (ta_ex*{ta_ex} = $tables(externval*{externval})) + -- if (ma_ex*{ma_ex} = $mems(externval*{externval})) + -- if (fa*{fa} = (|s.FUNC_store| + i_func)^(i_func instr* + ;; 7-module.watsup:139.1-139.46 + def {expr* : expr*, i : nat, reftype : reftype} runelem(`ELEM%%*%?`(reftype, expr*{expr}, ?()), i) = [] + ;; 7-module.watsup:140.1-140.62 + def {expr* : expr*, i : nat, reftype : reftype} runelem(`ELEM%%*%?`(reftype, expr*{expr}, ?(DECLARE_elemmode)), i) = [ELEM.DROP_instr(i)] + ;; 7-module.watsup:141.1-143.20 + def {expr* : expr*, i : nat, instr* : instr*, n : n, reftype : reftype, x : idx} runelem(`ELEM%%*%?`(reftype, expr*{expr}, ?(TABLE_elemmode(x, instr*{instr}))), i) = instr*{instr} :: [CONST_instr(I32_numtype, 0) CONST_instr(I32_numtype, n) TABLE.INIT_instr(x, i) ELEM.DROP_instr(i)] + -- if (n = |expr*{expr}|) + +;; 7-module.watsup:145.1-145.33 +def rundata : (data, idx) -> instr* + ;; 7-module.watsup:146.1-146.38 + def {byte* : byte*, i : nat} rundata(`DATA%*%?`(byte*{byte}, ?()), i) = [] + ;; 7-module.watsup:147.1-149.20 + def {byte* : byte*, i : nat, instr* : instr*, n : n} rundata(`DATA%*%?`(byte*{byte}, ?(MEMORY_datamode(0, instr*{instr}))), i) = instr*{instr} :: [CONST_instr(I32_numtype, 0) CONST_instr(I32_numtype, n) MEMORY.INIT_instr(i) DATA.DROP_instr(i)] + -- if (n = |byte*{byte}|) + +;; 7-module.watsup:152.1-152.36 +rec { + +;; 7-module.watsup:152.1-152.36 +def concat_instr : instr** -> instr* + ;; 7-module.watsup:153.1-153.37 + def concat_instr([]) = [] + ;; 7-module.watsup:154.1-154.68 + def {instr* : instr*, instr'** : instr**} concat_instr([instr]*{instr} :: instr'*{instr'}*{instr'}) = instr*{instr} :: $concat_instr(instr'*{instr'}*{instr'}) +} + +;; 7-module.watsup:157.1-157.55 +def instantiation : (store, module, externval*) -> config + ;; 7-module.watsup:158.1-180.28 + def {data* : data*, elem* : elem*, elemmode?* : elemmode?*, export* : export*, externval* : externval*, f : frame, f_init : frame, func* : func*, global* : global*, globaltype* : globaltype*, i^n_elem : nat^n_elem, import* : import*, instr_1** : instr**, instr_2*** : instr***, instr_data* : instr*, instr_elem* : instr*, j^n_data : nat^n_data, m : moduleinst, m_init : moduleinst, mem* : mem*, module : module, n_data : n, n_elem : n, ref** : ref**, reftype* : reftype*, s : store, s' : store, start? : start?, table* : table*, val* : val*, x? : idx?} instantiation(s, module, externval*{externval}) = `%;%*`(`%;%`(s', f), $admininstr_instr(instr_elem)*{instr_elem} :: $admininstr_instr(instr_data)*{instr_data} :: CALL_admininstr(x)?{x}) + -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, start?{start}, export*{export})) + -- if (m_init = {FUNC $funcs(externval*{externval}), GLOBAL $globals(externval*{externval}), TABLE [], MEM [], ELEM [], DATA [], EXPORT []}) + -- if (f_init = {LOCAL [], MODULE m_init}) + -- if (global*{global} = GLOBAL(globaltype, instr_1*{instr_1})*{globaltype instr_1}) + -- (Step_read: `%~>%*`(`%;%*`(`%;%`(s, f_init), $admininstr_instr(instr_1)*{instr_1}), [$admininstr_val(val)]))*{instr_1 val} + -- if (elem*{elem} = `ELEM%%*%?`(reftype, instr_2*{instr_2}*{instr_2}, elemmode?{elemmode})*{elemmode instr_2 reftype}) + -- (Step_read: `%~>%*`(`%;%*`(`%;%`(s, f_init), $admininstr_instr(instr_2)*{instr_2}), [$admininstr_ref(ref)]))*{instr_2 ref}*{instr_2 ref} + -- if ((s', m) = $allocmodule(s, module, externval*{externval}, val*{val}, ref*{ref}*{ref})) + -- if (f = {LOCAL [], MODULE m}) + -- if (n_elem = |elem*{elem}|) + -- if (instr_elem*{instr_elem} = $concat_instr($runelem(elem*{elem}[i], i)^(i config + ;; 7-module.watsup:184.1-196.52 + def {expr : expr, f : frame, fa : funcaddr, functype : functype, k : nat, m : moduleinst, n : n, s : store, val^n : val^n, valtype* : valtype*, valtype_param^n : valtype^n, valtype_res^k : valtype^k} invocation(s, fa, val^n{val}) = `%;%*`(`%;%`(s, f), $admininstr_val(val)^n{val} :: [CALL_ADDR_admininstr(fa)]) + -- if (m = {FUNC [], GLOBAL [], TABLE [], MEM [], ELEM [], DATA [], EXPORT []}) + -- if (f = {LOCAL [], MODULE m}) + -- if ($funcinst(`%;%`(s, f))[fa].CODE_funcinst = `FUNC%%*%`(functype, valtype*{valtype}, expr)) + -- if (functype = `%->%`(valtype_param^n{valtype_param}, valtype_res^k{valtype_res})) + == IL Validation... == Running pass wildcards @@ -7224,8 +8372,8 @@ syntax mem = MEMORY(memtype) ;; 1-syntax.watsup:198.1-199.31 syntax elem = `ELEM%%*%?`(reftype, expr*, elemmode?) -;; 1-syntax.watsup:200.1-201.26 -syntax data = `DATA(*)%*%?`(byte**, datamode?) +;; 1-syntax.watsup:200.1-201.23 +syntax data = `DATA%*%?`(byte*, datamode?) ;; 1-syntax.watsup:202.1-203.16 syntax start = START(funcidx) @@ -7823,8 +8971,8 @@ relation Datamode_ok: `%|-%:OK`(context, datamode) ;; 3-typing.watsup:402.1-402.73 relation Data_ok: `%|-%:OK`(context, data) ;; 3-typing.watsup:433.1-435.40 - rule _ {C : context, b** : byte**, datamode? : datamode?}: - `%|-%:OK`(C, `DATA(*)%*%?`(b*{b}*{b}, datamode?{datamode})) + rule _ {C : context, b* : byte*, datamode? : datamode?}: + `%|-%:OK`(C, `DATA%*%?`(b*{b}, datamode?{datamode})) -- (Datamode_ok: `%|-%:OK`(C, datamode))?{datamode} ;; 3-typing.watsup:405.1-405.74 @@ -7990,10 +9138,10 @@ syntax frame = {LOCAL val*, MODULE moduleinst} ;; 4-runtime.watsup:96.1-96.47 syntax state = `%;%`(store, frame) -;; 4-runtime.watsup:172.1-179.5 +;; 4-runtime.watsup:183.1-190.5 rec { -;; 4-runtime.watsup:172.1-179.5 +;; 4-runtime.watsup:183.1-190.5 syntax admininstr = | UNREACHABLE | NOP @@ -8114,87 +9262,112 @@ def funcaddr : state -> funcaddr* ;; 4-runtime.watsup:118.1-118.52 def funcinst : state -> funcinst* - ;; 4-runtime.watsup:119.1-119.31 + ;; 4-runtime.watsup:125.1-125.31 def {f : frame, s : store} funcinst(`%;%`(s, f)) = s.FUNC_store -;; 4-runtime.watsup:121.1-121.67 +;; 4-runtime.watsup:119.1-119.58 +def globalinst : state -> globalinst* + ;; 4-runtime.watsup:126.1-126.35 + def {f : frame, s : store} globalinst(`%;%`(s, f)) = s.GLOBAL_store + +;; 4-runtime.watsup:120.1-120.55 +def tableinst : state -> tableinst* + ;; 4-runtime.watsup:127.1-127.33 + def {f : frame, s : store} tableinst(`%;%`(s, f)) = s.TABLE_store + +;; 4-runtime.watsup:121.1-121.49 +def meminst : state -> meminst* + ;; 4-runtime.watsup:128.1-128.29 + def {f : frame, s : store} meminst(`%;%`(s, f)) = s.MEM_store + +;; 4-runtime.watsup:122.1-122.52 +def eleminst : state -> eleminst* + ;; 4-runtime.watsup:129.1-129.31 + def {f : frame, s : store} eleminst(`%;%`(s, f)) = s.ELEM_store + +;; 4-runtime.watsup:123.1-123.52 +def datainst : state -> datainst* + ;; 4-runtime.watsup:130.1-130.31 + def {f : frame, s : store} datainst(`%;%`(s, f)) = s.DATA_store + +;; 4-runtime.watsup:132.1-132.67 def func : (state, funcidx) -> funcinst - ;; 4-runtime.watsup:129.1-129.48 + ;; 4-runtime.watsup:140.1-140.48 def {f : frame, s : store, x : idx} func(`%;%`(s, f), x) = s.FUNC_store[f.MODULE_frame.FUNC_moduleinst[x]] -;; 4-runtime.watsup:122.1-122.69 +;; 4-runtime.watsup:133.1-133.69 def global : (state, globalidx) -> globalinst - ;; 4-runtime.watsup:130.1-130.54 + ;; 4-runtime.watsup:141.1-141.54 def {f : frame, s : store, x : idx} global(`%;%`(s, f), x) = s.GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]] -;; 4-runtime.watsup:123.1-123.68 +;; 4-runtime.watsup:134.1-134.68 def table : (state, tableidx) -> tableinst - ;; 4-runtime.watsup:131.1-131.51 + ;; 4-runtime.watsup:142.1-142.51 def {f : frame, s : store, x : idx} table(`%;%`(s, f), x) = s.TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]] -;; 4-runtime.watsup:124.1-124.66 +;; 4-runtime.watsup:135.1-135.66 def mem : (state, memidx) -> meminst - ;; 4-runtime.watsup:132.1-132.45 + ;; 4-runtime.watsup:143.1-143.45 def {f : frame, s : store, x : idx} mem(`%;%`(s, f), x) = s.MEM_store[f.MODULE_frame.MEM_moduleinst[x]] -;; 4-runtime.watsup:125.1-125.67 +;; 4-runtime.watsup:136.1-136.67 def elem : (state, tableidx) -> eleminst - ;; 4-runtime.watsup:133.1-133.48 + ;; 4-runtime.watsup:144.1-144.48 def {f : frame, s : store, x : idx} elem(`%;%`(s, f), x) = s.ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]] -;; 4-runtime.watsup:126.1-126.67 +;; 4-runtime.watsup:137.1-137.67 def data : (state, dataidx) -> datainst - ;; 4-runtime.watsup:134.1-134.48 + ;; 4-runtime.watsup:145.1-145.48 def {f : frame, s : store, x : idx} data(`%;%`(s, f), x) = s.DATA_store[f.MODULE_frame.DATA_moduleinst[x]] -;; 4-runtime.watsup:127.1-127.68 +;; 4-runtime.watsup:138.1-138.68 def local : (state, localidx) -> val - ;; 4-runtime.watsup:135.1-135.35 + ;; 4-runtime.watsup:146.1-146.35 def {f : frame, s : store, x : idx} local(`%;%`(s, f), x) = f.LOCAL_frame[x] -;; 4-runtime.watsup:138.1-138.78 +;; 4-runtime.watsup:149.1-149.78 def with_local : (state, localidx, val) -> state - ;; 4-runtime.watsup:147.1-147.52 + ;; 4-runtime.watsup:158.1-158.52 def {f : frame, s : store, v : val, x : idx} with_local(`%;%`(s, f), x, v) = `%;%`(s, f[LOCAL_frame[x] = v]) -;; 4-runtime.watsup:139.1-139.85 +;; 4-runtime.watsup:150.1-150.85 def with_global : (state, globalidx, val) -> state - ;; 4-runtime.watsup:148.1-148.77 + ;; 4-runtime.watsup:159.1-159.77 def {f : frame, s : store, v : val, x : idx} with_global(`%;%`(s, f), x, v) = `%;%`(s[GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]].VALUE_globalinst = v], f) -;; 4-runtime.watsup:140.1-140.88 +;; 4-runtime.watsup:151.1-151.88 def with_table : (state, tableidx, nat, ref) -> state - ;; 4-runtime.watsup:149.1-149.79 + ;; 4-runtime.watsup:160.1-160.79 def {f : frame, i : nat, r : ref, s : store, x : idx} with_table(`%;%`(s, f), x, i, r) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]].ELEM_tableinst[i] = r], f) -;; 4-runtime.watsup:141.1-141.84 +;; 4-runtime.watsup:152.1-152.84 def with_tableinst : (state, tableidx, tableinst) -> state - ;; 4-runtime.watsup:150.1-150.74 + ;; 4-runtime.watsup:161.1-161.74 def {f : frame, s : store, ti : tableinst, x : idx} with_tableinst(`%;%`(s, f), x, ti) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]] = ti], f) -;; 4-runtime.watsup:142.1-142.93 +;; 4-runtime.watsup:153.1-153.93 def with_mem : (state, memidx, nat, nat, byte*) -> state - ;; 4-runtime.watsup:151.1-151.82 + ;; 4-runtime.watsup:162.1-162.82 def {b* : byte*, f : frame, i : nat, j : nat, s : store, x : idx} with_mem(`%;%`(s, f), x, i, j, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]].DATA_meminst[i : j] = b*{b}], f) -;; 4-runtime.watsup:143.1-143.77 +;; 4-runtime.watsup:154.1-154.77 def with_meminst : (state, memidx, meminst) -> state - ;; 4-runtime.watsup:152.1-152.68 + ;; 4-runtime.watsup:163.1-163.68 def {f : frame, mi : meminst, s : store, x : idx} with_meminst(`%;%`(s, f), x, mi) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]] = mi], f) -;; 4-runtime.watsup:144.1-144.82 +;; 4-runtime.watsup:155.1-155.82 def with_elem : (state, elemidx, ref*) -> state - ;; 4-runtime.watsup:153.1-153.72 + ;; 4-runtime.watsup:164.1-164.72 def {f : frame, r* : ref*, s : store, x : idx} with_elem(`%;%`(s, f), x, r*{r}) = `%;%`(s[ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]].ELEM_eleminst = r*{r}], f) -;; 4-runtime.watsup:145.1-145.82 +;; 4-runtime.watsup:156.1-156.82 def with_data : (state, dataidx, byte*) -> state - ;; 4-runtime.watsup:154.1-154.72 + ;; 4-runtime.watsup:165.1-165.72 def {b* : byte*, f : frame, s : store, x : idx} with_data(`%;%`(s, f), x, b*{b}) = `%;%`(s[DATA_store[f.MODULE_frame.DATA_moduleinst[x]].DATA_datainst = b*{b}], f) -;; 4-runtime.watsup:156.1-156.63 +;; 4-runtime.watsup:167.1-167.63 def grow_table : (tableinst, nat, ref) -> tableinst? - ;; 4-runtime.watsup:159.1-163.36 + ;; 4-runtime.watsup:170.1-174.36 def {i : nat, i' : nat, j : nat, n : n, r : ref, r'* : ref*, rt : reftype, ti : tableinst, ti' : tableinst} grow_table(ti, n, r) = ?(ti') -- if (ti = {TYPE `%%`(`[%..%]`(i, j), rt), ELEM r'*{r'}}) -- if (i' = (|r'*{r'}| + n)) @@ -8202,9 +9375,9 @@ def grow_table : (tableinst, nat, ref) -> tableinst? -- Tabletype_ok: `|-%:OK`(ti'.TYPE_tableinst) def {x : (tableinst, nat, ref)} grow_table(x) = ?() -;; 4-runtime.watsup:157.1-157.55 +;; 4-runtime.watsup:168.1-168.55 def grow_memory : (meminst, nat) -> meminst? - ;; 4-runtime.watsup:164.1-168.34 + ;; 4-runtime.watsup:175.1-179.34 def {b* : byte*, i : nat, i' : nat, j : nat, mi : meminst, mi' : meminst, n : n} grow_memory(mi, n) = ?(mi') -- if (mi = {TYPE `%I8`(`[%..%]`(i, j)), DATA b*{b}}) -- if (i' = ((|b*{b}| / (64 * $Ki)) + n)) @@ -8212,10 +9385,10 @@ def grow_memory : (meminst, nat) -> meminst? -- Memtype_ok: `|-%:OK`(mi'.TYPE_meminst) def {x : (meminst, nat)} grow_memory(x) = ?() -;; 4-runtime.watsup:181.1-184.21 +;; 4-runtime.watsup:192.1-195.21 rec { -;; 4-runtime.watsup:181.1-184.21 +;; 4-runtime.watsup:192.1-195.21 syntax E = | _HOLE | _SEQ(val*, E, instr*) @@ -8665,6 +9838,268 @@ relation Step: `%~>%`(config, config) rule data.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [DATA.DROP_admininstr(x)]), `%;%*`($with_data(z, x, []), [])) +;; 7-module.watsup:4.1-4.35 +rec { + +;; 7-module.watsup:4.1-4.35 +def funcs : externval* -> funcaddr* + ;; 7-module.watsup:5.1-5.30 + def funcs([]) = [] + ;; 7-module.watsup:6.1-6.59 + def {externval'* : externval*, fa : funcaddr} funcs([FUNC_externval(fa)] :: externval'*{externval'}) = [fa] :: $funcs(externval'*{externval'}) + ;; 7-module.watsup:7.1-8.15 + def {externval : externval, externval'* : externval*} funcs([externval] :: externval'*{externval'}) = $funcs(externval'*{externval'}) + -- otherwise +} + +;; 7-module.watsup:10.1-10.39 +rec { + +;; 7-module.watsup:10.1-10.39 +def globals : externval* -> globaladdr* + ;; 7-module.watsup:11.1-11.32 + def globals([]) = [] + ;; 7-module.watsup:12.1-12.65 + def {externval'* : externval*, ga : globaladdr} globals([GLOBAL_externval(ga)] :: externval'*{externval'}) = [ga] :: $globals(externval'*{externval'}) + ;; 7-module.watsup:13.1-14.15 + def {externval : externval, externval'* : externval*} globals([externval] :: externval'*{externval'}) = $globals(externval'*{externval'}) + -- otherwise +} + +;; 7-module.watsup:16.1-16.37 +rec { + +;; 7-module.watsup:16.1-16.37 +def tables : externval* -> tableaddr* + ;; 7-module.watsup:17.1-17.31 + def tables([]) = [] + ;; 7-module.watsup:18.1-18.62 + def {externval'* : externval*, ta : tableaddr} tables([TABLE_externval(ta)] :: externval'*{externval'}) = [ta] :: $tables(externval'*{externval'}) + ;; 7-module.watsup:19.1-20.15 + def {externval : externval, externval'* : externval*} tables([externval] :: externval'*{externval'}) = $tables(externval'*{externval'}) + -- otherwise +} + +;; 7-module.watsup:22.1-22.33 +rec { + +;; 7-module.watsup:22.1-22.33 +def mems : externval* -> memaddr* + ;; 7-module.watsup:23.1-23.29 + def mems([]) = [] + ;; 7-module.watsup:24.1-24.56 + def {externval'* : externval*, ma : memaddr} mems([MEM_externval(ma)] :: externval'*{externval'}) = [ma] :: $mems(externval'*{externval'}) + ;; 7-module.watsup:25.1-26.15 + def {externval : externval, externval'* : externval*} mems([externval] :: externval'*{externval'}) = $mems(externval'*{externval'}) + -- otherwise +} + +;; 7-module.watsup:29.1-29.83 +def instexport : (funcaddr*, globaladdr*, tableaddr*, memaddr*, export) -> exportinst + ;; 7-module.watsup:30.1-30.95 + def {fa* : funcaddr*, ga* : globaladdr*, ma* : memaddr*, name : name, ta* : tableaddr*, x : idx} instexport(fa*{fa}, ga*{ga}, ta*{ta}, ma*{ma}, EXPORT(name, FUNC_externuse(x))) = {NAME name, VALUE FUNC_externval(fa*{fa}[x])} + ;; 7-module.watsup:31.1-31.99 + def {fa* : funcaddr*, ga* : globaladdr*, ma* : memaddr*, name : name, ta* : tableaddr*, x : idx} instexport(fa*{fa}, ga*{ga}, ta*{ta}, ma*{ma}, EXPORT(name, GLOBAL_externuse(x))) = {NAME name, VALUE GLOBAL_externval(ga*{ga}[x])} + ;; 7-module.watsup:32.1-32.97 + def {fa* : funcaddr*, ga* : globaladdr*, ma* : memaddr*, name : name, ta* : tableaddr*, x : idx} instexport(fa*{fa}, ga*{ga}, ta*{ta}, ma*{ma}, EXPORT(name, TABLE_externuse(x))) = {NAME name, VALUE TABLE_externval(ta*{ta}[x])} + ;; 7-module.watsup:33.1-33.93 + def {fa* : funcaddr*, ga* : globaladdr*, ma* : memaddr*, name : name, ta* : tableaddr*, x : idx} instexport(fa*{fa}, ga*{ga}, ta*{ta}, ma*{ma}, EXPORT(name, MEM_externuse(x))) = {NAME name, VALUE MEM_externval(ma*{ma}[x])} + +;; 7-module.watsup:36.1-36.60 +def allocfunc : (store, moduleinst, func) -> (store, funcaddr) + ;; 7-module.watsup:37.1-38.37 + def {fi : funcinst, func : func, m : moduleinst, s : store} allocfunc(s, m, func) = (s[FUNC_store =.. [fi]], |s.FUNC_store|) + -- if (fi = {MODULE m, CODE func}) + +;; 7-module.watsup:40.1-40.63 +rec { + +;; 7-module.watsup:40.1-40.63 +def allocfuncs : (store, moduleinst, func*) -> (store, funcaddr*) + ;; 7-module.watsup:41.1-41.46 + def {m : moduleinst, s : store} allocfuncs(s, m, []) = (s, []) + ;; 7-module.watsup:42.1-44.50 + def {fa : funcaddr, fa'* : funcaddr*, func : func, func'* : func*, m : moduleinst, s : store, s_1 : store, s_2 : store} allocfuncs(s, m, [func] :: func'*{func'}) = (s_2, [fa] :: fa'*{fa'}) + -- if ((s_1, fa) = $allocfunc(s, m, func)) + -- if ((s_2, fa'*{fa'}) = $allocfuncs(s_1, m, func'*{func'})) +} + +;; 7-module.watsup:46.1-46.63 +def allocglobal : (store, globaltype, val) -> (store, globaladdr) + ;; 7-module.watsup:47.1-48.44 + def {gi : globalinst, globaltype : globaltype, s : store, val : val} allocglobal(s, globaltype, val) = (s[GLOBAL_store =.. [gi]], |s.GLOBAL_store|) + -- if (gi = {TYPE globaltype, VALUE val}) + +;; 7-module.watsup:50.1-50.67 +rec { + +;; 7-module.watsup:50.1-50.67 +def allocglobals : (store, globaltype*, val*) -> (store, globaladdr*) + ;; 7-module.watsup:51.1-51.54 + def {s : store} allocglobals(s, [], []) = (s, []) + ;; 7-module.watsup:52.1-54.62 + def {ga : globaladdr, ga'* : globaladdr*, globaltype : globaltype, globaltype'* : globaltype*, s : store, s_1 : store, s_2 : store, val : val, val'* : val*} allocglobals(s, [globaltype] :: globaltype'*{globaltype'}, [val] :: val'*{val'}) = (s_2, [ga] :: ga'*{ga'}) + -- if ((s_1, ga) = $allocglobal(s, globaltype, val)) + -- if ((s_2, ga'*{ga'}) = $allocglobals(s_1, globaltype'*{globaltype'}, val'*{val'})) +} + +;; 7-module.watsup:56.1-56.55 +def alloctable : (store, tabletype) -> (store, tableaddr) + ;; 7-module.watsup:57.1-58.59 + def {i : nat, j : nat, rt : reftype, s : store, ti : tableinst} alloctable(s, `%%`(`[%..%]`(i, j), rt)) = (s[TABLE_store =.. [ti]], |s.TABLE_store|) + -- if (ti = {TYPE `%%`(`[%..%]`(i, j), rt), ELEM REF.NULL_ref(rt)^i{}}) + +;; 7-module.watsup:60.1-60.58 +rec { + +;; 7-module.watsup:60.1-60.58 +def alloctables : (store, tabletype*) -> (store, tableaddr*) + ;; 7-module.watsup:61.1-61.44 + def {s : store} alloctables(s, []) = (s, []) + ;; 7-module.watsup:62.1-64.53 + def {s : store, s_1 : store, s_2 : store, ta : tableaddr, ta'* : tableaddr*, tabletype : tabletype, tabletype'* : tabletype*} alloctables(s, [tabletype] :: tabletype'*{tabletype'}) = (s_2, [ta] :: ta'*{ta'}) + -- if ((s_1, ta) = $alloctable(s, tabletype)) + -- if ((s_2, ta'*{ta'}) = $alloctables(s_1, tabletype'*{tabletype'})) +} + +;; 7-module.watsup:66.1-66.49 +def allocmem : (store, memtype) -> (store, memaddr) + ;; 7-module.watsup:67.1-68.62 + def {i : nat, j : nat, mi : meminst, s : store} allocmem(s, `%I8`(`[%..%]`(i, j))) = (s[MEM_store =.. [mi]], |s.MEM_store|) + -- if (mi = {TYPE `%I8`(`[%..%]`(i, j)), DATA 0^((i * 64) * $Ki){}}) + +;; 7-module.watsup:70.1-70.52 +rec { + +;; 7-module.watsup:70.1-70.52 +def allocmems : (store, memtype*) -> (store, memaddr*) + ;; 7-module.watsup:71.1-71.42 + def {s : store} allocmems(s, []) = (s, []) + ;; 7-module.watsup:72.1-74.49 + def {ma : memaddr, ma'* : memaddr*, memtype : memtype, memtype'* : memtype*, s : store, s_1 : store, s_2 : store} allocmems(s, [memtype] :: memtype'*{memtype'}) = (s_2, [ma] :: ma'*{ma'}) + -- if ((s_1, ma) = $allocmem(s, memtype)) + -- if ((s_2, ma'*{ma'}) = $allocmems(s_1, memtype'*{memtype'})) +} + +;; 7-module.watsup:76.1-76.57 +def allocelem : (store, reftype, ref*) -> (store, elemaddr) + ;; 7-module.watsup:77.1-78.36 + def {ei : eleminst, ref* : ref*, rt : reftype, s : store} allocelem(s, rt, ref*{ref}) = (s[ELEM_store =.. [ei]], |s.ELEM_store|) + -- if (ei = {TYPE rt, ELEM ref*{ref}}) + +;; 7-module.watsup:80.1-80.63 +rec { + +;; 7-module.watsup:80.1-80.63 +def allocelems : (store, reftype*, ref**) -> (store, elemaddr*) + ;; 7-module.watsup:81.1-81.52 + def {s : store} allocelems(s, [], []) = (s, []) + ;; 7-module.watsup:82.1-84.53 + def {ea : elemaddr, ea'* : elemaddr*, ref* : ref*, ref'** : ref**, rt : reftype, rt'* : reftype*, s : store, s_1 : store, s_2 : store} allocelems(s, [rt] :: rt'*{rt'}, [ref]*{ref} :: ref'*{ref'}*{ref'}) = (s_2, [ea] :: ea'*{ea'}) + -- if ((s_1, ea) = $allocelem(s, rt, ref*{ref})) + -- if ((s_2, ea'*{ea'}) = $allocelems(s_2, rt'*{rt'}, ref'*{ref'}*{ref'})) +} + +;; 7-module.watsup:86.1-86.49 +def allocdata : (store, byte*) -> (store, dataaddr) + ;; 7-module.watsup:87.1-88.28 + def {byte* : byte*, di : datainst, s : store} allocdata(s, byte*{byte}) = (s[DATA_store =.. [di]], |s.DATA_store|) + -- if (di = {DATA byte*{byte}}) + +;; 7-module.watsup:90.1-90.52 +rec { + +;; 7-module.watsup:90.1-90.52 +def allocdatas : (store, byte**) -> (store, dataaddr*) + ;; 7-module.watsup:91.1-91.43 + def {s : store} allocdatas(s, []) = (s, []) + ;; 7-module.watsup:92.1-94.48 + def {byte* : byte*, byte'** : byte**, da : dataaddr, da'* : dataaddr*, s : store, s_1 : store, s_2 : store} allocdatas(s, [byte]*{byte} :: byte'*{byte'}*{byte'}) = (s_2, [da] :: da'*{da'}) + -- if ((s_1, da) = $allocdata(s, byte*{byte})) + -- if ((s_2, da'*{da'}) = $allocdatas(s_1, byte'*{byte'}*{byte'})) +} + +;; 7-module.watsup:97.1-97.81 +def allocmodule : (store, module, externval*, val*, ref**) -> (store, moduleinst) + ;; 7-module.watsup:98.1-135.54 + def {byte*^n_data : byte*^n_data, da* : dataaddr*, datamode?^n_data : datamode?^n_data, ea* : elemaddr*, elemmode?^n_elem : elemmode?^n_elem, export* : export*, expr_1^n_global : expr^n_global, expr_2*^n_elem : expr*^n_elem, externval* : externval*, fa* : funcaddr*, fa_ex* : funcaddr*, func^n_func : func^n_func, ga* : globaladdr*, ga_ex* : globaladdr*, globaltype^n_global : globaltype^n_global, i_data^n_data : nat^n_data, i_elem^n_elem : nat^n_elem, i_func^n_func : nat^n_func, i_global^n_global : nat^n_global, i_mem^n_mem : nat^n_mem, i_table^n_table : nat^n_table, import* : import*, m : moduleinst, ma* : memaddr*, ma_ex* : memaddr*, memtype^n_mem : memtype^n_mem, module : module, n_data : n, n_elem : n, n_func : n, n_global : n, n_mem : n, n_table : n, ref** : ref**, rt^n_elem : reftype^n_elem, s : store, s_1 : store, s_2 : store, s_3 : store, s_4 : store, s_5 : store, s_6 : store, start? : start?, ta* : tableaddr*, ta_ex* : tableaddr*, tabletype^n_table : tabletype^n_table, val* : val*, xi* : exportinst*} allocmodule(s, module, externval*{externval}, val*{val}, ref*{ref}*{ref}) = (s_6, m) + -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func^n_func{func}, GLOBAL(globaltype, expr_1)^n_global{expr_1 globaltype}, TABLE(tabletype)^n_table{tabletype}, MEMORY(memtype)^n_mem{memtype}, `ELEM%%*%?`(rt, expr_2*{expr_2}, elemmode?{elemmode})^n_elem{elemmode expr_2 rt}, `DATA%*%?`(byte*{byte}, datamode?{datamode})^n_data{byte datamode}, start?{start}, export*{export})) + -- if (fa_ex*{fa_ex} = $funcs(externval*{externval})) + -- if (ga_ex*{ga_ex} = $globals(externval*{externval})) + -- if (ta_ex*{ta_ex} = $tables(externval*{externval})) + -- if (ma_ex*{ma_ex} = $mems(externval*{externval})) + -- if (fa*{fa} = (|s.FUNC_store| + i_func)^(i_func instr* + ;; 7-module.watsup:139.1-139.46 + def {expr* : expr*, i : nat, reftype : reftype} runelem(`ELEM%%*%?`(reftype, expr*{expr}, ?()), i) = [] + ;; 7-module.watsup:140.1-140.62 + def {expr* : expr*, i : nat, reftype : reftype} runelem(`ELEM%%*%?`(reftype, expr*{expr}, ?(DECLARE_elemmode)), i) = [ELEM.DROP_instr(i)] + ;; 7-module.watsup:141.1-143.20 + def {expr* : expr*, i : nat, instr* : instr*, n : n, reftype : reftype, x : idx} runelem(`ELEM%%*%?`(reftype, expr*{expr}, ?(TABLE_elemmode(x, instr*{instr}))), i) = instr*{instr} :: [CONST_instr(I32_numtype, 0) CONST_instr(I32_numtype, n) TABLE.INIT_instr(x, i) ELEM.DROP_instr(i)] + -- if (n = |expr*{expr}|) + +;; 7-module.watsup:145.1-145.33 +def rundata : (data, idx) -> instr* + ;; 7-module.watsup:146.1-146.38 + def {byte* : byte*, i : nat} rundata(`DATA%*%?`(byte*{byte}, ?()), i) = [] + ;; 7-module.watsup:147.1-149.20 + def {byte* : byte*, i : nat, instr* : instr*, n : n} rundata(`DATA%*%?`(byte*{byte}, ?(MEMORY_datamode(0, instr*{instr}))), i) = instr*{instr} :: [CONST_instr(I32_numtype, 0) CONST_instr(I32_numtype, n) MEMORY.INIT_instr(i) DATA.DROP_instr(i)] + -- if (n = |byte*{byte}|) + +;; 7-module.watsup:152.1-152.36 +rec { + +;; 7-module.watsup:152.1-152.36 +def concat_instr : instr** -> instr* + ;; 7-module.watsup:153.1-153.37 + def concat_instr([]) = [] + ;; 7-module.watsup:154.1-154.68 + def {instr* : instr*, instr'** : instr**} concat_instr([instr]*{instr} :: instr'*{instr'}*{instr'}) = instr*{instr} :: $concat_instr(instr'*{instr'}*{instr'}) +} + +;; 7-module.watsup:157.1-157.55 +def instantiation : (store, module, externval*) -> config + ;; 7-module.watsup:158.1-180.28 + def {data* : data*, elem* : elem*, elemmode?* : elemmode?*, export* : export*, externval* : externval*, f : frame, f_init : frame, func* : func*, global* : global*, globaltype* : globaltype*, i^n_elem : nat^n_elem, import* : import*, instr_1** : instr**, instr_2*** : instr***, instr_data* : instr*, instr_elem* : instr*, j^n_data : nat^n_data, m : moduleinst, m_init : moduleinst, mem* : mem*, module : module, n_data : n, n_elem : n, ref** : ref**, reftype* : reftype*, s : store, s' : store, start? : start?, table* : table*, val* : val*, x? : idx?} instantiation(s, module, externval*{externval}) = `%;%*`(`%;%`(s', f), $admininstr_instr(instr_elem)*{instr_elem} :: $admininstr_instr(instr_data)*{instr_data} :: CALL_admininstr(x)?{x}) + -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, start?{start}, export*{export})) + -- if (m_init = {FUNC $funcs(externval*{externval}), GLOBAL $globals(externval*{externval}), TABLE [], MEM [], ELEM [], DATA [], EXPORT []}) + -- if (f_init = {LOCAL [], MODULE m_init}) + -- if (global*{global} = GLOBAL(globaltype, instr_1*{instr_1})*{globaltype instr_1}) + -- (Step_read: `%~>%*`(`%;%*`(`%;%`(s, f_init), $admininstr_instr(instr_1)*{instr_1}), [$admininstr_val(val)]))*{instr_1 val} + -- if (elem*{elem} = `ELEM%%*%?`(reftype, instr_2*{instr_2}*{instr_2}, elemmode?{elemmode})*{elemmode instr_2 reftype}) + -- (Step_read: `%~>%*`(`%;%*`(`%;%`(s, f_init), $admininstr_instr(instr_2)*{instr_2}), [$admininstr_ref(ref)]))*{instr_2 ref}*{instr_2 ref} + -- if ((s', m) = $allocmodule(s, module, externval*{externval}, val*{val}, ref*{ref}*{ref})) + -- if (f = {LOCAL [], MODULE m}) + -- if (n_elem = |elem*{elem}|) + -- if (instr_elem*{instr_elem} = $concat_instr($runelem(elem*{elem}[i], i)^(i config + ;; 7-module.watsup:184.1-196.52 + def {expr : expr, f : frame, fa : funcaddr, functype : functype, k : nat, m : moduleinst, n : n, s : store, val^n : val^n, valtype* : valtype*, valtype_param^n : valtype^n, valtype_res^k : valtype^k} invocation(s, fa, val^n{val}) = `%;%*`(`%;%`(s, f), $admininstr_val(val)^n{val} :: [CALL_ADDR_admininstr(fa)]) + -- if (m = {FUNC [], GLOBAL [], TABLE [], MEM [], ELEM [], DATA [], EXPORT []}) + -- if (f = {LOCAL [], MODULE m}) + -- if ($funcinst(`%;%`(s, f))[fa].CODE_funcinst = `FUNC%%*%`(functype, valtype*{valtype}, expr)) + -- if (functype = `%->%`(valtype_param^n{valtype_param}, valtype_res^k{valtype_res})) + == IL Validation... == Running pass sideconditions @@ -8988,8 +10423,8 @@ syntax mem = MEMORY(memtype) ;; 1-syntax.watsup:198.1-199.31 syntax elem = `ELEM%%*%?`(reftype, expr*, elemmode?) -;; 1-syntax.watsup:200.1-201.26 -syntax data = `DATA(*)%*%?`(byte**, datamode?) +;; 1-syntax.watsup:200.1-201.23 +syntax data = `DATA%*%?`(byte*, datamode?) ;; 1-syntax.watsup:202.1-203.16 syntax start = START(funcidx) @@ -9625,8 +11060,8 @@ relation Datamode_ok: `%|-%:OK`(context, datamode) ;; 3-typing.watsup:402.1-402.73 relation Data_ok: `%|-%:OK`(context, data) ;; 3-typing.watsup:433.1-435.40 - rule _ {C : context, b** : byte**, datamode? : datamode?}: - `%|-%:OK`(C, `DATA(*)%*%?`(b*{b}*{b}, datamode?{datamode})) + rule _ {C : context, b* : byte*, datamode? : datamode?}: + `%|-%:OK`(C, `DATA%*%?`(b*{b}, datamode?{datamode})) -- (Datamode_ok: `%|-%:OK`(C, datamode))?{datamode} ;; 3-typing.watsup:405.1-405.74 @@ -9802,10 +11237,10 @@ syntax frame = {LOCAL val*, MODULE moduleinst} ;; 4-runtime.watsup:96.1-96.47 syntax state = `%;%`(store, frame) -;; 4-runtime.watsup:172.1-179.5 +;; 4-runtime.watsup:183.1-190.5 rec { -;; 4-runtime.watsup:172.1-179.5 +;; 4-runtime.watsup:183.1-190.5 syntax admininstr = | UNREACHABLE | NOP @@ -9926,87 +11361,112 @@ def funcaddr : state -> funcaddr* ;; 4-runtime.watsup:118.1-118.52 def funcinst : state -> funcinst* - ;; 4-runtime.watsup:119.1-119.31 + ;; 4-runtime.watsup:125.1-125.31 def {f : frame, s : store} funcinst(`%;%`(s, f)) = s.FUNC_store -;; 4-runtime.watsup:121.1-121.67 +;; 4-runtime.watsup:119.1-119.58 +def globalinst : state -> globalinst* + ;; 4-runtime.watsup:126.1-126.35 + def {f : frame, s : store} globalinst(`%;%`(s, f)) = s.GLOBAL_store + +;; 4-runtime.watsup:120.1-120.55 +def tableinst : state -> tableinst* + ;; 4-runtime.watsup:127.1-127.33 + def {f : frame, s : store} tableinst(`%;%`(s, f)) = s.TABLE_store + +;; 4-runtime.watsup:121.1-121.49 +def meminst : state -> meminst* + ;; 4-runtime.watsup:128.1-128.29 + def {f : frame, s : store} meminst(`%;%`(s, f)) = s.MEM_store + +;; 4-runtime.watsup:122.1-122.52 +def eleminst : state -> eleminst* + ;; 4-runtime.watsup:129.1-129.31 + def {f : frame, s : store} eleminst(`%;%`(s, f)) = s.ELEM_store + +;; 4-runtime.watsup:123.1-123.52 +def datainst : state -> datainst* + ;; 4-runtime.watsup:130.1-130.31 + def {f : frame, s : store} datainst(`%;%`(s, f)) = s.DATA_store + +;; 4-runtime.watsup:132.1-132.67 def func : (state, funcidx) -> funcinst - ;; 4-runtime.watsup:129.1-129.48 + ;; 4-runtime.watsup:140.1-140.48 def {f : frame, s : store, x : idx} func(`%;%`(s, f), x) = s.FUNC_store[f.MODULE_frame.FUNC_moduleinst[x]] -;; 4-runtime.watsup:122.1-122.69 +;; 4-runtime.watsup:133.1-133.69 def global : (state, globalidx) -> globalinst - ;; 4-runtime.watsup:130.1-130.54 + ;; 4-runtime.watsup:141.1-141.54 def {f : frame, s : store, x : idx} global(`%;%`(s, f), x) = s.GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]] -;; 4-runtime.watsup:123.1-123.68 +;; 4-runtime.watsup:134.1-134.68 def table : (state, tableidx) -> tableinst - ;; 4-runtime.watsup:131.1-131.51 + ;; 4-runtime.watsup:142.1-142.51 def {f : frame, s : store, x : idx} table(`%;%`(s, f), x) = s.TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]] -;; 4-runtime.watsup:124.1-124.66 +;; 4-runtime.watsup:135.1-135.66 def mem : (state, memidx) -> meminst - ;; 4-runtime.watsup:132.1-132.45 + ;; 4-runtime.watsup:143.1-143.45 def {f : frame, s : store, x : idx} mem(`%;%`(s, f), x) = s.MEM_store[f.MODULE_frame.MEM_moduleinst[x]] -;; 4-runtime.watsup:125.1-125.67 +;; 4-runtime.watsup:136.1-136.67 def elem : (state, tableidx) -> eleminst - ;; 4-runtime.watsup:133.1-133.48 + ;; 4-runtime.watsup:144.1-144.48 def {f : frame, s : store, x : idx} elem(`%;%`(s, f), x) = s.ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]] -;; 4-runtime.watsup:126.1-126.67 +;; 4-runtime.watsup:137.1-137.67 def data : (state, dataidx) -> datainst - ;; 4-runtime.watsup:134.1-134.48 + ;; 4-runtime.watsup:145.1-145.48 def {f : frame, s : store, x : idx} data(`%;%`(s, f), x) = s.DATA_store[f.MODULE_frame.DATA_moduleinst[x]] -;; 4-runtime.watsup:127.1-127.68 +;; 4-runtime.watsup:138.1-138.68 def local : (state, localidx) -> val - ;; 4-runtime.watsup:135.1-135.35 + ;; 4-runtime.watsup:146.1-146.35 def {f : frame, s : store, x : idx} local(`%;%`(s, f), x) = f.LOCAL_frame[x] -;; 4-runtime.watsup:138.1-138.78 +;; 4-runtime.watsup:149.1-149.78 def with_local : (state, localidx, val) -> state - ;; 4-runtime.watsup:147.1-147.52 + ;; 4-runtime.watsup:158.1-158.52 def {f : frame, s : store, v : val, x : idx} with_local(`%;%`(s, f), x, v) = `%;%`(s, f[LOCAL_frame[x] = v]) -;; 4-runtime.watsup:139.1-139.85 +;; 4-runtime.watsup:150.1-150.85 def with_global : (state, globalidx, val) -> state - ;; 4-runtime.watsup:148.1-148.77 + ;; 4-runtime.watsup:159.1-159.77 def {f : frame, s : store, v : val, x : idx} with_global(`%;%`(s, f), x, v) = `%;%`(s[GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]].VALUE_globalinst = v], f) -;; 4-runtime.watsup:140.1-140.88 +;; 4-runtime.watsup:151.1-151.88 def with_table : (state, tableidx, nat, ref) -> state - ;; 4-runtime.watsup:149.1-149.79 + ;; 4-runtime.watsup:160.1-160.79 def {f : frame, i : nat, r : ref, s : store, x : idx} with_table(`%;%`(s, f), x, i, r) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]].ELEM_tableinst[i] = r], f) -;; 4-runtime.watsup:141.1-141.84 +;; 4-runtime.watsup:152.1-152.84 def with_tableinst : (state, tableidx, tableinst) -> state - ;; 4-runtime.watsup:150.1-150.74 + ;; 4-runtime.watsup:161.1-161.74 def {f : frame, s : store, ti : tableinst, x : idx} with_tableinst(`%;%`(s, f), x, ti) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]] = ti], f) -;; 4-runtime.watsup:142.1-142.93 +;; 4-runtime.watsup:153.1-153.93 def with_mem : (state, memidx, nat, nat, byte*) -> state - ;; 4-runtime.watsup:151.1-151.82 + ;; 4-runtime.watsup:162.1-162.82 def {b* : byte*, f : frame, i : nat, j : nat, s : store, x : idx} with_mem(`%;%`(s, f), x, i, j, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]].DATA_meminst[i : j] = b*{b}], f) -;; 4-runtime.watsup:143.1-143.77 +;; 4-runtime.watsup:154.1-154.77 def with_meminst : (state, memidx, meminst) -> state - ;; 4-runtime.watsup:152.1-152.68 + ;; 4-runtime.watsup:163.1-163.68 def {f : frame, mi : meminst, s : store, x : idx} with_meminst(`%;%`(s, f), x, mi) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]] = mi], f) -;; 4-runtime.watsup:144.1-144.82 +;; 4-runtime.watsup:155.1-155.82 def with_elem : (state, elemidx, ref*) -> state - ;; 4-runtime.watsup:153.1-153.72 + ;; 4-runtime.watsup:164.1-164.72 def {f : frame, r* : ref*, s : store, x : idx} with_elem(`%;%`(s, f), x, r*{r}) = `%;%`(s[ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]].ELEM_eleminst = r*{r}], f) -;; 4-runtime.watsup:145.1-145.82 +;; 4-runtime.watsup:156.1-156.82 def with_data : (state, dataidx, byte*) -> state - ;; 4-runtime.watsup:154.1-154.72 + ;; 4-runtime.watsup:165.1-165.72 def {b* : byte*, f : frame, s : store, x : idx} with_data(`%;%`(s, f), x, b*{b}) = `%;%`(s[DATA_store[f.MODULE_frame.DATA_moduleinst[x]].DATA_datainst = b*{b}], f) -;; 4-runtime.watsup:156.1-156.63 +;; 4-runtime.watsup:167.1-167.63 def grow_table : (tableinst, nat, ref) -> tableinst? - ;; 4-runtime.watsup:159.1-163.36 + ;; 4-runtime.watsup:170.1-174.36 def {i : nat, i' : nat, j : nat, n : n, r : ref, r'* : ref*, rt : reftype, ti : tableinst, ti' : tableinst} grow_table(ti, n, r) = ?(ti') -- if (ti = {TYPE `%%`(`[%..%]`(i, j), rt), ELEM r'*{r'}}) -- if (i' = (|r'*{r'}| + n)) @@ -10014,9 +11474,9 @@ def grow_table : (tableinst, nat, ref) -> tableinst? -- Tabletype_ok: `|-%:OK`(ti'.TYPE_tableinst) def {x : (tableinst, nat, ref)} grow_table(x) = ?() -;; 4-runtime.watsup:157.1-157.55 +;; 4-runtime.watsup:168.1-168.55 def grow_memory : (meminst, nat) -> meminst? - ;; 4-runtime.watsup:164.1-168.34 + ;; 4-runtime.watsup:175.1-179.34 def {b* : byte*, i : nat, i' : nat, j : nat, mi : meminst, mi' : meminst, n : n} grow_memory(mi, n) = ?(mi') -- if (mi = {TYPE `%I8`(`[%..%]`(i, j)), DATA b*{b}}) -- if (i' = ((|b*{b}| / (64 * $Ki)) + n)) @@ -10024,10 +11484,10 @@ def grow_memory : (meminst, nat) -> meminst? -- Memtype_ok: `|-%:OK`(mi'.TYPE_meminst) def {x : (meminst, nat)} grow_memory(x) = ?() -;; 4-runtime.watsup:181.1-184.21 +;; 4-runtime.watsup:192.1-195.21 rec { -;; 4-runtime.watsup:181.1-184.21 +;; 4-runtime.watsup:192.1-195.21 syntax E = | _HOLE | _SEQ(val*, E, instr*) @@ -10485,6 +11945,268 @@ relation Step: `%~>%`(config, config) rule data.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [DATA.DROP_admininstr(x)]), `%;%*`($with_data(z, x, []), [])) +;; 7-module.watsup:4.1-4.35 +rec { + +;; 7-module.watsup:4.1-4.35 +def funcs : externval* -> funcaddr* + ;; 7-module.watsup:5.1-5.30 + def funcs([]) = [] + ;; 7-module.watsup:6.1-6.59 + def {externval'* : externval*, fa : funcaddr} funcs([FUNC_externval(fa)] :: externval'*{externval'}) = [fa] :: $funcs(externval'*{externval'}) + ;; 7-module.watsup:7.1-8.15 + def {externval : externval, externval'* : externval*} funcs([externval] :: externval'*{externval'}) = $funcs(externval'*{externval'}) + -- otherwise +} + +;; 7-module.watsup:10.1-10.39 +rec { + +;; 7-module.watsup:10.1-10.39 +def globals : externval* -> globaladdr* + ;; 7-module.watsup:11.1-11.32 + def globals([]) = [] + ;; 7-module.watsup:12.1-12.65 + def {externval'* : externval*, ga : globaladdr} globals([GLOBAL_externval(ga)] :: externval'*{externval'}) = [ga] :: $globals(externval'*{externval'}) + ;; 7-module.watsup:13.1-14.15 + def {externval : externval, externval'* : externval*} globals([externval] :: externval'*{externval'}) = $globals(externval'*{externval'}) + -- otherwise +} + +;; 7-module.watsup:16.1-16.37 +rec { + +;; 7-module.watsup:16.1-16.37 +def tables : externval* -> tableaddr* + ;; 7-module.watsup:17.1-17.31 + def tables([]) = [] + ;; 7-module.watsup:18.1-18.62 + def {externval'* : externval*, ta : tableaddr} tables([TABLE_externval(ta)] :: externval'*{externval'}) = [ta] :: $tables(externval'*{externval'}) + ;; 7-module.watsup:19.1-20.15 + def {externval : externval, externval'* : externval*} tables([externval] :: externval'*{externval'}) = $tables(externval'*{externval'}) + -- otherwise +} + +;; 7-module.watsup:22.1-22.33 +rec { + +;; 7-module.watsup:22.1-22.33 +def mems : externval* -> memaddr* + ;; 7-module.watsup:23.1-23.29 + def mems([]) = [] + ;; 7-module.watsup:24.1-24.56 + def {externval'* : externval*, ma : memaddr} mems([MEM_externval(ma)] :: externval'*{externval'}) = [ma] :: $mems(externval'*{externval'}) + ;; 7-module.watsup:25.1-26.15 + def {externval : externval, externval'* : externval*} mems([externval] :: externval'*{externval'}) = $mems(externval'*{externval'}) + -- otherwise +} + +;; 7-module.watsup:29.1-29.83 +def instexport : (funcaddr*, globaladdr*, tableaddr*, memaddr*, export) -> exportinst + ;; 7-module.watsup:30.1-30.95 + def {fa* : funcaddr*, ga* : globaladdr*, ma* : memaddr*, name : name, ta* : tableaddr*, x : idx} instexport(fa*{fa}, ga*{ga}, ta*{ta}, ma*{ma}, EXPORT(name, FUNC_externuse(x))) = {NAME name, VALUE FUNC_externval(fa*{fa}[x])} + ;; 7-module.watsup:31.1-31.99 + def {fa* : funcaddr*, ga* : globaladdr*, ma* : memaddr*, name : name, ta* : tableaddr*, x : idx} instexport(fa*{fa}, ga*{ga}, ta*{ta}, ma*{ma}, EXPORT(name, GLOBAL_externuse(x))) = {NAME name, VALUE GLOBAL_externval(ga*{ga}[x])} + ;; 7-module.watsup:32.1-32.97 + def {fa* : funcaddr*, ga* : globaladdr*, ma* : memaddr*, name : name, ta* : tableaddr*, x : idx} instexport(fa*{fa}, ga*{ga}, ta*{ta}, ma*{ma}, EXPORT(name, TABLE_externuse(x))) = {NAME name, VALUE TABLE_externval(ta*{ta}[x])} + ;; 7-module.watsup:33.1-33.93 + def {fa* : funcaddr*, ga* : globaladdr*, ma* : memaddr*, name : name, ta* : tableaddr*, x : idx} instexport(fa*{fa}, ga*{ga}, ta*{ta}, ma*{ma}, EXPORT(name, MEM_externuse(x))) = {NAME name, VALUE MEM_externval(ma*{ma}[x])} + +;; 7-module.watsup:36.1-36.60 +def allocfunc : (store, moduleinst, func) -> (store, funcaddr) + ;; 7-module.watsup:37.1-38.37 + def {fi : funcinst, func : func, m : moduleinst, s : store} allocfunc(s, m, func) = (s[FUNC_store =.. [fi]], |s.FUNC_store|) + -- if (fi = {MODULE m, CODE func}) + +;; 7-module.watsup:40.1-40.63 +rec { + +;; 7-module.watsup:40.1-40.63 +def allocfuncs : (store, moduleinst, func*) -> (store, funcaddr*) + ;; 7-module.watsup:41.1-41.46 + def {m : moduleinst, s : store} allocfuncs(s, m, []) = (s, []) + ;; 7-module.watsup:42.1-44.50 + def {fa : funcaddr, fa'* : funcaddr*, func : func, func'* : func*, m : moduleinst, s : store, s_1 : store, s_2 : store} allocfuncs(s, m, [func] :: func'*{func'}) = (s_2, [fa] :: fa'*{fa'}) + -- if ((s_1, fa) = $allocfunc(s, m, func)) + -- if ((s_2, fa'*{fa'}) = $allocfuncs(s_1, m, func'*{func'})) +} + +;; 7-module.watsup:46.1-46.63 +def allocglobal : (store, globaltype, val) -> (store, globaladdr) + ;; 7-module.watsup:47.1-48.44 + def {gi : globalinst, globaltype : globaltype, s : store, val : val} allocglobal(s, globaltype, val) = (s[GLOBAL_store =.. [gi]], |s.GLOBAL_store|) + -- if (gi = {TYPE globaltype, VALUE val}) + +;; 7-module.watsup:50.1-50.67 +rec { + +;; 7-module.watsup:50.1-50.67 +def allocglobals : (store, globaltype*, val*) -> (store, globaladdr*) + ;; 7-module.watsup:51.1-51.54 + def {s : store} allocglobals(s, [], []) = (s, []) + ;; 7-module.watsup:52.1-54.62 + def {ga : globaladdr, ga'* : globaladdr*, globaltype : globaltype, globaltype'* : globaltype*, s : store, s_1 : store, s_2 : store, val : val, val'* : val*} allocglobals(s, [globaltype] :: globaltype'*{globaltype'}, [val] :: val'*{val'}) = (s_2, [ga] :: ga'*{ga'}) + -- if ((s_1, ga) = $allocglobal(s, globaltype, val)) + -- if ((s_2, ga'*{ga'}) = $allocglobals(s_1, globaltype'*{globaltype'}, val'*{val'})) +} + +;; 7-module.watsup:56.1-56.55 +def alloctable : (store, tabletype) -> (store, tableaddr) + ;; 7-module.watsup:57.1-58.59 + def {i : nat, j : nat, rt : reftype, s : store, ti : tableinst} alloctable(s, `%%`(`[%..%]`(i, j), rt)) = (s[TABLE_store =.. [ti]], |s.TABLE_store|) + -- if (ti = {TYPE `%%`(`[%..%]`(i, j), rt), ELEM REF.NULL_ref(rt)^i{}}) + +;; 7-module.watsup:60.1-60.58 +rec { + +;; 7-module.watsup:60.1-60.58 +def alloctables : (store, tabletype*) -> (store, tableaddr*) + ;; 7-module.watsup:61.1-61.44 + def {s : store} alloctables(s, []) = (s, []) + ;; 7-module.watsup:62.1-64.53 + def {s : store, s_1 : store, s_2 : store, ta : tableaddr, ta'* : tableaddr*, tabletype : tabletype, tabletype'* : tabletype*} alloctables(s, [tabletype] :: tabletype'*{tabletype'}) = (s_2, [ta] :: ta'*{ta'}) + -- if ((s_1, ta) = $alloctable(s, tabletype)) + -- if ((s_2, ta'*{ta'}) = $alloctables(s_1, tabletype'*{tabletype'})) +} + +;; 7-module.watsup:66.1-66.49 +def allocmem : (store, memtype) -> (store, memaddr) + ;; 7-module.watsup:67.1-68.62 + def {i : nat, j : nat, mi : meminst, s : store} allocmem(s, `%I8`(`[%..%]`(i, j))) = (s[MEM_store =.. [mi]], |s.MEM_store|) + -- if (mi = {TYPE `%I8`(`[%..%]`(i, j)), DATA 0^((i * 64) * $Ki){}}) + +;; 7-module.watsup:70.1-70.52 +rec { + +;; 7-module.watsup:70.1-70.52 +def allocmems : (store, memtype*) -> (store, memaddr*) + ;; 7-module.watsup:71.1-71.42 + def {s : store} allocmems(s, []) = (s, []) + ;; 7-module.watsup:72.1-74.49 + def {ma : memaddr, ma'* : memaddr*, memtype : memtype, memtype'* : memtype*, s : store, s_1 : store, s_2 : store} allocmems(s, [memtype] :: memtype'*{memtype'}) = (s_2, [ma] :: ma'*{ma'}) + -- if ((s_1, ma) = $allocmem(s, memtype)) + -- if ((s_2, ma'*{ma'}) = $allocmems(s_1, memtype'*{memtype'})) +} + +;; 7-module.watsup:76.1-76.57 +def allocelem : (store, reftype, ref*) -> (store, elemaddr) + ;; 7-module.watsup:77.1-78.36 + def {ei : eleminst, ref* : ref*, rt : reftype, s : store} allocelem(s, rt, ref*{ref}) = (s[ELEM_store =.. [ei]], |s.ELEM_store|) + -- if (ei = {TYPE rt, ELEM ref*{ref}}) + +;; 7-module.watsup:80.1-80.63 +rec { + +;; 7-module.watsup:80.1-80.63 +def allocelems : (store, reftype*, ref**) -> (store, elemaddr*) + ;; 7-module.watsup:81.1-81.52 + def {s : store} allocelems(s, [], []) = (s, []) + ;; 7-module.watsup:82.1-84.53 + def {ea : elemaddr, ea'* : elemaddr*, ref* : ref*, ref'** : ref**, rt : reftype, rt'* : reftype*, s : store, s_1 : store, s_2 : store} allocelems(s, [rt] :: rt'*{rt'}, [ref]*{ref} :: ref'*{ref'}*{ref'}) = (s_2, [ea] :: ea'*{ea'}) + -- if ((s_1, ea) = $allocelem(s, rt, ref*{ref})) + -- if ((s_2, ea'*{ea'}) = $allocelems(s_2, rt'*{rt'}, ref'*{ref'}*{ref'})) +} + +;; 7-module.watsup:86.1-86.49 +def allocdata : (store, byte*) -> (store, dataaddr) + ;; 7-module.watsup:87.1-88.28 + def {byte* : byte*, di : datainst, s : store} allocdata(s, byte*{byte}) = (s[DATA_store =.. [di]], |s.DATA_store|) + -- if (di = {DATA byte*{byte}}) + +;; 7-module.watsup:90.1-90.52 +rec { + +;; 7-module.watsup:90.1-90.52 +def allocdatas : (store, byte**) -> (store, dataaddr*) + ;; 7-module.watsup:91.1-91.43 + def {s : store} allocdatas(s, []) = (s, []) + ;; 7-module.watsup:92.1-94.48 + def {byte* : byte*, byte'** : byte**, da : dataaddr, da'* : dataaddr*, s : store, s_1 : store, s_2 : store} allocdatas(s, [byte]*{byte} :: byte'*{byte'}*{byte'}) = (s_2, [da] :: da'*{da'}) + -- if ((s_1, da) = $allocdata(s, byte*{byte})) + -- if ((s_2, da'*{da'}) = $allocdatas(s_1, byte'*{byte'}*{byte'})) +} + +;; 7-module.watsup:97.1-97.81 +def allocmodule : (store, module, externval*, val*, ref**) -> (store, moduleinst) + ;; 7-module.watsup:98.1-135.54 + def {byte*^n_data : byte*^n_data, da* : dataaddr*, datamode?^n_data : datamode?^n_data, ea* : elemaddr*, elemmode?^n_elem : elemmode?^n_elem, export* : export*, expr_1^n_global : expr^n_global, expr_2*^n_elem : expr*^n_elem, externval* : externval*, fa* : funcaddr*, fa_ex* : funcaddr*, func^n_func : func^n_func, ga* : globaladdr*, ga_ex* : globaladdr*, globaltype^n_global : globaltype^n_global, i_data^n_data : nat^n_data, i_elem^n_elem : nat^n_elem, i_func^n_func : nat^n_func, i_global^n_global : nat^n_global, i_mem^n_mem : nat^n_mem, i_table^n_table : nat^n_table, import* : import*, m : moduleinst, ma* : memaddr*, ma_ex* : memaddr*, memtype^n_mem : memtype^n_mem, module : module, n_data : n, n_elem : n, n_func : n, n_global : n, n_mem : n, n_table : n, ref** : ref**, rt^n_elem : reftype^n_elem, s : store, s_1 : store, s_2 : store, s_3 : store, s_4 : store, s_5 : store, s_6 : store, start? : start?, ta* : tableaddr*, ta_ex* : tableaddr*, tabletype^n_table : tabletype^n_table, val* : val*, xi* : exportinst*} allocmodule(s, module, externval*{externval}, val*{val}, ref*{ref}*{ref}) = (s_6, m) + -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func^n_func{func}, GLOBAL(globaltype, expr_1)^n_global{expr_1 globaltype}, TABLE(tabletype)^n_table{tabletype}, MEMORY(memtype)^n_mem{memtype}, `ELEM%%*%?`(rt, expr_2*{expr_2}, elemmode?{elemmode})^n_elem{elemmode expr_2 rt}, `DATA%*%?`(byte*{byte}, datamode?{datamode})^n_data{byte datamode}, start?{start}, export*{export})) + -- if (fa_ex*{fa_ex} = $funcs(externval*{externval})) + -- if (ga_ex*{ga_ex} = $globals(externval*{externval})) + -- if (ta_ex*{ta_ex} = $tables(externval*{externval})) + -- if (ma_ex*{ma_ex} = $mems(externval*{externval})) + -- if (fa*{fa} = (|s.FUNC_store| + i_func)^(i_func instr* + ;; 7-module.watsup:139.1-139.46 + def {expr* : expr*, i : nat, reftype : reftype} runelem(`ELEM%%*%?`(reftype, expr*{expr}, ?()), i) = [] + ;; 7-module.watsup:140.1-140.62 + def {expr* : expr*, i : nat, reftype : reftype} runelem(`ELEM%%*%?`(reftype, expr*{expr}, ?(DECLARE_elemmode)), i) = [ELEM.DROP_instr(i)] + ;; 7-module.watsup:141.1-143.20 + def {expr* : expr*, i : nat, instr* : instr*, n : n, reftype : reftype, x : idx} runelem(`ELEM%%*%?`(reftype, expr*{expr}, ?(TABLE_elemmode(x, instr*{instr}))), i) = instr*{instr} :: [CONST_instr(I32_numtype, 0) CONST_instr(I32_numtype, n) TABLE.INIT_instr(x, i) ELEM.DROP_instr(i)] + -- if (n = |expr*{expr}|) + +;; 7-module.watsup:145.1-145.33 +def rundata : (data, idx) -> instr* + ;; 7-module.watsup:146.1-146.38 + def {byte* : byte*, i : nat} rundata(`DATA%*%?`(byte*{byte}, ?()), i) = [] + ;; 7-module.watsup:147.1-149.20 + def {byte* : byte*, i : nat, instr* : instr*, n : n} rundata(`DATA%*%?`(byte*{byte}, ?(MEMORY_datamode(0, instr*{instr}))), i) = instr*{instr} :: [CONST_instr(I32_numtype, 0) CONST_instr(I32_numtype, n) MEMORY.INIT_instr(i) DATA.DROP_instr(i)] + -- if (n = |byte*{byte}|) + +;; 7-module.watsup:152.1-152.36 +rec { + +;; 7-module.watsup:152.1-152.36 +def concat_instr : instr** -> instr* + ;; 7-module.watsup:153.1-153.37 + def concat_instr([]) = [] + ;; 7-module.watsup:154.1-154.68 + def {instr* : instr*, instr'** : instr**} concat_instr([instr]*{instr} :: instr'*{instr'}*{instr'}) = instr*{instr} :: $concat_instr(instr'*{instr'}*{instr'}) +} + +;; 7-module.watsup:157.1-157.55 +def instantiation : (store, module, externval*) -> config + ;; 7-module.watsup:158.1-180.28 + def {data* : data*, elem* : elem*, elemmode?* : elemmode?*, export* : export*, externval* : externval*, f : frame, f_init : frame, func* : func*, global* : global*, globaltype* : globaltype*, i^n_elem : nat^n_elem, import* : import*, instr_1** : instr**, instr_2*** : instr***, instr_data* : instr*, instr_elem* : instr*, j^n_data : nat^n_data, m : moduleinst, m_init : moduleinst, mem* : mem*, module : module, n_data : n, n_elem : n, ref** : ref**, reftype* : reftype*, s : store, s' : store, start? : start?, table* : table*, val* : val*, x? : idx?} instantiation(s, module, externval*{externval}) = `%;%*`(`%;%`(s', f), $admininstr_instr(instr_elem)*{instr_elem} :: $admininstr_instr(instr_data)*{instr_data} :: CALL_admininstr(x)?{x}) + -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, start?{start}, export*{export})) + -- if (m_init = {FUNC $funcs(externval*{externval}), GLOBAL $globals(externval*{externval}), TABLE [], MEM [], ELEM [], DATA [], EXPORT []}) + -- if (f_init = {LOCAL [], MODULE m_init}) + -- if (global*{global} = GLOBAL(globaltype, instr_1*{instr_1})*{globaltype instr_1}) + -- (Step_read: `%~>%*`(`%;%*`(`%;%`(s, f_init), $admininstr_instr(instr_1)*{instr_1}), [$admininstr_val(val)]))*{instr_1 val} + -- if (elem*{elem} = `ELEM%%*%?`(reftype, instr_2*{instr_2}*{instr_2}, elemmode?{elemmode})*{elemmode instr_2 reftype}) + -- (Step_read: `%~>%*`(`%;%*`(`%;%`(s, f_init), $admininstr_instr(instr_2)*{instr_2}), [$admininstr_ref(ref)]))*{instr_2 ref}*{instr_2 ref} + -- if ((s', m) = $allocmodule(s, module, externval*{externval}, val*{val}, ref*{ref}*{ref})) + -- if (f = {LOCAL [], MODULE m}) + -- if (n_elem = |elem*{elem}|) + -- if (instr_elem*{instr_elem} = $concat_instr($runelem(elem*{elem}[i], i)^(i config + ;; 7-module.watsup:184.1-196.52 + def {expr : expr, f : frame, fa : funcaddr, functype : functype, k : nat, m : moduleinst, n : n, s : store, val^n : val^n, valtype* : valtype*, valtype_param^n : valtype^n, valtype_res^k : valtype^k} invocation(s, fa, val^n{val}) = `%;%*`(`%;%`(s, f), $admininstr_val(val)^n{val} :: [CALL_ADDR_admininstr(fa)]) + -- if (m = {FUNC [], GLOBAL [], TABLE [], MEM [], ELEM [], DATA [], EXPORT []}) + -- if (f = {LOCAL [], MODULE m}) + -- if ($funcinst(`%;%`(s, f))[fa].CODE_funcinst = `FUNC%%*%`(functype, valtype*{valtype}, expr)) + -- if (functype = `%->%`(valtype_param^n{valtype_param}, valtype_res^k{valtype_res})) + == IL Validation... == Running pass animate Animation failed:if ($funcinst(z)[a].CODE_funcinst = `FUNC%%*%`(ft', t*{t}, instr*{instr})) @@ -10811,8 +12533,8 @@ syntax mem = MEMORY(memtype) ;; 1-syntax.watsup:198.1-199.31 syntax elem = `ELEM%%*%?`(reftype, expr*, elemmode?) -;; 1-syntax.watsup:200.1-201.26 -syntax data = `DATA(*)%*%?`(byte**, datamode?) +;; 1-syntax.watsup:200.1-201.23 +syntax data = `DATA%*%?`(byte*, datamode?) ;; 1-syntax.watsup:202.1-203.16 syntax start = START(funcidx) @@ -11448,8 +13170,8 @@ relation Datamode_ok: `%|-%:OK`(context, datamode) ;; 3-typing.watsup:402.1-402.73 relation Data_ok: `%|-%:OK`(context, data) ;; 3-typing.watsup:433.1-435.40 - rule _ {C : context, b** : byte**, datamode? : datamode?}: - `%|-%:OK`(C, `DATA(*)%*%?`(b*{b}*{b}, datamode?{datamode})) + rule _ {C : context, b* : byte*, datamode? : datamode?}: + `%|-%:OK`(C, `DATA%*%?`(b*{b}, datamode?{datamode})) -- (Datamode_ok: `%|-%:OK`(C, datamode))?{datamode} ;; 3-typing.watsup:405.1-405.74 @@ -11625,10 +13347,10 @@ syntax frame = {LOCAL val*, MODULE moduleinst} ;; 4-runtime.watsup:96.1-96.47 syntax state = `%;%`(store, frame) -;; 4-runtime.watsup:172.1-179.5 +;; 4-runtime.watsup:183.1-190.5 rec { -;; 4-runtime.watsup:172.1-179.5 +;; 4-runtime.watsup:183.1-190.5 syntax admininstr = | UNREACHABLE | NOP @@ -11749,87 +13471,112 @@ def funcaddr : state -> funcaddr* ;; 4-runtime.watsup:118.1-118.52 def funcinst : state -> funcinst* - ;; 4-runtime.watsup:119.1-119.31 + ;; 4-runtime.watsup:125.1-125.31 def {f : frame, s : store} funcinst(`%;%`(s, f)) = s.FUNC_store -;; 4-runtime.watsup:121.1-121.67 +;; 4-runtime.watsup:119.1-119.58 +def globalinst : state -> globalinst* + ;; 4-runtime.watsup:126.1-126.35 + def {f : frame, s : store} globalinst(`%;%`(s, f)) = s.GLOBAL_store + +;; 4-runtime.watsup:120.1-120.55 +def tableinst : state -> tableinst* + ;; 4-runtime.watsup:127.1-127.33 + def {f : frame, s : store} tableinst(`%;%`(s, f)) = s.TABLE_store + +;; 4-runtime.watsup:121.1-121.49 +def meminst : state -> meminst* + ;; 4-runtime.watsup:128.1-128.29 + def {f : frame, s : store} meminst(`%;%`(s, f)) = s.MEM_store + +;; 4-runtime.watsup:122.1-122.52 +def eleminst : state -> eleminst* + ;; 4-runtime.watsup:129.1-129.31 + def {f : frame, s : store} eleminst(`%;%`(s, f)) = s.ELEM_store + +;; 4-runtime.watsup:123.1-123.52 +def datainst : state -> datainst* + ;; 4-runtime.watsup:130.1-130.31 + def {f : frame, s : store} datainst(`%;%`(s, f)) = s.DATA_store + +;; 4-runtime.watsup:132.1-132.67 def func : (state, funcidx) -> funcinst - ;; 4-runtime.watsup:129.1-129.48 + ;; 4-runtime.watsup:140.1-140.48 def {f : frame, s : store, x : idx} func(`%;%`(s, f), x) = s.FUNC_store[f.MODULE_frame.FUNC_moduleinst[x]] -;; 4-runtime.watsup:122.1-122.69 +;; 4-runtime.watsup:133.1-133.69 def global : (state, globalidx) -> globalinst - ;; 4-runtime.watsup:130.1-130.54 + ;; 4-runtime.watsup:141.1-141.54 def {f : frame, s : store, x : idx} global(`%;%`(s, f), x) = s.GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]] -;; 4-runtime.watsup:123.1-123.68 +;; 4-runtime.watsup:134.1-134.68 def table : (state, tableidx) -> tableinst - ;; 4-runtime.watsup:131.1-131.51 + ;; 4-runtime.watsup:142.1-142.51 def {f : frame, s : store, x : idx} table(`%;%`(s, f), x) = s.TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]] -;; 4-runtime.watsup:124.1-124.66 +;; 4-runtime.watsup:135.1-135.66 def mem : (state, memidx) -> meminst - ;; 4-runtime.watsup:132.1-132.45 + ;; 4-runtime.watsup:143.1-143.45 def {f : frame, s : store, x : idx} mem(`%;%`(s, f), x) = s.MEM_store[f.MODULE_frame.MEM_moduleinst[x]] -;; 4-runtime.watsup:125.1-125.67 +;; 4-runtime.watsup:136.1-136.67 def elem : (state, tableidx) -> eleminst - ;; 4-runtime.watsup:133.1-133.48 + ;; 4-runtime.watsup:144.1-144.48 def {f : frame, s : store, x : idx} elem(`%;%`(s, f), x) = s.ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]] -;; 4-runtime.watsup:126.1-126.67 +;; 4-runtime.watsup:137.1-137.67 def data : (state, dataidx) -> datainst - ;; 4-runtime.watsup:134.1-134.48 + ;; 4-runtime.watsup:145.1-145.48 def {f : frame, s : store, x : idx} data(`%;%`(s, f), x) = s.DATA_store[f.MODULE_frame.DATA_moduleinst[x]] -;; 4-runtime.watsup:127.1-127.68 +;; 4-runtime.watsup:138.1-138.68 def local : (state, localidx) -> val - ;; 4-runtime.watsup:135.1-135.35 + ;; 4-runtime.watsup:146.1-146.35 def {f : frame, s : store, x : idx} local(`%;%`(s, f), x) = f.LOCAL_frame[x] -;; 4-runtime.watsup:138.1-138.78 +;; 4-runtime.watsup:149.1-149.78 def with_local : (state, localidx, val) -> state - ;; 4-runtime.watsup:147.1-147.52 + ;; 4-runtime.watsup:158.1-158.52 def {f : frame, s : store, v : val, x : idx} with_local(`%;%`(s, f), x, v) = `%;%`(s, f[LOCAL_frame[x] = v]) -;; 4-runtime.watsup:139.1-139.85 +;; 4-runtime.watsup:150.1-150.85 def with_global : (state, globalidx, val) -> state - ;; 4-runtime.watsup:148.1-148.77 + ;; 4-runtime.watsup:159.1-159.77 def {f : frame, s : store, v : val, x : idx} with_global(`%;%`(s, f), x, v) = `%;%`(s[GLOBAL_store[f.MODULE_frame.GLOBAL_moduleinst[x]].VALUE_globalinst = v], f) -;; 4-runtime.watsup:140.1-140.88 +;; 4-runtime.watsup:151.1-151.88 def with_table : (state, tableidx, nat, ref) -> state - ;; 4-runtime.watsup:149.1-149.79 + ;; 4-runtime.watsup:160.1-160.79 def {f : frame, i : nat, r : ref, s : store, x : idx} with_table(`%;%`(s, f), x, i, r) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]].ELEM_tableinst[i] = r], f) -;; 4-runtime.watsup:141.1-141.84 +;; 4-runtime.watsup:152.1-152.84 def with_tableinst : (state, tableidx, tableinst) -> state - ;; 4-runtime.watsup:150.1-150.74 + ;; 4-runtime.watsup:161.1-161.74 def {f : frame, s : store, ti : tableinst, x : idx} with_tableinst(`%;%`(s, f), x, ti) = `%;%`(s[TABLE_store[f.MODULE_frame.TABLE_moduleinst[x]] = ti], f) -;; 4-runtime.watsup:142.1-142.93 +;; 4-runtime.watsup:153.1-153.93 def with_mem : (state, memidx, nat, nat, byte*) -> state - ;; 4-runtime.watsup:151.1-151.82 + ;; 4-runtime.watsup:162.1-162.82 def {b* : byte*, f : frame, i : nat, j : nat, s : store, x : idx} with_mem(`%;%`(s, f), x, i, j, b*{b}) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]].DATA_meminst[i : j] = b*{b}], f) -;; 4-runtime.watsup:143.1-143.77 +;; 4-runtime.watsup:154.1-154.77 def with_meminst : (state, memidx, meminst) -> state - ;; 4-runtime.watsup:152.1-152.68 + ;; 4-runtime.watsup:163.1-163.68 def {f : frame, mi : meminst, s : store, x : idx} with_meminst(`%;%`(s, f), x, mi) = `%;%`(s[MEM_store[f.MODULE_frame.MEM_moduleinst[x]] = mi], f) -;; 4-runtime.watsup:144.1-144.82 +;; 4-runtime.watsup:155.1-155.82 def with_elem : (state, elemidx, ref*) -> state - ;; 4-runtime.watsup:153.1-153.72 + ;; 4-runtime.watsup:164.1-164.72 def {f : frame, r* : ref*, s : store, x : idx} with_elem(`%;%`(s, f), x, r*{r}) = `%;%`(s[ELEM_store[f.MODULE_frame.ELEM_moduleinst[x]].ELEM_eleminst = r*{r}], f) -;; 4-runtime.watsup:145.1-145.82 +;; 4-runtime.watsup:156.1-156.82 def with_data : (state, dataidx, byte*) -> state - ;; 4-runtime.watsup:154.1-154.72 + ;; 4-runtime.watsup:165.1-165.72 def {b* : byte*, f : frame, s : store, x : idx} with_data(`%;%`(s, f), x, b*{b}) = `%;%`(s[DATA_store[f.MODULE_frame.DATA_moduleinst[x]].DATA_datainst = b*{b}], f) -;; 4-runtime.watsup:156.1-156.63 +;; 4-runtime.watsup:167.1-167.63 def grow_table : (tableinst, nat, ref) -> tableinst? - ;; 4-runtime.watsup:159.1-163.36 + ;; 4-runtime.watsup:170.1-174.36 def {i : nat, i' : nat, j : nat, n : n, r : ref, r'* : ref*, rt : reftype, ti : tableinst, ti' : tableinst} grow_table(ti, n, r) = ?(ti') -- if (ti = {TYPE `%%`(`[%..%]`(i, j), rt), ELEM r'*{r'}}) -- if (i' = (|r'*{r'}| + n)) @@ -11837,9 +13584,9 @@ def grow_table : (tableinst, nat, ref) -> tableinst? -- Tabletype_ok: `|-%:OK`(ti'.TYPE_tableinst) def {x : (tableinst, nat, ref)} grow_table(x) = ?() -;; 4-runtime.watsup:157.1-157.55 +;; 4-runtime.watsup:168.1-168.55 def grow_memory : (meminst, nat) -> meminst? - ;; 4-runtime.watsup:164.1-168.34 + ;; 4-runtime.watsup:175.1-179.34 def {b* : byte*, i : nat, i' : nat, j : nat, mi : meminst, mi' : meminst, n : n} grow_memory(mi, n) = ?(mi') -- if (mi = {TYPE `%I8`(`[%..%]`(i, j)), DATA b*{b}}) -- if (i' = ((|b*{b}| / (64 * $Ki)) + n)) @@ -11847,10 +13594,10 @@ def grow_memory : (meminst, nat) -> meminst? -- Memtype_ok: `|-%:OK`(mi'.TYPE_meminst) def {x : (meminst, nat)} grow_memory(x) = ?() -;; 4-runtime.watsup:181.1-184.21 +;; 4-runtime.watsup:192.1-195.21 rec { -;; 4-runtime.watsup:181.1-184.21 +;; 4-runtime.watsup:192.1-195.21 syntax E = | _HOLE | _SEQ(val*, E, instr*) @@ -12308,6 +14055,268 @@ relation Step: `%~>%`(config, config) rule data.drop {x : idx, z : state}: `%~>%`(`%;%*`(z, [DATA.DROP_admininstr(x)]), `%;%*`($with_data(z, x, []), [])) +;; 7-module.watsup:4.1-4.35 +rec { + +;; 7-module.watsup:4.1-4.35 +def funcs : externval* -> funcaddr* + ;; 7-module.watsup:5.1-5.30 + def funcs([]) = [] + ;; 7-module.watsup:6.1-6.59 + def {externval'* : externval*, fa : funcaddr} funcs([FUNC_externval(fa)] :: externval'*{externval'}) = [fa] :: $funcs(externval'*{externval'}) + ;; 7-module.watsup:7.1-8.15 + def {externval : externval, externval'* : externval*} funcs([externval] :: externval'*{externval'}) = $funcs(externval'*{externval'}) + -- otherwise +} + +;; 7-module.watsup:10.1-10.39 +rec { + +;; 7-module.watsup:10.1-10.39 +def globals : externval* -> globaladdr* + ;; 7-module.watsup:11.1-11.32 + def globals([]) = [] + ;; 7-module.watsup:12.1-12.65 + def {externval'* : externval*, ga : globaladdr} globals([GLOBAL_externval(ga)] :: externval'*{externval'}) = [ga] :: $globals(externval'*{externval'}) + ;; 7-module.watsup:13.1-14.15 + def {externval : externval, externval'* : externval*} globals([externval] :: externval'*{externval'}) = $globals(externval'*{externval'}) + -- otherwise +} + +;; 7-module.watsup:16.1-16.37 +rec { + +;; 7-module.watsup:16.1-16.37 +def tables : externval* -> tableaddr* + ;; 7-module.watsup:17.1-17.31 + def tables([]) = [] + ;; 7-module.watsup:18.1-18.62 + def {externval'* : externval*, ta : tableaddr} tables([TABLE_externval(ta)] :: externval'*{externval'}) = [ta] :: $tables(externval'*{externval'}) + ;; 7-module.watsup:19.1-20.15 + def {externval : externval, externval'* : externval*} tables([externval] :: externval'*{externval'}) = $tables(externval'*{externval'}) + -- otherwise +} + +;; 7-module.watsup:22.1-22.33 +rec { + +;; 7-module.watsup:22.1-22.33 +def mems : externval* -> memaddr* + ;; 7-module.watsup:23.1-23.29 + def mems([]) = [] + ;; 7-module.watsup:24.1-24.56 + def {externval'* : externval*, ma : memaddr} mems([MEM_externval(ma)] :: externval'*{externval'}) = [ma] :: $mems(externval'*{externval'}) + ;; 7-module.watsup:25.1-26.15 + def {externval : externval, externval'* : externval*} mems([externval] :: externval'*{externval'}) = $mems(externval'*{externval'}) + -- otherwise +} + +;; 7-module.watsup:29.1-29.83 +def instexport : (funcaddr*, globaladdr*, tableaddr*, memaddr*, export) -> exportinst + ;; 7-module.watsup:30.1-30.95 + def {fa* : funcaddr*, ga* : globaladdr*, ma* : memaddr*, name : name, ta* : tableaddr*, x : idx} instexport(fa*{fa}, ga*{ga}, ta*{ta}, ma*{ma}, EXPORT(name, FUNC_externuse(x))) = {NAME name, VALUE FUNC_externval(fa*{fa}[x])} + ;; 7-module.watsup:31.1-31.99 + def {fa* : funcaddr*, ga* : globaladdr*, ma* : memaddr*, name : name, ta* : tableaddr*, x : idx} instexport(fa*{fa}, ga*{ga}, ta*{ta}, ma*{ma}, EXPORT(name, GLOBAL_externuse(x))) = {NAME name, VALUE GLOBAL_externval(ga*{ga}[x])} + ;; 7-module.watsup:32.1-32.97 + def {fa* : funcaddr*, ga* : globaladdr*, ma* : memaddr*, name : name, ta* : tableaddr*, x : idx} instexport(fa*{fa}, ga*{ga}, ta*{ta}, ma*{ma}, EXPORT(name, TABLE_externuse(x))) = {NAME name, VALUE TABLE_externval(ta*{ta}[x])} + ;; 7-module.watsup:33.1-33.93 + def {fa* : funcaddr*, ga* : globaladdr*, ma* : memaddr*, name : name, ta* : tableaddr*, x : idx} instexport(fa*{fa}, ga*{ga}, ta*{ta}, ma*{ma}, EXPORT(name, MEM_externuse(x))) = {NAME name, VALUE MEM_externval(ma*{ma}[x])} + +;; 7-module.watsup:36.1-36.60 +def allocfunc : (store, moduleinst, func) -> (store, funcaddr) + ;; 7-module.watsup:37.1-38.37 + def {fi : funcinst, func : func, m : moduleinst, s : store} allocfunc(s, m, func) = (s[FUNC_store =.. [fi]], |s.FUNC_store|) + -- if (fi = {MODULE m, CODE func}) + +;; 7-module.watsup:40.1-40.63 +rec { + +;; 7-module.watsup:40.1-40.63 +def allocfuncs : (store, moduleinst, func*) -> (store, funcaddr*) + ;; 7-module.watsup:41.1-41.46 + def {m : moduleinst, s : store} allocfuncs(s, m, []) = (s, []) + ;; 7-module.watsup:42.1-44.50 + def {fa : funcaddr, fa'* : funcaddr*, func : func, func'* : func*, m : moduleinst, s : store, s_1 : store, s_2 : store} allocfuncs(s, m, [func] :: func'*{func'}) = (s_2, [fa] :: fa'*{fa'}) + -- if ((s_1, fa) = $allocfunc(s, m, func)) + -- if ((s_2, fa'*{fa'}) = $allocfuncs(s_1, m, func'*{func'})) +} + +;; 7-module.watsup:46.1-46.63 +def allocglobal : (store, globaltype, val) -> (store, globaladdr) + ;; 7-module.watsup:47.1-48.44 + def {gi : globalinst, globaltype : globaltype, s : store, val : val} allocglobal(s, globaltype, val) = (s[GLOBAL_store =.. [gi]], |s.GLOBAL_store|) + -- if (gi = {TYPE globaltype, VALUE val}) + +;; 7-module.watsup:50.1-50.67 +rec { + +;; 7-module.watsup:50.1-50.67 +def allocglobals : (store, globaltype*, val*) -> (store, globaladdr*) + ;; 7-module.watsup:51.1-51.54 + def {s : store} allocglobals(s, [], []) = (s, []) + ;; 7-module.watsup:52.1-54.62 + def {ga : globaladdr, ga'* : globaladdr*, globaltype : globaltype, globaltype'* : globaltype*, s : store, s_1 : store, s_2 : store, val : val, val'* : val*} allocglobals(s, [globaltype] :: globaltype'*{globaltype'}, [val] :: val'*{val'}) = (s_2, [ga] :: ga'*{ga'}) + -- if ((s_1, ga) = $allocglobal(s, globaltype, val)) + -- if ((s_2, ga'*{ga'}) = $allocglobals(s_1, globaltype'*{globaltype'}, val'*{val'})) +} + +;; 7-module.watsup:56.1-56.55 +def alloctable : (store, tabletype) -> (store, tableaddr) + ;; 7-module.watsup:57.1-58.59 + def {i : nat, j : nat, rt : reftype, s : store, ti : tableinst} alloctable(s, `%%`(`[%..%]`(i, j), rt)) = (s[TABLE_store =.. [ti]], |s.TABLE_store|) + -- if (ti = {TYPE `%%`(`[%..%]`(i, j), rt), ELEM REF.NULL_ref(rt)^i{}}) + +;; 7-module.watsup:60.1-60.58 +rec { + +;; 7-module.watsup:60.1-60.58 +def alloctables : (store, tabletype*) -> (store, tableaddr*) + ;; 7-module.watsup:61.1-61.44 + def {s : store} alloctables(s, []) = (s, []) + ;; 7-module.watsup:62.1-64.53 + def {s : store, s_1 : store, s_2 : store, ta : tableaddr, ta'* : tableaddr*, tabletype : tabletype, tabletype'* : tabletype*} alloctables(s, [tabletype] :: tabletype'*{tabletype'}) = (s_2, [ta] :: ta'*{ta'}) + -- if ((s_1, ta) = $alloctable(s, tabletype)) + -- if ((s_2, ta'*{ta'}) = $alloctables(s_1, tabletype'*{tabletype'})) +} + +;; 7-module.watsup:66.1-66.49 +def allocmem : (store, memtype) -> (store, memaddr) + ;; 7-module.watsup:67.1-68.62 + def {i : nat, j : nat, mi : meminst, s : store} allocmem(s, `%I8`(`[%..%]`(i, j))) = (s[MEM_store =.. [mi]], |s.MEM_store|) + -- if (mi = {TYPE `%I8`(`[%..%]`(i, j)), DATA 0^((i * 64) * $Ki){}}) + +;; 7-module.watsup:70.1-70.52 +rec { + +;; 7-module.watsup:70.1-70.52 +def allocmems : (store, memtype*) -> (store, memaddr*) + ;; 7-module.watsup:71.1-71.42 + def {s : store} allocmems(s, []) = (s, []) + ;; 7-module.watsup:72.1-74.49 + def {ma : memaddr, ma'* : memaddr*, memtype : memtype, memtype'* : memtype*, s : store, s_1 : store, s_2 : store} allocmems(s, [memtype] :: memtype'*{memtype'}) = (s_2, [ma] :: ma'*{ma'}) + -- if ((s_1, ma) = $allocmem(s, memtype)) + -- if ((s_2, ma'*{ma'}) = $allocmems(s_1, memtype'*{memtype'})) +} + +;; 7-module.watsup:76.1-76.57 +def allocelem : (store, reftype, ref*) -> (store, elemaddr) + ;; 7-module.watsup:77.1-78.36 + def {ei : eleminst, ref* : ref*, rt : reftype, s : store} allocelem(s, rt, ref*{ref}) = (s[ELEM_store =.. [ei]], |s.ELEM_store|) + -- if (ei = {TYPE rt, ELEM ref*{ref}}) + +;; 7-module.watsup:80.1-80.63 +rec { + +;; 7-module.watsup:80.1-80.63 +def allocelems : (store, reftype*, ref**) -> (store, elemaddr*) + ;; 7-module.watsup:81.1-81.52 + def {s : store} allocelems(s, [], []) = (s, []) + ;; 7-module.watsup:82.1-84.53 + def {ea : elemaddr, ea'* : elemaddr*, ref* : ref*, ref'** : ref**, rt : reftype, rt'* : reftype*, s : store, s_1 : store, s_2 : store} allocelems(s, [rt] :: rt'*{rt'}, [ref]*{ref} :: ref'*{ref'}*{ref'}) = (s_2, [ea] :: ea'*{ea'}) + -- if ((s_1, ea) = $allocelem(s, rt, ref*{ref})) + -- if ((s_2, ea'*{ea'}) = $allocelems(s_2, rt'*{rt'}, ref'*{ref'}*{ref'})) +} + +;; 7-module.watsup:86.1-86.49 +def allocdata : (store, byte*) -> (store, dataaddr) + ;; 7-module.watsup:87.1-88.28 + def {byte* : byte*, di : datainst, s : store} allocdata(s, byte*{byte}) = (s[DATA_store =.. [di]], |s.DATA_store|) + -- if (di = {DATA byte*{byte}}) + +;; 7-module.watsup:90.1-90.52 +rec { + +;; 7-module.watsup:90.1-90.52 +def allocdatas : (store, byte**) -> (store, dataaddr*) + ;; 7-module.watsup:91.1-91.43 + def {s : store} allocdatas(s, []) = (s, []) + ;; 7-module.watsup:92.1-94.48 + def {byte* : byte*, byte'** : byte**, da : dataaddr, da'* : dataaddr*, s : store, s_1 : store, s_2 : store} allocdatas(s, [byte]*{byte} :: byte'*{byte'}*{byte'}) = (s_2, [da] :: da'*{da'}) + -- if ((s_1, da) = $allocdata(s, byte*{byte})) + -- if ((s_2, da'*{da'}) = $allocdatas(s_1, byte'*{byte'}*{byte'})) +} + +;; 7-module.watsup:97.1-97.81 +def allocmodule : (store, module, externval*, val*, ref**) -> (store, moduleinst) + ;; 7-module.watsup:98.1-135.54 + def {byte*^n_data : byte*^n_data, da* : dataaddr*, datamode?^n_data : datamode?^n_data, ea* : elemaddr*, elemmode?^n_elem : elemmode?^n_elem, export* : export*, expr_1^n_global : expr^n_global, expr_2*^n_elem : expr*^n_elem, externval* : externval*, fa* : funcaddr*, fa_ex* : funcaddr*, func^n_func : func^n_func, ga* : globaladdr*, ga_ex* : globaladdr*, globaltype^n_global : globaltype^n_global, i_data^n_data : nat^n_data, i_elem^n_elem : nat^n_elem, i_func^n_func : nat^n_func, i_global^n_global : nat^n_global, i_mem^n_mem : nat^n_mem, i_table^n_table : nat^n_table, import* : import*, m : moduleinst, ma* : memaddr*, ma_ex* : memaddr*, memtype^n_mem : memtype^n_mem, module : module, n_data : n, n_elem : n, n_func : n, n_global : n, n_mem : n, n_table : n, ref** : ref**, rt^n_elem : reftype^n_elem, s : store, s_1 : store, s_2 : store, s_3 : store, s_4 : store, s_5 : store, s_6 : store, start? : start?, ta* : tableaddr*, ta_ex* : tableaddr*, tabletype^n_table : tabletype^n_table, val* : val*, xi* : exportinst*} allocmodule(s, module, externval*{externval}, val*{val}, ref*{ref}*{ref}) = (s_6, m) + -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func^n_func{func}, GLOBAL(globaltype, expr_1)^n_global{expr_1 globaltype}, TABLE(tabletype)^n_table{tabletype}, MEMORY(memtype)^n_mem{memtype}, `ELEM%%*%?`(rt, expr_2*{expr_2}, elemmode?{elemmode})^n_elem{elemmode expr_2 rt}, `DATA%*%?`(byte*{byte}, datamode?{datamode})^n_data{byte datamode}, start?{start}, export*{export})) + -- if (fa_ex*{fa_ex} = $funcs(externval*{externval})) + -- if (ga_ex*{ga_ex} = $globals(externval*{externval})) + -- if (ta_ex*{ta_ex} = $tables(externval*{externval})) + -- if (ma_ex*{ma_ex} = $mems(externval*{externval})) + -- if (fa*{fa} = (|s.FUNC_store| + i_func)^(i_func instr* + ;; 7-module.watsup:139.1-139.46 + def {expr* : expr*, i : nat, reftype : reftype} runelem(`ELEM%%*%?`(reftype, expr*{expr}, ?()), i) = [] + ;; 7-module.watsup:140.1-140.62 + def {expr* : expr*, i : nat, reftype : reftype} runelem(`ELEM%%*%?`(reftype, expr*{expr}, ?(DECLARE_elemmode)), i) = [ELEM.DROP_instr(i)] + ;; 7-module.watsup:141.1-143.20 + def {expr* : expr*, i : nat, instr* : instr*, n : n, reftype : reftype, x : idx} runelem(`ELEM%%*%?`(reftype, expr*{expr}, ?(TABLE_elemmode(x, instr*{instr}))), i) = instr*{instr} :: [CONST_instr(I32_numtype, 0) CONST_instr(I32_numtype, n) TABLE.INIT_instr(x, i) ELEM.DROP_instr(i)] + -- if (n = |expr*{expr}|) + +;; 7-module.watsup:145.1-145.33 +def rundata : (data, idx) -> instr* + ;; 7-module.watsup:146.1-146.38 + def {byte* : byte*, i : nat} rundata(`DATA%*%?`(byte*{byte}, ?()), i) = [] + ;; 7-module.watsup:147.1-149.20 + def {byte* : byte*, i : nat, instr* : instr*, n : n} rundata(`DATA%*%?`(byte*{byte}, ?(MEMORY_datamode(0, instr*{instr}))), i) = instr*{instr} :: [CONST_instr(I32_numtype, 0) CONST_instr(I32_numtype, n) MEMORY.INIT_instr(i) DATA.DROP_instr(i)] + -- if (n = |byte*{byte}|) + +;; 7-module.watsup:152.1-152.36 +rec { + +;; 7-module.watsup:152.1-152.36 +def concat_instr : instr** -> instr* + ;; 7-module.watsup:153.1-153.37 + def concat_instr([]) = [] + ;; 7-module.watsup:154.1-154.68 + def {instr* : instr*, instr'** : instr**} concat_instr([instr]*{instr} :: instr'*{instr'}*{instr'}) = instr*{instr} :: $concat_instr(instr'*{instr'}*{instr'}) +} + +;; 7-module.watsup:157.1-157.55 +def instantiation : (store, module, externval*) -> config + ;; 7-module.watsup:158.1-180.28 + def {data* : data*, elem* : elem*, elemmode?* : elemmode?*, export* : export*, externval* : externval*, f : frame, f_init : frame, func* : func*, global* : global*, globaltype* : globaltype*, i^n_elem : nat^n_elem, import* : import*, instr_1** : instr**, instr_2*** : instr***, instr_data* : instr*, instr_elem* : instr*, j^n_data : nat^n_data, m : moduleinst, m_init : moduleinst, mem* : mem*, module : module, n_data : n, n_elem : n, ref** : ref**, reftype* : reftype*, s : store, s' : store, start? : start?, table* : table*, val* : val*, x? : idx?} instantiation(s, module, externval*{externval}) = `%;%*`(`%;%`(s', f), $admininstr_instr(instr_elem)*{instr_elem} :: $admininstr_instr(instr_data)*{instr_data} :: CALL_admininstr(x)?{x}) + -- if (module = `MODULE%*%*%*%*%*%*%*%?%*`(import*{import}, func*{func}, global*{global}, table*{table}, mem*{mem}, elem*{elem}, data*{data}, start?{start}, export*{export})) + -- if (m_init = {FUNC $funcs(externval*{externval}), GLOBAL $globals(externval*{externval}), TABLE [], MEM [], ELEM [], DATA [], EXPORT []}) + -- if (f_init = {LOCAL [], MODULE m_init}) + -- if (global*{global} = GLOBAL(globaltype, instr_1*{instr_1})*{globaltype instr_1}) + -- (Step_read: `%~>%*`(`%;%*`(`%;%`(s, f_init), $admininstr_instr(instr_1)*{instr_1}), [$admininstr_val(val)]))*{instr_1 val} + -- if (elem*{elem} = `ELEM%%*%?`(reftype, instr_2*{instr_2}*{instr_2}, elemmode?{elemmode})*{elemmode instr_2 reftype}) + -- (Step_read: `%~>%*`(`%;%*`(`%;%`(s, f_init), $admininstr_instr(instr_2)*{instr_2}), [$admininstr_ref(ref)]))*{instr_2 ref}*{instr_2 ref} + -- if ((s', m) = $allocmodule(s, module, externval*{externval}, val*{val}, ref*{ref}*{ref})) + -- if (f = {LOCAL [], MODULE m}) + -- if (n_elem = |elem*{elem}|) + -- if (instr_elem*{instr_elem} = $concat_instr($runelem(elem*{elem}[i], i)^(i config + ;; 7-module.watsup:184.1-196.52 + def {expr : expr, f : frame, fa : funcaddr, functype : functype, k : nat, m : moduleinst, n : n, s : store, val^n : val^n, valtype* : valtype*, valtype_param^n : valtype^n, valtype_res^k : valtype^k} invocation(s, fa, val^n{val}) = `%;%*`(`%;%`(s, f), $admininstr_val(val)^n{val} :: [CALL_ADDR_admininstr(fa)]) + -- if (m = {FUNC [], GLOBAL [], TABLE [], MEM [], ELEM [], DATA [], EXPORT []}) + -- if (f = {LOCAL [], MODULE m}) + -- if ($funcinst(`%;%`(s, f))[fa].CODE_funcinst = `FUNC%%*%`(functype, valtype*{valtype}, expr)) + -- if (functype = `%->%`(valtype_param^n{valtype_param}, valtype_res^k{valtype_res})) + == IL Validation... == Complete. ```