MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / lookup_wasmtime_exception_data

Method lookup_wasmtime_exception_data

cranelift/jit/src/backend.rs:380–412  ·  view source on GitHub ↗
(
        &'a self,
        pc: usize,
    )

Source from the content-addressed store, hash-verified

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
415impl Module for JITModule {

Callers 1

__cranelift_throwFunction · 0.80

Calls 6

binary_search_by_keyMethod · 0.80
parseFunction · 0.50
unwrapMethod · 0.45
as_refMethod · 0.45
okMethod · 0.45

Tested by

no test coverage detected