feat(runtime): add optional pause and resume lifecycle hooks
Intrepid/Prometeu/Runtime/pipeline/pr-master Build started...

This commit is contained in:
2026-10-13 12:18:18 +01:00
parent 23dc6fc66d
commit 0af8b2b1fe
39 changed files with 1381 additions and 70 deletions
@@ -105,7 +105,8 @@ impl VirtualMachineRuntime {
match step_result {
Ok(())
| Err(
LogicalFrameEndingReason::FrameSync
LogicalFrameEndingReason::LifecycleComplete
| LogicalFrameEndingReason::FrameSync
| LogicalFrameEndingReason::BudgetExhausted
| LogicalFrameEndingReason::Halted
| LogicalFrameEndingReason::EndOfRom
@@ -138,6 +139,55 @@ impl VirtualMachineRuntime {
}
}
/// Uses the session's real services, outside logical-frame accounting.
#[allow(clippy::too_many_arguments)]
pub(crate) fn tick_lifecycle(
&mut self,
log_service: &mut LogService,
fs: &mut VirtualFS,
fs_state: &mut FsState,
memcard: &mut MemcardService,
open_files: &mut HashMap<u32, String>,
next_handle: &mut u32,
vm: &mut VirtualMachine,
platform: &mut dyn RuntimePlatform,
single_step: bool,
) -> LogicalFrameEndingReason {
if self.paused && !single_step && !self.debug_step_request {
return LogicalFrameEndingReason::Breakpoint;
}
let result = catch_unwind(AssertUnwindSafe(|| {
let mut ctx = HostContext::new_platform(Some(platform));
let mut host = VmRuntimeHost {
runtime: self,
log_service,
fs,
fs_state,
memcard,
open_files,
next_handle,
};
if single_step {
vm.step(&mut host, &mut ctx)
.err()
.unwrap_or(LogicalFrameEndingReason::BudgetExhausted)
} else {
vm.run_budget(VirtualMachine::LIFECYCLE_SLICE, &mut host, &mut ctx)
.map(|report| report.reason)
.unwrap_or_else(LogicalFrameEndingReason::Panic)
}
}));
let reason = result.unwrap_or_else(|payload| {
LogicalFrameEndingReason::Panic(Self::host_panic_payload_to_string(payload))
});
if reason == LogicalFrameEndingReason::Breakpoint || single_step || self.debug_step_request
{
self.paused = true;
self.debug_step_request = false;
}
reason
}
#[allow(clippy::too_many_arguments)]
pub fn tick(
&mut self,