JVM: purge redundant val BaseExpressionCodegen.v

This commit is contained in:
pyos
2021-05-25 13:55:05 +02:00
committed by max-kammerer
parent 1f9db7cf25
commit 7333abf50d
4 changed files with 14 additions and 19 deletions
@@ -109,7 +109,7 @@ abstract class InlineCodegen<out T : BaseExpressionCodegen>(
protected fun generateStub(text: String, codegen: BaseExpressionCodegen) { protected fun generateStub(text: String, codegen: BaseExpressionCodegen) {
leaveTemps() 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) { protected fun endCall(result: InlineResult, registerLineNumberAfterwards: Boolean) {
@@ -248,17 +248,17 @@ abstract class InlineCodegen<out T : BaseExpressionCodegen>(
removeFinallyMarkers(adapter) removeFinallyMarkers(adapter)
} }
// In case `codegen.v` is `<clinit>`, initializer for the `$assertionsDisabled` field // In case `codegen.visitor` is `<clinit>`, initializer for the `$assertionsDisabled` field
// needs to be inserted before the code that actually uses it. // needs to be inserted before the code that actually uses it.
generateAssertFieldIfNeeded(info) generateAssertFieldIfNeeded(info)
val shouldSpillStack = !canSkipStackSpillingOnInline(node) val shouldSpillStack = !canSkipStackSpillingOnInline(node)
if (shouldSpillStack) { if (shouldSpillStack) {
addInlineMarker(codegen.v, true) addInlineMarker(codegen.visitor, true)
} }
adapter.accept(MethodBodyVisitor(codegen.v)) adapter.accept(MethodBodyVisitor(codegen.visitor))
if (shouldSpillStack) { if (shouldSpillStack) {
addInlineMarker(codegen.v, false) addInlineMarker(codegen.visitor, false)
} }
return result return result
} }
@@ -364,7 +364,7 @@ abstract class InlineCodegen<out T : BaseExpressionCodegen>(
val jvmType = jvmKotlinType.type val jvmType = jvmKotlinType.type
val kotlinType = jvmKotlinType.kotlinType val kotlinType = jvmKotlinType.kotlinType
if (!isDefaultParameter && shouldPutGeneralValue(jvmType, kotlinType, stackValue)) { if (!isDefaultParameter && shouldPutGeneralValue(jvmType, kotlinType, stackValue)) {
stackValue.put(jvmType, kotlinType, codegen.v) stackValue.put(jvmType, kotlinType, codegen.visitor)
} }
if (!asFunctionInline && Type.VOID_TYPE !== jvmType) { if (!asFunctionInline && Type.VOID_TYPE !== jvmType) {
@@ -413,7 +413,7 @@ abstract class InlineCodegen<out T : BaseExpressionCodegen>(
val type = info.type val type = info.type
val local = StackValue.local(index[i], type) val local = StackValue.local(index[i], type)
if (!skipStore) { if (!skipStore) {
local.store(StackValue.onStack(info.typeOnStack), codegen.v) local.store(StackValue.onStack(info.typeOnStack), codegen.visitor)
} }
if (info is CapturedParamInfo) { if (info is CapturedParamInfo) {
info.remapValue = local info.remapValue = local
@@ -708,6 +708,3 @@ abstract class InlineCodegen<out T : BaseExpressionCodegen>(
} }
} }
val BaseExpressionCodegen.v: InstructionAdapter
get() = visitor
@@ -588,7 +588,7 @@ class ExpressionCodegen(
closureReifiedMarkers[expression.symbol.owner.parentAsClass]?.let { closureReifiedMarkers[expression.symbol.owner.parentAsClass]?.let {
if (it.wereUsedReifiedParameters()) { if (it.wereUsedReifiedParameters()) {
putNeedClassReificationMarker(v) putNeedClassReificationMarker(mv)
propagateChildReifiedTypeParametersUsages(it) propagateChildReifiedTypeParametersUsages(it)
} }
} }
@@ -1018,7 +1018,7 @@ class ExpressionCodegen(
if (typeOperand.isReifiedTypeParameter) { if (typeOperand.isReifiedTypeParameter) {
val operationKind = if (expression.operator == IrTypeOperator.CAST) AS else SAFE_AS val operationKind = if (expression.operator == IrTypeOperator.CAST) AS else SAFE_AS
putReifiedOperationMarkerIfTypeIsReifiedParameter(typeOperand, operationKind) putReifiedOperationMarkerIfTypeIsReifiedParameter(typeOperand, operationKind)
v.checkcast(boxedRightType) mv.checkcast(boxedRightType)
} else { } else {
assert(expression.operator == IrTypeOperator.CAST) { "IrTypeOperator.SAFE_CAST should have been lowered." } assert(expression.operator == IrTypeOperator.CAST) { "IrTypeOperator.SAFE_CAST should have been lowered." }
TypeIntrinsics.checkcast(mv, kotlinType, boxedRightType, false) TypeIntrinsics.checkcast(mv, kotlinType, boxedRightType, false)
@@ -1031,7 +1031,7 @@ class ExpressionCodegen(
val type = typeMapper.boxType(typeOperand) val type = typeMapper.boxType(typeOperand)
if (typeOperand.isReifiedTypeParameter) { if (typeOperand.isReifiedTypeParameter) {
putReifiedOperationMarkerIfTypeIsReifiedParameter(typeOperand, ReifiedTypeInliner.OperationKind.IS) putReifiedOperationMarkerIfTypeIsReifiedParameter(typeOperand, ReifiedTypeInliner.OperationKind.IS)
v.instanceOf(type) mv.instanceOf(type)
} else { } else {
TypeIntrinsics.instanceOf(mv, kotlinType, type, state.languageVersionSettings.isReleaseCoroutines()) TypeIntrinsics.instanceOf(mv, kotlinType, type, state.languageVersionSettings.isReleaseCoroutines())
} }
@@ -1444,8 +1444,8 @@ class ExpressionCodegen(
if (noLineNumberScope || registerLineNumberAfterwards) { if (noLineNumberScope || registerLineNumberAfterwards) {
if (lastLineNumber > -1) { if (lastLineNumber > -1) {
val label = Label() val label = Label()
v.visitLabel(label) mv.visitLabel(label)
v.visitLineNumber(lastLineNumber, label) mv.visitLineNumber(lastLineNumber, label)
} }
} else { } else {
// Inline function has its own line number which is in a separate instance of codegen, // Inline function has its own line number which is in a separate instance of codegen,
@@ -9,7 +9,6 @@ import org.jetbrains.kotlin.backend.jvm.ir.eraseTypeParameters
import org.jetbrains.kotlin.backend.jvm.lower.inlineclasses.* import org.jetbrains.kotlin.backend.jvm.lower.inlineclasses.*
import org.jetbrains.kotlin.codegen.AsmUtil import org.jetbrains.kotlin.codegen.AsmUtil
import org.jetbrains.kotlin.codegen.StackValue 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.declarations.IrTypeParameter
import org.jetbrains.kotlin.ir.symbols.IrTypeParameterSymbol import org.jetbrains.kotlin.ir.symbols.IrTypeParameterSymbol
import org.jetbrains.kotlin.ir.types.* 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 val irClass = codegen.irFunction.parentAsClass
if (irClass.isInline && irClass.symbol == irType.classifierOrNull && !irType.isNullable()) { if (irClass.isInline && irClass.symbol == irType.classifierOrNull && !irType.isNullable()) {
// Use getfield instead of unbox-impl inside inline classes // Use getfield instead of unbox-impl inside inline classes
codegen.v.getfield( codegen.mv.getfield(
typeMapper.classInternalName(irClass), typeMapper.classInternalName(irClass),
irClass.inlineClassFieldName.asString(), irClass.inlineClassFieldName.asString(),
typeMapper.mapType(irType).descriptor typeMapper.mapType(irType).descriptor
@@ -7,7 +7,6 @@ package org.jetbrains.kotlin.backend.jvm.intrinsics
import org.jetbrains.kotlin.backend.jvm.JvmLoweredDeclarationOrigin import org.jetbrains.kotlin.backend.jvm.JvmLoweredDeclarationOrigin
import org.jetbrains.kotlin.backend.jvm.codegen.* 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.builders.declarations.buildClass
import org.jetbrains.kotlin.ir.declarations.IrClass import org.jetbrains.kotlin.ir.declarations.IrClass
import org.jetbrains.kotlin.ir.declarations.IrConstructor import org.jetbrains.kotlin.ir.declarations.IrConstructor
@@ -66,7 +65,7 @@ object JvmInvokeDynamic : IntrinsicMethod() {
dynamicCallGenerator.genValueAndPut(dynamicCalleeParameter, dynamicCalleeArgument, dynamicCalleeArgumentType, codegen, data) 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) return MaterialValue(codegen, dynamicCalleeMethod.returnType, expression.type)
} }