Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upstore ADT information in an AdtDef structure in a unified way #27551
Conversation
rust-highfive
assigned
nikomatsakis
Aug 5, 2015
eefriedman
reviewed
Aug 6, 2015
| @@ -170,7 +170,6 @@ RUST_LIB_FLAGS_ST3 += -C prefer-dynamic | |||
|
|
|||
| # Landing pads require a lot of codegen. We can get through bootstrapping faster | |||
| # by not emitting them. | |||
| RUSTFLAGS_STAGE0 += -Z no-landing-pads | |||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
arielb1
force-pushed the
arielb1:adt-def
branch
from
cfd5878
to
5f0f53f
Aug 6, 2015
This comment has been minimized.
This comment has been minimized.
|
passes check locally |
added some commits
Jul 20, 2015
arielb1
force-pushed the
arielb1:adt-def
branch
from
5f0f53f
to
99c6bfd
Aug 6, 2015
arielb1
force-pushed the
arielb1:adt-def
branch
from
99c6bfd
to
c533f96
Aug 6, 2015
arielb1
force-pushed the
arielb1:adt-def
branch
from
b478196
to
1902973
Aug 6, 2015
arielb1
force-pushed the
arielb1:adt-def
branch
from
1902973
to
0153001
Aug 6, 2015
arielb1
changed the title
[WIP] store ADT information in an ADTDef structure in a unified way
store ADT information in an ADTDef structure in a unified way
Aug 6, 2015
This comment has been minimized.
This comment has been minimized.
nikomatsakis
commented on src/librustc_data_structures/ivar.rs in 03ee3f5
Aug 6, 2015
|
Why require that |
This comment has been minimized.
This comment has been minimized.
nikomatsakis
replied
Aug 6, 2015
|
If that is the case, we should add a comment justifying the |
This comment has been minimized.
This comment has been minimized.
|
Because |
This comment has been minimized.
This comment has been minimized.
nikomatsakis
commented on src/librustc/middle/traits/coherence.rs in 764310e
Aug 6, 2015
|
nit: move |
This comment has been minimized.
This comment has been minimized.
nikomatsakis
commented on src/librustc/middle/ty.rs in 764310e
Aug 6, 2015
|
In general, these flags could use comments, but definitely |
This comment has been minimized.
This comment has been minimized.
nikomatsakis
commented on src/librustc/middle/ty.rs in 764310e
Aug 6, 2015
|
Nit: I think Rust's precedent is to treat acronyms like other words. I'm sure we're inconsistent here and there, but Less nit: Writing |
This comment has been minimized.
This comment has been minimized.
nikomatsakis
commented on src/librustc/middle/ty.rs in 764310e
Aug 6, 2015
|
(a new type feels right to me because this constraint is more naturally enforced as part of the newtype, which signals "an interned AdtDefData") |
This comment has been minimized.
This comment has been minimized.
|
it is not like there are any non-interned |
This comment has been minimized.
This comment has been minimized.
|
The constructor is private, so you can't create them. It may be better to make the un-primed |
This comment has been minimized.
This comment has been minimized.
nikomatsakis
replied
Aug 6, 2015
right, seems fine. maybe just put that in the comment. |
This comment has been minimized.
This comment has been minimized.
|
When reverse-variance goes away this should be split into an |
This comment has been minimized.
This comment has been minimized.
nikomatsakis
replied
Aug 6, 2015
|
Interesting. It might be worth retaining some sort of type that enables reverse-variance, but then again i'm not sure it carries its weight here. In particular we could also have an (unsafely implemented) method that downgrades from "write" to "read-only". |
This comment has been minimized.
This comment has been minimized.
|
That's what I meant by "hand-variancing". I guess I will split the methods anyway. |
This comment has been minimized.
This comment has been minimized.
nikomatsakis
commented on src/librustc/middle/ty.rs in 213b6d7
Aug 6, 2015
|
is this sentence incomplete? it'd be nice to have some documentation of where it is important to have variance here |
This comment has been minimized.
This comment has been minimized.
|
merge damage I imagine |
This comment has been minimized.
This comment has been minimized.
nikomatsakis
commented on src/librustc/middle/ty.rs in 213b6d7
Aug 6, 2015
|
If the major problem here is that we want OTOH, the trick you've worked out here is pretty clever. It does seem like it's nice to be able to have a "read-only" alias that is variant, and I guess that the lifetime games you are playing here make that possible. /me ponders |
This comment has been minimized.
This comment has been minimized.
nikomatsakis
replied
Aug 6, 2015
|
OK, having reconsidered, I think this is a cool pattern you've got here, but we perhaps just need a clearer elucidation of what it's aiming to do, along with some nicer type aliases. For example: /// A read-only reference to an ADT definition. References
/// of this type can query the state of an ivar, but not mutate it.
type AdtDef<'tcx> = &'tcx AdtDefData<'tcx, 'static>;
/// A mutable reference to an ADT definition. This is what we
/// store in the tcx tables. In particular, this form
/// permits the IVars to be fulfilled. Note that, unlike with
/// `&mut` references, there may be extant read-only aliases
/// when the ivar is fulfilled.
type AdtDefMut<'tcx> = &'tcx AdtDefData<'tcx, 'tcx>; |
This comment has been minimized.
This comment has been minimized.
|
Having |
This comment has been minimized.
This comment has been minimized.
nikomatsakis
commented on src/librustc/middle/ty.rs in 213b6d7
Aug 6, 2015
|
I feel like we should find a more meaningful name than |
This comment has been minimized.
This comment has been minimized.
nikomatsakis
replied
Aug 6, 2015
|
Also I'd prefer a name like |
This comment has been minimized.
This comment has been minimized.
|
ADTDef/ADTDef_ was the variance distinction. I guess I could go AdtDefData/AdtDef. Maybe call the lifetime `'owner' - this is essentially about preventing types from a child tcx from leaking into the parent tcx. |
This comment has been minimized.
This comment has been minimized.
nikomatsakis
commented on src/librustc/metadata/decoder.rs in 4816e60
Aug 6, 2015
|
nit: can you replace skip_binder with a call to |
This comment has been minimized.
This comment has been minimized.
|
I copied somewhere that did |
This comment has been minimized.
This comment has been minimized.
nikomatsakis
commented on src/librustc/middle/ty.rs in 4816e60
Aug 6, 2015
|
nice, I'm usually too lazy and just return a Vec :) |
This comment has been minimized.
This comment has been minimized.
nikomatsakis
commented on 612760b
Aug 6, 2015
|
the commit message here suggests that changing how we issue this note causes a 2.5% perf improvement. How is that possible, given that this code only executes in error cases? What are you testing? |
This comment has been minimized.
This comment has been minimized.
|
that's for the entire patchset up to this point (I wanted to separate it from |
This comment has been minimized.
This comment has been minimized.
nikomatsakis
commented on src/librustc/middle/ty.rs in 764310e
Aug 6, 2015
|
It'd be nice to move this code out of this file and (ideally) into dropck. Perhaps just have the code that uses the "is_dtorck" flag stuff elsewhere. Or maintain the flag a bit differently. Or use some external sets. I don't know. Not a huge thing, but I do feel like this kind of random code is best kept with the code that is consuming it (in general |
This comment has been minimized.
This comment has been minimized.
nikomatsakis
replied
Aug 6, 2015
|
I guess though that under RFC rust-lang/rfcs#1238 this just becomes an attribute check anyhow. |
This comment has been minimized.
This comment has been minimized.
|
dropck was somewhat an hotspot on my profile. We really should split up |
This comment has been minimized.
This comment has been minimized.
nikomatsakis
commented on src/librustc/middle/ty.rs in 764310e
Aug 6, 2015
|
eventually, this "destructor_for_type" thing should go into |
This comment has been minimized.
This comment has been minimized.
nikomatsakis
replied
Aug 6, 2015
|
to clarify: not necessarily as part of this PR |
This comment has been minimized.
This comment has been minimized.
|
Right. This PR is already somewhat too big to my taste. |
This comment has been minimized.
This comment has been minimized.
|
NOTE: this is commented to prevent duplicate error messages, and is uncommented in a later commit. |
This comment has been minimized.
This comment has been minimized.
|
Awesome, I'm glad somebody did this. The performance increase is consistent with what I saw with my version of this change. Hopefully this should also make working with ADTs easier going forward, at the very least it's much more obvious. |
nikomatsakis
referenced this pull request
Aug 7, 2015
Closed
derive(Copy) on tuple struct with non-Copy field uses unclear "<unnamed_field>" #27340
This comment has been minimized.
This comment has been minimized.
Oh, I can believe it, since I wrote them, but I've been migrating code to the following conventions:
|
This comment has been minimized.
This comment has been minimized.
While technically true, that's not particularly interesting, is it? The intention of these types is as I wrote them, no? I'm fine if you want to note that caveat in a comment, but I still favor names that lay clear the intent of "read-only" vs "mutable", as this is a subtle trick. |
This comment has been minimized.
This comment has been minimized.
How is this relevant? I'm talking about what module the code is in, not what it does. |
This comment has been minimized.
This comment has been minimized.
ah, ok, sounds good. |
This comment has been minimized.
This comment has been minimized.
|
cc @rust-lang/compiler <-- this PR is worth having more eyes on, incidentally |
This comment has been minimized.
This comment has been minimized.
|
OK, I've finished reading through the PR. I am happy with it, this is nice work. r+ modulo:
|
This comment has been minimized.
This comment has been minimized.
|
ps, if you prefer, perhaps the name |
added some commits
Aug 7, 2015
This comment has been minimized.
This comment has been minimized.
|
addressed |
arielb1
force-pushed the
arielb1:adt-def
branch
from
29970b6
to
eedb1cc
Aug 7, 2015
This comment has been minimized.
This comment has been minimized.
nikomatsakis
commented on src/librustc/metadata/decoder.rs in 62cd3cc
Aug 7, 2015
|
Note: this still skips the binder :) it just does so in the implicit way I would eventually like to remove altogether (by making the |
arielb1
changed the title
store ADT information in an ADTDef structure in a unified way
store ADT information in an AdtDef structure in a unified way
Aug 7, 2015
This comment has been minimized.
This comment has been minimized.
|
@bors r+ |
This comment has been minimized.
This comment has been minimized.
|
|
arielb1 commentedAug 5, 2015
This ended up being a bigger refactoring than I thought, as I also cleaned a few ugly points in rustc. There are still a few areas that need improvements.
Performance numbers:
A good 5% perf improvement. Note that after this patch >70% of the time is spent in LLVM - Amdahl's law is in full effect.
Passes make check locally.
r? @nikomatsakis