Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wasp encodes element sections differently than binaryen [typed function references] #63

Open
dbezhetskov opened this issue Jul 9, 2021 · 2 comments

Comments

@dbezhetskov
Copy link

The example func_ref_o.wat:

(module
  (func (export "main") (result i32)
    (call_ref (i32.const 10)
              (ref.func $foo)
    )
  )
  (func $foo (param $x i32) (result i32)
    (i32.add (local.get $x)
             (i32.const 19))
  )
  (elem declare funcref (ref.func $foo))
)

wasp wat2wasm --enable-function-references:

Contents of section element:
0000025: 0107 7001 d201 0b                        ..p....

binaryen wasm-as --enable-reference-types:

Contents of section element:
0000025: 0103 0001 01                             .....

wasp encodes element section as vec(expr) and binaryen encodes it as vec(func_idx), according to the https://github.com/WebAssembly/function-references/blob/master/proposals/function-references/Overview.md there is no any evidence that vec(expr) should be used.

Is it a bug?

@dbezhetskov dbezhetskov changed the title wasp encodes element section wrong for typed function references proposal wasp encodes element sections differently than binaryen [typed function references] Jul 9, 2021
@dbezhetskov
Copy link
Author

If someone can confirm, I can make a fix.

@binji
Copy link
Member

binji commented Aug 2, 2021

IIRC, they are both allowed and equivalent. Has that changed recently? I suppose it would be best for tools to choose the smaller size, where possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants