WebAssembly/module-linking

In aliases, make outer module = 0 be the current module, not its parent

Closed this issue · 2 comments

This will allow mapping the same module or type to multiple indices within the current module's index space. This can be useful for wasm rewriting tools that end up doing things like de-duplicating types/modules but which do not want to renumber entities (e.g. to avoid needing to rewrite the code section, which could change the size of an encoded LEB and break debug info).

We would still preserve the acyclic property by only allowing (alias outer 0 n) where n < len(index_space).

Makes sense to me. An alias into your own index space is already achievable with a dummy module/instance:

(module
  (module $thing_i_want_to_alias)
  (module $dummy
    (import "m" (module $m))
    (export "m" (export (module $m))))
  (instance $dummy_i (instantiate $dummy (import "m" (module $thing_i_want_to_alias))))
  (alias $dummy_i "m" (module $module_alias))
)

so I don't see a reason to prevent this being done more directly via (alias outer 0 n) if it satisfies tooling use cases (which I think would not be satisfied by the above dummy technique).

Resolved by #36