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

Queryify Vtable methods #45137

Merged
merged 5 commits into from
Oct 14, 2017
Merged

Conversation

theotherjimmy
Copy link
Contributor

This query might come with a downside: It converts an iterator to a Vec, which may increase the working set of rustc on programs that use many many traits (I think that's where this is used).

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @nikomatsakis (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

Copy link
Contributor

@nikomatsakis nikomatsakis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Left a few minor suggestions.

@@ -227,6 +227,8 @@ define_maps! { <'tcx>
[] fn item_body_nested_bodies: ItemBodyNestedBodies(DefId) -> ExternBodyNestedBodies,
[] fn const_is_rvalue_promotable_to_static: ConstIsRvaluePromotableToStatic(DefId) -> bool,
[] fn is_mir_available: IsMirAvailable(DefId) -> bool,
[] fn vtable_methods: vtable_methods_node(ty::PolyTraitRef<'tcx>)
-> Vec<Option<(DefId, &'tcx Substs<'tcx>)>>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Returning Rc<Vec<Option<..>>> would be better.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right! I had that change before, I should re-apply that patch.

@@ -650,12 +650,12 @@ pub fn normalize_and_test_predicates<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
/// Given a trait `trait_ref`, iterates the vtable entries
/// that come from `trait_ref`, including its supertraits.
#[inline] // FIXME(#35870) Avoid closures being unexported due to impl Trait.
pub fn get_vtable_methods<'a, 'tcx>(
pub fn vtable_methods<'a, 'tcx>(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This need not be public anymore.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤦‍ Yep, Another one that I'll do real quick.

@theotherjimmy
Copy link
Contributor Author

@nikomatsakis Thanks for the review. I corrected all of the minor suggestions.

@nikomatsakis
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Oct 9, 2017

📌 Commit cb7e101 has been approved by nikomatsakis

@bors
Copy link
Contributor

bors commented Oct 11, 2017

⌛ Testing commit cb7e1016e48ca77277d82d427971c0988ccda497 with merge e66fd14c879d45c57f5c293e922a72de6b666a0d...

@bors
Copy link
Contributor

bors commented Oct 11, 2017

💔 Test failed - status-travis

@theotherjimmy
Copy link
Contributor Author

I don't think this is my fault:

Failed to fetch URL https://dl.google.com/android/repository/addons_list-2.xml, reason: peer not authenticated

@kennytm
Copy link
Member

kennytm commented Oct 11, 2017

@bors retry

@bors
Copy link
Contributor

bors commented Oct 12, 2017

☔ The latest upstream changes (presumably #44967) made this pull request unmergeable. Please resolve the merge conflicts.

@aidanhs
Copy link
Member

aidanhs commented Oct 12, 2017

@bors r=nikomatsakis

@bors
Copy link
Contributor

bors commented Oct 12, 2017

📌 Commit 09258e7 has been approved by nikomatsakis

@aidanhs aidanhs added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Oct 12, 2017
@aidanhs
Copy link
Member

aidanhs commented Oct 12, 2017

Wait @bors r-

[00:08:12] �[1m�[31merror�(B�[m�[1m: recursion limit reached while expanding the macro `stringify`�(B�[m
[00:08:12]    �(B�[m�[1m�[34m--> �(B�[m/checkout/src/librustc/ty/maps/plumbing.rs:563:26�(B�[m
[00:08:12]     �(B�[m�[1m�[34m|�(B�[m
[00:08:12] �[1m�[34m563�(B�[m �(B�[m�[1m�[34m| �(B�[m  �(B�[m                         stringify!($name), key);�(B�[m
[00:08:12]     �(B�[m�[1m�[34m| �(B�[m                           �(B�[m�[1m�[31m^^^^^^^^^^^^^^^^^�(B�[m
[00:08:12]     �(B�[m�[1m�[34m| �(B�[m
[00:08:12]    �(B�[m�[1m�[34m::: �(B�[m/checkout/src/librustc/ty/maps/mod.rs�(B�[m
[00:08:12]     �(B�[m�[1m�[34m|�(B�[m
[00:08:12] �[1m�[34m78�(B�[m  �(B�[m�[1m�[34m| �(B�[m�[1m�[34m/�(B�[m �(B�[mdefine_maps! { <'tcx>�(B�[m
[00:08:12] �[1m�[34m79�(B�[m  �(B�[m�[1m�[34m| �(B�[m�[1m�[34m|�(B�[m �(B�[m    /// Records the type of every item.�(B�[m
[00:08:12] �[1m�[34m80�(B�[m  �(B�[m�[1m�[34m| �(B�[m�[1m�[34m|�(B�[m �(B�[m    [] fn type_of: TypeOfItem(DefId) -> Ty<'tcx>,�(B�[m
[00:08:12] �[1m�[34m81�(B�[m  �(B�[m�[1m�[34m| �(B�[m�[1m�[34m|�(B�[m
[00:08:12] �[1m�[34m...�(B�[m   �(B�[m�[1m�[34m|�(B�[m
[00:08:12] �[1m�[34m341�(B�[m �(B�[m�[1m�[34m| �(B�[m�[1m�[34m|�(B�[m �(B�[m    [] fn has_clone_closures: HasCloneClosures(CrateNum) -> bool,�(B�[m
[00:08:12] �[1m�[34m342�(B�[m �(B�[m�[1m�[34m| �(B�[m�[1m�[34m|�(B�[m �(B�[m}�(B�[m
[00:08:12]     �(B�[m�[1m�[34m| �(B�[m�[1m�[34m|_-�(B�[m �(B�[m�[1m�[34min this macro invocation�(B�[m
[00:08:12]     �(B�[m�[1m�[34m|�(B�[m
[00:08:12]     �(B�[m�[1m�[34m= �(B�[m�[1mhelp�(B�[m: consider adding a `#![recursion_limit="512"]` attribute to your crate�(B�[m
[00:08:12] 
[00:08:12] �[m�[m�[31m�[1merror:�[m Could not compile `rustc`.

@theotherjimmy
Copy link
Contributor Author

Well, the good is that I can reproduce the problem. The bad is that I have no idea why it's happening.

@theotherjimmy
Copy link
Contributor Author

theotherjimmy commented Oct 12, 2017

It seems like the macro that implements the provider structure, define_provider_struct!, was using some pretty heavy recursion to move data around. I'm working on a direct version of that macro now.

@theotherjimmy
Copy link
Contributor Author

@nikomatsakis @michaelwoerister This change set now includes a big change to plumbing.rs, which should be scrutinized.

@kennytm kennytm added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Oct 13, 2017
(tcx: $tcx:tt,
input: (),
output: ($(([$name:ident] [$K:ty] [$R:ty]))*)) => {
input: ($(([$($modifiers:tt)*] [$name:ident] [$K:ty] [$R:ty]))*)) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change looks fine. It does mean we lose the ability to have modifiers that adjust the type of a query's field. At present, we are not using this capability (we used to be...), so that's probably ok, but we could also just lift the recursion-limit, right?

I'm ok either way, but let's also rebase and remove the merge commit.

@theotherjimmy
Copy link
Contributor Author

Rebasing. Just a moment.

@theotherjimmy
Copy link
Contributor Author

@nikomatsakis rebase complete. Merge commit removed.

@nikomatsakis
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Oct 13, 2017

📌 Commit fcb8bc9 has been approved by nikomatsakis

@kennytm kennytm added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 13, 2017
@bors
Copy link
Contributor

bors commented Oct 14, 2017

⌛ Testing commit fcb8bc9 with merge 3037965...

bors added a commit that referenced this pull request Oct 14, 2017
…akis

Queryify Vtable methods

This query might come with a downside: It converts an iterator to a Vec, which may increase the working set of rustc on programs that use many many traits (I think that's where this is used).
@bors
Copy link
Contributor

bors commented Oct 14, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: nikomatsakis
Pushing 3037965 to master...

@michaelwoerister
Copy link
Member

🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants