diff options
Diffstat (limited to 'chapter33/docs')
| -rw-r--r-- | chapter33/docs/AllocationSurvey.java | 138 | ||||
| -rw-r--r-- | chapter33/docs/ArrayDeleteSurvey.java | 107 | ||||
| -rw-r--r-- | chapter33/docs/allocation-survey-functions.tsv | 262 | ||||
| -rw-r--r-- | chapter33/docs/allocation-survey.md | 256 | ||||
| -rw-r--r-- | chapter33/docs/array-delete-survey.md | 141 | ||||
| -rw-r--r-- | chapter33/docs/examples/Breakout.smp | 8 | ||||
| -rw-r--r-- | chapter33/docs/growing-arrays-survey.md | 230 | ||||
| -rw-r--r-- | chapter33/docs/growing-arrays.md (renamed from chapter33/docs/growing-array-rewrites.md) | 57 | ||||
| -rw-r--r-- | chapter33/docs/memory-management.md | 368 | ||||
| -rw-r--r-- | chapter33/docs/ownership-analysis-architecture-review.md | 79 |
10 files changed, 407 insertions, 1239 deletions
diff --git a/chapter33/docs/AllocationSurvey.java b/chapter33/docs/AllocationSurvey.java deleted file mode 100644 index 108cbfb3..00000000 --- a/chapter33/docs/AllocationSurvey.java +++ /dev/null @@ -1,138 +0,0 @@ -import com.seaofnodes.simple.codegen.*; -import com.seaofnodes.simple.node.*; -import com.seaofnodes.simple.type.*; -import com.seaofnodes.simple.util.Ary; -import java.nio.file.*; -import java.lang.reflect.Field; -import java.util.*; - -// Standalone survey, not a test or a compiler option. Run from chapter33. -public class AllocationSurvey { - static Object field(Object object, String name) throws Exception { - Field f=object.getClass().getDeclaredField(name); - f.setAccessible(true); - return f.get(object); - } - static String clean(Object s) { return s==null ? "" : s.toString().replace('\t',' ').replace('\n',' '); } - static String category(String reason) { - if( reason==null ) return "supported"; - if( reason.contains("opaque body") ) return "opaque body"; - if( reason.contains("opaque or indirect") ) return "indirect call"; - if( reason.contains("recursive call") ) return "recursion"; - if( reason.contains("raw address") ) return "raw address"; - if( reason.contains("variable-size") ) return "variable size"; - if( reason.contains("across its backedge") ) return "loop retention"; - if( reason.contains("cyclic field-path") ) return "field paths"; - if( reason.contains("reference origin") ) return "reference origin"; - if( reason.contains("native result storage") ) return "native result"; - return "other"; - } - static String probe(String name) { - return switch(name) { - case "LocalArray" -> """ - val work_noInline={ u32 n -> - val xs=new i64[n]; - for( u32 i=0; i<n; i++ ) xs[i]=i; - return n ? xs[n-1] : 0; - }; - u32 len=arg; - return work_noInline(len); - """; - case "ReturnedArray" -> """ - val make_noInline={ u32 n -> new i64[n]; }; - u32 len=arg; - return make_noInline(len)#; - """; - case "OverwrittenSlot" -> """ - struct Thing { i64 !x; new Thing={i64 n -> x=n;}; }; - struct Holder { Thing? !c=null; }; - val work_noInline={i64 n -> - val h=new Holder; - while(n>0) { h.c=new Thing(n); n--; } - return h.c ? h.c.x : 0; - }; - return work_noInline(arg); - """; - case "ReusedObject" -> """ - struct Thing { i64 !x; new Thing={i64 n -> x=n;}; }; - val read_noInline={Thing t -> t.x;}; - val work_noInline={i64 n -> - val t=new Thing(0); - i64 sum=0; - while(n>0) { t.x=n; sum+=read_noInline(t); n--; } - return sum; - }; - return work_noInline(arg); - """; - default -> throw new IllegalArgumentException(name); - }; - } - @SuppressWarnings("unchecked") - public static void main(String[] args) throws Exception { - String name=args[0], mode=args.length>1 ? args[1] : "source"; - Path out=Path.of("build/allocation-survey",name+"-"+mode); - Files.createDirectories(out); - for( String file : new String[]{"error.txt","dump.txt","functions.tsv","sites.tsv","allocations.tsv","calls.tsv"} ) - Files.deleteIfExists(out.resolve(file)); - String src=mode.equals("probe") ? probe(name) : name.equals("sys") ? null : - name.equals("RuntimeArgs") ? Files.readString(Path.of("src/main/smp/sys/rt/simple_args.smp")) : - Files.readString(Path.of("docs/examples",name+".smp")); - if( src!=null && !name.equals("RuntimeArgs") && mode.equals("source") ) src="val _survey_sys=sys;\n"+src; - String root=mode.equals("source") ? "src/main/smp" : "docs/examples"; - Ary<String> libs=mode.equals("object") ? new Ary<>(new String[]{"build/release/x86_64_v2_win64"}) : null; - CodeGen code=new CodeGen(root,out.resolve("objects").toString(),libs,name,src,456,true,TypeInteger.BOT); - long start=System.nanoTime(); - try { code.driver(CodeGen.Phase.TypeCheck); } - catch(Throwable t) { - StringBuilder error=new StringBuilder(t.toString()+"\nphase="+code._phase+"\n"); - if( t instanceof com.seaofnodes.simple.parser.Parser.ParseException p ) error.append(p.diagnostic()).append('\n'); - for( StackTraceElement frame : t.getStackTrace() ) error.append(frame).append('\n'); - Files.writeString(out.resolve("error.txt"),error); - System.out.println(name+" "+mode+" ERROR "+t); - return; - } - Allocation.Summary[] summaries=(Allocation.Summary[])field(code._allocation,"_summaries"); - Files.writeString(out.resolve("dump.txt"),code._allocation.toString()); - StringBuilder rows=new StringBuilder("program\tmode\tunit\tfunction\tid\tstatus\tcategory\troot_function\troot_id\troot_unit\tnew_user\tnew_class\tvariable\tplaced_user\tplaced_class\tloops\treason\n"); - StringBuilder sites=new StringBuilder("program\tmode\tunit\tfunction\tsite\ttype\tbytes\tdestination\n"); - StringBuilder nodes=new StringBuilder("program\tmode\tunit\tfunction\tnode\tsize\ttype\n"); - StringBuilder calls=new StringBuilder("program\tmode\tunit\tfunction\tnode\ttarget\tsignature\n"); - int total=0,pass=0,allocated=0; - for( Allocation.Summary sum : summaries ) { - if( sum==null ) continue; - FunNode fun=sum._fun; - String unit=fun._compunit==null ? "" : fun._compunit._cname; - Allocation.Summary cause=sum; - HashSet<Allocation.Summary> seen=new HashSet<>(); - while( cause._reject!=null && cause._reject.startsWith("call #") && seen.add(cause) ) { - int id=Integer.parseInt(cause._reject.substring(6,cause._reject.indexOf(' ',6))); - Allocation.Summary next=null; - for( CallNode call : (ArrayList<CallNode>)field(cause,"_calls") ) - if( call._nid==id && call.fptr()._type instanceof TypeFunPtr fp && fp.isConstant() ) next=summaries[fp.fidx()]; - if( next==null ) break; - cause=next; - } - int local=0,clz=0,variable=0,placed=0,placedClz=0; - for( CallNode call : (ArrayList<CallNode>)field(sum,"_calls") ) - calls.append(name).append('\t').append(mode).append('\t').append(clean(unit)).append('\t').append(clean(fun._name)).append('\t').append(call._nid).append('\t').append(clean(call.name())).append('\t').append(clean(call.fptr()._type)).append('\n'); - for( Node n : (ArrayList<Node>)field(sum,"_nodes") ) if( n instanceof NewNode a ) { - if( TypeStruct.startsClzPrefix(a._ts._name) ) clz++; else local++; - if( !(a.size()._type instanceof TypeInteger sz) || !sz.isConstant() ) variable++; - nodes.append(name).append('\t').append(mode).append('\t').append(clean(unit)).append('\t').append(clean(fun._name)).append('\t').append(a._nid).append('\t').append(clean(a.size()._type)).append('\t').append(clean(a._ts._name)).append('\n'); - } - if( sum.supported() ) for( Allocation.Site site : sum._sites ) if( site._allocation!=null ) { - if( TypeStruct.startsClzPrefix(site._allocation._ts._name) ) placedClz++; else placed++; - sites.append(name).append('\t').append(mode).append('\t').append(clean(unit)).append('\t').append(clean(fun._name)).append('\t').append(clean(site._name)).append('\t').append(clean(site._allocation._ts._name)).append('\t').append(site._bytes).append('\t').append(clean(site.destination())).append('\n'); - } - String status=sum.supported() ? "pass" : sum._reject.startsWith("call #") ? "blocked" : "direct"; - rows.append(name).append('\t').append(mode).append('\t').append(clean(unit)).append('\t').append(clean(fun._name)).append('\t').append(fun.sig().fidx()).append('\t').append(status).append('\t').append(category(cause._reject)).append('\t').append(clean(cause._fun._name)).append('\t').append(cause._fun.sig().fidx()).append('\t').append(clean(cause._fun._compunit==null ? null : cause._fun._compunit._cname)).append('\t').append(local).append('\t').append(clz).append('\t').append(variable).append('\t').append(placed).append('\t').append(placedClz).append('\t').append(((IdentityHashMap<?,?>)field(sum,"_loops")).size()).append('\t').append(clean(sum._reject)).append('\n'); - total++; - if( sum.supported() ) { pass++; if( placed>0 ) allocated++; } - } - Files.writeString(out.resolve("functions.tsv"),rows); - Files.writeString(out.resolve("sites.tsv"),sites); - Files.writeString(out.resolve("allocations.tsv"),nodes); - Files.writeString(out.resolve("calls.tsv"),calls); - System.out.println(name+" "+mode+": "+pass+"/"+total+" pass, "+allocated+" with user allocations; "+((System.nanoTime()-start)/1000000)+" ms"); - } -} diff --git a/chapter33/docs/ArrayDeleteSurvey.java b/chapter33/docs/ArrayDeleteSurvey.java deleted file mode 100644 index 7e549048..00000000 --- a/chapter33/docs/ArrayDeleteSurvey.java +++ /dev/null @@ -1,107 +0,0 @@ -import com.seaofnodes.simple.codegen.*; -import com.seaofnodes.simple.parser.Parser; -import com.seaofnodes.simple.type.TypeInteger; -import com.seaofnodes.simple.util.SB; -import java.nio.file.*; -import java.util.ArrayDeque; - -/** Compile-only source migrations. Originals are never changed. Run from chapter33. */ -public class ArrayDeleteSurvey { - private static String change(String src, String from, String to) { - if( !src.contains(from) ) throw new IllegalArgumentException("Survey source changed: "+from); - return src.replace(from,to); - } - - private static String migrate(String name, String src) { - switch(name) { - case "aryu8": - src=change(src,"u8[] !buf;","u8[^] !buf;"); - src=change(src,"new u8[1]","new u8[^1]"); - src=change(src,"u8[] !buf2 = new u8[newlen];","val old = buf;\n u8[^] !buf2 = new u8[^newlen];"); - return change(src,"buf = buf2;","buf = buf2;\n old.del();"); - case "aryi64": - src=change(src,"i64[] !buf;","i64[^] !buf;"); - src=change(src,"i64[] b ->","i64[^] b ->"); - src=change(src,"new i64[","new i64[^"); - src=change(src,"i64[] !buf2 =","val old = buf;\n i64[^] !buf2 ="); - return change(src,"buf = buf2;","buf = buf2;\n old.del();"); - case "bitset": - src=change(src,"i64[] !_bits;","i64[^] !_bits;"); - src=change(src,"new i64[","new i64[^"); - src=change(src,"var bits =","val old = _bits;\n var bits ="); - return change(src,"_bits = bits;","_bits = bits;\n old.del();"); - case "Timers": - src=change(src,"u32[]","u32[^]"); - src=change(src,"i64[]","i64[^]"); - src=change(src,"new u32[","new u32[^"); - src=change(src,"new i64[","new i64[^"); - src=change(src,"val ids =","val oldIds = _ids, oldDue = _due_ms, oldPeriod = _period_ms;\n val ids ="); - return change(src,"_period_ms = periods_ms;","_period_ms = periods_ms;\n oldIds.del(); oldDue.del(); oldPeriod.del();"); - case "Canvas": - src=change(src,"u32[] !pixels;","u32[^] !pixels;"); - src=change(src,"new u32[","new u32[^"); - return change(src,"pixels = new u32[^capacity];", - "val old = pixels;\n pixels = new u32[^capacity];\n old.del();"); - default: throw new IllegalArgumentException(name); - } - } - - private static void copyTree(Path src, Path dst) throws Exception { - ArrayDeque<Path> work=new ArrayDeque<>(); - work.push(src); - while( !work.isEmpty() ) { - Path path=work.pop(), target=dst.resolve(src.relativize(path)); - if( Files.isDirectory(path) ) { - Files.createDirectories(target); - try( DirectoryStream<Path> children=Files.newDirectoryStream(path) ) { - for( Path child : children ) work.push(child); - } - } else Files.copy(path,target); - } - } - - private static String clean(String s) { return s.replace('\t',' ').replace('\n',' ').replace('\r',' '); } - - public static void main(String[] args) throws Exception { - Path build=Path.of("build/array-delete-survey"); - Files.createDirectories(build); - Path run=Files.createTempDirectory(build,"run-"); - SB report=new SB().p("case\tfunction\tstatus\tdetail\n"); - String[] names={"aryu8","aryi64","bitset","Timers","Canvas"}; - String[] files={"sys/aryu8.smp","sys/aryi64.smp","sys/adt/bitset.smp","sys/time/Timers.smp","sys/draw/Canvas.smp"}; - for( int i=0; i<names.length; i++ ) { - String name=names[i]; - Path out=run.resolve(name), src=out.resolve("src"); - copyTree(Path.of("src/main/smp"),src); - Path file=src.resolve(files[i]); - Files.writeString(file,migrate(name,Files.readString(file))); - CodeGen code=new CodeGen(src.toString(),out.resolve("objects").toString(),null,"sys",null,456,true,TypeInteger.BOT); - try { - code.driver(CodeGen.Phase.Allocation); - if( Boolean.getBoolean("simple.delete.graph") ) { - Files.writeString(out.resolve("graph.txt"),code.toString()); - Files.writeString(out.resolve("allocation.txt"),code._allocation.toString()); - } - for( ArrayDelete deletion : code._allocation._deletes ) { - String status=deletion._reject!=null ? "REJECT" : deletion._unique!=null ? "NEEDS UNIQUE ENTRY" : "PASS"; - report.p(name).p('\t').p(deletion._call.fun()._name).p('\t').p(status).p('\t').p(clean(deletion.toString())).p('\n'); - } - if( code._allocation._deletes.isEmpty() ) throw new IllegalStateException("No deletion sites found"); - code.driver(CodeGen.Phase.TypeCheck); - System.out.println(name+": TypeCheck PASS"); - } catch( Parser.ParseException e ) { - Files.writeString(out.resolve("rejection.txt"),e.diagnostic()); - report.p(name).p("\t<TypeCheck>\tREJECT\t").p(clean(e.getMessage())).p('\n'); - System.out.println(name+": REJECT at "+code._phase+": "+e.getMessage()); - } catch( Throwable e ) { - SB stack=new SB().p(e.toString()).p('\n'); - for( StackTraceElement frame : e.getStackTrace() ) stack.p(frame.toString()).p('\n'); - Files.writeString(out.resolve("crash.txt"),stack.toString()); - report.p(name).p("\t<compiler>\tCRASH\t").p(clean(e.toString())).p('\n'); - System.out.println(name+": CRASH at "+code._phase+": "+e); - } - } - Files.writeString(run.resolve("results.tsv"),report.toString()); - System.out.println("Results: "+run.resolve("results.tsv")); - } -} diff --git a/chapter33/docs/allocation-survey-functions.tsv b/chapter33/docs/allocation-survey-functions.tsv deleted file mode 100644 index 80f22547..00000000 --- a/chapter33/docs/allocation-survey-functions.tsv +++ /dev/null @@ -1,262 +0,0 @@ -"program" "mode" "unit" "function" "id" "status" "category" "root_function" "root_id" "root_unit" "new_user" "new_class" "variable" "placed_user" "placed_class" "loops" "reason" -"sys" "source" "sys" "class:sys.<clinit>" "2" "pass" "supported" "class:sys.<clinit>" "2" "sys" "0" "0" "0" "0" "0" "0" "" -"sys" "source" "sys.adt" "class:sys.adt.<clinit>" "3" "pass" "supported" "class:sys.adt.<clinit>" "3" "sys.adt" "0" "0" "0" "0" "0" "0" "" -"sys" "source" "sys.audio" "class:sys.audio.<clinit>" "4" "pass" "supported" "class:sys.audio.<clinit>" "4" "sys.audio" "0" "0" "0" "0" "0" "0" "" -"sys" "source" "sys.audio" "sys.audio.open" "11" "direct" "indirect call" "sys.audio.open" "11" "sys.audio" "0" "0" "0" "0" "0" "0" "opaque or indirect call #257" -"sys" "source" "sys.audio" "sys.audio.load" "12" "direct" "raw address" "sys.audio.load" "12" "sys.audio" "0" "0" "0" "0" "0" "0" "raw address escapes lifetime tracking #274" -"sys" "source" "sys.audio" "sys.audio.play" "13" "direct" "indirect call" "sys.audio.play" "13" "sys.audio" "0" "0" "0" "0" "0" "0" "opaque or indirect call #321" -"sys" "source" "sys.audio" "sys.audio.boop" "14" "direct" "indirect call" "sys.audio.boop" "14" "sys.audio" "0" "0" "0" "0" "0" "0" "opaque or indirect call #361" -"sys" "source" "sys.audio" "sys.audio.win" "15" "direct" "indirect call" "sys.audio.win" "15" "sys.audio" "0" "0" "0" "0" "0" "0" "opaque or indirect call #401" -"sys" "source" "sys.audio" "sys.audio.lose" "16" "direct" "indirect call" "sys.audio.lose" "16" "sys.audio" "0" "0" "0" "0" "0" "0" "opaque or indirect call #441" -"sys" "source" "sys.audio" "sys.audio.stop" "17" "direct" "indirect call" "sys.audio.stop" "17" "sys.audio" "0" "0" "0" "0" "0" "0" "opaque or indirect call #468" -"sys" "source" "sys.audio" "sys.audio.playing" "18" "direct" "indirect call" "sys.audio.playing" "18" "sys.audio" "0" "0" "0" "0" "0" "0" "opaque or indirect call #495" -"sys" "source" "sys.audio" "sys.audio.close" "19" "direct" "indirect call" "sys.audio.close" "19" "sys.audio" "0" "0" "0" "0" "0" "0" "opaque or indirect call #522" -"sys" "source" "sys.ary" "class:sys.ary.<clinit>" "20" "pass" "supported" "class:sys.ary.<clinit>" "20" "sys.ary" "0" "0" "0" "0" "0" "0" "" -"sys" "source" "sys.ary" "sys.ary.capacity" "21" "pass" "supported" "sys.ary.capacity" "21" "sys.ary" "0" "0" "0" "0" "0" "1" "" -"sys" "source" "sys.ary" "sys.ary.copy" "22" "pass" "supported" "sys.ary.copy" "22" "sys.ary" "0" "0" "0" "0" "0" "1" "" -"sys" "source" "sys.ary" "sys.ary.cmp" "23" "pass" "supported" "sys.ary.cmp" "23" "sys.ary" "0" "0" "0" "0" "0" "1" "" -"sys" "source" "sys.aryi64" "class:sys.aryi64.<clinit>" "24" "pass" "supported" "class:sys.aryi64.<clinit>" "24" "sys.aryi64" "0" "0" "0" "0" "0" "0" "" -"sys" "source" "sys.aryi64" "sys.aryi64.<init>" "25" "pass" "supported" "sys.aryi64.<init>" "25" "sys.aryi64" "0" "0" "0" "0" "0" "0" "" -"sys" "source" "sys.aryi64" "sys.aryi64._grow" "26" "direct" "indirect call" "sys.aryi64._grow" "26" "sys.aryi64" "1" "0" "1" "0" "0" "1" "opaque or indirect call #1392" -"sys" "source" "sys.aryi64" "sys.aryi64.add" "27" "blocked" "indirect call" "sys.aryi64._grow" "26" "sys.aryi64" "0" "0" "0" "0" "0" "0" "call #1495 -> sys.aryi64._grow: opaque or indirect call #1392" -"sys" "source" "sys.aryi64" "sys.aryi64.get" "28" "pass" "supported" "sys.aryi64.get" "28" "sys.aryi64" "0" "0" "0" "0" "0" "0" "" -"sys" "source" "sys.aryi64" "sys.aryi64.str" "29" "blocked" "indirect call" "sys.aryu8._grow" "37" "sys.aryu8" "2" "0" "0" "0" "0" "1" "call #27695 -> sys.aryu8._grow: opaque or indirect call #2466" -"sys" "source" "sys.aryi64" "sys.aryi64.swap" "30" "pass" "supported" "sys.aryi64.swap" "30" "sys.aryi64" "0" "0" "0" "0" "0" "0" "" -"sys" "source" "sys.aryi64" "sys.aryi64.<new>" "32" "pass" "supported" "sys.aryi64.<new>" "32" "sys.aryi64" "1" "0" "0" "1" "0" "0" "" -"sys" "source" "sys.aryi64" "sys.aryi64.parseAryI64" "33" "blocked" "indirect call" "sys.aryi64._grow" "26" "sys.aryi64" "3" "0" "0" "0" "0" "6" "call #27372 -> sys.aryi64._grow: opaque or indirect call #1392" -"sys" "source" "sys.aryi64" "sys.aryi64.copy" "34" "pass" "supported" "sys.aryi64.copy" "34" "sys.aryi64" "0" "0" "0" "0" "0" "1" "" -"sys" "source" "sys.aryu8" "class:sys.aryu8.<clinit>" "35" "pass" "supported" "class:sys.aryu8.<clinit>" "35" "sys.aryu8" "0" "0" "0" "0" "0" "0" "" -"sys" "source" "sys.aryu8" "sys.aryu8.<init>" "36" "pass" "supported" "sys.aryu8.<init>" "36" "sys.aryu8" "0" "0" "0" "0" "0" "0" "" -"sys" "source" "sys.aryu8" "sys.aryu8._grow" "37" "direct" "indirect call" "sys.aryu8._grow" "37" "sys.aryu8" "1" "0" "1" "0" "0" "0" "opaque or indirect call #2466" -"sys" "source" "sys.aryu8" "sys.aryu8.clear" "38" "pass" "supported" "sys.aryu8.clear" "38" "sys.aryu8" "0" "0" "0" "0" "0" "0" "" -"sys" "source" "sys.aryu8" "sys.aryu8.add" "39" "blocked" "indirect call" "sys.aryu8._grow" "37" "sys.aryu8" "0" "0" "0" "0" "0" "0" "call #2559 -> sys.aryu8._grow: opaque or indirect call #2466" -"sys" "source" "sys.aryu8" "sys.aryu8.addAry" "40" "blocked" "indirect call" "sys.aryu8._grow" "37" "sys.aryu8" "0" "0" "0" "0" "0" "0" "call #2607 -> sys.aryu8._grow: opaque or indirect call #2466" -"sys" "source" "sys.aryu8" "sys.aryu8.undo" "41" "pass" "supported" "sys.aryu8.undo" "41" "sys.aryu8" "0" "0" "0" "0" "0" "0" "" -"sys" "source" "sys.aryu8" "sys.aryu8.num" "42" "blocked" "indirect call" "sys.aryu8._grow" "37" "sys.aryu8" "0" "0" "0" "0" "0" "0" "call #2705 -> sys.text.integer: call #5950 -> sys.text.string: call #23308 -> sys.aryu8._grow: opaque or indirect call #2466" -"sys" "source" "sys.aryu8" "sys.aryu8.write" "43" "blocked" "raw address" "sys.io.writeOff" "68" "sys.io" "0" "0" "0" "0" "0" "0" "call #2738 -> sys.io.writeOff: raw address escapes lifetime tracking #4102" -"sys" "source" "sys.aryu8" "sys.aryu8.<new>" "45" "pass" "supported" "sys.aryu8.<new>" "45" "sys.aryu8" "2" "0" "0" "2" "0" "0" "" -"sys" "source" "sys.aryu8" "sys.aryu8.atoi" "46" "pass" "supported" "sys.aryu8.atoi" "46" "sys.aryu8" "0" "0" "0" "0" "0" "2" "" -"sys" "source" "sys.aryu8" "sys.aryu8.str0" "47" "direct" "indirect call" "sys.aryu8.str0" "47" "sys.aryu8" "1" "0" "1" "0" "0" "1" "opaque or indirect call #3085" -"sys" "source" "sys.char" "class:sys.char.<clinit>" "48" "pass" "supported" "class:sys.char.<clinit>" "48" "sys.char" "0" "0" "0" "0" "0" "0" "" -"sys" "source" "sys.char" "sys.char.toupper" "49" "pass" "supported" "sys.char.toupper" "49" "sys.char" "0" "0" "0" "0" "0" "0" "" -"sys" "source" "sys.char" "sys.char.tolower" "50" "pass" "supported" "sys.char.tolower" "50" "sys.char" "0" "0" "0" "0" "0" "0" "" -"sys" "source" "sys.integer" "class:sys.integer.<clinit>" "51" "pass" "supported" "class:sys.integer.<clinit>" "51" "sys.integer" "0" "0" "0" "0" "0" "0" "" -"sys" "source" "sys.math" "class:sys.math.<clinit>" "52" "pass" "supported" "class:sys.math.<clinit>" "52" "sys.math" "0" "0" "0" "0" "0" "0" "" -"sys" "source" "sys.math" "sys.math.max" "60" "pass" "supported" "sys.math.max" "60" "sys.math" "0" "0" "0" "0" "0" "0" "" -"sys" "source" "sys.math" "sys.math.min" "61" "pass" "supported" "sys.math.min" "61" "sys.math" "0" "0" "0" "0" "0" "0" "" -"sys" "source" "sys.io" "class:sys.io.<clinit>" "62" "pass" "supported" "class:sys.io.<clinit>" "62" "sys.io" "0" "0" "0" "0" "0" "0" "" -"sys" "source" "sys.io" "sys.io.p" "63" "blocked" "raw address" "sys.io.writeOff" "68" "sys.io" "0" "0" "0" "0" "0" "0" "call #24576 -> sys.io.writeOff: raw address escapes lifetime tracking #4102" -"sys" "source" "sys.io" "sys.io.p_noInline" "64" "blocked" "raw address" "sys.io.writeOff" "68" "sys.io" "0" "0" "0" "0" "0" "0" "call #23093 -> sys.io.writeOff: raw address escapes lifetime tracking #4102" -"sys" "source" "sys.io" "sys.io.err" "65" "blocked" "raw address" "sys.io.writeOff" "68" "sys.io" "0" "0" "0" "0" "0" "0" "call #27466 -> sys.io.writeOff: raw address escapes lifetime tracking #4102" -"sys" "source" "sys.io" "sys.io.read" "66" "direct" "raw address" "sys.io.read" "66" "sys.io" "4" "0" "1" "0" "0" "1" "raw address escapes lifetime tracking #3695" -"sys" "source" "sys.io" "sys.io.write" "67" "blocked" "raw address" "sys.io.writeOff" "68" "sys.io" "0" "0" "0" "0" "0" "0" "call #4008 -> sys.io.writeOff: raw address escapes lifetime tracking #4102" -"sys" "source" "sys.io" "sys.io.writeOff" "68" "direct" "raw address" "sys.io.writeOff" "68" "sys.io" "0" "0" "0" "0" "0" "1" "raw address escapes lifetime tracking #4102" -"sys" "source" "sys.io" "sys.io.stdin" "69" "blocked" "raw address" "sys.io.read" "66" "sys.io" "0" "0" "0" "0" "0" "0" "call #4301 -> sys.io.read: raw address escapes lifetime tracking #3695" -"sys" "source" "sys.io" "sys.io.getch" "70" "direct" "indirect call" "sys.io.getch" "70" "sys.io" "0" "0" "0" "0" "0" "0" "opaque or indirect call #4326" -"sys" "source" "sys.io" "sys.io.create" "71" "direct" "raw address" "sys.io.create" "71" "sys.io" "0" "0" "0" "0" "0" "0" "raw address escapes lifetime tracking #26751" -"sys" "source" "sys.io" "sys.io.open" "72" "direct" "raw address" "sys.io.open" "72" "sys.io" "0" "0" "0" "0" "0" "0" "raw address escapes lifetime tracking #25971" -"sys" "source" "sys.io" "sys.io.close" "73" "direct" "indirect call" "sys.io.close" "73" "sys.io" "0" "0" "0" "0" "0" "0" "opaque or indirect call #4495" -"sys" "source" "sys.io" "sys.io.remove" "74" "direct" "raw address" "sys.io.remove" "74" "sys.io" "0" "0" "0" "0" "0" "0" "raw address escapes lifetime tracking #26389" -"sys" "source" "sys.gfx" "class:sys.gfx.<clinit>" "75" "pass" "supported" "class:sys.gfx.<clinit>" "75" "sys.gfx" "0" "0" "0" "0" "0" "0" "" -"sys" "source" "sys.gfx" "sys.gfx.open" "88" "direct" "raw address" "sys.gfx.open" "88" "sys.gfx" "0" "0" "0" "0" "0" "0" "raw address escapes lifetime tracking #4719" -"sys" "source" "sys.gfx" "sys.gfx.present" "89" "direct" "raw address" "sys.gfx.present" "89" "sys.gfx" "0" "0" "0" "0" "0" "0" "raw address escapes lifetime tracking #4751" -"sys" "source" "sys.gfx" "sys.gfx.width" "90" "direct" "indirect call" "sys.gfx.width" "90" "sys.gfx" "0" "0" "0" "0" "0" "0" "opaque or indirect call #4796" -"sys" "source" "sys.gfx" "sys.gfx.height" "91" "direct" "indirect call" "sys.gfx.height" "91" "sys.gfx" "0" "0" "0" "0" "0" "0" "opaque or indirect call #4823" -"sys" "source" "sys.gfx" "sys.gfx.presentSize" "92" "direct" "raw address" "sys.gfx.presentSize" "92" "sys.gfx" "0" "0" "0" "0" "0" "0" "raw address escapes lifetime tracking #4990" -"sys" "source" "sys.gfx" "sys.gfx.poll" "93" "direct" "indirect call" "sys.gfx.poll" "93" "sys.gfx" "0" "0" "0" "0" "0" "0" "opaque or indirect call #5042" -"sys" "source" "sys.gfx" "sys.gfx.mouseX" "94" "direct" "indirect call" "sys.gfx.mouseX" "94" "sys.gfx" "0" "0" "0" "0" "0" "0" "opaque or indirect call #5069" -"sys" "source" "sys.gfx" "sys.gfx.mouseY" "95" "direct" "indirect call" "sys.gfx.mouseY" "95" "sys.gfx" "0" "0" "0" "0" "0" "0" "opaque or indirect call #5096" -"sys" "source" "sys.gfx" "sys.gfx.button" "96" "direct" "indirect call" "sys.gfx.button" "96" "sys.gfx" "0" "0" "0" "0" "0" "0" "opaque or indirect call #5125" -"sys" "source" "sys.gfx" "sys.gfx.key" "97" "direct" "indirect call" "sys.gfx.key" "97" "sys.gfx" "0" "0" "0" "0" "0" "0" "opaque or indirect call #5154" -"sys" "source" "sys.gfx" "sys.gfx.close" "98" "direct" "indirect call" "sys.gfx.close" "98" "sys.gfx" "0" "0" "0" "0" "0" "0" "opaque or indirect call #5181" -"sys" "source" "sys.gfx" "sys.gfx.wait" "99" "direct" "indirect call" "sys.gfx.wait" "99" "sys.gfx" "0" "0" "0" "0" "0" "0" "opaque or indirect call #5210" -"sys" "source" "sys.draw" "class:sys.draw.<clinit>" "100" "pass" "supported" "class:sys.draw.<clinit>" "100" "sys.draw" "0" "0" "0" "0" "0" "0" "" -"sys" "source" "sys.draw" "sys.draw.rgb" "101" "pass" "supported" "sys.draw.rgb" "101" "sys.draw" "0" "0" "0" "0" "0" "0" "" -"sys" "source" "sys.text" "class:sys.text.<clinit>" "102" "pass" "supported" "class:sys.text.<clinit>" "102" "sys.text" "0" "0" "0" "0" "0" "0" "" -"sys" "source" "sys.text" "sys.text.begin" "103" "pass" "supported" "sys.text.begin" "103" "sys.text" "2" "0" "0" "2" "0" "0" "" -"sys" "source" "sys.text" "sys.text.end" "104" "direct" "variable size" "sys.text.end" "104" "sys.text" "1" "0" "1" "0" "0" "1" "variable-size allocation #5612" -"sys" "source" "sys.text" "sys.text._pad" "105" "blocked" "indirect call" "sys.aryu8._grow" "37" "sys.aryu8" "0" "0" "0" "0" "0" "1" "call #22342 -> sys.aryu8._grow: opaque or indirect call #2466" -"sys" "source" "sys.text" "sys.text.string" "106" "blocked" "indirect call" "sys.aryu8._grow" "37" "sys.aryu8" "0" "0" "0" "0" "0" "3" "call #23308 -> sys.aryu8._grow: opaque or indirect call #2466" -"sys" "source" "sys.text" "sys.text.integer" "107" "blocked" "indirect call" "sys.aryu8._grow" "37" "sys.aryu8" "1" "0" "0" "0" "0" "8" "call #5950 -> sys.text.string: call #23308 -> sys.aryu8._grow: opaque or indirect call #2466" -"sys" "source" "sys.text" "sys.text.floating" "109" "blocked" "indirect call" "sys.aryu8._grow" "37" "sys.aryu8" "0" "0" "0" "0" "0" "0" "call #23862 -> sys.aryu8._grow: opaque or indirect call #2466" -"sys" "source" "sys.text" "sys.text.int" "110" "blocked" "indirect call" "sys.aryu8._grow" "37" "sys.aryu8" "3" "0" "1" "0" "0" "1" "call #7146 -> sys.text.integer: call #5950 -> sys.text.string: call #23308 -> sys.aryu8._grow: opaque or indirect call #2466" -"sys" "source" "sys.text" "sys.text.flt" "111" "direct" "indirect call" "sys.text.flt" "111" "sys.text" "3" "0" "1" "0" "0" "1" "opaque or indirect call #23783" -"sys" "source" "sys.text" "sys.text.f32" "112" "blocked" "indirect call" "sys.aryu8._grow" "37" "sys.aryu8" "3" "0" "1" "0" "0" "1" "call #24296 -> sys.aryu8._grow: opaque or indirect call #2466" -"sys" "source" "sys.text" "sys.text.f64" "113" "direct" "indirect call" "sys.text.f64" "113" "sys.text" "3" "0" "1" "0" "0" "1" "opaque or indirect call #22964" -"sys" "source" "sys.text" "sys.text.char" "114" "blocked" "indirect call" "sys.aryu8._grow" "37" "sys.aryu8" "3" "0" "1" "0" "0" "1" "call #7450 -> sys.text.integer: call #5950 -> sys.text.string: call #23308 -> sys.aryu8._grow: opaque or indirect call #2466" -"sys" "source" "sys.text" "sys.text.bool" "115" "blocked" "indirect call" "sys.aryu8._grow" "37" "sys.aryu8" "3" "0" "1" "0" "0" "1" "call #7526 -> sys.text.integer: call #5950 -> sys.text.string: call #23308 -> sys.aryu8._grow: opaque or indirect call #2466" -"sys" "source" "sys.text" "sys.text.hex" "116" "blocked" "indirect call" "sys.aryu8._grow" "37" "sys.aryu8" "3" "0" "1" "0" "0" "1" "call #7602 -> sys.text.integer: call #5950 -> sys.text.string: call #23308 -> sys.aryu8._grow: opaque or indirect call #2466" -"sys" "source" "sys.text" "sys.text.time" "117" "blocked" "raw address" "sys.time.local" "148" "sys.time" "0" "0" "0" "0" "0" "0" "call #27428 -> sys.time._format: call #10394 -> sys.time.local: raw address escapes lifetime tracking #9945" -"sys" "source" "sys.time" "class:sys.time.<clinit>" "118" "pass" "supported" "class:sys.time.<clinit>" "118" "sys.time" "0" "0" "0" "0" "0" "0" "" -"sys" "source" "sys.time" "sys.time.now" "125" "direct" "indirect call" "sys.time.now" "125" "sys.time" "0" "0" "0" "0" "0" "0" "opaque or indirect call #7965" -"sys" "source" "sys.time" "sys.time.monotonic" "126" "direct" "indirect call" "sys.time.monotonic" "126" "sys.time" "0" "0" "0" "0" "0" "0" "opaque or indirect call #7992" -"sys" "source" "sys.time" "sys.time.nanoTime" "127" "direct" "indirect call" "sys.time.nanoTime" "127" "sys.time" "0" "0" "0" "0" "0" "0" "opaque or indirect call #8019" -"sys" "source" "sys.time" "sys.time.sleep" "128" "direct" "indirect call" "sys.time.sleep" "128" "sys.time" "0" "0" "0" "0" "0" "0" "opaque or indirect call #8049" -"sys" "source" "sys.time" "sys.time.sleepUntil" "129" "direct" "indirect call" "sys.time.sleepUntil" "129" "sys.time" "0" "0" "0" "0" "0" "0" "opaque or indirect call #8079" -"sys" "source" "sys.time" "sys.time._scale" "130" "pass" "supported" "sys.time._scale" "130" "sys.time" "0" "0" "0" "0" "0" "0" "" -"sys" "source" "sys.time" "sys.time.seconds" "131" "pass" "supported" "sys.time.seconds" "131" "sys.time" "0" "0" "0" "0" "0" "0" "" -"sys" "source" "sys.time" "sys.time.minutes" "132" "pass" "supported" "sys.time.minutes" "132" "sys.time" "0" "0" "0" "0" "0" "0" "" -"sys" "source" "sys.time" "sys.time.hours" "133" "pass" "supported" "sys.time.hours" "133" "sys.time" "0" "0" "0" "0" "0" "0" "" -"sys" "source" "sys.time" "sys.time.days" "134" "pass" "supported" "sys.time.days" "134" "sys.time" "0" "0" "0" "0" "0" "0" "" -"sys" "source" "sys.time" "sys.time.toSeconds" "135" "pass" "supported" "sys.time.toSeconds" "135" "sys.time" "0" "0" "0" "0" "0" "0" "" -"sys" "source" "sys.time" "sys.time.toMinutes" "136" "pass" "supported" "sys.time.toMinutes" "136" "sys.time" "0" "0" "0" "0" "0" "0" "" -"sys" "source" "sys.time" "sys.time.toHours" "137" "pass" "supported" "sys.time.toHours" "137" "sys.time" "0" "0" "0" "0" "0" "0" "" -"sys" "source" "sys.time" "sys.time.toDays" "138" "pass" "supported" "sys.time.toDays" "138" "sys.time" "0" "0" "0" "0" "0" "0" "" -"sys" "source" "sys.time" "sys.time.fromNanos" "139" "pass" "supported" "sys.time.fromNanos" "139" "sys.time" "0" "0" "0" "0" "0" "0" "" -"sys" "source" "sys.time" "sys.time.toNanos" "140" "pass" "supported" "sys.time.toNanos" "140" "sys.time" "0" "0" "0" "0" "0" "0" "" -"sys" "source" "sys.time" "sys.time.remaining" "141" "pass" "supported" "sys.time.remaining" "141" "sys.time" "0" "0" "0" "0" "0" "0" "" -"sys" "source" "sys.time" "sys.time.leap" "142" "pass" "supported" "sys.time.leap" "142" "sys.time" "0" "0" "0" "0" "0" "0" "" -"sys" "source" "sys.time" "sys.time.monthDays" "143" "pass" "supported" "sys.time.monthDays" "143" "sys.time" "0" "0" "0" "0" "0" "0" "" -"sys" "source" "sys.time" "sys.time._days" "144" "pass" "supported" "sys.time._days" "144" "sys.time" "0" "0" "0" "0" "0" "0" "" -"sys" "source" "sys.time" "sys.time.valid" "145" "pass" "supported" "sys.time.valid" "145" "sys.time" "0" "0" "0" "0" "0" "0" "" -"sys" "source" "sys.time" "sys.time.makeUTC" "146" "pass" "supported" "sys.time.makeUTC" "146" "sys.time" "0" "0" "0" "0" "0" "0" "" -"sys" "source" "sys.time" "sys.time.utc" "147" "pass" "supported" "sys.time.utc" "147" "sys.time" "1" "0" "0" "1" "0" "0" "" -"sys" "source" "sys.time" "sys.time.local" "148" "direct" "raw address" "sys.time.local" "148" "sys.time" "2" "0" "0" "0" "0" "0" "raw address escapes lifetime tracking #9945" -"sys" "source" "sys.time" "sys.time.zoneName" "149" "direct" "raw address" "sys.time.zoneName" "149" "sys.time" "4" "0" "1" "0" "0" "2" "raw address escapes lifetime tracking #10204" -"sys" "source" "sys.time" "sys.time._digits" "150" "blocked" "indirect call" "sys.aryu8._grow" "37" "sys.aryu8" "0" "0" "0" "0" "0" "0" "call #10353 -> sys.text.integer: call #5950 -> sys.text.string: call #23308 -> sys.aryu8._grow: opaque or indirect call #2466" -"sys" "source" "sys.time" "sys.time._format" "151" "blocked" "raw address" "sys.time.local" "148" "sys.time" "3" "0" "1" "0" "0" "1" "call #10394 -> sys.time.local: raw address escapes lifetime tracking #9945" -"sys" "source" "sys.time" "sys.time.elapsed" "152" "blocked" "indirect call" "sys.aryu8._grow" "37" "sys.aryu8" "3" "0" "1" "0" "0" "1" "call #22941 -> sys.text.integer: call #5950 -> sys.text.string: call #23308 -> sys.aryu8._grow: opaque or indirect call #2466" -"sys" "source" "sys.time" "sys.time.format" "153" "blocked" "raw address" "sys.time.local" "148" "sys.time" "0" "0" "0" "0" "0" "0" "call #11574 -> sys.time._format: call #10394 -> sys.time.local: raw address escapes lifetime tracking #9945" -"sys" "source" "sys.time" "sys.time.formatLocal" "154" "blocked" "raw address" "sys.time.local" "148" "sys.time" "0" "0" "0" "0" "0" "0" "call #11663 -> sys.time._format: call #10394 -> sys.time.local: raw address escapes lifetime tracking #9945" -"sys" "source" "sys.time" "sys.time._number" "155" "pass" "supported" "sys.time._number" "155" "sys.time" "0" "0" "0" "0" "0" "1" "" -"sys" "source" "sys.time" "sys.time._parseZone" "156" "pass" "supported" "sys.time._parseZone" "156" "sys.time" "0" "0" "0" "0" "0" "0" "" -"sys" "source" "sys.time" "sys.time.parse" "157" "pass" "supported" "sys.time.parse" "157" "sys.time" "0" "0" "0" "0" "0" "0" "" -"sys" "source" "sys.libc" "class:sys.libc.<clinit>" "158" "pass" "supported" "class:sys.libc.<clinit>" "158" "sys.libc" "0" "0" "0" "0" "0" "0" "" -"sys" "source" "sys.libc" "sys.libc.errno" "167" "direct" "indirect call" "sys.libc.errno" "167" "sys.libc" "0" "0" "0" "0" "0" "0" "opaque or indirect call #13351" -"sys" "source" "sys.libc" "sys.libc.set_errno" "169" "direct" "indirect call" "sys.libc.set_errno" "169" "sys.libc" "0" "0" "0" "0" "0" "0" "opaque or indirect call #13383" -"sys" "source" "sys.rt" "class:sys.rt.<clinit>" "172" "pass" "supported" "class:sys.rt.<clinit>" "172" "sys.rt" "0" "0" "0" "0" "0" "0" "" -"sys" "source" "sys.scan" "class:sys.scan.<clinit>" "173" "pass" "supported" "class:sys.scan.<clinit>" "173" "sys.scan" "0" "0" "0" "0" "0" "0" "" -"sys" "source" "sys.scan" "sys.scan.<init>" "174" "pass" "supported" "sys.scan.<init>" "174" "sys.scan" "0" "0" "0" "0" "0" "0" "" -"sys" "source" "sys.scan" "sys.scan.skip" "175" "pass" "supported" "sys.scan.skip" "175" "sys.scan" "0" "0" "0" "0" "0" "1" "" -"sys" "source" "sys.scan" "sys.scan.match" "176" "pass" "supported" "sys.scan.match" "176" "sys.scan" "0" "0" "0" "0" "0" "1" "" -"sys" "source" "sys.scan" "sys.scan.number" "177" "pass" "supported" "sys.scan.number" "177" "sys.scan" "0" "0" "0" "0" "0" "3" "" -"sys" "source" "sys.scan" "sys.scan.<new>" "179" "pass" "supported" "sys.scan.<new>" "179" "sys.scan" "1" "0" "0" "1" "0" "0" "" -"sys" "source" "sys.adt.bitset" "class:sys.adt.bitset.<clinit>" "180" "pass" "supported" "class:sys.adt.bitset.<clinit>" "180" "sys.adt.bitset" "0" "0" "0" "0" "0" "0" "" -"sys" "source" "sys.adt.bitset" "sys.adt.bitset.<init>" "181" "pass" "supported" "sys.adt.bitset.<init>" "181" "sys.adt.bitset" "0" "0" "0" "0" "0" "0" "" -"sys" "source" "sys.adt.bitset" "sys.adt.bitset.get" "182" "pass" "supported" "sys.adt.bitset.get" "182" "sys.adt.bitset" "0" "0" "0" "0" "0" "0" "" -"sys" "source" "sys.adt.bitset" "sys.adt.bitset._grow" "183" "direct" "variable size" "sys.adt.bitset._grow" "183" "sys.adt.bitset" "1" "0" "1" "0" "0" "2" "variable-size allocation #14313" -"sys" "source" "sys.adt.bitset" "sys.adt.bitset.set" "184" "blocked" "variable size" "sys.adt.bitset._grow" "183" "sys.adt.bitset" "0" "0" "0" "0" "0" "0" "call #14413 -> sys.adt.bitset._grow: variable-size allocation #14313" -"sys" "source" "sys.adt.bitset" "sys.adt.bitset.tset" "185" "blocked" "variable size" "sys.adt.bitset._grow" "183" "sys.adt.bitset" "0" "0" "0" "0" "0" "0" "call #14465 -> sys.adt.bitset._grow: variable-size allocation #14313" -"sys" "source" "sys.adt.bitset" "sys.adt.bitset.clr" "186" "pass" "supported" "sys.adt.bitset.clr" "186" "sys.adt.bitset" "0" "0" "0" "0" "0" "0" "" -"sys" "source" "sys.adt.bitset" "sys.adt.bitset.clear" "187" "pass" "supported" "sys.adt.bitset.clear" "187" "sys.adt.bitset" "0" "0" "0" "0" "0" "1" "" -"sys" "source" "sys.adt.bitset" "sys.adt.bitset.<new>" "189" "pass" "supported" "sys.adt.bitset.<new>" "189" "sys.adt.bitset" "2" "0" "0" "2" "0" "0" "" -"sys" "source" "sys.draw.Canvas" "class:sys.draw.Canvas.<clinit>" "190" "pass" "supported" "class:sys.draw.Canvas.<clinit>" "190" "sys.draw.Canvas" "0" "0" "0" "0" "0" "0" "" -"sys" "source" "sys.draw.Canvas" "sys.draw.Canvas.<init>" "191" "pass" "supported" "sys.draw.Canvas.<init>" "191" "sys.draw.Canvas" "0" "0" "0" "0" "0" "0" "" -"sys" "source" "sys.draw.Canvas" "sys.draw.Canvas.resize" "192" "direct" "indirect call" "sys.draw.Canvas.resize" "192" "sys.draw.Canvas" "1" "0" "1" "0" "0" "0" "opaque or indirect call #15078" -"sys" "source" "sys.draw.Canvas" "sys.draw.Canvas.localX" "193" "pass" "supported" "sys.draw.Canvas.localX" "193" "sys.draw.Canvas" "0" "0" "0" "0" "0" "0" "" -"sys" "source" "sys.draw.Canvas" "sys.draw.Canvas.localY" "194" "pass" "supported" "sys.draw.Canvas.localY" "194" "sys.draw.Canvas" "0" "0" "0" "0" "0" "0" "" -"sys" "source" "sys.draw.Canvas" "sys.draw.Canvas.clear" "195" "pass" "supported" "sys.draw.Canvas.clear" "195" "sys.draw.Canvas" "0" "0" "0" "0" "0" "1" "" -"sys" "source" "sys.draw.Canvas" "sys.draw.Canvas.pixel" "196" "pass" "supported" "sys.draw.Canvas.pixel" "196" "sys.draw.Canvas" "0" "0" "0" "0" "0" "0" "" -"sys" "source" "sys.draw.Canvas" "sys.draw.Canvas.fillRect" "197" "pass" "supported" "sys.draw.Canvas.fillRect" "197" "sys.draw.Canvas" "0" "0" "0" "0" "0" "2" "" -"sys" "source" "sys.draw.Canvas" "sys.draw.Canvas.rect" "198" "pass" "supported" "sys.draw.Canvas.rect" "198" "sys.draw.Canvas" "0" "0" "0" "0" "0" "0" "" -"sys" "source" "sys.draw.Canvas" "sys.draw.Canvas.fillCircle" "199" "pass" "supported" "sys.draw.Canvas.fillCircle" "199" "sys.draw.Canvas" "0" "0" "0" "0" "0" "0" "" -"sys" "source" "sys.draw.Canvas" "sys.draw.Canvas.circle" "200" "pass" "supported" "sys.draw.Canvas.circle" "200" "sys.draw.Canvas" "0" "0" "0" "0" "0" "0" "" -"sys" "source" "sys.draw.Canvas" "sys.draw.Canvas._circle" "201" "pass" "supported" "sys.draw.Canvas._circle" "201" "sys.draw.Canvas" "0" "0" "0" "0" "0" "2" "" -"sys" "source" "sys.draw.Canvas" "sys.draw.Canvas.line" "202" "pass" "supported" "sys.draw.Canvas.line" "202" "sys.draw.Canvas" "0" "0" "0" "0" "0" "2" "" -"sys" "source" "sys.draw.Canvas" "sys.draw.Canvas.text" "203" "pass" "supported" "sys.draw.Canvas.text" "203" "sys.draw.Canvas" "0" "0" "0" "0" "0" "3" "" -"sys" "source" "sys.draw.Canvas" "sys.draw.Canvas.Canvas" "204" "direct" "indirect call" "sys.draw.Canvas.Canvas" "204" "sys.draw.Canvas" "1" "0" "1" "0" "0" "0" "opaque or indirect call #17231" -"sys" "source" "sys.draw.Canvas" "sys.draw.Canvas.<new>" "205" "blocked" "indirect call" "sys.draw.Canvas.Canvas" "204" "sys.draw.Canvas" "1" "0" "0" "0" "0" "0" "call #17399 -> sys.draw.Canvas.Canvas: opaque or indirect call #17231" -"sys" "source" "sys.draw.Canvas" "sys.draw.Canvas._glyph" "206" "pass" "supported" "sys.draw.Canvas._glyph" "206" "sys.draw.Canvas" "0" "0" "0" "0" "0" "0" "" -"sys" "source" "sys.draw.Canvas" "sys.draw.Canvas._onLine" "207" "pass" "supported" "sys.draw.Canvas._onLine" "207" "sys.draw.Canvas" "0" "0" "0" "0" "0" "0" "" -"sys" "source" "sys.draw.Button" "class:sys.draw.Button.<clinit>" "208" "pass" "supported" "class:sys.draw.Button.<clinit>" "208" "sys.draw.Button" "0" "0" "0" "0" "0" "0" "" -"sys" "source" "sys.draw.Button" "sys.draw.Button.<init>" "209" "pass" "supported" "sys.draw.Button.<init>" "209" "sys.draw.Button" "0" "0" "0" "0" "0" "0" "" -"sys" "source" "sys.draw.Button" "sys.draw.Button.contains" "210" "pass" "supported" "sys.draw.Button.contains" "210" "sys.draw.Button" "0" "0" "0" "0" "0" "0" "" -"sys" "source" "sys.draw.Button" "sys.draw.Button.update" "211" "pass" "supported" "sys.draw.Button.update" "211" "sys.draw.Button" "0" "0" "0" "0" "0" "0" "" -"sys" "source" "sys.draw.Button" "sys.draw.Button.draw" "212" "pass" "supported" "sys.draw.Button.draw" "212" "sys.draw.Button" "0" "0" "0" "0" "0" "0" "" -"sys" "source" "sys.draw.Button" "sys.draw.Button.<new>" "214" "pass" "supported" "sys.draw.Button.<new>" "214" "sys.draw.Button" "1" "0" "0" "1" "0" "0" "" -"sys" "source" "sys.time.DateTime" "class:sys.time.DateTime.<clinit>" "215" "pass" "supported" "class:sys.time.DateTime.<clinit>" "215" "sys.time.DateTime" "0" "0" "0" "0" "0" "0" "" -"sys" "source" "sys.time.DateTime" "sys.time.DateTime.<new>" "217" "pass" "supported" "sys.time.DateTime.<new>" "217" "sys.time.DateTime" "1" "0" "0" "1" "0" "0" "" -"sys" "source" "sys.time.DateTime" "sys.time.DateTime.empty" "218" "pass" "supported" "sys.time.DateTime.empty" "218" "sys.time.DateTime" "1" "0" "0" "1" "0" "0" "" -"sys" "source" "sys.time.Timers" "class:sys.time.Timers.<clinit>" "219" "pass" "supported" "class:sys.time.Timers.<clinit>" "219" "sys.time.Timers" "0" "0" "0" "0" "0" "0" "" -"sys" "source" "sys.time.Timers" "sys.time.Timers.<init>" "220" "pass" "supported" "sys.time.Timers.<init>" "220" "sys.time.Timers" "3" "0" "0" "3" "0" "0" "" -"sys" "source" "sys.time.Timers" "sys.time.Timers._add" "221" "direct" "recursion" "sys.time.Timers._add" "221" "sys.time.Timers" "3" "0" "3" "0" "0" "2" "recursive call component" -"sys" "source" "sys.time.Timers" "sys.time.Timers.afterAt" "222" "blocked" "recursion" "sys.time.Timers._add" "221" "sys.time.Timers" "0" "0" "0" "0" "0" "0" "call #20364 -> sys.time.Timers._add: recursive call component" -"sys" "source" "sys.time.Timers" "sys.time.Timers.everyAt" "223" "blocked" "recursion" "sys.time.Timers._add" "221" "sys.time.Timers" "0" "0" "0" "0" "0" "0" "call #20399 -> sys.time.Timers._add: recursive call component" -"sys" "source" "sys.time.Timers" "sys.time.Timers.after" "224" "direct" "indirect call" "sys.time.Timers.after" "224" "sys.time.Timers" "0" "0" "0" "0" "0" "0" "opaque or indirect call #22597" -"sys" "source" "sys.time.Timers" "sys.time.Timers.every" "225" "direct" "indirect call" "sys.time.Timers.every" "225" "sys.time.Timers" "0" "0" "0" "0" "0" "0" "opaque or indirect call #23115" -"sys" "source" "sys.time.Timers" "sys.time.Timers.cancel" "226" "pass" "supported" "sys.time.Timers.cancel" "226" "sys.time.Timers" "0" "0" "0" "0" "0" "1" "" -"sys" "source" "sys.time.Timers" "sys.time.Timers.nextDeadline" "227" "pass" "supported" "sys.time.Timers.nextDeadline" "227" "sys.time.Timers" "0" "0" "0" "0" "0" "1" "" -"sys" "source" "sys.time.Timers" "sys.time.Timers.poll" "228" "pass" "supported" "sys.time.Timers.poll" "228" "sys.time.Timers" "0" "0" "0" "0" "0" "1" "" -"sys" "source" "sys.time.Timers" "sys.time.Timers.<new>" "229" "pass" "supported" "sys.time.Timers.<new>" "229" "sys.time.Timers" "1" "0" "0" "4" "0" "0" "" -"RuntimeArgs" "source" "RuntimeArgs" "class:RuntimeArgs.<clinit>" "2" "pass" "supported" "class:RuntimeArgs.<clinit>" "2" "RuntimeArgs" "0" "0" "0" "0" "0" "0" "" -"RuntimeArgs" "source" "RuntimeArgs" "simple_args" "6" "direct" "raw address" "simple_args" "6" "RuntimeArgs" "2" "0" "2" "0" "0" "1" "raw address escapes lifetime tracking #248" -"A_helloWorld" "object" "A_helloWorld" "class:A_helloWorld.<clinit>" "2" "blocked" "raw address" "sys.io.writeOff" "95" "sys.io" "0" "0" "0" "0" "0" "0" "call #4079 -> sys.io.writeOff: raw address escapes lifetime tracking #3733" -"BubbleSort" "object" "BubbleSort" "class:BubbleSort.<clinit>" "2" "pass" "supported" "class:BubbleSort.<clinit>" "2" "BubbleSort" "0" "0" "0" "0" "0" "0" "" -"BubbleSort" "object" "BubbleSort" "sort" "202" "pass" "supported" "sort" "202" "BubbleSort" "0" "0" "0" "0" "0" "2" "" -"BubbleSort" "object" "BubbleSort" "main" "203" "blocked" "raw address" "sys.io.writeOff" "95" "sys.io" "0" "0" "0" "0" "0" "0" "call #5100 -> sys.io.writeOff: raw address escapes lifetime tracking #4714" -"BubbleSort" "object" "BubbleSort" "usage" "204" "blocked" "raw address" "sys.io.writeOff" "95" "sys.io" "0" "0" "0" "0" "0" "0" "call #5978 -> sys.io.writeOff: raw address escapes lifetime tracking #4714" -"Capitalize" "object" "Capitalize" "class:Capitalize.<clinit>" "2" "pass" "supported" "class:Capitalize.<clinit>" "2" "Capitalize" "0" "0" "0" "0" "0" "0" "" -"Capitalize" "object" "Capitalize" "main" "3" "blocked" "raw address" "sys.io.writeOff" "96" "sys.io" "1" "0" "1" "0" "0" "0" "call #4536 -> sys.io.writeOff: raw address escapes lifetime tracking #4076" -"FileIO" "object" "FileIO" "class:FileIO.<clinit>" "2" "pass" "supported" "class:FileIO.<clinit>" "2" "FileIO" "0" "0" "0" "0" "0" "0" "" -"FileIO" "object" "FileIO" "main" "3" "direct" "raw address" "main" "3" "FileIO" "2" "0" "0" "0" "0" "0" "raw address escapes lifetime tracking #6573" -"FileIO" "object" "FileIO" "_error2" "203" "direct" "raw address" "_error2" "203" "FileIO" "2" "0" "0" "0" "0" "0" "raw address escapes lifetime tracking #6670" -"FileIO" "object" "FileIO" "_error" "204" "direct" "indirect call" "_error" "204" "FileIO" "0" "0" "0" "0" "0" "0" "opaque or indirect call #6874" -"Dijkstra" "object" "Dijkstra" "class:Dijkstra.<clinit>" "2" "pass" "supported" "class:Dijkstra.<clinit>" "2" "Dijkstra" "0" "0" "0" "0" "0" "0" "" -"Dijkstra" "object" "Dijkstra" "shortestPath" "202" "blocked" "variable size" "sys.adt.bitset._grow" "48" "sys.adt.bitset" "3" "0" "1" "0" "0" "4" "call #7543 -> sys.adt.bitset._grow: variable-size allocation #6202" -"Dijkstra" "object" "Dijkstra" "usage" "203" "blocked" "raw address" "sys.io.writeOff" "95" "sys.io" "0" "0" "0" "0" "0" "0" "call #7528 -> sys.io.writeOff: raw address escapes lifetime tracking #6699" -"Dijkstra" "object" "Dijkstra" "main" "204" "blocked" "raw address" "sys.io.writeOff" "95" "sys.io" "2" "0" "0" "0" "0" "2" "call #7568 -> sys.io.writeOff: raw address escapes lifetime tracking #6699" -"Graphics" "object" "Graphics" "class:Graphics.<clinit>" "2" "pass" "supported" "class:Graphics.<clinit>" "2" "Graphics" "0" "0" "0" "0" "0" "0" "" -"Graphics" "object" "Graphics" "main" "3" "direct" "raw address" "main" "3" "Graphics" "1" "0" "0" "0" "0" "3" "raw address escapes lifetime tracking #6220" -"Clock" "object" "Clock" "class:Clock.<clinit>" "2" "pass" "supported" "class:Clock.<clinit>" "2" "Clock" "0" "0" "0" "0" "0" "0" "" -"Clock" "object" "Clock" "main" "3" "direct" "raw address" "main" "3" "Clock" "3" "0" "0" "0" "0" "1" "raw address escapes lifetime tracking #11014" -"Clock" "object" "Clock" "_draw" "203" "blocked" "raw address" "sys.time.local" "185" "sys.time" "3" "0" "1" "0" "0" "2" "call #1002 -> sys.time.local: raw address escapes lifetime tracking #12253" -"Clock" "object" "Clock" "_digit" "208" "pass" "supported" "_digit" "208" "Clock" "0" "0" "0" "0" "0" "1" "" -"Clock" "object" "Clock" "_digital" "209" "pass" "supported" "_digital" "209" "Clock" "0" "0" "0" "0" "0" "1" "" -"Clock" "object" "Clock" "_hand" "210" "direct" "indirect call" "_hand" "210" "Clock" "0" "0" "0" "0" "0" "0" "opaque or indirect call #2302" -"Clock" "object" "Clock" "_analog" "211" "direct" "indirect call" "_analog" "211" "Clock" "0" "0" "0" "0" "0" "1" "opaque or indirect call #2540" -"Breakout" "object" "Breakout" "class:Breakout.<clinit>" "2" "pass" "supported" "class:Breakout.<clinit>" "2" "Breakout" "1" "0" "0" "1" "0" "0" "" -"Breakout" "object" "Breakout" "Breakout.Game.<init>" "3" "pass" "supported" "Breakout.Game.<init>" "3" "Breakout" "1" "0" "0" "1" "0" "1" "" -"Breakout" "object" "Breakout" "_tick" "4" "pass" "supported" "_tick" "4" "Breakout" "0" "0" "0" "0" "0" "3" "" -"Breakout" "object" "Breakout" "_cue" "5" "pass" "supported" "_cue" "5" "Breakout" "0" "0" "0" "0" "0" "0" "" -"Breakout" "object" "Breakout" "_speed" "6" "pass" "supported" "_speed" "6" "Breakout" "0" "0" "0" "0" "0" "0" "" -"Breakout" "object" "Breakout" "_paddle" "7" "pass" "supported" "_paddle" "7" "Breakout" "0" "0" "0" "0" "0" "0" "" -"Breakout" "object" "Breakout" "_rebound" "8" "pass" "supported" "_rebound" "8" "Breakout" "0" "0" "0" "0" "0" "1" "" -"Breakout" "object" "Breakout" "_brick" "9" "pass" "supported" "_brick" "9" "Breakout" "0" "0" "0" "0" "0" "0" "" -"Breakout" "object" "Breakout" "_lostBall" "10" "pass" "supported" "_lostBall" "10" "Breakout" "0" "0" "0" "0" "0" "0" "" -"Breakout" "object" "Breakout" "_reset" "11" "pass" "supported" "_reset" "11" "Breakout" "0" "0" "0" "0" "0" "1" "" -"Breakout" "object" "Breakout" "_hud" "211" "pass" "supported" "_hud" "211" "Breakout" "0" "0" "0" "0" "0" "4" "" -"Breakout" "object" "Breakout" "_bricks" "212" "pass" "supported" "_bricks" "212" "Breakout" "0" "0" "0" "0" "0" "1" "" -"Breakout" "object" "Breakout" "_overlay" "213" "pass" "supported" "_overlay" "213" "Breakout" "0" "0" "0" "0" "0" "0" "" -"Breakout" "object" "Breakout" "_draw" "214" "pass" "supported" "_draw" "214" "Breakout" "0" "0" "0" "0" "0" "1" "" -"Breakout" "object" "Breakout" "_input" "215" "direct" "indirect call" "_input" "215" "Breakout" "0" "0" "0" "0" "0" "0" "opaque or indirect call #18288" -"Breakout" "object" "Breakout" "debounce" "216" "direct" "indirect call" "debounce" "216" "Breakout" "0" "0" "0" "0" "0" "0" "opaque or indirect call #6273" -"Breakout" "object" "Breakout" "_serve" "217" "pass" "supported" "_serve" "217" "Breakout" "0" "0" "0" "0" "0" "1" "" -"Breakout" "object" "Breakout" "" "218" "direct" "indirect call" "" "218" "Breakout" "0" "0" "0" "0" "0" "0" "opaque or indirect call #18379" -"Breakout" "object" "Breakout" "" "219" "pass" "supported" "" "219" "Breakout" "0" "0" "0" "0" "0" "0" "" -"Breakout" "object" "Breakout" "Breakout.Game.<new>" "220" "pass" "supported" "Breakout.Game.<new>" "220" "Breakout" "1" "0" "0" "2" "0" "0" "" -"Breakout" "object" "Breakout" "_number" "221" "pass" "supported" "_number" "221" "Breakout" "0" "0" "0" "0" "0" "1" "" -"Breakout" "object" "Breakout" "_tone" "222" "direct" "raw address" "_tone" "222" "Breakout" "1" "0" "0" "0" "0" "1" "raw address escapes lifetime tracking #18921" -"Breakout" "object" "Breakout" "_sqrt" "223" "pass" "supported" "_sqrt" "223" "Breakout" "0" "0" "0" "0" "0" "1" "" -"Breakout" "object" "Breakout" "main" "224" "direct" "raw address" "main" "224" "Breakout" "4" "0" "1" "0" "0" "3" "raw address escapes lifetime tracking #19167" -"TicTacToe" "object" "TicTacToe" "class:TicTacToe.<clinit>" "2" "pass" "supported" "class:TicTacToe.<clinit>" "2" "TicTacToe" "0" "0" "0" "0" "0" "0" "" -"TicTacToe" "object" "TicTacToe" "main" "3" "blocked" "raw address" "sys.io.writeOff" "96" "sys.io" "4" "0" "1" "0" "0" "3" "call #9529 -> sys.io.writeOff: raw address escapes lifetime tracking #7910" -"TicTacToe" "object" "TicTacToe" "_validMove" "207" "direct" "indirect call" "_validMove" "207" "TicTacToe" "3" "0" "1" "0" "0" "2" "opaque or indirect call #9266" -"TicTacToe" "object" "TicTacToe" "_winner" "208" "pass" "supported" "_winner" "208" "TicTacToe" "0" "0" "0" "0" "0" "1" "" -"TicTacToe" "object" "TicTacToe" "_finished" "209" "blocked" "raw address" "sys.io.writeOff" "96" "sys.io" "0" "0" "0" "0" "0" "1" "call #9491 -> sys.io.writeOff: raw address escapes lifetime tracking #7910" -"TicTacToe" "object" "TicTacToe" "_threat" "210" "pass" "supported" "_threat" "210" "TicTacToe" "0" "0" "0" "0" "0" "1" "" -"TicTacToe" "object" "TicTacToe" "_cpu" "211" "pass" "supported" "_cpu" "211" "TicTacToe" "0" "0" "0" "0" "0" "2" "" -"TicTacToe" "object" "TicTacToe" "_draw" "212" "blocked" "opaque body" "sys.ary.capacity" "64" "sys.ary" "2" "0" "0" "0" "0" "2" "call #8785 -> sys.aryu8._grow: call #8389 -> sys.ary.capacity: opaque body: allocation contract unavailable" -"TicTacToeGraphical" "object" "TicTacToeGraphical" "class:TicTacToeGraphical.<clinit>" "2" "pass" "supported" "class:TicTacToeGraphical.<clinit>" "2" "TicTacToeGraphical" "0" "0" "0" "0" "0" "0" "" -"TicTacToeGraphical" "object" "TicTacToeGraphical" "main" "3" "direct" "raw address" "main" "3" "TicTacToeGraphical" "2" "0" "0" "0" "0" "4" "raw address escapes lifetime tracking #9861" -"TicTacToeGraphical" "object" "TicTacToeGraphical" "_sound" "203" "pass" "supported" "_sound" "203" "TicTacToeGraphical" "0" "0" "0" "0" "0" "0" "" -"TicTacToeGraphical" "object" "TicTacToeGraphical" "_reset" "204" "pass" "supported" "_reset" "204" "TicTacToeGraphical" "0" "0" "0" "0" "0" "1" "" -"TicTacToeGraphical" "object" "TicTacToeGraphical" "_square" "205" "pass" "supported" "_square" "205" "TicTacToeGraphical" "0" "0" "0" "0" "0" "0" "" -"TicTacToeGraphical" "object" "TicTacToeGraphical" "_move" "206" "pass" "supported" "_move" "206" "TicTacToeGraphical" "0" "0" "0" "0" "0" "2" "" -"TicTacToeGraphical" "object" "TicTacToeGraphical" "_finished" "207" "pass" "supported" "_finished" "207" "TicTacToeGraphical" "0" "0" "0" "0" "0" "1" "" -"TicTacToeGraphical" "object" "TicTacToeGraphical" "_winningLine" "208" "pass" "supported" "_winningLine" "208" "TicTacToeGraphical" "0" "0" "0" "0" "0" "1" "" -"TicTacToeGraphical" "object" "TicTacToeGraphical" "_winner" "209" "pass" "supported" "_winner" "209" "TicTacToeGraphical" "0" "0" "0" "0" "0" "0" "" -"TicTacToeGraphical" "object" "TicTacToeGraphical" "_threat" "210" "pass" "supported" "_threat" "210" "TicTacToeGraphical" "0" "0" "0" "0" "0" "1" "" -"TicTacToeGraphical" "object" "TicTacToeGraphical" "_cpu" "211" "pass" "supported" "_cpu" "211" "TicTacToeGraphical" "0" "0" "0" "0" "0" "2" "" -"TicTacToeGraphical" "object" "TicTacToeGraphical" "_draw" "212" "pass" "supported" "_draw" "212" "TicTacToeGraphical" "0" "0" "0" "0" "0" "4" "" -"LocalArray" "probe" "LocalArray" "class:LocalArray.<clinit>" "2" "blocked" "variable size" "work_noInline" "3" "LocalArray" "0" "0" "0" "0" "0" "0" "call #111 -> work_noInline: variable-size allocation #36" -"LocalArray" "probe" "LocalArray" "work_noInline" "3" "direct" "variable size" "work_noInline" "3" "LocalArray" "1" "0" "1" "0" "0" "1" "variable-size allocation #36" -"ReturnedArray" "probe" "ReturnedArray" "class:ReturnedArray.<clinit>" "2" "blocked" "variable size" "make_noInline" "3" "ReturnedArray" "0" "0" "0" "0" "0" "0" "call #53 -> make_noInline: variable-size allocation #36" -"ReturnedArray" "probe" "ReturnedArray" "make_noInline" "3" "direct" "variable size" "make_noInline" "3" "ReturnedArray" "1" "0" "1" "0" "0" "0" "variable-size allocation #36" -"OverwrittenSlot" "probe" "OverwrittenSlot" "class:OverwrittenSlot.<clinit>" "2" "blocked" "loop retention" "work_noInline" "8" "OverwrittenSlot" "0" "0" "0" "0" "0" "0" "call #206 -> work_noInline: loop#148 carries new#277:OverwrittenSlot.Thing across its backedge; collection/overlap destinations not implemented" -"OverwrittenSlot" "probe" "OverwrittenSlot" "OverwrittenSlot.Thing.<new>" "5" "pass" "supported" "OverwrittenSlot.Thing.<new>" "5" "OverwrittenSlot" "1" "0" "0" "1" "0" "0" "" -"OverwrittenSlot" "probe" "OverwrittenSlot" "OverwrittenSlot.Holder.<new>" "7" "pass" "supported" "OverwrittenSlot.Holder.<new>" "7" "OverwrittenSlot" "1" "0" "0" "1" "0" "0" "" -"OverwrittenSlot" "probe" "OverwrittenSlot" "work_noInline" "8" "direct" "loop retention" "work_noInline" "8" "OverwrittenSlot" "2" "0" "0" "0" "0" "1" "loop#148 carries new#277:OverwrittenSlot.Thing across its backedge; collection/overlap destinations not implemented" -"ReusedObject" "probe" "ReusedObject" "class:ReusedObject.<clinit>" "2" "pass" "supported" "class:ReusedObject.<clinit>" "2" "ReusedObject" "0" "0" "0" "0" "0" "0" "" -"ReusedObject" "probe" "ReusedObject" "ReusedObject.Thing.<new>" "5" "pass" "supported" "ReusedObject.Thing.<new>" "5" "ReusedObject" "1" "0" "0" "1" "0" "0" "" -"ReusedObject" "probe" "ReusedObject" "read_noInline" "6" "pass" "supported" "read_noInline" "6" "ReusedObject" "0" "0" "0" "0" "0" "0" "" -"ReusedObject" "probe" "ReusedObject" "work_noInline" "7" "pass" "supported" "work_noInline" "7" "ReusedObject" "1" "0" "0" "1" "0" "1" "" diff --git a/chapter33/docs/allocation-survey.md b/chapter33/docs/allocation-survey.md deleted file mode 100644 index eb803c78..00000000 --- a/chapter33/docs/allocation-survey.md +++ /dev/null @@ -1,256 +0,0 @@ -# Allocation survey: existing Simple programs - -Measured 2026-11-21, at TypeCheck with assertions enabled. This surveys the -current analysis; it does not implement or validate stack allocation at runtime. - -The fixed-size plans handle useful object graphs and native borrowing. -Variable-sized storage is now the broadest limitation; the original baseline -below records the earlier native-call and raw-address blockers. - -## Update: lexical KeepAlive - -The parser now retains converted addresses through their lexical scope exits. -This admits integer arguments forwarded through Simple wrappers and addresses -stored and reloaded within that scope. Conditional conversions, overwritten -locals, return/break/continue paths, implicit branch scopes, forward calls, and -imported bodies are covered by the chapter tests. A returned integer does not -promote its backing storage into the caller's lifetime. - -The large-program totals remain 134/179 accepted for `sys` source and -52/68 for the examples' own functions. Those programs had already passed -the simpler borrowing checks or encountered another blocker first. - -The current first-cause breakdown for the 45 rejected `sys` functions is: - -| Cause | Direct | Blocked callers | -|---|---:|---:| -| Variable-size allocation | 7 | 32 | -| Recursion | 1 | 4 | -| Native pointer result without an allocation contract | 1 | 0 | - -First-cause counts can change with optimization order when a function has several -blockers. The native-result requirement remains; this is not permission to assume -that a native-produced pointer is borrowed. The examples' remaining failures -are eleven missing imported bodies, four variable-size plans, and one indirect -callback. - -The next substantial gains need variable-size plans and allocation contracts -for imported bodies. Recursion and Breakout's indirect callback remain separate -work. `_exit` still needs the agreed nonreturning handling. KeepAlive is erased -before scheduling; storage placement still uses function/iteration frames and -does not yet change runtime allocation. - -## Update: native borrowing - -After adopting the native non-retention rule and tracking pointer-derived -integer SSA values through calls, the same cohorts improve as follows. The -remaining sections preserve the original survey and its baseline snapshot. - -| Cohort | Accepted before | Accepted now | With user allocations now | -|---|---:|---:|---:| -| `sys` source, 179 functions | 98 | 134 | 12 | -| Examples' own 68 functions | 43 | 52 | 4 | - -Hello world's executable initializer now gets a supported plan. Clock's `_hand` -and `_analog` pass. Breakout improves from 19/24 to 22/24; its `_tone` buffer is -now accepted as scratch. `sys.time.local` now accepts the DateTime result and -its temporary native buffer. - -Of the remaining 45 `sys` rejections, 38 stop at variable-sized allocation -(seven direct, 31 callers), five at recursion (one direct, four callers), and -two at native-produced Simple pointers without allocation contracts. No call -or raw-address rejection remains the first cause in that source cohort. -Precompiled-library examples still expose missing imported summaries, such as -`sys.ary.capacity`, `sys.ary.copy`, and `sys.aryu8.str0`. Breakout's `debounce` -also contains a genuinely indirect callback. - -This change is analysis-only. `_exit` is accepted under the native borrowing -rule, but is not yet a nonreturning intrinsic. The ABI, allocation lowering, -and default runtime allocation behavior are unchanged. - -## Original baseline - -| Cohort | Function summaries | Accepted | Accepted with user allocations | -|---|---:|---:|---:| -| `sys`, compiled from source | 179 | 98 | 11 | -| Ten examples, their own functions only | 68 | 43 | 3 | -| Native argument conversion, compiled separately | 2 | 1 | 0 | - -These counts include retained/exported functions and class initializers, not -just functions reachable by direct calls from an entry point. Native declarations -without a Simple body are not separate function summaries. A passing function -can still call other passing functions that allocate. The last column counts -fresh storage represented in that function's plan, including imported callee -sites; it excludes compiler class objects. It is not a count of dynamic objects. -All 87 other accepted `sys` functions have no remaining allocation sites. - -## What passes - -The accepted `sys` plans include 19 user-storage sites: 16 with result destinations -and three retained through constructor receiver `arg2`. - -- `sys.time.utc` builds and returns a DateTime: a real fixed-size factory, with - calendar computation and conditional paths. -- `sys.time.Timers.<new>` returns a timer object and its three fixed initial - arrays. The initializer puts the arrays in the receiver's lifetime; the factory - composes that into the returned graph. -- `sys.aryu8.<new>` and `sys.text.begin` return a byte-vector object plus its - initial backing array. Growing that array is a separate, rejected operation. -- Bitset construction, Button construction, and scanner construction pass. -- All six `sys.scan` summaries and all six `sys.draw.Button` summaries pass. - Canvas has 15 passing summaries out of 18: the drawing operations work on - borrowed storage; construction and resizing encounter allocation/call barriers. -- Breakout's Game factory returns the Game and its 192-element brick array. - Its initializer correctly gives the array the receiver's lifetime. Most game - logic and drawing routines pass too. - -The accepted `sys` functions contain 26 loop summaries. Ordinary loops over -existing storage are not the main obstacle. - -## Where the library stops - -The pass records the first rejection in a function. A caller can then inherit -that rejection. Following those call chains gives: - -| First underlying reason | Directly rejected functions | Blocked callers | Total | -|---|---:|---:|---:| -| Opaque or indirect call | 35 | 18 | 53 | -| Raw-address conversion | 11 | 10 | 21 | -| Variable-size allocation | 2 | 2 | 4 | -| Recursion | 1 | 2 | 3 | -| Total | 49 | 32 | 81 | - -These are first-cause counts, not independent fixes or predicted acceptance -after removing a barrier. For example, `sys.aryu8._grow` accounts for 16 rejected -summaries including itself. Its first rejection is the `_exit(1)` call used for -overflow failure, but it also allocates a variable-sized array. Accepting that -call alone would not make growth work. - -Independent inspection of the collected IR finds 21 variable-sized NewNodes -across 19 `sys` functions. Only two functions currently report that as their -first direct failure: `sys.text.end` and `sys.adt.bitset._grow`. - -There were no first-reported loop-retention, cyclic-field-path, or unmapped-origin -failures in this library cohort. Earlier rejection barriers can hide them. - -## The examples - -These use the normal precompiled `sys` library. Counts include only each -example's own functions, avoiding repeated counts of imported library exports. -The compiler may load and inline imported bodies; some others remain opaque. - -| Example | Accepted / total | Accepted with allocations | Representative failure | -|---|---:|---:|---| -| Hello world | 0 / 1 | 0 | String address passed to output | -| BubbleSort | 2 / 4 | 0 | Output; sorting itself passes | -| Capitalize | 1 / 2 | 0 | Output; main also has a variable-sized array | -| FileIO | 1 / 4 | 0 | Native I/O and raw addresses | -| Dijkstra | 1 / 4 | 0 | Bitset growth; output | -| Graphics | 1 / 2 | 0 | Raw address passed to graphics | -| Clock | 3 / 7 | 0 | Graphics/time pointers; scalar libm calls | -| Breakout | 19 / 24 | 3 | Input/audio/graphics calls | -| TicTacToe | 4 / 8 | 0 | I/O, growth, an opaque imported `sys.ary.capacity` | -| TicTacToeGraphical | 11 / 12 | 0 | Main's graphics boundary | - -No example's `main` receives a complete supported plan; hello world's executable -class initializer is rejected too. High per-function acceptance is not yet a -working automatically managed program. - -## Analysis improvements versus storage decisions - -| Case | What is missing | Likely action | -|---|---|---| -| Clock's `sin`/`cos`, clocks, input polling, `_exit` | Known native behavior is treated as opaque | Targeted native contracts/recognition; no application rewrite should be needed | -| Array passed to synchronous I/O or copying audio loader | Lifetime/provenance is lost at conversion to `i64` | Wrapper contract and provenance tracking through the native call | -| Opaque imported Simple function | No serialized allocation summary | Export/import lifetime summaries; avoid changing source merely to force inlining | -| Runtime-sized local scratch array | Immediate rejection of nonconstant size | Keep the lifetime result and represent a runtime size; later lower a local reservation | -| Finished variable-sized result, such as `sys.text.end` | Caller needs storage whose size the callee discovers | Destination/buffer/region choice under the agreed design; possibly a small library rewrite | -| Replaced vector/Canvas backing array | Dynamic sizing plus proof that old aliases are no longer usable | Analysis for reclaiming old buffers; explicit storage policy where proof fails | -| Fixed-size object repeatedly replacing `Holder.c` | Weak updates never kill the old reference | Overwrite/liveness analysis; this is not inherently unbounded storage | -| `Timers._add` retries recursively after growing | SCC support, plus three variable-sized arrays | Defer SCCs; changing the retry to a loop alone would not solve storage | - -Native scalar signatures must not be accepted indiscriminately: an `i64` may -carry a raw pointer. Contracts must describe the actual wrapper, including -whether it retains a passed address or creates returned storage. - -One concrete native allocation requires attention: -[`simple_text_float`](../src/main/c/simple_crt.c) uses `malloc` to create a -Simple-format byte array and returns it. There is no Simple NewNode for that -allocation. A non-retaining-call annotation is insufficient: the result needs -an allocation/ownership contract, or the wrapper should write into caller-provided -storage. This is a useful first native-interface design case. - -The separately compiled [`simple_args`](../src/main/smp/sys/rt/simple_args.smp) -has two variable-sized allocation sites: an outer reference array and byte -arrays created inside its initializer loop. Its first rejection is the raw -destination passed to `memcpy`. Beyond that contract, it exercises the planned -collection destination and variable-sized returned graph. - -## Small reductions - -The survey probe also compiles four isolated cases, without native calls: - -| Probe | Result | -|---|---| -| Allocate `i64[n]`, fill/read it, return a scalar | Rejected: variable-size allocation | -| Return a freshly allocated `i64[n]` | Rejected for the same reason, despite a different storage problem | -| Repeatedly replace `h.c` with a fresh fixed-size Thing, then read the last one | Rejected: Thing survives the backedge | -| Allocate one mutable Thing before the loop, overwrite its scalar field, borrow it each iteration | Accepted: one Thing in the function frame | - -The overwrite reduction has no saved reference to an older Thing. It needs an -analysis improvement, not a language prohibition. Reusing one mutable object -is a possible rewrite for that particular program, not a general replacement -for allocations with distinct observable identities. - -## Suggested next work - -First, admit a small audited set of scalar native calls and specify borrowing -for the common array wrappers. Preserve those contracts across imported calls. -That removes the largest observational barrier without tackling SCCs. - -Then distinguish local variable-sized scratch from returned/growing storage, -and tackle the fixed-size overwrite proof. Re-run this survey after those steps; -the first-cause distribution should become much more informative. - -For an initial lowering implementation, the passing Game, Timers, byte-vector, -and DateTime factories already supply useful fixed-size object graphs. Use them -alongside the existing scratch/winner poster children. Do not wait for every -library operation to pass before validating real storage placement. - -## Reproduction and limitations - -[`AllocationSurvey.java`](AllocationSurvey.java) is a standalone observational -probe. It reads private analysis collections by reflection rather than adding -production compiler APIs. It does not change contracts, suppress rejections, -link native code, run games, or lower allocation plans. -The [function-level snapshot](allocation-survey-functions.tsv) contains the -cohorts above and the four reductions, with first-cause chains and site counts. -Full dumps, allocation sites, and call lists are written under -`build/allocation-survey/<name>-<mode>/`. - -From `chapter33`, after building the Java compiler and the normal `sys` objects: - -```powershell -javac -cp build/classes/main -d build/allocation-survey docs/AllocationSurvey.java -java -ea -Xss16m -Xmx2g -XX:ActiveProcessorCount=2 -cp 'build/classes/main;build/allocation-survey' AllocationSurvey sys source -java -ea -Xss16m -Xmx2g -XX:ActiveProcessorCount=2 -cp 'build/classes/main;build/allocation-survey' AllocationSurvey Clock object -java -ea -Xss16m -Xmx2g -XX:ActiveProcessorCount=2 -cp 'build/classes/main;build/allocation-survey' AllocationSurvey OverwrittenSlot probe -``` - -Use each example's filename without `.smp`; modes are `source` and `object`. -`RuntimeArgs source` compiles the native-startup helper. Probe names are -`LocalArray`, `ReturnedArray`, `OverwrittenSlot`, and `ReusedObject`. -On bash use `:` instead of `;` in the classpath. - -The auxiliary all-source run succeeds for hello world, BubbleSort, Capitalize, -and Breakout. Breakout's own 19/24 result is unchanged with library source visible. -The other six examples stop in Parse on qualified `sys` types, before Allocation; -they are not counted as lifetime failures. The source-mode probe prepends a -private `sys` binding to request library discovery; that does not resolve those -type-name failures. A first all-source Breakout run exhausted the default Java -stack in `Node._walk`; all reported runs use `-Xss16m`. - -Counts use seed 456 and optimized IR, so inlining and dead-code removal affect -which sites and functions remain. They measure the current conservative analysis, -not runtime allocation frequency, memory saved, or proof that future lowering is -correct. Existing compiler files were not changed for this survey. diff --git a/chapter33/docs/array-delete-survey.md b/chapter33/docs/array-delete-survey.md deleted file mode 100644 index 82303acb..00000000 --- a/chapter33/docs/array-delete-survey.md +++ /dev/null @@ -1,141 +0,0 @@ -# Deletable-array source survey - -2026-11-23. Five production resize implementations, seven source deletion sites. -The compiler now accepts `E[^]`, `new E[^N]`, and `.del()` and requires an ownership -proof at TypeCheck. Runtime recycling remains unimplemented. - -| Source | Local deletion check | Full TypeCheck | -|---|---|---| -| [aryu8._grow](../src/main/smp/sys/aryu8.smp) | Grow/add/append, string/integer formatting, and `aryi64.str` compose | Reject: native boundaries in file input, floating formatting, and calendar formatting | -| [aryi64._grow](../src/main/smp/sys/aryi64.smp) | Initializer and repeated `add` calls compose | Pass, including `parseAryI64` | -| [bitset._grow](../src/main/smp/sys/adt/bitset.smp) | Contract propagates through `set` and `tset` | Pass | -| [Timers._add](../src/main/smp/sys/time/Timers.smp) | Consuming recursion not supported | Reject | -| [Canvas.resize](../src/main/smp/sys/draw/Canvas.smp) | Consuming `self.pixels` contract inferred | Pass | - -No compiler crashes remain in the final sweep. Initially four cases asserted on -an array `.del` field offset: the receiver became an array only after parsing. -Deferred member resolution now folds that load to the intrinsic. The added -generic receiver signature also exposed an abstract-pointer type-upgrade bug; -abstract struct bounds now remain bounds instead of being looked up as classes. - -The source-level poster children in Chapter33Test pass: local arrays, replacement -of a locally constructed owner's buffer, borrowing helpers, list/generator -initializers, and serialized/imported deletion bodies. Saved aliases and -double deletion reject. Extracting an element reference does not retain its -backing array. Incoming ownership becomes a checked function requirement; callers -must discharge it or propagate it in their own contract. A library can therefore -pass TypeCheck while retaining requirements for future callers. - -## What the failures tell us - -Known native `_exit` calls now retain normal call control but return `TypeMem.TOP` -memory and `TypeScalar.TOP` values. The machine call remains; mixed or unknown -targets remain conservative. This removes `_exit` from the merged memory effects -without adding an exceptional CFG edge. - -The earlier reduced case's redundant `Test.$init` guard is handled: loads recover -the initialized flag through whole-memory parameters when every live incoming -path proves it. Variable-sized `[^]` allocations are planned as buddy storage. - -Its replacement, `testArrayDeleteAryu8IntegerInit`, reads `sys.integer.MAX_U32` -directly and imports the release library, isolating remote initialization from -`ary.capacity` and `ary.copy`. The saved summary now records the function's own -written aliases, reference-write flag, and escaping identities. Incoming memory -and unrelated functions' escapes are not part of that contract. Effects compose -through calls, including recursive and nonreturning paths. The initializer has -no reference writes. The local proof produces a consuming requirement, and the -fresh-wrapper caller discharges it; the test now passes TypeCheck. - -This removes `sys.ary.capacity` and `sys.integer` as blockers in the production -sweep. Allocation contracts now survive serialization too: `ary.copy` returns -its `dst` argument, allocates no storage, and writes no references. The deletion -checker follows returned argument aliases, allowing this copy while still -rejecting uses of an old array through a returned alias after deletion. -`testArrayDeleteAryu8Copy` exercises the actual imported contract without loading -the copy implementation; its fresh-wrapper caller now passes too. Caller checks -use the buffer's entry identity: saved aliases reject, but a reload of the -replaced field is valid. Requirements survive forwarding and serialization. - -The repeated-checkpoint restriction is now removed. `testArrayConsumeGrowLoop` -passes, as do nested loops, breaks, fresh allocation/deletion per iteration, and -loops calling an imported forwarder. The backedge check rejects saved array -references and verifies the callee preserves an exclusive owning field. A helper -that publishes an alias of its replacement cannot satisfy that proof. -Copies of the replacement crossing the backedge are conservatively rejected, -even when the next iteration could use and discard them before its next grow. - -The two-grow example now passes (`testArrayConsumeTwoGrows`). The checker follows -memory SSA; it substitutes each call's field stores and returned origins at that -call's memory output. A proven unique outgoing field provides a new ownership -version, even on a no-growth path. Loop heads provide iteration-entry versions, -so several grows per iteration do not confuse prior and current buffers. The -initializer-specific proof was replaced by this general call substitution. - -String formatting needs both a writable builder and a borrowed input array. -Its unique-buffer requirement excludes an alias in that input parameter; callers -check their actual arguments. Passing the builder's own buffer rejects. Distinct -wrapper parameters are still allowed to alias, so their field paths cannot gain -this disjointness assumption merely by having different names. - -## Checkpoint for design review - -The latest sweep passes the complete `aryi64`, `bitset`, and `Canvas` migrations. -Within the `aryu8` migration, `_grow`, `add`, `addAry`, `num`, padding, string and -integer formatting, `aryi64.str`, and elapsed-time formatting pass their checks. -The remaining failures are: - -| Boundary | Current rejection | -|---|---| -| `sys.io.read` | Native `read` has no usable pointer-memory effect contract | -| Floating formatting | `simple_text_float` returns storage with unknown origin | -| Calendar formatting | `sys.time.local` carries unmodeled native effects | -| Timers | Recursive consuming groups lack allocation/ownership contracts | - -The storage graph is still flow-insensitive. It supplies conservative may-stores -and the proof of unique outgoing fields; the deletion checker applies those -facts in memory order. Arbitrary callee overwrites do not yet prove an alias was -cleared. Other conservative limits remain: replacement aliases carried across -iterations, cyclic reference queries, multiple incoming ownership paths, and -array-element ownership slots requiring index proofs. These are useful targets -for the architecture review rather than more library-specific exceptions. - -IR format 8 records whether raw/native/initialization effects are absent from -the field graph. Such summaries remain opaque to ownership composition, also -after serialization. Tests cover unsafe saved aliases, helper retention, actual -argument aliasing, multiple grows per iteration, imported forwarders, and an -imported raw-address store. The headless test suite passes. No compiler crashes -occurred in the sweep. Runtime recycling remains unimplemented. - -## Reproducing the sweep - -[ArrayDeleteSurvey.java](ArrayDeleteSurvey.java) copies `src/main/smp` into a fresh -directory under `build/array-delete-survey`, changes one library per case, then -compiles the whole source `sys`. It does not alter production files or run Simple -code. Each migration marks backing arrays and their allocations `[^]`, saves the -old references, publishes replacements, and calls `.del()` on the old buffers. -For aryi64 it also changes the owning constructor parameter and its factory's -initial allocation; arbitrary caller arrays cannot simply acquire the capability. - -From chapter33, compile the runner: - -```text -javac -cp build/classes/main -d build/array-delete-survey docs/ArrayDeleteSurvey.java -``` - -PowerShell or cmd: - -```text -java -ea -Xss16m -Xmx2g -XX:ActiveProcessorCount=2 -cp "build/classes/main;build/array-delete-survey" ArrayDeleteSurvey -``` - -Bash on Unix: - -```sh -java -ea -Xss16m -Xmx2g -XX:ActiveProcessorCount=2 -cp 'build/classes/main:build/array-delete-survey' ArrayDeleteSurvey -``` - -The runner prints the output directory. It contains migrated sources, a -`results.tsv` with every deletion result, and source diagnostics for rejected -compilations. Java exceptions/assertions are recorded separately as crashes. -Adding `-Dsimple.delete.graph=true` also saves the IR and allocation dump for each -case. Quote that option in PowerShell. diff --git a/chapter33/docs/examples/Breakout.smp b/chapter33/docs/examples/Breakout.smp index d60894ac..ecb7fc26 100644 --- a/chapter33/docs/examples/Breakout.smp +++ b/chapter33/docs/examples/Breakout.smp @@ -246,12 +246,12 @@ struct Game { int mouse = c.localX(gfx.mouseX()); // Restart requested - restartHeld = debounce( restart, restartHeld, { -> _reset(); sys.audio.stop(); } ); + restartHeld = _debounce( restart, restartHeld, { -> _reset(); sys.audio.stop(); } ); // Playing or ready to play game? if( phase == READY || phase == PLAY ) { // Flip pause state - pauseHeld = debounce( pause, pauseHeld, { -> paused = !paused; } ); + pauseHeld = _debounce( pause, pauseHeld, { -> paused = !paused; } ); // If no key and mouse moved, set paddle to mouse if( mouse >= 0 && mouse != lastMouse && direction == 0 && !paused ) { @@ -264,13 +264,13 @@ struct Game { } // Serve requested - serveHeld = debounce( serve, serveHeld, _serve ); + serveHeld = _debounce( serve, serveHeld, _serve ); // Return key direction, so the tick tracking can slide paddle smoothly return direction; }; - val debounce = { bool b, bool bHeld, { int } action -> + val _debounce = { bool b, bool bHeld, { int } action -> if( b && !bHeld ) // Action requested and repeating action(); // Do action b; // Dont action again, until 'b' is released diff --git a/chapter33/docs/growing-arrays-survey.md b/chapter33/docs/growing-arrays-survey.md deleted file mode 100644 index 13fd93d0..00000000 --- a/chapter33/docs/growing-arrays-survey.md +++ /dev/null @@ -1,230 +0,0 @@ -# Growing arrays: where grow-in-place fits - -Surveyed 2026-11-21. Most current byte builders have a single construction -phase and could finish as ordinary arrays. The persistent counterexamples are -bitsets, timers, and canvas buffers. The choice belongs to a use of a collection, -not to every instance of `aryu8` or `aryi64`. - -This is a source survey, not an implemented placement proof or a runtime profile. -It covers chapter33's Simple library, examples, Simple programs embedded in Java -tests, and retained regression workloads. Earlier chapter copies are not counted -again. Compiler Java collections appear separately as future Simple-in-Simple -requirements. No language or library behavior changed during the survey. -The [first source rewrites](growing-array-rewrites.md) show BrainFuck and direct -block reads using scope-ended growth and a proposed writable array length. - -## Construction that finishes - -“Candidate” below means growth has a recognizable end. It does not yet prove -that the physical allocation end is free, or solve returning variable-sized data. - -| Code | Observed growth and subsequent use | Grow-in-place assessment | -|---|---|---| -| [Interpolation](../src/main/java/com/seaofnodes/simple/parser/Strings.java), [text.integer/string](../src/main/smp/sys/text.smp) | Parser creates one builder, appends literal pieces and formatted expressions, then calls `end`. Integer formatting uses a fixed 22-byte digit scratch array. | Strong candidate. Fixed scratch needs placement before/beside the growing storage; formatting helpers need to borrow the active builder. Arbitrary interpolation expressions can introduce nested allocation. | -| [text.floating/time](../src/main/smp/sys/text.smp) | Both obtain a temporary string and append it to the outer builder. `floating` gets a native allocation; `time` calls another Simple formatter. | Candidate after arranging temporary storage or changing to destination-writing helpers. Not automatically one free growing end; see below. | -| [aryi64.str](../src/main/smp/sys/aryi64.smp) | Appends brackets, numbers, and separators, removes the final separator, then returns the builder. [BubbleSort](examples/BubbleSort.smp) and [StreamIOTest](../src/test/java/com/seaofnodes/simple/StreamIOTest.java) append a newline afterwards. | Construction is localized, but its present API returns a still-growable value. Prefer an append-into-destination formatter, with the caller adding the newline before finishing. | -| [parseAryI64](../src/main/smp/sys/aryi64.smp) | One scanner and one result vector; append parsed numbers, validate closing syntax, return. BubbleSort sorts the result; Dijkstra only reads it. Neither appends more numbers. | Strong candidate for a finished mutable `i64[]`. Freeze length, not element stores. Returned variable-sized storage still needs a destination. | -| [io.read](../src/main/smp/sys/io.smp) | Allocates an 8 KiB scratch chunk before starting the builder. Reads until EOF, appends each received prefix, then copies to an exact-length result. Errors discard the partial result. | Strong candidate. The scratch buffer is already separate from the growing output. Finish could avoid the final copy if the result's lifetime and placement permit it. Keep short-read/EINTR/error behavior. | -| [BrainFuckTest](../src/test/java/com/seaofnodes/simple/BrainFuckTest.java) | One output builder, one fixed 100-byte tape, no other growing collection in the interpreter. Output is consumed only after execution finishes. | Strong candidate. Place the fixed tape before the growing output, or in reserved fixed storage. Finish at interpreter exit; the current wrapper-return API needs changing or an explicit result destination. | -| [TicTacToe._draw](examples/TicTacToe.smp) | Builds one board rendering and immediately writes it. No builder escapes. | Simplest local candidate. This particular rendering is exactly 60 bytes, so a fixed array also suffices. | -| [FileIO](examples/FileIO.smp), [Dijkstra's diagnostic output](examples/Dijkstra.smp) | FileIO builds its message before opening/writing/reading the file, then compares it with the readback. Diagnostics build and write once. | Finish FileIO's message before later I/O allocations; its storage remains live for comparison. The literal message can also be sized exactly. Diagnostics are local builders. | -| [time._format/elapsed/zoneName](../src/main/smp/sys/time.smp) | Formatters build and finish one result. `zoneName` first fills a fixed 128-byte buffer, learns `n`, then builds another buffer and copies again in `text.end`. | `_format`/`elapsed` are localized builders. `zoneName` needs no growing array: after the native call, allocate exactly `n` bytes and copy once. All returned results retain the destination question. | - -The [original BrainFuck workload](../src/test/java/com/seaofnodes/simple/spill/BrainFuckTest-testBrainFuck.smp) -does `new u8[output# + 1]` and copies the old output on every `.` command. -For N emitted bytes that copies N(N-1)/2 old bytes, in addition to writing the -N new bytes. It is the clearest avoidable-copy example. The aryu8 version already -uses geometric growth. Keep the historical workload if its purpose remains -cross-target compiler comparison; add a new builder version alongside it. - -## Growth interleaved with continued use - -The production Simple library has five implementations that replace backing -arrays to increase capacity: `aryu8`, `aryi64`, `bitset`, `Timers`, and `Canvas`. -Timers replaces three arrays together. The first two support the construction -cases above; the other three illustrate why we still need another storage choice. - -| Code | Why a single temporary construction scope is insufficient | Suitable direction | -|---|---|---| -| [adt.bitset](../src/main/smp/sys/adt/bitset.smp) | Random indexed `set`/`tset` can increase capacity between reads, clears, and other work. | General instance: retain a replaceable backing array or use chunks. [Dijkstra](examples/Dijkstra.smp) knows the bit universe from `nodes`, so reserve `(nodes+63)/64` words before its loop instead. | -| [time.Timers](../src/main/smp/sys/time/Timers.smp) | IDs, deadlines, and periods grow together; registration, cancellation, and polling interleave. [TimeTest](../src/test/java/com/seaofnodes/simple/TimeTest.java) forces growth past eight slots. Clock itself registers only one timer. | A mini-arena owned by the Timers instance can hold replacement arrays. Alternatively, fixed chunks of inline timer entries would avoid copying and exercise value objects; that is a representation change, not just append syntax. Three independent arrays cannot all own one contiguous growing end. | -| [draw.Canvas.resize](../src/main/smp/sys/draw/Canvas.smp) | Capacity increases across window events, interleaved with drawing, timers, and text formatting. Smaller sizes reuse capacity. On growth the old pixels are discarded, not copied. | Retain replacement-buffer behavior in the Canvas lifetime group. A deliberately reserved non-moving region is plausible for a small number of windows, but should be an explicit choice. Chunking pixels directly would change the contiguous graphics interface. | - -The generic aryu8 API also permits `clear`, `undo`, reads, and later appends. -[StreamIOTest](../src/test/java/com/seaofnodes/simple/StreamIOTest.java) exercises -that mutable-container behavior. The small `_Vec` in -[Chapter21Test.testArmVectorGrowth](../src/test/java/com/seaofnodes/simple/Chapter21Test.java) -is another explicit doubling/copy implementation outside sys. Its particular -caller builds five integers in one expression; the generic type allows later -growth. The frozen BubbleSort and seed-reproduction sources contain older copies -of the same byte/integer vector pattern. - -## Two constraints exposed by the survey - -### Explicit containers for interleaved growth - -Discussion direction: infer one active growing end, with properly nested -temporary work allowed. If multiple live arrays need interleaved extension at -that end, reject with a concrete rewrite path. Do not automatically synthesize -independent regions or a general collector to preserve the source representation. - -A proposed diagnostic at the failed extension: - -```text -Cannot extend 'ids' here: live storage for 'due_ms' follows it. - 'ids' starts growing at ... - 'due_ms' is allocated at ... and is still needed at ... -Use one array of inline timer entries, or explicit resizable containers -such as aryu32 and aryi64 for independently growing buffers. -``` - -This diagnoses unavailable tail space while growth is still permitted. Trying -to grow an array whose constructor has already ended instead reports that its -length is fixed, with the constructor boundary and the attempted growth shown. - -For Timers the programmer can choose either representation: - -- Array of inline Timer entries containing id, due, and period, with explicit - resize logic. Under the previously agreed notation this is `new *Timer[8]` - (with appropriate element initialization), rather than an array of Timer - references. No per-entry object allocation or pointer chase is required; - padding and field-scan locality can still differ from struct-of-arrays. -- Keep the struct-of-arrays layout, using three explicit container instances: - one aryu32 and two aryi64 collections. These containers need not own the - shared stack's growing end. - -Agreed allocator direction: growable containers use power-of-two backing arrays -and deleted backing arrays are recycled through a buddy allocator. Resize obtains -a larger chunk, copies the used elements, publishes the replacement, and calls -`old.del()` to retire the old backing allocation. This moving representation -does not promise stable -direct interior references through resize. Container/index handles and copied -primitive/reference values remain useful interfaces. - -Agreed safety rule: a deletable array has a different type from an ordinary -array; its provisional modifier is `^`. It disallows interior references and -requires unique access and no escaping aliases. Deletion consumes the owning -access, with no outstanding borrows or other usable aliases surviving it. -The compiler checks this rule; it is not an unchecked promise by the library. -Copied primitive elements and copied object references are not references into -the backing storage. Container/index handles can resolve through the current -buffer without retaining the retired one. - -In resize, replacing the container's backing field removes that owning access -to the old buffer; the local `old` then supplies the access consumed by delete. -If another usable alias remains, diagnose that alias and the attempted deletion. -Ordinary arrays retain their automatic-lifetime behavior and cannot be deleted. -Raw-address borrowing must also respect the no-surviving-use requirement. - -This differs from deletable class slots, whose stale references remain type-safe. -Buddy splitting/coalescing can change the array extent and layout. An old array -header can become element data after reuse, so even bounds checks can read the -wrong length. Merely preserving the element type is not enough to inherit the -class-slot post-delete guarantees. The agreed uniqueness rule excludes those -stale accesses, allowing the buddy allocator to recycle the whole block. -Moving the length field out of the allocation is therefore not needed for this -safety argument; it remains a separate, useful layout optimization. -The same buddy allocator can serve every element type and keep metadata inside -freed blocks. Automatic deletion on a proven last-reference overwrite is deferred; -the first interface uses explicit `.del()`. The -[first ownership experiment](../README.md#array-deletion-first-ownership-checks) -now accepts source `E[^]` and `.del()` and checks local aliases and field kills. -The [migration survey](array-delete-survey.md) records which real resize bodies -pass these local checks and which proof obligations remain. The runtime -intrinsic is not implemented yet. - -`text.begin()` currently returns a newly created builder. For the proposed -scope-owned growing array, interpolation should establish that storage in the -expression's owning scope, then let helpers borrow it. Keeping `begin()` unchanged -and hoping the inliner erases its call would make a language lifetime rule depend -on optimization. The same issue applies to factories returning fresh growable -wrappers; it is separate from a helper appending to an existing destination. - -One logical builder does not imply one free physical end. For example, -[Clock._draw](examples/Clock.smp) interpolates `sys.time.formatLocal(...)` into -an outer string. The outer builder is started before that expression is evaluated. -The inner formatter returns its finished array, then the outer builder grows -while reading that array. With both on the same growing end, the inner result -still occupies the space the outer wants. This is not the easy nested case where -the child has unwound before the parent resumes growing. - -Agreed follow-up: append time formatting directly into a supplied destination. -For floating formatting, pre-grow the destination by a sufficient bound, pass -the writable tail and its capacity to the C helper, and receive the actual byte -count. Trim the unused tail afterwards. The helper fills the destination directly; -it does not allocate a returned string or copy from an intermediate output array. -The bound must account for the value, format, width, precision, and any terminating -NUL needed by the C implementation. The NUL is not part of the final string length. -The existing [simple_text_float](../src/main/c/simple_crt.c) still allocates; -changing it to this interface remains implementation work. - -Arbitrary interpolation expressions follow the ordinary rules for code executing -inside any growable-array constructor. Their allocation/lifetime plan must leave -the required growing end free when extension resumes. If no legal plan exists, -the normal allocation analysis rejects the program. There is no separate -interpolation allocation rule. Helpers growing a caller's destination likewise -use the general call-frame placement rules. - -The agreed return destination is now a separate growable data stack. `io.read`, -parsed number arrays, formatted strings, and BrainFuck results finish growth -before returning; their bytes survive the callee's control frame. The hidden -data-stack top is updated on return, and the owning lifetime later restores its -mark. This supplies contiguous non-moving storage without a final copy; lowering -and the calling convention remain implementation work. - -## Aliases and future inline elements - -Backing-array references are already observable, even without interior pointers: - -- `aryi64` accepts a caller-provided backing array; it need not own the only reference. -- `buf`/`pixels` are exposed. StreamIOTest saves `b.buf`; DrawTest saves old and - grown pixel arrays and checks reuse when resizing within capacity. -- `text.end(b)` currently copies into a read-only array and leaves `b` usable. - A consuming finish operation changes that contract. Existing callers that are - done with `b` can migrate; the general API cannot silently change meaning. -- `aryi64.str()` callers demonstrably continue growing the returned value. - -A mini-arena makes its allocated blocks stationary. It does not make a vector -stationary if the vector later copies its contents into a larger block. An -array of future inline objects can promise stable direct interior references -only with the non-moving choice; those references also inherit the backing -storage's lifetime. Movable containers can expose values or `(container,index)` -handles instead. Truncating/clearing and reusing inline slots will need its own -reference-validity rule, even when the storage address stays fixed. - -Old backing arrays cannot be recycled merely because the wrapper now points to -a new array: another reference may still name the old one. Retaining all blocks -until the lifetime group unwinds is the simple safe policy. Earlier recycling -needs proof that those references are gone. Allocator chunk recycling here is -distinct from the language's explicit `delete` and its weaker post-delete rules. - -## Compiler collections: future Simple-in-Simple cases - -| Existing Java use | Storage implication | -|---|---| -| [Node inputs/outputs](../src/main/java/com/seaofnodes/simple/node/Node.java), backed by [Ary](../src/main/java/com/seaofnodes/simple/util/Ary.java) | Many independently growing collections, mutated throughout optimization. Embedded small vectors plus overflow storage fit; one reserved growing region per Node does not. Entries currently hold references, not inline Nodes. | -| [CodeGen linker/call/CFG lists](../src/main/java/com/seaofnodes/simple/codegen/CodeGen.java) | Broad lifetimes, but several lists grow interleaved. Being long-lived does not alone make their ends free. Separate explicit areas or a common chunk allocator are options. | -| [Serialize.write](../src/main/java/com/seaofnodes/simple/codegen/Serialize.java), [Lexer.stringPart](../src/main/java/com/seaofnodes/simple/parser/Lexer.java) | Local output accumulation followed by a completed byte result. Candidates for finishable builders, subject to helper temporaries and the return destination. | -| [Encoding](../src/main/java/com/seaofnodes/simple/codegen/Encoding.java), [BAOS](../src/main/java/com/seaofnodes/simple/util/BAOS.java) | Instruction bytes, constant data, and writable data have separate buffers; emission also creates metadata, patches earlier bytes, and can replace the instruction buffer during compaction. This needs an explicit layout plan or independent buffers, not blanket conversion of BAOS. | -| [IntHashMap](../src/main/java/com/seaofnodes/simple/util/IntHashMap.java) | Growth rehashes entries. Reserving more address space does not remove that semantic relocation. A future inline-entry reference cannot promise stability through rehash. | - -The native MiniFB adapter has a separate resizable repaint buffer in -[simple_minifb.c](../src/main/c/simple_minifb.c). It copies the Simple pixels; -the retained native buffer is not a retained pointer into the Simple array. - -## Suggested first cases - -1. BrainFuck output: one unknown-length append stream, fixed scratch, finish; - first consume it within the same activation to isolate growth from return placement. -2. `io.read`: chunked input, error unwind, and a finished variable-sized result. -3. Integer/string interpolation, then nested time formatting: borrowed builder - helpers, fixed scratch, and the first real competing-temporary case. -4. Timers: persistent growth and three coupled arrays; compare grouped replacement - buffers with chunks of inline entries rather than forcing it into the first case. - -Some current variable-size failures are not growing arrays at all: `str0`, -`Canvas` construction, and `text.end` know their length when they allocate. -Supporting runtime-sized fixed arrays is independently useful. This survey does -not predict a new accepted-function count: the current pass also rejects loop -retention, returned variable-sized storage, and recursive Timers._add before -these proposed storage representations exist. diff --git a/chapter33/docs/growing-array-rewrites.md b/chapter33/docs/growing-arrays.md index cd9257d3..4a0d5046 100644 --- a/chapter33/docs/growing-array-rewrites.md +++ b/chapter33/docs/growing-arrays.md @@ -1,11 +1,11 @@ -# Growing arrays: first source rewrites +# Scope-owned growing arrays -Design notes, 2026-11-21. Writable array length and the constructor return rules -below are agreed; the parser and allocator do not implement these examples yet. -They follow the -[growing-array survey](growing-arrays-survey.md). +This is the selected language and storage design, with illustrative source +examples. Writable array length, whole-array construction scopes, and growable +data-stack lowering are not implemented. See [memory management](memory-management.md) +for the analysis and storage-policy boundary. -The proposed rule is: `new E[]` creates an initially empty array whose growth +The selected rule is: `new E[]` creates an initially empty array whose growth belongs to the allocating lexical scope. Leaving that scope ends growth, including returning the array. Its storage can outlive that scope; its permission to grow cannot. Element mutation remains allowed. Returning from a helper that @@ -108,24 +108,13 @@ state remain. Cleanup must preserve errno. References into abandoned storage must not survive its reclamation; the lifetime check includes the failure edge. -### Other exit spellings considered - -- `self = null` with an implicit exit hides control flow in assignment; rejected. -- `self = null; break` separates the failure marker from the exit, makes self - nullable inside the body, and normally breaks only the innermost loop. Avoid it. -- `self# = -1; break` violates the valid-length invariant and overloads an unsigned - length with an error sentinel. Negative lengths remain invalid. -- `break null` could be part of a general value-producing loop/block design, but - here it needs a new target rule: does it exit the loop or the constructor? - A labeled value-break could disambiguate it, at the cost of more syntax. - -The chosen forms are `return self` / `return null`, ordinary loop breaks, and implicit -successful completion at the constructor's closing brace. No magic assignment, -negative-length sentinel, or dedicated finish keyword is required. +Explicit returns keep completion distinct from mutation: assigning null to self +would hide control flow, a negative length would violate the length invariant, +and an ordinary break belongs to the nearest loop. No finish keyword is needed. ## Growing and trimming with `#` -Try extending the existing length notation rather than adding a finish keyword: +Extend the existing length notation during construction: | Expression | Proposed meaning during construction | |---|---| @@ -224,7 +213,7 @@ than the old implementation's possible full extra chunk. No regular read chunk and no final copy remain. Physical alignment or mapped-page slack can remain after trimming; the logical result length is exactly `used`. -## What these examples settle, and what they do not +## Placement and borrowing constraints Floating formatting uses the same extend/fill/trim pattern as direct I/O: remember the current length, extend by enough space for the requested format, @@ -257,3 +246,27 @@ different: references into the removed tail must be gone before that storage is reclaimed or reused. For these byte programs there are no typed interior references, and the native borrow ends before the final trim. Future inline objects need that restriction; non-moving alone does not make shrinking safe. + +## Persistent containers + +Finishable builders and persistent resizable containers have different needs. +A byte stream, rendered string, or parsed number array can end growth at a +lexical boundary. Timers, bitsets, and Canvas pixel buffers grow between unrelated +operations and need an explicit container/storage policy. Consolidating coupled +timer arrays into entries can simplify placement; it does not remove other live +growth at the same stack tip. The storage heuristic may choose another growth +stack, replacement buffers, or report an unsupported layout. + +Backing-array aliases are observable. Replacing `v.buf` or `Canvas.pixels` does +not by itself authorize recycling the old array. An `E[^]` deletable array needs +proof that no usable aliases or raw-address borrows survive deletion. Ordinary +arrays retain their automatic-lifetime behavior. Buddy allocation can reuse the +array header only after this proof; type-compatible element storage alone cannot +make a stale length field safe. These ownership proofs and runtime recycling +remain unimplemented. + +Time formatting should append into a supplied destination. Floating formatting +can use the extend/fill/trim protocol above, with a bounded native helper writing +directly into the destination. Arbitrary interpolation expressions obey ordinary +lifetime and growth-placement rules: a retained inner result can obstruct the +outer array's next extension. diff --git a/chapter33/docs/memory-management.md b/chapter33/docs/memory-management.md new file mode 100644 index 00000000..29461b99 --- /dev/null +++ b/chapter33/docs/memory-management.md @@ -0,0 +1,368 @@ +# Points-to, ownership, and storage + +## Scope and architecture + +Allocation2 computes allocation-site points-to facts after Opto, FinalizeIR, and +LoopTree, before TypeCheck. It is the only allocation-analysis phase. It does +not prove ownership, select storage, insert deletion, or implement recycling. +Separate-compilation analysis is incomplete; its results must not authorize +reclamation yet. + +The design separates three jobs: + +1. Analyze references, ownership/borrows, lifetime boundaries, multiplicity, + object sizes, and interference. +2. Choose storage with a heuristic. Every outcome is a concrete plan or an + explicit unsupported diagnostic. +3. Lower the plan into frame slots, allocations, resets, and reclamation. + +This separation keeps policy changes independent of the safety facts they use. +A may-points-to set records possible aliases; it cannot by itself prove that an +overwrite removed the last usable reference. Temporal proofs need memory order +and reference liveness. Ownership additionally needs relationships between +concrete objects represented by the same allocation site. + +## (1) Points-to analysis + +### Object abstraction and precision + +Each optimized NewNode denotes one abstract Site, potentially representing many +runtime objects. Static constant objects have separate Sites. Distinct NewNodes +of the same class stay distinct. TypeStruct supplies the layout; each Site owns +its reference-field facts, indexed in TypeStruct field order and looked up by +field alias. Array indices share the `[]` field. + +The analysis is interprocedural and context-insensitive over the remaining IR. +Parameters merge live actuals and calls share their callee's result facts. +Earlier inlining supplies context precision by cloning code. There are no +per-call analysis copies. A shared factory therefore has one abstract allocation +even when two calls produce different concrete objects. + +This gives a small finite abstraction with ordinary monotone constraints. The +cost is loss of call-site correlation, array-index precision, and temporal field +contents. A set containing one Site is not proof of one concrete object. +Bounded repetition belongs to earlier optimization: unrolling four allocations +gives four NewNodes; this pass does not add exact-count analysis. + +Recursion is deferred for lifetime placement. Cyclic points-to constraints have +a finite domain, but convergence does not prove a recursive storage policy. +The intended later model treats a recursive call SCC as a loop-like unit. +[Recency abstraction][recency], distinguishing the newest object from older +summary objects, is an optional future precision improvement. + +### Facts and worklist + +```text +P(pointer SSA node) -> set of Sites, plus an outside-storage flag +H(Site, reference field) -> set of Sites, plus an outside-storage flag +Escapes -> local Sites accessible outside, plus outside storage +``` + +Points stores a HashSet of Sites. Null adds no Site; nullability belongs to the +type analysis. The `_unknown` flag denotes storage outside the local collection; +compatible local escapees are separate explicit Sites. An empty local set is +therefore different from an unknown external reference. + +| Operation | Constraint | +|---|---| +| New and its pointer projection | Seed the allocation Site | +| Static object constant | Seed its static Site | +| Pointer Phi / formal parameter | Union live input facts | +| Guard, readonly, construction/init view | Forward pointer facts | +| `p.f = q` | Union P(q) into each possible base Site's field | +| `q = p.f` | Union the corresponding fields of possible base Sites | +| Known loaded call | Actual-to-Parm links; Return-to-call-result links | +| External argument or result | Relate outside storage and compatible escapees; incomplete | + +Stores are weak updates: a Site can represent many concrete objects. Conversely, +multiple aliases to a proven concrete singleton would not prevent a strong +update, because all those aliases observe the same cell. Set cardinality, +number of pointer names, and concrete multiplicity are distinct facts. + +Reading a Points registers the consuming Node. Growing a fact requeues its +readers on util.WorkList; loads and stores discover field dependencies as their +bases grow. Node-keyed tables use identity rather than Node.hashCode, which +participates in GVN locking. The solver uses graph walks for initialization and +dependency-driven propagation thereafter. `verify()` explicitly re-evaluates +constraints and is called by assertions/tests; it is not a second production +analysis pass. Convergence checking is not a soundness proof. + +After solving, reverse field-edge counts identify candidate owning fields. +These counts exclude local SSA aliases and do not prove concrete ownership. +`simple.alloc2.dump` prints Sites, fields, escapes, and pointer facts. + +This is an inclusion-based, field-sensitive analysis with flow-insensitive field +facts. Its finite monotone domain supports worklist solving; broad sets and field +cross-products can still be expensive. Cornell's [alias-analysis lesson][cornell] +provides the standard terminology. + +### Separate compilation and escapes + +FunctionSummary is metadata for an unloaded SummaryNode: signature, optimized +return state, name, size, and class-initialization dependencies. Serialized format +10 (`C0DA`) contains no allocation destinations, consume contracts, or separate +function-write analysis. A body loads when needed for inlining or evaluation. + +An internal call does not publish its callee's FIDX. Class-init dependency edges +serve cycle checking and must not grant unknown callers access. Hidden private +construction memory defaults to unknown contents with empty escape sets; actual +calls still carry initialized field values under the broad declared signature. +Publication of one field uses that field's value, rather than unrelated escapes +from the entire private object. Final singleton-memory constants refresh their +escape sets after recursive type closure has completed. + +Boundary handling still needs work: imported pointer results must include +returned local arguments; escape closure must observe later field growth; +outside writes, raw addresses, and intrinsic calls need explicit treatment. +The current implementation and regression tests expose these gaps. Neither an +unknown result nor a low incoming-edge count permits a lifetime decision. + +Cofinite imported escape sets also need a defined receiving universe. Renaming +only their finite exclusions admits caller-private FIDXs into the infinite tail. +Preserve membership of known remote identities while excluding local identities +from the anonymous remote remainder. Actual local escapes enter through the +caller's escape flow. Today type-table loading occurs during parsing, before all +local identities exist, although SummaryNodes are installed after parsing. +Import ordering and universe rebasing are pending work; ordinary universal type +bounds must retain their meaning. + +### Normalized exits + +LoopTree inserts Never exits before Allocation2 and TypeCheck. FunNode preserves +the semantic return state before adding synthetic control flow, so diagnostics +and serialized summaries do not claim a nonreturning function returns. Rebuilding +the loop tree for scheduling retains existing synthetic exits. Unloaded summary +wrappers remain dispatch metadata and are detached from scheduling roots. + +## (2) Ownership: candidates first, per-instance proofs next + +Reverse field-edge counts fall directly out of points-to. If only abstract +`A.buf` points to B, record the single source as an ownership candidate. Counts +exclude local SSA aliases and must not silently ignore unknown external edges +when someone eventually consumes them as evidence. + +The tempting inference "one reverse edge, therefore A owns B" is unsound for +summary objects. Both heaps below have `A.buf -> {B}`: + +```text +a1.buf = b1; a2.buf = b2; // separate pairings +a1.buf = b1; a2.buf = b1; // shared child +``` + +The missing fact is relational: for every concrete a, a.buf belongs to that a, +and distinct As do not retain the same owned B. Establish this at construction, +then show every write +to the owning field restores it. Temporary aliases are borrows whose usable +lifetimes end before reclamation. Copying the owner pointer is fine; both copies +name the same owning field. Copying the child creates a separate borrow to track. + +For hand-over-hand replacement: + +| Step | Old B | New B | +|---|---|---| +| Entry | retained by v.buf | absent | +| `old = v.buf` | v.buf and old | absent | +| Allocate next, copy | v.buf and old | next | +| `v.buf = next` | old | v.buf and next | +| Last use of next | old | v.buf | +| Last usable reference to old ends | reclaimable | v.buf | + +The straight-line case is deliberately modest. Every reachable mutation, +constructor/helper, and call must preserve the invariant or invalidate the +candidate. A no-growth path can retain the incoming B. A new summary/version +name must not assert a physically new object on that path. Outstanding aliases +such as `saved = v.buf` across grow block old-buffer reclamation; loading v.buf +after grow refers to the current child instead. + +This does not require runtime reference counting. [Alias burying][burying] +explains why temporary aliases need not prevent later uniqueness. Preconditions, +postconditions, and frame reasoning from [separation logic][seplogic] are useful +without adopting a general theorem prover. + +### From one-step ownership to aggregates + +Prove immediate owner edges first. If A owns B and B owns C, ownership composes; +an owner tree plus ancestry queries suffices, without enumerating every pair. +This is not ordinary reachability: + +```text +A.b -> B; A.c -> C; B.c -> C +``` + +A may own B and C, but B does not own C because A.c bypasses B. Detaching B does +not authorize reclaiming C. [Owners-as-dominators][ownership] concerns the +object graph, not the control-flow dominator tree or frame containment tree. + +The next generalization permits internal sharing/cycles within a representation +while controlling access crossing its boundary, as in [external uniqueness][external]. +The ownership hierarchy may be a tree even though heap pointers form a graph. +Whole-aggregate lifetime resembles [region reference counting][regions-rc], but +we are not committing to runtime counts or one arena per owner. + +Examples: v owns its current buffer; Canvas owns its current pixel array; Game +can own its bricks. Breakout's Game and Canvas are separate roots in main; a +drawing helper borrowing Canvas does not transfer ownership. Keeping every +historical buffer in the owner's arena defeats prompt reclamation, so an owned +child must be detachable after its boundary borrows end. + +Pros: a uniform rule for wrappers, canvases, and nested representations, with +cheap transitive composition. Cons: proving the first edge requires temporal +and relational information absent from raw may-points-to sets. Internal sharing +requires a wider boundary proof. Start with paired fields; do not solve general +heap shape merely to handle a resize. + +## (3) Lifetime boundaries and reclamation proofs + +The proposed "frame idom" is a containing allocation-frame relation: function +activation, loop iteration, or suitable single-entry/single-exit region. For +`main: p=make(); use(p);`, make and use are siblings under main; the object can +be allocated in main's frame. Ordinary immediate CFG dominance alone does not +give that lifetime. Calling this a frame LCA avoids conflating the structures. + +Find a common enclosing frame for the allocation and all usable accesses, +including indirect access through fields, returns, and retained aliases. Model +cleanup boundaries, including loop continuation and exits. A call-DAG walk can +propagate these requirements; do not expand the dynamic activation tree. +Interprocedural paths must respect matched calls/returns, not connect a shared +callee return to arbitrary callers. [Realizable-path analysis][realizable] +explains that distinction. Context-insensitive may results may conservatively +include infeasible paths; lifetime reasoning must preserve call/return meaning. + +Multiplicity is relative to the selected frame. A site may need one slot per +iteration yet accumulate many retained objects in the enclosing function: + +```text +head = null; +while (...) head = new Cell(head); +use(head); +``` + +The tiny graph `head -> A; A.next -> A` represents a potentially large list. +The common frame is outside the loop, requiring growth. A known object size +does not prove bounded total demand. "Many/unknown" is conservative, not a proof +that demand is mathematically unbounded. A repeatedly executed site may still +reuse one slot when each previous object's lifetime ends before the next. + +Memory-SSA walks can establish borrow ends through overwrites, calls, and +loop backedges. Propagate checked contracts on the call DAG. Automatic deletion +also needs a selected endpoint; conservative checkpoints suffice initially. +These proofs are not implemented in Allocation2. + +"No usable future reference" is the reclamation condition. It is weaker than +"no pointer bits anywhere": an unused local or a field overwritten before its +next read need not keep storage alive. Mere lexical scope exit is insufficient +if a stored/returned alias remains usable. + +Pros: use memory-SSA reasoning and keep lifetime separate from alias +possibility. Cons: still must connect per-instance ownership and temporal facts +without rebuilding the old parallel reference machinery. The frame tree and +its SESE/cleanup representation remain to be implemented in Allocation2. + +## (4) Storage selection is a separate heuristic + +There need not be a safety theorem saying "stack allocation has become +impossible." Retaining everything in a growing outermost region can often be +safe but wasteful. Lifetime safety and useful bounded-space behavior differ. +Ownership transfer exposes earlier reclamation opportunities; policy decides +whether to exploit them. [Region inference][regions] supplies a lifetime model, +without deciding every allocator tradeoff for us. + +Use an explicit decision tree, initially conservative: + +| Candidate decision | Required facts / tradeoff | +|---|---| +| Fixed slot in the LCA frame | Known size, singleton relative to that frame, sufficient lifetime; simple and cheap | +| Grow at an available open tip | Dynamic size or overlapping instances; allocate at definition, reclaim at owning-frame end; may retain dead intermediates | +| Another growth stack | Competing live growth obstructs one tip; extra stack/metadata cost; fixed-size repetitions are useful candidates, not a hard restriction | +| Free-list/buddy allocation | Hand-over-hand or other proven reuse endpoints; unordered deaths/variable sizes; allocator overhead | +| Unsupported, request rewrite | No plan justified by available facts and policy | + +The policy can improve later. It needs neither an optimal answer nor elaborate +theory up front. All leaves report a decision and reason. Analysis supplies +lifetime bounds, size, multiplicity, ownership/borrow facts, safe reuse points, +and interference. Open-tip availability also depends on prior layout choices, +so the heuristic combines these facts with its current plan. It must never +manufacture a missing lifetime or deletion proof. + +Lowering subsequently reserves slots, passes region destinations where needed, +inserts allocation/reset/drop operations, and handles every exit. Separating it +from analysis makes policy changes and debugging easier. + +## (5) Deletion semantics: zero first, optimize later + +The selected design changes deletion to clear ALL fields, references and +scalars, including final fields. References stored in deletable objects must +admit null. Final means immutable during the live-object protocol; reset of dead +storage is permitted. Bulk zeroing is a natural initial implementation. +Removing redundant clearing is a later optimization with an observability proof. + +Between deletion and reuse, a stale non-array reference sees zeroed fields; +after reuse its backing slot must still have a type-compatible representation. Zeroing eliminates +references discoverable by rereading the deleted object, but cannot revoke +references copied out before deletion. Those retain their own lifetime duties. + +StoreNode's existing `_init` permission bypasses final/readonly store checks, +which is relevant to reset lowering. It is not by itself a complete solution: +load folding, field type bounds, final-field assumptions, and memory ordering +must agree that dead/reset memory can contain zeros. Consider an explicit raw +storage/reset meaning for that permission. Numeric nonzero bounds and array +headers need the same care as reference nullability. + +Non-array stale aliases remain type-safe and readable, so deletion does not by +itself end the backing slot's lifetime. Reusing a readable field as an arbitrary +allocator link is not justified. Arrays instead require proof of no usable +stale access before physical recycling; then the allocator may reuse the old +header, including the length field, as metadata. Auto-inserted deletion likewise +needs the no-remaining-usable-reference proof, not just a one-edge candidate. + +Pros: predictable reset semantics; stale object paths no longer expose the whole +former representation; initially simple bulk clearing. Cons: observable writes, +final/type optimizer changes, and restrictions on reuse with stale aliases. +Keep the chain "prove alias death -> permit header reuse -> buddy allocation" +visible and revisit alternatives if expensive. These semantic and runtime +changes are not implemented by the points-to slice. + +## Remaining implementation + +Complete and review separate-compilation points-to constraints before using +them for lifetime proofs. Then implement paired ownership and borrow endpoints, +containing-frame lifetime and multiplicity facts, the storage decision heuristic, +and reset/reclamation lowering. Native-effect precision and consuming recursion +are separate follow-ups, not prerequisites for choosing this analysis structure. + +Use small semantic assertions as well as fixed-point checks. In particular, +exercise shared factories, weak field stores, loops, pointer arrays, imported +identity functions, escaping object graphs, and callbacks. Keep failing semantic +regressions visible until the corresponding behavior is implemented. + +The [growing-array design](growing-arrays.md) gives scope, return-destination, +and direct-I/O examples for the later storage stage. + +## References + +- [Cornell, Alias Analysis][cornell]: constraints, heap abstraction, sensitivity. + Also the original [pointer-analysis notes][notes]. +- [Tofte and Talpin, Region-Based Memory Management][regions]: lifetime/regions. +- [Balakrishnan and Reps, Recency-Abstraction for Heap-Allocated Storage][recency]: + most-recent versus summary objects; optional precision. +- [Reynolds, Separation Logic][seplogic]: local heap reasoning and contracts. +- [Boyland, Alias Burying][burying]: uniqueness after temporary aliases. +- [Clarke and Wrigstad, External Uniqueness Is Unique Enough][external]: + aggregate boundaries despite internal sharing. +- [Gay and Aiken, Memory Management with Explicit Regions][regions-rc]: + region reference counting; motivation, not a selected runtime scheme. +- [Clarke et al., Ownership Types: A Survey][ownership]: owners-as-dominators + and ownership variants/inference. +- [Reps, Horwitz, and Sagiv, Precise Interprocedural Dataflow Analysis via Graph + Reachability][realizable]: valid call/return paths. + +[cornell]: https://www.cs.cornell.edu/courses/cs6120/2023fa/lesson/10/ +[notes]: https://www.cs.cornell.edu/courses/cs4120/2026sp/notes.html?id=pointer +[regions]: https://ropas.snu.ac.kr/lib/dock/ToTa1997.pdf +[recency]: https://research.cs.wisc.edu/wpis/papers/sas06-recency.pdf +[seplogic]: https://www.cs.cmu.edu/~jcr/seplogic.pdf +[burying]: https://onlinelibrary.wiley.com/doi/abs/10.1002/spe.370 +[external]: https://ics-archive.science.uu.nl/research/techreps/repo/CS-2002/2002-048.pdf +[regions-rc]: https://theory.stanford.edu/~aiken/publications/papers/pldi98a.pdf +[ownership]: https://ilyasergey.net/papers/ownership-survey.pdf +[realizable]: https://www.cs.tufts.edu/comp/150CMP/papers/reps95reachability.pdf diff --git a/chapter33/docs/ownership-analysis-architecture-review.md b/chapter33/docs/ownership-analysis-architecture-review.md deleted file mode 100644 index e804d4b0..00000000 --- a/chapter33/docs/ownership-analysis-architecture-review.md +++ /dev/null @@ -1,79 +0,0 @@ -# Ownership analysis architecture review - -2026-11-23. - -I agree with the broad assessment. Native effects and the Timer rewrite can wait; neither needs to drive this redesign. - -After reading the implementation, I think the main problem is that we discard information in one analysis and reconstruct it in another. Better terminology would help expose that, but we also need clearer boundaries between the questions being answered. - -I would describe the task as: points-to analysis and reference liveness, feeding region inference and checks for safe storage reuse. Alias analysis supplies much of the evidence, but cannot by itself determine when storage can be reclaimed. - -Your solution space looks right, with these additional proof obligations: - -| Storage choice | What must be established | -|---|---| -| Fixed storage reserved in the current or an enclosing frame | Size, sufficient slots for simultaneously needed objects, and a frame lifetime covering every permitted access | -| Dynamically sized storage at a growing stack tip | Lifetime compatibility and an allocation order compatible with contiguous growth and stack reclamation | -| Recycled non-array object slots | Type-safe reuse while old aliases remain valid; backing storage must still outlive those aliases | -| Recycled arrays | No usable access to the old array survives deletion | -| Require a rewrite | The available analysis cannot establish a supported storage arrangement | - -Two additions matter here. Fixed object size does not imply fixed storage demand: one allocation site can produce arbitrarily many simultaneously needed objects. And dynamically sized storage need not have a compile-time size bound, but growth still has ordering constraints—a retained inner allocation can obstruct an outer growing array. - -The first two choices fit the established subject of region inference: infer storage regions and prove that their reclamation respects accesses. Tofte and Talpin give a formal foundation for that separation between lifetime reasoning and runtime regions. [Region-Based Memory Management](https://ropas.snu.ac.kr/lib/dock/ToTa1997.pdf) - -The terminology I would use for our current machinery is: - -| Current concept | Established terminology | -|---|---| -| Possible reference “origins” | Points-to sets over abstract objects | -| `arg3.c` | An access path rooted at a formal parameter | -| Union of everything stored into a field | A flow-insensitive may-points-to relation | -| Following field contents at a memory version | Flow-sensitive points-to analysis | -| Forgetting a field’s previous contents after a definite overwrite | Strong update | -| Retaining both previous and newly stored possibilities | Weak update | -| Substituting arguments and allocations at a call | Instantiation of a procedure summary | -| Proving no usable alias survives | A lifetime/deallocation proof using alias and liveness information | - -These distinctions are standard in pointer analysis; in particular, flow sensitivity determines whether facts distinguish program points. [Cornell’s pointer-analysis notes](https://www.cs.cornell.edu/courses/cs4120/2026sp/notes.html?id=pointer) - -One especially important distinction: strong updates do not require that an object have only one pointer to it. They require that the analysis establish which concrete storage cell is overwritten. Several aliases can all observe that same overwrite. Conversely, a points-to set containing one abstract allocation-site node may represent many concrete objects, so “set size one” alone does not justify a strong update. This is exactly the problem addressed by work on allocation-site abstractions and recency abstractions. [Balakrishnan and Reps](https://research.cs.wisc.edu/wpis/papers/sas06-recency.pdf) - -That distinction should help us avoid making “unique” stand for several different properties. - -The clearest architectural issue is visible in a tiny example: - -```text -old = v.buf; -v.buf = next; -old.del(); -``` - -`Allocation` accumulates both buffers in the field’s possible contents. `ArrayDelete` then follows memory SSA to recover that the field no longer contains `old`. Calls and loops require additional machinery because their summaries have also merged facts from different times. - -The code currently has two reference representations, `Site` and `Ref`, two reference-resolution mechanisms, and two forms of call substitution. Their purposes differ, but the overlap is substantial. `arrayOwned`, outgoing call versions, and loop-entry versions bridge the difference between the representations. - -My inference is that this mismatch accounts for a substantial part of the special cases. - -I would move toward one account of how references and memory change, with separate consumers for placement and deletion. A procedure summary should describe a transformation from incoming memory to outgoing memory, including: - -- Possible returned references and newly allocated objects. -- Fields that may change, and fields definitely overwritten. -- Storage that may be consumed. -- Preconditions and guarantees needed for those operations. - -For `grow(v)`, the useful contract is approximately: the incoming buffer may be consumed; the outgoing buffer is valid; aliases that could access a consumed buffer must not remain usable. The outgoing buffer may be the incoming buffer on the no-growth path. Giving it a new analysis name must not imply that it is a physically distinct allocation. - -That is also where ideas from separation logic are useful: explicit preconditions, postconditions, and reasoning about the portion of memory a procedure affects. We need not adopt a full separation-logic prover to benefit from those distinctions. [Reynolds](https://www.cs.cmu.edu/~jcr/seplogic.pdf) - -A second addition to your assessment is that “no aliases” is stronger than the property we ultimately need. An unused local can still contain the old pointer. A field can contain it if the field is definitely overwritten before any subsequent read. The safety question is whether a future execution can use that reference to access reclaimed storage. - -That introduces reference liveness alongside points-to information. A conservative first implementation can reject whenever it finds a surviving reference, but the architecture should make clear that this is an approximation. Otherwise every improvement in recognizing dead aliases becomes another ownership exception. - -The non-array deletion semantics deserve a separate, explicit rule. Because old references remain usable, deleting an object does not end the lifetime of its backing slot. It makes the slot eligible for reuse under the language’s historical-value rules. References recoverable from those permitted historical values also retain lifetime obligations. Arrays instead require the proof that old access has ended before recycling. Both can use the same alias information, but their reuse conditions are fundamentally different. - -Finally, loops need a stated abstraction for repeated allocations. One abstract object per allocation site conflates successive objects. Our loop versions are already attempting to recover that distinction. Recency abstraction—separating the most recent object from older objects—is a relevant established option, though we should evaluate whether it fits our cases rather than adopt it automatically. - -I would start the redesign with a small abstract semantics: what an abstract object denotes, what information a memory state contains, the rules for loads/stores/calls/joins, and the exact conditions for reclamation and reuse. Then work the existing two-grow and loop-winner examples through those rules by hand. - -The simplification target is that initializers, ordinary helpers, consecutive grows, and loop iterations follow those same rules. That would give us a theoretical explanation for accepted programs, and a precise description of where our chosen approximation requires the user to rewrite. |
