Skip to content
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

refactoring: Kill ref cycle in librustc trans #21024

Closed

Conversation

pnkfelix
Copy link
Member

This is the first commit from #21022, pulled out into a separate PR to ease future rebasing pain.

This is a semantics-preserving refactoring of the existing code. It removes a cyclic structure from librustc_trans, so that the BlockS structures no longer carry a reference to the FunctionContext.

@rust-highfive
Copy link
Contributor

r? @eddyb

(rust_highfive has picked a reviewer for you, use r? to override)

@eddyb
Copy link
Member

eddyb commented Jan 12, 2015

This makes me sad - the old design has served as well.
This could be karma for 'tcx, who knows.

Namely, `BlockS` used to carry an `fcx: &'blk FunctionContext`, while
the `FunctionContext` carries a reference to the arena that holds the
blocks.

This creates a chicken/egg problem where we are attempting to assign
the lifetime `'blk` to both the `FunctionContext` and to the arena's
blocks, which does not work under the new lifetime rules for `Drop`,
since there has to be some order in which the two are torn down.

To resolve this, I removed the `fcx` from the `BlockS`, and instead
turn the `Block` type (which was formerly `&'blk BlockS`) into a struct
carrying both the pointer to the `BlockS` as well as the `fcx`.
@pnkfelix pnkfelix force-pushed the kill-ref-cycle-in-librustc_trans branch from 7cae921 to ac01b56 Compare January 20, 2015 14:41
@pnkfelix
Copy link
Member Author

@bors: r=nikomatsakis ac01b56

@pnkfelix
Copy link
Member Author

@bors: r-

(holding off on merging this -- I want to check a few things on my local branch before committing to this refactoring.)

@pnkfelix pnkfelix assigned pnkfelix and unassigned eddyb Jan 20, 2015
@pnkfelix
Copy link
Member Author

@eddyb you'll be happy to know that I just found a couple of changes and/or tricks that make this particular refactoring unnecessary. Closing without merge.

@pnkfelix pnkfelix closed this Jan 22, 2015
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.

3 participants