summary refs log tree commit diff stats
path: root/compiler/injectdestructors.nim
Commit message (Collapse)AuthorAgeFilesLines
* fixes #23907; Double destroy using proc type alias with a sink (#23909)ringabout2024-08-111-1/+2
| | | fixes #23907
* fixes #23775; injectdestructors now handles discardable statements (#23780)ringabout2024-07-021-2/+2
| | | fixes #23775
* fixes #20048; fixes #15746; don't sink object fields if it's of openarray ↵ringabout2024-06-151-1/+2
| | | | | | type (#23608) fixes #20048 fixes #15746
* fixes #23524; global variables cannot be analysed when injecting `move` (#23529)ringabout2024-04-241-3/+3
| | | | | | | | | | | | fixes #23524 ```nim proc isAnalysableFieldAccess*(orig: PNode; owner: PSym): bool = ... result = n.kind == nkSym and n.sym.owner == owner and {sfGlobal, sfThread, sfCursor} * n.sym.flags == {} and (n.sym.kind != skParam or isSinkParam(n.sym)) ``` In `isAnalysableFieldAccess`, globals, cursors are already rejected
* fixes #23505; fixes injectdestructors errors on transformed addr (deref) ↵ringabout2024-04-181-1/+4
| | | | | refs (#23507) fixes #23505
* fixes #23440; fixes destruction for temporary object subclass (#23452)ringabout2024-04-051-3/+13
| | | fixes #23440
* chore: fix some typos (#23412)soonsouth2024-03-161-1/+1
| | | Signed-off-by: soonsouth <cuibuwei@163.com>
* fixes sink regression for ORC; ref #23354 (#23359)ringabout2024-03-031-1/+2
| | | | | | | | | ref #23354 The new move analyzer requires types that have the tfAsgn flag (otherwise `lastRead` will return true); tfAsgn is included when the destructor is not trival. But it should consider the assignement for objects in this case because objects might have a trival destructors but it's the assignement that matters when it is passed to sink parameters.
* fixes #22723; skips tyUserTypeClasses in injectdestructors (#23341)ringabout2024-02-241-9/+10
| | | fixes #22723
* fixes #23247; don't destroy openarray since it doesn't own the data (#23254)ringabout2024-01-261-2/+7
| | | | | | | | | | | | | | | | | | | | | | | fixes #23247 closes #23251 (which accounts for why the openarray type is lifted because ops are lifted for openarray conversions) related: https://github.com/nim-lang/Nim/pull/18713 It seems to me that openarray doesn't own the data, so it cannot destroy itself. The same case should be applied to https://github.com/nim-lang/Nim/issues/19435. It shouldn't be destroyed even openarray can have a destructor. A cleanup will be followed for https://github.com/nim-lang/Nim/pull/19723 if it makes sense. According to https://github.com/nim-lang/Nim/pull/12073, it lifts destructor for openarray when openarray is sunk into the function, when means `sink openarray` owns the data and needs to destroy it. In other cases, destructor shouldn't be lifted for `openarray` in the first place and it shouldn't destroy the data if it doesn't own it. --------- Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* type refactor: part 4 (#23077)Andreas Rumpf2023-12-151-2/+2
|
* Types: Refactorings; step 1 (#23055)Andreas Rumpf2023-12-121-2/+2
|
* fixes #22552 (#23014)Andreas Rumpf2023-12-021-0/+2
|
* IC: progress and refactorings (#22961)Andreas Rumpf2023-11-201-1/+1
|
* fixes #22866; fixes #19998; ensure destruction for Object construction with ↵ringabout2023-11-021-1/+3
| | | | | | custom destructors (#22901) fixes #22866; fixes #19998
* prepare for the enforcement of `std` prefix (#22873)ringabout2023-10-291-2/+4
| | | follow up https://github.com/nim-lang/Nim/pull/22851
* Fix #21722 (#22512)SirOlaf2023-08-191-6/+8
| | | | | | | | | | | * Keep return in mind for sink * Keep track of return using bool instead of mode * Update compiler/injectdestructors.nim * Add back IsReturn --------- Co-authored-by: SirOlaf <> Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* fixes #22357; don't sink elements of var tuple cursors (#22486)ringabout2023-08-161-1/+3
|
* use strictdefs for compiler (#22365)ringabout2023-08-061-1/+5
| | | | | | | | | | | | | | | * wip; use strictdefs for compiler * checkpoint * complete the chores * more fixes * first phase cleanup * Update compiler/bitsets.nim * cleanup
* fix set op related to {sfGlobal, sfPure} (#22393)Bung2023-08-061-1/+1
|
* fix #15005; [ARC] Global variable declared in a block is destroyed too… ↵Bung2023-08-061-1/+2
| | | | | (#22388) * fix #15005 [ARC] Global variable declared in a block is destroyed too early
* implement `ensureMove` (#22339)ringabout2023-07-291-3/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * implement `ensureMove` * use an additional flag * improve some logics * progress: fixes discard ensureMove * forbids nested expressions * improve error messages * checkpoint * fixes cursor * ADD MORE TESTS * fixes cursorinference again * tiny cleanup * improve error messages * fixes docs * implement comments add more tests * fixes js
* fixes #22132; hoisted openArray params result in erroneous code (#22224)ringabout2023-07-051-1/+4
|
* allow destructors to accept non var parameters; deprecate `proc =destroy(x: ↵ringabout2023-06-211-2/+6
| | | | | | | | | | var T)` (#22130) * make destructors accept non var parameters * define nimAllowNonVarDestructor * add a test case and a changelog * update documentation and error messages * deprecate destructors taking 'var T'
* fixes #22058; invalid free with {.noSideEffect.} in template (#22088)ringabout2023-06-131-20/+19
|
* fixes overriden typo (#22044)ringabout2023-06-081-2/+2
|
* infer error for `=dup` if there is a custom `=copy` error hook (#22004)ringabout2023-06-051-1/+10
|
* lift the `=dup` hook (#21903)ringabout2023-06-021-11/+7
| | | | | | * fixes tests again * remove helper functions * fixes closures, owned refs * final cleanup
* fixes #21974; fixes sameConstant fieldDefect (#21981)ringabout2023-06-011-1/+1
| | | | | * fixes #21974; fixes sameConstant fieldDefect * add a test case
* improve `wasMoved` hooks; allow reset to use the overridden `wasMoved` hook ↵ringabout2023-05-121-1/+1
| | | | | | | (#21831) * improve `wasMoved` hooks * Because `wasMoved` is lifted
* adds documentation for `=wasMoved` and `=dup` hooks and small fixes (#21827)ringabout2023-05-111-1/+3
| | | | | | | | | | | * adds documentation for `=wasMoved` and `=dup` hooks and small fixes * Update doc/destructors.md * Update doc/destructors.md --------- Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* bring #21802 back; fixes #21753 [backport] (#21815)ringabout2023-05-111-2/+2
| | | | | | | | | | | | | * bring #21802 back; fixes #21753 [backport] * adds tests and multiple fixes * add test cases * refactor and remove startId * fixes custom hooks and adds tests * handle tyUncheckedArray better
* adds an experimental `mm:atomicArc` switch (#21798)ringabout2023-05-081-4/+4
|
* implement `=dup` hook eliminating `wasMoved` and `=copy` pairs (#21586)ringabout2023-05-061-5/+22
| | | | | | | | | | | | | | | | | | | * import `=dup` hook eliminating `wasMoved` and `=copy` pairs * add dup * add a test for dup * fixes documentation * fixes signature * resolve comments * fixes tests * fixes tests * clean up
* fixes #21703; moveOrCopy should consider when vm (#21721)ringabout2023-04-241-1/+2
|
* refactoring in preparation for better, simpler name mangling that wor… ↵Andreas Rumpf2023-04-241-3/+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 #20993 [backport:1.6] (#21574)Andreas Rumpf2023-03-281-16/+33
| | | | | * fixes #20993 [backport:1.6] * proper line endings for the test file
* fix #18977; disallow change branch of an object variant in ORC (#21526)ringabout2023-03-161-12/+33
| | | | | | | | | | | * fix #18977 disallow change branch of an object variant in ORC * check errors for goto exception * fixes conditions * fixes tests * add a test case for #18977
* fixes #20139; hash types based on its path relative to its package path ↵ringabout2023-03-021-1/+1
| | | | | | | | | | | | | | | (#21274) [backport:1.6] * fixes #20139; hash types based on its path relative its project * add a test case * fixes procs * better implementation and test case --------- Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* fixes #19291; implements `wasMoved` hook (#21303)ringabout2023-03-021-5/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * fixes #19291; implements `wasMoved` hook * basics * checkpoint * finish `wasMoved` * add a test for #19291 * add documentation and changelog * work `attachedWasMoved` with generics * fixes optimizer * register `=wasMoved` * handle wasMoved magcis * check another round * some patches * try `op == nil` * nicer * generate `wasMoved` before `destroy` * try again * fixes tests * default wasMoved * Update tests/destructor/tv2_cast.nim * Update tests/destructor/tv2_cast.nim * Update tests/arc/topt_refcursors.nim
* Dont produce initing moves for sfNoInit variables in closure env (#21026)Yuriy Glukhov2022-12-051-1/+4
|
* Arc global (#20768)Bung2022-11-061-1/+1
| | | | | | | | | | | | | | | * temp * unsure * fix condition * port macro arc runable examples to one file * trigger doc ci * fix Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com>
* Revert "fix arc global variable issues" (#20764)ringabout2022-11-051-5/+2
| | | | | | | * Revert "fix arc global variable issues (#20759)" This reverts commit a3d32a4176539d0829a4e868f4b005a1a71eb7ee. * trigger documentation builds
* fix arc global variable issues (#20759)Bung2022-11-051-2/+5
| | | | | * temp * unsure
* fixes #20572 (#20585)Andreas Rumpf2022-10-171-37/+47
| | | | | * fixes #20572 * added a test case
* cleanup nfFirstWrite flags (#20500)Andreas Rumpf2022-10-051-1/+1
|
* [ARC] fixes #18645; C Compiler error when initializing {.global.} with a ↵ringabout2022-10-031-12/+17
| | | | | | | | | | block (#19953) * fixes #18645; C Compiler error when initializing {.global.} with a block: * arguably cleaner solution Co-authored-by: xflywind <43030857+xflywind@users.noreply.github.com> Co-authored-by: Araq <rumpf_a@web.de>
* new move analyser2 (#20471)Andreas Rumpf2022-10-011-197/+136
| | | | | | | | * 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-3/+3
| | | | | | | | | | | | | | | | | | | | | | | * 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
* fixes #20303; wasMoved expressions with side effects for ORC (#20307) [backport]ringabout2022-09-081-2/+25
| | | fixes #20303; wasMoved expressions with side effects