Fix two toolchain defects found by the M checkpoint
A. Interpreter memory grew with the number of executed steps (one arena, never reclaimed): block and call arguments, frames, frame storage, value copies, place paths, channel buffers and per-step scratch now live in a collectable execution heap. Between instructions, past a threshold, the live state is copied into a fresh heap (sharing preserved) and the old one released. Long-lived state (module, world, authority, task, channel and region tables, the result) stays in the caller's arena. The guarded value of a mutex is a separate cell (no interior pointers). Nothing observable changes: fuel, schedule, PRNG, values, traps and run records are the same. - test: five loop shapes x 100k/1M/4M iterations, measured with the interpreter's own heap counters: live state after a collection does not grow with the iteration count; the heap stays under a fixed bound - conformance --collect-every-step: the second run of every run test collects before every instruction; records must be byte-identical (passes, also with --stress 20) B. A void function whose body ends in an if/if-else/match/block/void call lowered to `ret %` (malformed AIR, reported as E0001): it now lowers to `ret`. Seven fall-through tests (six failed before). Also: files_opened counts reads by relative path and file name; P6A-11 (malformed generated AIR as an internal compiler diagnostic) and Q-023 (ref of a whole array as an argument) recorded.
This commit is contained in:
1 parent
4aa9183e78
commit
222c0c884c
15 files changed
+573
-48
No files matched your search
@@ -0,0 +1,23 @@
|
||||
// A void function ending in a nested block falls through to `ret`.
|
||||
// expect: run
|
||||
// result: 12
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md
|
||||
module demo.block_tail
|
||||
|
||||
fn f(c: mut<u64>) -> void
|
||||
effects []
|
||||
{
|
||||
{
|
||||
let d = 2u64;
|
||||
*c = *c + d;
|
||||
}
|
||||
}
|
||||
|
||||
fn main() -> u64
|
||||
effects []
|
||||
{
|
||||
var c: u64 = 10;
|
||||
f(mut c);
|
||||
c
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
// A void function ending in an `if`/`else` statement falls through to `ret`.
|
||||
// expect: run
|
||||
// result: 21
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md
|
||||
module demo.if_else
|
||||
|
||||
fn f(c: mut<u64>, x: u64) -> void
|
||||
effects []
|
||||
{
|
||||
if x == 2 { *c = *c + 10; } else { *c = *c + 1; }
|
||||
}
|
||||
|
||||
fn main() -> u64
|
||||
effects []
|
||||
{
|
||||
var c: u64 = 10;
|
||||
f(mut c, 2);
|
||||
f(mut c, 3);
|
||||
c
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
// A void function ending in an `if` statement whose branch returns falls through to `ret`.
|
||||
// expect: run
|
||||
// result: 13
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md
|
||||
module demo.if_with_return
|
||||
|
||||
fn f(c: mut<u64>, x: u64) -> void
|
||||
effects []
|
||||
{
|
||||
*c = *c + 1;
|
||||
if x == 2 { return; }
|
||||
}
|
||||
|
||||
fn main() -> u64
|
||||
effects []
|
||||
{
|
||||
var c: u64 = 10;
|
||||
f(mut c, 1);
|
||||
f(mut c, 2);
|
||||
f(mut c, 3);
|
||||
c
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
module demo.if_with_return
|
||||
air 0
|
||||
lang 0.1
|
||||
features [effects, ownership]
|
||||
|
||||
fn @f(%c: mut<u64>, %x: u64) -> void
|
||||
effects []
|
||||
entry:
|
||||
%v_1 = load %c
|
||||
%c_2 = const.u64 1
|
||||
%t_3 = add.checked.u64 %v_1, %c_2
|
||||
store %c, %t_3
|
||||
%c_4 = const.u64 2
|
||||
%cmp_5 = eq.u64 %x, %c_4
|
||||
cbr %cmp_5, @then_6(), @else_7()
|
||||
then_6:
|
||||
ret
|
||||
else_7:
|
||||
br @endif_8()
|
||||
endif_8:
|
||||
ret
|
||||
|
||||
fn @main() -> u64
|
||||
effects []
|
||||
entry:
|
||||
%c_1 = local.alloc u64
|
||||
%c_2 = const.u64 10
|
||||
local.store %c_1, %c_2
|
||||
%c_3 = borrow.mut %c_1
|
||||
%c_4 = const.u64 1
|
||||
call @f(%c_3, %c_4)
|
||||
borrow.end %c_3
|
||||
%c_5 = borrow.mut %c_1
|
||||
%c_6 = const.u64 2
|
||||
call @f(%c_5, %c_6)
|
||||
borrow.end %c_5
|
||||
%c_7 = borrow.mut %c_1
|
||||
%c_8 = const.u64 3
|
||||
call @f(%c_7, %c_8)
|
||||
borrow.end %c_7
|
||||
%c_9 = local.load %c_1
|
||||
ret %c_9
|
||||
@@ -0,0 +1,23 @@
|
||||
// A void function ending in a `loop` left by `break` falls through to `ret`.
|
||||
// expect: run
|
||||
// result: 13
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md
|
||||
module demo.loop_tail
|
||||
|
||||
fn f(c: mut<u64>) -> void
|
||||
effects []
|
||||
{
|
||||
loop {
|
||||
*c = *c + 1;
|
||||
if *c > 12 { break; }
|
||||
}
|
||||
}
|
||||
|
||||
fn main() -> u64
|
||||
effects []
|
||||
{
|
||||
var c: u64 = 10;
|
||||
f(mut c);
|
||||
c
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
// A void function ending in a `match` statement with void arms falls through to `ret`.
|
||||
// expect: run
|
||||
// result: 17
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md
|
||||
module demo.match_tail
|
||||
|
||||
enum Op {
|
||||
Inc,
|
||||
Add(u64),
|
||||
}
|
||||
|
||||
fn f(c: mut<u64>, op: Op) -> void
|
||||
effects []
|
||||
{
|
||||
match op {
|
||||
Op::Inc => { *c = *c + 1; }
|
||||
Op::Add(n) => { *c = *c + n; }
|
||||
}
|
||||
}
|
||||
|
||||
fn main() -> u64
|
||||
effects []
|
||||
{
|
||||
var c: u64 = 10;
|
||||
f(mut c, Op::Inc);
|
||||
f(mut c, Op::Add(6));
|
||||
c
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
// A void function whose tail is a call of a void function falls through to `ret`.
|
||||
// expect: run
|
||||
// result: 11
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md
|
||||
module demo.void_call_tail
|
||||
|
||||
fn g(c: mut<u64>) -> void
|
||||
effects []
|
||||
{
|
||||
*c = *c + 1;
|
||||
}
|
||||
|
||||
fn f(c: mut<u64>) -> void
|
||||
effects []
|
||||
{
|
||||
g(c)
|
||||
}
|
||||
|
||||
fn main() -> u64
|
||||
effects []
|
||||
{
|
||||
var c: u64 = 10;
|
||||
f(mut c);
|
||||
c
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
// A void function ending in a `while` loop falls through to `ret`.
|
||||
// expect: run
|
||||
// result: 15
|
||||
// phase: 6
|
||||
// spec: docs/spec/15-source-language.md
|
||||
module demo.while_tail
|
||||
|
||||
fn f(c: mut<u64>, n: u64) -> void
|
||||
effects []
|
||||
{
|
||||
var i: u64 = 0;
|
||||
while i < n { *c = *c + 1; i = i + 1; }
|
||||
}
|
||||
|
||||
fn main() -> u64
|
||||
effects []
|
||||
{
|
||||
var c: u64 = 10;
|
||||
f(mut c, 5);
|
||||
c
|
||||
}
|
||||
Reference in new issue
Block a user