Phase 1: frame storage, second-class borrows, arrays (P1-3..P1-10)
- air: types local/ref/mut/array/slice/slice_mut, from-returns, multi-result binding, 18 new instructions; feature gating reports E0006 feature_not_declared; borrow-typed block parameters gated by borrow_joins; printer and round-trip tests for all new forms - verifier: second-class and zeroable type rules (E1001); local.alloc only in entry (E5002); frame size accounting (E5101); stages init (E1010), borrow (E2101, E2102, E2105-E2108) and bounds facts (E2103); value types shared between stages - interp: frame cells, places, slices, deep copies between storage and SSA values, T0008 bounds traps - features arrays and ownership supported; implemented_phase = 1 - conformance: 5 accept, 18 reject, 11 run tests for Phase 1, including the file-copy core exit program; 6000 mutants without a crash
This commit is contained in:
1 parent
be9dd0e1ed
commit
1ae6b485d8
50 files changed
+2376
-37
No files matched your search
@@ -0,0 +1,26 @@
|
||||
; Exclusive borrows of two different fields coexist.
|
||||
; expect: accept
|
||||
; phase: 1
|
||||
; spec: docs/spec/08-verifier.md
|
||||
module test.disjoint_fields
|
||||
air 0
|
||||
lang 0.1
|
||||
features [arrays, ownership]
|
||||
|
||||
type @P = struct { a: u8, b: u8 }
|
||||
|
||||
fn @f() -> void
|
||||
effects []
|
||||
entry:
|
||||
%x = local.alloc @P
|
||||
local.zero %x
|
||||
%m = borrow.mut %x
|
||||
%a = borrow.field @P.a, %m
|
||||
%b = borrow.field @P.b, %m
|
||||
%one = const.u8 1
|
||||
store %a, %one
|
||||
store %b, %one
|
||||
borrow.end %a
|
||||
borrow.end %b
|
||||
borrow.end %m
|
||||
ret
|
||||
@@ -0,0 +1,25 @@
|
||||
; A borrow ended in each branch of a cbr: exactly one end executes on every path.
|
||||
; expect: accept
|
||||
; phase: 1
|
||||
; spec: docs/spec/08-verifier.md
|
||||
module test.path_linear_ends
|
||||
air 0
|
||||
lang 0.1
|
||||
features [arrays, ownership]
|
||||
|
||||
fn @f(%c: bool) -> u8
|
||||
effects []
|
||||
entry:
|
||||
%x = local.alloc u8
|
||||
local.zero %x
|
||||
|
||||
%r = borrow.ref %x
|
||||
cbr %c, @a(), @b()
|
||||
a:
|
||||
%v = load %r
|
||||
borrow.end %r
|
||||
ret %v
|
||||
b:
|
||||
borrow.end %r
|
||||
%z = const.u8 0
|
||||
ret %z
|
||||
@@ -0,0 +1,15 @@
|
||||
; A borrow returned with `from` derives from the named parameter.
|
||||
; expect: accept
|
||||
; phase: 1
|
||||
; spec: docs/spec/08-verifier.md
|
||||
module test.return_from_param
|
||||
air 0
|
||||
lang 0.1
|
||||
features [arrays, ownership]
|
||||
|
||||
fn @first(%s: slice<u8>) -> ref<u8> from %s
|
||||
effects []
|
||||
entry:
|
||||
%z = const.usize 0
|
||||
%e = borrow.index %s, %z
|
||||
ret %e
|
||||
@@ -0,0 +1,21 @@
|
||||
; Any number of shared borrows and direct reads coexist.
|
||||
; expect: accept
|
||||
; phase: 1
|
||||
; spec: docs/spec/08-verifier.md
|
||||
module test.shared_borrows
|
||||
air 0
|
||||
lang 0.1
|
||||
features [arrays, ownership]
|
||||
|
||||
fn @f() -> u8
|
||||
effects []
|
||||
entry:
|
||||
%x = local.alloc u8
|
||||
local.zero %x
|
||||
|
||||
%a = borrow.ref %x
|
||||
%b = borrow.ref %x
|
||||
%v = local.load %x
|
||||
borrow.end %a
|
||||
borrow.end %b
|
||||
ret %v
|
||||
@@ -0,0 +1,26 @@
|
||||
; The two halves of slice.split are disjoint, so one can be copied into the other.
|
||||
; expect: accept
|
||||
; phase: 1
|
||||
; spec: docs/spec/08-verifier.md
|
||||
module test.split_halves
|
||||
air 0
|
||||
lang 0.1
|
||||
features [arrays, ownership]
|
||||
|
||||
fn @f() -> void
|
||||
effects []
|
||||
entry:
|
||||
%x = local.alloc array<u8, 8>
|
||||
local.zero %x
|
||||
%m = borrow.mut %x
|
||||
%s = slice.make %m
|
||||
%k = const.usize 4
|
||||
%l, %r = slice.split %s, %k
|
||||
%src = borrow.ref %l
|
||||
slice.copy %r, %src
|
||||
borrow.end %src
|
||||
borrow.end %l
|
||||
borrow.end %r
|
||||
borrow.end %s
|
||||
borrow.end %m
|
||||
ret
|
||||
Reference in new issue
Block a user