Files
wasmtime/crates/runtime/signalhandlers/Trampolines.cpp
Alex Crichton 80b095f2e2 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
2020-02-20 09:28:12 -06:00

24 lines
364 B
C++

#include <setjmp.h>
#include "SignalHandlers.hpp"
extern "C"
int RegisterSetjmp(
void **buf_storage,
void (*body)(void*),
void *payload) {
jmp_buf buf;
if (setjmp(buf) != 0) {
return 0;
}
*buf_storage = &buf;
body(payload);
return 1;
}
extern "C"
void Unwind(void *JmpBuf) {
jmp_buf *buf = (jmp_buf*) JmpBuf;
longjmp(*buf, 1);
}