Use actual form of decodeSerializableElement function in 'decodeSequentially'

code path in deserialize.

Old 3-argument form is deprecated and should be removed.
This commit is contained in:
Leonid Startsev
2020-10-06 16:23:15 +03:00
parent 1bb2eefcaa
commit 0616f948c7
3 changed files with 11 additions and 11 deletions
@@ -404,7 +404,6 @@ open class SerializerIrGenerator(val irClass: IrClass, final override val compil
genericIndex = property.genericIndex genericIndex = property.genericIndex
) )
val isSerializable = innerSerial != null val isSerializable = innerSerial != null
// todo: update
val decodeFuncToCall = val decodeFuncToCall =
(if (isSerializable) "${CallingConventions.decode}${sti.elementMethodPrefix}Serializable${CallingConventions.elementPostfix}" (if (isSerializable) "${CallingConventions.decode}${sti.elementMethodPrefix}Serializable${CallingConventions.elementPostfix}"
else "${CallingConventions.decode}${sti.elementMethodPrefix}${CallingConventions.elementPostfix}") else "${CallingConventions.decode}${sti.elementMethodPrefix}${CallingConventions.elementPostfix}")
@@ -414,8 +413,8 @@ open class SerializerIrGenerator(val irClass: IrClass, final override val compil
val typeArgs = val typeArgs =
if (decodeFuncToCall.descriptor.typeParameters.isNotEmpty()) listOf(property.type.toIrType()) else listOf() if (decodeFuncToCall.descriptor.typeParameters.isNotEmpty()) listOf(property.type.toIrType()) else listOf()
val args = mutableListOf<IrExpression>(localSerialDesc.get(), irInt(index)) val args = mutableListOf<IrExpression>(localSerialDesc.get(), irInt(index))
if (innerSerial != null) { if (isSerializable) {
args.add(innerSerial) args.add(innerSerial!!)
args.add(localProps[index].get()) args.add(localProps[index].get())
} }
// local$i = localInput.decode...(...) // local$i = localInput.decode...(...)
@@ -334,7 +334,7 @@ open class SerializerCodegenImpl(
propVar = propsStartVar propVar = propsStartVar
for ((index, property) in serializableProperties.withIndex()) { for ((index, property) in serializableProperties.withIndex()) {
val propertyType = codegen.typeMapper.mapType(property.type) val propertyType = codegen.typeMapper.mapType(property.type)
callReadProperty(property, propertyType, index, inputVar, descVar, -1, propVar) callReadProperty(property, propertyType, index, inputVar, descVar, propVar)
propVar += propertyType.size propVar += propertyType.size
} }
// set all bit masks to true // set all bit masks to true
@@ -373,7 +373,7 @@ open class SerializerCodegenImpl(
val propertyAddressInBitMask = bitMaskOff(index) val propertyAddressInBitMask = bitMaskOff(index)
// labelI: // labelI:
visitLabel(labels[labelNum + 1]) visitLabel(labels[labelNum + 1])
callReadProperty(property, propertyType, index, inputVar, descVar, propertyAddressInBitMask, propVar) callReadProperty(property, propertyType, index, inputVar, descVar, propVar)
// mark read bit in mask // mark read bit in mask
// bitMask = bitMask | 1 << index // bitMask = bitMask | 1 << index
@@ -454,7 +454,6 @@ open class SerializerCodegenImpl(
index: Int, index: Int,
inputVar: Int, inputVar: Int,
descriptorVar: Int, descriptorVar: Int,
propertyAddressInBitMask: Int,
propertyVar: Int propertyVar: Int
) { ) {
// propX := input.readXxxValue(value) // propX := input.readXxxValue(value)
@@ -482,12 +481,12 @@ open class SerializerCodegenImpl(
) )
} }
val isUpdatable = useSerializer && propertyAddressInBitMask != -1 if (useSerializer) {
if (isUpdatable) { // then it is not a primitive and can be updated via `oldValue` parameter in decodeSerializableElement
load(propertyVar, propertyType) load(propertyVar, propertyType)
StackValue.coerce(propertyType, sti.type, this) StackValue.coerce(propertyType, sti.type, this)
} }
produceCall(isUpdatable) produceCall(useSerializer)
StackValue.coerce(sti.type, propertyType, this) StackValue.coerce(sti.type, propertyType, this)
store(propertyVar, propertyType) store(propertyVar, propertyType)
@@ -80,7 +80,8 @@ public final class ListOfUsers$$serializer : java/lang/Object, kotlinx/serializa
GETSTATIC (INSTANCE, LUser$$serializer;) GETSTATIC (INSTANCE, LUser$$serializer;)
CHECKCAST CHECKCAST
INVOKESPECIAL (kotlinx/serialization/internal/ArrayListSerializer, <init>, (Lkotlinx/serialization/KSerializer;)V) INVOKESPECIAL (kotlinx/serialization/internal/ArrayListSerializer, <init>, (Lkotlinx/serialization/KSerializer;)V)
INVOKEINTERFACE (kotlinx/serialization/encoding/CompositeDecoder, decodeSerializableElement, (Lkotlinx/serialization/descriptors/SerialDescriptor;ILkotlinx/serialization/DeserializationStrategy;)Ljava/lang/Object;) ALOAD (5)
INVOKEINTERFACE (kotlinx/serialization/encoding/CompositeDecoder, decodeSerializableElement, (Lkotlinx/serialization/descriptors/SerialDescriptor;ILkotlinx/serialization/DeserializationStrategy;Ljava/lang/Object;)Ljava/lang/Object;)
CHECKCAST CHECKCAST
ASTORE (5) ASTORE (5)
LDC (2147483647) LDC (2147483647)
@@ -365,7 +366,8 @@ public final class OptionalUser$$serializer : java/lang/Object, kotlinx/serializ
ICONST_0 ICONST_0
GETSTATIC (INSTANCE, LUser$$serializer;) GETSTATIC (INSTANCE, LUser$$serializer;)
CHECKCAST CHECKCAST
INVOKEINTERFACE (kotlinx/serialization/encoding/CompositeDecoder, decodeSerializableElement, (Lkotlinx/serialization/descriptors/SerialDescriptor;ILkotlinx/serialization/DeserializationStrategy;)Ljava/lang/Object;) ALOAD (5)
INVOKEINTERFACE (kotlinx/serialization/encoding/CompositeDecoder, decodeSerializableElement, (Lkotlinx/serialization/descriptors/SerialDescriptor;ILkotlinx/serialization/DeserializationStrategy;Ljava/lang/Object;)Ljava/lang/Object;)
CHECKCAST CHECKCAST
ASTORE (5) ASTORE (5)
LDC (2147483647) LDC (2147483647)