Skip to content

A lightweight WebAssembly runtime that is fast, secure, and standards-compliant

Use `TryClone::clone_panic_on_oom` where it makes sense (#12681)

Nick Fitzgerald9872fefb08ae
diff --git a/crates/environ/src/compile/module_types.rs b/crates/environ/src/compile/module_types.rs
index 2ecfcd0e88..a82843dc9a 100644
--- a/crates/environ/src/compile/module_types.rs
+++ b/crates/environ/src/compile/module_types.rs
@@ -168,7 +168,7 @@ impl ModuleTypesBuilder {
// can reuse it in the future.
TryCow::Borrowed(f) => {
self.trampoline_types
- .insert(f.try_clone().panic_on_oom(), for_func_ty);
+ .insert(f.clone_panic_on_oom(), for_func_ty);
for_func_ty
}
// The trampoline type is different from the original function
@@ -179,7 +179,7 @@ impl ModuleTypesBuilder {
is_final: true,
supertype: None,
composite_type: WasmCompositeType {
- inner: WasmCompositeInnerType::Func(f.try_clone().panic_on_oom()),
+ inner: WasmCompositeInnerType::Func(f.clone_panic_on_oom()),
shared: sub_ty.composite_type.shared,
},
});
diff --git a/crates/wasmtime/src/runtime/linker.rs b/crates/wasmtime/src/runtime/linker.rs
index c47c41ac57..500928b19f 100644
--- a/crates/wasmtime/src/runtime/linker.rs
+++ b/crates/wasmtime/src/runtime/linker.rs
@@ -13,7 +13,7 @@ use core::future::Future;
use core::marker;
use core::mem::MaybeUninit;
use log::warn;
-use wasmtime_environ::{Atom, PanicOnOom as _, StringPool, collections::HashMap};
+use wasmtime_environ::{Atom, StringPool, collections::HashMap};
/// Structure used to link wasm modules/instances together.
///
@@ -100,8 +100,8 @@ impl<T> Clone for Linker<T> {
fn clone(&self) -> Linker<T> {
Linker {
engine: self.engine.clone(),
- pool: self.pool.try_clone().panic_on_oom(),
- map: self.map.try_clone().panic_on_oom(),
+ pool: self.pool.clone_panic_on_oom(),
+ map: self.map.clone_panic_on_oom(),
allow_shadowing: self.allow_shadowing,
allow_unknown_exports: self.allow_unknown_exports,
_marker: self._marker,
diff --git a/crates/wasmtime/src/runtime/type_registry.rs b/crates/wasmtime/src/runtime/type_registry.rs
index 5bb9127869..054bb768d2 100644
--- a/crates/wasmtime/src/runtime/type_registry.rs
+++ b/crates/wasmtime/src/runtime/type_registry.rs
@@ -23,8 +23,8 @@ use core::{
};
use wasmtime_core::slab::{Id as SlabId, Slab};
use wasmtime_environ::{
- EngineOrModuleTypeIndex, EntityRef, GcLayout, ModuleInternedTypeIndex, ModuleTypes,
- PanicOnOom as _, TypeTrace, Undo, VMSharedTypeIndex, WasmRecGroup, WasmSubType,
+ EngineOrModuleTypeIndex, EntityRef, GcLayout, ModuleInternedTypeIndex, ModuleTypes, TypeTrace,
+ Undo, VMSharedTypeIndex, WasmRecGroup, WasmSubType,
collections::{HashSet, PrimaryMap, SecondaryMap, TryCow, Vec},
iter_entity_range,
packed_option::{PackedOption, ReservedValue},
@@ -272,7 +272,7 @@ impl Debug for RegisteredType {
impl Clone for RegisteredType {
fn clone(&self) -> Self {
- self.try_clone().panic_on_oom()
+ self.clone_panic_on_oom()
}
}
diff --git a/crates/wasmtime/src/runtime/types.rs b/crates/wasmtime/src/runtime/types.rs
index 21787c82d0..54b9ade2bf 100644
--- a/crates/wasmtime/src/runtime/types.rs
+++ b/crates/wasmtime/src/runtime/types.rs
@@ -1509,7 +1509,7 @@ impl ExternType {
engine,
subty.is_final,
subty.supertype,
- subty.unwrap_func().try_clone().panic_on_oom(),
+ subty.unwrap_func().clone_panic_on_oom(),
)
.panic_on_oom()
.into()
diff --git a/winch/codegen/src/codegen/control.rs b/winch/codegen/src/codegen/control.rs
index cecf901256..77d0376ea2 100644
--- a/winch/codegen/src/codegen/control.rs
+++ b/winch/codegen/src/codegen/control.rs
@@ -16,7 +16,7 @@ use crate::{
stack::Val,
};
use cranelift_codegen::MachLabel;
-use wasmtime_environ::{PanicOnOom as _, WasmFuncType, WasmValType, collections::TryClone as _};
+use wasmtime_environ::{WasmFuncType, WasmValType, collections::TryClone as _};
/// Categorization of the type of the block.
#[derive(Debug)]
@@ -37,7 +37,7 @@ impl Clone for BlockType {
Self::Void => Self::Void,
Self::Single(x) => Self::Single(*x),
Self::ABISig(x) => Self::ABISig(x.clone()),
- Self::Func(f) => Self::Func(f.try_clone().panic_on_oom()),
+ Self::Func(f) => Self::Func(f.clone_panic_on_oom()),
}
}
}
diff --git a/winch/codegen/src/codegen/env.rs b/winch/codegen/src/codegen/env.rs
index 683d354698..51b457102e 100644
--- a/winch/codegen/src/codegen/env.rs
+++ b/winch/codegen/src/codegen/env.rs
@@ -13,9 +13,8 @@ use std::mem;
use wasmparser::BlockType;
use wasmtime_environ::{
BuiltinFunctionIndex, DefinedFuncIndex, FuncIndex, FuncKey, GlobalIndex, IndexType, Memory,
- MemoryIndex, ModuleTranslation, ModuleTypesBuilder, PanicOnOom as _, PrimaryMap, PtrSize,
- Table, TableIndex, TypeConvert, TypeIndex, VMOffsets, WasmHeapType, WasmValType,
- collections::TryClone as _,
+ MemoryIndex, ModuleTranslation, ModuleTypesBuilder, PrimaryMap, PtrSize, Table, TableIndex,
+ TypeConvert, TypeIndex, VMOffsets, WasmHeapType, WasmValType, collections::TryClone as _,
};
#[derive(Debug, Clone, Copy)]
@@ -195,7 +194,7 @@ impl<'a, 'translation, 'data, P: PtrSize> FuncEnv<'a, 'translation, 'data, P> {
let sig_index = self.translation.module.types[TypeIndex::from_u32(idx)]
.unwrap_module_type_index();
let sig = self.types[sig_index].unwrap_func();
- BlockSig::new(control::BlockType::func(sig.try_clone().panic_on_oom()))
+ BlockSig::new(control::BlockType::func(sig.clone_panic_on_oom()))
}
})
}