A lightweight WebAssembly runtime that is fast, secure, and standards-compliant
Remove `ExceptionTable::lookup_pc_tag` (#13604)
Alex Crichton0fcb97bcc608
diff --git a/cranelift/filetests/src/function_runner.rs b/cranelift/filetests/src/function_runner.rsindex 1dbbcc2f30..f671c841d3 100644--- a/cranelift/filetests/src/function_runner.rs+++ b/cranelift/filetests/src/function_runner.rs@@ -652,14 +652,15 @@ extern "C-unwind" fn __cranelift_throw().expect("module larger than 4GiB");- table- .lookup_pc_tag(relative_pc, tag)- .map(|(frame_offset, handler)| {+ let (frame_offset, mut handlers) = table.lookup_pc(relative_pc);+ handlers+ .find(|handler| handler.tag == Some(tag) || handler.tag.is_none())+ .map(|handler| {let handler_sp = frame.fp()- .wrapping_sub(usize::try_from(frame_offset).unwrap());+ .wrapping_sub(usize::try_from(frame_offset.unwrap_or(0)).unwrap());let handler_pc = base- .checked_add(usize::try_from(handler).unwrap())+ .checked_add(usize::try_from(handler.handler_offset).unwrap()).expect("Handler address computation overflowed");(handler_pc, handler_sp)})diff --git a/crates/unwinder/src/exception_table.rs b/crates/unwinder/src/exception_table.rsindex 85ba28732e..2f10f7bb05 100644--- a/crates/unwinder/src/exception_table.rs+++ b/crates/unwinder/src/exception_table.rs@@ -322,39 +322,6 @@ impl<'a> ExceptionTable<'a> {)}- /// Look up the frame offset and handler destination if any, for a- /// given return address (as an offset into the code section) and- /// exception tag.- ///- /// Note: we use raw `u32` types for code offsets and tags here to- /// avoid dependencies on `cranelift-codegen` when this crate is- /// built without compiler backend support (runtime-only config).- pub fn lookup_pc_tag(&self, pc: u32, tag: u32) -> Option<(u32, u32)> {- // First, look up the callsite in the sorted callsites list.- let callsite_idx = self- .callsites- .binary_search_by_key(&pc, |callsite| callsite.get(LittleEndian))- .ok()?;- let frame_offset =- option_from_u32(self.frame_offsets[callsite_idx].get(LittleEndian)).unwrap_or(0);-- let (tags, _, handlers) = self.tags_contexts_handlers_for_callsite(callsite_idx);-- // Is there any handler with an exact tag match?- if let Ok(handler_idx) = tags.binary_search_by_key(&tag, |tag| tag.get(LittleEndian)) {- return Some((frame_offset, handlers[handler_idx].get(LittleEndian)));- }-- // If not, is there a fallback handler? Note that we serialize- // it with the tag `u32::MAX`, so it is always last in sorted- // order.- if tags.last().map(|v| v.get(LittleEndian)) == Some(u32::MAX) {- return Some((frame_offset, handlers.last().unwrap().get(LittleEndian)));- }-- None- }-fn tags_contexts_handlers_for_callsite(&self,idx: usize,