verifier: preserve resource obligations across CFG handoff
This commit is contained in:
1 parent
0e98638bc6
commit
09fbf8a5bc
34 files changed
+1267
-67
No files matched your search
@@ -0,0 +1,41 @@
|
||||
; The cancelled handle of task.join.cancel passed through an ordinary block argument keeps its loans.
|
||||
; expect: reject E4302
|
||||
; phase: 3
|
||||
; spec: docs/spec/04-concurrency-and-atomics.md §34, §37
|
||||
module test.cfg_provenance_cancel_arg
|
||||
air 0
|
||||
lang 0.1
|
||||
features [cancellation, effects, ownership, tasks]
|
||||
|
||||
fn @main() -> u8
|
||||
effects [task.spawn, task.wait]
|
||||
entry:
|
||||
%x = local.alloc u8
|
||||
local.zero %x
|
||||
%r = borrow.ref %x
|
||||
%sc = task.scope.begin
|
||||
%t = task.spawn %sc, @rd(%r)
|
||||
task.join.cancel %t, ok -> @joined, cancelled -> @cancelled
|
||||
joined(%v: u8):
|
||||
task.scope.end %sc
|
||||
borrow.end %r
|
||||
ret %v
|
||||
cancelled(%t1: task<u8>):
|
||||
br @handle(%t1)
|
||||
handle(%t2: task<u8>):
|
||||
borrow.end %r
|
||||
%v2 = task.join %t2
|
||||
task.scope.end %sc
|
||||
ret %v2
|
||||
|
||||
fn @rd(%p: ref<u8>) -> u8
|
||||
effects []
|
||||
entry:
|
||||
%v = load %p
|
||||
ret %v
|
||||
|
||||
fn @zero() -> u8
|
||||
effects []
|
||||
entry:
|
||||
%z = const.u8 0
|
||||
ret %z
|
||||
@@ -0,0 +1,27 @@
|
||||
; A guard passed through a block argument still depends on the mutex borrow it was locked through; ending that borrow while the guard is live is rejected.
|
||||
; expect: reject E2102
|
||||
; phase: 3
|
||||
; spec: docs/spec/04-concurrency-and-atomics.md §40
|
||||
module test.cfg_provenance_guard_parent
|
||||
air 0
|
||||
lang 0.1
|
||||
features [cancellation, effects, ownership, sync, tasks]
|
||||
|
||||
fn @main() -> u64
|
||||
effects [task.wait]
|
||||
entry:
|
||||
%z = const.u64 0
|
||||
%m = mutex.make %z
|
||||
%mr = borrow.ref %m
|
||||
mutex.lock %mr, ok -> @locked, cancelled -> @out
|
||||
locked(%g: guard<u64>):
|
||||
br @next(%g)
|
||||
next(%g2: guard<u64>):
|
||||
borrow.end %mr
|
||||
mutex.unlock %g2
|
||||
%v = mutex.take %m
|
||||
ret %v
|
||||
out:
|
||||
borrow.end %mr
|
||||
%w = mutex.take %m
|
||||
ret %w
|
||||
@@ -0,0 +1,37 @@
|
||||
; Parent store through the lent exclusive borrow races after a handle handoff.
|
||||
; expect: reject E4101
|
||||
; phase: 3
|
||||
; spec: docs/spec/04-concurrency-and-atomics.md §34
|
||||
module test.cfg_provenance_loan_access
|
||||
air 0
|
||||
lang 0.1
|
||||
features [cancellation, effects, ownership, tasks]
|
||||
|
||||
fn @main() -> u8
|
||||
effects [task.spawn, task.wait]
|
||||
entry:
|
||||
%x = local.alloc u8
|
||||
local.zero %x
|
||||
%r = borrow.mut %x
|
||||
%sc = task.scope.begin
|
||||
%t = task.spawn %sc, @rd(%r)
|
||||
br @next(%t)
|
||||
next(%t2: task<u8>):
|
||||
%one = const.u8 1
|
||||
store %r, %one
|
||||
%v = task.join %t2
|
||||
borrow.end %r
|
||||
task.scope.end %sc
|
||||
ret %v
|
||||
|
||||
fn @rd(%p: mut<u8>) -> u8
|
||||
effects []
|
||||
entry:
|
||||
%v = load %p
|
||||
ret %v
|
||||
|
||||
fn @zero() -> u8
|
||||
effects []
|
||||
entry:
|
||||
%z = const.u8 0
|
||||
ret %z
|
||||
@@ -0,0 +1,42 @@
|
||||
; The loop body lends the borrow to a new task and passes it back to the header; the exit sees that handle through the header parameter, so ending the borrow before its join is rejected.
|
||||
; expect: reject E4302
|
||||
; phase: 3
|
||||
; spec: docs/spec/04-concurrency-and-atomics.md §34
|
||||
module test.cfg_provenance_loan_backedge
|
||||
air 0
|
||||
lang 0.1
|
||||
features [cancellation, effects, ownership, tasks]
|
||||
|
||||
fn @main() -> u8
|
||||
effects [task.spawn, task.wait]
|
||||
entry:
|
||||
%x = local.alloc u8
|
||||
local.zero %x
|
||||
%r = borrow.ref %x
|
||||
%sc = task.scope.begin
|
||||
%t0 = task.spawn %sc, @zero()
|
||||
br @head(%t0)
|
||||
head(%t: task<u8>):
|
||||
%c = const.bool false
|
||||
cbr %c, @body(%t), @exit(%t)
|
||||
body(%tb: task<u8>):
|
||||
%old = task.join %tb
|
||||
%t1 = task.spawn %sc, @rd(%r)
|
||||
br @head(%t1)
|
||||
exit(%te: task<u8>):
|
||||
borrow.end %r
|
||||
%v = task.join %te
|
||||
task.scope.end %sc
|
||||
ret %v
|
||||
|
||||
fn @rd(%p: ref<u8>) -> u8
|
||||
effects []
|
||||
entry:
|
||||
%v = load %p
|
||||
ret %v
|
||||
|
||||
fn @zero() -> u8
|
||||
effects []
|
||||
entry:
|
||||
%z = const.u8 0
|
||||
ret %z
|
||||
@@ -0,0 +1,35 @@
|
||||
; A task handle passed through an ordinary block argument keeps its loans: ending the lent borrow before the join is rejected.
|
||||
; expect: reject E4302
|
||||
; phase: 3
|
||||
; spec: docs/spec/04-concurrency-and-atomics.md §34
|
||||
module test.cfg_provenance_loan_br
|
||||
air 0
|
||||
lang 0.1
|
||||
features [cancellation, effects, ownership, tasks]
|
||||
|
||||
fn @main() -> u8
|
||||
effects [task.spawn, task.wait]
|
||||
entry:
|
||||
%x = local.alloc u8
|
||||
local.zero %x
|
||||
%r = borrow.ref %x
|
||||
%sc = task.scope.begin
|
||||
%t = task.spawn %sc, @rd(%r)
|
||||
br @next(%t)
|
||||
next(%t2: task<u8>):
|
||||
borrow.end %r
|
||||
%v = task.join %t2
|
||||
task.scope.end %sc
|
||||
ret %v
|
||||
|
||||
fn @rd(%p: ref<u8>) -> u8
|
||||
effects []
|
||||
entry:
|
||||
%v = load %p
|
||||
ret %v
|
||||
|
||||
fn @zero() -> u8
|
||||
effects []
|
||||
entry:
|
||||
%z = const.u8 0
|
||||
ret %z
|
||||
@@ -0,0 +1,41 @@
|
||||
; Both cbr targets receive the lent task; ending the borrow before the join on one target is rejected.
|
||||
; expect: reject E4302
|
||||
; phase: 3
|
||||
; spec: docs/spec/04-concurrency-and-atomics.md §34
|
||||
module test.cfg_provenance_loan_cbr
|
||||
air 0
|
||||
lang 0.1
|
||||
features [cancellation, effects, ownership, tasks]
|
||||
|
||||
fn @main() -> u8
|
||||
effects [task.spawn, task.wait]
|
||||
entry:
|
||||
%x = local.alloc u8
|
||||
local.zero %x
|
||||
%r = borrow.ref %x
|
||||
%sc = task.scope.begin
|
||||
%t = task.spawn %sc, @rd(%r)
|
||||
%c = const.bool true
|
||||
cbr %c, @early(%t), @late(%t)
|
||||
early(%a: task<u8>):
|
||||
borrow.end %r
|
||||
%va = task.join %a
|
||||
task.scope.end %sc
|
||||
ret %va
|
||||
late(%b: task<u8>):
|
||||
%vb = task.join %b
|
||||
borrow.end %r
|
||||
task.scope.end %sc
|
||||
ret %vb
|
||||
|
||||
fn @rd(%p: ref<u8>) -> u8
|
||||
effects []
|
||||
entry:
|
||||
%v = load %p
|
||||
ret %v
|
||||
|
||||
fn @zero() -> u8
|
||||
effects []
|
||||
entry:
|
||||
%z = const.u8 0
|
||||
ret %z
|
||||
@@ -0,0 +1,41 @@
|
||||
; One predecessor lends the borrow to its task and the other does not; after the join the handle may hold the loan, so ending the borrow first is rejected.
|
||||
; expect: reject E4302
|
||||
; phase: 3
|
||||
; spec: docs/spec/04-concurrency-and-atomics.md §34
|
||||
module test.cfg_provenance_loan_join
|
||||
air 0
|
||||
lang 0.1
|
||||
features [cancellation, effects, ownership, tasks]
|
||||
|
||||
fn @main() -> u8
|
||||
effects [task.spawn, task.wait]
|
||||
entry:
|
||||
%x = local.alloc u8
|
||||
local.zero %x
|
||||
%r = borrow.ref %x
|
||||
%sc = task.scope.begin
|
||||
%c = const.bool true
|
||||
cbr %c, @lend(), @plain()
|
||||
lend:
|
||||
%t1 = task.spawn %sc, @rd(%r)
|
||||
br @joined(%t1)
|
||||
plain:
|
||||
%t2 = task.spawn %sc, @zero()
|
||||
br @joined(%t2)
|
||||
joined(%t: task<u8>):
|
||||
borrow.end %r
|
||||
%v = task.join %t
|
||||
task.scope.end %sc
|
||||
ret %v
|
||||
|
||||
fn @rd(%p: ref<u8>) -> u8
|
||||
effects []
|
||||
entry:
|
||||
%v = load %p
|
||||
ret %v
|
||||
|
||||
fn @zero() -> u8
|
||||
effects []
|
||||
entry:
|
||||
%z = const.u8 0
|
||||
ret %z
|
||||
@@ -0,0 +1,41 @@
|
||||
; An integer switch hands the lent task to its targets; ending the borrow before the join on the default target is rejected.
|
||||
; expect: reject E4302
|
||||
; phase: 3
|
||||
; spec: docs/spec/04-concurrency-and-atomics.md §34
|
||||
module test.cfg_provenance_loan_switch
|
||||
air 0
|
||||
lang 0.1
|
||||
features [cancellation, effects, ownership, tasks]
|
||||
|
||||
fn @main() -> u8
|
||||
effects [task.spawn, task.wait]
|
||||
entry:
|
||||
%x = local.alloc u8
|
||||
local.zero %x
|
||||
%r = borrow.ref %x
|
||||
%sc = task.scope.begin
|
||||
%t = task.spawn %sc, @rd(%r)
|
||||
%k = const.u8 7
|
||||
switch.u8 %k, 0 -> @zero_case(%t), default -> @other(%t)
|
||||
zero_case(%a: task<u8>):
|
||||
%va = task.join %a
|
||||
borrow.end %r
|
||||
task.scope.end %sc
|
||||
ret %va
|
||||
other(%b: task<u8>):
|
||||
borrow.end %r
|
||||
%vb = task.join %b
|
||||
task.scope.end %sc
|
||||
ret %vb
|
||||
|
||||
fn @rd(%p: ref<u8>) -> u8
|
||||
effects []
|
||||
entry:
|
||||
%v = load %p
|
||||
ret %v
|
||||
|
||||
fn @zero() -> u8
|
||||
effects []
|
||||
entry:
|
||||
%z = const.u8 0
|
||||
ret %z
|
||||
@@ -0,0 +1,31 @@
|
||||
; Only the scope is passed through a block argument; its task is still unjoined when the renamed scope ends.
|
||||
; expect: reject E4301
|
||||
; phase: 3
|
||||
; spec: docs/spec/04-concurrency-and-atomics.md §33
|
||||
module test.cfg_provenance_scope_alone
|
||||
air 0
|
||||
lang 0.1
|
||||
features [cancellation, effects, ownership, tasks]
|
||||
|
||||
fn @main() -> u8
|
||||
effects [task.spawn, task.wait]
|
||||
entry:
|
||||
%sc = task.scope.begin
|
||||
%t = task.spawn %sc, @zero()
|
||||
br @next(%sc)
|
||||
next(%s2: scope):
|
||||
task.scope.end %s2
|
||||
%v = const.u8 0
|
||||
ret %v
|
||||
|
||||
fn @rd(%p: ref<u8>) -> u8
|
||||
effects []
|
||||
entry:
|
||||
%v = load %p
|
||||
ret %v
|
||||
|
||||
fn @zero() -> u8
|
||||
effects []
|
||||
entry:
|
||||
%z = const.u8 0
|
||||
ret %z
|
||||
@@ -0,0 +1,31 @@
|
||||
; The scope and its task are passed together through block arguments; the renamed scope ends while the renamed task is unjoined.
|
||||
; expect: reject E4301
|
||||
; phase: 3
|
||||
; spec: docs/spec/04-concurrency-and-atomics.md §33
|
||||
module test.cfg_provenance_scope_task
|
||||
air 0
|
||||
lang 0.1
|
||||
features [cancellation, effects, ownership, tasks]
|
||||
|
||||
fn @main() -> u8
|
||||
effects [task.spawn, task.wait]
|
||||
entry:
|
||||
%sc = task.scope.begin
|
||||
%t = task.spawn %sc, @zero()
|
||||
br @next(%sc, %t)
|
||||
next(%s2: scope, %t2: task<u8>):
|
||||
task.scope.end %s2
|
||||
%v = const.u8 0
|
||||
ret %v
|
||||
|
||||
fn @rd(%p: ref<u8>) -> u8
|
||||
effects []
|
||||
entry:
|
||||
%v = load %p
|
||||
ret %v
|
||||
|
||||
fn @zero() -> u8
|
||||
effects []
|
||||
entry:
|
||||
%z = const.u8 0
|
||||
ret %z
|
||||
@@ -0,0 +1,19 @@
|
||||
; Shields passed through block arguments keep their nesting: ending the outer shield first is rejected.
|
||||
; expect: reject E4305
|
||||
; phase: 3
|
||||
; spec: docs/spec/04-concurrency-and-atomics.md §37.3
|
||||
module test.cfg_provenance_shield_order
|
||||
air 0
|
||||
lang 0.1
|
||||
features [cancellation, effects, ownership, tasks]
|
||||
|
||||
fn @main() -> void
|
||||
effects []
|
||||
entry:
|
||||
%a = task.shield.begin
|
||||
%b = task.shield.begin
|
||||
br @next(%a, %b)
|
||||
next(%outer: shield, %inner: shield):
|
||||
task.shield.end %outer
|
||||
task.shield.end %inner
|
||||
ret
|
||||
@@ -0,0 +1,21 @@
|
||||
; Incoming stacks disagree; ending a first also violates the b-inside-a path.
|
||||
; The two edges into a block pass the live shields in opposite nesting order, so the shield stack differs between edges (spec 04 §37.3).
|
||||
; expect: reject E3002 E4305
|
||||
; phase: 3
|
||||
; spec: docs/spec/04-concurrency-and-atomics.md §37.3
|
||||
module test.cfg_provenance_shield_stack_join
|
||||
air 0
|
||||
lang 0.1
|
||||
features [cancellation, effects, ownership, tasks]
|
||||
|
||||
fn @main() -> void
|
||||
effects []
|
||||
entry:
|
||||
%a = task.shield.begin
|
||||
%b = task.shield.begin
|
||||
%c = const.bool true
|
||||
cbr %c, @joined(%a, %b), @joined(%b, %a)
|
||||
joined(%x: shield, %y: shield):
|
||||
task.shield.end %y
|
||||
task.shield.end %x
|
||||
ret
|
||||
@@ -0,0 +1,38 @@
|
||||
; The cancelled handle of task.join.cancel may travel through an ordinary block argument; joining it before ending the lent borrow is valid.
|
||||
; expect: run
|
||||
; schedules: 20
|
||||
; result: 5
|
||||
; phase: 3
|
||||
; spec: docs/spec/04-concurrency-and-atomics.md §37
|
||||
module test.cfg_provenance_cancel_arg
|
||||
air 0
|
||||
lang 0.1
|
||||
features [cancellation, effects, ownership, tasks]
|
||||
|
||||
fn @main() -> u8
|
||||
effects [task.spawn, task.wait]
|
||||
entry:
|
||||
%x = local.alloc u8
|
||||
%five = const.u8 5
|
||||
local.store %x, %five
|
||||
%r = borrow.ref %x
|
||||
%sc = task.scope.begin
|
||||
%t = task.spawn %sc, @rd(%r)
|
||||
task.join.cancel %t, ok -> @joined, cancelled -> @cancelled
|
||||
joined(%v: u8):
|
||||
task.scope.end %sc
|
||||
borrow.end %r
|
||||
ret %v
|
||||
cancelled(%t1: task<u8>):
|
||||
br @handle(%t1)
|
||||
handle(%t2: task<u8>):
|
||||
%v2 = task.join %t2
|
||||
task.scope.end %sc
|
||||
borrow.end %r
|
||||
ret %v2
|
||||
|
||||
fn @rd(%p: ref<u8>) -> u8
|
||||
effects []
|
||||
entry:
|
||||
%v = load %p
|
||||
ret %v
|
||||
@@ -0,0 +1,41 @@
|
||||
; Two scopes and their tasks are permuted together on the two edges into a block; each renamed task belongs to the renamed scope beside it, so joining and ending them pairwise is valid.
|
||||
; expect: run
|
||||
; schedules: 20
|
||||
; result: 12
|
||||
; phase: 3
|
||||
; spec: docs/spec/04-concurrency-and-atomics.md §33
|
||||
module test.cfg_provenance_correlated_scopes
|
||||
air 0
|
||||
lang 0.1
|
||||
features [cancellation, effects, ownership, tasks]
|
||||
|
||||
fn @main() -> u8
|
||||
effects [task.spawn, task.wait]
|
||||
entry:
|
||||
%s1 = task.scope.begin
|
||||
%s2 = task.scope.begin
|
||||
%t1 = task.spawn %s1, @one()
|
||||
%t2 = task.spawn %s2, @two()
|
||||
%c = const.bool true
|
||||
cbr %c, @next(%s1, %s2, %t1, %t2), @next(%s2, %s1, %t2, %t1)
|
||||
next(%pa: scope, %pb: scope, %ta: task<u8>, %tb: task<u8>):
|
||||
%va = task.join %ta
|
||||
task.scope.end %pa
|
||||
%vb = task.join %tb
|
||||
task.scope.end %pb
|
||||
%ten = const.u8 10
|
||||
%hi = mul.checked.u8 %va, %ten
|
||||
%r = add.checked.u8 %hi, %vb
|
||||
ret %r
|
||||
|
||||
fn @one() -> u8
|
||||
effects []
|
||||
entry:
|
||||
%v = const.u8 1
|
||||
ret %v
|
||||
|
||||
fn @two() -> u8
|
||||
effects []
|
||||
entry:
|
||||
%v = const.u8 2
|
||||
ret %v
|
||||
@@ -0,0 +1,33 @@
|
||||
; A guard may be passed through a block argument; borrowing through it, unlocking and only then ending the mutex borrow is valid.
|
||||
; expect: run
|
||||
; schedules: 20
|
||||
; result: 7
|
||||
; phase: 3
|
||||
; spec: docs/spec/04-concurrency-and-atomics.md §40
|
||||
module test.cfg_provenance_guard_handoff
|
||||
air 0
|
||||
lang 0.1
|
||||
features [cancellation, effects, ownership, sync, tasks]
|
||||
|
||||
fn @main() -> u64
|
||||
effects [task.wait]
|
||||
entry:
|
||||
%z = const.u64 0
|
||||
%m = mutex.make %z
|
||||
%mr = borrow.ref %m
|
||||
mutex.lock %mr, ok -> @locked, cancelled -> @out
|
||||
locked(%g: guard<u64>):
|
||||
br @next(%g)
|
||||
next(%g2: guard<u64>):
|
||||
%p = mutex.borrow %g2
|
||||
%seven = const.u64 7
|
||||
store %p, %seven
|
||||
borrow.end %p
|
||||
mutex.unlock %g2
|
||||
borrow.end %mr
|
||||
%v = mutex.take %m
|
||||
ret %v
|
||||
out:
|
||||
borrow.end %mr
|
||||
%w = mutex.take %m
|
||||
ret %w
|
||||
@@ -0,0 +1,39 @@
|
||||
; Joining the renamed handle returns its exclusive loan before parent reuse.
|
||||
; expect: run
|
||||
; schedules: 20
|
||||
; result: 0
|
||||
; phase: 3
|
||||
; spec: docs/spec/04-concurrency-and-atomics.md §34
|
||||
module test.cfg_provenance_loan_returned
|
||||
air 0
|
||||
lang 0.1
|
||||
features [cancellation, effects, ownership, tasks]
|
||||
|
||||
fn @main() -> u8
|
||||
effects [task.spawn, task.wait]
|
||||
entry:
|
||||
%x = local.alloc u8
|
||||
local.zero %x
|
||||
%r = borrow.mut %x
|
||||
%sc = task.scope.begin
|
||||
%t = task.spawn %sc, @rd(%r)
|
||||
br @next(%t)
|
||||
next(%t2: task<u8>):
|
||||
%v = task.join %t2
|
||||
%one = const.u8 1
|
||||
store %r, %one
|
||||
borrow.end %r
|
||||
task.scope.end %sc
|
||||
ret %v
|
||||
|
||||
fn @rd(%p: mut<u8>) -> u8
|
||||
effects []
|
||||
entry:
|
||||
%v = load %p
|
||||
ret %v
|
||||
|
||||
fn @zero() -> u8
|
||||
effects []
|
||||
entry:
|
||||
%z = const.u8 0
|
||||
ret %z
|
||||
@@ -0,0 +1,22 @@
|
||||
; Shields may be passed through block arguments and ended innermost first.
|
||||
; expect: run
|
||||
; schedules: 20
|
||||
; result: 4
|
||||
; phase: 3
|
||||
; spec: docs/spec/04-concurrency-and-atomics.md §37.3
|
||||
module test.cfg_provenance_shield_handoff
|
||||
air 0
|
||||
lang 0.1
|
||||
features [cancellation, effects, ownership, tasks]
|
||||
|
||||
fn @main() -> u8
|
||||
effects []
|
||||
entry:
|
||||
%a = task.shield.begin
|
||||
%b = task.shield.begin
|
||||
br @next(%a, %b)
|
||||
next(%outer: shield, %inner: shield):
|
||||
task.shield.end %inner
|
||||
task.shield.end %outer
|
||||
%v = const.u8 4
|
||||
ret %v
|
||||
@@ -0,0 +1,42 @@
|
||||
; A loop lends a borrow to a new task each iteration and joins it at the header; the borrow ends only after the last join.
|
||||
; expect: run
|
||||
; schedules: 20
|
||||
; result: 3
|
||||
; phase: 3
|
||||
; spec: docs/spec/04-concurrency-and-atomics.md §34
|
||||
module test.cfg_provenance_task_loop
|
||||
air 0
|
||||
lang 0.1
|
||||
features [cancellation, effects, ownership, tasks]
|
||||
|
||||
fn @main() -> u8
|
||||
effects [task.spawn, task.wait]
|
||||
entry:
|
||||
%x = local.alloc u8
|
||||
%one = const.u8 1
|
||||
local.store %x, %one
|
||||
%r = borrow.ref %x
|
||||
%sc = task.scope.begin
|
||||
%t0 = task.spawn %sc, @rd(%r)
|
||||
%zero = const.u8 0
|
||||
br @head(%t0, %zero, %zero)
|
||||
head(%t: task<u8>, %acc: u8, %i: u8):
|
||||
%v = task.join %t
|
||||
%acc2 = add.checked.u8 %acc, %v
|
||||
%i2 = add.checked.u8 %i, %one
|
||||
%three = const.u8 3
|
||||
%more = lt.u8 %i2, %three
|
||||
cbr %more, @body(%acc2, %i2), @exit(%acc2)
|
||||
body(%a: u8, %n: u8):
|
||||
%t1 = task.spawn %sc, @rd(%r)
|
||||
br @head(%t1, %a, %n)
|
||||
exit(%total: u8):
|
||||
task.scope.end %sc
|
||||
borrow.end %r
|
||||
ret %total
|
||||
|
||||
fn @rd(%p: ref<u8>) -> u8
|
||||
effects []
|
||||
entry:
|
||||
%v = load %p
|
||||
ret %v
|
||||
@@ -0,0 +1,27 @@
|
||||
// expect: reject E4302
|
||||
// phase: 6
|
||||
// spec: docs/spec/04-concurrency-and-atomics.md §37
|
||||
// AIR twin: phase3/reject/cancel_join_keeps_loans.air
|
||||
module test.twins.cancel_join_keeps_loans
|
||||
|
||||
fn work(p: ref<u8>) -> u8 effects [] {
|
||||
return *p;
|
||||
}
|
||||
|
||||
fn main() -> u8 effects [task.spawn, task.wait] {
|
||||
var data: u8 = zero;
|
||||
scope sc {
|
||||
let t = {
|
||||
ref part = data; // diagnostic here
|
||||
let t = task.spawn(sc, work, part); // task spawn here
|
||||
match task.join_cancel(move t) {
|
||||
ok(n) => {
|
||||
return n;
|
||||
} cancelled(t) => {
|
||||
move t
|
||||
}
|
||||
}
|
||||
};
|
||||
return task.join(move t);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// expect: reject E4302
|
||||
// phase: 6
|
||||
// spec: docs/spec/04-concurrency-and-atomics.md §37
|
||||
// AIR twin: phase3/reject/cancel_join_twice_keeps_spawn.air
|
||||
module test.twins.cancel_join_twice_keeps_spawn
|
||||
|
||||
fn work(p: ref<u8>) -> u8 effects [] {
|
||||
return *p;
|
||||
}
|
||||
|
||||
fn main() -> u8 effects [task.spawn, task.wait] {
|
||||
var data: u8 = zero;
|
||||
scope sc {
|
||||
let t = {
|
||||
ref part = data; // diagnostic here
|
||||
let t = task.spawn(sc, work, part); // task spawn here
|
||||
match task.join_cancel(move t) {
|
||||
ok(n) => {
|
||||
return n;
|
||||
} cancelled(t) => {
|
||||
match task.join_cancel(move t) {
|
||||
ok(n) => {
|
||||
return n;
|
||||
} cancelled(t) => {
|
||||
move t
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
return task.join(move t);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
// expect: run
|
||||
// schedules: 20
|
||||
// result: 7
|
||||
// phase: 6
|
||||
// spec: docs/spec/04-concurrency-and-atomics.md §34
|
||||
module test.cfg_provenance.cancel_task_block
|
||||
|
||||
fn read(p: ref<u8>) -> u8 effects [] {
|
||||
return *p;
|
||||
}
|
||||
|
||||
fn main() -> u8 effects [task.spawn, task.wait] {
|
||||
var data: u8 = 7u8;
|
||||
ref part = data;
|
||||
scope sc {
|
||||
let t = {
|
||||
let child = task.spawn(sc, read, part);
|
||||
match task.join_cancel(move child) {
|
||||
ok(n) => {
|
||||
return n;
|
||||
} cancelled(back) => {
|
||||
move back
|
||||
}
|
||||
}
|
||||
};
|
||||
return task.join(move t);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
// expect: run
|
||||
// schedules: 20
|
||||
// result: 7
|
||||
// phase: 6
|
||||
// spec: docs/spec/04-concurrency-and-atomics.md §34
|
||||
module test.cfg_provenance.task_block
|
||||
|
||||
fn read(p: ref<u8>) -> u8 effects [] {
|
||||
return *p;
|
||||
}
|
||||
|
||||
fn main() -> u8 effects [task.spawn, task.wait] {
|
||||
var data: u8 = 7u8;
|
||||
ref part = data;
|
||||
scope sc {
|
||||
let t = {
|
||||
let child = task.spawn(sc, read, part);
|
||||
move child
|
||||
};
|
||||
return task.join(move t);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
// expect: run
|
||||
// schedules: 20
|
||||
// result: 7
|
||||
// phase: 6
|
||||
// spec: docs/spec/04-concurrency-and-atomics.md §34
|
||||
module test.cfg_provenance.task_branch
|
||||
|
||||
fn read(p: ref<u8>) -> u8 effects [] {
|
||||
return *p;
|
||||
}
|
||||
|
||||
fn main() -> u8 effects [task.spawn, task.wait] {
|
||||
var data: u8 = 7u8;
|
||||
ref part = data;
|
||||
scope sc {
|
||||
let t = if true {
|
||||
task.spawn(sc, read, part)
|
||||
} else {
|
||||
task.spawn(sc, read, part)
|
||||
};
|
||||
return task.join(move t);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
// expect: reject E4302
|
||||
// phase: 6
|
||||
// spec: docs/spec/04-concurrency-and-atomics.md §34
|
||||
// AIR twin: phase3/reject/tasks_end_lent_borrow.air
|
||||
module test.twins.tasks_end_lent_borrow
|
||||
|
||||
fn work(p: mut<u64>) -> u64 effects [] {
|
||||
return *p;
|
||||
}
|
||||
|
||||
fn main() -> u64 effects [task.spawn] {
|
||||
var data: u64 = zero;
|
||||
scope sc {
|
||||
let t = {
|
||||
mut part = data; // diagnostic here
|
||||
task.spawn(sc, work, part) // task spawn here
|
||||
};
|
||||
return task.join(move t);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user