|
1 | 1 | use crate::{ |
2 | | - ModuleInternedRecGroupIndex, ModuleInternedTypeIndex, PrimaryMap, TypeTrace, WasmSubType, |
| 2 | + ModuleInternedRecGroupIndex, ModuleInternedTypeIndex, PanicOnOom as _, TypeTrace, WasmSubType, |
| 3 | + collections::{PrimaryMap, SecondaryMap}, |
| 4 | + packed_option::PackedOption, |
3 | 5 | }; |
4 | 6 | use core::ops::{Index, Range}; |
5 | | -use cranelift_entity::{SecondaryMap, packed_option::PackedOption}; |
6 | 7 | use serde_derive::{Deserialize, Serialize}; |
7 | 8 |
|
8 | 9 | /// All types used in a core wasm module. |
@@ -77,7 +78,7 @@ impl ModuleTypes { |
77 | 78 |
|
78 | 79 | /// Adds a new type to this interned list of types. |
79 | 80 | pub fn push(&mut self, ty: WasmSubType) -> ModuleInternedTypeIndex { |
80 | | - self.wasm_types.push(ty) |
| 81 | + self.wasm_types.push(ty).panic_on_oom() |
81 | 82 | } |
82 | 83 |
|
83 | 84 | /// Iterate over the trampoline function types that this module requires. |
@@ -131,20 +132,22 @@ impl ModuleTypes { |
131 | 132 | .is_trampoline_type() |
132 | 133 | ); |
133 | 134 |
|
134 | | - self.trampoline_types[for_ty] = Some(trampoline_ty).into(); |
| 135 | + self.trampoline_types |
| 136 | + .insert(for_ty, Some(trampoline_ty).into()) |
| 137 | + .panic_on_oom(); |
135 | 138 | } |
136 | 139 |
|
137 | 140 | /// Adds a new rec group to this interned list of types. |
138 | 141 | pub fn push_rec_group( |
139 | 142 | &mut self, |
140 | 143 | range: Range<ModuleInternedTypeIndex>, |
141 | 144 | ) -> ModuleInternedRecGroupIndex { |
142 | | - self.rec_groups.push(range) |
| 145 | + self.rec_groups.push(range).panic_on_oom() |
143 | 146 | } |
144 | 147 |
|
145 | 148 | /// Reserves space for `amt` more types. |
146 | 149 | pub fn reserve(&mut self, amt: usize) { |
147 | | - self.wasm_types.reserve(amt) |
| 150 | + self.wasm_types.reserve(amt).panic_on_oom() |
148 | 151 | } |
149 | 152 |
|
150 | 153 | /// Returns the next return value of `push_rec_group`. |
|
0 commit comments