From 73c14ad4c507a912bdef8ea918a9869903ccf27a Mon Sep 17 00:00:00 2001 From: rossberg-chromium Date: Tue, 5 Sep 2017 12:56:53 +0200 Subject: [PATCH 1/5] [spec] Fix alignment immediate in text format --- document/core/text/instructions.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/document/core/text/instructions.rst b/document/core/text/instructions.rst index d2caf58d9d..175dacaa58 100644 --- a/document/core/text/instructions.rst +++ b/document/core/text/instructions.rst @@ -184,7 +184,7 @@ Lexically, an |Toffset| or |Talign| phrase is considered a single :ref:`keyword \text{offset{=}}o{:}\Tu32 &\Rightarrow& o \\ &&|& \epsilon &\Rightarrow& 0 \\ \production{memory alignment} & \Talign_N &::=& - \text{align{=}}a{:}\Tu32 &\Rightarrow& a \\ &&|& + \text{align{=}}a{:}\Tu32 &\Rightarrow& n & (\iff a = 2^n) \\ &&|& \epsilon &\Rightarrow& N \\ \production{instruction} & \Tplaininstr_I &::=& \dots \\ &&|& \text{i32.load}~~m{:}\Tmemarg_4 &\Rightarrow& \I32.\LOAD~m \\ &&|& From 3f242573a4ff2ee0e9dd1881e175660d86f4e9e4 Mon Sep 17 00:00:00 2001 From: rossberg-chromium Date: Tue, 5 Sep 2017 15:26:22 +0200 Subject: [PATCH 2/5] Add note about alignment --- document/core/exec/instructions.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/document/core/exec/instructions.rst b/document/core/exec/instructions.rst index d564924912..8c0347e2f3 100644 --- a/document/core/exec/instructions.rst +++ b/document/core/exec/instructions.rst @@ -372,6 +372,13 @@ Variable Instructions Memory Instructions ~~~~~~~~~~~~~~~~~~~ +.. note:: + The alignment component of a :math:`\memarg` immediate does not affect execution of a load or store instruction, + it is merely an optimization hint for the engine. + Memory access at an offset with less alignment than annotated will succeed regardless, + but may be significantly slower on some hardware. + + .. _exec-load: .. _exec-loadn: From 2484d765a94958ef5c44904b7c86758b0e783a40 Mon Sep 17 00:00:00 2001 From: rossberg-chromium Date: Tue, 5 Sep 2017 15:32:03 +0200 Subject: [PATCH 3/5] Move preexisting note --- document/core/exec/instructions.rst | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/document/core/exec/instructions.rst b/document/core/exec/instructions.rst index 8c0347e2f3..2fd91b276c 100644 --- a/document/core/exec/instructions.rst +++ b/document/core/exec/instructions.rst @@ -373,10 +373,10 @@ Memory Instructions ~~~~~~~~~~~~~~~~~~~ .. note:: - The alignment component of a :math:`\memarg` immediate does not affect execution of a load or store instruction, - it is merely an optimization hint for the engine. - Memory access at an offset with less alignment than annotated will succeed regardless, + The alignment :math:`\memarg.\ALIGN` in load and store instructions does not affect the semantics. + Unaligned access is supported for all types, and succeeds regardless of the annotation, but may be significantly slower on some hardware. + The only purpose of the annotation is to provide a respective optimizatons hints to the engine. .. _exec-load: @@ -454,11 +454,6 @@ Memory Instructions (\otherwise) \\ \end{array} -.. note:: - The alignment :math:`\memarg.\ALIGN` does not affect the semantics. - Unaligned access is supported for all types, and succeeds regardless of the annotation. - The only purpose of the annotation is to provide optimizatons hints. - .. _exec-store: .. _exec-storen: From 33cd136925f10846da502447fe3f8a992f5fbba9 Mon Sep 17 00:00:00 2001 From: rossberg-chromium Date: Tue, 5 Sep 2017 18:28:11 +0200 Subject: [PATCH 4/5] Correct log conversion --- document/core/text/instructions.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/document/core/text/instructions.rst b/document/core/text/instructions.rst index 175dacaa58..f95c590ea1 100644 --- a/document/core/text/instructions.rst +++ b/document/core/text/instructions.rst @@ -179,12 +179,12 @@ Lexically, an |Toffset| or |Talign| phrase is considered a single :ref:`keyword .. math:: \begin{array}{llclll} \production{memory argument} & \Tmemarg_N &::=& - o{:}\Toffset~~a{:}\Talign_N &\Rightarrow& \{ \ALIGN~a,~\OFFSET~o \} \\ + o{:}\Toffset~~a{:}\Talign_N &\Rightarrow& \{ \ALIGN~n,~\OFFSET~o \} & (\iff a = 2^n) \\ \production{memory offset} & \Toffset &::=& \text{offset{=}}o{:}\Tu32 &\Rightarrow& o \\ &&|& \epsilon &\Rightarrow& 0 \\ \production{memory alignment} & \Talign_N &::=& - \text{align{=}}a{:}\Tu32 &\Rightarrow& n & (\iff a = 2^n) \\ &&|& + \text{align{=}}a{:}\Tu32 &\Rightarrow& a \\ &&|& \epsilon &\Rightarrow& N \\ \production{instruction} & \Tplaininstr_I &::=& \dots \\ &&|& \text{i32.load}~~m{:}\Tmemarg_4 &\Rightarrow& \I32.\LOAD~m \\ &&|& From fb9790ec3cb809154203215321efc42b2189fdc2 Mon Sep 17 00:00:00 2001 From: rossberg-chromium Date: Tue, 5 Sep 2017 18:44:43 +0200 Subject: [PATCH 5/5] Refine note --- document/core/exec/instructions.rst | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/document/core/exec/instructions.rst b/document/core/exec/instructions.rst index 2fd91b276c..ee21271f86 100644 --- a/document/core/exec/instructions.rst +++ b/document/core/exec/instructions.rst @@ -374,9 +374,10 @@ Memory Instructions .. note:: The alignment :math:`\memarg.\ALIGN` in load and store instructions does not affect the semantics. - Unaligned access is supported for all types, and succeeds regardless of the annotation, - but may be significantly slower on some hardware. - The only purpose of the annotation is to provide a respective optimizatons hints to the engine. + It is an indication that the offset :math:`\X{ea}` at which the memory is accessed is intended to satisfy the property :math:`\X{ea} \mod 2^{\memarg.\ALIGN} = 0`. + A WebAssembly implementation can use this hint to optimize for the intended use. + Unaligned access violating that property is still allowed and must succeed regardless of the annotation. + However, it may be substantially slower on some hardware. .. _exec-load: