Add generic logical guards and atomic storage publication
This commit is contained in:
@@ -704,7 +704,44 @@ fn check(
|
||||
base += registry.type_layout(parameter.type_id).unwrap().storage.slots as usize;
|
||||
}
|
||||
}
|
||||
Op::ArrayNew => require(working[end - 1], I64, 0, registry, budget)?,
|
||||
Op::ArrayNew | Op::ArrayCheckLength => require(working[end - 1], I64, 0, registry, budget)?,
|
||||
Op::IndexGuard => {
|
||||
require(working[end - 2], I64, 0, registry, budget)?;
|
||||
require(working[end - 1], I64, 1, registry, budget)?;
|
||||
}
|
||||
Op::ArrayCopy | Op::StoragePublish => {
|
||||
let [a, o, f, s] = if instruction.opcode == Op::StoragePublish {
|
||||
instruction.imm_u32x4().unwrap()
|
||||
} else {
|
||||
[instruction.imm_u32().unwrap(), 0, 0, 0]
|
||||
};
|
||||
let effect = instruction.registry_stack_effect_in(registry, FunctionId(id))?.unwrap();
|
||||
let base = end - effect.pops as usize;
|
||||
check_group(&working[base..base + 1], TypeId(a), registry, budget)?;
|
||||
check_group(&working[base + 2..base + 3], TypeId(a), registry, budget)?;
|
||||
for i in [1, 3, 4] {
|
||||
require(working[base + i], I64, i, registry, budget)?;
|
||||
}
|
||||
if instruction.opcode == Op::StoragePublish {
|
||||
for i in [5, 6] {
|
||||
require(working[base + i], I64, i, registry, budget)?;
|
||||
}
|
||||
let element =
|
||||
registry.type_layout(TypeId(a)).unwrap().array.unwrap().element_type_id;
|
||||
let mut at = base + 7;
|
||||
check_group(&working[at..], element, registry, budget)?;
|
||||
at += registry.type_layout(element).unwrap().storage.slots as usize;
|
||||
check_group(&working[at..], TypeId(o), registry, budget)?;
|
||||
at += 1;
|
||||
let fields =
|
||||
®istry.type_layout(TypeId(o)).unwrap().instance.as_ref().unwrap().fields;
|
||||
for field in [f, s] {
|
||||
let ty = fields[field as usize].type_id;
|
||||
check_group(&working[at..], ty, registry, budget)?;
|
||||
at += registry.type_layout(ty).unwrap().storage.slots as usize;
|
||||
}
|
||||
}
|
||||
}
|
||||
Op::StructGet | Op::StructSet | Op::ArrayLen | Op::ArrayGet | Op::ArraySet => {
|
||||
budget.work(3)?;
|
||||
let (id, field) = if matches!(instruction.opcode, Op::StructGet | Op::StructSet) {
|
||||
|
||||
Reference in New Issue
Block a user