[JS IR] Move the JS AST serialization right before the IC data committing
It allows not to keep the binary representation in memory
This commit is contained in:
committed by
Space Team
parent
eb781168b8
commit
c0a1fa6f98
@@ -10,6 +10,7 @@ import org.jetbrains.kotlin.ir.backend.js.WholeWorldStageController
|
||||
import org.jetbrains.kotlin.ir.backend.js.ic.*
|
||||
import org.jetbrains.kotlin.ir.backend.js.moduleName
|
||||
import org.jetbrains.kotlin.ir.backend.js.utils.serialization.JsIrAstDeserializer
|
||||
import org.jetbrains.kotlin.ir.backend.js.utils.serialization.JsIrAstSerializer
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFactoryImplForJsIC
|
||||
import org.jetbrains.kotlin.js.test.handlers.JsBoxRunner
|
||||
import org.jetbrains.kotlin.konan.properties.propertyList
|
||||
@@ -24,6 +25,7 @@ import org.jetbrains.kotlin.test.services.compilerConfigurationProvider
|
||||
import org.jetbrains.kotlin.test.services.configuration.JsEnvironmentConfigurator
|
||||
import org.jetbrains.kotlin.test.services.jsLibraryProvider
|
||||
import java.io.ByteArrayInputStream
|
||||
import java.io.ByteArrayOutputStream
|
||||
import java.io.File
|
||||
|
||||
private class TestArtifactCache(val moduleName: String, val binaryAsts: MutableMap<String, ByteArray> = mutableMapOf()) {
|
||||
@@ -34,7 +36,7 @@ private class TestArtifactCache(val moduleName: String, val binaryAsts: MutableM
|
||||
fileArtifacts = binaryAsts.entries.map {
|
||||
SrcFileArtifact(
|
||||
srcFilePath = it.key,
|
||||
// TODO: It will be better to use saved fragments (from JsIrFragmentAndBinaryAst), but it doesn't work
|
||||
// TODO: It will be better to use saved fragments, but it doesn't work
|
||||
// Merger.merge() + JsNode.resolveTemporaryNames() modify fragments,
|
||||
// therefore the sequential calls produce different results
|
||||
fragment = deserializer.deserialize(ByteArrayInputStream(it.value))
|
||||
@@ -146,9 +148,13 @@ class JsIrIncrementalDataProvider(private val testServices: TestServices) : Test
|
||||
)
|
||||
|
||||
val moduleCache = icCache[canonicalPath] ?: TestArtifactCache(mainModuleIr.name.asString())
|
||||
|
||||
val serializer = JsIrAstSerializer()
|
||||
for (rebuiltFile in rebuiltFiles) {
|
||||
if (rebuiltFile.irFile.module == mainModuleIr) {
|
||||
moduleCache.binaryAsts[rebuiltFile.irFile.fileEntry.name] = rebuiltFile.binaryAst
|
||||
if (rebuiltFile.first.module == mainModuleIr) {
|
||||
val output = ByteArrayOutputStream()
|
||||
serializer.serialize(rebuiltFile.second, output)
|
||||
moduleCache.binaryAsts[rebuiltFile.first.fileEntry.name] = output.toByteArray()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user