Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions lib/AST/Type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,11 @@ bool TypeBase::canBeIsolatedTo() {
// Optional<Builtin.ImplicitActor> 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();
}

Expand Down Expand Up @@ -2364,6 +2369,10 @@ bool TypeBase::mayHaveSuperclass() {
if (auto archetype = getAs<ArchetypeType>())
return (bool)archetype->requiresClass();

// TODO: remove debugging stuff
// if (true)
// return getReferenceStorageReferent()->mayHaveSuperclass();

return is<DynamicSelfType>();
}

Expand Down Expand Up @@ -2943,6 +2952,12 @@ static bool isBridgeableObjectType(CanType type) {
== SILFunctionType::Representation::Block;
}

if (false) {
type->getReferenceStorageReferent()
->getCanonicalType()
->isBridgeableObjectType();
}

return false;
}

Expand Down
4 changes: 2 additions & 2 deletions lib/SIL/Verifier/SILVerifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7811,8 +7811,8 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
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;
Expand Down
36 changes: 35 additions & 1 deletion lib/SILGen/SILGenConcurrency.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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<UnownedStorageType>(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);
}

Expand Down
8 changes: 8 additions & 0 deletions lib/SILGen/SILGenPoly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down