Files
aji/tests/conformance/phase2/run/budget_children_compete.air
T
dev 7f4ce71d44 Phase 2: heap, regions and allocation budgets (RFC 0008)
- air: own<T>, own_array<T>, region, alloc_error; own.new/array/take/
  free, region.create/new/array/reset/destroy; mem.alloc budget form;
  linear contents of owners gated by linear_aggregates
- verifier: allocation types and capability kind (E1001, E3201),
  mem.alloc effect (E3101), ok/err counts; borrow-typed block params
  checked in the CFG stage with the region-allocation exception; linear
  owners and regions (E3002, E3001, E2001, E2002, E2101); region
  allocations as disjoint exclusive children of the shared region
  borrow; E2104 when reset/destroy would invalidate a live reference
- interp: live-byte budgets charged along the narrowing chain, shared by
  copies, mandatory in the deterministic profile; heap cells; regions
  return quota only on reset/destroy
- conformance: 25 heap/region tests including a 64 KiB region file copy;
  4000 mutants without a crash
2026-10-04 14:26:34 +03:00

42 lines
1.0 KiB
LLVM

; Two 12-byte children of a 16-byte parent: limits may oversubscribe; the parent bounds the total.
; expect: run
; grant: heap=mem.alloc:16
; result: 1
; phase: 2
; spec: docs/spec/03-memory-model.md
module test.budget_children_compete
air 0
lang 0.1
features [capabilities, effects, heap, ownership, resources]
fn @main(%heap: cap<mem.alloc>) -> u8
effects [mem.alloc]
entry:
%twelve = const.usize 12
cap.narrow.budget %heap, %twelve, ok -> @a, err -> @bad
a(%ca: cap<mem.alloc>):
cap.narrow.budget %heap, %twelve, ok -> @b, err -> @bad2
b(%cb: cap<mem.alloc>):
%v = const.u64 1
own.new %v, %ca, ok -> @x, err -> @nomem
x(%ox: own<u64>):
own.new %v, %cb, ok -> @y, err -> @nomem2
y(%oy: own<u64>):
%small = const.u8 1
own.new %small, %cb, ok -> @z, err -> @parent_full
z(%oz: own<u8>):
trap
parent_full(%e3: alloc_error):
own.free %ox
own.free %oy
%one = const.u8 1
ret %one
bad(%c1: cap_error):
trap
bad2(%c2: cap_error):
trap
nomem2(%e2: alloc_error):
trap
nomem(%e: alloc_error):
trap