Skip to content

End lifetime and deallocating deinits #7858

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

Conversation

gottesmm
Copy link
Contributor

@gottesmm gottesmm commented Mar 2, 2017

This PR contains two commits:

  1. b4923b2. This commit adds a new SIL instruction called end_lifetime. It is the destroying use equivalent of fix_lifetime. Its intent is to enable SILGen to in certain cases lie about ownership to the verifier to fix some corner cases. It is eliminated when the ownership model eliminator runs.

  2. 0e89d6e. This uses end_lifetime to special case the lifetime of self in destructors. Specifically:

    a. Self is passed into deallocating deinits at +1.
    b. Destroying deinits take in self as a +0 value that is then returned at +1.

    This means that the lifetime of self can not be modeled statically in a
    deallocating deinit without analyzing the body of the destroying deinit
    (something that violates semantic sil). Thus we add an artifical destroy of
    self before the actual destroy of self so that the verifier can understand
    that self is being properly balanced.

rdar://29791263

@gottesmm
Copy link
Contributor Author

gottesmm commented Mar 2, 2017

@swift-ci Please smoke test and merge

gottesmm added 2 commits March 1, 2017 18:30
This is the lifetime ending variant of fix_lifetime. It is a lie to the
ownership verifier that a value is being consumed along a path. Its intention is
to be used to allow for the static verification of ownership in deallocating
deinits which for compatibility with objective-c have weird ownership behavior.
See the commit merged with this commit for more information.
…inits using end_lifetime.

The issue here is that:

1. Self is passed into deallocating deinits at +1.
2. Destroying deinits take in self as a +0 value that is then returned at +1.

This means that the lifetime of self can not be modeled statically in a
deallocating deinit without analyzing the body of the destroying deinit
(something that violates semantic sil). Thus we add an artifical destroy of
self before the actual destroy of self so that the verifier can understand
that self is being properly balanced.

rdar://29791263
@gottesmm gottesmm force-pushed the end_lifetime_and_deallocating_deinits branch from 0e89d6e to f92693a Compare March 2, 2017 02:30
@gottesmm
Copy link
Contributor Author

gottesmm commented Mar 2, 2017

@swift-ci Please smoke test and merge

1 similar comment
@gottesmm
Copy link
Contributor Author

gottesmm commented Mar 2, 2017

@swift-ci Please smoke test and merge

@swift-ci swift-ci merged commit cbcea38 into swiftlang:master Mar 2, 2017
@gottesmm gottesmm deleted the end_lifetime_and_deallocating_deinits branch March 2, 2017 03:02
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.

2 participants