Skip to content

Conversation

@laelath
Copy link
Collaborator

@laelath laelath commented Mar 5, 2021

Closes #7

@laelath laelath requested a review from atgeller March 5, 2021 23:07
@pmatos
Copy link

pmatos commented Mar 8, 2021

Do I understand correctly that this would allow calling Racket from the Wasm redex model?
I am curious how this would work. Is this by exposing racket functions as a funcref in wasm that you put in a table and call using call_indirect? Alternatively with function references you could do call_ref. Is this the scope of what the FFI is supposed to do?

@laelath
Copy link
Collaborator Author

laelath commented Mar 8, 2021

We want to model the way that Wasm modules can be linked to call Javascript functions, which can then perform certain modifications to the Wasm module from outside the Wasm runtime. This PR adds Racket procedures as part of the cl definition in the paper model. This allows foreign functions to be called using the same syntax as regular function calls.

The Racket functions called are expected to take a Wasm store as the first argument, then all the arguments for the function, and return a new store, and a list of the return arguments. (It would be nice to return values to reflect how the function takes the Wasm arguments, but afaik there's no way to deal with a variable number of values).

@laelath laelath marked this pull request as draft March 9, 2021 02:14
@laelath laelath marked this pull request as ready for review March 10, 2021 00:58
@laelath laelath marked this pull request as draft March 10, 2021 01:19
@atgeller
Copy link
Owner

I think we should ensure that the returned store is an extension of the store that we call the host function with. This will give us Racket errors instead of causing Redex to blow up, which should be more helpful for debugging. It's also a closer approximation of the JS API model.

@laelath laelath marked this pull request as ready for review March 25, 2021 04:18
@laelath
Copy link
Collaborator Author

laelath commented Mar 25, 2021

This PR now includes safe procedures for ffi functions to change some of the state of the wasm program.
Closes #8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Modeling foreign functions

4 participants