Get rid of using label field in named function
It preventing from making it protected (as it was before) #KT-17898 In progress
This commit is contained in:
+34
-17
@@ -113,11 +113,7 @@ class CoroutineTransformerMethodVisitor(
|
||||
*withInstructionAdapter { loadCoroutineSuspendedMarker() }.toArray(),
|
||||
VarInsnNode(Opcodes.ASTORE, suspendMarkerVarIndex),
|
||||
VarInsnNode(Opcodes.ALOAD, continuationIndex),
|
||||
FieldInsnNode(
|
||||
Opcodes.GETFIELD,
|
||||
COROUTINE_IMPL_ASM_TYPE.internalName,
|
||||
COROUTINE_LABEL_FIELD_NAME, Type.INT_TYPE.descriptor
|
||||
),
|
||||
createInsnForReadingLabel(),
|
||||
TableSwitchInsnNode(0,
|
||||
suspensionPoints.size,
|
||||
defaultLabel,
|
||||
@@ -140,6 +136,38 @@ class CoroutineTransformerMethodVisitor(
|
||||
methodNode.removeEmptyCatchBlocks()
|
||||
}
|
||||
|
||||
private fun createInsnForReadingLabel() =
|
||||
if (isForNamedFunction)
|
||||
MethodInsnNode(
|
||||
Opcodes.INVOKEVIRTUAL,
|
||||
classBuilderForCoroutineState.thisName,
|
||||
"getLabel",
|
||||
Type.getMethodDescriptor(Type.INT_TYPE),
|
||||
false
|
||||
)
|
||||
else
|
||||
FieldInsnNode(
|
||||
Opcodes.GETFIELD,
|
||||
COROUTINE_IMPL_ASM_TYPE.internalName,
|
||||
COROUTINE_LABEL_FIELD_NAME, Type.INT_TYPE.descriptor
|
||||
)
|
||||
|
||||
private fun createInsnForSettingLabel() =
|
||||
if (isForNamedFunction)
|
||||
MethodInsnNode(
|
||||
Opcodes.INVOKEVIRTUAL,
|
||||
classBuilderForCoroutineState.thisName,
|
||||
"setLabel",
|
||||
Type.getMethodDescriptor(Type.VOID_TYPE, Type.INT_TYPE),
|
||||
false
|
||||
)
|
||||
else
|
||||
FieldInsnNode(
|
||||
Opcodes.PUTFIELD,
|
||||
COROUTINE_IMPL_ASM_TYPE.internalName,
|
||||
COROUTINE_LABEL_FIELD_NAME, Type.INT_TYPE.descriptor
|
||||
)
|
||||
|
||||
private fun updateMaxStack(methodNode: MethodNode) {
|
||||
methodNode.instructions.resetLabels()
|
||||
methodNode.accept(
|
||||
@@ -441,18 +469,7 @@ class CoroutineTransformerMethodVisitor(
|
||||
insnListOf(
|
||||
VarInsnNode(Opcodes.ALOAD, continuationIndex),
|
||||
*withInstructionAdapter { iconst(id) }.toArray(),
|
||||
if (isForNamedFunction)
|
||||
MethodInsnNode(
|
||||
Opcodes.INVOKEVIRTUAL, classBuilderForCoroutineState.thisName,
|
||||
"setLabel",
|
||||
Type.getMethodDescriptor(Type.VOID_TYPE, Type.INT_TYPE),
|
||||
false
|
||||
)
|
||||
else
|
||||
FieldInsnNode(
|
||||
Opcodes.PUTFIELD, COROUTINE_IMPL_ASM_TYPE.internalName, COROUTINE_LABEL_FIELD_NAME,
|
||||
Type.INT_TYPE.descriptor
|
||||
)
|
||||
createInsnForSettingLabel()
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user