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
15 changes: 9 additions & 6 deletions crates/environ/src/module_types.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use crate::{
ModuleInternedRecGroupIndex, ModuleInternedTypeIndex, PrimaryMap, TypeTrace, WasmSubType,
ModuleInternedRecGroupIndex, ModuleInternedTypeIndex, PanicOnOom as _, TypeTrace, WasmSubType,
collections::{PrimaryMap, SecondaryMap},
packed_option::PackedOption,
};
use core::ops::{Index, Range};
use cranelift_entity::{SecondaryMap, packed_option::PackedOption};
use serde_derive::{Deserialize, Serialize};

/// All types used in a core wasm module.
Expand Down Expand Up @@ -77,7 +78,7 @@ impl ModuleTypes {

/// Adds a new type to this interned list of types.
pub fn push(&mut self, ty: WasmSubType) -> ModuleInternedTypeIndex {
self.wasm_types.push(ty)
self.wasm_types.push(ty).panic_on_oom()
}

/// Iterate over the trampoline function types that this module requires.
Expand Down Expand Up @@ -131,20 +132,22 @@ impl ModuleTypes {
.is_trampoline_type()
);

self.trampoline_types[for_ty] = Some(trampoline_ty).into();
self.trampoline_types
.insert(for_ty, Some(trampoline_ty).into())
.panic_on_oom();
}

/// Adds a new rec group to this interned list of types.
pub fn push_rec_group(
&mut self,
range: Range<ModuleInternedTypeIndex>,
) -> ModuleInternedRecGroupIndex {
self.rec_groups.push(range)
self.rec_groups.push(range).panic_on_oom()
}

/// Reserves space for `amt` more types.
pub fn reserve(&mut self, amt: usize) {
self.wasm_types.reserve(amt)
self.wasm_types.reserve(amt).panic_on_oom()
}

/// Returns the next return value of `push_rec_group`.
Expand Down