@@ -113,11 +113,7 @@ class CoroutineTransformerMethodVisitor(
113
113
* withInstructionAdapter { loadCoroutineSuspendedMarker() }.toArray(),
114
114
VarInsnNode (Opcodes .ASTORE , suspendMarkerVarIndex),
115
115
VarInsnNode (Opcodes .ALOAD , continuationIndex),
116
- FieldInsnNode (
117
- Opcodes .GETFIELD ,
118
- COROUTINE_IMPL_ASM_TYPE .internalName,
119
- COROUTINE_LABEL_FIELD_NAME , Type .INT_TYPE .descriptor
120
- ),
116
+ createInsnForReadingLabel(),
121
117
TableSwitchInsnNode (0 ,
122
118
suspensionPoints.size,
123
119
defaultLabel,
@@ -140,6 +136,38 @@ class CoroutineTransformerMethodVisitor(
140
136
methodNode.removeEmptyCatchBlocks()
141
137
}
142
138
139
+ private fun createInsnForReadingLabel () =
140
+ if (isForNamedFunction)
141
+ MethodInsnNode (
142
+ Opcodes .INVOKEVIRTUAL ,
143
+ classBuilderForCoroutineState.thisName,
144
+ " getLabel" ,
145
+ Type .getMethodDescriptor(Type .INT_TYPE ),
146
+ false
147
+ )
148
+ else
149
+ FieldInsnNode (
150
+ Opcodes .GETFIELD ,
151
+ COROUTINE_IMPL_ASM_TYPE .internalName,
152
+ COROUTINE_LABEL_FIELD_NAME , Type .INT_TYPE .descriptor
153
+ )
154
+
155
+ private fun createInsnForSettingLabel () =
156
+ if (isForNamedFunction)
157
+ MethodInsnNode (
158
+ Opcodes .INVOKEVIRTUAL ,
159
+ classBuilderForCoroutineState.thisName,
160
+ " setLabel" ,
161
+ Type .getMethodDescriptor(Type .VOID_TYPE , Type .INT_TYPE ),
162
+ false
163
+ )
164
+ else
165
+ FieldInsnNode (
166
+ Opcodes .PUTFIELD ,
167
+ COROUTINE_IMPL_ASM_TYPE .internalName,
168
+ COROUTINE_LABEL_FIELD_NAME , Type .INT_TYPE .descriptor
169
+ )
170
+
143
171
private fun updateMaxStack (methodNode : MethodNode ) {
144
172
methodNode.instructions.resetLabels()
145
173
methodNode.accept(
@@ -441,18 +469,7 @@ class CoroutineTransformerMethodVisitor(
441
469
insnListOf(
442
470
VarInsnNode (Opcodes .ALOAD , continuationIndex),
443
471
* withInstructionAdapter { iconst(id) }.toArray(),
444
- if (isForNamedFunction)
445
- MethodInsnNode (
446
- Opcodes .INVOKEVIRTUAL , classBuilderForCoroutineState.thisName,
447
- " setLabel" ,
448
- Type .getMethodDescriptor(Type .VOID_TYPE , Type .INT_TYPE ),
449
- false
450
- )
451
- else
452
- FieldInsnNode (
453
- Opcodes .PUTFIELD , COROUTINE_IMPL_ASM_TYPE .internalName, COROUTINE_LABEL_FIELD_NAME ,
454
- Type .INT_TYPE .descriptor
455
- )
472
+ createInsnForSettingLabel()
456
473
)
457
474
)
458
475
0 commit comments