-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Query-ify Instance::resolve #67797
Query-ify Instance::resolve #67797
Conversation
r? @estebank (rust_highfive has picked a reviewer for you, use r? to override) |
r? @nikomatsakis cc @Zoxc @eddyb @bors try @rust-timer queue |
Awaiting bors try build completion |
⌛ Trying commit d1eb2de827f187de057cacbcc4c62edff2b9c45a with merge 609a6dac721d35c178f8b8147e885b190fc01e35... |
☀️ Try build successful - checks-azure |
Queued 609a6dac721d35c178f8b8147e885b190fc01e35 with parent 0ec3706, future comparison URL. |
Finished benchmarking try commit 609a6dac721d35c178f8b8147e885b190fc01e35, comparison URL. |
The |
style-servo is currently broken (on master, too): "error: truncating cast: the value 4294967292 requires 32 bits but the target type is only 16 bits" (amongst others). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thoughts?
src/librustc/ty/instance.rs
Outdated
}; | ||
debug!("resolve(def_id={:?}, substs={:?}) = {:?}", def_id, substs, result); | ||
result | ||
tcx.resolve_instance((param_env, def_id, substs)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, this seems like a place where canonicalization would be appropriate. We don't expect inference variables, but we do use this (I believe) without having fully erased regions, right? In that case, canonicalizing might eliminate duplicate work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. However, I think #67717 is already doing canonicalization changes related to (among other things) Instance::resolve
. My queryification of Instance::resolve
is just a copy-paste of the existing method body, so it should be hopefully be straightforward to apply one PR on top of the other (depending on which gets merged first).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heh, I just came here from reviewing #67717 to point out that it is making changes to Instance::resolve
that would require canonicalization.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nikomatsakis: Would you like me to add canonicalization in this PR, or should it be done in a follow-up PR after #67717 is merged?
Is there something blocking this PR? It holds up #67953. |
I assumed that this was waiting on |
I have been waiting until we land #67117 -- though if we want to land this first, perhaps some assertions that we don't have inference variables would suffice. |
@nikomatsakis: I assume you meant #67717? |
Yes. Sorry. :) |
Now that the servo benchmarks have been fixed, can I get another perf run? |
@bors try @rust-timer queue |
Awaiting bors try build completion |
🔒 Merge conflict This pull request and the master branch diverged in a way that cannot be automatically merged. Please rebase on top of the latest master branch, and let the reviewer approve again. How do I rebase?Assuming
You may also read Git Rebasing to Resolve Conflicts by Drew Blessing for a short tutorial. Please avoid the "Resolve conflicts" button on GitHub. It uses Sometimes step 4 will complete without asking for resolution. This is usually due to difference between how Error message
|
d1eb2de
to
e73f7a7
Compare
@Mark-Simulacrum: I've fixed the merge conflict |
@bors try |
⌛ Trying commit e73f7a7af4cff1c3af953db35272bcd9812622ae with merge b3fa52e9b78a50cbeec31bbb22ea6ec6209bdd77... |
@Dylan-DPC: This should be |
@Aaron1011 thanks. made the change (Btw you can change labels with rustbot if you don't have access :) |
@JohnCSimon: See my previous comment - this should be |
This comment has been minimized.
This comment has been minimized.
@nikomatsakis: Are there any changes you'd like me to make, or should I just rebase this? |
@Aaron1011 sorry for delay. r=me when rebased. |
2bbc172
to
63d6ef6
Compare
@bors r=nikomatsakis |
📌 Commit 63d6ef6 has been approved by |
⌛ Testing commit 63d6ef6 with merge 84cff50957e27f6a9f18fd6f836cc35ced665e75... |
@bors retry yield |
Rollup of 5 pull requests Successful merges: - rust-lang#67797 (Query-ify Instance::resolve) - rust-lang#70777 (Don't import integer and float modules, use assoc consts) - rust-lang#70795 (Keep track of position when deleting from a BTreeMap) - rust-lang#70812 (Do not use "nil" to refer to `()`) - rust-lang#70815 (Enable layout debugging for `impl Trait` type aliases) Failed merges: r? @ghost
☔ The latest upstream changes (presumably #70816) made this pull request unmergeable. Please resolve the merge conflicts. |
@@ -1257,5 +1257,9 @@ rustc_queries! { | |||
eval_always | |||
desc { "looking up enabled feature gates" } | |||
} | |||
|
|||
query resolve_instance(key: (ty::ParamEnv<'tcx>, DefId, SubstsRef<'tcx>)) -> Option<ty::Instance<'tcx>> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just spotted this: whenever you have a ty::ParamEnv
and some thing referring the to same parameters it adds bounds in scope of, like (DefId, SubstsRef)
here, the right thing to do is to use ty::ParamEnvAnd<(DefId, SubstsRef)>
.
Doing so should result in better caching (as the bounds in scope aren't kept if they're not needed by the SubtsRef
), and is more semantically meaningful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do this in a drive-by commit.
@@ -296,3 +296,14 @@ impl Key for (Symbol, u32, u32) { | |||
DUMMY_SP | |||
} | |||
} | |||
|
|||
impl<'tcx> Key for (ty::ParamEnv<'tcx>, DefId, SubstsRef<'tcx>) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess a strong hint is that you had to add a new Key
impl: generally, you shouldn't need one.
Split off from #65989
Instance::resolve is now a wrapper for a new
resolve_instance
query.This greatly improves performance on several benchmarks