Add API to statically assert signature of a Func (#955)
* Add API to statically assert signature of a `Func` 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. * rustfmt * Remove stray debugging
This commit is contained in:
@@ -3,35 +3,16 @@
|
||||
#include "SignalHandlers.hpp"
|
||||
|
||||
extern "C"
|
||||
int WasmtimeCallTrampoline(
|
||||
int RegisterSetjmp(
|
||||
void **buf_storage,
|
||||
void *vmctx,
|
||||
void *caller_vmctx,
|
||||
void (*trampoline)(void*, void*, void*, void*),
|
||||
void *body,
|
||||
void *args)
|
||||
{
|
||||
void (*body)(void*),
|
||||
void *payload) {
|
||||
jmp_buf buf;
|
||||
if (setjmp(buf) != 0) {
|
||||
return 0;
|
||||
}
|
||||
*buf_storage = &buf;
|
||||
trampoline(vmctx, caller_vmctx, body, args);
|
||||
return 1;
|
||||
}
|
||||
|
||||
extern "C"
|
||||
int WasmtimeCall(
|
||||
void **buf_storage,
|
||||
void *vmctx,
|
||||
void *caller_vmctx,
|
||||
void (*body)(void*, void*)) {
|
||||
jmp_buf buf;
|
||||
if (setjmp(buf) != 0) {
|
||||
return 0;
|
||||
}
|
||||
*buf_storage = &buf;
|
||||
body(vmctx, caller_vmctx);
|
||||
body(payload);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user