Move coroutine intrinsics to object (backend's)

This commit is contained in:
Denis Zharkov
2016-12-15 19:18:13 +03:00
committed by Stanislav Erokhin
parent 7b079bd1f7
commit c73b0d7b76
4 changed files with 22 additions and 22 deletions
@@ -24,6 +24,7 @@ import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.descriptors.annotations.Annotations
import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl
import org.jetbrains.kotlin.load.java.JvmAbi
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.resolve.BindingContext
@@ -278,9 +279,14 @@ fun createMethodNodeForSuspendWithCurrentContinuation(
fun CallableDescriptor?.unwrapInitialDescriptorForSuspendFunction() =
(this as? SimpleFunctionDescriptor)?.getUserData(INITIAL_DESCRIPTOR_FOR_SUSPEND_FUNCTION) ?: this
fun InstructionAdapter.loadSuspendMarker() = invokestatic(
AsmTypes.COROUTINES_SUSPEND_MARKER_OWNER.internalName,
"getSUSPENDED",
Type.getMethodDescriptor(AsmTypes.OBJECT_TYPE),
false
)
fun InstructionAdapter.loadSuspendMarker() {
getstatic(
AsmTypes.COROUTINES_INTRINSICS.internalName, JvmAbi.INSTANCE_FIELD, AsmTypes.COROUTINES_INTRINSICS.descriptor
)
invokevirtual(
AsmTypes.COROUTINES_INTRINSICS.internalName,
"getSUSPENDED",
Type.getMethodDescriptor(AsmTypes.OBJECT_TYPE),
false
)
}
@@ -331,20 +331,11 @@ public class KotlinTypeMapper {
}
private static final ClassId FAKE_CLASS_ID_FOR_BUILTINS = ClassId.topLevel(new FqName("kotlin.KotlinPackage"));
private static final FqName COROUTINE_SUSPENDED_PROPERTY = new FqName("kotlin.coroutines.SUSPENDED");
@Nullable
private static ContainingClassesInfo getPackageMemberContainingClassesInfo(@NotNull DeserializedCallableMemberDescriptor descriptor) {
DeclarationDescriptor containingDeclaration = descriptor.getContainingDeclaration();
if (containingDeclaration instanceof BuiltInsPackageFragment) {
// TODO: Top level callables are not supported in built-ins
// (while they are loaded from .kotlin-builtins files information about the actual file part is lost)
// This must be fixed when built-ins get loaded through their class files
if (DescriptorUtils.getFqName(descriptor).equals(COROUTINE_SUSPENDED_PROPERTY.toUnsafe())) {
ClassId id = ClassId.topLevel(new FqName("kotlin.coroutines.CoroutinesKt"));
return new ContainingClassesInfo(id, id);
}
return new ContainingClassesInfo(FAKE_CLASS_ID_FOR_BUILTINS, FAKE_CLASS_ID_FOR_BUILTINS);
}
@@ -42,7 +42,7 @@ public class AsmTypes {
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_SUSPEND_MARKER_OWNER = Type.getObjectType("kotlin/coroutines/CoroutinesKt");
public static final Type COROUTINES_INTRINSICS = Type.getObjectType("kotlin/coroutines/CoroutineIntrinsics");
public static final Type CONTINUATION = Type.getObjectType("kotlin/coroutines/Continuation");