summary refs log tree commit diff stats
path: root/lib/system
diff options
context:
space:
mode:
authorringabout <43030857+ringabout@users.noreply.github.com>2023-05-07 03:36:57 +0800
committerGitHub <noreply@github.com>2023-05-06 21:36:57 +0200
commitb562e1e6d85d5c64eec1d714257e2f728e60f12f (patch)
tree67c4dad9040ab9164cabf578695e366b020efc33 /lib/system
parentba698d37c3254072a3bb946d3750ceaf450da7b4 (diff)
downloadNim-b562e1e6d85d5c64eec1d714257e2f728e60f12f.tar.gz
implement `=dup` hook eliminating `wasMoved` and `=copy` pairs (#21586)
* 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
Diffstat (limited to 'lib/system')
-rw-r--r--lib/system/arc.nim4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/system/arc.nim b/lib/system/arc.nim
index d8527e1e4..55c4c412a 100644
--- a/lib/system/arc.nim
+++ b/lib/system/arc.nim
@@ -185,6 +185,10 @@ proc nimDecRefIsLast(p: pointer): bool {.compilerRtl, inl.} =
       when traceCollector:
         cprintf("[DeCREF] %p\n", cell)
 
+proc nimDupRef(dest: ptr pointer, src: pointer) {.compilerRtl, inl.} =
+  dest[] = src
+  if src != nil: nimIncRef src
+
 proc GC_unref*[T](x: ref T) =
   ## New runtime only supports this operation for 'ref T'.
   var y {.cursor.} = x