diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/FunctionInlining.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/FunctionInlining.kt index 1ba02632f37..3470ed8ffbe 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/FunctionInlining.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/FunctionInlining.kt @@ -56,7 +56,7 @@ internal class FunctionInlining(val context: Context): IrElementTransformerVoidW val irCall = super.visitCall(expression) as IrCall val functionDescriptor = irCall.descriptor as FunctionDescriptor - if (!functionDescriptor.needsInlining) return irCall // This call does not need inlining. + if (!needsInlining(functionDescriptor)) return irCall // This call does not need inlining. val functionDeclaration = getFunctionDeclaration(irCall) // Get declaration of the function to be inlined. if (functionDeclaration == null) { // We failed to get the declaration. @@ -83,6 +83,28 @@ internal class FunctionInlining(val context: Context): IrElementTransformerVoidW return functionDeclaration as IrFunction? } + //-------------------------------------------------------------------------// + // Enforce inlining of some constructors (ByteArray, IntArray, ...) + + private fun needsInlining(functionDescriptor: FunctionDescriptor): Boolean { + + val needsInlining = functionDescriptor.needsInlining + val functionName = functionDescriptor.name.toString() + if (functionName != "") return needsInlining // This is not constructor. + if (functionDescriptor.valueParameters.size != 2) return needsInlining // Constructor must have two parameters. + + val returnType = functionDescriptor.returnType.toString() + if (returnType == "DoubleArray") return true + if (returnType == "FloatArray" ) return true + if (returnType == "ByteArray" ) return true + if (returnType == "ShortArray" ) return true + if (returnType == "IntArray" ) return true + if (returnType == "LongArray" ) return true + if (returnType == "CharArray" ) return true + + return needsInlining + } + //-------------------------------------------------------------------------// override fun visitElement(element: IrElement) = element.accept(this, null) @@ -357,6 +379,8 @@ private class Inliner(val currentScope: ScopeWithIr, val context: Context) { } } +//-------------------------------------------------------------------------// +