[JS IC] Write cache info in per-file mode too
- make sure that file is existed and not crashes the compiler
This commit is contained in:
committed by
teamcityserver
parent
a55be02007
commit
f85a59b7f3
@@ -150,6 +150,7 @@ private fun KotlinLibrary.filesAndSigReaders(): List<Pair<String, IdSignatureDes
|
||||
}
|
||||
|
||||
private fun buildCacheForModule(
|
||||
libraryPath: String,
|
||||
irModule: IrModuleFragment,
|
||||
dirtyFiles: Collection<String>,
|
||||
cleanInlineHashes: Map<IdSignature, Hash>,
|
||||
@@ -195,6 +196,7 @@ private fun buildCacheForModule(
|
||||
// TODO: actual way of building a cache could change in future
|
||||
cacheConsumer.buildForFile(irFile)
|
||||
}
|
||||
cacheConsumer.commitLibraryPath(libraryPath)
|
||||
}
|
||||
|
||||
private fun loadModules(
|
||||
@@ -407,6 +409,14 @@ private fun actualizeCacheForModule(
|
||||
|
||||
val deserializers = dirtySet.associateWith { currentModuleDeserializer.signatureDeserializerForFile(it).signatureToIndexMapping() }
|
||||
|
||||
buildCacheForModule(currentIrModule, dirtySet, sigHashes, persistentCacheConsumer, deserializers, fileFingerPrints)
|
||||
buildCacheForModule(
|
||||
library.libraryFile.canonicalPath,
|
||||
currentIrModule,
|
||||
dirtySet,
|
||||
sigHashes,
|
||||
persistentCacheConsumer,
|
||||
deserializers,
|
||||
fileFingerPrints
|
||||
)
|
||||
return false // invalidated and re-built
|
||||
}
|
||||
+23
-4
@@ -132,12 +132,12 @@ class PersistentCacheProviderImpl(private val cachePath: String) : PersistentCac
|
||||
override fun allInlineHashes(sigResolver: (String, Int) -> IdSignature): Map<IdSignature, TransHash> {
|
||||
val result = mutableMapOf<IdSignature, TransHash>()
|
||||
val cachePath = File(cachePath)
|
||||
cachePath.listFiles { file: File -> file.isDirectory }!!.forEach {
|
||||
val fileInfo = File(it, fileInfoFile)
|
||||
cachePath.listFiles { file: File -> file.isDirectory }!!.forEach { f ->
|
||||
val fileInfo = File(f, fileInfoFile)
|
||||
if (fileInfo.exists()) {
|
||||
val fileName = fileInfo.readLines()[0]
|
||||
parseHashList(it, inlineFunctionsFile) { id -> sigResolver(fileName, id) }.forEach {
|
||||
result[it.first] = it.second
|
||||
parseHashList(f, inlineFunctionsFile) { id -> sigResolver(fileName, id) }.forEach { (sig, hash) ->
|
||||
result[sig] = hash
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -161,6 +161,8 @@ interface PersistentCacheConsumer {
|
||||
fun commitBinaryAst(path: String, astData: ByteArray)
|
||||
fun invalidateForFile(path: String)
|
||||
|
||||
fun commitLibraryPath(libraryPath: String)
|
||||
|
||||
companion object {
|
||||
val EMPTY = object : PersistentCacheConsumer {
|
||||
override fun commitInlineFunctions(
|
||||
@@ -190,6 +192,10 @@ interface PersistentCacheConsumer {
|
||||
|
||||
}
|
||||
|
||||
override fun commitLibraryPath(libraryPath: String) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -265,4 +271,17 @@ class PersistentCacheConsumerImpl(private val cachePath: String) : PersistentCac
|
||||
astFile.createNewFile()
|
||||
astFile.writeBytes(astData)
|
||||
}
|
||||
|
||||
override fun commitLibraryPath(libraryPath: String) {
|
||||
val infoFile = File(File(cachePath), "info")
|
||||
if (infoFile.exists()) {
|
||||
infoFile.delete()
|
||||
}
|
||||
infoFile.createNewFile()
|
||||
|
||||
PrintWriter(infoFile).use {
|
||||
it.println(libraryPath)
|
||||
it.println("0")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user