WebAssembly / function-references

Proposal for Typed Function References
https://webassembly.github.io/function-references/
Other
101 stars 15 forks source link

Default/init values in JS-API for globals and table. #94

Closed yurydelendik closed 1 year ago

yurydelendik commented 1 year ago

Currently, there is a test in SM codebase:

    let g = new WebAssembly.Global({value: "externref"});
    assertEq(g.value, null);

With changes in how the init parameter works in the objects constructors (and grow method, and maybe set one), we are treating externref and funcref differently. The DefaultValues for these two are different. If I read the JS-API spec correctly, the externref default value is undefined, and the funcref is null.

What is the right value for g.value with the current spec? Will the function-references proposal change the behavior?

rossberg commented 1 year ago

Inside Wasm, the default value for all (nullable) reference types is null, so I would expect the same here.

yurydelendik commented 1 year ago

https://webassembly.github.io/function-references/js-api/index.html#defaultvalue points to ToWebAssemblyValue(undefined, valuetype) for externref. And https://webassembly.github.io/function-references/js-api/index.html#towebassemblyvalue does not really explain what undefined is mapped to.

yurydelendik commented 1 year ago

Moving discussion about externref to https://github.com/WebAssembly/spec/issues/1620