JS: don't load binary AST unless required by the inliner
This commit is contained in:
@@ -72,7 +72,7 @@ open class IncrementalJsCache(cachesDir: File) : AbstractIncrementalCache<FqName
|
||||
|
||||
for ((srcFile, data) in translatedFiles) {
|
||||
dirtySources.remove(srcFile)
|
||||
val (binaryMetadata, binaryAst) = data
|
||||
val (binaryMetadata, binaryAst, header) = data
|
||||
|
||||
val oldProtoMap = translationResults[srcFile]?.metadata?.let { getProtoData(srcFile, it) } ?: emptyMap()
|
||||
val newProtoMap = getProtoData(srcFile, binaryMetadata)
|
||||
@@ -89,7 +89,7 @@ open class IncrementalJsCache(cachesDir: File) : AbstractIncrementalCache<FqName
|
||||
changesCollector.collectProtoChanges(oldProtoMap[classId], newProtoMap[classId])
|
||||
}
|
||||
|
||||
translationResults.put(srcFile, binaryMetadata, binaryAst)
|
||||
translationResults.put(srcFile, binaryMetadata, binaryAst, header)
|
||||
}
|
||||
|
||||
for ((srcFile, inlineDeclarations) in incrementalResults.inlineFunctions) {
|
||||
@@ -130,6 +130,9 @@ private object TranslationResultValueExternalizer : DataExternalizer<Translation
|
||||
|
||||
output.writeInt(value.binaryAst.size)
|
||||
output.write(value.binaryAst)
|
||||
|
||||
output.writeInt(value.header.size)
|
||||
output.write(value.header)
|
||||
}
|
||||
|
||||
override fun read(input: DataInput): TranslationResultValue {
|
||||
@@ -141,16 +144,20 @@ private object TranslationResultValueExternalizer : DataExternalizer<Translation
|
||||
val binaryAst = ByteArray(binaryAstSize)
|
||||
input.readFully(binaryAst)
|
||||
|
||||
return TranslationResultValue(metadata = metadata, binaryAst = binaryAst)
|
||||
val headerSize = input.readInt()
|
||||
val header = ByteArray(headerSize)
|
||||
input.readFully(header)
|
||||
|
||||
return TranslationResultValue(metadata = metadata, binaryAst = binaryAst, header = header)
|
||||
}
|
||||
}
|
||||
|
||||
private class TranslationResultMap(storageFile: File) : BasicStringMap<TranslationResultValue>(storageFile, TranslationResultValueExternalizer) {
|
||||
override fun dumpValue(value: TranslationResultValue): String =
|
||||
"Metadata: ${value.metadata.md5()}, Binary AST: ${value.binaryAst.md5()}"
|
||||
"Metadata: ${value.metadata.md5()}, Binary AST: ${value.binaryAst.md5()}, Header: ${value.header.md5()}"
|
||||
|
||||
fun put(file: File, newMetadata: ByteArray, newBinaryAst: ByteArray) {
|
||||
storage[file.canonicalPath] = TranslationResultValue(metadata = newMetadata, binaryAst = newBinaryAst)
|
||||
fun put(file: File, newMetadata: ByteArray, newBinaryAst: ByteArray, newHeader: ByteArray) {
|
||||
storage[file.canonicalPath] = TranslationResultValue(metadata = newMetadata, binaryAst = newBinaryAst, header = newHeader)
|
||||
}
|
||||
|
||||
operator fun get(file: File): TranslationResultValue? =
|
||||
|
||||
Reference in New Issue
Block a user