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

Support the updated reference types proposal #147

Open
alexcrichton opened this issue Jun 26, 2020 · 3 comments
Open

Support the updated reference types proposal #147

alexcrichton opened this issue Jun 26, 2020 · 3 comments

Comments

@alexcrichton
Copy link

There's been a few changes to the reference types proposal which I don't believe have been reflected into the C API. Notably I think a few things need to be added to fully support the reference types proposal:

  • wasm_val_t should be extended with a wasm_func_t or wasm_funcref_t variant in its union
  • Construction of a host-defined externref value should be supported, either through construction of wasm_ref_t directly or through a new type wasm_externref_t.
  • Given the lack of subtyping in reference types I'm not sure if the various conversion functions between wasm_ref_t and other types should still be supported (or if types like wasm_module_t should be convert-ible to references)
@alexcrichton
Copy link
Author

One thing I think may also need an update is the wasm_table_* APIs. They currently operate on a wasm_ref_t but this means that there needs to be a uniform representation, at the C API level, for reference types. Given that the reference types proposal has externref and funcref as separate types this may not be the best API any more?

One possible solution would be switching wasm_table_* APIs to working with a wasm_val_t similar to how wasm works as well. That should centralize the issue at least about how to represent these.

@fitzgen
Copy link

fitzgen commented Jul 10, 2020

See also #148

One possible solution would be switching wasm_table_* APIs to working with a wasm_val_t similar to how wasm works as well. That should centralize the issue at least about how to represent these.

I think this would be best, since wasm_val_t has to have the type tag anyways.

(or if types like wasm_module_t should be convert-ible to references)

I am also in favor of removing the everything-can-implicitly-be-a-reference stuff. If we have APIs for creating/manipulating externrefs directly, then we don't need this stuff in the spec, and can just let embedders do wasm_externref_new(my_module) themselves or whatever.

@rossberg
Copy link
Member

rossberg commented Aug 6, 2020

Yeah, this is one of the issues I mentioned when we discussed the changes to references. To be honest, I still don't know how to address that properly.

Conflating the types for references and values would be a very bad idea IMO. They are different categories, and moving forward there will be more places that are specific to references. So if going the union route, than a more appropriate solution is to introduce a new union for references (and maybe hack it so that it can be treated as a subtype of value?).

However, another problem with the union approach is that I don't know how to make it scale and how to make it future-proof. It assumes a fixed partitioning into disjoint kinds of refs, but what if that changes as the language evolves, e.g., some of these become subcategories of another, or some overlap?

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

3 participants