Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions crates/wasmtime/src/runtime/type_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ use core::{
};
use wasmtime_core::slab::{Id as SlabId, Slab};
use wasmtime_environ::{
EngineOrModuleTypeIndex, EntityRef, GcLayout, ModuleInternedTypeIndex, ModuleTypes, TypeTrace,
Undo, VMSharedTypeIndex, WasmRecGroup, WasmSubType,
collections::{HashSet, PrimaryMap, SecondaryMap, TryClone as _, Vec},
EngineOrModuleTypeIndex, EntityRef, GcLayout, ModuleInternedTypeIndex, ModuleTypes,
PanicOnOom as _, TypeTrace, Undo, VMSharedTypeIndex, WasmRecGroup, WasmSubType,
collections::{HashSet, PrimaryMap, SecondaryMap, TryClone, Vec},
iter_entity_range,
packed_option::{PackedOption, ReservedValue},
};
Expand Down Expand Up @@ -273,15 +273,21 @@ impl Debug for RegisteredType {

impl Clone for RegisteredType {
fn clone(&self) -> Self {
self.try_clone().panic_on_oom()
}
}

impl TryClone for RegisteredType {
fn try_clone(&self) -> Result<Self, OutOfMemory> {
self.engine.signatures().debug_assert_contains(self.index);
self.entry.incref("RegisteredType::clone");
RegisteredType {
self.entry.incref("RegisteredType::try_clone");
Ok(RegisteredType {
engine: self.engine.clone(),
entry: self.entry.clone(),
ty: self.ty.clone(),
index: self.index,
layout: self.layout.clone(),
}
})
}
}

Expand Down Expand Up @@ -457,6 +463,12 @@ impl RegisteredType {
#[derive(Clone)]
struct RecGroupEntry(Arc<RecGroupEntryInner>);

impl TryClone for RecGroupEntry {
fn try_clone(&self) -> Result<Self, OutOfMemory> {
Ok(self.clone())
}
}

impl Debug for RecGroupEntry {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
struct FormatAsPtr<'a, P>(&'a P);
Expand Down