diff options
author | Araq <rumpf_a@web.de> | 2018-11-22 23:17:38 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2018-11-22 23:17:47 +0100 |
commit | 61d08ebcd8f9ab2f4cb63c0cc61866d46434f2ab (patch) | |
tree | c8f6a3bbab494b175474770504c08d9e27eb5aa4 /compiler/rodimpl.nim | |
parent | 962b2e4b39e92c755975e2e0225fdd7c75fef6d1 (diff) | |
download | Nim-61d08ebcd8f9ab2f4cb63c0cc61866d46434f2ab.tar.gz |
IC: further progress
Diffstat (limited to 'compiler/rodimpl.nim')
-rw-r--r-- | compiler/rodimpl.nim | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/compiler/rodimpl.nim b/compiler/rodimpl.nim index f2e0fd1a2..730328642 100644 --- a/compiler/rodimpl.nim +++ b/compiler/rodimpl.nim @@ -366,13 +366,7 @@ proc storeType(g: ModuleGraph; t: PType) = db.exec(sql"insert into types(nimid, module, data) values (?, ?, ?)", t.id, mid, buf) -proc storeNode*(g: ModuleGraph; module: PSym; n: PNode) = - if g.config.symbolFiles == disabledSf: return - var buf = newStringOfCap(160) - encodeNode(g, module.info, n, buf) - db.exec(sql"insert into toplevelstmts(module, position, data) values (?, ?, ?)", - abs(module.id), module.offset, buf) - inc module.offset +proc transitiveClosure(g: ModuleGraph) = var i = 0 while true: if i > 10_000: @@ -391,9 +385,25 @@ proc storeNode*(g: ModuleGraph; module: PSym; n: PNode) = break inc i +proc storeNode*(g: ModuleGraph; module: PSym; n: PNode) = + if g.config.symbolFiles == disabledSf: return + var buf = newStringOfCap(160) + encodeNode(g, module.info, n, buf) + db.exec(sql"insert into toplevelstmts(module, position, data) values (?, ?, ?)", + abs(module.id), module.offset, buf) + inc module.offset + transitiveClosure(g) + proc recordStmt*(g: ModuleGraph; module: PSym; n: PNode) = storeNode(g, module, n) +proc storeFilename(g: ModuleGraph; fullpath: AbsoluteFile; fileIdx: FileIndex) = + let id = db.getValue(sql"select id from filenames where fullpath = ?", fullpath.string) + if id.len == 0: + let fullhash = hashFileCached(g.config, fileIdx, fullpath) + db.exec(sql"insert into filenames(nimid, fullpath, fullhash) values (?, ?, ?)", + int(fileIdx), fullpath.string, fullhash) + proc storeRemaining*(g: ModuleGraph; module: PSym) = if g.config.symbolFiles == disabledSf: return var stillForwarded: seq[PSym] = @[] @@ -403,6 +413,13 @@ proc storeRemaining*(g: ModuleGraph; module: PSym) = else: stillForwarded.add s swap w.forwardedSyms, stillForwarded + transitiveClosure(g) + var nimid = 0 + for x in items(g.config.m.fileInfos): + # don't store the "command line" entry: + if nimid != 0: + storeFilename(g, x.fullPath, FileIndex(nimid)) + inc nimid # ---------------- decoder ----------------------------------- @@ -880,20 +897,22 @@ proc setupModuleCache*(g: ModuleGraph) = if g.config.symbolFiles == writeOnlySf: removeFile(dbfile) createDir getNimcacheDir(g.config) + let ec = encodeConfig(g) if not fileExists(dbfile): db = open(connection=string dbfile, user="nim", password="", database="nim") createDb(db) - db.exec(sql"insert into config(config) values (?)", encodeConfig(g)) + db.exec(sql"insert into config(config) values (?)", ec) else: db = open(connection=string dbfile, user="nim", password="", database="nim") let oldConfig = db.getValue(sql"select config from config") - g.incr.configChanged = oldConfig != encodeConfig(g) + g.incr.configChanged = oldConfig != ec # ensure the filename IDs stay consistent: for row in db.rows(sql"select fullpath, nimid from filenames order by nimid"): let id = fileInfoIdx(g.config, AbsoluteFile row[0]) doAssert id.int == parseInt(row[1]) + db.exec(sql"update config set config = ?", ec) db.exec(sql"pragma journal_mode=off") # This MUST be turned off, otherwise it's way too slow even for testing purposes: db.exec(sql"pragma SYNCHRONOUS=off") |