From 26da0b9e7e6342b8dfbc50d83c99526f68ddba7b Mon Sep 17 00:00:00 2001 From: Denis Zharkov Date: Mon, 15 Oct 2018 11:38:52 +0300 Subject: [PATCH] Do not call default constructor of SourceInterpreter in subclasses It became illegal since asm-6.x See https://gitlab.ow2.org/asm/asm/blob/c72a86bd5f48a308537695213d3a23ac35a57d55/asm-analysis/src/main/java/org/objectweb/asm/tree/analysis/SourceInterpreter.java#L56 #KT-27572 Fixed --- .../codegen/coroutines/CoroutineTransformerMethodVisitor.kt | 2 +- .../kotlin/codegen/coroutines/refinedIntTypesAnalysis.kt | 2 +- .../optimization/boxing/PopBackwardPropagationTransformer.kt | 5 +++-- .../org/jetbrains/kotlin/codegen/optimization/common/Util.kt | 4 +++- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/CoroutineTransformerMethodVisitor.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/CoroutineTransformerMethodVisitor.kt index 6ae746d1eae..7267e9b2c3d 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/CoroutineTransformerMethodVisitor.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/CoroutineTransformerMethodVisitor.kt @@ -948,7 +948,7 @@ private fun allSuspensionPointsAreTailCalls( } } -internal class IgnoringCopyOperationSourceInterpreter : SourceInterpreter() { +internal class IgnoringCopyOperationSourceInterpreter : SourceInterpreter(OPTIMIZATION_ASM_API_VERSION) { override fun copyOperation(insn: AbstractInsnNode?, value: SourceValue?) = value } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/refinedIntTypesAnalysis.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/refinedIntTypesAnalysis.kt index c97a2741068..2f4b59fde5d 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/refinedIntTypesAnalysis.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/refinedIntTypesAnalysis.kt @@ -169,7 +169,7 @@ private fun checkUpdatedExpectedType(was: Type?, new: Type) { } } -private class MySourceInterpreter : SourceInterpreter() { +private class MySourceInterpreter : SourceInterpreter(OPTIMIZATION_ASM_API_VERSION) { override fun copyOperation(insn: AbstractInsnNode, value: SourceValue) = when { insn.isStoreOperation() || insn.isLoadOperation() -> SourceValue(value.size, insn) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/boxing/PopBackwardPropagationTransformer.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/boxing/PopBackwardPropagationTransformer.kt index e0a45e81d29..1e91f3ce9cc 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/boxing/PopBackwardPropagationTransformer.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/boxing/PopBackwardPropagationTransformer.kt @@ -17,6 +17,7 @@ package org.jetbrains.kotlin.codegen.optimization.boxing import org.jetbrains.kotlin.codegen.optimization.OptimizationMethodVisitor +import org.jetbrains.kotlin.codegen.optimization.common.OPTIMIZATION_ASM_API_VERSION import org.jetbrains.kotlin.codegen.optimization.common.debugText import org.jetbrains.kotlin.codegen.optimization.common.isLoadOperation import org.jetbrains.kotlin.codegen.optimization.common.isMeaningful @@ -119,7 +120,7 @@ class PopBackwardPropagationTransformer : MethodTransformer() { throw AssertionError("Incorrect bytecode at ${methodNode.instructions.indexOf(insn)}: ${insn.debugText} $frame") } - private inner class HazardsTrackingInterpreter : SourceInterpreter() { + private inner class HazardsTrackingInterpreter : SourceInterpreter(OPTIMIZATION_ASM_API_VERSION) { override fun naryOperation(insn: AbstractInsnNode, values: MutableList): SourceValue { for (value in values) { value.insns.markAsDontTouch() @@ -313,4 +314,4 @@ fun AbstractInsnNode.isUnitInstance() = this is FieldInsnNode && owner == "kotlin/Unit" && name == "INSTANCE" fun AbstractInsnNode.isPrimitiveTypeConversion() = - opcode in Opcodes.I2L..Opcodes.I2S \ No newline at end of file + opcode in Opcodes.I2L..Opcodes.I2S diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/common/Util.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/common/Util.kt index 801cb8dd470..1903bc7d1e5 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/common/Util.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/common/Util.kt @@ -27,6 +27,8 @@ import org.jetbrains.org.objectweb.asm.Opcodes.* import org.jetbrains.org.objectweb.asm.Type import org.jetbrains.org.objectweb.asm.tree.* +const val OPTIMIZATION_ASM_API_VERSION = Opcodes.ASM5 + val AbstractInsnNode.isMeaningful: Boolean get() = when (this.type) { @@ -221,4 +223,4 @@ internal inline fun AbstractInsnNode.takeInsnIf(o fun InsnList.removeAll(nodes: Collection) { for (node in nodes) remove(node) -} \ No newline at end of file +}