Nim
Nim copied to clipboard
WIP: Alternative move analyser that avoids the expensive creation of …
…a control flow graph
Todo:
- [x] fix the bug "break" does not leave the loop that owns the variable in question.
- [x] fix the bug which prevents
lastUse(obj.field)from working - [x] fix the remaining
resultfalse negatives - [x] fix false positive in
symObjforproc fieldVisible. - [x] the move analyser must be smarter for this pattern:
if cond:
let a = result
result = newNodeI(nkPragmaBlock, a.info)
- [x] figure out why the algorithm doesn't understand closures properly
- [x] use the algorithm from sempass2 to set
nfFirstWrite. - [ ] enable the new analysers and make tests green again
While it's nowhere near correct, here are numbers to justify its existence:
Old move analyser:
nim c --gc:orc --compileOnly compiler\nim.nim 162289 lines; 20.660s; 1.016GiB peakmem;
New move analyser:
nim c --gc:orc --compileOnly compiler\nim.nim 162094 lines; 13.596s; 1.016GiB peakmem;
Unfortunately no reduction in memory consumption was achieved. However, more than 6 seconds of compile-time improvement is nothing to complain about.
The bootstrap failed because the compiler now bootstraps with -d:nimPreviewSystem. If you are using assert/doAssert, you need to add
when defined(nimPreviewSlimSystem):
import std/assertions
When doing local bootstrap, disabled nimPreviewSlimSystem or use --lib:lib.
Succeeded by https://github.com/nim-lang/Nim/pull/20471 which has fewer weird special cases, produces slightly better results and runs just as fast.