Phase 3: structured tasks and the deterministic scheduler (RFC 0011)
- interpreter core rewritten around explicit per-task frame stacks so a task can be suspended at any instruction; behavior of all existing tests unchanged - tasks: scope and task<T> (function-bound; task_transfer and task_borrow_returns reserved), spawn/join/cancel/cancelled/scope.end; cooperative scheduler with seeded choice rule, separate schedule seed, quantum = fuel unit, task limit (limit_exceeded kind tasks), global quiescence over waiting tasks; schedule field in the run record - verifier: Send/Share table (E4001, E4002), loans as task-owned borrows (E4302 on early end, E4101 on conflicts), E4301 at scope end, task effects (E3101) - CLI --quantum, --task-limit, --schedule-seed; runner schedules:, quantum:, task_limit:, limit_exceeded: - fixed: schedule seed default used orelse/^ precedence wrongly - 15 phase-3 conformance tests; 4000 mutants without a crash - Agent Reference Bundle +10.9 % tokens (recorded)
This commit is contained in:
1 parent
2289917af3
commit
ab5814a7bb
31 files changed
+1252
-94
No files matched your search
@@ -0,0 +1,70 @@
|
||||
; The same exclusive borrow is lent to two live tasks.
|
||||
; expect: reject E4101
|
||||
; phase: 3
|
||||
; spec: docs/spec/04-concurrency-and-atomics.md
|
||||
module test.tasks_same_mut_twice
|
||||
air 0
|
||||
lang 0.1
|
||||
features [arrays, ownership, tasks]
|
||||
|
||||
fn @main() -> void
|
||||
effects [task.spawn]
|
||||
entry:
|
||||
%buf = local.alloc array<u64, 4>
|
||||
local.zero %buf
|
||||
%m = borrow.mut %buf
|
||||
%s = slice.make %m
|
||||
%i0 = const.usize 0
|
||||
%i1 = const.usize 1
|
||||
%i2 = const.usize 2
|
||||
%i3 = const.usize 3
|
||||
%e0 = borrow.index %s, %i0
|
||||
%v1 = const.u64 1
|
||||
store %e0, %v1
|
||||
borrow.end %e0
|
||||
%e1 = borrow.index %s, %i1
|
||||
%v2 = const.u64 2
|
||||
store %e1, %v2
|
||||
borrow.end %e1
|
||||
%e2 = borrow.index %s, %i2
|
||||
%v3 = const.u64 3
|
||||
store %e2, %v3
|
||||
borrow.end %e2
|
||||
%e3 = borrow.index %s, %i3
|
||||
%v4 = const.u64 4
|
||||
store %e3, %v4
|
||||
borrow.end %e3
|
||||
%two = const.usize 2
|
||||
%l, %r = slice.split %s, %two
|
||||
%sc = task.scope.begin
|
||||
%t1 = task.spawn %sc, @square(%l)
|
||||
%t2 = task.spawn %sc, @square(%l)
|
||||
task.join %t1
|
||||
task.join %t2
|
||||
task.scope.end %sc
|
||||
borrow.end %l
|
||||
borrow.end %r
|
||||
borrow.end %s
|
||||
borrow.end %m
|
||||
ret
|
||||
|
||||
fn @square(%s: slice_mut<u64>) -> void
|
||||
effects []
|
||||
entry:
|
||||
%n = slice.len %s
|
||||
%z = const.usize 0
|
||||
br @loop(%z)
|
||||
loop(%i: usize):
|
||||
%c = lt.usize %i, %n
|
||||
cbr %c, @body(), @done()
|
||||
body:
|
||||
%e = borrow.index.proven %s, %i
|
||||
%v = load %e
|
||||
%sq = mul.checked.u64 %v, %v
|
||||
store %e, %sq
|
||||
borrow.end %e
|
||||
%one = const.usize 1
|
||||
%j = add.checked.usize %i, %one
|
||||
br @loop(%j)
|
||||
done:
|
||||
ret
|
||||
Reference in new issue
Block a user