spec: bit-exact PRNG, canonical run record, global quiescence
Owner review of the RFC 0007 implementation: - spec 11 §8.1: xoshiro256** with SplitMix64 seeding specified bit for bit, fill consumes ceil(n/8) outputs LSB first; golden vector; own implementation replaces std.Random (whose seeding differs) - spec 07a: canonical run record; stdout/stderr as UTF-8 strings or base64 objects, files always base64 objects - spec 11 §8: blocked only at global quiescence (no runnable unit, no known future event, unfinished execution) - reserved feature resource_joins; test names are permanent and rule-descriptive (renamed resource_*/borrow_* tests) - plan: remaining Phase 2 order heap/regions -> unsafe -> hosted -> reports -> aji.toml
This commit is contained in:
1 parent
d405d4ea50
commit
7a74be3cf7
18 files changed
+203
-38
No files matched your search
@@ -36,9 +36,13 @@ Out: tasks, threads, async I/O (P3); FFI to native code (P7).
|
||||
| P2-9 | doing | Entry-point capability instantiation (`--grant` done; `aji.toml` `[capabilities]` pending) | P2-5 | `src/runtime/host.zig` | missing grant fails instantiation, not execution (spec 05 §6) |
|
||||
| P2-10 | todo | Reports: effect graph, capability requirements, unsafe sites | P2-4, P2-5, P2-7 | `src/report/` | deterministic JSON report; snapshot test |
|
||||
| P2-11 | done | Reference programs: hello (real `io.write` if deferred from P0), file-copy, tcp-echo (single task) | P2-8 | `tests/programs/` | all three run; cleanup on every error path verified |
|
||||
| P2-8a | todo | Hosted profile: real console, files and TCP; run record through `--result-file` (spec 11 §8) | P2-8 | `src/interp/host.zig` | hello, file-copy and tcp-echo run against the real OS in CI |
|
||||
| P2-8a | todo | (after heap and regions, unsafe) Hosted profile: real console, files and TCP; run record through `--result-file` (spec 11 §8) | P2-8 | `src/interp/host.zig` | hello, file-copy and tcp-echo run against the real OS in CI |
|
||||
| P2-12 | todo | Phase exit review | all | plan status | exit criterion passes |
|
||||
|
||||
## Conformance tests to add
|
||||
|
||||
Negative corpus entries owned by this phase: missing capability, undeclared effect, linear resource leak. Plus E3001, E3202, E6001.
|
||||
|
||||
## Remaining order (owner decision)
|
||||
|
||||
RFC 0008 heap and regions → implementation and conformance → unsafe boundaries (P2-7) → hosted profile (P2-8a) → audit reports (P2-10) → `aji.toml` grants (P2-9). The memory model is completed in the deterministic world before the real OS widens the bug surface.
|
||||
@@ -41,6 +41,7 @@ Declaring `features [capabilities, effects, ownership]` grants no authority. It
|
||||
| `linear_aggregates` | reserved | — | `capabilities`, `effects`, `ownership`, `resources` | resource types as struct fields, enum payloads and array elements; unscheduled |
|
||||
| `ownership` | published | 1 | — | frame storage `local<T>`, second-class borrows `ref<T>`/`mut<T>`, `from` returns, initialization (spec 07 §8.8, spec 07a, spec 08 §11, §13) |
|
||||
| `regions` | reserved | 2 | `capabilities`, `effects`, `ownership` | `Region`, static generations, region allocation, reset and destroy |
|
||||
| `resource_joins` | reserved | — | `capabilities`, `effects`, `ownership`, `resources` | joins whose incoming edges carry different resource states (spec 06 §6.3); unscheduled |
|
||||
| `resources` | published | 2 | `capabilities`, `effects`, `ownership` | linear resources `file<read>`, `file<write>`, `file<append>`, `listener`, `stream`; built-in `io_error`; I/O intrinsics (spec 06 §6–§7, `reference/intrinsics.md`) |
|
||||
| `sync` | reserved | 3 | `ownership` | `Mutex<T>`, `RwLock<T>`, linear guards |
|
||||
| `tasks` | reserved | 3 | `ownership` | structured task scopes, spawn/join/cancel, `Send`/`Share` |
|
||||
|
||||
@@ -107,7 +107,7 @@ The resource state of each resource value — `owned`, `consumed by close`, `con
|
||||
| Rule | Code |
|
||||
|---|---|
|
||||
| owned resource live at `ret` (other than the returned one) | `E3002` (`resource.leak`) |
|
||||
| resource state differs between edges into a block | `E3002` |
|
||||
| resource state differs between edges into a block | `E3002` (joins with differing states are reserved for the feature `resource_joins`) |
|
||||
| resource consumed again after any consumption | `E2002` (`ownership.double_consume`) |
|
||||
| non-consuming use after consumption by a closing intrinsic | `E3001` (`resource.use_after_consume`) |
|
||||
| non-consuming use after consumption by transfer | `E2001` (`ownership.use_after_move`) |
|
||||
|
||||
@@ -242,4 +242,11 @@ Resource types and their consumption rules: spec 06 §6. Resources are used thro
|
||||
|
||||
On a trap it reports `{"status":"trapped", "code":…, "kind":…, "function":…, "block":…, "inst":…}` (spec 01 §6).
|
||||
|
||||
Programs that declare `capabilities` also get `"stdout"` and `"stderr"` (captured output) and `"files"` (files written in the virtual file system, keyed by path in byte order) in the record of the `deterministic` profile (spec 11 §8). These byte strings are written as JSON strings in which printable ASCII other than `"` and `\` appears as is, `"`, `\` and newline are escaped as `\"`, `\\` and `\n`, and every other byte `b` as `\u00XX`, so any output is valid, deterministic JSON. When the deterministic runtime detects quiescence it reports `{"status":"blocked","kind":"no_future_event",…}` (spec 11 §8). When instantiation fails (spec 05 §10.2) the program does not start and the runner reports `{"status":"not_instantiated","reason":…,…}`. When the runner stops execution because an execution limit is exhausted (spec 11 §7), it reports `{"status":"limit_exceeded","kind":"fuel","limit":N,"steps":N}`. This is an outcome of the execution environment, not of the program, and is not a trap.
|
||||
Programs that declare `capabilities` also get `"stdout"` and `"stderr"` (captured output) and `"files"` (files written in the virtual file system, keyed by path in byte order) in the record of the `deterministic` profile (spec 11 §8).
|
||||
|
||||
**Canonical record.** The run record is canonical JSON: UTF-8, no whitespace, fields in the order this section lists them, integers in decimal, no locale dependence. Strings escape `"` as `\"`, `\` as `\\`, the control characters U+0008, U+0009, U+000A, U+000C, U+000D as `\b`, `\t`, `\n`, `\f`, `\r`, and other characters below U+0020 as `\u00xx` (lowercase hex); everything else, including non-ASCII, is written as its UTF-8 bytes. Byte data is encoded unambiguously:
|
||||
|
||||
- `stdout`, `stderr`: a JSON string if the bytes are valid UTF-8, otherwise `{"encoding":"base64","data":"…"}`;
|
||||
- every entry of `files`: always `{"encoding":"base64","data":"…"}`, since file contents are arbitrary bytes.
|
||||
|
||||
Base64 is RFC 4648 with padding. Two records are equal exactly when their bytes are equal. When the deterministic runtime detects quiescence it reports `{"status":"blocked","kind":"no_future_event",…}` (spec 11 §8). When instantiation fails (spec 05 §10.2) the program does not start and the runner reports `{"status":"not_instantiated","reason":…,…}`. When the runner stops execution because an execution limit is exhausted (spec 11 §7), it reports `{"status":"limit_exceeded","kind":"fuel","limit":N,"steps":N}`. This is an outcome of the execution environment, not of the program, and is not a trap.
|
||||
@@ -115,9 +115,15 @@ The run record gains fields for observable output. `aji run` uses the **determin
|
||||
| files | in-memory file system seeded by `--vfs PATH=TEXT`; files written during the run are reported as `"files"` in the run record | real file system, limited by capability scopes |
|
||||
| network | in-process loopback: `net.connect` to a listening address of the same run queues a connection that `net.accept` returns; sends are buffered; an operation that would wait for an event that can never occur ends the run with the environment outcome `blocked` (below) | real sockets |
|
||||
| clock | the number of instructions executed so far (1 ns per instruction) | real monotonic clock |
|
||||
| random | xoshiro256\*\* whose state is initialized by SplitMix64 from `--seed N` (default 0); bytes are taken from successive 64-bit outputs, least significant byte first | host CSPRNG |
|
||||
| random | the generator of §8.1, seeded by `--seed N` (default 0) | host CSPRNG |
|
||||
|
||||
**Quiescence.** In the `deterministic` profile, when an operation would wait, no other execution unit can run, and no future deterministic event can complete the wait, the run ends with the environment outcome
|
||||
**Quiescence.** `blocked` is a property of the whole execution, never of one operation. In the `deterministic` profile the run ends as `blocked` exactly when all of the following hold at once:
|
||||
|
||||
- the execution is unfinished (some execution unit has neither returned nor trapped);
|
||||
- no execution unit is runnable;
|
||||
- the runtime knows no future deterministic event (a pending connection, buffered data, an expiring timer, a completing I/O operation, …) that could make one runnable.
|
||||
|
||||
An operation that cannot continue now only suspends its execution unit; while another unit is runnable or a future event is known, the run continues. In Phase 2 there is a single execution unit and no timers, so a wait that nothing can satisfy is immediately global quiescence; Phase 3 extends the set of units and event sources without changing this definition. The run then ends with the environment outcome
|
||||
|
||||
```json
|
||||
{"status":"blocked","kind":"no_future_event","function":"…","block":"…","inst":0}
|
||||
@@ -131,3 +137,24 @@ environment outcome: not_instantiated, limit_exceeded, blocked
|
||||
```
|
||||
|
||||
**Result channel.** In the `hosted` profile the program owns stdout and stderr, so the run record cannot share them unambiguously. The machine-readable record goes to a separate channel: `aji run --profile hosted --result-file PATH` (a `--result-fd N` form may follow; `ajid` has its own control channel). Without `--result-file` the CLI may print a human-readable summary on stderr after the program ends; that summary is not a machine interface.
|
||||
|
||||
### 8.1 Deterministic random generator
|
||||
|
||||
The `deterministic` profile uses xoshiro256\*\* with SplitMix64 seeding. All arithmetic is on unsigned 64-bit integers, wrapping modulo 2^64; `rotl(x, k)` is `(x << k) | (x >> (64 − k))`.
|
||||
|
||||
Seeding from `seed`: let `x = seed`; four times, `x = x + 0x9e3779b97f4a7c15`, `z = x`, `z = (z ^ (z >> 30)) * 0xbf58476d1ce4e5b9`, `z = (z ^ (z >> 27)) * 0x94d049bb133111eb`, output `z ^ (z >> 31)`. The four outputs are the state `s[0]`, `s[1]`, `s[2]`, `s[3]` in that order.
|
||||
|
||||
Next output: `result = rotl(s[1] * 5, 7) * 9`; `t = s[1] << 17`; `s[2] ^= s[0]`; `s[3] ^= s[1]`; `s[1] ^= s[2]`; `s[0] ^= s[3]`; `s[2] ^= t`; `s[3] = rotl(s[3], 45)`; return `result`.
|
||||
|
||||
`random.fill` of `n` bytes consumes `ceil(n / 8)` outputs in order and writes each output's bytes least significant first; the unused bytes of the last output are discarded, so every call starts at a fresh output. The generator state is shared by all `random.read` capabilities of the run.
|
||||
|
||||
Golden vector, `seed = 0`, successive calls of 1, 7, 8 and 17 bytes:
|
||||
|
||||
```text
|
||||
1: b4
|
||||
7: 2a 45 56 49 78 1f 6e
|
||||
8: e0 e6 33 49 9d 84 5f 1a
|
||||
17: 2c 2d 2d 26 f1 94 a5 6a 59 2e 84 1f 4a ad a5 bb ca
|
||||
```
|
||||
|
||||
A conforming implementation MUST produce exactly these bytes.
|
||||
@@ -33,6 +33,7 @@ pub const registry = [_]Feature{
|
||||
.{ .name = "linear_aggregates", .depends = &.{ "capabilities", "effects", "ownership", "resources" }, .status = .reserved, .phase = null },
|
||||
.{ .name = "ownership", .depends = &.{}, .status = .published, .phase = 1 },
|
||||
.{ .name = "regions", .depends = &.{ "capabilities", "effects", "ownership" }, .status = .reserved, .phase = 2 },
|
||||
.{ .name = "resource_joins", .depends = &.{ "capabilities", "effects", "ownership", "resources" }, .status = .reserved, .phase = null },
|
||||
.{ .name = "resources", .depends = &.{ "capabilities", "effects", "ownership" }, .status = .published, .phase = 2 },
|
||||
.{ .name = "sync", .depends = &.{"ownership"}, .status = .reserved, .phase = 3 },
|
||||
.{ .name = "tasks", .depends = &.{"ownership"}, .status = .reserved, .phase = 3 },
|
||||
|
||||
+41
-21
@@ -830,18 +830,32 @@ pub fn writeValue(module: air.Module, v: Value, s: *std.json.Stringify) std.Io.W
|
||||
}
|
||||
}
|
||||
|
||||
/// Writes bytes as a JSON string: printable ASCII as is, every other byte
|
||||
/// as `\u00XX`, so arbitrary output is valid, deterministic JSON.
|
||||
fn writeBytes(w: *std.Io.Writer, bytes: []const u8) std.Io.Writer.Error!void {
|
||||
try w.writeByte('"');
|
||||
for (bytes) |b| switch (b) {
|
||||
'"' => try w.writeAll("\\\""),
|
||||
'\\' => try w.writeAll("\\\\"),
|
||||
'\n' => try w.writeAll("\\n"),
|
||||
0x20...0x21, 0x23...0x5b, 0x5d...0x7e => try w.writeByte(b),
|
||||
else => try w.print("\\u{x:0>4}", .{b}),
|
||||
};
|
||||
try w.writeByte('"');
|
||||
/// Byte strings in the run record (spec 07a "Run result"): a JSON string
|
||||
/// when the bytes are valid UTF-8, otherwise {"encoding":"base64","data":…}.
|
||||
fn writeText(s: *std.json.Stringify, bytes: []const u8) std.Io.Writer.Error!void {
|
||||
if (std.unicode.utf8ValidateSlice(bytes)) return s.write(bytes);
|
||||
try writeBase64(s, bytes);
|
||||
}
|
||||
|
||||
/// Binary data: always {"encoding":"base64","data":…} (RFC 4648, padded).
|
||||
fn writeBase64(s: *std.json.Stringify, bytes: []const u8) std.Io.Writer.Error!void {
|
||||
try s.beginObject();
|
||||
try s.objectField("encoding");
|
||||
try s.write("base64");
|
||||
try s.objectField("data");
|
||||
var buf: [4096]u8 = undefined;
|
||||
try s.beginWriteRaw();
|
||||
try s.writer.writeByte('"');
|
||||
var i: usize = 0;
|
||||
// Encode in chunks of 3-byte groups so no padding appears mid-string.
|
||||
while (i < bytes.len) {
|
||||
const n = @min(bytes.len - i, 3 * 1024);
|
||||
try s.writer.writeAll(std.base64.standard.Encoder.encode(&buf, bytes[i..][0..n]));
|
||||
i += n;
|
||||
}
|
||||
try s.writer.writeByte('"');
|
||||
s.endWriteRaw();
|
||||
try s.endObject();
|
||||
}
|
||||
|
||||
/// Writes the run record for `outcome` as one JSON object (no newline).
|
||||
@@ -911,20 +925,14 @@ pub fn writeOutcome(module: air.Module, outcome: Outcome, out: ?Output, w: *std.
|
||||
}
|
||||
if (out) |o| if (module.declares("capabilities") and outcome != .not_instantiated) {
|
||||
try s.objectField("stdout");
|
||||
try s.beginWriteRaw();
|
||||
try writeBytes(w, o.stdout);
|
||||
s.endWriteRaw();
|
||||
try writeText(&s, o.stdout);
|
||||
try s.objectField("stderr");
|
||||
try s.beginWriteRaw();
|
||||
try writeBytes(w, o.stderr);
|
||||
s.endWriteRaw();
|
||||
try writeText(&s, o.stderr);
|
||||
try s.objectField("files");
|
||||
try s.beginObject();
|
||||
for (o.files) |file| {
|
||||
try s.objectField(file[0]);
|
||||
try s.beginWriteRaw();
|
||||
try writeBytes(w, file[1]);
|
||||
s.endWriteRaw();
|
||||
try writeBase64(&s, file[1]);
|
||||
}
|
||||
try s.endObject();
|
||||
};
|
||||
@@ -1088,3 +1096,15 @@ test "a trap at the last unit of fuel is still a trap" {
|
||||
// const, const, add (traps) = the add begins with the third unit.
|
||||
try expectRunFuel(comptime main1("u8", " %a = const.u8 255\n %b = const.u8 1\n %c = add.checked.u8 %a, %b\n ret %c\n"), "{\"status\":\"trapped\",\"code\":\"T0003\",\"kind\":\"trap.overflow\",\"function\":\"main\",\"block\":\"entry\",\"inst\":2}", 3);
|
||||
}
|
||||
|
||||
test "canonical byte strings in the run record" {
|
||||
var buf: [256]u8 = undefined;
|
||||
var w: std.Io.Writer = .fixed(&buf);
|
||||
var s: std.json.Stringify = .{ .writer = &w };
|
||||
try s.beginArray();
|
||||
try writeText(&s, "h\u{e9}\n");
|
||||
try writeText(&s, "\xff");
|
||||
try writeBase64(&s, "Aji");
|
||||
try s.endArray();
|
||||
try std.testing.expectEqualStrings("[\"h\u{e9}\\n\",{\"encoding\":\"base64\",\"data\":\"/w==\"},{\"encoding\":\"base64\",\"data\":\"QWpp\"}]", w.buffered());
|
||||
}
|
||||
+67
-4
@@ -47,6 +47,53 @@ pub const Options = struct {
|
||||
seed: u64 = 0,
|
||||
};
|
||||
|
||||
/// xoshiro256** with SplitMix64 seeding, specified bit for bit in spec 11 §8.1.
|
||||
/// Implemented here rather than taken from `std.Random`, so that neither a
|
||||
/// toolchain upgrade nor library details can change deterministic output.
|
||||
pub const Prng = struct {
|
||||
s: [4]u64,
|
||||
|
||||
pub fn init(seed: u64) Prng {
|
||||
var x = seed;
|
||||
var p: Prng = undefined;
|
||||
for (&p.s) |*w| {
|
||||
x +%= 0x9e3779b97f4a7c15;
|
||||
var z = x;
|
||||
z = (z ^ (z >> 30)) *% 0xbf58476d1ce4e5b9;
|
||||
z = (z ^ (z >> 27)) *% 0x94d049bb133111eb;
|
||||
w.* = z ^ (z >> 31);
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
pub fn next(p: *Prng) u64 {
|
||||
const s = &p.s;
|
||||
const result = std.math.rotl(u64, s[1] *% 5, 7) *% 9;
|
||||
const t = s[1] << 17;
|
||||
s[2] ^= s[0];
|
||||
s[3] ^= s[1];
|
||||
s[1] ^= s[2];
|
||||
s[0] ^= s[3];
|
||||
s[2] ^= t;
|
||||
s[3] = std.math.rotl(u64, s[3], 45);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// Each call consumes ceil(len / 8) outputs; bytes are taken least
|
||||
/// significant first; unused bytes of the last output are discarded.
|
||||
pub fn fill(p: *Prng, buf: []u8) void {
|
||||
var i: usize = 0;
|
||||
while (i < buf.len) {
|
||||
const v = p.next();
|
||||
var k: u6 = 0;
|
||||
while (k < 8 and i < buf.len) : ({
|
||||
k += 1;
|
||||
i += 1;
|
||||
}) buf[i] = @truncate(v >> (@as(u6, k) * 8));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
pub const World = struct {
|
||||
arena: std.mem.Allocator,
|
||||
stdout: std.ArrayList(u8) = .empty,
|
||||
@@ -57,9 +104,7 @@ pub const World = struct {
|
||||
written: std.StringArrayHashMapUnmanaged(void) = .empty,
|
||||
handles: std.ArrayList(Handle) = .empty,
|
||||
listeners: std.StringHashMapUnmanaged(u32) = .empty,
|
||||
/// xoshiro256** seeded by SplitMix64 from `--seed` (spec 11 §8); pinned
|
||||
/// explicitly so a toolchain upgrade cannot change deterministic output.
|
||||
prng: std.Random.Xoshiro256,
|
||||
prng: Prng,
|
||||
|
||||
pub fn init(arena: std.mem.Allocator, o: Options) !World {
|
||||
var w: World = .{ .arena = arena, .stdin = o.stdin, .prng = .init(o.seed) };
|
||||
@@ -221,7 +266,7 @@ pub const World = struct {
|
||||
// ------------------------------------------------------------ random
|
||||
|
||||
pub fn fill(w: *World, buf: []u8) void {
|
||||
w.prng.random().bytes(buf);
|
||||
w.prng.fill(buf);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -240,3 +285,21 @@ test "addresses" {
|
||||
try std.testing.expect(!World.validAddr("localhost:80"));
|
||||
try std.testing.expect(!World.validAddr("127.0.0.1:99999"));
|
||||
}
|
||||
|
||||
test "PRNG golden vectors (spec 11 §8.1)" {
|
||||
var p: Prng = .init(0);
|
||||
// SplitMix64(0) first output, a published reference value.
|
||||
try std.testing.expectEqual(@as(u64, 0xe220a8397b1dcdaf), Prng.init(0).s[0]);
|
||||
var b1: [1]u8 = undefined;
|
||||
var b7: [7]u8 = undefined;
|
||||
var b8: [8]u8 = undefined;
|
||||
var b17: [17]u8 = undefined;
|
||||
p.fill(&b1);
|
||||
p.fill(&b7);
|
||||
p.fill(&b8);
|
||||
p.fill(&b17);
|
||||
try std.testing.expectEqualSlices(u8, &.{180}, &b1);
|
||||
try std.testing.expectEqualSlices(u8, &.{ 42, 69, 86, 73, 120, 31, 110 }, &b7);
|
||||
try std.testing.expectEqualSlices(u8, &.{ 224, 230, 51, 73, 157, 132, 95, 26 }, &b8);
|
||||
try std.testing.expectEqualSlices(u8, &.{ 44, 45, 45, 38, 241, 148, 165, 106, 89, 46, 132, 31, 74, 173, 165, 187, 202 }, &b17);
|
||||
}
|
||||
@@ -51,6 +51,7 @@ A key is a single lowercase word; header lines without a `key:` prefix are free-
|
||||
## Rules
|
||||
|
||||
- Every verifier rule gets at least one `accept` and one `reject` test (AGENTS.md, testing policy).
|
||||
- **Names are permanent and describe the rule** (`resource_use_after_move.air`, `borrow_use_after_end.air`). A name is never reused for a different rule; the corpus doubles as an executable specification.
|
||||
- One defect per `reject` test. A test that triggers several unrelated errors is hard to repair against.
|
||||
- Keep tests minimal: the smallest module that exhibits the rule.
|
||||
- Tests are written in text AIR format 0 (`docs/reference/air-text.ebnf`) and start with the four-line module header.
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
; expect: reject E2106
|
||||
; phase: 1
|
||||
; spec: docs/spec/08-verifier.md
|
||||
module test.use_after_end
|
||||
module test.borrow_use_after_end
|
||||
air 0
|
||||
lang 0.1
|
||||
features [arrays, ownership]
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
; expect: reject E5002
|
||||
; phase: 2
|
||||
; spec: docs/reference/intrinsics.md
|
||||
module test.ok_arity
|
||||
module test.intrinsic_ok_arity
|
||||
air 0
|
||||
lang 0.1
|
||||
features [arrays, capabilities, effects, ownership, resources]
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
; expect: reject E2002
|
||||
; phase: 2
|
||||
; spec: docs/spec/06-resources-and-errors.md
|
||||
module test.close_twice_after_error
|
||||
module test.resource_close_twice_after_error
|
||||
air 0
|
||||
lang 0.1
|
||||
features [arrays, capabilities, effects, ownership, resources]
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
; expect: reject E2101
|
||||
; phase: 2
|
||||
; spec: docs/spec/06-resources-and-errors.md
|
||||
module test.close_while_borrowed
|
||||
module test.resource_close_while_borrowed
|
||||
air 0
|
||||
lang 0.1
|
||||
features [arrays, capabilities, effects, ownership, resources]
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
; expect: reject E1001
|
||||
; phase: 2
|
||||
; spec: docs/spec/06-resources-and-errors.md
|
||||
module test.copy_resource
|
||||
module test.resource_copy
|
||||
air 0
|
||||
lang 0.1
|
||||
features [arrays, capabilities, effects, ownership, resources]
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
; expect: reject E3001
|
||||
; phase: 2
|
||||
; spec: docs/spec/06-resources-and-errors.md
|
||||
module test.use_after_close
|
||||
module test.resource_use_after_close
|
||||
air 0
|
||||
lang 0.1
|
||||
features [arrays, capabilities, effects, ownership, resources]
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
; expect: reject E2001
|
||||
; phase: 2
|
||||
; spec: docs/spec/06-resources-and-errors.md
|
||||
module test.use_after_move
|
||||
module test.resource_use_after_move
|
||||
air 0
|
||||
lang 0.1
|
||||
features [arrays, capabilities, effects, ownership, resources]
|
||||
@@ -0,0 +1,41 @@
|
||||
; Golden vector of the deterministic generator (spec 11 §8.1): seed 0, calls of 1, 7, 8 and 17 bytes.
|
||||
; expect: run
|
||||
; grant: rng=random.read
|
||||
; seed: 0
|
||||
; result: [180,42,69,86,73,120,31,110,224,230,51,73,157,132,95,26,44,45,45,38,241,148,165,106,89,46,132,31,74,173,165,187,202]
|
||||
; phase: 2
|
||||
; spec: docs/spec/11-determinism-and-replay.md
|
||||
module test.random_golden_vector
|
||||
air 0
|
||||
lang 0.1
|
||||
features [arrays, capabilities, effects, ownership]
|
||||
|
||||
fn @main(%rng: cap<random.read>) -> array<u8, 33>
|
||||
effects [random.read]
|
||||
entry:
|
||||
%b = local.alloc array<u8, 33>
|
||||
local.zero %b
|
||||
%m = borrow.mut %b
|
||||
%s = slice.make %m
|
||||
%o0 = const.usize 0
|
||||
%o1 = const.usize 1
|
||||
%o8 = const.usize 8
|
||||
%o16 = const.usize 16
|
||||
%n7 = const.usize 7
|
||||
%n17 = const.usize 17
|
||||
%a = slice.sub %s, %o0, %o1
|
||||
intrinsic random.fill(%rng, %a)
|
||||
borrow.end %a
|
||||
%c = slice.sub %s, %o1, %n7
|
||||
intrinsic random.fill(%rng, %c)
|
||||
borrow.end %c
|
||||
%d = slice.sub %s, %o8, %o8
|
||||
intrinsic random.fill(%rng, %d)
|
||||
borrow.end %d
|
||||
%e = slice.sub %s, %o16, %n17
|
||||
intrinsic random.fill(%rng, %e)
|
||||
borrow.end %e
|
||||
borrow.end %s
|
||||
borrow.end %m
|
||||
%r = local.load %b
|
||||
ret %r
|
||||
@@ -2,7 +2,7 @@
|
||||
; expect: run
|
||||
; grant: rng=random.read
|
||||
; seed: 7
|
||||
; result: [61,145,174,42]
|
||||
; result: [90,118,249,78]
|
||||
; phase: 2
|
||||
; spec: docs/reference/intrinsics.md
|
||||
module test.random_seeded
|
||||
|
||||
Reference in new issue
Block a user