Phase 4 exit review; AIR twins for the .aji-only island rejects
New AIR rejects: island_use_after_send (E2001), island_lend_task (E4002), island_destroy_while_borrowed (E2101), arc_content_mutex (E2111), frozen_borrow_mut (E1001). Every Phase 4 invariant now has an AIR and an .aji test. Full suite 392/392, also under --stress 1000 and --collect-every-step; test-extended, hosted smoke, source coverage 61/61.
This commit is contained in:
1 parent
3c5c129078
commit
7cc23338e2
7 files changed
+189
-2
No files matched your search
@@ -0,0 +1,20 @@
|
||||
; An arc holds only ArcSafe values: a mutex is Share but not ArcSafe (E2111).
|
||||
; expect: reject E2111
|
||||
; phase: 4
|
||||
; spec: docs/spec/03-memory-model.md
|
||||
module test.arc_content_mutex
|
||||
air 0
|
||||
lang 0.1
|
||||
features [arc, cancellation, capabilities, effects, heap, islands, ownership, resources, sync, tasks]
|
||||
|
||||
fn @main(%heap: cap<mem.alloc>) -> u64
|
||||
effects [mem.alloc]
|
||||
entry:
|
||||
%v = const.u64 1
|
||||
%m = mutex.make %v
|
||||
arc.new %m, %heap, ok -> @made, err -> @oom
|
||||
made(%a: arc<mutex<u64>>):
|
||||
arc.release %a
|
||||
ret %v
|
||||
oom(%e: alloc_error):
|
||||
trap
|
||||
@@ -0,0 +1,26 @@
|
||||
; A frozen graph never yields a mutable reference: frozen.borrow gives ref<T>, and a store through it is E1001.
|
||||
; expect: reject E1001
|
||||
; phase: 4
|
||||
; spec: docs/spec/03-memory-model.md
|
||||
module test.frozen_borrow_mut
|
||||
air 0
|
||||
lang 0.1
|
||||
features [capabilities, effects, heap, islands, ownership, resources]
|
||||
|
||||
fn @main(%heap: cap<mem.alloc>) -> u64
|
||||
effects [mem.alloc]
|
||||
entry:
|
||||
%v = const.u64 1
|
||||
island.create %v, %heap, ok -> @made, err -> @oom
|
||||
made(%i: island<u64>):
|
||||
%f = island.freeze %i
|
||||
%g = borrow.ref %f
|
||||
%r = frozen.root %g
|
||||
%p = frozen.borrow %g, %r
|
||||
store %p, %v
|
||||
borrow.end %p
|
||||
borrow.end %g
|
||||
frozen.release %f
|
||||
ret %v
|
||||
oom(%e: alloc_error):
|
||||
trap
|
||||
@@ -0,0 +1,25 @@
|
||||
; A borrow of an object inside an island cannot outlive the island: destroying it while the borrow is live is E2101.
|
||||
; expect: reject E2101
|
||||
; phase: 4
|
||||
; spec: docs/spec/03-memory-model.md
|
||||
module test.island_destroy_while_borrowed
|
||||
air 0
|
||||
lang 0.1
|
||||
features [capabilities, effects, heap, islands, ownership, resources]
|
||||
|
||||
fn @main(%heap: cap<mem.alloc>) -> u64
|
||||
effects [mem.alloc]
|
||||
entry:
|
||||
%v = const.u64 1
|
||||
island.create %v, %heap, ok -> @made, err -> @oom
|
||||
made(%i: island<u64>):
|
||||
%g = borrow.ref %i
|
||||
%r = island.root %g
|
||||
%p = island.borrow %g, %r
|
||||
island.destroy %i
|
||||
%x = load %p
|
||||
borrow.end %p
|
||||
borrow.end %g
|
||||
ret %x
|
||||
oom(%e: alloc_error):
|
||||
trap
|
||||
@@ -0,0 +1,34 @@
|
||||
; An island is not Share (its owner may mutate it): lending it to a task is E4002.
|
||||
; expect: reject E4002
|
||||
; phase: 4
|
||||
; spec: docs/spec/04-concurrency-and-atomics.md
|
||||
module test.island_lend_task
|
||||
air 0
|
||||
lang 0.1
|
||||
features [capabilities, effects, heap, islands, ownership, resources, tasks]
|
||||
|
||||
fn @read(%g: ref<island<u64>>) -> u64
|
||||
effects []
|
||||
entry:
|
||||
%r = island.root %g
|
||||
%p = island.borrow %g, %r
|
||||
%v = load %p
|
||||
borrow.end %p
|
||||
ret %v
|
||||
|
||||
fn @main(%heap: cap<mem.alloc>) -> u64
|
||||
effects [mem.alloc, task.spawn]
|
||||
entry:
|
||||
%v = const.u64 1
|
||||
island.create %v, %heap, ok -> @made, err -> @oom
|
||||
made(%i: island<u64>):
|
||||
%g = borrow.ref %i
|
||||
%sc = task.scope.begin
|
||||
%t = task.spawn %sc, @read(%g)
|
||||
%r = task.join %t
|
||||
task.scope.end %sc
|
||||
borrow.end %g
|
||||
island.destroy %i
|
||||
ret %r
|
||||
oom(%e: alloc_error):
|
||||
trap
|
||||
@@ -0,0 +1,43 @@
|
||||
; After an island is sent, the sender holds nothing that reaches it: a later use is E2001.
|
||||
; expect: reject E2001
|
||||
; phase: 4
|
||||
; spec: docs/spec/03-memory-model.md
|
||||
module test.island_use_after_send
|
||||
air 0
|
||||
lang 0.1
|
||||
features [cancellation, capabilities, channels, effects, heap, islands, ownership, resources, tasks]
|
||||
|
||||
fn @main(%heap: cap<mem.alloc>) -> u64
|
||||
effects [mem.alloc, task.wait]
|
||||
entry:
|
||||
%one = const.usize 1
|
||||
channel.make island<u64>, %one, %heap, ok -> @made, err -> @oom
|
||||
made(%tx: sender<island<u64>>, %rx: receiver<island<u64>>):
|
||||
%v = const.u64 1
|
||||
island.create %v, %heap, ok -> @built, err -> @oom2
|
||||
built(%i: island<u64>):
|
||||
%txb = borrow.mut %tx
|
||||
channel.send %txb, %i, ok -> @sent, closed -> @fail, cancelled -> @fail
|
||||
sent:
|
||||
borrow.end %txb
|
||||
%g = borrow.ref %i
|
||||
borrow.end %g
|
||||
channel.close_sender %tx
|
||||
%rxb = borrow.mut %rx
|
||||
channel.recv %rxb, ok -> @got, closed -> @none, cancelled -> @none
|
||||
got(%back: island<u64>):
|
||||
borrow.end %rxb
|
||||
island.destroy %back
|
||||
channel.close_receiver %rx, ok -> @done, pending -> @pending
|
||||
none:
|
||||
trap
|
||||
done:
|
||||
ret %v
|
||||
pending(%r: receiver<island<u64>>):
|
||||
trap
|
||||
fail(%x: island<u64>):
|
||||
trap
|
||||
oom(%e: alloc_error):
|
||||
trap
|
||||
oom2(%e2: alloc_error):
|
||||
trap
|
||||
Reference in new issue
Block a user