Skip to content
This repository was archived by the owner on Apr 25, 2025. It is now read-only.

func.bind and call_ref on generic funcref values #13

Closed
lars-t-hansen opened this issue Feb 24, 2020 · 1 comment
Closed

func.bind and call_ref on generic funcref values #13

lars-t-hansen opened this issue Feb 24, 2020 · 1 comment

Comments

@lars-t-hansen
Copy link
Contributor

(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.

@rossberg
Copy link
Member

Func.bind has been dropped from the proposal.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants