(
&'a self,
pc: usize,
)
| 378 | /// CompiledBlobs in this module. |
| 379 | #[cfg(feature = "wasmtime-unwinder")] |
| 380 | pub fn lookup_wasmtime_exception_data<'a>( |
| 381 | &'a self, |
| 382 | pc: usize, |
| 383 | ) -> Option<(usize, wasmtime_unwinder::ExceptionTable<'a>)> { |
| 384 | // Search the sorted code-ranges for the PC. |
| 385 | let idx = match self |
| 386 | .code_ranges |
| 387 | .binary_search_by_key(&pc, |(start, _end, _func)| *start) |
| 388 | { |
| 389 | Ok(exact_start_match) => Some(exact_start_match), |
| 390 | Err(least_upper_bound) if least_upper_bound > 0 => { |
| 391 | let last_range_before_pc = &self.code_ranges[least_upper_bound - 1]; |
| 392 | if last_range_before_pc.0 <= pc && pc < last_range_before_pc.1 { |
| 393 | Some(least_upper_bound - 1) |
| 394 | } else { |
| 395 | None |
| 396 | } |
| 397 | } |
| 398 | _ => None, |
| 399 | }?; |
| 400 | |
| 401 | let (start, _, func) = self.code_ranges[idx]; |
| 402 | |
| 403 | // Get the ExceptionTable. The "parse" here simply reads two |
| 404 | // u32s for lengths and constructs borrowed slices, so it's |
| 405 | // cheap. |
| 406 | let data = self.compiled_functions[func] |
| 407 | .as_ref() |
| 408 | .unwrap() |
| 409 | .wasmtime_exception_data()?; |
| 410 | let exception_table = wasmtime_unwinder::ExceptionTable::parse(data).ok()?; |
| 411 | Some((start, exception_table)) |
| 412 | } |
| 413 | } |
| 414 | |
| 415 | impl Module for JITModule { |
no test coverage detected