Merge RestrictedCoroutineImpl into CoroutineImpl
This commit is contained in:
@@ -187,7 +187,7 @@ class CoroutineCodegen(
|
||||
// .resume(Unit)
|
||||
StackValue.putUnitInstance(this)
|
||||
invokevirtual(
|
||||
AsmTypes.RESTRICTED_COROUTINE_IMPL.internalName,
|
||||
AsmTypes.COROUTINE_IMPL.internalName,
|
||||
CONTINUATION_RESUME_METHOD_NAME.identifier,
|
||||
Type.getMethodDescriptor(Type.VOID_TYPE, AsmTypes.OBJECT_TYPE),
|
||||
false
|
||||
|
||||
+2
-2
@@ -110,7 +110,7 @@ class CoroutineTransformerMethodVisitor(
|
||||
VarInsnNode(Opcodes.ALOAD, 0),
|
||||
FieldInsnNode(
|
||||
Opcodes.GETFIELD,
|
||||
AsmTypes.RESTRICTED_COROUTINE_IMPL.internalName,
|
||||
AsmTypes.COROUTINE_IMPL.internalName,
|
||||
COROUTINE_LABEL_FIELD_NAME, Type.INT_TYPE.descriptor
|
||||
),
|
||||
TableSwitchInsnNode(0,
|
||||
@@ -295,7 +295,7 @@ class CoroutineTransformerMethodVisitor(
|
||||
VarInsnNode(Opcodes.ALOAD, 0),
|
||||
*withInstructionAdapter { iconst(id) }.toArray(),
|
||||
FieldInsnNode(
|
||||
Opcodes.PUTFIELD, AsmTypes.RESTRICTED_COROUTINE_IMPL.internalName, COROUTINE_LABEL_FIELD_NAME,
|
||||
Opcodes.PUTFIELD, AsmTypes.COROUTINE_IMPL.internalName, COROUTINE_LABEL_FIELD_NAME,
|
||||
Type.INT_TYPE.descriptor
|
||||
)
|
||||
)
|
||||
|
||||
@@ -41,7 +41,6 @@ public class AsmTypes {
|
||||
public static final Type MUTABLE_PROPERTY_REFERENCE1 = Type.getObjectType("kotlin/jvm/internal/MutablePropertyReference1");
|
||||
public static final Type MUTABLE_PROPERTY_REFERENCE2 = Type.getObjectType("kotlin/jvm/internal/MutablePropertyReference2");
|
||||
public static final Type COROUTINE_IMPL = Type.getObjectType("kotlin/jvm/internal/CoroutineImpl");
|
||||
public static final Type RESTRICTED_COROUTINE_IMPL = Type.getObjectType("kotlin/jvm/internal/RestrictedCoroutineImpl");
|
||||
public static final Type COROUTINES_INTRINSICS_FILE_FACADE = Type.getObjectType("kotlin/coroutines/intrinsics/IntrinsicsKt");
|
||||
public static final Type CONTINUATION = Type.getObjectType("kotlin/coroutines/Continuation");
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ fun builder1(c: suspend () -> Unit) {
|
||||
|
||||
fun builder2(c: suspend () -> Unit) {
|
||||
val continuation = c.createCoroutine(EmptyContinuation)
|
||||
val declaredField = continuation.javaClass.superclass.superclass.getDeclaredField("label")
|
||||
val declaredField = continuation.javaClass.superclass.getDeclaredField("label")
|
||||
declaredField.setAccessible(true)
|
||||
declaredField.set(continuation, -3)
|
||||
continuation.resume(Unit)
|
||||
|
||||
@@ -19,8 +19,18 @@ package kotlin.jvm.internal
|
||||
import kotlin.coroutines.*
|
||||
import kotlin.coroutines.intrinsics.SUSPENDED_MARKER
|
||||
|
||||
abstract class CoroutineImpl : RestrictedCoroutineImpl, DispatchedContinuation<Any?> {
|
||||
private val _dispatcher: ContinuationDispatcher?
|
||||
abstract class CoroutineImpl(
|
||||
arity: Int,
|
||||
@JvmField
|
||||
protected var completion: Continuation<Any?>?
|
||||
) : DispatchedContinuation<Any?>, Lambda(arity), Continuation<Any?> {
|
||||
|
||||
// label == -1 when coroutine cannot be started (it is just a factory object) or has already finished execution
|
||||
// label == 0 in initial part of the coroutine
|
||||
@JvmField
|
||||
protected var label: Int = if (completion != null) 0 else -1
|
||||
|
||||
private val _dispatcher: ContinuationDispatcher? = (completion as? DispatchedContinuation<*>)?.dispatcher
|
||||
|
||||
override val dispatcher: ContinuationDispatcher?
|
||||
get() = _dispatcher
|
||||
@@ -34,27 +44,6 @@ abstract class CoroutineImpl : RestrictedCoroutineImpl, DispatchedContinuation<A
|
||||
return facade_!!
|
||||
}
|
||||
|
||||
// this constructor is used to create a continuation instance for coroutine
|
||||
constructor(arity: Int, completion: Continuation<Any?>?) : super(arity, completion) {
|
||||
_dispatcher = (completion as? DispatchedContinuation<*>)?.dispatcher
|
||||
}
|
||||
}
|
||||
|
||||
abstract class RestrictedCoroutineImpl : Lambda, Continuation<Any?> {
|
||||
@JvmField
|
||||
protected var completion: Continuation<Any?>?
|
||||
|
||||
// label == -1 when coroutine cannot be started (it is just a factory object) or has already finished execution
|
||||
// label == 0 in initial part of the coroutine
|
||||
@JvmField
|
||||
protected var label: Int
|
||||
|
||||
// this constructor is used to create a continuation instance for coroutine
|
||||
constructor(arity: Int, completion: Continuation<Any?>?) : super(arity) {
|
||||
this.completion = completion
|
||||
label = if (completion != null) 0 else -1
|
||||
}
|
||||
|
||||
override fun resume(value: Any?) {
|
||||
try {
|
||||
val result = doResume(value, null)
|
||||
|
||||
+4
-10
@@ -468,8 +468,11 @@ public class kotlin/jvm/internal/CollectionToArray {
|
||||
public static fun toArray (Ljava/util/Collection;[Ljava/lang/Object;)[Ljava/lang/Object;
|
||||
}
|
||||
|
||||
public abstract class kotlin/jvm/internal/CoroutineImpl : kotlin/jvm/internal/RestrictedCoroutineImpl, kotlin/jvm/internal/DispatchedContinuation {
|
||||
public abstract class kotlin/jvm/internal/CoroutineImpl : kotlin/jvm/internal/Lambda, kotlin/coroutines/Continuation, kotlin/jvm/internal/DispatchedContinuation {
|
||||
protected field completion Lkotlin/coroutines/Continuation;
|
||||
protected field label I
|
||||
public fun <init> (ILkotlin/coroutines/Continuation;)V
|
||||
protected abstract fun doResume (Ljava/lang/Object;Ljava/lang/Throwable;)Ljava/lang/Object;
|
||||
public fun getDispatcher ()Lkotlin/coroutines/ContinuationDispatcher;
|
||||
public final fun getFacade ()Lkotlin/coroutines/Continuation;
|
||||
public fun resume (Ljava/lang/Object;)V
|
||||
@@ -867,15 +870,6 @@ public class kotlin/jvm/internal/ReflectionFactory {
|
||||
public fun renderLambdaToString (Lkotlin/jvm/internal/Lambda;)Ljava/lang/String;
|
||||
}
|
||||
|
||||
public abstract class kotlin/jvm/internal/RestrictedCoroutineImpl : kotlin/jvm/internal/Lambda, kotlin/coroutines/Continuation {
|
||||
protected field completion Lkotlin/coroutines/Continuation;
|
||||
protected field label I
|
||||
public fun <init> (ILkotlin/coroutines/Continuation;)V
|
||||
protected abstract fun doResume (Ljava/lang/Object;Ljava/lang/Throwable;)Ljava/lang/Object;
|
||||
public fun resume (Ljava/lang/Object;)V
|
||||
public fun resumeWithException (Ljava/lang/Throwable;)V
|
||||
}
|
||||
|
||||
public final class kotlin/jvm/internal/ShortCompanionObject {
|
||||
public static final field INSTANCE Lkotlin/jvm/internal/ShortCompanionObject;
|
||||
public static final field MAX_VALUE S
|
||||
|
||||
Reference in New Issue
Block a user