KT-33119 Generate IINC for primitive types only
This commit is contained in:
@@ -15,6 +15,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns;
|
||||
import org.jetbrains.kotlin.builtins.PrimitiveType;
|
||||
import org.jetbrains.kotlin.builtins.UnsignedTypes;
|
||||
import org.jetbrains.kotlin.codegen.binding.CodegenBinding;
|
||||
import org.jetbrains.kotlin.codegen.coroutines.CoroutineCodegenUtilKt;
|
||||
import org.jetbrains.kotlin.codegen.intrinsics.IntrinsicMethods;
|
||||
@@ -794,8 +795,11 @@ public abstract class StackValue {
|
||||
ResolvedCall resolvedCall,
|
||||
@NotNull ExpressionCodegen codegen
|
||||
) {
|
||||
if (stackValue instanceof StackValue.Local && Type.INT_TYPE == stackValue.type) {
|
||||
return preIncrementForLocalVar(((StackValue.Local) stackValue).index, delta, stackValue.kotlinType);
|
||||
KotlinType kotlinType = stackValue.kotlinType;
|
||||
if (stackValue instanceof StackValue.Local && Type.INT_TYPE == stackValue.type &&
|
||||
kotlinType != null && KotlinBuiltIns.isPrimitiveType(kotlinType)
|
||||
) {
|
||||
return preIncrementForLocalVar(((StackValue.Local) stackValue).index, delta, kotlinType);
|
||||
}
|
||||
return new PrefixIncrement(type, stackValue, resolvedCall, codegen);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
|
||||
inline class WrappingInt(val value: Int) {
|
||||
operator fun inc(): WrappingInt = plus(1)
|
||||
operator fun plus(num: Int): WrappingInt = WrappingInt((value + num) and 0xFFFF)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var x = WrappingInt(65535)
|
||||
x++
|
||||
if (x.value != 0) throw AssertionError("x++: ${x.value}")
|
||||
|
||||
var y = WrappingInt(65535)
|
||||
++y
|
||||
if (y.value != 0) throw AssertionError("++y: ${y.value}")
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+5
@@ -13408,6 +13408,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt28920_javaPrimitiveType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt33119.kt")
|
||||
public void testKt33119() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt33119.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt34268.kt")
|
||||
public void testKt34268() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt34268.kt");
|
||||
|
||||
+5
@@ -13413,6 +13413,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt28920_javaPrimitiveType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt33119.kt")
|
||||
public void testKt33119() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt33119.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt34268.kt")
|
||||
public void testKt34268() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt34268.kt");
|
||||
|
||||
+5
@@ -12278,6 +12278,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt28920_javaPrimitiveType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt33119.kt")
|
||||
public void testKt33119() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt33119.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt34268.kt")
|
||||
public void testKt34268() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt34268.kt");
|
||||
|
||||
+5
@@ -12278,6 +12278,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt28920_javaPrimitiveType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt33119.kt")
|
||||
public void testKt33119() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt33119.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt34268.kt")
|
||||
public void testKt34268() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt34268.kt");
|
||||
|
||||
@@ -43,6 +43,7 @@ object UnsignedTypes {
|
||||
fun getUnsignedClassIdByArrayClassId(arrayClassId: ClassId): ClassId? = arrayClassIdToUnsignedClassId[arrayClassId]
|
||||
fun getUnsignedArrayClassIdByUnsignedClassId(arrayClassId: ClassId): ClassId? = unsignedClassIdToArrayClassId[arrayClassId]
|
||||
|
||||
@JvmStatic
|
||||
fun isUnsignedType(type: KotlinType): Boolean {
|
||||
if (TypeUtils.noExpectedType(type)) return false
|
||||
|
||||
|
||||
Generated
+5
@@ -10558,6 +10558,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt28585.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt33119.kt")
|
||||
public void testKt33119() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt33119.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt34268.kt")
|
||||
public void testKt34268() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt34268.kt");
|
||||
|
||||
+5
@@ -10623,6 +10623,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt28585.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt33119.kt")
|
||||
public void testKt33119() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt33119.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt34268.kt")
|
||||
public void testKt34268() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt34268.kt");
|
||||
|
||||
Reference in New Issue
Block a user