diff options
| author | 2026-10-14 08:29:46 +0330 | |
|---|---|---|
| committer | 2026-10-14 08:29:46 +0330 | |
| commit | 1c53304d03414890af0da7432d1aea87e754a14a (patch) | |
| tree | 97190d86cf548c9bc63f68c86a4d2a4f09809713 /tests/drivers/compiler_growth_test.py | |
| parent | a (diff) | |
feat: grow memory limits, add icon/actor libraries, overhaul LSP diagnostics
Compiler and VM
- make every memory map limit dynamic and adjustable at both build time and
runtime, including compiler tables, stacks, and every execution region
- reserve and grow tables, operand and return stacks, frame segments, and
image-building output without relocating live code or globals
- rename i/o and string helpers consistently (puts -> put_s, putn -> put_n,
scat -> cat_s) across compiler, runtime, examples, tests, and docs
- recast and consume values assigned to globals from inside functions
- allow fixed and const together, add typed closure returns (fn:t(...)),
multi-include syntax (include rt, run, core;), and recurse type inference
- never infer string literals as word, anywhere, as argument, variable, or
return type
- draft docs/BORROW.md: a borrow checker less intrusive than Rust's but more
intelligent
LSP and editor integration
- require explicit includes and give every toolchain area its own namespace
(rt, lsp, run, core)
- hover for built-in types, inferred types, values known at hover time, array
and pointer lifetime/size, library names in include statements, and inferred
lifetimes with explanations
- honor /* */ comments as documentation for variables and arguments, and stop
misattributing section headers or trailing comments as variable hints
- stream diagnostics and cancel stale requests on change
- jump to definition and references, including cross-file
- quick fixes with automatic library import, and namespace completion
Hints and diagnostics
- render hints as blue squigglies by default, with hints on/small/off per file
- suppress magic-number hints via a preceding /* */ comment, and say so
- warn on unused arguments; allow multiple _ discards in parameters, pattern
matching, and tagged enums, warning if a _ is actually used
- rewrite hint and comment prose in professional compiler-doc register
Libraries
- add icon.zc: run-time self-modification, find/replace syntax, type and block
edits, and step-through inspection of locals and globals
- add actor.zc: async actors with Actor<I,O>, implicit this, spawn/recv/send,
injected into the compiler machinery at include time rather than built in
Tooling and docs
- reorganize sources, tests, and designs into subdirectories
- unify windows entry points in tinyvm.bat and add a matching tinyvm.sh
- add --help across the toolchain
- polish the learning guide, stdlib docs, and design notes
Tests
- add accept, reject, and regression coverage across the compiler, LSP,
- runtime, icon, actors, threads, formatting, and the toolchain contracts,
plus fuzzers and property tests
Diffstat (limited to 'tests/drivers/compiler_growth_test.py')
| -rw-r--r-- | tests/drivers/compiler_growth_test.py | 61 |
1 files changed, 32 insertions, 29 deletions
diff --git a/tests/drivers/compiler_growth_test.py b/tests/drivers/compiler_growth_test.py index 982611c..e56bf43 100644 --- a/tests/drivers/compiler_growth_test.py +++ b/tests/drivers/compiler_growth_test.py @@ -18,65 +18,68 @@ def run(source, expected): assert result.stdout == expected, result.stdout[:1000] -locals_source = 'fn main() {\n' +locals_source = 'include rt; fn main() {\n' locals_source += ''.join(f'int local_{i} = {i};\n' for i in range(900)) -locals_source += 'put_n(local_899); put_c(10); return 0; }\n' +locals_source += 'rt.put_n(local_899); rt.put_c(10); return 0; }\n' run(locals_source, '899\n') -types_source = ''.join(f'type array_{i} = [{i + 1}]int;\n' for i in range(1500)) -types_source += 'fn main() { put_n(ntl > 1500); put_c(10); gc(); put_n(tsz(tarr(tint, 1500))); put_c(10); return 0; }\n' +types_source = ''.join(f'type array_{i} = int[{i + 1}];\n' for i in range(1500)) +types_source = 'include rt, run;\n' + types_source +types_source += 'fn main() { rt.put_n(run.ntl > 1500); rt.put_c(10); rt.gc(); rt.put_n(run.tsz(run.tarr(run.tint, 1500))); rt.put_c(10); return 0; }\n' run(types_source, '1\n1500\n') -names_source = ''.join(f'const int repeated_long_identifier_for_pool_and_hash_growth_{i} = {i};\n' for i in range(options.names)) +names_source = 'include rt, run;\n' + ''.join(f'const int repeated_long_identifier_for_pool_and_hash_growth_{i} = {i};\n' for i in range(options.names)) names_source += f'''fn main() {{ - word saved = intern("a name that must survive growth"); - reserve_names(hashcap * 4); reserve_symbols(symcap * 2); reserve_locals(loccap * 2); - reserve_fixes(fixcap * 2); reserve_R_SRC(4096); reserve_R_CTX(4096); - reserve_R_LOOP(4096); reserve_R_SNAP(32768); reserve_R_QBUF(32768); reserve_R_EXIT(8192); - gc(); - put_n(saved == intern("a name that must survive growth")); put_c(10); - put_n(repeated_long_identifier_for_pool_and_hash_growth_{options.names - 1}); put_c(10); - put_n(poolblocks != 0 && symcap > NS && hashcap > IHN); put_c(10); + word saved = run.intern("a name that must survive growth"); + run.reserve_names(run.hashcap * 4); run.reserve_symbols(run.symcap * 2); run.reserve_locals(run.loccap * 2); + run.reserve_fixes(run.fixcap * 2); run.reserve_R_SRC(4096); run.reserve_R_CTX(4096); + run.reserve_R_LOOP(4096); run.reserve_R_SNAP(32768); run.reserve_R_QBUF(32768); run.reserve_R_EXIT(8192); + rt.gc(); + rt.put_n(saved == run.intern("a name that must survive growth")); rt.put_c(10); + rt.put_n(repeated_long_identifier_for_pool_and_hash_growth_{options.names - 1}); rt.put_c(10); + rt.put_n(run.poolblocks != 0 && run.symcap > run.NS && run.hashcap > run.IHN); rt.put_c(10); return 0; }} ''' run(names_source, f'1\n{options.names - 1}\n1\n') long_name = 'identifier_' + 'x' * 1500 -run(f'const int {long_name} = 7; fn main() {{ put_n({long_name}); put_c(10); return 0; }}\n', '7\n') +run(f'include rt; const int {long_name} = 7; fn main() {{ rt.put_n({long_name}); rt.put_c(10); return 0; }}\n', '7\n') -mark_source = '''let roots[60000]; +mark_source = '''include rt; let roots[60000]; unchecked fn main() { - int i = 0; - while (i < 60000) { roots[i] = new(1); i++; } - gc(); put_n(markcap > MARKN); put_c(32); put_n(live_objects() == 60000); put_c(32); - fill_w(roots, 0, 60000); scrub(); gc(); - // conservative roots can retain incidental addresses in code or untyped words. - put_n(live_objects() < 1000); put_c(10); return 0; + int i = 0, before = rt.live_objects(); + while (i < 60000) { roots[i] = rt.new(1); i++; } + rt.gc(); rt.put_n(rt.markcap > rt.MARKN); rt.put_c(32); rt.put_n(rt.live_objects() - before == 60000); rt.put_c(32); + // explicitly release survivors: conservative instruction roots may resemble heap addresses. + i = 0; while (i < 60000) { rt.free(roots[i]); i++; } + rt.fill_w(roots, 0, 60000); rt.scrub(); rt.gc(); + rt.put_n(rt.live_objects() == before); rt.put_c(10); return 0; } ''' run(mark_source, '1 1 1\n') generics_source = ''.join(f'int generic_{i}<T>() {{ return sizeof(T); }}\n' for i in range(90)) generics_source += 'int size_of<T>() { return sizeof(T); }\n' +generics_source = 'include rt;\n' + generics_source generics_source += 'fn main() { int total = 0;\n' generics_source += ''.join(f'total += generic_{i}<int>();\n' for i in range(90)) -generics_source += ''.join(f'total += size_of<[{i + 1}]int>();\n' for i in range(150)) -generics_source += 'gc(); put_n(total); put_c(10); return 0; }\n' +generics_source += ''.join(f'total += size_of<int[{i + 1}]>();\n' for i in range(150)) +generics_source += 'rt.gc(); rt.put_n(total); rt.put_c(10); return 0; }\n' run(generics_source, '11415\n') -captures_source = 'fn main() {\n' + ''.join(f'int captured_{i} = {i};\n' for i in range(70)) +captures_source = 'include rt; fn main() {\n' + ''.join(f'int captured_{i} = {i};\n' for i in range(70)) captures_source += 'let f = fn() { return ' + ' + '.join(f'captured_{i}' for i in range(70)) + '; };\n' -captures_source += 'gc(); put_n(f()); put_c(10); return 0; }\n' +captures_source += 'rt.gc(); rt.put_n(f()); rt.put_c(10); return 0; }\n' run(captures_source, '2415\n') -nested_source = 'fn main() { int captured = 7;\n' +nested_source = 'include rt; fn main() { int captured = 7;\n' nested_source += ''.join(f'let nested_{i} = fn() {{\n' for i in range(12)) nested_source += 'return captured;\n' nested_source += ''.join(f'}}; return nested_{i}();\n' for i in reversed(range(1, 12))) -nested_source += '}; gc(); put_n(nested_0()); put_c(10); return 0; }\n' +nested_source += '}; rt.gc(); rt.put_n(nested_0()); rt.put_c(10); return 0; }\n' run(nested_source, '7\n') -assembly_source = 'fn main() { int value = asm { ' + 'future _ ' * 300 -assembly_source += ''.join(f':label_{i} ' for i in range(200)) + ':future 7 }; gc(); put_n(value); put_c(10); return 0; }\n' +assembly_source = 'include rt; fn main() { int value = asm { ' + 'future _ ' * 300 +assembly_source += ''.join(f':label_{i} ' for i in range(200)) + ':future 7 }; rt.gc(); rt.put_n(value); rt.put_c(10); return 0; }\n' run(assembly_source, '7\n') print('ok compiler tables, long identifiers, and mark work grow without losing references') |
