Skip to content

Conversation

@sbc100
Copy link
Member

@sbc100 sbc100 commented Apr 13, 2022

This effectively means that we no longer support imports that are
overloaded by signature only, which is not something that we need to
support in order to support the core wasm spec.

This feature is available in the JS embedding but there is no good
reason (AFAICT) to support it in wasm2c, and this simplifies the
generated code.

Fixes #1858

@sbc100 sbc100 force-pushed the wasm2c_remove_sigs branch 2 times, most recently from 8e6fb55 to 0ed29c8 Compare April 13, 2022 23:00
@sbc100 sbc100 requested review from binji and keithw April 13, 2022 23:08
This effectively means that we no longer support imports that are
overloaded by signature only, which is not something that we need to
support in order to support the core wasm spec.

This feature is available in the JS embedding but there is no good
reason (AFAICT) to support it in wasm2c, and this simplifies the
generated code.

Fixes #1858
@sbc100 sbc100 force-pushed the wasm2c_remove_sigs branch from 0ed29c8 to 44bddf0 Compare April 13, 2022 23:09
@keithw
Copy link
Member

keithw commented Apr 13, 2022

In principle this is good by us, and we'll conform to whatever you want, but, @angelamontemayor and @yhdengh had already done a version of this in #1814 (including the name of the module in the name of an exported function -- e.g. "Z_caesar_Z_rot13" for a module named "caesar" that exports a function named "rot13"), with #1877 and #1887 stacked behind it.

We added some checking for clearly erroneous duplicate imports (https://github.com/fixpointOS/wabt/blob/module_instancing/src/c-writer.cc#L953-L962) in response to @binji's review at #1877 (comment) , which might be a good idea in any case.

Bottom line, if it were up to us, our preference would be to do this as part of #1814 (after working through a review), rather than trying to rebase our PRs later. In the end, though, obviously it's your call and we'll work with whatever you prefer.

@sbc100
Copy link
Member Author

sbc100 commented Apr 13, 2022

In principle this is good by us, and we'll conform to whatever you want, but, @angelamontemayor and @yhdengh had already done a version of this in #1814 (including the name of the module in the name of an exported function -- e.g. "Z_caesar_Z_rot13" for a module named "caesar" that exports a function named "rot13"), with #1877 and #1887 stacked behind it.

We added some checking for clearly erroneous duplicate imports (https://github.com/fixpointOS/wabt/blob/module_instancing/src/c-writer.cc#L953-L962) in response to @binji's review at #1877 (comment) , which might be a good idea in any case.

Bottom line, if it were up to us, our preference would be to do this as part of #1814 (after working through a review), rather than trying to rebase our PRs later. In the end, though, obviously it's your call and we'll work with whatever you prefer.

I like the idea to doing it stages:

  1. remove signature mangling
  2. Remove optional prefixing (make it mandatory)
  3. Add instancing (wasm2c: add support for module instancing #1814)

These all seems like logically separate things and should make #1814 a lot smaller and more precise.

I'm also looking to ways to remove the Z_ where possible. It would be nicer do just have caesar_rot13 as the symbol name... but its complicated because module names and function names can also contain "_".

@keithw
Copy link
Member

keithw commented Apr 13, 2022

Ok, fine with us.

On #2 (remove optional prefixing) after #3, we think it's simplest if instance naming dictates the prefixing:

  • the names of exported functions should be determined by the name of the module (e.g. "caesar_rot13")
  • the exported globals, memories, and tables will be members of the corresponding instance structure, which in turn is named something like "caesar_module_instance_t".

But we can cross that bridge when we come to it.

We'd love to get rid of "Z"; I think what we'd have to do at that point would be to escape _ in the mangling. If every exported function symbol has a _ in it between the modname and func export name, then I don't think you have to worry about colliding with a C reserved word (like "void").

@sbc100
Copy link
Member Author

sbc100 commented Apr 13, 2022

I also have PR for removal of optional prefixing: #1897. I made these a few weeks ago but went on vacation before uploading them. Sorry I didn't realize that both of them were already basically contained in #1814

Copy link
Member

@keithw keithw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@sbc100 sbc100 merged commit 67c7490 into main Apr 14, 2022
@sbc100 sbc100 deleted the wasm2c_remove_sigs branch April 14, 2022 07:58
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

Successfully merging this pull request may close these issues.

Should we remove signature mangling from wasm2c output?

3 participants