diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp index 19a5fa16e5a9a..c84ea00dfacba 100644 --- a/lib/AST/Type.cpp +++ b/lib/AST/Type.cpp @@ -525,6 +525,11 @@ bool TypeBase::canBeIsolatedTo() { // Optional since we shouldn't ever see that. if (auto ty = getOptionalObjectType()) return ty->isAnyActorType(); + + // TODO: remove debugging stuff + if (true) + return getReferenceStorageReferent()->isAnyActorType(); + return isAnyActorType(); } @@ -2364,6 +2369,10 @@ bool TypeBase::mayHaveSuperclass() { if (auto archetype = getAs()) return (bool)archetype->requiresClass(); + // TODO: remove debugging stuff +// if (true) +// return getReferenceStorageReferent()->mayHaveSuperclass(); + return is(); } @@ -2943,6 +2952,12 @@ static bool isBridgeableObjectType(CanType type) { == SILFunctionType::Representation::Block; } + if (false) { + type->getReferenceStorageReferent() + ->getCanonicalType() + ->isBridgeableObjectType(); + } + return false; } diff --git a/lib/SIL/Verifier/SILVerifier.cpp b/lib/SIL/Verifier/SILVerifier.cpp index d5515e6243b2d..1be958b77df61 100644 --- a/lib/SIL/Verifier/SILVerifier.cpp +++ b/lib/SIL/Verifier/SILVerifier.cpp @@ -7811,8 +7811,8 @@ class SILVerifier : public SILVerifierBase { auto *distributedProtocol = ctx.getProtocol(KnownProtocolKind::DistributedActor); require(argType->canBeIsolatedTo() || - genericSig->requiresProtocol(argType, actorProtocol) || - genericSig->requiresProtocol(argType, distributedProtocol), + (genericSig && genericSig->requiresProtocol(argType, actorProtocol)) || + (genericSig && genericSig->requiresProtocol(argType, distributedProtocol)), "Only any actor types can be isolated"); require(!foundIsolatedParameter, "Two isolated parameters"); foundIsolatedParameter = true; diff --git a/lib/SILGen/SILGenConcurrency.cpp b/lib/SILGen/SILGenConcurrency.cpp index b03fcd82fcad6..b78c288b6e1ce 100644 --- a/lib/SILGen/SILGenConcurrency.cpp +++ b/lib/SILGen/SILGenConcurrency.cpp @@ -437,6 +437,28 @@ emitNonOptionalActorInstanceIsolation(SILGenFunction &SGF, SILLocation loc, return emitDistributedActorIsolation(SGF, loc, actor, actorType); } +// llvm::dbgs() << "JQ: actor ownership: " << actor.getOwnershipKind() << "\n"; +// llvm::dbgs() << actor.getType().getReferenceStorageOwnership() << "\n"; +// if (false && actor.getType().getReferenceStorageOwnership() == ReferenceOwnership::Unowned) { +// // if (true && actor.getOwnershipKind() == OwnershipKind::Unowned) { +// llvm::dbgs() << "JQ: unowned conversion\n"; +// auto *UTRI = SGF.getBuilder().createUnownedToRef(loc, actor.getValue(), actor.getType().getReferenceStorageReferentType()); +// UTRI->dump(); +// actor = ManagedValue::forUnownedObjectValue(UTRI).ensurePlusOne(SGF, loc); + +// // auto ogTy = actorType; +// auto newTy = actorType->getReferenceStorageReferent()->getCanonicalType(); +// // actorType = actorType->getReferenceStorageReferent()->getCanonicalType(); + +// auto transformed = actor.forUnownedObjectValue(actor.getValue()) +// .ensurePlusOne(SGF, loc); +// // emitTransformedValue(loc, actor, +// // ogTy, +// // newTy); +// actor = transformed; +// actorType = newTy; +// } + return SGF.emitTransformExistential(loc, actor, actorType, anyActorType); } @@ -634,7 +656,19 @@ static ManagedValue emitLoadOfCaptureIsolation(SILGenFunction &SGF, TC.getCaptureTypeExpansionContext(constant)) == CaptureKind::Constant); - auto value = captureArgs[i].copy(SGF, loc); + ManagedValue value; + if (true && isa(isolatedVarType)) { + auto isolatedArg = captureArgs[i]; + // convert from sil_unowned + auto *UTRI = SGF.getBuilder().createUnownedToRef(loc, isolatedArg.getValue(), isolatedArg.getType().getReferenceStorageReferentType()); + value = ManagedValue::forUnownedObjectValue(UTRI).ensurePlusOne(SGF, loc); +// value = SGF.getBuilder().createStrongCopyUnownedValue(loc, captureArgs[i]); + isolatedVarType = isolatedVarType->getReferenceStorageReferent()->getCanonicalType(); + } else { + value = captureArgs[i].copy(SGF, loc); + } + +// auto value = captureArgs[i].copy(SGF, loc); return SGF.emitActorInstanceIsolation(loc, value, isolatedVarType); } diff --git a/lib/SILGen/SILGenPoly.cpp b/lib/SILGen/SILGenPoly.cpp index 8dfd02ce97aa6..6c5bd7a4801eb 100644 --- a/lib/SILGen/SILGenPoly.cpp +++ b/lib/SILGen/SILGenPoly.cpp @@ -291,6 +291,14 @@ SILGenFunction::emitTransformExistential(SILLocation loc, toInstanceType, /*allowMissing=*/true); +// if (input.getOwnershipKind() == OwnershipKind::Unowned) { +// auto *UTRI = getBuilder().createUnownedToRef(loc, input.getValue(), input.getType().getReferenceStorageReferentType()); +// input = ManagedValue::forUnownedObjectValue(UTRI); +// +// input = ManagedValue::forUnownedObjectValue(input.getValue()); +// inputType = inputType->getReferenceStorageReferent()->getCanonicalType(); +// } + // Build result existential AbstractionPattern opaque = AbstractionPattern::getOpaque(); const TypeLowering &concreteTL = getTypeLowering(opaque, inputType);