summary refs log tree commit diff stats
path: root/compiler/transf.nim
Commit message (Collapse)AuthorAgeFilesLines
* fixes #24141; Calling algorithm reverse causes a SIGSEGV on ORC (#24142)ringabout2024-09-191-1/+6
| | | fixes #24141
* disable closure iterator changes in #23787 unless `-d:nimOptIters` is ↵metagn2024-09-161-5/+11
| | | | | | | | | | | | | | enabled (#24108) refs #24094, soft reverts #23787 #23787 turned out to cause issues as described in #24094, but the changes are still positive, so it is now only enabled if compiling with `-d:nimOptIters`. Unfortunately the changes are really interwoven with each other so the checks for this switch in the code are a bit messy, but searching for `nimOptIters` should give the necessary clues to remove the switch properly later on. Locally tested that nimlangserver works but others can also check.
* fixes #24033; Yielding from var fails with pairs and destructuring (#24046)ringabout2024-09-021-3/+9
| | | fixes #24033
* fixes #23454; IndexDefect thrown when destructuring a lent tuple (#23993)ringabout2024-08-221-1/+4
| | | fixes #23454
* fixes #23982; codegen regression passing pointer expressions to inline ↵ringabout2024-08-201-2/+4
| | | | | iterators (#23986) fixes #23982
* fixes #22389; fixes #19840; don't fold paths containing `addr` (#23807)ringabout2024-07-091-1/+5
| | | | fixes #22389; fixes #19840
* Optimize closure iterator locals (#23787)Yuriy Glukhov2024-07-031-11/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This pr redefines the relation between lambda lifting and closureiter transformation. Key takeaways: - Lambdalifting now has less distinction between closureiters and regular closures. Namely instead of lifting _all_ closureiter variables, it lifts only those variables it would also lift for simple closure, i.e. those not owned by the closure. - It is now closureiter transformation's responsibility to lift all the locals that need lifting and are not lifted by lambdalifting. So now we lift only those locals that appear in more than one state. The rest remains on stack, yay! - Closureiter transformation always relies on the closure env param created by lambdalifting. Special care taken to make lambdalifting create it even in cases when it's "too early" to lift. - Environments created by lambdalifting will contain `:state` only for closureiters, whereas previously any closure env contained it. IMO this is a more reasonable approach as it simplifies not only lambdalifting, but transf too (e.g. freshVarsForClosureIters is now gone for good). I tried to organize the changes logically by commits, so it might be easier to review this on per commit basis. Some ugliness: - Adding lifting to closureiters transformation I had to repeat this matching of `return result = value` node. I tried to understand why it is needed, but that was just another rabbit hole, so I left it for another time. @Araq your input is welcome. - In the last commit I've reused currently undocumented `liftLocals` pragma for symbols so that closureiter transformation will forcefully lift those even if they don't require lifting otherwise. This is needed for [yasync](https://github.com/yglukhov/yasync) or else it will be very sad. Overall I'm quite happy with the results, I'm seeing some noticeable code size reductions in my projects. Heavy closureiter/async users, please give it a go.
* implement `legacy:jsNoLambdaLifting` for compatibility (#23727)ringabout2024-06-171-0/+1
|
* fixes #23536; Stack trace with wrong line number when the proc called inside ↵ringabout2024-04-261-6/+8
| | | | | for loop (#23540) fixes #23536
* fixes #4299 #12492 #10849; lambda lifting for JS backend (#23484)ringabout2024-04-111-1/+0
| | | | | | | | fixes #4299 fixes #12492 fixes #10849 It binds `function` with `env`: `function.bind(:env)` to ease codegen for now
* fixes addr/hiddenAddr in strictdefs (#23477)ringabout2024-04-101-4/+0
|
* refactoring: no inheritance for PType/PSym (#23403)Andreas Rumpf2024-03-141-12/+14
|
* fixes #19977; rework inlining of 'var openarray' iterators for C++ (#23258)ringabout2024-01-261-1/+2
| | | fixes #19977
* fixes #22552 (#23014)Andreas Rumpf2023-12-021-2/+17
|
* NIR: progress (#22817)Andreas Rumpf2023-10-121-26/+26
| | | | | | Done: - [x] Implement conversions to openArray/varargs. - [x] Implement index/range checking.
* `initNodeTable` and friends now return (#22444)ringabout2023-08-111-3/+1
|
* use strictdefs for compiler (#22365)ringabout2023-08-061-2/+6
| | | | | | | | | | | | | | | * wip; use strictdefs for compiler * checkpoint * complete the chores * more fixes * first phase cleanup * Update compiler/bitsets.nim * cleanup
* fixes #22237; fixes #21160; wrong cursor on unowned parameters in the for ↵ringabout2023-07-101-2/+15
| | | | | loop in ORC (#22240) fixes #22237; fixes #21160; wrong cursor on unowned parameters
* fixes #22148; std/memfiles.memSlices nesting now fails with memory sa… ↵ringabout2023-06-251-1/+1
| | | | | | | (#22154) * fixes #22148; std/memfiles.memSlices nesting now fails with memory safety capture violation * adds a test case
* fixes #21110; duplicate proc definitions for inline iters (#21136)ringabout2023-06-221-0/+8
| | | fixes #21110; duplicate proc definitions for iters
* fixes explicit deref block (#22093)ringabout2023-06-151-1/+3
| | | fixes explicit deref
* refactoring in preparation for better, simpler name mangling that wor… ↵Andreas Rumpf2023-04-241-4/+3
| | | | | | | | | | | (#21667) * refactoring in preparation for better, simpler name mangling that works with IC flawlessly * use new disamb field * see if this makes tests green * make tests green again
* fixes #21540; deref block at transf phase to make injectdestructors function ↵ringabout2023-04-191-1/+15
| | | | | | | | | | | | | properly (#21688) * fixes #21540; deref block at transf phase to make injectdestructors function properly * add a test case * add one more test * fixes the type of block * transform block
* fixes #21306; fixes #20485; don't transform yields in the var section when ↵ringabout2023-03-101-1/+4
| | | | | | | | | | | introducing new local vars [backport: 1.6] (#21489) * fixes #21306; don't transform yields in the var section when introducing new local vars * adds `inVarSection` so the var section in the var section is freshed * use `isIntroducingNewLocalVars` to avoid yield transformations in var sections * fixes comments
* Force lambda lifting for getImplTransformed. Hacky. Fixes #19818 (#21031)Yuriy Glukhov2023-01-191-3/+3
|
* remove duplicate assignment (#21050)ringabout2022-12-091-1/+0
| | | `newNodeIT` has already assigned `n.typ` to x.
* fixes #20856; store defaults directly (#20859)ringabout2022-11-171-7/+0
| | | | | | | | | | | * fixes #20856; store defaults directly * fixes * fixes * check * fixes
* Fix #18079 Illegal storage access compiling call with nested ref/deref (#20738)Bung2022-11-041-8/+10
| | | | | | * add test case * refactoring transformAddrDeref and fix #18079 * fix jsgen
* refactorings (#20536)Andreas Rumpf2022-10-101-5/+9
| | | | | | | * refactoring * refactoring: removed unused macroUsagesSection * enum instead of bool for better readability
* cleanup nfFirstWrite flags (#20500)Andreas Rumpf2022-10-051-1/+1
|
* add default field support for object in ARC/ORC (#20480)ringabout2022-10-041-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * fresh start * add cpp target * add result support * add nimPreviewRangeDefault * reduce * use orc * refactor common parts * add tuple support * add testcase for tuple * cleanup; fixes nimsuggest tests * there is something wrong with cpp * remove * add support for seqs * fixes style * addd initial distinct support * remove links * typo * fixes tuple defaults * add rangedefault * add cpp support * fixes one more bugs * add more hasDefaults * fixes ordinal types * add testcase for #16744 * add testcase for #3608 * fixes docgen * small fix * recursive * fixes * cleanup and remove tuple support * fixes nimsuggest * fixes generics procs * refactor * increases timeout * refactor hasDefault * zero default; disable i386 * add tuples back * fixes bugs * fixes tuple * add more tests * fix one more bug regarding tuples * more tests and cleanup * remove messy distinct types which must be initialized by original types * add tests * fixes zero default * fixes grammar * fixes tests * fixes tests * fixes tests * fixes comments * fixes and add testcase * undo default values for results Co-authored-by: flywind <43030857+xflywind@users.noreply.github.com>
* new move analyser2 (#20471)Andreas Rumpf2022-10-011-5/+7
| | | | | | | | * produce better code for closure environment creation * new 'first write' analysis; * scope based move analyser * code cleanup Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com>
* store full definition AST for consts, fix noRewrite (#20115)metagn2022-09-281-4/+6
| | | | | | | | | | | | | | | | | | | | | | | * continue #9582 for consts, close #9331, fix #20114 also move extractPragma to ast to pave the way for things like {.strdefine: "abc".} etc * changelog correctly * fix jsgen * update tgetimpl * fix sighashes * fix #19766, add comment about postfix * fix noRewrite LOL refs #16620 * fix changelog * fix destructors
* document compiler procs regarding `&` (#20257)ringabout2022-08-221-0/+5
|
* move assertions out of system (#19599)flywind2022-03-231-0/+3
|
* Fixed distinct composite type class proc borrowing (#18904)Jason Beetham2021-10-261-0/+8
| | | | | | | * Fixed composite type class proc borrowing * Moved borrow search into transf * added borrow check to symbol flag
* fixes #12642 (#18811)Andreas Rumpf2021-09-061-2/+3
| | | | | | | | | | | | | | | | | | | * fixes #12642 * update important packages; refs #18804 * fixes #18805; refs #18806 * fixes a regression * Update testament/categories.nim Co-authored-by: flywind <xzsflywind@gmail.com> * progress * progress Co-authored-by: flywind <xzsflywind@gmail.com>
* fixes #14165, fixes #18739, fix the second example of #6269 (#18812)Andreas Rumpf2021-09-061-4/+7
|
* remove unnecessary if statement (#18792)flywind2021-09-031-6/+6
|
* fix #9778 (pairs iterator calling a helper proc with tuple return type will ↵flywind2021-09-021-11/+44
| | | | | | | | | | | cut the iterator yield into half) (#18767) * test someSymFromImportTable * Update compiler/lookups.nim * test nkTupleConstr * use isConstExpr * add tests * add comments and todo * use todo
* cString => cSourceString; tyCString => tyCstring so that error msgs show ↵Timothee Cour2021-04-171-2/+2
| | | | cstring, not cString (#17744)
* IC: bugfix (#17533)Andreas Rumpf2021-03-271-4/+2
| | | | * cleanups * IC: bugfix
* fixes #11225; generic sandwich problems; [backport:1.2] (#17255)Andreas Rumpf2021-03-091-1/+1
| | | | | * fixes #11225; generic sandwich problems; [backport:1.2] * progress * delegating these symbols must be done via 'bind'
* IC: next steps (#16729)Andreas Rumpf2021-01-231-1/+3
| | | | | | | | | | | * IC: dead code elimination pass * preparations for a different codegen strategy * added documentation to the newly written code * IC: backend code * IC: backend adjustments * optimized the compiler a bit * IC: yet another massive refactoring * fixes regressions * cleanups
* Fix 16722 (#16730)cooldome2021-01-151-0/+2
| | | | | | | * fix #16722 * fix spacing * spacing
* IC: next steps (#16705)Andreas Rumpf2021-01-141-2/+2
| | | | | | | | | | | * code cleanups * refactorings for IC * more refactorings for IC * IC: attach the 'nil' type to its module * IC: refactorings and improvements * IC: progress * IC: more serialization fixes * IC: embarrassing omission * code cleanups
* IC: next steps (#16550)Andreas Rumpf2021-01-071-7/+8
| | | | | | | | | | | | | | | | | | * cleanups * ast.nim: cleanups * IC: no more sym.tab field, stored externally in the module graph * nimble compiles again * rodfiles: store bitwidth of integers and the endianness in the cookie because we serialize 'int' directly * rodfiles: added compilerproc and export sections * rodfiles: added all the missing sections * rodfiles: track the missing information * IC: architecture for lazy loading of proc bodies * make tests green again * completed the lazy loading of proc bodies * symbol lookup integration, part 1 * symbol lookup integration, part 2 * symbol lookup integration, part 3 * make tcompilerapi work again * rodfiles: fixed config change handling
* big steps torwards an efficient, simple IC implementation (#16543)Andreas Rumpf2021-01-021-3/+3
| | | | | | | | | | | | | | | | | | | * reworked ID handling * the packed AST now has its own ID mechanism * basic serialization code works * extract rodfiles to its own module * rodfiles: store and compare configs * rodfiles: store dependencies * store config at the end * precise dependency tracking * dependency tracking for rodfiles * completed loading of PSym, PType, etc * removed dead code * bugfix: do not realloc seqs when taking addr into an element * make IC opt-in for now * makes tcompilerapi green again * final cleanups Co-authored-by: Andy Davidoff <github@andy.disruptek.com>
* fixes #16069; [backport:1.2] [backport:1.4] (#16115)Andreas Rumpf2020-11-241-0/+5
| | | | | * fixes #16069; refs https://github.com/nim-lang/RFCs/issues/257 [backport:1.2] [backport:1.4] * make tests green again
* explicit ID generation for easier IC (#15559)Andreas Rumpf2020-10-251-30/+32
| | | | | | | | | | | | | | | | | * refactoring: idents don't need inheritance * refactoring: adding an IdGenerator (part 1) * refactoring: adding an IdGenerator (part 2) * refactoring: adding an IdGenerator (part 3) * refactoring: adding an IdGenerator (part 4) * refactoring: adding an IdGenerator (part 5) * refactoring: adding an IdGenerator (part 5) * IdGenerator must be a ref type; hello world works again * make bootstrapping work again * progress: add back the 'exactReplica' ideas * added back the missing exactReplica hacks * make tcompilerapi work again * make important packages green * attempt to fix the build for 32 bit machines (probably need a better solution here)