From 7333abf50d0737740595ef305fb02820f377daf8 Mon Sep 17 00:00:00 2001 From: pyos Date: Tue, 25 May 2021 13:55:05 +0200 Subject: [PATCH] JVM: purge redundant val BaseExpressionCodegen.v --- .../kotlin/codegen/inline/InlineCodegen.kt | 17 +++++++---------- .../backend/jvm/codegen/ExpressionCodegen.kt | 10 +++++----- .../kotlin/backend/jvm/codegen/PromisedValue.kt | 3 +-- .../backend/jvm/intrinsics/JvmInvokeDynamic.kt | 3 +-- 4 files changed, 14 insertions(+), 19 deletions(-) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/InlineCodegen.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/InlineCodegen.kt index 156e25f423d..555b3ffc65d 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/InlineCodegen.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/InlineCodegen.kt @@ -109,7 +109,7 @@ abstract class InlineCodegen( protected fun generateStub(text: String, codegen: BaseExpressionCodegen) { leaveTemps() - AsmUtil.genThrow(codegen.v, "java/lang/UnsupportedOperationException", "Call is part of inline cycle: $text") + AsmUtil.genThrow(codegen.visitor, "java/lang/UnsupportedOperationException", "Call is part of inline cycle: $text") } protected fun endCall(result: InlineResult, registerLineNumberAfterwards: Boolean) { @@ -248,17 +248,17 @@ abstract class InlineCodegen( removeFinallyMarkers(adapter) } - // In case `codegen.v` is ``, initializer for the `$assertionsDisabled` field + // In case `codegen.visitor` is ``, initializer for the `$assertionsDisabled` field // needs to be inserted before the code that actually uses it. generateAssertFieldIfNeeded(info) val shouldSpillStack = !canSkipStackSpillingOnInline(node) if (shouldSpillStack) { - addInlineMarker(codegen.v, true) + addInlineMarker(codegen.visitor, true) } - adapter.accept(MethodBodyVisitor(codegen.v)) + adapter.accept(MethodBodyVisitor(codegen.visitor)) if (shouldSpillStack) { - addInlineMarker(codegen.v, false) + addInlineMarker(codegen.visitor, false) } return result } @@ -364,7 +364,7 @@ abstract class InlineCodegen( val jvmType = jvmKotlinType.type val kotlinType = jvmKotlinType.kotlinType if (!isDefaultParameter && shouldPutGeneralValue(jvmType, kotlinType, stackValue)) { - stackValue.put(jvmType, kotlinType, codegen.v) + stackValue.put(jvmType, kotlinType, codegen.visitor) } if (!asFunctionInline && Type.VOID_TYPE !== jvmType) { @@ -413,7 +413,7 @@ abstract class InlineCodegen( val type = info.type val local = StackValue.local(index[i], type) if (!skipStore) { - local.store(StackValue.onStack(info.typeOnStack), codegen.v) + local.store(StackValue.onStack(info.typeOnStack), codegen.visitor) } if (info is CapturedParamInfo) { info.remapValue = local @@ -708,6 +708,3 @@ abstract class InlineCodegen( } } - -val BaseExpressionCodegen.v: InstructionAdapter - get() = visitor diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt index 25b11f055d4..503e6a91978 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt @@ -588,7 +588,7 @@ class ExpressionCodegen( closureReifiedMarkers[expression.symbol.owner.parentAsClass]?.let { if (it.wereUsedReifiedParameters()) { - putNeedClassReificationMarker(v) + putNeedClassReificationMarker(mv) propagateChildReifiedTypeParametersUsages(it) } } @@ -1018,7 +1018,7 @@ class ExpressionCodegen( if (typeOperand.isReifiedTypeParameter) { val operationKind = if (expression.operator == IrTypeOperator.CAST) AS else SAFE_AS putReifiedOperationMarkerIfTypeIsReifiedParameter(typeOperand, operationKind) - v.checkcast(boxedRightType) + mv.checkcast(boxedRightType) } else { assert(expression.operator == IrTypeOperator.CAST) { "IrTypeOperator.SAFE_CAST should have been lowered." } TypeIntrinsics.checkcast(mv, kotlinType, boxedRightType, false) @@ -1031,7 +1031,7 @@ class ExpressionCodegen( val type = typeMapper.boxType(typeOperand) if (typeOperand.isReifiedTypeParameter) { putReifiedOperationMarkerIfTypeIsReifiedParameter(typeOperand, ReifiedTypeInliner.OperationKind.IS) - v.instanceOf(type) + mv.instanceOf(type) } else { TypeIntrinsics.instanceOf(mv, kotlinType, type, state.languageVersionSettings.isReleaseCoroutines()) } @@ -1444,8 +1444,8 @@ class ExpressionCodegen( if (noLineNumberScope || registerLineNumberAfterwards) { if (lastLineNumber > -1) { val label = Label() - v.visitLabel(label) - v.visitLineNumber(lastLineNumber, label) + mv.visitLabel(label) + mv.visitLineNumber(lastLineNumber, label) } } else { // Inline function has its own line number which is in a separate instance of codegen, diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/PromisedValue.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/PromisedValue.kt index 3a6a23e50a4..ddcfcc810a3 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/PromisedValue.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/PromisedValue.kt @@ -9,7 +9,6 @@ import org.jetbrains.kotlin.backend.jvm.ir.eraseTypeParameters import org.jetbrains.kotlin.backend.jvm.lower.inlineclasses.* import org.jetbrains.kotlin.codegen.AsmUtil import org.jetbrains.kotlin.codegen.StackValue -import org.jetbrains.kotlin.codegen.inline.v import org.jetbrains.kotlin.ir.declarations.IrTypeParameter import org.jetbrains.kotlin.ir.symbols.IrTypeParameterSymbol import org.jetbrains.kotlin.ir.types.* @@ -46,7 +45,7 @@ abstract class PromisedValue(val codegen: ExpressionCodegen, val type: Type, val val irClass = codegen.irFunction.parentAsClass if (irClass.isInline && irClass.symbol == irType.classifierOrNull && !irType.isNullable()) { // Use getfield instead of unbox-impl inside inline classes - codegen.v.getfield( + codegen.mv.getfield( typeMapper.classInternalName(irClass), irClass.inlineClassFieldName.asString(), typeMapper.mapType(irType).descriptor diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/intrinsics/JvmInvokeDynamic.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/intrinsics/JvmInvokeDynamic.kt index 60fa956b85a..af015770114 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/intrinsics/JvmInvokeDynamic.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/intrinsics/JvmInvokeDynamic.kt @@ -7,7 +7,6 @@ package org.jetbrains.kotlin.backend.jvm.intrinsics import org.jetbrains.kotlin.backend.jvm.JvmLoweredDeclarationOrigin import org.jetbrains.kotlin.backend.jvm.codegen.* -import org.jetbrains.kotlin.codegen.inline.v import org.jetbrains.kotlin.ir.builders.declarations.buildClass import org.jetbrains.kotlin.ir.declarations.IrClass import org.jetbrains.kotlin.ir.declarations.IrConstructor @@ -66,7 +65,7 @@ object JvmInvokeDynamic : IntrinsicMethod() { dynamicCallGenerator.genValueAndPut(dynamicCalleeParameter, dynamicCalleeArgument, dynamicCalleeArgumentType, codegen, data) } - codegen.v.invokedynamic(dynamicCalleeMethod.name, dynamicCalleeMethod.descriptor, bootstrapMethodHandle, asmBootstrapMethodArgs) + codegen.mv.invokedynamic(dynamicCalleeMethod.name, dynamicCalleeMethod.descriptor, bootstrapMethodHandle, asmBootstrapMethodArgs) return MaterialValue(codegen, dynamicCalleeMethod.returnType, expression.type) }