Minor. Remove redundant kind of coroutine markers

It was necessary while the additional code was being inserted
outside of transformer, but now we can just remember where
the actual body starts
This commit is contained in:
Denis Zharkov
2017-05-04 12:42:54 +03:00
parent b3f66c7641
commit ba200f5de1
2 changed files with 4 additions and 14 deletions
@@ -64,6 +64,9 @@ class CoroutineTransformerMethodVisitor(
override fun performTransformations(methodNode: MethodNode) {
val suspensionPoints = collectSuspensionPoints(methodNode)
// First instruction in the method node may change in case of named function
val actualCoroutineStart = methodNode.instructions.first
if (isForNamedFunction) {
if (allSuspensionPointsAreTailCalls(containingClassInternalName, methodNode, suspensionPoints)) {
dropSuspensionMarkers(methodNode, suspensionPoints)
@@ -76,16 +79,6 @@ class CoroutineTransformerMethodVisitor(
prepareMethodNodePreludeForNamedFunction(methodNode)
}
val customCoroutineStart = run {
val customCoroutineStartMarker = methodNode.instructions.toArray().filterIsInstance<MethodInsnNode>().firstOrNull {
it.owner == COROUTINE_MARKER_OWNER && it.name == ACTUAL_COROUTINE_START_MARKER_NAME
}
customCoroutineStartMarker?.next?.also {
methodNode.instructions.remove(customCoroutineStartMarker)
}
}
for (suspensionPoint in suspensionPoints) {
splitTryCatchBlocksContainingSuspensionPoint(methodNode, suspensionPoint)
}
@@ -110,7 +103,7 @@ class CoroutineTransformerMethodVisitor(
methodNode.instructions.apply {
val startLabel = LabelNode()
val defaultLabel = LabelNode()
val firstToInsertBefore = customCoroutineStart ?: first
val firstToInsertBefore = actualCoroutineStart
// tableswitch(this.label)
insertBefore(firstToInsertBefore,
insnListOf(
@@ -221,8 +214,6 @@ class CoroutineTransformerMethodVisitor(
checkcast(objectTypeForState)
getfield(COROUTINE_IMPL_FOR_NAMED_ASM_TYPE.internalName, "exception", AsmTypes.JAVA_THROWABLE_TYPE.descriptor)
visitVarInsn(Opcodes.ASTORE, exceptionIndex)
invokestatic(COROUTINE_MARKER_OWNER, ACTUAL_COROUTINE_START_MARKER_NAME, "()V", false)
})
}
@@ -55,7 +55,6 @@ import org.jetbrains.org.objectweb.asm.tree.MethodNode
const val COROUTINE_MARKER_OWNER = "kotlin/coroutines/Markers"
const val BEFORE_SUSPENSION_POINT_MARKER_NAME = "beforeSuspensionPoint"
const val AFTER_SUSPENSION_POINT_MARKER_NAME = "afterSuspensionPoint"
const val ACTUAL_COROUTINE_START_MARKER_NAME = "actualCoroutineStart"
const val COROUTINE_LABEL_FIELD_NAME = "label"
const val SUSPEND_FUNCTION_CREATE_METHOD_NAME = "create"