Save exit Wasm FP and PC in component-to-host trampolines (#4601)

* Wasmtime: Add a pointer to `VMRuntimeLimits` in component contexts

* Save exit Wasm FP and PC in component-to-host trampolines

Fixes #4535

* Add comment about why we deref the trampoline's FP

* Update some tests to use new `vmruntime_limits_*` methods
This commit is contained in:
Nick Fitzgerald
2022-08-04 08:27:30 -07:00
committed by GitHub
parent f69acd6187
commit 70ce288dc7
16 changed files with 206 additions and 149 deletions

View File

@@ -35,7 +35,7 @@ asm_func!(
#[cfg(test)]
mod host_to_wasm_trampoline_offsets_tests {
use wasmtime_environ::{Module, VMOffsets};
use wasmtime_environ::{Module, PtrSize, VMOffsets};
#[test]
fn test() {
@@ -43,7 +43,7 @@ mod host_to_wasm_trampoline_offsets_tests {
let offsets = VMOffsets::new(std::mem::size_of::<*mut u8>() as u8, &module);
assert_eq!(8, offsets.vmctx_runtime_limits());
assert_eq!(40, offsets.vmruntime_limits_last_wasm_entry_sp());
assert_eq!(40, offsets.ptr.vmruntime_limits_last_wasm_entry_sp());
assert_eq!(16, offsets.vmctx_callee());
assert_eq!(0x65726f63, u32::from_le_bytes(*b"core"));
}
@@ -79,7 +79,7 @@ asm_func!(
mod wasm_to_host_trampoline_offsets_tests {
use crate::VMHostFuncContext;
use memoffset::offset_of;
use wasmtime_environ::{Module, VMOffsets};
use wasmtime_environ::{Module, PtrSize, VMOffsets};
#[test]
fn test() {
@@ -87,8 +87,8 @@ mod wasm_to_host_trampoline_offsets_tests {
let offsets = VMOffsets::new(std::mem::size_of::<*mut u8>() as u8, &module);
assert_eq!(8, offsets.vmctx_runtime_limits());
assert_eq!(24, offsets.vmruntime_limits_last_wasm_exit_fp());
assert_eq!(32, offsets.vmruntime_limits_last_wasm_exit_pc());
assert_eq!(24, offsets.ptr.vmruntime_limits_last_wasm_exit_fp());
assert_eq!(32, offsets.ptr.vmruntime_limits_last_wasm_exit_pc());
assert_eq!(8, offset_of!(VMHostFuncContext, host_func));
}
}

View File

@@ -3,7 +3,7 @@
#[cfg(test)]
mod host_to_wasm_trampoline_offsets_tests {
use wasmtime_environ::{Module, VMOffsets};
use wasmtime_environ::{Module, PtrSize, VMOffsets};
#[test]
fn test() {
@@ -11,7 +11,7 @@ mod host_to_wasm_trampoline_offsets_tests {
let offsets = VMOffsets::new(std::mem::size_of::<*mut u8>() as u8, &module);
assert_eq!(8, offsets.vmctx_runtime_limits());
assert_eq!(40, offsets.vmruntime_limits_last_wasm_entry_sp());
assert_eq!(40, offsets.ptr.vmruntime_limits_last_wasm_entry_sp());
assert_eq!(16, offsets.vmctx_callee());
assert_eq!(0x65726f63, u32::from_le_bytes(*b"core"));
}
@@ -24,7 +24,7 @@ mod host_to_wasm_trampoline_offsets_tests {
mod wasm_to_host_trampoline_offsets_tests {
use crate::VMHostFuncContext;
use memoffset::offset_of;
use wasmtime_environ::{Module, VMOffsets};
use wasmtime_environ::{Module, PtrSize, VMOffsets};
#[test]
fn test() {
@@ -32,8 +32,8 @@ mod wasm_to_host_trampoline_offsets_tests {
let offsets = VMOffsets::new(std::mem::size_of::<*mut u8>() as u8, &module);
assert_eq!(8, offsets.vmctx_runtime_limits());
assert_eq!(24, offsets.vmruntime_limits_last_wasm_exit_fp());
assert_eq!(32, offsets.vmruntime_limits_last_wasm_exit_pc());
assert_eq!(24, offsets.ptr.vmruntime_limits_last_wasm_exit_fp());
assert_eq!(32, offsets.ptr.vmruntime_limits_last_wasm_exit_pc());
assert_eq!(8, offset_of!(VMHostFuncContext, host_func));
}
}

View File

@@ -47,7 +47,7 @@ asm_func!(
#[cfg(test)]
mod host_to_wasm_trampoline_offsets_tests {
use wasmtime_environ::{Module, VMOffsets};
use wasmtime_environ::{Module, PtrSize, VMOffsets};
#[test]
fn test() {
@@ -55,7 +55,7 @@ mod host_to_wasm_trampoline_offsets_tests {
let offsets = VMOffsets::new(std::mem::size_of::<*mut u8>() as u8, &module);
assert_eq!(8, offsets.vmctx_runtime_limits());
assert_eq!(40, offsets.vmruntime_limits_last_wasm_entry_sp());
assert_eq!(40, offsets.ptr.vmruntime_limits_last_wasm_entry_sp());
assert_eq!(16, offsets.vmctx_callee());
assert_eq!(0x65726f63, u32::from_le_bytes(*b"core"));
}
@@ -92,7 +92,7 @@ asm_func!(
mod wasm_to_host_trampoline_offsets_tests {
use crate::VMHostFuncContext;
use memoffset::offset_of;
use wasmtime_environ::{Module, VMOffsets};
use wasmtime_environ::{Module, PtrSize, VMOffsets};
#[test]
fn test() {
@@ -100,8 +100,8 @@ mod wasm_to_host_trampoline_offsets_tests {
let offsets = VMOffsets::new(std::mem::size_of::<*mut u8>() as u8, &module);
assert_eq!(8, offsets.vmctx_runtime_limits());
assert_eq!(24, offsets.vmruntime_limits_last_wasm_exit_fp());
assert_eq!(32, offsets.vmruntime_limits_last_wasm_exit_pc());
assert_eq!(24, offsets.ptr.vmruntime_limits_last_wasm_exit_fp());
assert_eq!(32, offsets.ptr.vmruntime_limits_last_wasm_exit_pc());
assert_eq!(8, offset_of!(VMHostFuncContext, host_func));
}
}