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

questions on tag identity #324

Open
yamt opened this issue Aug 28, 2024 · 3 comments
Open

questions on tag identity #324

yamt opened this issue Aug 28, 2024 · 3 comments

Comments

@yamt
Copy link
Contributor

yamt commented Aug 28, 2024

some embedder apis have two-step instatantiation. that is,

  1. load (and validate) a module
  2. instantiate the loaded module

some embedder apis allow to instantiate a loaded module multiple times.

consider a module, module-A, which exports a tag.

load the module (loaded-module-A)
create two instances from the loaded module: instance-A1 and instance-A2

now another instance imports the tags from both of instance-A1 and instance-A2.
my understanding is that these two imported tags should be considered as different tags.
(it's how i implemented the tag matching in my runtime: https://github.com/yamt/toywasm/blob/4924e0efe7785b2482131a681928a61ca9916910/lib/type.h#L605-L619)

questions:

  • is my understanding correct?
  • i don't think wast can express the situation. the closest thing would be to write two identical (module). am i right?
@rossberg
Copy link
Member

Yes, tag definitions are "generative", i.e., allocated anew with each instantiation of a containing module.

You are right that this is not something .wast can observe right now, which is a bummer. We would need to add a separate instantiate command to support that. That's surely possible, but might be substantial work for the multiple tool chains consuming the .wast format, perhaps too much to be worthwhile. But worth discussing. @tlively

@tlively
Copy link
Member

tlively commented Aug 28, 2024

Interesting idea. In Binaryen’s case I think you’re right that this would be complicated to handle, but that’s mostly because of bugs and limitations that are already observable. We’ll work to improve our support over time, so if an instantiate command would be useful, I wouldn’t want to block it.

@rossberg
Copy link
Member

rossberg commented Sep 1, 2024

@yamt, @tlively, I created a respective PR (against the wasm-3.0 branch). It implements the script extension and adds a test for generativity of instantiation. PTAL.

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

4 participants
@yamt @rossberg @tlively and others