WebAssembly 规范中 "block" 和 "loop" 有什么区别?

What's the difference between "block" and "loop" in WebAssembly spec?

正如标题,规范说 "loop" 是

a block with a label at the beginning which may be used to form loops.

和 "block":

the beginning of a block construct, a sequence of instructions with a label at the end.

但是在“br”(用于将分支切换到标记块)的帮助下,我可以形成相同的控件结构甚至 "block",对吧?。那么,这两条指令有什么区别呢?

不,你不能阻止在末尾有标签,因为它说块在末尾有标签

LOOP START
label:
SOME CODE
IF condtion BR label:
EVEN MORE CODE
LOOP END

将执行一次SOME CODE。比重复一些代码直到条件不正确。比执行更多的代码

BLOCK START
SOME CODE
IF condition BR label:
EVEN MORE CODE
label:
BLOCK END

将只执行一次某些代码。当条件不正确时,可能会执行更多的代码。

A br to a block label 跳转到包含的指令序列的 end -- 它的行为类似于 C 中的 break 语句.

循环标签的 br 跳转到包含的指令序列的 start -- 它的行为类似于 C 中的 continue 语句。

前者允许向前跳跃,后者允许向后跳跃。两者都不能表达对方。