cleaned up some debugging code

This commit is contained in:
Zahary Karadjov 2013-01-20 21:19:49 +02:00
commit 86bf97a730
8 changed files with 66 additions and 110 deletions

View file

@ -188,19 +188,9 @@ proc genRefAssign(p: BProc, dest, src: TLoc, flags: TAssignmentFlags) =
linefmt(p, cpsStmts, "#asgnRef((void**) $1, $2);$n",
addrLoc(dest), rdLoc(src))
else:
if cnimdbg:
echo "ASSIGN REF ", dest.k, " ", dest.s, " ", dest.r.ropeToStr
if dest.heapRoot != nil:
echo "ROOTED AT ", dest.heapRoot.ropeToStr
linefmt(p, cpsStmts, "#asgnRefNoCycle((void**) $1, $2);$n",
addrLoc(dest), rdLoc(src))
else:
if cnimdbg:
echo "ASSIGN REF ", dest.k, " ", dest.s, " ", dest.r.ropeToStr
if dest.heapRoot != nil:
echo "ROOTED AT ", dest.heapRoot.ropeToStr
linefmt(p, cpsStmts, "#unsureAsgnRef((void**) $1, $2);$n",
addrLoc(dest), rdLoc(src))
if needToKeepAlive in flags: keepAlive(p, dest)

View file

@ -1133,18 +1133,16 @@ proc rawNewModule(module: PSym): BModule =
result = rawNewModule(module, module.filename)
proc newModule(module: PSym): BModule =
result = getCgenModule(module)
if result == nil:
result = rawNewModule(module)
growCache gModules, module.position
gModules[module.position] = result
# we should create only one cgen module for each module sym
InternalAssert getCgenModule(module) == nil
if (optDeadCodeElim in gGlobalOptions):
if (sfDeadCodeElim in module.flags):
InternalError("added pending module twice: " & module.filename)
else:
echo "CGEN CACHED MODULE: ", result.filename
assert optCaasEnabled in gGlobalOptions
result = rawNewModule(module)
growCache gModules, module.position
gModules[module.position] = result
if (optDeadCodeElim in gGlobalOptions):
if (sfDeadCodeElim in module.flags):
InternalError("added pending module twice: " & module.filename)
proc myOpen(module: PSym): PPassContext =
result = newModule(module)
@ -1260,7 +1258,6 @@ proc updateCachedModule(m: BModule) =
let cfilenoext = changeFileExt(cfile, "")
if mergeRequired(m):
echo "MERGE REQUIRED FOR ", m.filename
mergeFiles(cfile, m)
genInitCode(m)
finishTypeDescriptions(m)
@ -1271,6 +1268,7 @@ proc updateCachedModule(m: BModule) =
addFileToLink(cfilenoext)
proc cgenCaasUpdate* =
# XXX(zah): clean-up the fromCache mess
for m in cgenModules():
if m.fromCache: m.updateCachedModule

View file

@ -143,7 +143,8 @@ proc newProc*(prc: PSym, module: BModule): BProc =
iterator cgenModules*: var BModule =
for i in 0..high(gModules):
# some modules (like stdin) may exist only in memory.
# they won't have a cgen BModule for them and we must skip them.
# ultimately, we are iterating over the file ids here.
# some "files" won't have an associated cgen module (like stdin)
# and we must skip over them.
if gModules[i] != nil: yield gModules[i]

View file

@ -509,10 +509,10 @@ proc getEscapedChar(L: var TLexer, tok: var TToken) =
else: lexMessage(L, errInvalidCharacterConstant)
else: lexMessage(L, errInvalidCharacterConstant)
proc newString(s: cstring, l: int): string =
proc newString(s: cstring, len: int): string =
## XXX, how come there is no support for this?
result = newString(l)
for i in 0 .. <l:
result = newString(len)
for i in 0 .. <len:
result[i] = s[i]
proc HandleCRLF(L: var TLexer, pos: int): int =

View file

@ -442,9 +442,14 @@ proc resetMemory =
GC_fullCollect()
echo GC_getStatistics()
const
SimiluateCaasMemReset = false
PrintRopeCacheStats = false
proc MainCommand =
gGlobalOptions.incl(optCaasEnabled)
when SimiluateCaasMemReset:
gGlobalOptions.incl(optCaasEnabled)
# In "nimrod serve" scenario, each command must reset the registered passes
clearPasses()
gLastCmdTime = epochTime()
@ -561,19 +566,21 @@ proc MainCommand =
gGlobalOptions.incl(optCaasEnabled)
msgs.gErrorMax = high(int) # do not stop after first error
serve(MainCommand)
else: rawMessage(errInvalidCommandX, command)
else:
rawMessage(errInvalidCommandX, command)
if msgs.gErrorCounter == 0 and gCmd notin {cmdInterpret, cmdRun}:
rawMessage(hintSuccessX, [$gLinesCompiled,
formatFloat(epochTime() - gLastCmdTime, ffDecimal, 3),
formatSize(getTotalMem())])
echo "rope cache stats: "
echo " tries : ", gCacheTries
echo " misses: ", gCacheMisses
echo " int tries: ", gCacheIntTries
echo " efficiency: ", formatFloat(1-(gCacheMisses.float/gCacheTries.float), ffDecimal, 3)
when PrintRopeCacheStats:
echo "rope cache stats: "
echo " tries : ", gCacheTries
echo " misses: ", gCacheMisses
echo " int tries: ", gCacheIntTries
echo " efficiency: ", formatFloat(1-(gCacheMisses.float/gCacheTries.float), ffDecimal, 3)
# resetMemory()
when SimiluateCaasMemReset:
resetMemory()