A lightweight WebAssembly runtime that is fast, secure, and standards-compliant
Use `wasmtime_environ::collections::HashSet` in the `TypeRegistry` (#12522)
Nick Fitzgeraldf44d1e46fe5f
diff --git a/crates/wasmtime/src/lib.rs b/crates/wasmtime/src/lib.rsindex 809f21fbb4..72b56c5d0b 100644--- a/crates/wasmtime/src/lib.rs+++ b/crates/wasmtime/src/lib.rs@@ -417,6 +417,10 @@ use wasmtime_environ::prelude;// for all internal usage instead of using abort-on-OOM versions. Once that's// done this can be removed and the collections should be directly imported from// `wasmtime_environ::collections::*`.+#[allow(+ unused_imports,+ reason = "not all build configs use these; easier to allow than to precisely `cfg`"+)]use wasmtime_environ::collections::oom_abort::{hash_map, hash_set};/// A helper macro to safely map `MaybeUninit<T>` to `MaybeUninit<U>` where `U`diff --git a/crates/wasmtime/src/runtime/type_registry.rs b/crates/wasmtime/src/runtime/type_registry.rsindex f8726cb06a..c85744013d 100644--- a/crates/wasmtime/src/runtime/type_registry.rs+++ b/crates/wasmtime/src/runtime/type_registry.rs@@ -5,7 +5,6 @@use crate::Engine;use crate::error::OutOfMemory;-use crate::hash_set::HashSet;use crate::prelude::*;use crate::sync::RwLock;use crate::vm::GcRuntime;@@ -27,7 +26,7 @@ use wasmtime_core::slab::{Id as SlabId, Slab};use wasmtime_environ::{EngineOrModuleTypeIndex, EntityRef, GcLayout, ModuleInternedTypeIndex, ModuleTypes, TypeTrace,Undo, VMSharedTypeIndex, WasmRecGroup, WasmSubType,- collections::{PrimaryMap, SecondaryMap, Vec},+ collections::{HashSet, PrimaryMap, SecondaryMap, Vec},iter_entity_range,packed_option::{PackedOption, ReservedValue},};@@ -855,7 +854,7 @@ impl TypeRegistryInner {registry.insert_entry_trampolines(gc_runtime, &entry)?;registry.insert_entry_gc_layouts(gc_runtime, &entry)?;- let is_new_entry = registry.hash_consing_map.insert(entry.clone());+ let is_new_entry = registry.hash_consing_map.insert(entry.clone())?;debug_assert!(is_new_entry);// We successfully registered the rec group! Commit our changes,@@ -1226,10 +1225,8 @@ impl TypeRegistryInner {// This map contains rec groups, not types, so only reserve space for// one additional entry.- //- // TODO(#12069): handle OOM here.log::trace!(" hash_consing_map.reserve(1)");- hash_consing_map.reserve(1);+ hash_consing_map.reserve(1)?;log::trace!(" types.reserve({num_types})");types.reserve(num_types)?;