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:
@@ -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) = ®istry.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
|
||||
®istry.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()
|
||||
|
||||
Reference in New Issue
Block a user