diff --git a/specification/wasm-3.0/2.1-validation.types.spectec b/specification/wasm-3.0/2.1-validation.types.spectec index 0d74d8109e..eac31a1408 100644 --- a/specification/wasm-3.0/2.1-validation.types.spectec +++ b/specification/wasm-3.0/2.1-validation.types.spectec @@ -222,11 +222,11 @@ rule Globaltype_ok: rule Memtype_ok: C |- addrtype limits PAGE : OK - -- Limits_ok: C |- limits : $(2^16) + -- Limits_ok: C |- limits : $(2^($size(addrtype) - 16)) rule Tabletype_ok: C |- addrtype limits reftype : OK - -- Limits_ok: C |- limits : $(2^32 - 1) + -- Limits_ok: C |- limits : $(2^$size(addrtype) - 1) -- Reftype_ok: C |- reftype : OK diff --git a/spectec/doc/example/output/NanoWasm.pdf b/spectec/doc/example/output/NanoWasm.pdf index 50850e9bd5..270dac88bd 100644 Binary files a/spectec/doc/example/output/NanoWasm.pdf and b/spectec/doc/example/output/NanoWasm.pdf differ diff --git a/spectec/test-frontend/TEST.md b/spectec/test-frontend/TEST.md index 60c4bfc6d4..310c7aaa93 100644 --- a/spectec/test-frontend/TEST.md +++ b/spectec/test-frontend/TEST.md @@ -3148,14 +3148,14 @@ relation Memtype_ok: `%|-%:OK`(context, memtype) ;; ../../../../specification/wasm-3.0/2.1-validation.types.spectec rule _{C : context, addrtype : addrtype, limits : limits}: `%|-%:OK`(C, `%%PAGE`_memtype(addrtype, limits)) - -- Limits_ok: `%|-%:%`(C, limits, (2 ^ 16)) + -- Limits_ok: `%|-%:%`(C, limits, (2 ^ ((($size((addrtype : addrtype <: numtype)) : nat <:> int) - (16 : nat <:> int)) : int <:> nat))) ;; ../../../../specification/wasm-3.0/2.1-validation.types.spectec relation Tabletype_ok: `%|-%:OK`(context, tabletype) ;; ../../../../specification/wasm-3.0/2.1-validation.types.spectec rule _{C : context, addrtype : addrtype, limits : limits, reftype : reftype}: `%|-%:OK`(C, `%%%`_tabletype(addrtype, limits, reftype)) - -- Limits_ok: `%|-%:%`(C, limits, ((((2 ^ 32) : nat <:> int) - (1 : nat <:> int)) : int <:> nat)) + -- Limits_ok: `%|-%:%`(C, limits, ((((2 ^ $size((addrtype : addrtype <: numtype))) : nat <:> int) - (1 : nat <:> int)) : int <:> nat)) -- Reftype_ok: `%|-%:OK`(C, reftype) ;; ../../../../specification/wasm-3.0/2.1-validation.types.spectec diff --git a/spectec/test-latex/TEST.md b/spectec/test-latex/TEST.md index 6e7984d6fb..6b6193a24b 100644 --- a/spectec/test-latex/TEST.md +++ b/spectec/test-latex/TEST.md @@ -5072,7 +5072,7 @@ $$ $$ \begin{array}{@{}c@{}}\displaystyle \frac{ -C \vdash {\mathit{limits}} : {2^{16}} +C \vdash {\mathit{limits}} : {2^{{|{\mathit{addrtype}}|} - 16}} }{ C \vdash {\mathit{addrtype}}~{\mathit{limits}}~\mathsf{page} : \mathsf{ok} } \, {[\textsc{\scriptsize K{-}mem}]} @@ -5083,7 +5083,7 @@ $$ $$ \begin{array}{@{}c@{}}\displaystyle \frac{ -C \vdash {\mathit{limits}} : {2^{32}} - 1 +C \vdash {\mathit{limits}} : {2^{{|{\mathit{addrtype}}|}}} - 1 \qquad C \vdash {\mathit{reftype}} : \mathsf{ok} }{ diff --git a/spectec/test-middlend/TEST.md b/spectec/test-middlend/TEST.md index cd32d52dbf..018c3d0c8a 100644 --- a/spectec/test-middlend/TEST.md +++ b/spectec/test-middlend/TEST.md @@ -3138,14 +3138,14 @@ relation Memtype_ok: `%|-%:OK`(context, memtype) ;; ../../../../specification/wasm-3.0/2.1-validation.types.spectec rule _{C : context, addrtype : addrtype, limits : limits}: `%|-%:OK`(C, `%%PAGE`_memtype(addrtype, limits)) - -- Limits_ok: `%|-%:%`(C, limits, (2 ^ 16)) + -- Limits_ok: `%|-%:%`(C, limits, (2 ^ ((($size((addrtype : addrtype <: numtype)) : nat <:> int) - (16 : nat <:> int)) : int <:> nat))) ;; ../../../../specification/wasm-3.0/2.1-validation.types.spectec relation Tabletype_ok: `%|-%:OK`(context, tabletype) ;; ../../../../specification/wasm-3.0/2.1-validation.types.spectec rule _{C : context, addrtype : addrtype, limits : limits, reftype : reftype}: `%|-%:OK`(C, `%%%`_tabletype(addrtype, limits, reftype)) - -- Limits_ok: `%|-%:%`(C, limits, ((((2 ^ 32) : nat <:> int) - (1 : nat <:> int)) : int <:> nat)) + -- Limits_ok: `%|-%:%`(C, limits, ((((2 ^ $size((addrtype : addrtype <: numtype))) : nat <:> int) - (1 : nat <:> int)) : int <:> nat)) -- Reftype_ok: `%|-%:OK`(C, reftype) ;; ../../../../specification/wasm-3.0/2.1-validation.types.spectec @@ -14492,14 +14492,14 @@ relation Memtype_ok: `%|-%:OK`(context, memtype) ;; ../../../../specification/wasm-3.0/2.1-validation.types.spectec rule _{C : context, addrtype : addrtype, limits : limits}: `%|-%:OK`(C, `%%PAGE`_memtype(addrtype, limits)) - -- Limits_ok: `%|-%:%`(C, limits, (2 ^ 16)) + -- Limits_ok: `%|-%:%`(C, limits, (2 ^ ((($size((addrtype : addrtype <: numtype)) : nat <:> int) - (16 : nat <:> int)) : int <:> nat))) ;; ../../../../specification/wasm-3.0/2.1-validation.types.spectec relation Tabletype_ok: `%|-%:OK`(context, tabletype) ;; ../../../../specification/wasm-3.0/2.1-validation.types.spectec rule _{C : context, addrtype : addrtype, limits : limits, reftype : reftype}: `%|-%:OK`(C, `%%%`_tabletype(addrtype, limits, reftype)) - -- Limits_ok: `%|-%:%`(C, limits, ((((2 ^ 32) : nat <:> int) - (1 : nat <:> int)) : int <:> nat)) + -- Limits_ok: `%|-%:%`(C, limits, ((((2 ^ $size((addrtype : addrtype <: numtype))) : nat <:> int) - (1 : nat <:> int)) : int <:> nat)) -- Reftype_ok: `%|-%:OK`(C, reftype) ;; ../../../../specification/wasm-3.0/2.1-validation.types.spectec @@ -25865,14 +25865,14 @@ relation Memtype_ok: `%|-%:OK`(context, memtype) ;; ../../../../specification/wasm-3.0/2.1-validation.types.spectec rule _{C : context, addrtype : addrtype, limits : limits}: `%|-%:OK`(C, `%%PAGE`_memtype(addrtype, limits)) - -- Limits_ok: `%|-%:%`(C, limits, (2 ^ 16)) + -- Limits_ok: `%|-%:%`(C, limits, (2 ^ ((($size((addrtype : addrtype <: numtype)) : nat <:> int) - (16 : nat <:> int)) : int <:> nat))) ;; ../../../../specification/wasm-3.0/2.1-validation.types.spectec relation Tabletype_ok: `%|-%:OK`(context, tabletype) ;; ../../../../specification/wasm-3.0/2.1-validation.types.spectec rule _{C : context, addrtype : addrtype, limits : limits, reftype : reftype}: `%|-%:OK`(C, `%%%`_tabletype(addrtype, limits, reftype)) - -- Limits_ok: `%|-%:%`(C, limits, ((((2 ^ 32) : nat <:> int) - (1 : nat <:> int)) : int <:> nat)) + -- Limits_ok: `%|-%:%`(C, limits, ((((2 ^ $size((addrtype : addrtype <: numtype))) : nat <:> int) - (1 : nat <:> int)) : int <:> nat)) -- Reftype_ok: `%|-%:OK`(C, reftype) ;; ../../../../specification/wasm-3.0/2.1-validation.types.spectec diff --git a/spectec/test-prose/TEST.md b/spectec/test-prose/TEST.md index e8b5858aed..e6750e02b2 100644 --- a/spectec/test-prose/TEST.md +++ b/spectec/test-prose/TEST.md @@ -14776,7 +14776,7 @@ The global type :math:`({\mathsf{mut}^?}~t)` is :ref:`valid ` if: The memory type :math:`({\mathit{addrtype}}~{\mathit{limits}}~\mathsf{page})` is :ref:`valid ` if: - * The limits range :math:`{\mathit{limits}}` is :ref:`valid ` within :math:`{2^{16}}`. + * The limits range :math:`{\mathit{limits}}` is :ref:`valid ` within :math:`{2^{{|{\mathit{addrtype}}|} - 16}}`. @@ -14784,7 +14784,7 @@ The memory type :math:`({\mathit{addrtype}}~{\mathit{limits}}~\mathsf{page})` is The table type :math:`({\mathit{addrtype}}~{\mathit{limits}}~{\mathit{reftype}})` is :ref:`valid ` if: - * The limits range :math:`{\mathit{limits}}` is :ref:`valid ` within :math:`{2^{32}} - 1`. + * The limits range :math:`{\mathit{limits}}` is :ref:`valid ` within :math:`{2^{{|{\mathit{addrtype}}|}}} - 1`. * The reference type :math:`{\mathit{reftype}}` is :ref:`valid `. @@ -27294,11 +27294,11 @@ Globaltype_ok Memtype_ok - the memory type addrtype limits PAGE is valid if: - - the limits range limits is valid within (2 ^ 16). + - the limits range limits is valid within (2 ^ ($size(addrtype) - 16)). Tabletype_ok - the table type (addrtype limits reftype) is valid if: - - the limits range limits is valid within ((2 ^ 32) - 1). + - the limits range limits is valid within ((2 ^ $size(addrtype)) - 1). - the reference type reftype is valid. Externtype_ok