feat(vm): publish typed fields across multiple structs atomically

Add schema-driven FIELDS_PUBLISH without collection-specific runtime behavior. Validate every nullable destination and complete field group before allocation-free publication, with neutral ownership, malformed-input and quota coverage.
This commit is contained in:
Nilton Constantino
2026-10-23 09:53:40 +01:00
committed by bquarkz
parent d9b9eeb171
commit 57992cf214
13 changed files with 384 additions and 12 deletions
@@ -709,6 +709,27 @@ fn check(
require(working[end - 2], I64, 0, registry, budget)?;
require(working[end - 1], I64, 1, registry, budget)?;
}
Op::FieldsPublish => {
let schema = TypeId(instruction.imm_u32().unwrap());
let effect = instruction.registry_stack_effect(registry)?.unwrap();
let mut at = end - effect.pops as usize;
let TypeKind::Struct(entries) = &registry.declarations().types[schema.0 as usize].kind
else {
unreachable!()
};
for entry in entries {
budget.work(1)?;
check_group(&working[at..], entry.type_id, registry, budget)?;
at += 1;
for field in
&registry.type_layout(entry.type_id).unwrap().instance.as_ref().unwrap().fields
{
budget.work(1)?;
check_group(&working[at..], field.type_id, registry, budget)?;
at += registry.type_layout(field.type_id).unwrap().storage.slots as usize;
}
}
}
Op::ArrayCopy | Op::StoragePublish => {
let [a, o, f, s] = if instruction.opcode == Op::StoragePublish {
instruction.imm_u32x4().unwrap()