[JS IC] Add API to save/restore binary AST into IR codegen cache

- Add EMPTY stubs for cache accessors
This commit is contained in:
Roman Artemev
2021-09-09 15:29:36 +03:00
committed by teamcityserver
parent 3b53c97c2c
commit 08aa909569
@@ -35,6 +35,37 @@ interface PersistentCacheProvider {
fun inlineHashes(path: String, sigResolver: (Int) -> IdSignature): Map<IdSignature, TransHash>
fun allInlineHashes(sigResolver: (String, Int) -> IdSignature): Map<IdSignature, TransHash>
fun binaryAst(path: String): ByteArray
companion object {
val EMPTY = object : PersistentCacheProvider {
override fun fileFingerPrint(path: String): Hash {
return 0
}
override fun serializedParts(path: String): SerializedIcDataForFile {
TODO("..")
}
override fun inlineGraphForFile(path: String, sigResolver: (Int) -> IdSignature): Collection<Pair<IdSignature, TransHash>> {
return emptyList()
}
override fun inlineHashes(path: String, sigResolver: (Int) -> IdSignature): Map<IdSignature, TransHash> {
return emptyMap()
}
override fun allInlineHashes(sigResolver: (String, Int) -> IdSignature): Map<IdSignature, TransHash> {
return emptyMap()
}
override fun binaryAst(path: String): ByteArray {
return ByteArray(0)
}
}
}
}
@@ -110,6 +141,10 @@ class PersistentCacheProviderImpl(private val cachePath: String) : PersistentCac
return result
}
override fun binaryAst(path: String): ByteArray {
TODO("Not yet implemented")
}
}
interface PersistentCacheConsumer {
@@ -117,7 +152,40 @@ interface PersistentCacheConsumer {
fun commitFileFingerPrint(path: String, fingerprint: Hash)
fun commitInlineGraph(path: String, hashes: Collection<Pair<IdSignature, TransHash>>, sigResolver: (IdSignature) -> Int)
fun commitICCacheData(path: String, icData: SerializedIcDataForFile)
fun commitBinaryAst(path: String, astData: ByteArray)
fun invalidateForFile(path: String)
companion object {
val EMPTY = object : PersistentCacheConsumer {
override fun commitInlineFunctions(
path: String,
hashes: Collection<Pair<IdSignature, TransHash>>,
sigResolver: (IdSignature) -> Int
) {
}
override fun commitFileFingerPrint(path: String, fingerprint: Hash) {
}
override fun commitInlineGraph(
path: String,
hashes: Collection<Pair<IdSignature, TransHash>>,
sigResolver: (IdSignature) -> Int
) {
}
override fun commitICCacheData(path: String, icData: SerializedIcDataForFile) {
}
override fun invalidateForFile(path: String) {
}
override fun commitBinaryAst(path: String, astData: ByteArray) {
}
}
}
}
@@ -181,4 +249,8 @@ class PersistentCacheConsumerImpl(private val cachePath: String) : PersistentCac
// TODO: once per-file invalidation is integrated into IC delete the whole directory including PIR parts
//fileDir.deleteRecursively()
}
override fun commitBinaryAst(path: String, astData: ByteArray) {
TODO("Not yet implemented")
}
}