-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Distributed] Implement whenLocal properly #59598
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4829,6 +4829,9 @@ class AbstractStorageDecl : public ValueDecl { | |
} | ||
bool isCompileTimeConst() const; | ||
|
||
/// Is a reference to a distributed actor that is "known to be local". | ||
bool isDistributedKnownToBeLocal() const; | ||
|
||
/// \returns the way 'static'/'class' should be spelled for this declaration. | ||
StaticSpellingKind getCorrectStaticSpelling() const; | ||
|
||
|
@@ -5359,10 +5362,6 @@ class VarDecl : public AbstractStorageDecl { | |
/// 'distributed' and and nullptr otherwise. | ||
FuncDecl *getDistributedThunk() const; | ||
|
||
/// Is this var known to be a "local" distributed actor, | ||
/// if so the implicit throwing ans some isolation checks can be skipped. | ||
bool isKnownToBeLocal() const; | ||
|
||
/// Is this a stored property that will _not_ trigger any user-defined code | ||
/// upon any kind of access? | ||
bool isOrdinaryStoredProperty() const; | ||
|
@@ -5635,9 +5634,13 @@ class ParamDecl : public VarDecl { | |
|
||
/// Whether or not this parameter is '_const'. | ||
IsCompileTimeConst = 1 << 1, | ||
|
||
// FIXME: it's not on the name but on the type | ||
/// Whether or not this parameter is a '_local DistributedActor' reference. | ||
IsDistributedKnownToBeLocal = 1 << 2, | ||
}; | ||
|
||
llvm::PointerIntPair<Identifier, 2, OptionSet<ArgumentNameFlags>> | ||
llvm::PointerIntPair<Identifier, 3, OptionSet<ArgumentNameFlags>> | ||
ArgumentNameAndFlags; | ||
SourceLoc ParameterNameLoc; | ||
SourceLoc ArgumentNameLoc; | ||
|
@@ -5878,6 +5881,21 @@ class ParamDecl : public VarDecl { | |
: flags - Flags::IsIsolated); | ||
} | ||
|
||
/// Whether or not this parameter is marked with 'isolated'. | ||
bool isDistributedKnownToBeLocal() const { | ||
return ArgumentNameAndFlags.getInt().contains(ArgumentNameFlags::IsDistributedKnownToBeLocal); | ||
} | ||
|
||
void setDistributedKnownToBeLocal(bool value = true) { | ||
auto flags = ArgumentNameAndFlags.getInt(); | ||
if (value && !getAttrs().hasAttribute<DistributedKnownToBeLocalAttr>()) { | ||
getAttrs().add(new (getASTContext()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You shouldn't need to add an attribute here, and please don't because it's an additional unnecessary mutation on the AST. Nobody should be looking at the attribute except code that validates it when present, and sets this flag when needed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right, thank you! |
||
DistributedKnownToBeLocalAttr(/*isImplicit=*/true)); | ||
} | ||
ArgumentNameAndFlags.setInt(value ? flags | ArgumentNameFlags::IsDistributedKnownToBeLocal | ||
: flags - ArgumentNameFlags::IsDistributedKnownToBeLocal); | ||
} | ||
|
||
/// Whether or not this parameter is marked with '_const'. | ||
bool isCompileTimeConst() const { | ||
return ArgumentNameAndFlags.getInt().contains( | ||
|
Uh oh!
There was an error while loading. Please reload this page.