spec: accept RFC 0008 and integrate heap, regions and budgets

- spec 03 §18-§21: allocation authority and live-byte budgets, heap
  (own.new/array/take/free), regions (create/new/array/reset/destroy,
  static generations, E2104 on live references)
- spec 05 §11.2, 07 §8.9, 07a summary, 08 §11.2 region allocation paths
  and the ok-parameter exception to borrow_joins
- registries: alloc_error, mem.alloc budget form, mandatory deterministic
  budget; heap and regions published
This commit is contained in:
dev committed 2026-10-04 14:20:40 +03:00
1 parent d4d641ad84
commit b8d4ab4d4c
8 files changed
+154 -7

No files matched your search

+18
View File
@@ -228,6 +228,24 @@ Intrinsics have an infallible form (`[%r =] intrinsic …`) and a fallible termi
Resource types and their consumption rules: spec 06 §6. Resources are used through `borrow.ref`/`borrow.mut` (which accept a resource value as root) and consumed by closing intrinsics, by-value resource parameters, resource block parameters and `ret`.
## Feature `heap` and feature `regions`
Instructions, budget accounting and verifier rules: spec 03 §18–§20. Summary:
| Instruction | Form | Effect |
|---|---|---|
| `own.new %v, %c, ok -> @ok, err -> @err` | terminator, `@ok(own<T>)`, `@err(alloc_error)` | `mem.alloc` |
| `own.array %n, %v, %c, ok -> @ok, err -> @err` | terminator, `@ok(own_array<T>)`, `@err(alloc_error)` | `mem.alloc` |
| `%v = own.take %o` | consumes `own<T>`, yields `T` | — |
| `own.free %o` | consumes `own<T>` or `own_array<T>` | — |
| `region.create %c, ok -> @ok, err -> @err` | terminator, `@ok(region)`, `@err(alloc_error)` | `mem.alloc` |
| `region.new %rb, %v, ok -> @ok, err -> @err` | terminator, `@ok(mut<T>)`, `@err(alloc_error)` | `mem.alloc` |
| `region.array %rb, %n, %v, ok -> @ok, err -> @err` | terminator, `@ok(slice_mut<T>)`, `@err(alloc_error)` | `mem.alloc` |
| `region.reset %r` | region not consumed | — |
| `region.destroy %r` | consumes region | — |
`borrow.ref`/`borrow.mut` accept owners and regions as roots: `own<T>` gives `ref<T>`/`mut<T>`, `own_array<T>` gives `slice<T>`/`slice_mut<T>`, `region` gives `ref<region>`/`mut<region>`.
## Run result
`aji run` executes the function `@main`, whose parameters MUST all be capabilities, bound by name at instantiation (spec 05 §10.2); without the `capabilities` feature it takes no parameters. On return it reports `{"status":"returned","value":V}` where `V` renders the returned value as JSON: