-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[SILGen] Optimize generated dealloc for linearly recursive data struc… #41459
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
…tures Adds detection of linearly recursive data structures by finding stored properties that share the type of the class the dealloc is being generated for. Each link will then be deallocated in a loop, while ensuring to keep the next link alive to prevent the recursion. This prevents stack overflows for long chains while also improving performance. rdar://89162954
@swift-ci smoke test |
Nice! Do you have any tests? |
@swift-ci smoke test macos |
Working on it! |
a7b3d61
to
6c69b9a
Compare
6c69b9a
to
c858ced
Compare
@swift-ci smoke test |
0280334
to
aab8413
Compare
@swift-ci test |
@jckarter Added some tests. |
aab8413
to
550f38b
Compare
@swift-ci test |
@swift-ci test |
@swift-ci test |
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.
I'm in favor of this approach. I'm unfamiliar with the surrounding SILGen. It would be nice to have @slavapestov or @jckarter check the type-system aspects.
I made several comments about implementation details. Mainly wondering why we need to generate extra copies in SILGen.
@swift-ci test |
@swift-ci test macos |
c0c4997
to
dc013ea
Compare
@gottesmm Thanks, addressed all your comments! |
@swift-ci test |
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.
A few more comment changes then LGTM. Can you fix those and then feel free to merge. Thanks!
lib/SILGen/SILGenDestructor.cpp
Outdated
// recursively the same type as `self`, so we can iteratively | ||
// deinitialize them, to prevent deep recursion and potential | ||
// stack overflows. | ||
llvm::SmallSetVector<VarDecl*, 4> recursiveLinks; |
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.
Another instance showing git-clang-format missing. Can you git-clang-format 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.
git-clang-format
appears to accept this as is, as well as with added whitespace. It also accepts Type* variable;
and Type *variable;
. I'm happy to change this manually, but maybe the formatting rules have to be adjusted?
dc013ea
to
ba0de89
Compare
@swift-ci please test and merge |
@swift-ci test Linux |
@swift-ci test linux |
@swift-ci smoke test |
@swift-ci smoke test linux |
@swift-ci smoke test |
…tures
Adds detection of linearly recursive data structures by finding stored properties that share the type of the class the dealloc is being generated for. Each link will then be deallocated in a loop, while ensuring to keep the next link alive to prevent the recursion. This prevents stack overflows for long chains while also improving performance.
rdar://89162954