Commit graph

728 commits

Author SHA1 Message Date
Tyler Mandry
73aa2bd707
Rollup merge of #64942 - JohnTitor:fix-clippy, r=eddyb
Fix clippy warnings

* Use `match` instead of `if` chain
* Remove redundant `into_iter()`
* Use `copied()` instead of `map()`

etc.
2019-10-01 23:06:19 -07:00
Tyler Mandry
0e88e56a9a
Rollup merge of #64805 - nnethercote:ObligForest-still-more, r=nikomatsakis
Still more `ObligationForest` improvements.

Following on from #64627, more readability improvements, but negligible effects on speed.

r? @nikomatsakis
2019-10-01 23:06:14 -07:00
Yuki Okushi
f10d2e2d23 Fix clippy warnings 2019-10-01 23:15:47 +09:00
Nicholas Nethercote
a820672f6c Avoid the popping loop at the end of compress().
By collecting the done obligations (when necessary) in the main loop.
This makes the code cleaner.

The commit also changes the order in which successful obligations are
returned -- they are now returned in the registered order, rather than
reversed. Because this order doesn't actually matter, being only used by
tests, the commit uses `sort()` to make the test agnostic w.r.t. the
order.
2019-09-30 05:25:25 +10:00
Nicholas Nethercote
2883c258f1 Remove an out-of-date sentence in a comment. 2019-09-30 05:23:07 +10:00
Nicholas Nethercote
8a62bb1a1d Rename nodes_len and use it in a few more places. 2019-09-30 05:23:07 +10:00
Nicholas Nethercote
9e67f19eee Convert some match expressions to ifs.
These make the code more concise.
2019-09-30 05:23:07 +10:00
Nicholas Nethercote
6fb1f37888 Introduce some intermediate variables that aid readability. 2019-09-30 05:23:07 +10:00
Nicholas Nethercote
22943ee27c Remove unnecessary uses of ObligationForest::scratch.
They don't help performance at all, and just complicate things.
2019-09-30 05:23:07 +10:00
Nicholas Nethercote
ea726501e1 Use filter and map in to_errors. 2019-09-30 05:23:07 +10:00
Nicholas Nethercote
7130e6c073 Tweak the control flow in process_obligations(). 2019-09-30 05:23:07 +10:00
Nicholas Nethercote
85a56cbd88 Inline mark_as_waiting_from.
It has a single call site, and the code is easier to read this way.
2019-09-30 05:23:07 +10:00
Nicholas Nethercote
4a7fb8b13a Rename node_index as index.
For consistency with other variables in this file.
2019-09-30 05:23:07 +10:00
Nicholas Nethercote
3b506d9694 Remove NodeState::OnDfsStack.
It's not necessary; cycles (which are rare) can be detected by looking
at the node stack.

This change speeds things up slightly, as well as simplifying the code a
little.
2019-09-30 05:23:07 +10:00
csmoe
64f61c7888 remove indexed_vec re-export from rustc_data_structures 2019-09-29 16:48:31 +00:00
csmoe
d20183dbbf remove bit_set re-export from rustc_data_structures 2019-09-29 16:11:30 +00:00
csmoe
17990637b3 move bit_set into rustc_index 2019-09-29 16:11:30 +00:00
csmoe
1cff2e6557 move index_vec into rustc_index 2019-09-29 16:11:30 +00:00
Mazdak Farrokhzad
d7d7c2fce2
Rollup merge of #64824 - Mark-Simulacrum:no-stable-hasher-result-everywhere, r=michaelwoerister
No StableHasherResult everywhere

This removes the generic parameter on `StableHasher`, instead moving it to the call to `finish`. This has the side-effect of making all `HashStable` impls nicer, since we no longer need the verbose `<W: StableHasherResult>` that previously existed -- often forcing line wrapping.

This is done for two reasons:
 * we should avoid false "generic" dependency on the result of StableHasher
     * we don't need to codegen two/three copies of all the HashStable impls when they're transitively used to produce a fingerprint, u64, or u128. I haven't measured, but this might actually make our artifacts somewhat smaller too.
 * Easier to understand/read/write code -- the result of the stable hasher is irrelevant when writing a hash impl.
2019-09-29 04:36:02 +02:00
Mark Rousskov
14a5aefb01 Switch over all StableHash impls to new format 2019-09-28 11:47:36 -04:00
Mark Rousskov
f60e58e575 StableHasher does not need to be generic over the Result type 2019-09-28 11:47:15 -04:00
Shivani Bhardwaj
800bd3a11c data_structures: Add deterministic FxHashMap and FxHashSet wrappers
StableMap
A wrapper for FxHashMap that allows to insert, remove, get and get_mut
but no iteration support.

StableSet
A wrapper for FxHashSet that allows to insert, remove, get and create a
sorted vector from a hashset but no iteration support.
2019-09-28 14:35:20 +05:30
bors
c7bc0bf82f Auto merge of #64627 - nnethercote:ObligForest-even-more, r=nikomatsakis
Even more `ObligationForest` improvements

Following on from #64545, more speed and readability improvements.

r? @nikomatsakis
2019-09-25 05:54:00 +00:00
Dylan MacKenzie
4fd9b9944f Add cycle detection for graphs 2019-09-23 15:26:41 -07:00
Nicholas Nethercote
aa10abb211 Rename a variable.
Because the meaning of this `index` variable is quite different to all
the other `index` variables in this file.
2019-09-20 12:53:22 +10:00
Nicholas Nethercote
27c7c23840 Rename waiting_cache.
The name `waiting_cache` sounds like it is related to the states
`NodeState::Waiting`, but it's not; the cache holds nodes of various
states.

