()
| 454 | /// windows stay zero-copy mmap slices (the OS page cache backs them) |
| 455 | /// instead of heap copies. `mmap` must be the exact buffer |
| 456 | /// [`Env::parse_lazy_index`] walked. |
| 457 | #[cfg(not(target_arch = "riscv64"))] |
| 458 | pub fn from_lazy_index_mmap( |
| 459 | index: &LazyIndex, |
| 460 | mmap: &Arc<memmap2::Mmap>, |
| 461 | ) -> Result<Env, String> { |
| 462 | let env = Env::new(); |
| 463 | for c in &index.consts { |
| 464 | Self::lazy_slice_end(c, mmap.len(), "from_lazy_index_mmap")?; |
| 465 | env.store_const_lazy_mmap( |
| 466 | c.addr.clone(), |
| 467 | Arc::clone(mmap), |
| 468 | c.offset, |
| 469 | c.len, |
| 470 | ); |
| 471 | } |
| 472 | Ok(Self::fill_from_lazy_index(env, index)) |
| 473 | } |
| 474 | |
| 475 | #[cfg(not(target_arch = "riscv64"))] |
| 476 | fn lazy_slice_end( |
| 477 | c: &LazyConstSlice, |
| 478 | data_len: usize, |
| 479 | who: &str, |
| 480 | ) -> Result<usize, String> { |
| 481 | c.offset.checked_add(c.len).filter(|e| *e <= data_len).ok_or_else(|| { |
| 482 | format!( |
| 483 | "{who}: constant window [{}, +{}) out of bounds ({data_len} bytes)", |
| 484 | c.offset, c.len, |
nothing calls this directly
no test coverage detected