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(),
|
*withInstructionAdapter { loadCoroutineSuspendedMarker() }.toArray(),
|
||||||
VarInsnNode(Opcodes.ASTORE, suspendMarkerVarIndex),
|
VarInsnNode(Opcodes.ASTORE, suspendMarkerVarIndex),
|
||||||
VarInsnNode(Opcodes.ALOAD, continuationIndex),
|
VarInsnNode(Opcodes.ALOAD, continuationIndex),
|
||||||
FieldInsnNode(
|
createInsnForReadingLabel(),
|
||||||
Opcodes.GETFIELD,
|
|
||||||
COROUTINE_IMPL_ASM_TYPE.internalName,
|
|
||||||
COROUTINE_LABEL_FIELD_NAME, Type.INT_TYPE.descriptor
|
|
||||||
),
|
|
||||||
TableSwitchInsnNode(0,
|
TableSwitchInsnNode(0,
|
||||||
suspensionPoints.size,
|
suspensionPoints.size,
|
||||||
defaultLabel,
|
defaultLabel,
|
||||||
@@ -140,6 +136,38 @@ class CoroutineTransformerMethodVisitor(
|
|||||||
methodNode.removeEmptyCatchBlocks()
|
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) {
|
private fun updateMaxStack(methodNode: MethodNode) {
|
||||||
methodNode.instructions.resetLabels()
|
methodNode.instructions.resetLabels()
|
||||||
methodNode.accept(
|
methodNode.accept(
|
||||||
@@ -441,18 +469,7 @@ class CoroutineTransformerMethodVisitor(
|
|||||||
insnListOf(
|
insnListOf(
|
||||||
VarInsnNode(Opcodes.ALOAD, continuationIndex),
|
VarInsnNode(Opcodes.ALOAD, continuationIndex),
|
||||||
*withInstructionAdapter { iconst(id) }.toArray(),
|
*withInstructionAdapter { iconst(id) }.toArray(),
|
||||||
if (isForNamedFunction)
|
createInsnForSettingLabel()
|
||||||
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
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user