-
Notifications
You must be signed in to change notification settings - Fork 3
Description
My initial understanding of externref was "any unshared host value", especially as any.convert_extern would propagate that information to unshared anyref and all other abstract types have this notion of "not marked as shared == only unshared objects legal".
However, after starting with the implementation and considering the implications for the usage, I assume externref and anyref continue meaning "any host value independently of whether it is shared or unshared" because everything else would just be painful.
Considerations:
- A
funcrefcan be stored in anexternrefandanyrefvia the JS API as well, even though it is not a subtype ofanyref. externrefis used by toolchains for "any host value", if it disallowed shared objects, that would probably create a decent amount of pain.- For any engine having an
externrefin a signature and calling it from JS should be as cheap as possible. If we disallowed shared types there, the engine would need to check sharedness and then react accordingly. In a world where shared js structs exist, many JS values could be shared that are convertible to unshared variants (including Strings and Numbers) and therefore such a typecheck would need to consider these cases.
With externref containing shared struct and shared array, these propagate to unshared anyref then, however that only means that downcasts from anyref will need to check for non-sharedness then but these casts anyways aren't that cheap, so it probably is an acceptable cost.
WDYT? Does this make sense? Should we clarify this in the overview?
(It could very well be that some think that "obviously externref keeps the meaning of 'anything', that's how it is already spec'ed" but to me this wasn't very clear when starting with the implementation. 😄)