Remove update* calls

This commit is contained in:
Leonid Startsev
2020-02-17 20:03:39 +03:00
parent add0b461ee
commit ceb3cfbfd5
3 changed files with 23 additions and 67 deletions
@@ -371,18 +371,21 @@ open class SerializerIrGenerator(val irClass: IrClass, final override val compil
property.type,
genericIndex = property.genericIndex
)
val isSerializable = innerSerial != null
// todo: update
val decodeFuncToCall =
(if (innerSerial != null) "${CallingConventions.decode}${sti.elementMethodPrefix}Serializable${CallingConventions.elementPostfix}"
(if (isSerializable) "${CallingConventions.decode}${sti.elementMethodPrefix}Serializable${CallingConventions.elementPostfix}"
else "${CallingConventions.decode}${sti.elementMethodPrefix}${CallingConventions.elementPostfix}")
.let {
inputClass.referenceMethod(it)
inputClass.referenceMethod(it) { it.valueParameters.size == if (isSerializable) 4 else 2 }
}
val typeArgs =
if (decodeFuncToCall.descriptor.typeParameters.isNotEmpty()) listOf(property.type.toIrType()) else listOf()
val args = mutableListOf<IrExpression>(localSerialDesc.get(), irInt(index))
if (innerSerial != null)
if (innerSerial != null) {
args.add(innerSerial)
args.add(localProps[index].get())
}
// local$i = localInput.decode...(...)
+irSetVar(
localProps[index].symbol,
@@ -1,17 +1,6 @@
/*
* Copyright 2010-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlinx.serialization.compiler.backend.js
@@ -297,30 +286,16 @@ open class SerializerJsTranslator(
)
JsInvocation(JsNameRef(readFunc, inputVar), readArgs)
} else {
val notSeenTest = propNotSeenTest(bitMasks[bitMaskOff(i)], i)
val readFunc =
inputClass.getFuncDesc("${CallingConventions.decode}${sti.elementMethodPrefix}Serializable${CallingConventions.elementPostfix}")
.single()
.single { it.valueParameters.size == 4 }
.let { context.getNameForDescriptor(it) }
val updateFunc =
inputClass.getFuncDesc("${CallingConventions.update}${sti.elementMethodPrefix}Serializable${CallingConventions.elementPostfix}")
.single()
.let { context.getNameForDescriptor(it) }
JsConditional(
notSeenTest,
JsInvocation(
JsNameRef(readFunc, inputVar),
serialClassDescRef,
JsIntLiteral(i),
innerSerial
),
JsInvocation(
JsNameRef(updateFunc, inputVar),
serialClassDescRef,
JsIntLiteral(i),
innerSerial,
localProps[i]
)
JsInvocation(
JsNameRef(readFunc, inputVar),
serialClassDescRef,
JsIntLiteral(i),
innerSerial,
localProps[i]
)
}
// localPropI = ...
@@ -1,17 +1,6 @@
/*
* Copyright 2010-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlinx.serialization.compiler.backend.jvm
@@ -476,35 +465,24 @@ open class SerializerCodegenImpl(
AsmUtil.wrapJavaClassIntoKClass(this)
}
fun produceCall(update: Boolean) {
fun produceCall(isUpdatable: Boolean) {
invokeinterface(
kInputType.internalName,
(if (update) CallingConventions.update else CallingConventions.decode) + sti.elementMethodPrefix + (if (useSerializer) "Serializable" else "") + CallingConventions.elementPostfix,
(CallingConventions.decode) + sti.elementMethodPrefix + (if (useSerializer) "Serializable" else "") + CallingConventions.elementPostfix,
"(" + descType.descriptor + "I" +
(if (useSerializer) kSerialLoaderType.descriptor else "")
+ (if (unknownSer) AsmTypes.K_CLASS_TYPE.descriptor else "")
+ (if (update) sti.type.descriptor else "")
+ (if (isUpdatable) sti.type.descriptor else "")
+ ")" + (sti.type.descriptor)
)
}
if (useSerializer && propertyAddressInBitMask != -1) {
// we can choose either it is read or update
val readLabel = Label()
val endL = Label()
genValidateProperty(index, propertyAddressInBitMask)
ificmpeq(readLabel)
val isUpdatable = useSerializer && propertyAddressInBitMask != -1
if (isUpdatable) {
load(propertyVar, propertyType)
StackValue.coerce(propertyType, sti.type, this)
produceCall(true)
goTo(endL)
visitLabel(readLabel)
produceCall(false)
visitLabel(endL)
} else {
// update not supported for primitive types or decodeSequentially
produceCall(false)
}
produceCall(isUpdatable)
StackValue.coerce(sti.type, propertyType, this)
store(propertyVar, propertyType)