(&mut self, base: u64, offset: u64, bytes: [u8; SIZE])
| 159 | |
| 160 | #[inline(always)] |
| 161 | pub(crate) fn store<const SIZE: usize>(&mut self, base: u64, offset: u64, bytes: [u8; SIZE]) -> Result<(), Trap> { |
| 162 | // the compiler doesn't optimize .as_slice().try_into() for some reason, so we have to manually copy the bytes into an array |
| 163 | // heavy usage of cold_path() seems to help a lot from looking at profile data |
| 164 | let res = match SIZE { |
| 165 | 1 => self.inner.write_8(base, offset, bytes[0]), |
| 166 | 2 => self.inner.write_16(base, offset, [bytes[0], bytes[1]]), |
| 167 | 4 => self.inner.write_32(base, offset, [bytes[0], bytes[1], bytes[2], bytes[3]]), |
| 168 | 8 => self.inner.write_64( |
| 169 | base, |
| 170 | offset, |
| 171 | [bytes[0], bytes[1], bytes[2], bytes[3], bytes[4], bytes[5], bytes[6], bytes[7]], |
| 172 | ), |
| 173 | 16 => self.inner.write_128( |
| 174 | base, |
| 175 | offset, |
| 176 | [ |
| 177 | bytes[0], bytes[1], bytes[2], bytes[3], bytes[4], bytes[5], bytes[6], bytes[7], bytes[8], bytes[9], |
| 178 | bytes[10], bytes[11], bytes[12], bytes[13], bytes[14], bytes[15], |
| 179 | ], |
| 180 | ), |
| 181 | _ => unreachable!("unsupported fixed-size write width {SIZE}"), |
| 182 | }; |
| 183 | |
| 184 | if let Err(e) = res { |
| 185 | cold_path(); |
| 186 | return Err(e); |
| 187 | } |
| 188 | Ok(()) |
| 189 | } |
| 190 | |
| 191 | pub(crate) fn copy_from_memory( |
| 192 | &mut self, |
no test coverage detected