Skip to content

Commit

Permalink
Fix closing of types; fix rendering of nul
Browse files Browse the repository at this point in the history
  • Loading branch information
rossberg committed Sep 12, 2024
1 parent bebb0af commit 692b6e6
Show file tree
Hide file tree
Showing 8 changed files with 748 additions and 591 deletions.
6 changes: 6 additions & 0 deletions spectec/spec/wasm-3.0/2-syntax-aux.watsup
Original file line number Diff line number Diff line change
Expand Up @@ -611,11 +611,17 @@ def $subst_moduletype(xt_1* -> xt_2*, tv*, tu*) = $subst_externtype(xt_1, tv*, t
def $subst_all_valtype(valtype, heaptype*) : valtype hint(show %#`[:=%]) hint(macro "%subst")
def $subst_all_reftype(reftype, heaptype*) : reftype hint(show %#`[:=%]) hint(macro "%subst")
def $subst_all_deftype(deftype, heaptype*) : deftype hint(show %#`[:=%]) hint(macro "%subst")
def $subst_all_globaltype(globaltype, heaptype*) : globaltype hint(show %#`[:=%]) hint(macro "%subst")
def $subst_all_tabletype(tabletype, heaptype*) : tabletype hint(show %#`[:=%]) hint(macro "%subst")
def $subst_all_memtype(memtype, heaptype*) : memtype hint(show %#`[:=%]) hint(macro "%subst")
def $subst_all_moduletype(moduletype, heaptype*) : moduletype hint(show %#`[:=%]) hint(macro "%subst")

def $subst_all_valtype(t, tu^n) = $subst_valtype(t, (_IDX i)^(i<n), tu^n)
def $subst_all_reftype(rt, tu^n) = $subst_reftype(rt, (_IDX i)^(i<n), tu^n)
def $subst_all_deftype(dt, tu^n) = $subst_deftype(dt, (_IDX i)^(i<n), tu^n)
def $subst_all_globaltype(gt, tu^n) = $subst_globaltype(gt, (_IDX i)^(i<n), tu^n)
def $subst_all_tabletype(tt, tu^n) = $subst_tabletype(tt, (_IDX i)^(i<n), tu^n)
def $subst_all_memtype(mt, tu^n) = $subst_memtype(mt, (_IDX i)^(i<n), tu^n)
def $subst_all_moduletype(mmt, tu^n) = $subst_moduletype(mmt, (_IDX i)^(i<n), tu^n)

def $subst_all_deftypes(deftype*, heaptype*) : deftype* hint(show %#`[:=%]) hint(macro "%subst")
Expand Down
6 changes: 4 additions & 2 deletions spectec/spec/wasm-3.0/6-typing.watsup
Original file line number Diff line number Diff line change
Expand Up @@ -914,10 +914,12 @@ rule Instr_ok/array.init_data:
;; External reference instructions

rule Instr_ok/extern.convert_any:
C |- EXTERN.CONVERT_ANY : (REF nul ANY) -> (REF nul EXTERN)
C |- EXTERN.CONVERT_ANY : (REF nul1 ANY) -> (REF nul2 EXTERN)
-- if nul1 = nul2

rule Instr_ok/any.convert_extern:
C |- ANY.CONVERT_EXTERN : (REF nul EXTERN) -> (REF nul ANY)
C |- ANY.CONVERT_EXTERN : (REF nul1 EXTERN) -> (REF nul2 ANY)
-- if nul1 = nul2


;; Vector instructions
Expand Down
12 changes: 6 additions & 6 deletions spectec/spec/wasm-3.0/9-module.watsup
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ def $allocmems(s, memtype memtype'*) = (s_2, ma ma'*)
-- if (s_2, ma'*) = $allocmems(s_1, memtype'*)

def $alloctag(store, tagtype) : (store, tagaddr)
def $alloctag(s, at) = (s ++ {TAGS taginst}, |s.TAGS|)
def $alloctag(s, tagtype) = (s ++ {TAGS taginst}, |s.TAGS|)
---- ----
-- if taginst = { TYPE at }
-- if taginst = { TYPE tagtype }

def $alloctags(store, tagtype*) : (store, tagaddr*) hint(show $alloctag*#((%,%)))
def $alloctags(s, eps) = (s, eps)
Expand Down Expand Up @@ -129,11 +129,11 @@ def $allocmodule(s, module, externaddr*, val_G*, ref_T*, (ref_E*)*) = (s_7, modu
-- if da* = ($(|s.DATAS|+i_D))^(i_D<|data*|)
-- if dt* = $alloctypes(type*)
-- if (s_1, fa*) = $allocfuncs(s, dt*[x]*, (FUNC x local* expr_F)*, moduleinst^(|func*|))
-- if (s_2, ga*) = $allocglobals(s_1, globaltype*, val_G*)
-- if (s_3, ta*) = $alloctables(s_2, tabletype*, ref_T*)
-- if (s_4, ma*) = $allocmems(s_3, memtype*)
-- if (s_2, ga*) = $allocglobals(s_1, $subst_all_globaltype(globaltype, dt*)*, val_G*)
-- if (s_3, ta*) = $alloctables(s_2, $subst_all_tabletype(tabletype, dt*)*, ref_T*)
-- if (s_4, ma*) = $allocmems(s_3, $subst_all_memtype(memtype, dt*)*)
-- if (s_5, aa*) = $alloctags(s_4, dt*[y]*)
-- if (s_6, ea*) = $allocelems(s_5, elemtype*, (ref_E*)*)
-- if (s_6, ea*) = $allocelems(s_5, $subst_all_reftype(elemtype, dt*)*, (ref_E*)*)
-- if (s_7, da*) = $allocdatas(s_6, OK^(|data*|), (byte*)*)
;; TODO(2, rossberg): use moduleinst here and remove hack above
-- if xi* = $allocexports({FUNCS fa_I* fa*, GLOBALS ga_I* ga*, TABLES ta_I* ta*, MEMS ma_I* ma*, TAGS aa_I* aa*}, export*)
Expand Down
239 changes: 128 additions & 111 deletions spectec/test-frontend/TEST.md

Large diffs are not rendered by default.

36 changes: 28 additions & 8 deletions spectec/test-latex/TEST.md
Original file line number Diff line number Diff line change
Expand Up @@ -3302,6 +3302,24 @@ $$
\end{array}
$$
$$
\begin{array}{@{}lcl@{}l@{}}
{{\mathit{gt}}}{{}[ {:=}\, {{\mathit{tu}}^{n}} ]} &=& {{\mathit{gt}}}{{}[ {i^{i<n}} := {{\mathit{tu}}^{n}} ]} \\
\end{array}
$$
$$
\begin{array}{@{}lcl@{}l@{}}
{{\mathit{tt}}}{{}[ {:=}\, {{\mathit{tu}}^{n}} ]} &=& {{\mathit{tt}}}{{}[ {i^{i<n}} := {{\mathit{tu}}^{n}} ]} \\
\end{array}
$$
$$
\begin{array}{@{}lcl@{}l@{}}
{{\mathit{mt}}}{{}[ {:=}\, {{\mathit{tu}}^{n}} ]} &=& {{\mathit{mt}}}{{}[ {i^{i<n}} := {{\mathit{tu}}^{n}} ]} \\
\end{array}
$$
$$
\begin{array}{@{}lcl@{}l@{}}
{{\mathit{mmt}}}{{}[ {:=}\, {{\mathit{tu}}^{n}} ]} &=& {{\mathit{mmt}}}{{}[ {i^{i<n}} := {{\mathit{tu}}^{n}} ]} \\
Expand Down Expand Up @@ -6459,8 +6477,9 @@ $$
$$
\begin{array}{@{}c@{}}\displaystyle
\frac{
{\mathsf{null}}{{{}_{1}^?}} = {\mathsf{null}}{{{}_{2}^?}}
}{
C \vdash \mathsf{extern{.}convert\_any} : (\mathsf{ref}~{\mathsf{null}^?}~\mathsf{any}) \rightarrow (\mathsf{ref}~{\mathsf{null}^?}~\mathsf{extern})
C \vdash \mathsf{extern{.}convert\_any} : (\mathsf{ref}~{\mathsf{null}}{{{}_{1}^?}}~\mathsf{any}) \rightarrow (\mathsf{ref}~{\mathsf{null}}{{{}_{2}^?}}~\mathsf{extern})
} \, {[\textsc{\scriptsize T{-}extern.convert\_any}]}
\qquad
\end{array}
Expand All @@ -6469,8 +6488,9 @@ $$
$$
\begin{array}{@{}c@{}}\displaystyle
\frac{
{\mathsf{null}}{{{}_{1}^?}} = {\mathsf{null}}{{{}_{2}^?}}
}{
C \vdash \mathsf{any{.}convert\_extern} : (\mathsf{ref}~{\mathsf{null}^?}~\mathsf{extern}) \rightarrow (\mathsf{ref}~{\mathsf{null}^?}~\mathsf{any})
C \vdash \mathsf{any{.}convert\_extern} : (\mathsf{ref}~{\mathsf{null}}{{{}_{1}^?}}~\mathsf{extern}) \rightarrow (\mathsf{ref}~{\mathsf{null}}{{{}_{2}^?}}~\mathsf{any})
} \, {[\textsc{\scriptsize T{-}any.convert\_extern}]}
\qquad
\end{array}
Expand Down Expand Up @@ -9138,10 +9158,10 @@ $$
$$
\begin{array}{@{}lcl@{}l@{}}
{\mathrm{alloctag}}(s, {\mathit{at}}) &=& \multicolumn{2}{l@{}}{ (s \oplus \{ \begin{array}[t]{@{}l@{}}
{\mathrm{alloctag}}(s, {\mathit{tagtype}}) &=& \multicolumn{2}{l@{}}{ (s \oplus \{ \begin{array}[t]{@{}l@{}}
\mathsf{tags}~{\mathit{taginst}} \}\end{array}, {|s{.}\mathsf{tags}|}) } \\
\multicolumn{4}{@{}l@{}}{\qquad\quad \mbox{if}~{\mathit{taginst}} = \{ \begin{array}[t]{@{}l@{}}
\mathsf{type}~{\mathit{at}} \}\end{array}} \\
\mathsf{type}~{\mathit{tagtype}} \}\end{array}} \\
\end{array}
$$
Expand Down Expand Up @@ -9238,11 +9258,11 @@ $$
\multicolumn{4}{@{}l@{}}{\qquad\quad {\land}~{{\mathit{da}}^\ast} = {({|s{.}\mathsf{datas}|} + i_{\mathsf{d}})^{i_{\mathsf{d}}<{|{{\mathit{data}}^\ast}|}}}} \\
\multicolumn{4}{@{}l@{}}{\qquad\quad {\land}~{{\mathit{dt}}^\ast} = {{{\mathrm{alloctype}}^\ast}}{({{\mathit{type}}^\ast})}} \\
\multicolumn{4}{@{}l@{}}{\qquad\quad {\land}~(s_1, {{\mathit{fa}}^\ast}) = {{{\mathrm{allocfunc}}^\ast}}{(s, {{{\mathit{dt}}^\ast}{}[x]^\ast}, {(\mathsf{func}~x~{{\mathit{local}}^\ast}~{\mathit{expr}}_{\mathsf{f}})^\ast}, {{\mathit{moduleinst}}^{{|{{\mathit{func}}^\ast}|}}})}} \\
\multicolumn{4}{@{}l@{}}{\qquad\quad {\land}~(s_2, {{\mathit{ga}}^\ast}) = {{{\mathrm{allocglobal}}^\ast}}{(s_1, {{\mathit{globaltype}}^\ast}, {{\mathit{val}}_{\mathsf{g}}^\ast})}} \\
\multicolumn{4}{@{}l@{}}{\qquad\quad {\land}~(s_3, {{\mathit{ta}}^\ast}) = {{{\mathrm{alloctable}}^\ast}}{(s_2, {{\mathit{tabletype}}^\ast}, {{\mathit{ref}}_{\mathsf{t}}^\ast})}} \\
\multicolumn{4}{@{}l@{}}{\qquad\quad {\land}~(s_4, {{\mathit{ma}}^\ast}) = {{{\mathrm{allocmem}}^\ast}}{(s_3, {{\mathit{memtype}}^\ast})}} \\
\multicolumn{4}{@{}l@{}}{\qquad\quad {\land}~(s_2, {{\mathit{ga}}^\ast}) = {{{\mathrm{allocglobal}}^\ast}}{(s_1, {{{\mathit{globaltype}}}{{}[ {:=}\, {{\mathit{dt}}^\ast} ]}^\ast}, {{\mathit{val}}_{\mathsf{g}}^\ast})}} \\
\multicolumn{4}{@{}l@{}}{\qquad\quad {\land}~(s_3, {{\mathit{ta}}^\ast}) = {{{\mathrm{alloctable}}^\ast}}{(s_2, {{{\mathit{tabletype}}}{{}[ {:=}\, {{\mathit{dt}}^\ast} ]}^\ast}, {{\mathit{ref}}_{\mathsf{t}}^\ast})}} \\
\multicolumn{4}{@{}l@{}}{\qquad\quad {\land}~(s_4, {{\mathit{ma}}^\ast}) = {{{\mathrm{allocmem}}^\ast}}{(s_3, {{{\mathit{memtype}}}{{}[ {:=}\, {{\mathit{dt}}^\ast} ]}^\ast})}} \\
\multicolumn{4}{@{}l@{}}{\qquad\quad {\land}~(s_5, {{\mathit{aa}}^\ast}) = {{{\mathrm{alloctag}}^\ast}}{(s_4, {{{\mathit{dt}}^\ast}{}[y]^\ast})}} \\
\multicolumn{4}{@{}l@{}}{\qquad\quad {\land}~(s_6, {{\mathit{ea}}^\ast}) = {{{\mathrm{allocelem}}^\ast}}{(s_5, {{\mathit{elemtype}}^\ast}, {({{\mathit{ref}}_{\mathsf{e}}^\ast})^\ast})}} \\
\multicolumn{4}{@{}l@{}}{\qquad\quad {\land}~(s_6, {{\mathit{ea}}^\ast}) = {{{\mathrm{allocelem}}^\ast}}{(s_5, {{{\mathit{elemtype}}}{{}[ {:=}\, {{\mathit{dt}}^\ast} ]}^\ast}, {({{\mathit{ref}}_{\mathsf{e}}^\ast})^\ast})}} \\
\multicolumn{4}{@{}l@{}}{\qquad\quad {\land}~(s_7, {{\mathit{da}}^\ast}) = {{{\mathrm{allocdata}}^\ast}}{(s_6, {\mathsf{ok}^{{|{{\mathit{data}}^\ast}|}}}, {({{\mathit{byte}}^\ast})^\ast})}} \\
\multicolumn{4}{@{}l@{}}{\qquad\quad {\land}~{{\mathit{xi}}^\ast} = {{{\mathrm{allocexport}}^\ast}}{(\{ \begin{array}[t]{@{}l@{}}
\mathsf{funcs}~{{\mathit{fa}}_{\mathsf{i}}^\ast}~{{\mathit{fa}}^\ast},\; \mathsf{globals}~{{\mathit{ga}}_{\mathsf{i}}^\ast}~{{\mathit{ga}}^\ast},\; \mathsf{tables}~{{\mathit{ta}}_{\mathsf{i}}^\ast}~{{\mathit{ta}}^\ast},\; \mathsf{mems}~{{\mathit{ma}}_{\mathsf{i}}^\ast}~{{\mathit{ma}}^\ast},\; \mathsf{tags}~{{\mathit{aa}}_{\mathsf{i}}^\ast}~{{\mathit{aa}}^\ast} \}\end{array}, {{\mathit{export}}^\ast})}} \\
Expand Down
Loading

0 comments on commit 692b6e6

Please sign in to comment.