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

Conversation

Projects
None yet
7 participants
@theotherjimmy
Copy link
Contributor

theotherjimmy commented Oct 9, 2017

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

This comment has been minimized.

Copy link
Collaborator

rust-highfive commented Oct 9, 2017

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.

@nikomatsakis
Copy link
Contributor

nikomatsakis left a comment

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>)>>,

This comment has been minimized.

@nikomatsakis

nikomatsakis Oct 9, 2017

Contributor

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

This comment has been minimized.

@theotherjimmy

theotherjimmy Oct 9, 2017

Author Contributor

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>(

This comment has been minimized.

@nikomatsakis

nikomatsakis Oct 9, 2017

Contributor

This need not be public anymore.

This comment has been minimized.

@theotherjimmy

theotherjimmy Oct 9, 2017

Author Contributor

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

@theotherjimmy

This comment has been minimized.

Copy link
Contributor Author

theotherjimmy commented Oct 9, 2017

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

@theotherjimmy theotherjimmy force-pushed the theotherjimmy:vtable-methods-query branch from 6225f8a to cb7e101 Oct 9, 2017

@nikomatsakis

This comment has been minimized.

Copy link
Contributor

nikomatsakis commented Oct 9, 2017

@bors r+

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Oct 9, 2017

📌 Commit cb7e101 has been approved by nikomatsakis

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Oct 11, 2017

⌛️ Testing commit cb7e101 with merge e66fd14...

bors added a commit that referenced this pull request Oct 11, 2017

Auto merge of #45137 - theotherjimmy:vtable-methods-query, r=nikomats…
…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

This comment has been minimized.

Copy link
Contributor

bors commented Oct 11, 2017

💔 Test failed - status-travis

@theotherjimmy

This comment has been minimized.

Copy link
Contributor Author

theotherjimmy commented Oct 11, 2017

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

This comment has been minimized.

Copy link
Member

kennytm commented Oct 11, 2017

@bors retry

  • Android SDK HTTPS issue (fixed in #45193)
@bors

This comment has been minimized.

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

This comment has been minimized.

Copy link
Member

aidanhs commented Oct 12, 2017

@bors r=nikomatsakis

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Oct 12, 2017

📌 Commit 09258e7 has been approved by nikomatsakis

@aidanhs

This comment has been minimized.

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

This comment has been minimized.

Copy link
Contributor Author

theotherjimmy commented Oct 12, 2017

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

@theotherjimmy

This comment has been minimized.

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

This comment has been minimized.

Copy link
Contributor Author

theotherjimmy commented Oct 12, 2017

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

(tcx: $tcx:tt,
input: (),
output: ($(([$name:ident] [$K:ty] [$R:ty]))*)) => {
input: ($(([$($modifiers:tt)*] [$name:ident] [$K:ty] [$R:ty]))*)) => {

This comment has been minimized.

@nikomatsakis

nikomatsakis Oct 13, 2017

Contributor

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

This comment has been minimized.

Copy link
Contributor Author

theotherjimmy commented Oct 13, 2017

Rebasing. Just a moment.

@theotherjimmy theotherjimmy force-pushed the theotherjimmy:vtable-methods-query branch from 34cefbd to fcb8bc9 Oct 13, 2017

@theotherjimmy

This comment has been minimized.

Copy link
Contributor Author

theotherjimmy commented Oct 13, 2017

@nikomatsakis rebase complete. Merge commit removed.

@nikomatsakis

This comment has been minimized.

Copy link
Contributor

nikomatsakis commented Oct 13, 2017

@bors r+

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Oct 13, 2017

📌 Commit fcb8bc9 has been approved by nikomatsakis

@bors

This comment has been minimized.

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

Auto merge of #45137 - theotherjimmy:vtable-methods-query, r=nikomats…
…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

This comment has been minimized.

Copy link
Contributor

bors commented Oct 14, 2017

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

@bors bors merged commit fcb8bc9 into rust-lang:master Oct 14, 2017

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
@michaelwoerister

This comment has been minimized.

Copy link
Contributor

michaelwoerister commented Oct 16, 2017

🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.