feat(vm): add resource diagnostics and macOS stability qualification
Intrepid/Prometeu/Runtime/pipeline/pr-master This commit looks good

This commit is contained in:
2026-10-14 08:26:07 +01:00
parent 6c2a07e579
commit 3899b7f12c
21 changed files with 1502 additions and 33 deletions
@@ -1,28 +1,25 @@
use prometeu_hal::vm_fault::VmFault;
use prometeu_vm::VirtualMachine;
use prometeu_vm::{HostContext, HostReturn, NativeInterface, SyscallId};
#[allow(dead_code)]
#[path = "../../../console/prometeu-vm/tests/support/callables.rs"]
mod callables;
use prometeu_bytecode::{registry::TypeId, Value};
use prometeu_vm::LogicalFrameEndingReason;
#[test]
fn gc_collects_unreachable_closure_but_keeps_marked() {
// Black-box check: a fresh VM with no program initializes and can run a zero-budget slice.
// The GC behavior is covered by unit tests inside the VM crate; this layer test remains
// as a smoke-test for public API stability.
struct NoopNative;
impl NativeInterface for NoopNative {
fn syscall(
&mut self,
_id: SyscallId,
_args: &[prometeu_bytecode::Value],
_ret: &mut HostReturn,
_ctx: &mut HostContext,
) -> Result<(), VmFault> {
Ok(())
}
}
let mut vm = VirtualMachine::default();
let mut native = NoopNative;
let mut ctx = HostContext::new(None);
let res = vm.run_budget(0, &mut native, &mut ctx);
assert!(res.is_ok());
fn gc_collects_unreachable_closures_and_retains_active_environment_through_sync() {
let body =
format!("{}FRAME_SYNC\nGET_CAPTURE 0\nRET", "MAKE_CLOSURE fn=2,type=4\nPOP\n".repeat(1030));
let mut vm = callables::vm(&[
(
"PUSH_I32 73\nMAKE_CLOSURE fn=1,type=4\nCALL_CLOSURE 4\nRET",
callables::sig(&[], &[0]),
vec![],
),
(&body, callables::sig(&[], &[0]), vec![TypeId(0)]),
("PUSH_I32 1\nRET", callables::sig(&[], &[0]), vec![]),
]);
assert_eq!(callables::run(&mut vm, 100_000).reason, LogicalFrameEndingReason::FrameSync);
assert_eq!(vm.heap().allocation_count(), 1031);
assert_eq!(vm.heap().len(), 1, "only the active closure remains reachable");
assert_eq!(callables::run(&mut vm, 100).reason, LogicalFrameEndingReason::EndOfRom);
assert_eq!(&*vm.operand_stack_top(1), &[Value::Int32(73)]);
}