Invokes the pending upcall.
(self)
| 82 | impl<'a> UpcallHandler<'a> { |
| 83 | /// Invokes the pending upcall. |
| 84 | pub async fn invoke(self) -> Result<(), UpcallError> { |
| 85 | let vm = self.vm; |
| 86 | let image = self.image; |
| 87 | let (index, first_reg, upcall_pc) = vm |
| 88 | .pending_upcall |
| 89 | .take() |
| 90 | .expect("This is only reachable when the VM has a pending upcall"); |
| 91 | let (upcall, scope) = vm.prepare_upcall(image, index, first_reg, upcall_pc); |
| 92 | let result = upcall.async_exec(scope).await; |
| 93 | match vm.handle_upcall_result(image, upcall_pc, result) { |
| 94 | Ok(()) => Ok(()), |
| 95 | Err(e) => { |
| 96 | vm.park_at_eof(image); |
| 97 | Err(e) |
| 98 | } |
| 99 | } |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | /// Representation of termination states from program execution. |