Rename VMCallerCheckedAnyfunc to VMCallerCheckedFuncRef (#5738)
At some point what is now `funcref` was called `anyfunc` and the spec changed, but we didn't update our internal names. This does that. Co-authored-by: Jamey Sharp <jsharp@fastly.com>
This commit is contained in:
@@ -514,22 +514,22 @@ impl VMGlobalDefinition {
|
||||
|
||||
/// Return a reference to the value as an anyfunc.
|
||||
#[allow(clippy::cast_ptr_alignment)]
|
||||
pub unsafe fn as_anyfunc(&self) -> *const VMCallerCheckedAnyfunc {
|
||||
pub unsafe fn as_anyfunc(&self) -> *const VMCallerCheckedFuncRef {
|
||||
*(self
|
||||
.storage
|
||||
.as_ref()
|
||||
.as_ptr()
|
||||
.cast::<*const VMCallerCheckedAnyfunc>())
|
||||
.cast::<*const VMCallerCheckedFuncRef>())
|
||||
}
|
||||
|
||||
/// Return a mutable reference to the value as an anyfunc.
|
||||
#[allow(clippy::cast_ptr_alignment)]
|
||||
pub unsafe fn as_anyfunc_mut(&mut self) -> &mut *const VMCallerCheckedAnyfunc {
|
||||
pub unsafe fn as_anyfunc_mut(&mut self) -> &mut *const VMCallerCheckedFuncRef {
|
||||
&mut *(self
|
||||
.storage
|
||||
.as_mut()
|
||||
.as_mut_ptr()
|
||||
.cast::<*const VMCallerCheckedAnyfunc>())
|
||||
.cast::<*const VMCallerCheckedFuncRef>())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -582,7 +582,7 @@ impl Default for VMSharedSignatureIndex {
|
||||
/// by the caller.
|
||||
#[derive(Debug, Clone)]
|
||||
#[repr(C)]
|
||||
pub struct VMCallerCheckedAnyfunc {
|
||||
pub struct VMCallerCheckedFuncRef {
|
||||
/// Function body.
|
||||
pub func_ptr: NonNull<VMFunctionBody>,
|
||||
/// Function signature id.
|
||||
@@ -597,12 +597,12 @@ pub struct VMCallerCheckedAnyfunc {
|
||||
// If more elements are added here, remember to add offset_of tests below!
|
||||
}
|
||||
|
||||
unsafe impl Send for VMCallerCheckedAnyfunc {}
|
||||
unsafe impl Sync for VMCallerCheckedAnyfunc {}
|
||||
unsafe impl Send for VMCallerCheckedFuncRef {}
|
||||
unsafe impl Sync for VMCallerCheckedFuncRef {}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test_vmcaller_checked_anyfunc {
|
||||
use super::VMCallerCheckedAnyfunc;
|
||||
use super::VMCallerCheckedFuncRef;
|
||||
use memoffset::offset_of;
|
||||
use std::mem::size_of;
|
||||
use wasmtime_environ::{Module, PtrSize, VMOffsets};
|
||||
@@ -612,20 +612,20 @@ mod test_vmcaller_checked_anyfunc {
|
||||
let module = Module::new();
|
||||
let offsets = VMOffsets::new(size_of::<*mut u8>() as u8, &module);
|
||||
assert_eq!(
|
||||
size_of::<VMCallerCheckedAnyfunc>(),
|
||||
usize::from(offsets.ptr.size_of_vmcaller_checked_anyfunc())
|
||||
size_of::<VMCallerCheckedFuncRef>(),
|
||||
usize::from(offsets.ptr.size_of_vmcaller_checked_func_ref())
|
||||
);
|
||||
assert_eq!(
|
||||
offset_of!(VMCallerCheckedAnyfunc, func_ptr),
|
||||
usize::from(offsets.ptr.vmcaller_checked_anyfunc_func_ptr())
|
||||
offset_of!(VMCallerCheckedFuncRef, func_ptr),
|
||||
usize::from(offsets.ptr.vmcaller_checked_func_ref_func_ptr())
|
||||
);
|
||||
assert_eq!(
|
||||
offset_of!(VMCallerCheckedAnyfunc, type_index),
|
||||
usize::from(offsets.ptr.vmcaller_checked_anyfunc_type_index())
|
||||
offset_of!(VMCallerCheckedFuncRef, type_index),
|
||||
usize::from(offsets.ptr.vmcaller_checked_func_ref_type_index())
|
||||
);
|
||||
assert_eq!(
|
||||
offset_of!(VMCallerCheckedAnyfunc, vmctx),
|
||||
usize::from(offsets.ptr.vmcaller_checked_anyfunc_vmctx())
|
||||
offset_of!(VMCallerCheckedFuncRef, vmctx),
|
||||
usize::from(offsets.ptr.vmcaller_checked_func_ref_vmctx())
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1144,11 +1144,11 @@ pub type VMTrampoline =
|
||||
/// target context.
|
||||
///
|
||||
/// This context is used to represent that contexts specified in
|
||||
/// `VMCallerCheckedAnyfunc` can have any type and don't have an implicit
|
||||
/// `VMCallerCheckedFuncRef` can have any type and don't have an implicit
|
||||
/// structure. Neither wasmtime nor cranelift-generated code can rely on the
|
||||
/// structure of an opaque context in general and only the code which configured
|
||||
/// the context is able to rely on a particular structure. This is because the
|
||||
/// context pointer configured for `VMCallerCheckedAnyfunc` is guaranteed to be
|
||||
/// context pointer configured for `VMCallerCheckedFuncRef` is guaranteed to be
|
||||
/// the first parameter passed.
|
||||
///
|
||||
/// Note that Wasmtime currently has a layout where all contexts that are casted
|
||||
|
||||
Reference in New Issue
Block a user