feat(vm): add typed array and struct guest operations
Intrepid/Prometeu/Runtime/pipeline/pr-master This commit looks good
Intrepid/Prometeu/Runtime/pipeline/pr-master This commit looks good
Add seven Registry-backed collection opcodes with bounded verification, complete value groups, transactional publication and exact attempt costs. Publish ISA, memory and cycle contracts, producer handoff and the completed lesson. Validate with 925 workspace tests, optimized collection suites and all eight coverage domain gates. Make headless fixture directory names unique for parallel tests.
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
#[path = "../../../console/prometeu-vm/tests/support/collections.rs"]
|
||||
mod support;
|
||||
use prometeu_bytecode::{assemble, Value};
|
||||
use prometeu_hal::HostContext;
|
||||
use prometeu_vm::{resource_budget::RuntimeLimits, LogicalFrameEndingReason, VirtualMachine};
|
||||
#[test]
|
||||
fn serialized_guest_cycle_and_dynamic_box_cross_real_safepoints_then_reclaim() {
|
||||
let mut text="STRUCT_NEW 9\nSET_GLOBAL 0\nGET_GLOBAL 0\nSTRUCT_GET type=9, field=4\nSET_GLOBAL 9\nGET_GLOBAL 0\nGET_GLOBAL 0\nSTRUCT_SET type=9, field=9\nGET_GLOBAL 0\nGET_GLOBAL 0\nREF_TO_TRAIT source=9, target=10\nSTRUCT_SET type=9, field=10\nGET_GLOBAL 0\nPUSH_F64 f64:0x3ff0000000000000\nPUSH_F64 f64:0x4000000000000000\nDYN_PACK 5\nSTRUCT_SET type=9, field=8\nPUSH_I64 1\nARRAY_NEW 17\nSET_GLOBAL 1\nGET_GLOBAL 1\nPUSH_I64 0\nGET_GLOBAL 0\nARRAY_SET 17\nGET_GLOBAL 9\nSET_GLOBAL 0\n".to_string();
|
||||
// Meet the actual default GC trigger using guest instructions, without a
|
||||
// private heap mutation or a production GC policy change.
|
||||
for _ in 0..1024 {
|
||||
text += "STRUCT_NEW 19\nPOP_N 1\n";
|
||||
}
|
||||
text+="FRAME_SYNC\nGET_GLOBAL 1\nPUSH_I64 0\nARRAY_GET 17\nSTRUCT_GET type=9, field=8\nDYN_UNPACK 5\nPOP_N 2\nGET_GLOBAL 9\nSET_GLOBAL 1\n";
|
||||
for _ in 0..1024 {
|
||||
text += "STRUCT_NEW 19\nPOP_N 1\n";
|
||||
}
|
||||
text += "FRAME_SYNC\nHALT";
|
||||
let mut vm = VirtualMachine::from_image(
|
||||
support::load(&assemble(&text).unwrap()).unwrap(),
|
||||
RuntimeLimits::default(),
|
||||
);
|
||||
vm.prepare_boot_call().unwrap();
|
||||
let r = vm.run_budget(100_000, &mut support::Native, &mut HostContext::new(None)).unwrap();
|
||||
assert_eq!(r.reason, LogicalFrameEndingReason::FrameSync);
|
||||
assert_eq!(vm.heap().len(), 4); // main coroutine, Array, Node, Dynamic box
|
||||
vm.step(&mut support::Native, &mut HostContext::new(None)).unwrap();
|
||||
let Value::HeapRef(array) = vm.operand_stack_top(1)[0] else { panic!() };
|
||||
let r = vm.run_budget(100_000, &mut support::Native, &mut HostContext::new(None)).unwrap();
|
||||
assert_eq!(r.reason, LogicalFrameEndingReason::FrameSync);
|
||||
assert_eq!(vm.heap().len(), 1);
|
||||
assert!(!vm.heap().is_valid(array));
|
||||
}
|
||||
Reference in New Issue
Block a user