Add a type parameter to VMOffsets for pointer size (#3020)

* Add a type parameter to `VMOffsets` for pointer size

This commit adds a type parameter to `VMOffsets` representing the
pointer size to improve computations in `wasmtime-runtime` which always
use a constant value of the host's pointer size. The type parameter is
`u8` for `wasmtime-cranelift`'s use case where cross-compilation may be
involved.

* fix lightbeam
This commit is contained in:
Alex Crichton
2021-07-13 09:52:27 -05:00
committed by GitHub
parent 75e5219792
commit 992d85ae8b
7 changed files with 111 additions and 78 deletions

View File

@@ -120,7 +120,7 @@ pub struct FuncEnvironment<'module_environment> {
builtin_function_signatures: BuiltinFunctionSignatures,
/// Offsets to struct fields accessed by JIT code.
pub(crate) offsets: VMOffsets,
pub(crate) offsets: VMOffsets<u8>,
tunables: &'module_environment Tunables,
@@ -288,7 +288,7 @@ impl<'module_environment> FuncEnvironment<'module_environment> {
// If this changes that's ok, the `atomic_rmw` below just needs to be
// preceded with an add instruction of `externref` and the offset.
assert_eq!(VMOffsets::vm_extern_data_ref_count(), 0);
assert_eq!(self.offsets.vm_extern_data_ref_count(), 0);
let delta = builder.ins().iconst(pointer_type, delta);
builder.ins().atomic_rmw(
pointer_type,