-
Notifications
You must be signed in to change notification settings - Fork 4
idea for interaction with ref.cast #1
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
Comments
So here's what I was thinking for how one would bridge untyped function references (i.e. First, have an instruction like Note that, with These observations suggest to me that typed function references and untyped function references are distinct kinds of values, and consequently there's no subtyping relationship between these types. This observation is in line with the research on mixing sound typed and untyped functions. It also means that a typed function reference can be simply a pointer to assembly code that expects arguments of the given type and returns values of the given type. |
Ok, makes sense. It looks like the main difference is the broader question about function reference subtyping. |
Possibly. As I said, you can have both if you really want to. |
Hmm, I came across another way to look at the difference between rtts and call tags. Rtts are positive tags whereas call tags are negative tags. That is, the differ in who first commits to choosing what the cast should be and who can switch on that choice. With rtts, the castee first commits, and the caster can switch on that choice. With call tags, the caster first commits, and the callee can switch on that choice. Interestingly, since most types are positive, it seems to turn out that positive tags are the better fit for most data. But as functions are negative, it seems to turn out that negative tags are the better fit for them. I can't explain why that is, but it's an interesting observation. Either way, this suggests that rtts and call tags really are distinct concepts, which makes me concerned that attempts to combine them into one will not fair well. |
Thinking about callee-checked call tags vs. caller-checked casting from
funcref
to typed function references viaref.cast
, both seem valuable for optimizing different cases. The former can efficiently capture situations like interface dispatch, as presented. The latter can allow a type check to hoisted so it is performed once, followed by multiple typed (unchecked) calls.It seems like one can support both by specifying:
funcref
) as an "overload set" of N other functions (i.e.,dispatch_func
from #1346)funcref
s can be downcast viaref.cast
rtt
call_indirect
for passing anrtt
(call_funcref
from #1346)rtt
srtt
call_indirect $t
behaves as if using the newcall_indirect
variant, passingrtt.canon $t
, which means it also works for overload setsI think it would be possible to implement this feature with purely caller-side checking (reducing the two
call_indirect
variants into aref.cast
followed bycall_ref
), but I think it would be somewhat more efficient for the implementation to implement the twocall_indirect
s as a callee-side check. In any case, to supportref.cast
on an overload-setfuncref
, the implementation would need to have the list ofrtt
s efficiently reachable from thefuncref
, which seems doable.Anyhow, this is just a sketch of an idea for how to achieve both of these goals. Maybe I'm neglecting some details.
The text was updated successfully, but these errors were encountered: