parent
c1a06bd56e
commit
4395a26764
4 changed files with 26 additions and 3 deletions
|
|
@ -25,10 +25,10 @@ proc getTraverseProc(p: BProc, v: PSym): Rope =
|
||||||
|
|
||||||
proc registerTraverseProc(p: BProc, v: PSym, traverseProc: Rope) =
|
proc registerTraverseProc(p: BProc, v: PSym, traverseProc: Rope) =
|
||||||
if sfThread in v.flags:
|
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])
|
"$n\t#nimRegisterThreadLocalMarker($1);$n$n", [traverseProc])
|
||||||
else:
|
else:
|
||||||
appcg(p.module, p.module.initProc.procSec(cpsInit),
|
appcg(p.module, p.module.preInitProc.procSec(cpsInit),
|
||||||
"$n\t#nimRegisterGlobalMarker($1);$n$n", [traverseProc])
|
"$n\t#nimRegisterGlobalMarker($1);$n$n", [traverseProc])
|
||||||
|
|
||||||
proc isAssignedImmediately(conf: ConfigRef; n: PNode): bool {.inline.} =
|
proc isAssignedImmediately(conf: ConfigRef; n: PNode): bool {.inline.} =
|
||||||
|
|
|
||||||
|
|
@ -1654,7 +1654,7 @@ proc genInitCode(m: BModule) =
|
||||||
writeSection(preInitProc, cpsLocals)
|
writeSection(preInitProc, cpsLocals)
|
||||||
writeSection(preInitProc, cpsInit, m.hcrOn)
|
writeSection(preInitProc, cpsInit, m.hcrOn)
|
||||||
writeSection(preInitProc, cpsStmts)
|
writeSection(preInitProc, cpsStmts)
|
||||||
prc.addf("}$N", [])
|
prc.addf("}/* preInitProc end */$N", [])
|
||||||
when false:
|
when false:
|
||||||
m.initProc.blocks[0].sections[cpsLocals].add m.preInitProc.s(cpsLocals)
|
m.initProc.blocks[0].sections[cpsLocals].add m.preInitProc.s(cpsLocals)
|
||||||
m.initProc.blocks[0].sections[cpsInit].prepend m.preInitProc.s(cpsInit)
|
m.initProc.blocks[0].sections[cpsInit].prepend m.preInitProc.s(cpsInit)
|
||||||
|
|
|
||||||
|
|
@ -174,6 +174,7 @@ proc gcTests(r: var TResults, cat: Category, options: string) =
|
||||||
|
|
||||||
test "stackrefleak"
|
test "stackrefleak"
|
||||||
test "cyclecollector"
|
test "cyclecollector"
|
||||||
|
test "trace_globals"
|
||||||
|
|
||||||
proc longGCTests(r: var TResults, cat: Category, options: string) =
|
proc longGCTests(r: var TResults, cat: Category, options: string) =
|
||||||
when defined(windows):
|
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()
|
||||||
Loading…
Add table
Add a link
Reference in a new issue