Resolve a `HeapData` from a [MemoryIndex].
(&mut self, index: MemoryIndex)
| 265 | |
| 266 | /// Resolve a `HeapData` from a [MemoryIndex]. |
| 267 | pub fn resolve_heap(&mut self, index: MemoryIndex) -> HeapData { |
| 268 | let mem = self.translation.module.memories[index]; |
| 269 | let is_shared = mem.shared; |
| 270 | match self.resolved_heaps.entry(index) { |
| 271 | Occupied(entry) => *entry.get(), |
| 272 | Vacant(entry) => { |
| 273 | let (import_from, base_offset, current_length_offset) = |
| 274 | match self.translation.module.defined_memory_index(index) { |
| 275 | Some(defined) => { |
| 276 | if is_shared { |
| 277 | ( |
| 278 | Some(self.vmoffsets.vmctx_vmmemory_pointer(defined)), |
| 279 | self.vmoffsets.ptr.vmmemory_definition_base().into(), |
| 280 | self.vmoffsets |
| 281 | .ptr |
| 282 | .vmmemory_definition_current_length() |
| 283 | .into(), |
| 284 | ) |
| 285 | } else { |
| 286 | let owned = self.translation.module.owned_memory_index(defined); |
| 287 | ( |
| 288 | None, |
| 289 | self.vmoffsets.vmctx_vmmemory_definition_base(owned), |
| 290 | self.vmoffsets |
| 291 | .vmctx_vmmemory_definition_current_length(owned), |
| 292 | ) |
| 293 | } |
| 294 | } |
| 295 | None => ( |
| 296 | Some(self.vmoffsets.vmctx_vmmemory_import_from(index)), |
| 297 | self.vmoffsets.ptr.vmmemory_definition_base().into(), |
| 298 | self.vmoffsets |
| 299 | .ptr |
| 300 | .vmmemory_definition_current_length() |
| 301 | .into(), |
| 302 | ), |
| 303 | }; |
| 304 | |
| 305 | let memory = &self.translation.module.memories[index]; |
| 306 | |
| 307 | *entry.insert(HeapData { |
| 308 | offset: base_offset, |
| 309 | import_from, |
| 310 | current_length_offset, |
| 311 | memory: *memory, |
| 312 | }) |
| 313 | } |
| 314 | } |
| 315 | } |
| 316 | |
| 317 | /// Get a [`Table`] from a [`TableIndex`]. |
| 318 | pub fn table(&mut self, index: TableIndex) -> &Table { |
no test coverage detected