mirror of
https://github.com/nim-lang/Nim.git
synced 2026-02-15 07:43:26 +00:00
fixes #7833; still to-do: fix setLen
This commit is contained in:
@@ -1092,17 +1092,20 @@ proc genSeqElemAppend(p: BProc, e: PNode, d: var TLoc) =
|
||||
# seq = (typeof seq) incrSeq(&seq->Sup, sizeof(x));
|
||||
# seq->data[seq->len-1] = x;
|
||||
let seqAppendPattern = if not p.module.compileToCpp:
|
||||
"$1 = ($2) #incrSeqV3(&($1)->Sup, $3);$n"
|
||||
"($2) #incrSeqV3(&($1)->Sup, $3)"
|
||||
else:
|
||||
"$1 = ($2) #incrSeqV3($1, $3);$n"
|
||||
var a, b, dest, tmpL: TLoc
|
||||
"($2) #incrSeqV3($1, $3)"
|
||||
var a, b, dest, tmpL, call: TLoc
|
||||
initLocExpr(p, e.sons[1], a)
|
||||
initLocExpr(p, e.sons[2], b)
|
||||
let seqType = skipTypes(e.sons[1].typ, {tyVar})
|
||||
lineCg(p, cpsStmts, seqAppendPattern, [
|
||||
rdLoc(a),
|
||||
getTypeDesc(p.module, e.sons[1].typ),
|
||||
genTypeInfo(p.module, seqType, e.info)])
|
||||
initLoc(call, locCall, e, OnHeap)
|
||||
call.r = ropecg(p.module, seqAppendPattern, [rdLoc(a),
|
||||
getTypeDesc(p.module, e.sons[1].typ),
|
||||
genTypeInfo(p.module, seqType, e.info)])
|
||||
# emit the write barrier if required, but we can always move here, so
|
||||
# use 'genRefAssign' for the seq.
|
||||
genRefAssign(p, a, call, {})
|
||||
#if bt != b.t:
|
||||
# echo "YES ", e.info, " new: ", typeToString(bt), " old: ", typeToString(b.t)
|
||||
initLoc(dest, locExpr, e.sons[2], OnHeap)
|
||||
|
||||
@@ -72,3 +72,4 @@ proc initDefines*(symbols: StringTableRef) =
|
||||
defineSymbol("nimNoZeroTerminator")
|
||||
defineSymbol("nimNotNil")
|
||||
defineSymbol("nimVmExportFixed")
|
||||
defineSymbol("nimIncrSeqV3")
|
||||
|
||||
@@ -548,7 +548,10 @@ proc growObj(old: pointer, newsize: int, gch: var GcHeap): pointer =
|
||||
gcTrace(res, csAllocated)
|
||||
track("growObj old", ol, 0)
|
||||
track("growObj new", res, newsize)
|
||||
when reallyDealloc:
|
||||
when defined(nimIncrSeqV3):
|
||||
# since we steal the old seq's contents, we set the old length to 0.
|
||||
cast[PGenericSeq](old).len = 0
|
||||
elif reallyDealloc:
|
||||
sysAssert(allocInv(gch.region), "growObj before dealloc")
|
||||
if ol.refcount shr rcShift <=% 1:
|
||||
# free immediately to save space:
|
||||
|
||||
@@ -14,11 +14,11 @@ proc handleRequest(query: string): StringTableRef =
|
||||
let x = foo
|
||||
result = x()
|
||||
|
||||
const Limit = when compileOption("gc", "markAndSweep"): 5*1024*1024 else: 700_000
|
||||
const Limit = 5*1024*1024
|
||||
|
||||
proc main =
|
||||
var counter = 0
|
||||
for i in 0 .. 100_000:
|
||||
for i in 0 .. 10_000_000:
|
||||
for k, v in handleRequest("nick=Elina2&type=activate"):
|
||||
inc counter
|
||||
if counter mod 100 == 0:
|
||||
|
||||
Reference in New Issue
Block a user