Skip to content
Merged
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
6 changes: 6 additions & 0 deletions include/swift/SIL/SILArgument.h
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,12 @@ class SILFunctionArgument : public SILArgument {
/// Returns true if this SILFunctionArgument is an 'inout sending' parameter.
bool isInOutSending() const;

bool isIsolated() const {
return !isIndirectResult() && !isIndirectErrorResult() &&
getKnownParameterInfo().getOptions().contains(
SILParameterInfo::Isolated);
}

Lifetime getLifetime() const {
return getType()
.getLifetime(*getFunction())
Expand Down
21 changes: 19 additions & 2 deletions include/swift/SILOptimizer/Utils/SILIsolationInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,16 @@ class ActorInstance {
/// function)... so we just use an artificial ActorInstance to represent
/// self in this case.
CapturedActorSelf = 0x2,

/// An actor instance in an async allocating init where we are going to
/// allocate the actual actor internally. This is considered to be isolated
/// to the actor instance.
ActorAsyncAllocatingInit = 0x3,
};

/// Set to (SILValue(), $KIND) if we have an ActorAccessorInit|CapturedSelf.
/// Is null if we have (SILValue(), Kind::Value).
/// Set to (SILValue(), $KIND) if we have an
/// ActorAccessorInit|CapturedSelf|ActorAsyncAllocatingInit. Is null if we
/// have (SILValue(), Kind::Value).
llvm::PointerIntPair<SILValue, 2> value;

ActorInstance(SILValue value, Kind kind)
Expand Down Expand Up @@ -94,6 +100,12 @@ class ActorInstance {
return ActorInstance(SILValue(), Kind::CapturedActorSelf);
}

/// See Kind::ActorAsyncAllocatingInit for explanation on what a
/// ActorAsyncAllocatingInit is.
static ActorInstance getForActorAsyncAllocatingInit() {
return ActorInstance(SILValue(), Kind::ActorAsyncAllocatingInit);
}

explicit operator bool() const { return bool(value.getOpaqueValue()); }

Kind getKind() const { return Kind(value.getInt()); }
Expand All @@ -117,6 +129,10 @@ class ActorInstance {
return getKind() == Kind::CapturedActorSelf;
}

bool isActorAsyncAllocatingInit() const {
return getKind() == Kind::ActorAsyncAllocatingInit;
}

bool operator==(const ActorInstance &other) const {
// If both are null, return true.
if (!bool(*this) && !bool(other))
Expand All @@ -132,6 +148,7 @@ class ActorInstance {
return getValue() == other.getValue();
case Kind::ActorAccessorInit:
case Kind::CapturedActorSelf:
case Kind::ActorAsyncAllocatingInit:
return true;
}
}
Expand Down
Loading