[JS IC] Don't persist temporary copies of inline functions
- drop special `IrValueParameterPublicSymbol` - drop special `IrAnonymousInitializerPublicSymbolImpl` - drop hacky `useGlobalSignatures`
This commit is contained in:
committed by
teamcityserver
parent
b1251c1716
commit
b1eeb1fb27
+23
-11
@@ -93,6 +93,8 @@ class FunctionInlining(
|
||||
|
||||
private var containerScope: ScopeWithIr? = null
|
||||
|
||||
private var deepInline: Boolean = false
|
||||
|
||||
override fun lower(irBody: IrBody, container: IrDeclaration) {
|
||||
// TODO container: IrSymbolDeclaration
|
||||
containerScope = createScope(container as IrSymbolOwner)
|
||||
@@ -155,16 +157,6 @@ class FunctionInlining(
|
||||
|
||||
fun inline() = inlineFunction(callSite, callee, true)
|
||||
|
||||
/**
|
||||
* TODO: JVM inliner crashed on attempt inline this function from transform.kt with:
|
||||
* j.l.IllegalStateException: Couldn't obtain compiled function body for
|
||||
* public inline fun <reified T : org.jetbrains.kotlin.ir.IrElement> kotlin.collections.MutableList<T>.transform...
|
||||
*/
|
||||
private inline fun <reified T : IrElement> MutableList<T>.transform(transformation: (T) -> IrElement) {
|
||||
forEachIndexed { i, item ->
|
||||
set(i, transformation(item) as T)
|
||||
}
|
||||
}
|
||||
|
||||
private fun inlineFunction(
|
||||
callSite: IrFunctionAccessExpression,
|
||||
@@ -172,9 +164,22 @@ class FunctionInlining(
|
||||
performRecursiveInline: Boolean
|
||||
): IrReturnableBlock {
|
||||
val copiedCallee = (copyIrElement.copy(callee) as IrFunction).apply {
|
||||
|
||||
// It's a hack to overtake another hack in PIR. Due to PersistentIrFactory registers every created declaration
|
||||
// there also get temporary declaration like this which leads to some unclear behaviour. Since I am not aware
|
||||
// enough about PIR internals the simplest way seemed to me is to unregister temporary function. Hope it is going
|
||||
// to be removed ASAP along with registering every PIR declaration.
|
||||
factory.unlistFunction(this)
|
||||
|
||||
parent = callee.parent
|
||||
if (performRecursiveInline) {
|
||||
body?.transformChildrenVoid()
|
||||
val old = deepInline
|
||||
try {
|
||||
deepInline = true
|
||||
body?.transformChildrenVoid()
|
||||
} finally {
|
||||
deepInline = old
|
||||
}
|
||||
valueParameters.forEachIndexed { index, param ->
|
||||
if (callSite.getValueArgument(index) == null) {
|
||||
// Default values can recursively reference [callee] - transform only needed.
|
||||
@@ -537,6 +542,13 @@ class FunctionInlining(
|
||||
if (argument.isInlinableLambdaArgument) {
|
||||
substituteMap[argument.parameter] = argument.argumentExpression
|
||||
(argument.argumentExpression as? IrFunctionReference)?.let { evaluationStatements += evaluateArguments(it) }
|
||||
|
||||
(argument.argumentExpression as? IrFunctionExpression)?.let {
|
||||
if (deepInline) {
|
||||
it.function.factory.unlistFunction(it.function)
|
||||
}
|
||||
}
|
||||
|
||||
return@forEach
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user