This commit changes it to `active_state`.
2019-09-20 11:31:50 +10:00
Nicholas Nethercote
75fd4f754e Rename a loop variable.
We normally use `index` for indices to `ObligationForest::nodes`, but
this is a `Nodes::dependents` index.
2019-09-20 11:26:07 +10:00
Nicholas Nethercote
8d73faf9ab Remove some unnecessary backtrace intermediate variables. 2019-09-20 11:25:16 +10:00
Nicholas Nethercote
3eae7f6291 Upgrade to ena-0.13.1 and use the new inlined_probe_value function.
This is a big speed win for `keccak` and `inflate`.
2019-09-20 11:24:30 +10:00
Nicholas Nethercote
aaff05bd1c Reorder the state handling in process_cycles().
This gives a slight speed-up.
2019-09-20 07:22:10 +10:00
Nicholas Nethercote
7f6e160875 Rename some index variables.
Now that all indices have type `usize`, it makes sense to be more
consistent about their naming. This commit removes all uses of `i` in
favour of `index`.
2019-09-17 15:32:29 +10:00
Nicholas Nethercote
cf3a562c98 Remove NodeIndex.
The size of the indices doesn't matter much here, and having a
`newtype_index!` index type without also using `IndexVec` requires lots
of conversions. So this commit removes `NodeIndex` in favour of uniform
use of `usize` as the index type. As well as making the code slightly
more concise, it also slightly speeds things up.
2019-09-17 15:32:29 +10:00
Nicholas Nethercote
476e75ded7 Move a Node's parent into the descendents list.
`Node` has an optional parent and a list of other descendents. Most of
the time the parent is treated the same as the other descendents --
error-handling is the exception -- and chaining them together for
iteration has a non-trivial cost.

This commit changes the representation. There is now a single list of
descendants, and a boolean flag that indicates if there is a parent (in
which case it is first descendent). This representation encodes the same
information, in a way that is less idiomatic but cheaper to iterate over
for the common case where the parent doesn't need special treatment.

As a result, some benchmark workloads are up to 2% faster.
2019-09-17 15:32:29 +10:00
Mazdak Farrokhzad
1e3b57ee77
Rollup merge of #64500 - nnethercote:ObligForest-fixups, r=nikomatsakis
Various `ObligationForest` improvements

These commits make the code both nicer and faster.

r? @nikomatsakis
2019-09-17 03:08:38 +02:00
bors
16c4011673 Auto merge of #64381 - mati865:rand, r=alexcrichton
Upgrade parking_lot and tempfile rustc dependencies

This should be last piece to unbreak `rustc` in https://github.com/rust-lang/rust/issues/63848
2019-09-16 11:47:11 +00:00
Nicholas Nethercote
4ecd94e121 Move impl Node just after struct Node. 2019-09-16 12:47:46 +10:00
Nicholas Nethercote
201afa6455 Minor comment tweaks. 2019-09-16 12:47:04 +10:00
Nicholas Nethercote
f22bb2e722 Use retain for waiting_cache in apply_rewrites().
It's more concise, more idiomatic, and measurably faster.
2019-09-16 12:43:48 +10:00
Nicholas Nethercote
6e48053d5d Use iterators in error_at and process_cycle.
This makes the code a little faster, presumably because bounds checks
aren't needed on `nodes` accesses. It requires making `scratch` a
`RefCell`, which is not unreasonable.
2019-09-16 12:43:16 +10:00
Nicholas Nethercote
e2492b7163 Add comments about waiting_cache. 2019-09-16 12:41:36 +10:00
Nicholas Nethercote
6391ef4d6e Fix incorrect comment about contents of a Node. 2019-09-16 12:40:31 +10:00
Nicholas Nethercote
ac061dc5c8 Fix some out-of-date names of things in comments. 2019-09-16 12:39:21 +10:00
Nicholas Nethercote
3fda9578e0 Remove out-of-date comments.
These refer to code that no longer exists.
2019-09-16 12:38:24 +10:00
Nicholas Nethercote
1936e44c13 Factor out repeated self.nodes[i] expressions. 2019-09-16 11:57:10 +10:00
Nicholas Nethercote
43c0d2ce8e Redefine NodeIndex as a newtype_index!.
This commit removes the custom index implementation of `NodeIndex`,
which probably predates `newtype_index!`.

As well as eliminating code, it improves the debugging experience,
because the custom implementation had the property of being incremented
by 1 (so it could use `NonZeroU32`), which was incredibly confusing if
you didn't expect it.

For some reason, I also had to remove an `unsafe` block marker from
`from_u32_unchecked()` that the compiler said was now unnecessary.
2019-09-16 11:53:12 +10:00
Nicholas Nethercote
04b1111ae8 Name index variables consistently.
Those with type `usize` are now called `i`, those with type `NodeIndex`
are called `index`.
2019-09-16 11:52:47 +10:00
Nicholas Nethercote
a2261ad664 Inline mark_neighbours_as_waiting_from.
This function is very hot, doesn't get inlined because it's recursive,
and the function calls are significant.

This commit splits it into inlined and uninlined variants, and uses the
inlined variant for the hot call site. This wins several percent on a
few benchmarks.
2019-09-13 13:46:23 +10:00
Mateusz Mikuła
935394f4f8 Upgrade parking_lot and tempfile rustc dependencies 2019-09-11 19:15:32 +02:00
Mazdak Farrokhzad
5761fc759a
Rollup merge of #62744 - llogiq:tiny-list-refactor, r=eddyb
Refactor `TinyList::contains` and `len` to iterate instead of recurse

None
2019-08-25 02:44:58 +02:00
Mark Rousskov
2601c86487 Handle cfg(bootstrap) throughout 2019-08-14 05:39:53 -04:00