temporary debugging code for the memory leak investigation
This commit is contained in:
parent
a42545ea3e
commit
c67520a7c5
10 changed files with 125 additions and 25 deletions
|
|
@ -517,7 +517,7 @@ type
|
|||
TNodeSeq* = seq[PNode]
|
||||
PType* = ref TType
|
||||
PSym* = ref TSym
|
||||
TNode*{.acyclic, final.} = object # on a 32bit machine, this takes 32 bytes
|
||||
TNode*{.final.} = object # on a 32bit machine, this takes 32 bytes
|
||||
typ*: PType
|
||||
comment*: string
|
||||
info*: TLineInfo
|
||||
|
|
|
|||
|
|
@ -77,6 +77,15 @@ proc getSysType(kind: TTypeKind): PType =
|
|||
var
|
||||
intTypeCache: array[-5..64, PType]
|
||||
|
||||
proc resetSysTypes* =
|
||||
systemModule = nil
|
||||
initStrTable(compilerprocs)
|
||||
for i in low(gSysTypes)..high(gSysTypes):
|
||||
gSysTypes[i] = nil
|
||||
|
||||
for i in low(intTypeCache)..high(intTypeCache):
|
||||
intTypeCache[i] = nil
|
||||
|
||||
proc getIntLitType*(literal: PNode): PType =
|
||||
# we cache some common integer literal types for performance:
|
||||
let value = literal.intVal
|
||||
|
|
|
|||
|
|
@ -89,13 +89,23 @@ proc addDep(x: Psym, dep: int32) =
|
|||
growCache gMemCacheData, dep
|
||||
gMemCacheData[x.position].deps.safeAdd(dep)
|
||||
|
||||
proc ResetModule(fileIdx: int32) =
|
||||
echo "HARD RESETTING ", fileIdx.toFilename
|
||||
gMemCacheData[fileIdx].needsRecompile = Yes
|
||||
gCompiledModules[fileIdx] = nil
|
||||
cgendata.gModules[fileIdx] = nil
|
||||
|
||||
proc ResetAllModules =
|
||||
for i in 0..gCompiledModules.high:
|
||||
if gCompiledModules[i] != nil:
|
||||
ResetModule(i.int32)
|
||||
|
||||
for m in cgenModules():
|
||||
echo "CGEN MODULE FOUND"
|
||||
|
||||
proc checkDepMem(fileIdx: int32): TNeedRecompile =
|
||||
template markDirty =
|
||||
echo "HARD RESETTING ", fileIdx.toFilename
|
||||
gMemCacheData[fileIdx].needsRecompile = Yes
|
||||
gCompiledModules[fileIdx] = nil
|
||||
cgendata.gModules[fileIdx] = nil
|
||||
|
||||
ResetModule(fileIdx)
|
||||
return Yes
|
||||
|
||||
if gMemCacheData[fileIdx].needsRecompile != Maybe:
|
||||
|
|
@ -377,7 +387,13 @@ proc wantMainModule =
|
|||
if gProjectFull.len == 0:
|
||||
Fatal(gCmdLineInfo, errCommandExpectsFilename)
|
||||
gProjectMainIdx = addFileExt(gProjectFull, nimExt).fileInfoIdx
|
||||
|
||||
|
||||
var oss: PGenericSeq
|
||||
proc dbgseqimp(x: PGenericSeq) {.cdecl.} =
|
||||
oss = x
|
||||
|
||||
seqdbg = dbgseqimp
|
||||
|
||||
proc MainCommand =
|
||||
# In "nimrod serve" scenario, each command must reset the registered passes
|
||||
clearPasses()
|
||||
|
|
@ -482,6 +498,48 @@ proc MainCommand =
|
|||
of "e":
|
||||
# XXX: temporary command for easier testing
|
||||
commandEval(mainCommandArg())
|
||||
of "reset":
|
||||
ResetModule(gProjectMainIdx)
|
||||
gcDebugging = true
|
||||
GC_fullCollect()
|
||||
|
||||
resetCompilationLists()
|
||||
ccgutils.resetCaches()
|
||||
ResetAllModules()
|
||||
resetRopeCache()
|
||||
resetSysTypes()
|
||||
gGenericsCache = nil
|
||||
gOwners = @[]
|
||||
rangeDestructorProc = nil
|
||||
|
||||
# XXX: clean these global vars
|
||||
# ccgstmts.gBreakpoints
|
||||
# ccgthreadvars.nimtv
|
||||
# ccgthreadvars.nimtVDeps
|
||||
# ccgthreadvars.nimtvDeclared
|
||||
# cgendata
|
||||
# cgmeth?
|
||||
# condsyms?
|
||||
# depends?
|
||||
# lexer.gLinesCompiled
|
||||
# msgs - error counts
|
||||
# magicsys, when system.nim changes
|
||||
# rodread.rodcompilerProcs
|
||||
# rodread.gTypeTable
|
||||
# rodread.gMods
|
||||
|
||||
# !! ropes.cache
|
||||
# !! semdata.gGenericsCache
|
||||
# semthreads.computed?
|
||||
#
|
||||
# suggest.usageSym
|
||||
#
|
||||
# XXX: can we run out of IDs?
|
||||
# XXX: detect config reloading (implement as error/require restart)
|
||||
# XXX: options are appended (they will accumulate over time)
|
||||
# vis = visimpl
|
||||
GC_fullCollect()
|
||||
echo GC_getStatistics()
|
||||
of "idetools":
|
||||
gCmd = cmdIdeTools
|
||||
if gEvalExpr != "":
|
||||
|
|
|
|||
|
|
@ -114,6 +114,10 @@ proc freezeMutableRope*(r: PRope) {.inline.} =
|
|||
var
|
||||
cache: array[0..2048*2 -1, PRope]
|
||||
|
||||
proc resetRopeCache* =
|
||||
for i in low(cache)..high(cache):
|
||||
cache[i] = nil
|
||||
|
||||
proc RopeInvariant(r: PRope): bool =
|
||||
if r == nil:
|
||||
result = true
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ type
|
|||
# naming it multiple times
|
||||
|
||||
var
|
||||
gGenericsCache: PGenericsCache # save for modularity
|
||||
gGenericsCache*: PGenericsCache # save for modularity
|
||||
|
||||
proc makeInstPair*(s: PSym, inst: PInstantiation): TInstantiationPair =
|
||||
result.genericSym = s
|
||||
|
|
|
|||
|
|
@ -933,7 +933,7 @@ var
|
|||
destructorName = getIdent"destroy_"
|
||||
destructorParam = getIdent"this_"
|
||||
destructorPragma = newIdentNode(getIdent"destructor", UnknownLineInfo())
|
||||
rangeDestructorProc: PSym
|
||||
rangeDestructorProc*: PSym
|
||||
|
||||
proc destroyField(c: PContext, field: PSym, holder: PNode): PNode =
|
||||
if instantiateDestructor(c, field.typ):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue