Skip to content

Commit 0097ef6

Browse files
committed
Convert ActorIsolationRequest to use split caching
1 parent 6b9267a commit 0097ef6

File tree

4 files changed

+33
-3
lines changed

4 files changed

+33
-3
lines changed

include/swift/AST/Decl.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2820,6 +2820,10 @@ class ValueDecl : public Decl {
28202820
/// Whether this declaration produces an implicitly unwrapped
28212821
/// optional result.
28222822
unsigned isIUO : 1;
2823+
2824+
/// Whether we're in the common case where the ActorIsolationRequest
2825+
/// request returned ActorIsolation::forUnspecified().
2826+
unsigned noActorIsolation : 1;
28232827
} LazySemanticInfo = { };
28242828

28252829
friend class DynamicallyReplacedDeclRequest;
@@ -2830,6 +2834,7 @@ class ValueDecl : public Decl {
28302834
friend class IsImplicitlyUnwrappedOptionalRequest;
28312835
friend class InterfaceTypeRequest;
28322836
friend class CheckRedeclarationRequest;
2837+
friend class ActorIsolationRequest;
28332838
friend class Decl;
28342839
SourceLoc getLocFromSource() const { return NameLoc; }
28352840
protected:

include/swift/AST/TypeCheckRequests.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1534,7 +1534,8 @@ class GlobalActorAttributeRequest
15341534
class ActorIsolationRequest :
15351535
public SimpleRequest<ActorIsolationRequest,
15361536
ActorIsolation(ValueDecl *),
1537-
RequestFlags::Cached> {
1537+
RequestFlags::SeparatelyCached |
1538+
RequestFlags::SplitCached> {
15381539
public:
15391540
using SimpleRequest::SimpleRequest;
15401541

@@ -1544,8 +1545,10 @@ class ActorIsolationRequest :
15441545
ActorIsolation evaluate(Evaluator &evaluator, ValueDecl *value) const;
15451546

15461547
public:
1547-
// Caching
1548+
// Separate.
15481549
bool isCached() const { return true; }
1550+
std::optional<ActorIsolation> getCachedResult() const;
1551+
void cacheResult(ActorIsolation value) const;
15491552
};
15501553

15511554
/// Determine whether the given function should have an isolated 'self'.

include/swift/AST/TypeCheckerTypeIDZone.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ SWIFT_REQUEST(TypeChecker, GlobalActorAttributeRequest,
177177
SeparatelyCached | SplitCached, NoLocationInfo)
178178
SWIFT_REQUEST(TypeChecker, ActorIsolationRequest,
179179
ActorIsolationState(ValueDecl *),
180-
Cached, NoLocationInfo)
180+
SeparatelyCached | SplitCached, NoLocationInfo)
181181
SWIFT_REQUEST(TypeChecker, HasIsolatedSelfRequest,
182182
bool(ValueDecl *),
183183
Uncached, NoLocationInfo)

lib/AST/TypeCheckRequests.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1943,6 +1943,28 @@ GlobalActorAttributeRequest::cacheResult(std::optional<CustomAttrNominalPair> va
19431943
}
19441944
}
19451945

1946+
//----------------------------------------------------------------------------//
1947+
// ActorIsolationRequest computation.
1948+
//----------------------------------------------------------------------------//
1949+
1950+
std::optional<ActorIsolation> ActorIsolationRequest::getCachedResult() const {
1951+
auto *decl = std::get<0>(getStorage());
1952+
if (decl->LazySemanticInfo.noActorIsolation)
1953+
return ActorIsolation::forUnspecified();
1954+
1955+
return decl->getASTContext().evaluator.getCachedNonEmptyOutput(*this);
1956+
}
1957+
1958+
void ActorIsolationRequest::cacheResult(ActorIsolation value) const {
1959+
auto *decl = std::get<0>(getStorage());
1960+
if (value.isUnspecified()) {
1961+
decl->LazySemanticInfo.noActorIsolation = 1;
1962+
return;
1963+
}
1964+
1965+
decl->getASTContext().evaluator.cacheNonEmptyOutput(*this, std::move(value));
1966+
}
1967+
19461968
//----------------------------------------------------------------------------//
19471969
// ResolveMacroRequest computation.
19481970
//----------------------------------------------------------------------------//

0 commit comments

Comments
 (0)