mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-28 17:04:41 +00:00
(cherry picked from commit 4395a26764)
This commit is contained in:
@@ -25,10 +25,10 @@ proc getTraverseProc(p: BProc, v: PSym): Rope =
|
||||
|
||||
proc registerTraverseProc(p: BProc, v: PSym, traverseProc: Rope) =
|
||||
if sfThread in v.flags:
|
||||
appcg(p.module, p.module.initProc.procSec(cpsInit),
|
||||
appcg(p.module, p.module.preInitProc.procSec(cpsInit),
|
||||
"$n\t#nimRegisterThreadLocalMarker($1);$n$n", [traverseProc])
|
||||
else:
|
||||
appcg(p.module, p.module.initProc.procSec(cpsInit),
|
||||
appcg(p.module, p.module.preInitProc.procSec(cpsInit),
|
||||
"$n\t#nimRegisterGlobalMarker($1);$n$n", [traverseProc])
|
||||
|
||||
proc isAssignedImmediately(conf: ConfigRef; n: PNode): bool {.inline.} =
|
||||
|
||||
@@ -1645,7 +1645,7 @@ proc genInitCode(m: BModule) =
|
||||
writeSection(preInitProc, cpsLocals)
|
||||
writeSection(preInitProc, cpsInit, m.hcrOn)
|
||||
writeSection(preInitProc, cpsStmts)
|
||||
prc.addf("}$N", [])
|
||||
prc.addf("}/* preInitProc end */$N", [])
|
||||
|
||||
# add new scope for following code, because old vcc compiler need variable
|
||||
# be defined at the top of the block
|
||||
|
||||
@@ -217,6 +217,7 @@ proc gcTests(r: var TResults, cat: Category, options: string) =
|
||||
|
||||
test "stackrefleak"
|
||||
test "cyclecollector"
|
||||
test "trace_globals"
|
||||
|
||||
proc longGCTests(r: var TResults, cat: Category, options: string) =
|
||||
when defined(windows):
|
||||
|
||||
22
tests/gc/trace_globals.nim
Normal file
22
tests/gc/trace_globals.nim
Normal file
@@ -0,0 +1,22 @@
|
||||
discard """
|
||||
output: '''10000000
|
||||
10000000
|
||||
10000000'''
|
||||
"""
|
||||
|
||||
# bug #17085
|
||||
|
||||
proc init(): string =
|
||||
for a in 0..<10000000:
|
||||
result.add 'c'
|
||||
|
||||
proc f() =
|
||||
var a {.global.} = init()
|
||||
var b {.global.} = init()
|
||||
var c {.global.} = init()
|
||||
|
||||
echo a.len
|
||||
echo b.len
|
||||
echo c.len
|
||||
|
||||
f()
|
||||
Reference in New Issue
Block a user