IC: further progress (#17150)
* IC: respect the -f switch * IC: better rod file inspection * progress
This commit is contained in:
parent
f8cfe330b3
commit
8f1fa3e5b0
3 changed files with 19 additions and 12 deletions
|
|
@ -33,7 +33,7 @@ proc isExportedToC(c: var AliveContext; g: PackedModuleGraph; symId: int32): boo
|
||||||
# are not transformed correctly; issue (#411). However, the whole purpose here
|
# are not transformed correctly; issue (#411). However, the whole purpose here
|
||||||
# is to eliminate unused procs. So there is no special logic required for this case.
|
# is to eliminate unused procs. So there is no special logic required for this case.
|
||||||
if sfCompileTime notin flags:
|
if sfCompileTime notin flags:
|
||||||
if ({sfExportc, sfCompilerProc} * flags == {sfExportc}) or
|
if ({sfExportc, sfCompilerProc} * flags != {}) or
|
||||||
(symPtr.kind == skMethod):
|
(symPtr.kind == skMethod):
|
||||||
result = true
|
result = true
|
||||||
# XXX: This used to be a condition to:
|
# XXX: This used to be a condition to:
|
||||||
|
|
@ -52,6 +52,10 @@ proc followLater(c: var AliveContext; g: PackedModuleGraph; module: int; item: i
|
||||||
let opt = g[module].fromDisk.sh.syms[item].options
|
let opt = g[module].fromDisk.sh.syms[item].options
|
||||||
c.stack.add((module, opt, NodePos(body)))
|
c.stack.add((module, opt, NodePos(body)))
|
||||||
|
|
||||||
|
when false:
|
||||||
|
let name = g[module].fromDisk.sh.strings[g[module].fromDisk.sh.syms[item].name]
|
||||||
|
echo "I was called! ", name, " body exists: ", body != emptyNodeId
|
||||||
|
|
||||||
proc requestCompilerProc(c: var AliveContext; g: PackedModuleGraph; name: string) =
|
proc requestCompilerProc(c: var AliveContext; g: PackedModuleGraph; name: string) =
|
||||||
let (module, item) = c.compilerProcs[name]
|
let (module, item) = c.compilerProcs[name]
|
||||||
followLater(c, g, module, item)
|
followLater(c, g, module, item)
|
||||||
|
|
@ -107,7 +111,9 @@ proc aliveCode(c: var AliveContext; g: PackedModuleGraph; tree: PackedTree; n: N
|
||||||
nkFromStmt, nkStaticStmt:
|
nkFromStmt, nkStaticStmt:
|
||||||
discard
|
discard
|
||||||
of nkVarSection, nkLetSection, nkConstSection:
|
of nkVarSection, nkLetSection, nkConstSection:
|
||||||
discard
|
# XXX ignore the defining local variable name?
|
||||||
|
for son in sonsReadonly(tree, n):
|
||||||
|
aliveCode(c, g, tree, son)
|
||||||
of nkChckRangeF, nkChckRange64, nkChckRange:
|
of nkChckRangeF, nkChckRange64, nkChckRange:
|
||||||
rangeCheckAnalysis(c, g, tree, n)
|
rangeCheckAnalysis(c, g, tree, n)
|
||||||
of nkProcDef, nkConverterDef, nkMethodDef, nkLambda, nkDo, nkFuncDef:
|
of nkProcDef, nkConverterDef, nkMethodDef, nkLambda, nkDo, nkFuncDef:
|
||||||
|
|
|
||||||
|
|
@ -453,7 +453,8 @@ proc toPackedNodeTopLevel*(n: PNode, encoder: var PackedEncoder; m: var PackedMo
|
||||||
proc loadError(err: RodFileError; filename: AbsoluteFile) =
|
proc loadError(err: RodFileError; filename: AbsoluteFile) =
|
||||||
echo "Error: ", $err, " loading file: ", filename.string
|
echo "Error: ", $err, " loading file: ", filename.string
|
||||||
|
|
||||||
proc loadRodFile*(filename: AbsoluteFile; m: var PackedModule; config: ConfigRef): RodFileError =
|
proc loadRodFile*(filename: AbsoluteFile; m: var PackedModule; config: ConfigRef;
|
||||||
|
ignoreConfig = false): RodFileError =
|
||||||
m.sh = Shared()
|
m.sh = Shared()
|
||||||
var f = rodfiles.open(filename.string)
|
var f = rodfiles.open(filename.string)
|
||||||
f.loadHeader()
|
f.loadHeader()
|
||||||
|
|
@ -462,7 +463,7 @@ proc loadRodFile*(filename: AbsoluteFile; m: var PackedModule; config: ConfigRef
|
||||||
f.loadPrim m.definedSymbols
|
f.loadPrim m.definedSymbols
|
||||||
f.loadPrim m.cfg
|
f.loadPrim m.cfg
|
||||||
|
|
||||||
if f.err == ok and not configIdentical(m, config):
|
if f.err == ok and not configIdentical(m, config) and not ignoreConfig:
|
||||||
f.err = configMismatch
|
f.err = configMismatch
|
||||||
|
|
||||||
template loadSeqSection(section, data) {.dirty.} =
|
template loadSeqSection(section, data) {.dirty.} =
|
||||||
|
|
@ -875,7 +876,7 @@ proc needsRecompile(g: var PackedModuleGraph; conf: ConfigRef; cache: IdentCache
|
||||||
let rod = toRodFile(conf, AbsoluteFile fullpath)
|
let rod = toRodFile(conf, AbsoluteFile fullpath)
|
||||||
let err = loadRodFile(rod, g[m].fromDisk, conf)
|
let err = loadRodFile(rod, g[m].fromDisk, conf)
|
||||||
if err == ok:
|
if err == ok:
|
||||||
result = false
|
result = optForceFullMake in conf.globalOptions
|
||||||
# check its dependencies:
|
# check its dependencies:
|
||||||
for dep in g[m].fromDisk.imports:
|
for dep in g[m].fromDisk.imports:
|
||||||
let fid = toFileIndex(dep, g[m].fromDisk, conf)
|
let fid = toFileIndex(dep, g[m].fromDisk, conf)
|
||||||
|
|
@ -887,7 +888,9 @@ proc needsRecompile(g: var PackedModuleGraph; conf: ConfigRef; cache: IdentCache
|
||||||
if not result:
|
if not result:
|
||||||
setupLookupTables(g, conf, cache, fileIdx, g[m])
|
setupLookupTables(g, conf, cache, fileIdx, g[m])
|
||||||
cachedModules.add fileIdx
|
cachedModules.add fileIdx
|
||||||
g[m].status = if result: outdated else: loaded
|
g[m].status = loaded
|
||||||
|
else:
|
||||||
|
g[m] = LoadedModule(status: outdated, module: g[m].module)
|
||||||
else:
|
else:
|
||||||
loadError(err, rod)
|
loadError(err, rod)
|
||||||
g[m].status = outdated
|
g[m].status = outdated
|
||||||
|
|
@ -1062,14 +1065,15 @@ proc idgenFromLoadedModule*(m: LoadedModule): IdGenerator =
|
||||||
|
|
||||||
proc rodViewer*(rodfile: AbsoluteFile; config: ConfigRef, cache: IdentCache) =
|
proc rodViewer*(rodfile: AbsoluteFile; config: ConfigRef, cache: IdentCache) =
|
||||||
var m: PackedModule
|
var m: PackedModule
|
||||||
if loadRodFile(rodfile, m, config) != ok:
|
let err = loadRodFile(rodfile, m, config, ignoreConfig=true)
|
||||||
echo "Error: could not load: ", rodfile.string
|
if err != ok:
|
||||||
|
echo "Error: could not load: ", rodfile.string, " reason: ", err
|
||||||
quit 1
|
quit 1
|
||||||
|
|
||||||
when true:
|
when true:
|
||||||
echo "exports:"
|
echo "exports:"
|
||||||
for ex in m.exports:
|
for ex in m.exports:
|
||||||
echo " ", m.sh.strings[ex[0]]
|
echo " ", m.sh.strings[ex[0]], " local ID: ", ex[1]
|
||||||
assert ex[0] == m.sh.syms[ex[1]].name
|
assert ex[0] == m.sh.syms[ex[1]].name
|
||||||
# ex[1] int32
|
# ex[1] int32
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -378,7 +378,6 @@ proc reportUnhandledErrorAux(e: ref Exception) {.nodestroy.} =
|
||||||
# ugly, but avoids heap allocations :-)
|
# ugly, but avoids heap allocations :-)
|
||||||
template xadd(buf, s, slen) =
|
template xadd(buf, s, slen) =
|
||||||
if L + slen < high(buf):
|
if L + slen < high(buf):
|
||||||
|
|
||||||
copyMem(addr(buf[L]), (when s is cstring: s else: cstring(s)), slen)
|
copyMem(addr(buf[L]), (when s is cstring: s else: cstring(s)), slen)
|
||||||
inc L, slen
|
inc L, slen
|
||||||
template add(buf, s) =
|
template add(buf, s) =
|
||||||
|
|
@ -404,8 +403,6 @@ proc reportUnhandledError(e: ref Exception) {.nodestroy.} =
|
||||||
unhandledExceptionHook(e)
|
unhandledExceptionHook(e)
|
||||||
when hostOS != "any":
|
when hostOS != "any":
|
||||||
reportUnhandledErrorAux(e)
|
reportUnhandledErrorAux(e)
|
||||||
else:
|
|
||||||
discard ()
|
|
||||||
|
|
||||||
proc nimLeaveFinally() {.compilerRtl.} =
|
proc nimLeaveFinally() {.compilerRtl.} =
|
||||||
when defined(cpp) and not defined(noCppExceptions) and not gotoBasedExceptions:
|
when defined(cpp) and not defined(noCppExceptions) and not gotoBasedExceptions:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue