summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2019-09-01 23:28:26 +0200
committerAraq <rumpf_a@web.de>2019-09-01 23:28:26 +0200
commitad82e65387f39970b0f12cbcb12d8b382236f3da (patch)
tree16cc389295922ae2fbcbffef3d1accab246ec42d /lib
parentab48d7901e4626120ff430e597cbb32d007e9e0b (diff)
downloadNim-ad82e65387f39970b0f12cbcb12d8b382236f3da.tar.gz
gc:destructors progress
Diffstat (limited to 'lib')
-rw-r--r--lib/core/strs.nim49
-rw-r--r--lib/system.nim2
-rw-r--r--lib/system/gc_ms.nim2
3 files changed, 2 insertions, 51 deletions
diff --git a/lib/core/strs.nim b/lib/core/strs.nim
index 92c39331f..3b7a46ff1 100644
--- a/lib/core/strs.nim
+++ b/lib/core/strs.nim
@@ -9,20 +9,6 @@
 
 ## Default new string implementation used by Nim's core.
 
-when false:
-  # these are to be implemented or changed in the code generator.
-
-  #proc rawNewStringNoInit(space: int): NimString {.compilerproc.}
-  # seems to be unused.
-  proc copyDeepString(src: NimString): NimString {.inline.}
-  # ----------------- sequences ----------------------------------------------
-
-  proc incrSeqV3(s: PGenericSeq, typ: PNimType): PGenericSeq {.compilerproc.}
-  proc setLengthSeqV2(s: PGenericSeq, typ: PNimType, newLen: int): PGenericSeq {.
-      compilerRtl.}
-  proc newSeq(typ: PNimType, len: int): pointer {.compilerRtl.}
-  proc newSeqRC1(typ: PNimType, len: int): pointer {.compilerRtl.}
-
 import allocators
 
 type
@@ -45,41 +31,6 @@ template frees(s) =
   if not isLiteral(s):
     s.p.allocator.dealloc(s.p.allocator, s.p, contentSize(s.p.cap))
 
-when not defined(nimV2):
-  proc `=destroy`(s: var string) =
-    var a = cast[ptr NimStringV2](addr s)
-    frees(a)
-    a.len = 0
-    a.p = nil
-
-  proc `=sink`(x: var string, y: string) =
-    var a = cast[ptr NimStringV2](addr x)
-    var b = cast[ptr NimStringV2](unsafeAddr y)
-    # we hope this is optimized away for not yet alive objects:
-    if unlikely(a.p == b.p): return
-    frees(a)
-    a.len = b.len
-    a.p = b.p
-
-  proc `=`(x: var string, y: string) =
-    var a = cast[ptr NimStringV2](addr x)
-    var b = cast[ptr NimStringV2](unsafeAddr y)
-    if unlikely(a.p == b.p): return
-    frees(a)
-    a.len = b.len
-    if isLiteral(b):
-      # we can shallow copy literals:
-      a.p = b.p
-    else:
-      let allocator = if a.p != nil and a.p.allocator != nil: a.p.allocator else: getLocalAllocator()
-      # we have to allocate the 'cap' here, consider
-      # 'let y = newStringOfCap(); var x = y'
-      # on the other hand... These get turned into moves now.
-      a.p = cast[ptr NimStrPayload](allocator.alloc(allocator, contentSize(b.len)))
-      a.p.allocator = allocator
-      a.p.cap = b.len
-      copyMem(unsafeAddr a.p.data[0], unsafeAddr b.p.data[0], b.len+1)
-
 proc resize(old: int): int {.inline.} =
   if old <= 0: result = 4
   elif old < 65536: result = old * 2
diff --git a/lib/system.nim b/lib/system.nim
index edab33412..6b1421160 100644
--- a/lib/system.nim
+++ b/lib/system.nim
@@ -2093,7 +2093,7 @@ when not defined(JS) and not defined(nimscript) and hostOS != "standalone":
 when not defined(JS) and not defined(nimscript) and hasAlloc and not defined(gcDestructors):
   proc addChar(s: NimString, c: char): NimString {.compilerproc, benign.}
 
-when not defined(gcDestructors):
+when not defined(gcDestructors) or defined(nimscript):
   proc add*[T](x: var seq[T], y: T) {.magic: "AppendSeqElem", noSideEffect.}
     ## Generic proc for adding a data item `y` to a container `x`.
     ##
diff --git a/lib/system/gc_ms.nim b/lib/system/gc_ms.nim
index 87d803485..3ce428930 100644
--- a/lib/system/gc_ms.nim
+++ b/lib/system/gc_ms.nim
@@ -511,7 +511,7 @@ when not defined(useNimRtl):
       gch.tracing = true
 
   proc GC_fullCollect() =
-    var oldThreshold = gch.cycleThreshold
+    let oldThreshold = gch.cycleThreshold
     gch.cycleThreshold = 0 # forces cycle collection
     collectCT(gch, 0)
     gch.cycleThreshold = oldThreshold