Merge RestrictedCoroutineImpl into CoroutineImpl
This commit is contained in:
@@ -187,7 +187,7 @@ class CoroutineCodegen(
|
|||||||
// .resume(Unit)
|
// .resume(Unit)
|
||||||
StackValue.putUnitInstance(this)
|
StackValue.putUnitInstance(this)
|
||||||
invokevirtual(
|
invokevirtual(
|
||||||
AsmTypes.RESTRICTED_COROUTINE_IMPL.internalName,
|
AsmTypes.COROUTINE_IMPL.internalName,
|
||||||
CONTINUATION_RESUME_METHOD_NAME.identifier,
|
CONTINUATION_RESUME_METHOD_NAME.identifier,
|
||||||
Type.getMethodDescriptor(Type.VOID_TYPE, AsmTypes.OBJECT_TYPE),
|
Type.getMethodDescriptor(Type.VOID_TYPE, AsmTypes.OBJECT_TYPE),
|
||||||
false
|
false
|
||||||
|
|||||||
+2
-2
@@ -110,7 +110,7 @@ class CoroutineTransformerMethodVisitor(
|
|||||||
VarInsnNode(Opcodes.ALOAD, 0),
|
VarInsnNode(Opcodes.ALOAD, 0),
|
||||||
FieldInsnNode(
|
FieldInsnNode(
|
||||||
Opcodes.GETFIELD,
|
Opcodes.GETFIELD,
|
||||||
AsmTypes.RESTRICTED_COROUTINE_IMPL.internalName,
|
AsmTypes.COROUTINE_IMPL.internalName,
|
||||||
COROUTINE_LABEL_FIELD_NAME, Type.INT_TYPE.descriptor
|
COROUTINE_LABEL_FIELD_NAME, Type.INT_TYPE.descriptor
|
||||||
),
|
),
|
||||||
TableSwitchInsnNode(0,
|
TableSwitchInsnNode(0,
|
||||||
@@ -295,7 +295,7 @@ class CoroutineTransformerMethodVisitor(
|
|||||||
VarInsnNode(Opcodes.ALOAD, 0),
|
VarInsnNode(Opcodes.ALOAD, 0),
|
||||||
*withInstructionAdapter { iconst(id) }.toArray(),
|
*withInstructionAdapter { iconst(id) }.toArray(),
|
||||||
FieldInsnNode(
|
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
|
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_REFERENCE1 = Type.getObjectType("kotlin/jvm/internal/MutablePropertyReference1");
|
||||||
public static final Type MUTABLE_PROPERTY_REFERENCE2 = Type.getObjectType("kotlin/jvm/internal/MutablePropertyReference2");
|
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 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 COROUTINES_INTRINSICS_FILE_FACADE = Type.getObjectType("kotlin/coroutines/intrinsics/IntrinsicsKt");
|
||||||
public static final Type CONTINUATION = Type.getObjectType("kotlin/coroutines/Continuation");
|
public static final Type CONTINUATION = Type.getObjectType("kotlin/coroutines/Continuation");
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ fun builder1(c: suspend () -> Unit) {
|
|||||||
|
|
||||||
fun builder2(c: suspend () -> Unit) {
|
fun builder2(c: suspend () -> Unit) {
|
||||||
val continuation = c.createCoroutine(EmptyContinuation)
|
val continuation = c.createCoroutine(EmptyContinuation)
|
||||||
val declaredField = continuation.javaClass.superclass.superclass.getDeclaredField("label")
|
val declaredField = continuation.javaClass.superclass.getDeclaredField("label")
|
||||||
declaredField.setAccessible(true)
|
declaredField.setAccessible(true)
|
||||||
declaredField.set(continuation, -3)
|
declaredField.set(continuation, -3)
|
||||||
continuation.resume(Unit)
|
continuation.resume(Unit)
|
||||||
|
|||||||
@@ -19,8 +19,18 @@ package kotlin.jvm.internal
|
|||||||
import kotlin.coroutines.*
|
import kotlin.coroutines.*
|
||||||
import kotlin.coroutines.intrinsics.SUSPENDED_MARKER
|
import kotlin.coroutines.intrinsics.SUSPENDED_MARKER
|
||||||
|
|
||||||
abstract class CoroutineImpl : RestrictedCoroutineImpl, DispatchedContinuation<Any?> {
|
abstract class CoroutineImpl(
|
||||||
private val _dispatcher: ContinuationDispatcher?
|
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?
|
override val dispatcher: ContinuationDispatcher?
|
||||||
get() = _dispatcher
|
get() = _dispatcher
|
||||||
@@ -34,27 +44,6 @@ abstract class CoroutineImpl : RestrictedCoroutineImpl, DispatchedContinuation<A
|
|||||||
return facade_!!
|
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?) {
|
override fun resume(value: Any?) {
|
||||||
try {
|
try {
|
||||||
val result = doResume(value, null)
|
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 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
|
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 fun getDispatcher ()Lkotlin/coroutines/ContinuationDispatcher;
|
||||||
public final fun getFacade ()Lkotlin/coroutines/Continuation;
|
public final fun getFacade ()Lkotlin/coroutines/Continuation;
|
||||||
public fun resume (Ljava/lang/Object;)V
|
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 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 final class kotlin/jvm/internal/ShortCompanionObject {
|
||||||
public static final field INSTANCE Lkotlin/jvm/internal/ShortCompanionObject;
|
public static final field INSTANCE Lkotlin/jvm/internal/ShortCompanionObject;
|
||||||
public static final field MAX_VALUE S
|
public static final field MAX_VALUE S
|
||||||
|
|||||||
Reference in New Issue
Block a user