Skip to content

Commit 317cc51

Browse files
fitzgenjameysharp
andauthored
Rename VMCallerCheckedAnyfunc to VMCallerCheckedFuncRef (bytecodealliance#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 <[email protected]>
1 parent edfa10d commit 317cc51

File tree

23 files changed

+126
-126
lines changed

23 files changed

+126
-126
lines changed

crates/cranelift/src/compiler/component.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ impl ComponentCompiler for Compiler {
9595
None => builder.ins().iconst(pointer_type, 0),
9696
});
9797

98-
// realloc: *mut VMCallerCheckedAnyfunc
98+
// realloc: *mut VMCallerCheckedFuncRef
9999
host_sig.params.push(ir::AbiParam::new(pointer_type));
100100
callee_args.push(match realloc {
101101
Some(idx) => builder.ins().load(

crates/cranelift/src/func_environ.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1586,21 +1586,21 @@ impl<'module_environment> cranelift_wasm::FuncEnvironment for FuncEnvironment<'m
15861586
) -> WasmResult<ir::Inst> {
15871587
let pointer_type = self.pointer_type();
15881588

1589-
// Get the anyfunc pointer (the funcref) from the table.
1590-
let anyfunc_ptr = self.get_or_init_funcref_table_elem(builder, table_index, table, callee);
1589+
// Get the funcref pointer from the table.
1590+
let funcref_ptr = self.get_or_init_funcref_table_elem(builder, table_index, table, callee);
15911591

15921592
// Check for whether the table element is null, and trap if so.
15931593
builder
15941594
.ins()
1595-
.trapz(anyfunc_ptr, ir::TrapCode::IndirectCallToNull);
1595+
.trapz(funcref_ptr, ir::TrapCode::IndirectCallToNull);
15961596

1597-
// Dereference anyfunc pointer to get the function address.
1597+
// Dereference the funcref pointer to get the function address.
15981598
let mem_flags = ir::MemFlags::trusted();
15991599
let func_addr = builder.ins().load(
16001600
pointer_type,
16011601
mem_flags,
1602-
anyfunc_ptr,
1603-
i32::from(self.offsets.ptr.vmcaller_checked_anyfunc_func_ptr()),
1602+
funcref_ptr,
1603+
i32::from(self.offsets.ptr.vmcaller_checked_func_ref_func_ptr()),
16041604
);
16051605

16061606
// If necessary, check the signature.
@@ -1612,7 +1612,7 @@ impl<'module_environment> cranelift_wasm::FuncEnvironment for FuncEnvironment<'m
16121612
let base = builder.ins().global_value(pointer_type, vmctx);
16131613

16141614
// Load the caller ID. This requires loading the
1615-
// `*mut VMCallerCheckedAnyfunc` base pointer from `VMContext`
1615+
// `*mut VMCallerCheckedFuncRef` base pointer from `VMContext`
16161616
// and then loading, based on `SignatureIndex`, the
16171617
// corresponding entry.
16181618
let mem_flags = ir::MemFlags::trusted().with_readonly();
@@ -1635,8 +1635,8 @@ impl<'module_environment> cranelift_wasm::FuncEnvironment for FuncEnvironment<'m
16351635
let callee_sig_id = builder.ins().load(
16361636
sig_id_type,
16371637
mem_flags,
1638-
anyfunc_ptr,
1639-
i32::from(self.offsets.ptr.vmcaller_checked_anyfunc_type_index()),
1638+
funcref_ptr,
1639+
i32::from(self.offsets.ptr.vmcaller_checked_func_ref_type_index()),
16401640
);
16411641

16421642
// Check that they match.
@@ -1657,8 +1657,8 @@ impl<'module_environment> cranelift_wasm::FuncEnvironment for FuncEnvironment<'m
16571657
let vmctx = builder.ins().load(
16581658
pointer_type,
16591659
mem_flags,
1660-
anyfunc_ptr,
1661-
i32::from(self.offsets.ptr.vmcaller_checked_anyfunc_vmctx()),
1660+
funcref_ptr,
1661+
i32::from(self.offsets.ptr.vmcaller_checked_func_ref_vmctx()),
16621662
);
16631663
real_call_args.push(vmctx);
16641664
real_call_args.push(caller_vmctx);

crates/environ/src/component/info.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ pub enum GlobalInitializer {
184184
/// A core wasm function was "generated" via `canon lower` of a function
185185
/// that was `canon lift`'d in the same component, meaning that the function
186186
/// always traps. This is recorded within the `VMComponentContext` as a new
187-
/// `VMCallerCheckedAnyfunc` that's available for use.
187+
/// `VMCallerCheckedFuncRef` that's available for use.
188188
AlwaysTrap(AlwaysTrap),
189189

190190
/// A core wasm linear memory is going to be saved into the
@@ -213,7 +213,7 @@ pub enum GlobalInitializer {
213213
SaveModuleImport(RuntimeImportIndex),
214214

215215
/// Similar to `ExtractMemory` and friends and indicates that a
216-
/// `VMCallerCheckedAnyfunc` needs to be initialized for a transcoder
216+
/// `VMCallerCheckedFuncRef` needs to be initialized for a transcoder
217217
/// function and this will later be used to instantiate an adapter module.
218218
Transcoder(Transcoder),
219219
}
@@ -469,7 +469,7 @@ pub enum StringEncoding {
469469
pub struct Transcoder {
470470
/// The index of the transcoder being defined and initialized.
471471
///
472-
/// This indicates which `VMCallerCheckedAnyfunc` slot is written to in a
472+
/// This indicates which `VMCallerCheckedFuncRef` slot is written to in a
473473
/// `VMComponentContext`.
474474
pub index: RuntimeTranscoderIndex,
475475
/// The transcoding operation being performed.

crates/environ/src/component/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ indices! {
181181

182182
/// Index into the list of transcoders identified during compilation.
183183
///
184-
/// This is used to index the `VMCallerCheckedAnyfunc` slots reserved for
184+
/// This is used to index the `VMCallerCheckedFuncRef` slots reserved for
185185
/// string encoders which reference linear memories defined within a
186186
/// component.
187187
pub struct RuntimeTranscoderIndex(u32);

crates/environ/src/component/vmcomponent_offsets.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
// store: *mut dyn Store,
77
// limits: *const VMRuntimeLimits,
88
// flags: [VMGlobalDefinition; component.num_runtime_component_instances],
9-
// lowering_anyfuncs: [VMCallerCheckedAnyfunc; component.num_lowerings],
10-
// always_trap_anyfuncs: [VMCallerCheckedAnyfunc; component.num_always_trap],
11-
// transcoder_anyfuncs: [VMCallerCheckedAnyfunc; component.num_transcoders],
9+
// lowering_anyfuncs: [VMCallerCheckedFuncRef; component.num_lowerings],
10+
// always_trap_anyfuncs: [VMCallerCheckedFuncRef; component.num_always_trap],
11+
// transcoder_anyfuncs: [VMCallerCheckedFuncRef; component.num_transcoders],
1212
// lowerings: [VMLowering; component.num_lowerings],
1313
// memories: [*mut VMMemoryDefinition; component.num_memories],
14-
// reallocs: [*mut VMCallerCheckedAnyfunc; component.num_reallocs],
15-
// post_returns: [*mut VMCallerCheckedAnyfunc; component.num_post_returns],
14+
// reallocs: [*mut VMCallerCheckedFuncRef; component.num_reallocs],
15+
// post_returns: [*mut VMCallerCheckedFuncRef; component.num_post_returns],
1616
// }
1717

1818
use crate::component::{
@@ -57,7 +57,7 @@ pub struct VMComponentOffsets<P> {
5757
/// least 1).
5858
pub num_runtime_component_instances: u32,
5959
/// Number of "always trap" functions which have their
60-
/// `VMCallerCheckedAnyfunc` stored inline in the `VMComponentContext`.
60+
/// `VMCallerCheckedFuncRef` stored inline in the `VMComponentContext`.
6161
pub num_always_trap: u32,
6262
/// Number of transcoders needed for string conversion.
6363
pub num_transcoders: u32,
@@ -148,9 +148,9 @@ impl<P: PtrSize> VMComponentOffsets<P> {
148148
align(16),
149149
size(flags) = cmul(ret.num_runtime_component_instances, ret.ptr.size_of_vmglobal_definition()),
150150
align(u32::from(ret.ptr.size())),
151-
size(lowering_anyfuncs) = cmul(ret.num_lowerings, ret.ptr.size_of_vmcaller_checked_anyfunc()),
152-
size(always_trap_anyfuncs) = cmul(ret.num_always_trap, ret.ptr.size_of_vmcaller_checked_anyfunc()),
153-
size(transcoder_anyfuncs) = cmul(ret.num_transcoders, ret.ptr.size_of_vmcaller_checked_anyfunc()),
151+
size(lowering_anyfuncs) = cmul(ret.num_lowerings, ret.ptr.size_of_vmcaller_checked_func_ref()),
152+
size(always_trap_anyfuncs) = cmul(ret.num_always_trap, ret.ptr.size_of_vmcaller_checked_func_ref()),
153+
size(transcoder_anyfuncs) = cmul(ret.num_transcoders, ret.ptr.size_of_vmcaller_checked_func_ref()),
154154
size(lowerings) = cmul(ret.num_lowerings, ret.ptr.size() * 2),
155155
size(memories) = cmul(ret.num_runtime_memories, ret.ptr.size()),
156156
size(reallocs) = cmul(ret.num_runtime_reallocs, ret.ptr.size()),
@@ -210,12 +210,12 @@ impl<P: PtrSize> VMComponentOffsets<P> {
210210
self.lowering_anyfuncs
211211
}
212212

213-
/// The offset of `VMCallerCheckedAnyfunc` for the `index` specified.
213+
/// The offset of `VMCallerCheckedFuncRef` for the `index` specified.
214214
#[inline]
215215
pub fn lowering_anyfunc(&self, index: LoweredIndex) -> u32 {
216216
assert!(index.as_u32() < self.num_lowerings);
217217
self.lowering_anyfuncs()
218-
+ index.as_u32() * u32::from(self.ptr.size_of_vmcaller_checked_anyfunc())
218+
+ index.as_u32() * u32::from(self.ptr.size_of_vmcaller_checked_func_ref())
219219
}
220220

221221
/// The offset of the `always_trap_anyfuncs` field.
@@ -224,12 +224,12 @@ impl<P: PtrSize> VMComponentOffsets<P> {
224224
self.always_trap_anyfuncs
225225
}
226226

227-
/// The offset of `VMCallerCheckedAnyfunc` for the `index` specified.
227+
/// The offset of `VMCallerCheckedFuncRef` for the `index` specified.
228228
#[inline]
229229
pub fn always_trap_anyfunc(&self, index: RuntimeAlwaysTrapIndex) -> u32 {
230230
assert!(index.as_u32() < self.num_always_trap);
231231
self.always_trap_anyfuncs()
232-
+ index.as_u32() * u32::from(self.ptr.size_of_vmcaller_checked_anyfunc())
232+
+ index.as_u32() * u32::from(self.ptr.size_of_vmcaller_checked_func_ref())
233233
}
234234

235235
/// The offset of the `transcoder_anyfuncs` field.
@@ -238,12 +238,12 @@ impl<P: PtrSize> VMComponentOffsets<P> {
238238
self.transcoder_anyfuncs
239239
}
240240

241-
/// The offset of `VMCallerCheckedAnyfunc` for the `index` specified.
241+
/// The offset of `VMCallerCheckedFuncRef` for the `index` specified.
242242
#[inline]
243243
pub fn transcoder_anyfunc(&self, index: RuntimeTranscoderIndex) -> u32 {
244244
assert!(index.as_u32() < self.num_transcoders);
245245
self.transcoder_anyfuncs()
246-
+ index.as_u32() * u32::from(self.ptr.size_of_vmcaller_checked_anyfunc())
246+
+ index.as_u32() * u32::from(self.ptr.size_of_vmcaller_checked_func_ref())
247247
}
248248

249249
/// The offset of the `lowerings` field.
@@ -309,7 +309,7 @@ impl<P: PtrSize> VMComponentOffsets<P> {
309309
self.reallocs
310310
}
311311

312-
/// The offset of the `*mut VMCallerCheckedAnyfunc` for the runtime index
312+
/// The offset of the `*mut VMCallerCheckedFuncRef` for the runtime index
313313
/// provided.
314314
#[inline]
315315
pub fn runtime_realloc(&self, index: RuntimeReallocIndex) -> u32 {
@@ -323,7 +323,7 @@ impl<P: PtrSize> VMComponentOffsets<P> {
323323
self.post_returns
324324
}
325325

326-
/// The offset of the `*mut VMCallerCheckedAnyfunc` for the runtime index
326+
/// The offset of the `*mut VMCallerCheckedFuncRef` for the runtime index
327327
/// provided.
328328
#[inline]
329329
pub fn runtime_post_return(&self, index: RuntimePostReturnIndex) -> u32 {

crates/environ/src/module.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,7 @@ pub struct Module {
809809
pub num_imported_globals: usize,
810810

811811
/// Number of functions that "escape" from this module may need to have a
812-
/// `VMCallerCheckedAnyfunc` constructed for them.
812+
/// `VMCallerCheckedFuncRef` constructed for them.
813813
///
814814
/// This is also the number of functions in the `functions` array below with
815815
/// an `anyfunc` index (and is the maximum anyfunc index).

crates/environ/src/vmoffsets.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
// memories: [*mut VMMemoryDefinition; module.num_defined_memories],
2121
// owned_memories: [VMMemoryDefinition; module.num_owned_memories],
2222
// globals: [VMGlobalDefinition; module.num_defined_globals],
23-
// anyfuncs: [VMCallerCheckedAnyfunc; module.num_escaped_funcs],
23+
// anyfuncs: [VMCallerCheckedFuncRef; module.num_escaped_funcs],
2424
// }
2525

2626
use crate::{
@@ -101,26 +101,26 @@ pub trait PtrSize {
101101
/// The offset of the `func_ptr` field.
102102
#[allow(clippy::erasing_op)]
103103
#[inline]
104-
fn vmcaller_checked_anyfunc_func_ptr(&self) -> u8 {
104+
fn vmcaller_checked_func_ref_func_ptr(&self) -> u8 {
105105
0 * self.size()
106106
}
107107

108108
/// The offset of the `type_index` field.
109109
#[allow(clippy::identity_op)]
110110
#[inline]
111-
fn vmcaller_checked_anyfunc_type_index(&self) -> u8 {
111+
fn vmcaller_checked_func_ref_type_index(&self) -> u8 {
112112
1 * self.size()
113113
}
114114

115115
/// The offset of the `vmctx` field.
116116
#[inline]
117-
fn vmcaller_checked_anyfunc_vmctx(&self) -> u8 {
117+
fn vmcaller_checked_func_ref_vmctx(&self) -> u8 {
118118
2 * self.size()
119119
}
120120

121-
/// Return the size of `VMCallerCheckedAnyfunc`.
121+
/// Return the size of `VMCallerCheckedFuncRef`.
122122
#[inline]
123-
fn size_of_vmcaller_checked_anyfunc(&self) -> u8 {
123+
fn size_of_vmcaller_checked_func_ref(&self) -> u8 {
124124
3 * self.size()
125125
}
126126

@@ -233,7 +233,7 @@ pub struct VMOffsetsFields<P> {
233233
pub num_owned_memories: u32,
234234
/// The number of defined globals in the module.
235235
pub num_defined_globals: u32,
236-
/// The number of escaped functions in the module, the size of the anyfunc
236+
/// The number of escaped functions in the module, the size of the funcref
237237
/// array.
238238
pub num_escaped_funcs: u32,
239239
}
@@ -428,7 +428,7 @@ impl<P: PtrSize> From<VMOffsetsFields<P>> for VMOffsets<P> {
428428
= cmul(ret.num_defined_globals, ret.ptr.size_of_vmglobal_definition()),
429429
size(defined_anyfuncs) = cmul(
430430
ret.num_escaped_funcs,
431-
ret.ptr.size_of_vmcaller_checked_anyfunc(),
431+
ret.ptr.size_of_vmcaller_checked_func_ref(),
432432
),
433433
}
434434

@@ -749,14 +749,14 @@ impl<P: PtrSize> VMOffsets<P> {
749749
+ index.as_u32() * u32::from(self.ptr.size_of_vmglobal_definition())
750750
}
751751

752-
/// Return the offset to the `VMCallerCheckedAnyfunc` for the given function
752+
/// Return the offset to the `VMCallerCheckedFuncRef` for the given function
753753
/// index (either imported or defined).
754754
#[inline]
755755
pub fn vmctx_anyfunc(&self, index: AnyfuncIndex) -> u32 {
756756
assert!(!index.is_reserved_value());
757757
assert!(index.as_u32() < self.num_escaped_funcs);
758758
self.vmctx_anyfuncs_begin()
759-
+ index.as_u32() * u32::from(self.ptr.size_of_vmcaller_checked_anyfunc())
759+
+ index.as_u32() * u32::from(self.ptr.size_of_vmcaller_checked_func_ref())
760760
}
761761

762762
/// Return the offset to the `body` field in `*const VMFunctionBody` index `index`.

0 commit comments

Comments
 (0)