Calculate the number of words needed to encode the unwind codes.
(&self)
| 69 | impl UnwindInfo { |
| 70 | /// Calculate the number of words needed to encode the unwind codes. |
| 71 | pub fn code_words(&self) -> u8 { |
| 72 | let mut bytes = 0u16; |
| 73 | for code in self.unwind_codes.iter() { |
| 74 | let next_bytes = match code { |
| 75 | UnwindCode::SaveFpLrPair { .. } |
| 76 | | UnwindCode::AllocS { .. } |
| 77 | | UnwindCode::PacSignLr |
| 78 | | UnwindCode::SetFp => 1, |
| 79 | UnwindCode::SaveReg { .. } |
| 80 | | UnwindCode::SaveFReg { .. } |
| 81 | | UnwindCode::AllocM { .. } |
| 82 | | UnwindCode::AddFp { .. } => 2, |
| 83 | UnwindCode::AllocL { .. } => 4, |
| 84 | }; |
| 85 | bytes = bytes.checked_add(next_bytes).unwrap(); |
| 86 | } |
| 87 | |
| 88 | bytes.div_ceil(4).try_into().unwrap() |
| 89 | } |
| 90 | |
| 91 | /// Emits the unwind information into the given mutable byte slice. |
| 92 | /// |
no test coverage detected