func.bind and call_ref on generic funcref values #13
Description
(This is vaguely related to #11 and also came up whilst chatting with Luke about funcref and func.bind.)
It's possible to have safe func.bind and call_ref without typed functions, needing only funcref. The mechanism would be the same as for call_indirect: there's a runtime signature check. That's overhead, but we optimize it pretty well for call_indirect.
func.bind_checked $t $u
would check that the funcptr argument (on the stack) has the type $t; $u would be the desired type of the bound function, as for the proposed func.bind
.
call_ref_checked $t
would similarly check that the funcptr argument (on the stack) has the type $t, in the manner of call_indirect.
I'm curious about whether this is worth pursuing as an MVP of the MVP of typed functions, or simply because it is useful functionality when compiling some source languages - after all there is no proposed downcast from funcref to a typed function, yet sometimes a funcref slot may be the best way to store something. I'm not sure what the answer is.