Gc: Relationship between all the heap types

Created on 1 Sep 2020  ยท  4Comments  ยท  Source: WebAssembly/gc

With reference types, function references, exceptions and GC there are multiple proposals in flight currently that introduce or concretise heap types, and I'd like to understand the relationship the new types will have in the whole picture.

There are the extern and func heap types coming from reference types, and the exn heap type from exception handling. GC introduces any, eq and i31 on top, establishing the following subtyping relationship:

   โ”Œโ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”
extern  func  eq   exn
         โ”‚    โ”‚
   signature* โ”‚
              โ”‚
        โ”Œโ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
       i31  struct*  array*

with

  • signature* being a concrete function
  • struct* being a concrete struct
  • array* being a concrete array

What I am not sure about is:

  • Is extern a subtype of eq?
  • Are there subtypes of extern?
  • Is exn a subtype of eq?

Or is there perhaps something fundamentally wrong in my understanding?

All 4 comments

The graph you've drawn matches my understanding.

externref is the new name for what used to be called anyref, and back then intentionally didn't support equality checking, so I'd assume that it continues to not be a subtype of eqref. I further assume that it won't have any subtypes, because by virtue of being an "external" reference, it's opaque to Wasm. (That said, it's conceivable that we may want to allow subtype hierarchies of opaque external references; AFAIK no such proposal is in flight yet; and the use case might be subsumed by the type-imports proposal.)

My understanding is that the exceptions proposal is debating changes that would drop the exnref type.

And you're probably aware that within this GC proposal, there's some debate around i31, so that might change in the future as well.

externref is the new name for what used to be called anyref, and back then intentionally didn't support equality checking, so I'd assume that it continues to not be a subtype of eqref. I further assume that it won't have any subtypes, because by virtue of being an "external" reference, it's opaque to Wasm. (That said, it's conceivable that we may want to allow subtype hierarchies of opaque external references; AFAIK no such proposal is in flight yet; and the use case might be subsumed by the type-imports proposal.)

Does this mean that GC will no longer have an anyref type? Or that GC's anyref type is different from the anyref-now-externref previously mentioned in reference types?

Does this mean that GC will no longer have an anyref type?

This GC proposal has an anyref type, which is an alias for (ref null any). It also has an externref type that is an alias for (ref null extern). They are different types, and AIUI extern <: any, as described above.

Thanks for the clarification.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vargaz picture vargaz  ยท  8Comments

tlively picture tlively  ยท  12Comments

fgmccabe picture fgmccabe  ยท  9Comments

binji picture binji  ยท  12Comments

tlively picture tlively  ยท  8Comments