JVM: rename a couple ValueKinds to make their purpose clearer
This commit is contained in:
@@ -18,8 +18,8 @@ enum class ValueKind {
|
|||||||
DEFAULT_INLINE_PARAMETER,
|
DEFAULT_INLINE_PARAMETER,
|
||||||
DEFAULT_MASK,
|
DEFAULT_MASK,
|
||||||
METHOD_HANDLE_IN_DEFAULT,
|
METHOD_HANDLE_IN_DEFAULT,
|
||||||
NON_INLINEABLE_ARGUMENT_FOR_INLINE_PARAMETER_CALLED_IN_SUSPEND,
|
READ_OF_INLINE_LAMBDA_FOR_INLINE_SUSPEND_PARAMETER,
|
||||||
NON_INLINEABLE_ARGUMENT_FOR_INLINE_SUSPEND_PARAMETER
|
READ_OF_OBJECT_FOR_INLINE_SUSPEND_PARAMETER
|
||||||
}
|
}
|
||||||
|
|
||||||
interface CallGenerator {
|
interface CallGenerator {
|
||||||
|
|||||||
+1
-1
@@ -556,7 +556,7 @@ class AnonymousObjectTransformer(
|
|||||||
else
|
else
|
||||||
capturedParamBuilder.addCapturedParam(desc, addUniqueField(desc.fieldName + INLINE_TRANSFORMATION_SUFFIX), false)
|
capturedParamBuilder.addCapturedParam(desc, addUniqueField(desc.fieldName + INLINE_TRANSFORMATION_SUFFIX), false)
|
||||||
if (desc.isSuspend) {
|
if (desc.isSuspend) {
|
||||||
recapturedParamInfo.functionalArgument = NonInlineableArgumentForInlineableParameterCalledInSuspend
|
recapturedParamInfo.functionalArgument = NonInlineArgumentForInlineSuspendParameter.INLINE_LAMBDA_AS_VARIABLE
|
||||||
}
|
}
|
||||||
val composed = StackValue.field(
|
val composed = StackValue.field(
|
||||||
desc.type,
|
desc.type,
|
||||||
|
|||||||
@@ -233,10 +233,10 @@ abstract class InlineCodegen<out T : BaseExpressionCodegen>(
|
|||||||
|
|
||||||
val info = invocationParamBuilder.addNextValueParameter(jvmKotlinType.type, false, null, parameterIndex)
|
val info = invocationParamBuilder.addNextValueParameter(jvmKotlinType.type, false, null, parameterIndex)
|
||||||
info.functionalArgument = when (kind) {
|
info.functionalArgument = when (kind) {
|
||||||
ValueKind.NON_INLINEABLE_ARGUMENT_FOR_INLINE_PARAMETER_CALLED_IN_SUSPEND ->
|
ValueKind.READ_OF_INLINE_LAMBDA_FOR_INLINE_SUSPEND_PARAMETER ->
|
||||||
NonInlineableArgumentForInlineableParameterCalledInSuspend
|
NonInlineArgumentForInlineSuspendParameter.INLINE_LAMBDA_AS_VARIABLE
|
||||||
ValueKind.NON_INLINEABLE_ARGUMENT_FOR_INLINE_SUSPEND_PARAMETER ->
|
ValueKind.READ_OF_OBJECT_FOR_INLINE_SUSPEND_PARAMETER ->
|
||||||
NonInlineableArgumentForInlineableSuspendParameter
|
NonInlineArgumentForInlineSuspendParameter.OTHER
|
||||||
ValueKind.DEFAULT_INLINE_PARAMETER ->
|
ValueKind.DEFAULT_INLINE_PARAMETER ->
|
||||||
DefaultValueOfInlineParameter
|
DefaultValueOfInlineParameter
|
||||||
else -> null
|
else -> null
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ abstract class LambdaInfo : FunctionalArgument {
|
|||||||
?: error("Captured field not found: " + info.containingLambdaName + "." + info.fieldName)
|
?: error("Captured field not found: " + info.containingLambdaName + "." + info.fieldName)
|
||||||
val recapturedParamInfo = builder.addCapturedParam(field, info.fieldName)
|
val recapturedParamInfo = builder.addCapturedParam(field, info.fieldName)
|
||||||
if (info.isSuspend) {
|
if (info.isSuspend) {
|
||||||
recapturedParamInfo.functionalArgument = NonInlineableArgumentForInlineableParameterCalledInSuspend
|
recapturedParamInfo.functionalArgument = NonInlineArgumentForInlineSuspendParameter.INLINE_LAMBDA_AS_VARIABLE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,8 +65,7 @@ abstract class LambdaInfo : FunctionalArgument {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
object NonInlineableArgumentForInlineableParameterCalledInSuspend : FunctionalArgument
|
enum class NonInlineArgumentForInlineSuspendParameter : FunctionalArgument { INLINE_LAMBDA_AS_VARIABLE, OTHER }
|
||||||
object NonInlineableArgumentForInlineableSuspendParameter : FunctionalArgument
|
|
||||||
object DefaultValueOfInlineParameter : FunctionalArgument
|
object DefaultValueOfInlineParameter : FunctionalArgument
|
||||||
|
|
||||||
abstract class ExpressionLambda : LambdaInfo() {
|
abstract class ExpressionLambda : LambdaInfo() {
|
||||||
|
|||||||
@@ -885,7 +885,7 @@ class MethodInliner(
|
|||||||
insnNode is FieldInsnNode && insnNode.name.startsWith(CAPTURED_FIELD_FOLD_PREFIX) ->
|
insnNode is FieldInsnNode && insnNode.name.startsWith(CAPTURED_FIELD_FOLD_PREFIX) ->
|
||||||
findCapturedField(insnNode, nodeRemapper).functionalArgument
|
findCapturedField(insnNode, nodeRemapper).functionalArgument
|
||||||
insnNode is FieldInsnNode && inliningContext.root.sourceCompilerForInline.isSuspendLambdaCapturedByOuterObjectOrLambda(insnNode.name) ->
|
insnNode is FieldInsnNode && inliningContext.root.sourceCompilerForInline.isSuspendLambdaCapturedByOuterObjectOrLambda(insnNode.name) ->
|
||||||
NonInlineableArgumentForInlineableParameterCalledInSuspend
|
NonInlineArgumentForInlineSuspendParameter.INLINE_LAMBDA_AS_VARIABLE
|
||||||
else ->
|
else ->
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -127,8 +127,8 @@ class PsiInlineCodegen(
|
|||||||
val value = codegen.gen(argumentExpression)
|
val value = codegen.gen(argumentExpression)
|
||||||
val kind = when {
|
val kind = when {
|
||||||
isCallSiteIsSuspend(valueParameterDescriptor) && parameterType.kotlinType?.isSuspendFunctionTypeOrSubtype == true ->
|
isCallSiteIsSuspend(valueParameterDescriptor) && parameterType.kotlinType?.isSuspendFunctionTypeOrSubtype == true ->
|
||||||
ValueKind.NON_INLINEABLE_ARGUMENT_FOR_INLINE_PARAMETER_CALLED_IN_SUSPEND
|
ValueKind.READ_OF_INLINE_LAMBDA_FOR_INLINE_SUSPEND_PARAMETER
|
||||||
isInlineSuspendParameter(valueParameterDescriptor) -> ValueKind.NON_INLINEABLE_ARGUMENT_FOR_INLINE_SUSPEND_PARAMETER
|
isInlineSuspendParameter(valueParameterDescriptor) -> ValueKind.READ_OF_OBJECT_FOR_INLINE_SUSPEND_PARAMETER
|
||||||
else -> ValueKind.GENERAL
|
else -> ValueKind.GENERAL
|
||||||
}
|
}
|
||||||
putValueIfNeeded(parameterType, value, kind, parameterIndex)
|
putValueIfNeeded(parameterType, value, kind, parameterIndex)
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ class AnonymousObjectTransformationInfo internal constructor(
|
|||||||
// to map the inner reference to the outer regenerated type and producing an infinite recursion.
|
// to map the inner reference to the outer regenerated type and producing an infinite recursion.
|
||||||
override fun shouldRegenerate(sameModule: Boolean): Boolean = alreadyRegenerated ||
|
override fun shouldRegenerate(sameModule: Boolean): Boolean = alreadyRegenerated ||
|
||||||
!sameModule || capturedOuterRegenerated || needReification || capturesAnonymousObjectThatMustBeRegenerated ||
|
!sameModule || capturedOuterRegenerated || needReification || capturesAnonymousObjectThatMustBeRegenerated ||
|
||||||
functionalArguments.values.any { it != NonInlineableArgumentForInlineableParameterCalledInSuspend }
|
functionalArguments.values.any { it != NonInlineArgumentForInlineSuspendParameter.INLINE_LAMBDA_AS_VARIABLE }
|
||||||
|
|
||||||
override fun canRemoveAfterTransformation(): Boolean {
|
override fun canRemoveAfterTransformation(): Boolean {
|
||||||
// Note: It is unsafe to remove anonymous class that is referenced by GETSTATIC within lambda
|
// Note: It is unsafe to remove anonymous class that is referenced by GETSTATIC within lambda
|
||||||
|
|||||||
+2
-2
@@ -177,9 +177,9 @@ private const val NOINLINE_CALL_MARKER = "\$\$\$\$\$NOINLINE_CALL_MARKER\$\$\$\$
|
|||||||
|
|
||||||
fun markNoinlineLambdaIfSuspend(mv: MethodVisitor, info: FunctionalArgument?) {
|
fun markNoinlineLambdaIfSuspend(mv: MethodVisitor, info: FunctionalArgument?) {
|
||||||
when (info) {
|
when (info) {
|
||||||
NonInlineableArgumentForInlineableSuspendParameter ->
|
NonInlineArgumentForInlineSuspendParameter.OTHER ->
|
||||||
mv.visitMethodInsn(Opcodes.INVOKESTATIC, NOINLINE_CALL_MARKER, "always", "()V", false)
|
mv.visitMethodInsn(Opcodes.INVOKESTATIC, NOINLINE_CALL_MARKER, "always", "()V", false)
|
||||||
NonInlineableArgumentForInlineableParameterCalledInSuspend ->
|
NonInlineArgumentForInlineSuspendParameter.INLINE_LAMBDA_AS_VARIABLE -> // depends on how it's substituted later
|
||||||
mv.visitMethodInsn(Opcodes.INVOKESTATIC, NOINLINE_CALL_MARKER, "conditional", "()V", false)
|
mv.visitMethodInsn(Opcodes.INVOKESTATIC, NOINLINE_CALL_MARKER, "conditional", "()V", false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -111,9 +111,9 @@ class IrInlineCodegen(
|
|||||||
ValueKind.DEFAULT_PARAMETER
|
ValueKind.DEFAULT_PARAMETER
|
||||||
isInlineParameter && irValueParameter.type.isSuspendFunction() ->
|
isInlineParameter && irValueParameter.type.isSuspendFunction() ->
|
||||||
if (argumentExpression.isReadOfInlineLambda())
|
if (argumentExpression.isReadOfInlineLambda())
|
||||||
ValueKind.NON_INLINEABLE_ARGUMENT_FOR_INLINE_PARAMETER_CALLED_IN_SUSPEND
|
ValueKind.READ_OF_INLINE_LAMBDA_FOR_INLINE_SUSPEND_PARAMETER
|
||||||
else
|
else
|
||||||
ValueKind.NON_INLINEABLE_ARGUMENT_FOR_INLINE_SUSPEND_PARAMETER
|
ValueKind.READ_OF_OBJECT_FOR_INLINE_SUSPEND_PARAMETER
|
||||||
else ->
|
else ->
|
||||||
ValueKind.GENERAL
|
ValueKind.GENERAL
|
||||||
}
|
}
|
||||||
@@ -196,7 +196,7 @@ class IrExpressionLambdaImpl(
|
|||||||
val captureStart = if (isExtensionLambda) 1 else 0 // extension receiver comes before captures
|
val captureStart = if (isExtensionLambda) 1 else 0 // extension receiver comes before captures
|
||||||
val captureEnd = captureStart + capturedParameters.size
|
val captureEnd = captureStart + capturedParameters.size
|
||||||
capturedVars = capturedParameters.mapIndexed { index, (parameter, _) ->
|
capturedVars = capturedParameters.mapIndexed { index, (parameter, _) ->
|
||||||
val isSuspend = parameter.isInlineParameter() && parameter.type.isSuspendFunctionTypeOrSubtype()
|
val isSuspend = parameter.isInlineParameter() && parameter.type.isSuspendFunction()
|
||||||
capturedParamDesc(parameter.name.asString(), asmMethod.argumentTypes[captureStart + index], isSuspend)
|
capturedParamDesc(parameter.name.asString(), asmMethod.argumentTypes[captureStart + index], isSuspend)
|
||||||
}
|
}
|
||||||
// The parameter list should include the continuation if this is a suspend lambda. In the IR backend,
|
// The parameter list should include the continuation if this is a suspend lambda. In the IR backend,
|
||||||
|
|||||||
Reference in New Issue
Block a user