[JS IC] Don't persist temporary copies of inline functions

- drop special `IrValueParameterPublicSymbol`
 - drop special `IrAnonymousInitializerPublicSymbolImpl`
 - drop hacky `useGlobalSignatures`
This commit is contained in:
Roman Artemev
2021-07-28 20:25:56 +03:00
committed by teamcityserver
parent b1251c1716
commit b1eeb1fb27
10 changed files with 77 additions and 52 deletions
@@ -15,7 +15,6 @@ import org.jetbrains.kotlin.ir.expressions.IrExpressionBody
import org.jetbrains.kotlin.ir.expressions.persistent.PersistentIrBlockBody
import org.jetbrains.kotlin.ir.expressions.persistent.PersistentIrExpressionBody
import org.jetbrains.kotlin.ir.symbols.*
import org.jetbrains.kotlin.ir.symbols.impl.IrPublicSymbolBase
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.util.IdSignature
import org.jetbrains.kotlin.name.Name
@@ -26,9 +25,9 @@ class PersistentIrFactory : IrFactory {
override var stageController = StageController()
val allDeclarations = mutableListOf<IrDeclaration>()
val allDeclarations = hashSetOf<IrDeclaration>()
val allBodies = mutableListOf<IrBody>()
val allBodies = hashSetOf<IrBody>()
private fun IrDeclaration.register() {
allDeclarations += this
@@ -38,6 +37,15 @@ class PersistentIrFactory : IrFactory {
return (declaration as? PersistentIrDeclarationBase<*>)?.signature ?: declaration.symbol.signature
}
override fun unlistFunction(f: IrFunction) {
allDeclarations.remove(f)
f.dispatchReceiverParameter?.let { allDeclarations.remove(it) }
f.extensionReceiverParameter?.let { allDeclarations.remove(it) }
allDeclarations.removeAll(f.valueParameters)
allDeclarations.removeAll(f.typeParameters)
allBodies.remove(f.body)
}
@Suppress("UNUSED_PARAMETER")
internal fun currentSignature(declaration: IrDeclaration): IdSignature? {
val parentSig = stageController.currentDeclaration?.let { declarationSignature(it) } ?: return null
@@ -125,7 +133,19 @@ class PersistentIrFactory : IrFactory {
isExternal: Boolean,
isStatic: Boolean,
): IrField =
PersistentIrField(startOffset, endOffset, origin, symbol, name, type, visibility, isFinal, isExternal, isStatic, this).also { it.register() }
PersistentIrField(
startOffset,
endOffset,
origin,
symbol,
name,
type,
visibility,
isFinal,
isExternal,
isStatic,
this
).also { it.register() }
override fun createFunction(
startOffset: Int,
@@ -268,7 +288,19 @@ class PersistentIrFactory : IrFactory {
isAssignable: Boolean
): IrValueParameter =
PersistentIrValueParameter(
startOffset, endOffset, origin, symbol, name, index, type, varargElementType, isCrossinline, isNoinline, isHidden, isAssignable, this
startOffset,
endOffset,
origin,
symbol,
name,
index,
type,
varargElementType,
isCrossinline,
isNoinline,
isHidden,
isAssignable,
this
).also { it.register() }
override fun createExpressionBody(