wabt icon indicating copy to clipboard operation
wabt copied to clipboard

Function references support

Open zherczeg opened this issue 8 months ago • 5 comments
trafficstars

I would like to parse some test files using wabt from the function reference (Phase 5) proposal such as call_ref.wast.

https://github.com/WebAssembly/function-references/blob/main/test/core/call_ref.wast

I have enabled the feature with --enable-function-references.

However, I get errors such as:

call_ref.wast:5:15: error: unexpected token $ii, expected ).
    (call_ref $ii (local.get $x) (local.get $f))
              ^^^

The format of call_ref was changed in: https://github.com/WebAssembly/function-references/commit/2b194cef87ba7f71c187b063a2ff8fea878e900a

May I ask the status of function reference support in wabt? Do you plan to support these proposal changes?

Thank you very much for the help!

zherczeg avatar Mar 03 '25 14:03 zherczeg

This proposal is not yet fully supported. If you would like to take a look at adding support that would be great. Sadly wabt doesn't have many folks contributing these days to its hard to say when the proposal might get implemented.

sbc100 avatar Mar 03 '25 17:03 sbc100

I think my own long-term plan is to get wasm-tools's wat2wasm and wasm2wat (https://github.com/bytecodealliance/wasm-tools/) to the point where they can substitute fully for WABT's wat2wasm/wasm2wat, and then sunset WABT. wasm-tools already supports function-references and GC.

It would be helpful to hear: what are some of the features that you use from WABT, that wasm-tools is currently missing?

keithw avatar Mar 03 '25 18:03 keithw

Thank you for the information. Contributing to wabt might be possible, but I cannot promise anything at the moment.

Wabt is C++, and can be added to C++ projects.

zherczeg avatar Mar 03 '25 18:03 zherczeg

I will try to make a patch for this, but I have little experience with the project, so I need your guidance.

Could you help me with these questions:

  1. How can I represent an s33 value? For example type can be a value type or func index: https://github.com/WebAssembly/wabt/blob/main/include/wabt/binary-reader.h#L298

  2. How can I store a type in Val structure? Is this correct? The index is a large value, but still part of uint32_t range. https://github.com/WebAssembly/wabt/blob/main/src/wast-parser.cc#L959

  3. Type with argument looks like something new. -0x1c type (ref ht) has a $t : heaptype. How can I represent this?

zherczeg avatar Mar 10 '25 14:03 zherczeg

To start from somewhere, I have created a branch: #2562

zherczeg avatar Mar 11 '25 10:03 zherczeg

This issue can be closed. There are 6 patches implementing the whole GC support.

zherczeg avatar Oct 02 '25 11:10 zherczeg

My apologies Zoltan for the lack of progress reviewing your changes. I do hope to find time to do it, and perhaps we can find others to help too.

sbc100 avatar Oct 02 '25 17:10 sbc100