From 08aa9095693655bbca3876d3c73f75bb000dbb0e Mon Sep 17 00:00:00 2001 From: Roman Artemev Date: Thu, 9 Sep 2021 15:29:36 +0300 Subject: [PATCH] [JS IC] Add API to save/restore binary AST into IR codegen cache - Add EMPTY stubs for cache accessors --- .../kotlin/ir/backend/js/ic/CacheAccessors.kt | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/compiler/ir/serialization.js/src/org/jetbrains/kotlin/ir/backend/js/ic/CacheAccessors.kt b/compiler/ir/serialization.js/src/org/jetbrains/kotlin/ir/backend/js/ic/CacheAccessors.kt index 67591a418cf..112915c301f 100644 --- a/compiler/ir/serialization.js/src/org/jetbrains/kotlin/ir/backend/js/ic/CacheAccessors.kt +++ b/compiler/ir/serialization.js/src/org/jetbrains/kotlin/ir/backend/js/ic/CacheAccessors.kt @@ -35,6 +35,37 @@ interface PersistentCacheProvider { fun inlineHashes(path: String, sigResolver: (Int) -> IdSignature): Map fun allInlineHashes(sigResolver: (String, Int) -> IdSignature): Map + + 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> { + return emptyList() + } + + override fun inlineHashes(path: String, sigResolver: (Int) -> IdSignature): Map { + return emptyMap() + } + + override fun allInlineHashes(sigResolver: (String, Int) -> IdSignature): Map { + 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>, 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>, + sigResolver: (IdSignature) -> Int + ) { + } + + override fun commitFileFingerPrint(path: String, fingerprint: Hash) { + } + + override fun commitInlineGraph( + path: String, + hashes: Collection>, + 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") + } }