From 51dbc6072232f6d9b9a2e6708435abe75cdb1e28 Mon Sep 17 00:00:00 2001 From: pyos Date: Wed, 27 Apr 2022 14:40:31 +0200 Subject: [PATCH] JVM: use various `Interpreter.new*` methods in FastMethodAnalyzer These allow e.g. specifying different values for parameters depending on their indices. --- .../optimization/common/FastMethodAnalyzer.kt | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/common/FastMethodAnalyzer.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/common/FastMethodAnalyzer.kt index 1c323e8d71d..af57507a80f 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/common/FastMethodAnalyzer.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/common/FastMethodAnalyzer.kt @@ -132,7 +132,7 @@ open class FastMethodAnalyzer handler.init(f) handler.clearStack() - handler.push(interpreter.newValue(exnType)) + handler.push(interpreter.newExceptionValue(tcb, handler, exnType)) mergeControlFlowEdge(jump, handler) } } @@ -157,21 +157,25 @@ open class FastMethodAnalyzer } internal fun initLocals(current: Frame) { - current.setReturn(interpreter.newValue(Type.getReturnType(method.desc))) + current.setReturn(interpreter.newReturnTypeValue(Type.getReturnType(method.desc))) val args = Type.getArgumentTypes(method.desc) var local = 0 - if ((method.access and Opcodes.ACC_STATIC) == 0) { - val ctype = Type.getObjectType(owner) - current.setLocal(local++, interpreter.newValue(ctype)) + val isInstanceMethod = (method.access and Opcodes.ACC_STATIC) == 0 + if (isInstanceMethod) { + current.setLocal(local, interpreter.newParameterValue(true, local, Type.getObjectType(owner))) + local++ } for (arg in args) { - current.setLocal(local++, interpreter.newValue(arg)) + current.setLocal(local, interpreter.newParameterValue(isInstanceMethod, local, arg)) + local++ if (arg.size == 2) { - current.setLocal(local++, interpreter.newValue(null)) + current.setLocal(local, interpreter.newEmptyValue(local)) + local++ } } while (local < method.maxLocals) { - current.setLocal(local++, interpreter.newValue(null)) + current.setLocal(local, interpreter.newEmptyValue(local)) + local++ } }