-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[TypeChecker] Implement distributed computed properties #59481
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
Conversation
Okey so I made the tests pass but... We're missing the info that "this was a distributed thunk" and I'm sorry but I forgot what we agreed upon -- are we doing the new attribute to mark those? It would honestly be the simplest solution and also useful to inspect those ASTs then, and we might need it for the avoiding double-synthesis anyway, right @xedin? In any case this will now pass, and let's follow up fixing the FIXME's in 1178f62 by introducing an attr or what other idea you had there 👍 |
@swift-ci please test |
if (auto *FD = dyn_cast<FuncDecl>(decl)) { | ||
thunkDecl = FD->getDistributedThunk(); | ||
} else { | ||
thunkDecl = cast<VarDecl>(decl)->getDistributedThunk(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe
thunkDecl = cast<VarDecl>(decl)->getDistributedThunk(); | |
} else if (let var cast<VarDecl>(decl)) { | |
thunkDecl = var->getDistributedThunk(); | |
} else llvm_unreachable... |
? Just in case I guess...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The validity is checked by requiresDistributedThunk
so I don't really see a reason to double-check here, if anything cast is going to fail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha, thanks!
declRefExpr->setFunctionRefKind(choice.getFunctionRefKind()); | ||
declRefExpr->setType(thunkType); | ||
|
||
cs.cacheType(declRefExpr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh that's new to me, why do we do this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you talking about cacheType
specifically? That's used to let finishApply
know what the type was for the newly created node, since all the expressions involved in solving should have their types cached.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that -- I see, thanks :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, looking awesome.
The only follow up is that I forgot what we agreed to do about the thunks (too little sleep -_-) -- I'd be ok with the attribute to detect them, but do we want to do something else?
Yes, that's is correct. |
1178f62
to
b45f39a
Compare
The underlying mechanism has changed so the flag is no longer required.
31ca982
to
88db8a7
Compare
@ktoso Tests have been fixed and new attributed simplified checking some what as well, so the changes are complete now. |
@swift-ci please test |
88db8a7
to
3fce990
Compare
39bc076
to
df10d4c
Compare
@swift-ci please test |
Replace distributed member references with distributed thunks when access happens outside of distributed actor context. This significantly simplifies distributed compute properties implementation.
…le we work on getting them back
…utedThunk` Since the thunk is applied to expression during solution application, the use of this flag has shifted towards stating the fact.
…eter/capture base If distributed memeber is referenced on a base that represents a result of some expression which is not a variable, parameter, or a capture it should always be dispatched via a thunk.
…y check All the heavy lifting of checking whether reference throws and requires dispatch through a thunk is done during type-checking, so all `checkDistributedAccess` needs to do is determine whether access is distributed or not.
The attribute comes handy during solution application to determine whether the call is using a distributed thunk.
df10d4c
to
fa2e64c
Compare
@swift-ci please test |
Awesomeness, thank you Pavel :-) |
// let's mark the call as implicitly throwing/async. | ||
if (isa<SelfApplyExpr>(apply->getFn())) { | ||
auto *FD = dyn_cast<FuncDecl>(callee.getDecl()); | ||
if (FD && FD->isDistributedThunk()) { | ||
apply->setImplicitlyThrows(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is very nice and simple now, came togeher nicely :)
I'll pick it over to 5.7 |
@@ -7781,6 +7781,10 @@ bool AbstractFunctionDecl::isSendable() const { | |||
return getAttrs().hasAttribute<SendableAttr>(); | |||
} | |||
|
|||
bool AbstractFunctionDecl::isNonisolated() const { | |||
return getAttrs().hasAttribute<NonisolatedAttr>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't a semantic definition of "nonisolated" (one should check getActorIsolation
instead), so I'd prefer that we not have this function. Fortunately, it's unused, so we should remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I see, cool will remove 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Distributed] Revert "#59481 distributed-computed-properties"
🍒[5.7][Distributed] Revert "#59481 distributed-computed-properties"
Add support for parsing
distributed var <name> : <type> { ... }
declarations andtype-checking them by injecting distributed thunks during Sema.
Resolves rdar://91283164