summary refs log tree commit diff
path: root/src/librustc/traits/query/normalize.rs
AgeCommit message (Collapse)AuthorLines
2018-07-17Avoid most allocations in `Canonicalizer`.Nicholas Nethercote-2/+4
Extra allocations are a significant cost of NLL, and the most common ones come from within `Canonicalizer`. In particular, `canonical_var()` contains this code: indices .entry(kind) .or_insert_with(|| { let cvar1 = variables.push(info); let cvar2 = var_values.push(kind); assert_eq!(cvar1, cvar2); cvar1 }) .clone() `variables` and `var_values` are `Vec`s. `indices` is a `HashMap` used to track what elements have been inserted into `var_values`. If `kind` hasn't been seen before, `indices`, `variables` and `var_values` all get a new element. (The number of elements in each container is always the same.) This results in lots of allocations. In practice, most of the time these containers only end up holding a few elements. This PR changes them to avoid heap allocations in the common case, by changing the `Vec`s to `SmallVec`s and only using `indices` once enough elements are present. (When the number of elements is small, a direct linear search of `var_values` is as good or better than a hashmap lookup.) The changes to `variables` are straightforward and contained within `Canonicalizer`. The changes to `indices` are more complex but also contained within `Canonicalizer`. The changes to `var_values` are more intrusive because they require defining a new type `SmallCanonicalVarValues` -- which is to `CanonicalVarValues` as `SmallVec` is to `Vec -- and passing stack-allocated values of that type in from outside. All this speeds up a number of NLL "check" builds, the best by 2%.
2018-06-28Rebase falloutOliver Schneider-1/+1
2018-06-28Merge `ConstVal` and `ConstValue`Oliver Schneider-1/+1
2018-06-28Move everything over from `middle::const_val` to `mir::interpret`Oliver Schneider-2/+1
2018-06-28Auto merge of #51538 - nikomatsakis:nll-perf-examination, r=eddybbors-27/+1
convert NLL ops to caches This is a extension of <https://github.com/rust-lang/rust/pull/51460>. It uses a lot more caching than we used to do. This caching is not yet as efficient as it could be, but I'm curious to see the current perf results. This is the high-level idea: in the MIR type checker, use [canonicalized queries](https://rust-lang-nursery.github.io/rustc-guide/traits/canonical-queries.html) for all the major operations. This is helpful because the MIR type check is operating in a context where all types are fully known (mostly, anyway) but regions are completely renumbered. This means we often wind up with duplicate queries like `Foo<'1, '2> :Bar` and `Foo<'3, '4>: Bar`. Canonicalized queries let us re-use the results. By the final commit in this PR, we can essentially just "read off" the resulting region relations and add them to the NLL type check.
2018-06-26remove `Canonicalization` trait, which serves no purposeNiko Matsakis-13/+0
2018-06-26rename `instantiate_query_result`Niko Matsakis-1/+1
2018-06-26make one `Canonicalize` impl for `QueryResult`Niko Matsakis-14/+1
This lets us simplify a few type aliases.
2018-06-26Use proper debugging statements for infinite recursion assertionOliver Schneider-3/+3
2018-06-07Add existential type definitonsOliver Schneider-0/+5
2018-06-02Fix typos of 'ambiguous'Jon Purdy-1/+1
2018-05-17Rename trans to codegen everywhere.Irina Popa-1/+1
2018-04-30make needs_infer specific to inference variablesNiko Matsakis-1/+1
Notably, excluding ReSkolemized
2018-04-10Make recursion_limit and type_length_limit thread-safeJohn Kåre Alsaker-1/+1
2018-03-17Replace Rc with LrcJohn Kåre Alsaker-3/+3
2018-03-13add some debug outputNiko Matsakis-0/+6
2018-03-13introduce `infcx.at(..).normalize(..)` operation [VIC]Niko Matsakis-0/+268
It is backed by the new `normalize_projection_ty` query, which uses canonicalization.