JVM_IR: Do not box inline class in methods
This commit is contained in:
Generated
+5
@@ -3167,6 +3167,11 @@ public class FirBytecodeTextTestGenerated extends AbstractFirBytecodeTextTest {
|
||||
runTest("compiler/testData/codegen/bytecodeText/inlineClasses/noAssertionsForInlineClassesBasedOnNullableTypes.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("noBoxingInMethod.kt")
|
||||
public void testNoBoxingInMethod() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeText/inlineClasses/noBoxingInMethod.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("noBoxingOnCastOperations.kt")
|
||||
public void testNoBoxingOnCastOperations() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeText/inlineClasses/noBoxingOnCastOperations.kt");
|
||||
|
||||
+4
-1
@@ -13,6 +13,8 @@ import org.jetbrains.kotlin.backend.common.lower.createIrBuilder
|
||||
import org.jetbrains.kotlin.backend.common.lower.irBlockBody
|
||||
import org.jetbrains.kotlin.backend.common.lower.loops.forLoopsPhase
|
||||
import org.jetbrains.kotlin.backend.common.phaser.makeIrFilePhase
|
||||
import org.jetbrains.kotlin.backend.common.pop
|
||||
import org.jetbrains.kotlin.backend.common.push
|
||||
import org.jetbrains.kotlin.backend.jvm.JvmBackendContext
|
||||
import org.jetbrains.kotlin.backend.jvm.JvmLoweredDeclarationOrigin
|
||||
import org.jetbrains.kotlin.backend.jvm.lower.inlineclasses.*
|
||||
@@ -121,7 +123,9 @@ private class JvmInlineClassLowering(private val context: JvmBackendContext) : F
|
||||
|
||||
private fun transformSimpleFunctionFlat(function: IrSimpleFunction, replacement: IrSimpleFunction): List<IrDeclaration> {
|
||||
replacement.valueParameters.forEach { it.transformChildrenVoid() }
|
||||
allScopes.push(createScope(function))
|
||||
replacement.body = function.body?.transform(this, null)?.patchDeclarationParents(replacement)
|
||||
allScopes.pop()
|
||||
replacement.copyAttributes(function)
|
||||
|
||||
// Don't create a wrapper for functions which are only used in an unboxed context
|
||||
@@ -409,7 +413,6 @@ private class JvmInlineClassLowering(private val context: JvmBackendContext) : F
|
||||
val irElement = scope.irElement
|
||||
when {
|
||||
irElement is IrAnonymousInitializer -> return InitBlockOrConstructorImpl.InitBlock
|
||||
irElement is IrClass && irElement.isInline -> return InitBlockOrConstructorImpl.InitBlock
|
||||
irElement is IrFunction && irElement.origin == JvmLoweredDeclarationOrigin.STATIC_INLINE_CLASS_CONSTRUCTOR ->
|
||||
return InitBlockOrConstructorImpl.ConstructorImpl(irElement)
|
||||
}
|
||||
|
||||
+4
-5
@@ -16,15 +16,14 @@ fun takeNullable(a: UInt?) {}
|
||||
// 1 valueOf
|
||||
// 0 intValue
|
||||
|
||||
// JVM_TEMPLATES:
|
||||
// -- 1 before takeNullable
|
||||
// -- 1 before takeAnyInside
|
||||
// 2 INVOKESTATIC UInt\.box
|
||||
|
||||
// JVM_TEMPLATES:
|
||||
// -- equals-impl
|
||||
// 1 INVOKEVIRTUAL UInt\.unbox
|
||||
|
||||
// JVM_IR_TEMPLATES:
|
||||
// -- 1 before takeNullable
|
||||
// -- 1 before takeAnyInside
|
||||
// -- 1 before takeAnyInside's GETFIELD
|
||||
// 3 INVOKESTATIC UInt\.box
|
||||
// -- getA, toString, hashCode, equals-impl, equals
|
||||
// 5 INVOKEVIRTUAL UInt\.unbox
|
||||
@@ -0,0 +1,5 @@
|
||||
inline class IC(val value: Int) {
|
||||
inline fun toLong(): Long = this.value.toLong()
|
||||
}
|
||||
|
||||
// 0 INVOKESTATIC IC\.box-impl
|
||||
@@ -3112,6 +3112,11 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest {
|
||||
runTest("compiler/testData/codegen/bytecodeText/inlineClasses/noAssertionsForInlineClassesBasedOnNullableTypes.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("noBoxingInMethod.kt")
|
||||
public void testNoBoxingInMethod() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeText/inlineClasses/noBoxingInMethod.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("noBoxingOnCastOperations.kt")
|
||||
public void testNoBoxingOnCastOperations() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeText/inlineClasses/noBoxingOnCastOperations.kt");
|
||||
|
||||
+10
-10
@@ -14799,16 +14799,6 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/anySuperCall.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("boxImplDoesNotExecuteInitBlock.kt")
|
||||
public void ignoreBoxImplDoesNotExecuteInitBlock() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/boxImplDoesNotExecuteInitBlock.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("initBlock.kt")
|
||||
public void ignoreInitBlock() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/initBlock.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inlineClassWithCustomEquals.kt")
|
||||
public void ignoreInlineClassWithCustomEquals() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/inlineClassWithCustomEquals.kt");
|
||||
@@ -14842,6 +14832,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/boundCallableReferencePassedToInlineFunction.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("boxImplDoesNotExecuteInitBlock.kt")
|
||||
public void testBoxImplDoesNotExecuteInitBlock() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/boxImplDoesNotExecuteInitBlock.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("boxNullableValueOfInlineClassWithNonNullUnderlyingType.kt")
|
||||
public void testBoxNullableValueOfInlineClassWithNonNullUnderlyingType() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/boxNullableValueOfInlineClassWithNonNullUnderlyingType.kt");
|
||||
@@ -15127,6 +15122,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/genericVararg2ndConstructor.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("initBlock.kt")
|
||||
public void testInitBlock() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/initBlock.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inlineClassAsLastExpressionInInLambda.kt")
|
||||
public void testInlineClassAsLastExpressionInInLambda() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/inlineClassAsLastExpressionInInLambda.kt");
|
||||
|
||||
+5
@@ -3167,6 +3167,11 @@ public class IrBytecodeTextTestGenerated extends AbstractIrBytecodeTextTest {
|
||||
runTest("compiler/testData/codegen/bytecodeText/inlineClasses/noAssertionsForInlineClassesBasedOnNullableTypes.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("noBoxingInMethod.kt")
|
||||
public void testNoBoxingInMethod() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeText/inlineClasses/noBoxingInMethod.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("noBoxingOnCastOperations.kt")
|
||||
public void testNoBoxingOnCastOperations() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeText/inlineClasses/noBoxingOnCastOperations.kt");
|
||||
|
||||
Reference in New Issue
Block a user