Skip to content

Finish rewriting TLS #7751

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

Closed
wants to merge 4 commits into from
Closed

Conversation

alexcrichton
Copy link
Member

This changes the interface to get, and it also changes the keys to be static slices instead of static functions.

This allows the removal of the unsafe interface because while functions can monomorphize from different types to the same actual function, static slices cannot do this.

From at least what I can tell, we don't need to worry about LLVM coalescing these addresses. If we ever use the unnamed_addr it looks like there's cause for worry, but there doesn't appear to be any coalescing atm.

@huonw
Copy link
Member

huonw commented Jul 13, 2013

The non-uppercase statics lint is on by default because of #7526, and it looks like you've removed the warnings about @mut borrows being extended by rewriting find_insert as find ... insert; I believe that those warnings are harmless, so making the code slower just to avoid them would seem to be bad.

@alexcrichton
Copy link
Member Author

@huonw, I don't think that we should dictate the style of statics by default. Solving #7526 doesn't involve dictating what all programs should look like, but rather a more informative error message (if any).

Also you're right that it's "faster" by using find_or_insert rather than find and then insert, the lint is far more annoying than the few nanoseconds that this is going to add to the compilation time. If this does end up hitting perf, I'll revert it and just live with the lint for now.

@huonw
Copy link
Member

huonw commented Jul 13, 2013

Yes, warn by default is purely until that issue is properly resolved.

@alexcrichton
Copy link
Member Author

r? @bblum on the last commit?

You initially had the idea of using a vector as the TLS key values, although apparently 0-sized globals all get allocated to the same location on linux (from a linker perspective, nothing to do with LLVM). I just wanted to make sure that this idea is ok with you as well.

I think of this as a stylistic opinion which shouldn't necessarily be enforced
by default on all users of rust, but that's just my opinion.
If the TLS key is 0-sized, then the linux linker is apparently smart enough to
put everything at the same pointer. OSX on the other hand, will reserve some
space for all of them. To get around this, the TLS key now actuall consumes
space to ensure that it gets a unique pointer
bors added a commit that referenced this pull request Jul 14, 2013
This changes the interface to `get`, and it also changes the keys to be static slices instead of static functions.

This allows the removal of the `unsafe` interface because while functions can monomorphize from different types to the same actual function, static slices cannot do this.

From at least what I can tell, we don't need to worry about LLVM coalescing these addresses. If we ever use the `unnamed_addr` it looks like there's cause for worry, but there doesn't appear to be any coalescing atm.
@bors bors closed this Jul 14, 2013
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