提问人:Sam Estep 提问时间:9/23/2023 更新时间:9/25/2023 访问量:50
尚未设置的 WebAssembly 本地值是多少?
What is the value of a WebAssembly local that has not been set?
问:
如果我用来访问我尚未通过 或 设置的 WebAssembly 本地值,我是否保证获得特定的默认值,或者这是未定义的行为?例如:local.get
local.set
local.tee
(module
(func (result i32) (local i32)
local.get 0))
在 Chrome 中运行它给出零,但我想知道规范是否保证了这一点。
答:
2赞
robbepop
9/25/2023
#1
是的,Wasm 规范要求所有局部变量都初始化为零。因此,您将在所有符合规范的运行时上获得相同的行为。
您可以在此处的规范中找到它:https://webassembly.github.io/spec/core/exec/instructions.html#exec-invoke
评论