Use java.lang.Object as a fall-back reference type
If for some reason during preliminary analysis in redundant null check elimination we failed to determine a local variable type statically, treat it as java.lang.Object. This will disable some further optimizations using precise type information (such as INSTANCEOF check elimination), but will not fail with an exception anyway.
This commit is contained in:
+2
-4
@@ -27,6 +27,7 @@ import org.jetbrains.kotlin.codegen.optimization.common.isInsn
|
||||
import org.jetbrains.kotlin.codegen.optimization.fixStack.peek
|
||||
import org.jetbrains.kotlin.codegen.optimization.fixStack.top
|
||||
import org.jetbrains.kotlin.codegen.optimization.transformer.MethodTransformer
|
||||
import org.jetbrains.kotlin.resolve.jvm.AsmTypes
|
||||
import org.jetbrains.kotlin.utils.SmartList
|
||||
import org.jetbrains.org.objectweb.asm.Label
|
||||
import org.jetbrains.org.objectweb.asm.Opcodes
|
||||
@@ -42,9 +43,6 @@ class RedundantNullCheckMethodTransformer : MethodTransformer() {
|
||||
private class TransformerPass(val internalClassName: String, val methodNode: MethodNode) {
|
||||
private var changes = false
|
||||
|
||||
private fun AbstractInsnNode.getIndex() =
|
||||
methodNode.instructions.indexOf(this)
|
||||
|
||||
fun run(): Boolean {
|
||||
val checkedReferenceTypes = analyzeTypesAndRemoveDeadCode()
|
||||
eliminateRedundantChecks(checkedReferenceTypes)
|
||||
@@ -236,7 +234,7 @@ class RedundantNullCheckMethodTransformer : MethodTransformer() {
|
||||
for ((varIndex, dependentChecks) in checksDependingOnVariable) {
|
||||
for (checkInsn in dependentChecks) {
|
||||
val varType = checkedReferenceTypes[checkInsn]
|
||||
?: throw AssertionError("No var type @${checkInsn.getIndex()}")
|
||||
?: AsmTypes.OBJECT_TYPE
|
||||
nullabilityAssumptions.injectAssumptionsForCheck(varIndex, checkInsn, varType)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user