Skip to content

Re-implement NominalTypeDecl::getStoredProperties() using request evaluator #26119

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

Merged
merged 4 commits into from
Jul 17, 2019

Conversation

slavapestov
Copy link
Contributor

Also, continue refactoring accessor synthesis, finalizeDecl(), and related code.

@slavapestov
Copy link
Contributor Author

@swift-ci Please test

@slavapestov
Copy link
Contributor Author

@swift-ci Please test source compatibility

@slavapestov slavapestov requested review from DougGregor and xymus July 12, 2019 20:05
@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 2c43e216c61f1f3f48e2bc0e032a82218ab5ef35

Copy link
Member

@DougGregor DougGregor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cooooool


return name.str().startswith("$__lazy_storage_$_");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahhhh, thank you!

for (auto I = Range.begin(), E = Range.end(); I != E; ++I, ++Index) {
VarDecl *VD = *I;
const Operand &Op = Operands[Index];
for (unsigned I = 0, E = Props.size(); I < E; ++I) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You know you can write

for (unsigned I : indices(Props))

and we'll all think you're cool

for (auto *varDecl : target->getStoredProperties(/*skipInaccessible=*/true)) {
if (varDecl->getAttrs().hasAttribute<LazyAttr>())
for (auto *varDecl : target->getStoredProperties()) {
if (!varDecl->isUserAccessible())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. isUserAccessible() makes sense here, but it's a notion I'd kinda rather throw away at some point. I'm glad it's been pushed down into the clients, since it's a step forward.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it might be nice to define it directly at some point (right now I think the only decls with this bit set are backing storage for lazy and wrappers).

isInvalid() is another silly one too that we should replace with something derived from the other properties of the decl.

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 2c43e216c61f1f3f48e2bc0e032a82218ab5ef35

@slavapestov
Copy link
Contributor Author

@swift-ci Please test

@slavapestov
Copy link
Contributor Author

@swift-ci Please test source compatibility

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 2c43e216c61f1f3f48e2bc0e032a82218ab5ef35

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 2c43e216c61f1f3f48e2bc0e032a82218ab5ef35

@slavapestov
Copy link
Contributor Author

@swift-ci Please test

@slavapestov
Copy link
Contributor Author

@swift-ci Please test source compatibility

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 2c43e216c61f1f3f48e2bc0e032a82218ab5ef35

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 2c43e216c61f1f3f48e2bc0e032a82218ab5ef35

@slavapestov slavapestov force-pushed the stored-properties-request branch from 2c43e21 to 78a8f50 Compare July 15, 2019 21:51
@slavapestov
Copy link
Contributor Author

@swift-ci Please test

@slavapestov
Copy link
Contributor Author

@swift-ci Please test source compatibility

@slavapestov
Copy link
Contributor Author

@swift-ci Please test compiler performance

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 2c43e216c61f1f3f48e2bc0e032a82218ab5ef35

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 2c43e216c61f1f3f48e2bc0e032a82218ab5ef35

The test case crashes because we synthesize the body before validating
the function itself. I'm going to add a resolveDeclSignature() call
as well to avoid this.
This improves on the previous situation:

- The request ensures that the backing storage for lazy properties
  and property wrappers gets synthesized first; previously it was
  only somewhat guaranteed by callers.

- Instead of returning a range this just returns an ArrayRef,
  which simplifies clients.

- Indexing into the ArrayRef is O(1), which addresses some FIXMEs
  in the SIL optimizer.
Continue gutting finalizeType() by using our new request to
synthesize the backing storage for lazy properties and
property wrappers.
@slavapestov slavapestov force-pushed the stored-properties-request branch from 78a8f50 to d0240cc Compare July 16, 2019 20:39
@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

@slavapestov
Copy link
Contributor Author

@swift-ci Please test source compatibility

@slavapestov
Copy link
Contributor Author

@swift-ci Please test compiler performance

@slavapestov slavapestov merged commit 56515ee into swiftlang:master Jul 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants