Replace the global-exports mechanism with a caller-vmctx mechanism. (#789)
* Replace the global-exports mechanism with a caller-vmctx mechanism. This eliminates the global exports mechanism, and instead adds a caller-vmctx argument to wasm functions so that WASI can obtain the memory and other things from the caller rather than looking them up in a global registry. This replaces #390. * Fixup some merge conflicts * Rustfmt * Ensure VMContext is aligned to 16 bytes With the removal of `global_exports` it "just so happens" that this isn't happening naturally any more. * Fixup some bugs with double vmctx in wasmtime crate * Trampoline stub needed adjusting * Use pointer type instead of always using I64 for caller vmctx * Don't store `ir::Signature` in `Func` since we don't know the pointer size at creation time. * Skip the first 2 arguments in IR signatures since that's the two vmctx parameters. * Update cranelift to 0.56.0 * Handle more merge conflicts * Rustfmt Co-authored-by: Alex Crichton <alex@alexcrichton.com>
This commit is contained in:
@@ -3,7 +3,12 @@
|
||||
#include "SignalHandlers.hpp"
|
||||
|
||||
extern "C"
|
||||
int WasmtimeCallTrampoline(void *vmctx, void (*body)(void*, void*), void *args) {
|
||||
int WasmtimeCallTrampoline(
|
||||
void *vmctx,
|
||||
void *caller_vmctx,
|
||||
void (*body)(void*, void*, void*),
|
||||
void *args)
|
||||
{
|
||||
jmp_buf buf;
|
||||
void *volatile prev;
|
||||
if (setjmp(buf) != 0) {
|
||||
@@ -11,13 +16,13 @@ int WasmtimeCallTrampoline(void *vmctx, void (*body)(void*, void*), void *args)
|
||||
return 0;
|
||||
}
|
||||
prev = EnterScope(&buf);
|
||||
body(vmctx, args);
|
||||
body(vmctx, caller_vmctx, args);
|
||||
LeaveScope(prev);
|
||||
return 1;
|
||||
}
|
||||
|
||||
extern "C"
|
||||
int WasmtimeCall(void *vmctx, void (*body)(void*)) {
|
||||
int WasmtimeCall(void *vmctx, void *caller_vmctx, void (*body)(void*, void*)) {
|
||||
jmp_buf buf;
|
||||
void *volatile prev;
|
||||
if (setjmp(buf) != 0) {
|
||||
@@ -25,7 +30,7 @@ int WasmtimeCall(void *vmctx, void (*body)(void*)) {
|
||||
return 0;
|
||||
}
|
||||
prev = EnterScope(&buf);
|
||||
body(vmctx);
|
||||
body(vmctx, caller_vmctx);
|
||||
LeaveScope(prev);
|
||||
return 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user