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:
Nick Fitzgerald
2023-02-07 14:09:02 -08:00
committed by GitHub
parent edfa10d607
commit 317cc51337
23 changed files with 126 additions and 126 deletions

View File

@@ -184,7 +184,7 @@ pub enum GlobalInitializer {
/// A core wasm function was "generated" via `canon lower` of a function
/// that was `canon lift`'d in the same component, meaning that the function
/// always traps. This is recorded within the `VMComponentContext` as a new
/// `VMCallerCheckedAnyfunc` that's available for use.
/// `VMCallerCheckedFuncRef` that's available for use.
AlwaysTrap(AlwaysTrap),
/// A core wasm linear memory is going to be saved into the
@@ -213,7 +213,7 @@ pub enum GlobalInitializer {
SaveModuleImport(RuntimeImportIndex),
/// Similar to `ExtractMemory` and friends and indicates that a
/// `VMCallerCheckedAnyfunc` needs to be initialized for a transcoder
/// `VMCallerCheckedFuncRef` needs to be initialized for a transcoder
/// function and this will later be used to instantiate an adapter module.
Transcoder(Transcoder),
}
@@ -469,7 +469,7 @@ pub enum StringEncoding {
pub struct Transcoder {
/// The index of the transcoder being defined and initialized.
///
/// This indicates which `VMCallerCheckedAnyfunc` slot is written to in a
/// This indicates which `VMCallerCheckedFuncRef` slot is written to in a
/// `VMComponentContext`.
pub index: RuntimeTranscoderIndex,
/// The transcoding operation being performed.

View File

@@ -181,7 +181,7 @@ indices! {
/// Index into the list of transcoders identified during compilation.
///
/// This is used to index the `VMCallerCheckedAnyfunc` slots reserved for
/// This is used to index the `VMCallerCheckedFuncRef` slots reserved for
/// string encoders which reference linear memories defined within a
/// component.
pub struct RuntimeTranscoderIndex(u32);

View File

@@ -6,13 +6,13 @@
// store: *mut dyn Store,
// limits: *const VMRuntimeLimits,
// flags: [VMGlobalDefinition; component.num_runtime_component_instances],
// lowering_anyfuncs: [VMCallerCheckedAnyfunc; component.num_lowerings],
// always_trap_anyfuncs: [VMCallerCheckedAnyfunc; component.num_always_trap],
// transcoder_anyfuncs: [VMCallerCheckedAnyfunc; component.num_transcoders],
// lowering_anyfuncs: [VMCallerCheckedFuncRef; component.num_lowerings],
// always_trap_anyfuncs: [VMCallerCheckedFuncRef; component.num_always_trap],
// transcoder_anyfuncs: [VMCallerCheckedFuncRef; component.num_transcoders],
// lowerings: [VMLowering; component.num_lowerings],
// memories: [*mut VMMemoryDefinition; component.num_memories],
// reallocs: [*mut VMCallerCheckedAnyfunc; component.num_reallocs],
// post_returns: [*mut VMCallerCheckedAnyfunc; component.num_post_returns],
// reallocs: [*mut VMCallerCheckedFuncRef; component.num_reallocs],
// post_returns: [*mut VMCallerCheckedFuncRef; component.num_post_returns],
// }
use crate::component::{
@@ -57,7 +57,7 @@ pub struct VMComponentOffsets<P> {
/// least 1).
pub num_runtime_component_instances: u32,
/// Number of "always trap" functions which have their
/// `VMCallerCheckedAnyfunc` stored inline in the `VMComponentContext`.
/// `VMCallerCheckedFuncRef` stored inline in the `VMComponentContext`.
pub num_always_trap: u32,
/// Number of transcoders needed for string conversion.
pub num_transcoders: u32,
@@ -148,9 +148,9 @@ impl<P: PtrSize> VMComponentOffsets<P> {
align(16),
size(flags) = cmul(ret.num_runtime_component_instances, ret.ptr.size_of_vmglobal_definition()),
align(u32::from(ret.ptr.size())),
size(lowering_anyfuncs) = cmul(ret.num_lowerings, ret.ptr.size_of_vmcaller_checked_anyfunc()),
size(always_trap_anyfuncs) = cmul(ret.num_always_trap, ret.ptr.size_of_vmcaller_checked_anyfunc()),
size(transcoder_anyfuncs) = cmul(ret.num_transcoders, ret.ptr.size_of_vmcaller_checked_anyfunc()),
size(lowering_anyfuncs) = cmul(ret.num_lowerings, ret.ptr.size_of_vmcaller_checked_func_ref()),
size(always_trap_anyfuncs) = cmul(ret.num_always_trap, ret.ptr.size_of_vmcaller_checked_func_ref()),
size(transcoder_anyfuncs) = cmul(ret.num_transcoders, ret.ptr.size_of_vmcaller_checked_func_ref()),
size(lowerings) = cmul(ret.num_lowerings, ret.ptr.size() * 2),
size(memories) = cmul(ret.num_runtime_memories, ret.ptr.size()),
size(reallocs) = cmul(ret.num_runtime_reallocs, ret.ptr.size()),
@@ -210,12 +210,12 @@ impl<P: PtrSize> VMComponentOffsets<P> {
self.lowering_anyfuncs
}
/// The offset of `VMCallerCheckedAnyfunc` for the `index` specified.
/// The offset of `VMCallerCheckedFuncRef` for the `index` specified.
#[inline]
pub fn lowering_anyfunc(&self, index: LoweredIndex) -> u32 {
assert!(index.as_u32() < self.num_lowerings);
self.lowering_anyfuncs()
+ index.as_u32() * u32::from(self.ptr.size_of_vmcaller_checked_anyfunc())
+ index.as_u32() * u32::from(self.ptr.size_of_vmcaller_checked_func_ref())
}
/// The offset of the `always_trap_anyfuncs` field.
@@ -224,12 +224,12 @@ impl<P: PtrSize> VMComponentOffsets<P> {
self.always_trap_anyfuncs
}
/// The offset of `VMCallerCheckedAnyfunc` for the `index` specified.
/// The offset of `VMCallerCheckedFuncRef` for the `index` specified.
#[inline]
pub fn always_trap_anyfunc(&self, index: RuntimeAlwaysTrapIndex) -> u32 {
assert!(index.as_u32() < self.num_always_trap);
self.always_trap_anyfuncs()
+ index.as_u32() * u32::from(self.ptr.size_of_vmcaller_checked_anyfunc())
+ index.as_u32() * u32::from(self.ptr.size_of_vmcaller_checked_func_ref())
}
/// The offset of the `transcoder_anyfuncs` field.
@@ -238,12 +238,12 @@ impl<P: PtrSize> VMComponentOffsets<P> {
self.transcoder_anyfuncs
}
/// The offset of `VMCallerCheckedAnyfunc` for the `index` specified.
/// The offset of `VMCallerCheckedFuncRef` for the `index` specified.
#[inline]
pub fn transcoder_anyfunc(&self, index: RuntimeTranscoderIndex) -> u32 {
assert!(index.as_u32() < self.num_transcoders);
self.transcoder_anyfuncs()
+ index.as_u32() * u32::from(self.ptr.size_of_vmcaller_checked_anyfunc())
+ index.as_u32() * u32::from(self.ptr.size_of_vmcaller_checked_func_ref())
}
/// The offset of the `lowerings` field.
@@ -309,7 +309,7 @@ impl<P: PtrSize> VMComponentOffsets<P> {
self.reallocs
}
/// The offset of the `*mut VMCallerCheckedAnyfunc` for the runtime index
/// The offset of the `*mut VMCallerCheckedFuncRef` for the runtime index
/// provided.
#[inline]
pub fn runtime_realloc(&self, index: RuntimeReallocIndex) -> u32 {
@@ -323,7 +323,7 @@ impl<P: PtrSize> VMComponentOffsets<P> {
self.post_returns
}
/// The offset of the `*mut VMCallerCheckedAnyfunc` for the runtime index
/// The offset of the `*mut VMCallerCheckedFuncRef` for the runtime index
/// provided.
#[inline]
pub fn runtime_post_return(&self, index: RuntimePostReturnIndex) -> u32 {

View File

@@ -809,7 +809,7 @@ pub struct Module {
pub num_imported_globals: usize,
/// Number of functions that "escape" from this module may need to have a
/// `VMCallerCheckedAnyfunc` constructed for them.
/// `VMCallerCheckedFuncRef` constructed for them.
///
/// This is also the number of functions in the `functions` array below with
/// an `anyfunc` index (and is the maximum anyfunc index).

View File

@@ -20,7 +20,7 @@
// memories: [*mut VMMemoryDefinition; module.num_defined_memories],
// owned_memories: [VMMemoryDefinition; module.num_owned_memories],
// globals: [VMGlobalDefinition; module.num_defined_globals],
// anyfuncs: [VMCallerCheckedAnyfunc; module.num_escaped_funcs],
// anyfuncs: [VMCallerCheckedFuncRef; module.num_escaped_funcs],
// }
use crate::{
@@ -101,26 +101,26 @@ pub trait PtrSize {
/// The offset of the `func_ptr` field.
#[allow(clippy::erasing_op)]
#[inline]
fn vmcaller_checked_anyfunc_func_ptr(&self) -> u8 {
fn vmcaller_checked_func_ref_func_ptr(&self) -> u8 {
0 * self.size()
}
/// The offset of the `type_index` field.
#[allow(clippy::identity_op)]
#[inline]
fn vmcaller_checked_anyfunc_type_index(&self) -> u8 {
fn vmcaller_checked_func_ref_type_index(&self) -> u8 {
1 * self.size()
}
/// The offset of the `vmctx` field.
#[inline]
fn vmcaller_checked_anyfunc_vmctx(&self) -> u8 {
fn vmcaller_checked_func_ref_vmctx(&self) -> u8 {
2 * self.size()
}
/// Return the size of `VMCallerCheckedAnyfunc`.
/// Return the size of `VMCallerCheckedFuncRef`.
#[inline]
fn size_of_vmcaller_checked_anyfunc(&self) -> u8 {
fn size_of_vmcaller_checked_func_ref(&self) -> u8 {
3 * self.size()
}
@@ -233,7 +233,7 @@ pub struct VMOffsetsFields<P> {
pub num_owned_memories: u32,
/// The number of defined globals in the module.
pub num_defined_globals: u32,
/// The number of escaped functions in the module, the size of the anyfunc
/// The number of escaped functions in the module, the size of the funcref
/// array.
pub num_escaped_funcs: u32,
}
@@ -428,7 +428,7 @@ impl<P: PtrSize> From<VMOffsetsFields<P>> for VMOffsets<P> {
= cmul(ret.num_defined_globals, ret.ptr.size_of_vmglobal_definition()),
size(defined_anyfuncs) = cmul(
ret.num_escaped_funcs,
ret.ptr.size_of_vmcaller_checked_anyfunc(),
ret.ptr.size_of_vmcaller_checked_func_ref(),
),
}
@@ -749,14 +749,14 @@ impl<P: PtrSize> VMOffsets<P> {
+ index.as_u32() * u32::from(self.ptr.size_of_vmglobal_definition())
}
/// Return the offset to the `VMCallerCheckedAnyfunc` for the given function
/// Return the offset to the `VMCallerCheckedFuncRef` for the given function
/// index (either imported or defined).
#[inline]
pub fn vmctx_anyfunc(&self, index: AnyfuncIndex) -> u32 {
assert!(!index.is_reserved_value());
assert!(index.as_u32() < self.num_escaped_funcs);
self.vmctx_anyfuncs_begin()
+ index.as_u32() * u32::from(self.ptr.size_of_vmcaller_checked_anyfunc())
+ index.as_u32() * u32::from(self.ptr.size_of_vmcaller_checked_func_ref())
}
/// Return the offset to the `body` field in `*const VMFunctionBody` index `index`.