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

feat: Add wasm_module_name and wasm_module_set_name. #157

Closed
wants to merge 1 commit into from

Conversation

Hywan
Copy link
Contributor

@Hywan Hywan commented Oct 12, 2020

This patch proposes 2 new functions to handle module's name:

  • wasm_module_name that writes the module's name in a wasm_name_t
    if any,
  • wasm_module_set_name that sets the module's name if possible.

wasm_module_set_name returns true if the module's name has been
updated succesfully, false otherwise, e.g. if the name is invalid,
or if it's not possible to update it (e.g. if the module is already
instantiated).

Hywan added a commit to Hywan/wasmer that referenced this pull request Oct 12, 2020
I submited a proposal to the official `wasm.h` by the way,
WebAssembly/wasm-c-api#157. For the moment,
let's keep that as a vendor specific implementation.
This patch proposes 2 new functions to handle module's name:

* `wasm_module_name` that writes the module's name in a `wasm_name_t`
  if any,
* `wasm_module_set_name` that sets the module's name if possible.

`wasm_module_set_name` returns `true` if the module's name has been
updated succesfully, `false` otherwise, e.g. if the name is invalid,
or if it's not possible to update it (e.g. if the module is already
instantiated).
@rossberg
Copy link
Member

Hm, there is no such concept as a module's name in Wasm. So this would be a custom notion. But if you want to attach custom data to a module object, you already can by using wasm_module_set_host_info.

@syrusakbary
Copy link
Contributor

Some context:

We use Wasm names to identify the wasm modules when debugging.
Perhaps this is not useful for all VMs, but just throwing some context before closing the PR :)

@Hywan
Copy link
Contributor Author

Hywan commented Oct 13, 2020

What I call “name” is moduleName in (module $moduleName). How does it sound?

bors bot added a commit to wasmerio/wasmer that referenced this pull request Oct 13, 2020
1709: feat(c-api) Implement `wasm_module_name` and `wasm_module_set_name` r=Hywan a=Hywan

Until my official proposal made here, WebAssembly/wasm-c-api#157 is accepted or rejected, I implement those functions as “wasmer-specific” API.

Co-authored-by: Ivan Enderlin <[email protected]>
@rossberg
Copy link
Member

But that is just an artefact of the text format, it is not represented in the binary format (outside custom sections).

@Hywan Hywan closed this Oct 13, 2020
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.

3 participants