Skip to content
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

Add API to statically assert signature of a Func #955

Merged

Conversation

alexcrichton
Copy link
Member

This commit add a family of APIs to Func named getN where N is the
number of arguments. Each function will attempt to statically assert the
signature of a Func and, if matching, returns a corresponding closure
which can be used to invoke the underlying function.

The purpose of this commit is to add a highly optimized way to enter a
wasm module, performing type checks up front and avoiding all the costs
of boxing and unboxing arguments within a Val. In general this should
be much more optimized than the previous call API for entering a wasm
module, if the signature is statically known.

crates/api/src/func.rs Outdated Show resolved Hide resolved
This commit add a family of APIs to `Func` named `getN` where `N` is the
number of arguments. Each function will attempt to statically assert the
signature of a `Func` and, if matching, returns a corresponding closure
which can be used to invoke the underlying function.

The purpose of this commit is to add a highly optimized way to enter a
wasm module, performing type checks up front and avoiding all the costs
of boxing and unboxing arguments within a `Val`. In general this should
be much more optimized than the previous `call` API for entering a wasm
module, if the signature is statically known.
@alexcrichton alexcrichton merged commit 80b095f into bytecodealliance:master Feb 20, 2020
@alexcrichton alexcrichton deleted the static-assert-func-signature branch February 20, 2020 15:28
arkpar pushed a commit to paritytech/wasmtime that referenced this pull request Mar 4, 2020
This change should make the code more clear (and less code) when adding encodings for instructions with specific immediates; e.g., a constant with a 0 immediate could be encoded as an XOR with something like `const.bind(...)` without explicitly creating the necessary predicates. It has several parts:
* Introduce Bindable trait to instructions
* Convert all instruction bindings to use Bindable::bind()
* Add ability to bind immediates to BoundInstruction
This is an attempt to reduce some of the issues in bytecodealliance#955.
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.

2 participants