Add a marker for transitions between guest and host to the profile. This function should typically be called from a callback registered using [`Store::call_hook()`](crate::Store::call_hook), and the `kind` parameter should be the value of the same type passed into that hook.
(&mut self, store: impl AsContext, kind: CallHook)
| 218 | /// using [`Store::call_hook()`](crate::Store::call_hook), and the `kind` |
| 219 | /// parameter should be the value of the same type passed into that hook. |
| 220 | pub fn call_hook(&mut self, store: impl AsContext, kind: CallHook) { |
| 221 | let now = Timestamp::from_nanos_since_reference( |
| 222 | self.start.elapsed().as_nanos().try_into().unwrap(), |
| 223 | ); |
| 224 | match kind { |
| 225 | CallHook::CallingWasm | CallHook::ReturningFromWasm => {} |
| 226 | CallHook::CallingHost => { |
| 227 | let backtrace = Backtrace::new(store.as_context().0); |
| 228 | let frames = lookup_frames(&self.modules, &backtrace); |
| 229 | let marker = self.profile.add_marker( |
| 230 | self.thread, |
| 231 | MarkerTiming::IntervalStart(now), |
| 232 | self.marker, |
| 233 | ); |
| 234 | let stack = self |
| 235 | .profile |
| 236 | .intern_stack_frames(self.thread, frames.into_iter()); |
| 237 | self.profile.set_marker_stack(self.thread, marker, stack); |
| 238 | } |
| 239 | CallHook::ReturningFromHost => { |
| 240 | self.profile |
| 241 | .add_marker(self.thread, MarkerTiming::IntervalEnd(now), self.marker); |
| 242 | } |
| 243 | } |
| 244 | } |
| 245 | |
| 246 | /// When the guest finishes running, call this function to write the |
| 247 | /// profile to the given `output`. The output is a JSON-formatted object in |
nothing calls this directly
no test coverage detected