about summary refs log tree commit diff
path: root/compiler/rustc_data_structures
AgeCommit message (Collapse)AuthorLines
2023-05-15Process current bucket instead of parent's bucket when starting loop for ↵Camille GILLOT-8/+35
dominators.
2023-05-14Start node has no immediate dominatorTomasz Miąsko-14/+22
Change the immediate_dominator return type to Option, and use None to indicate that node has no immediate dominator. Also fix the issue where the start node would be returned as its own immediate dominator.
2023-05-13Auto merge of #107586 - SparrowLii:parallel-query, r=cjgillotbors-37/+465
Introduce `DynSend` and `DynSync` auto trait for parallel compiler part of parallel-rustc #101566 This PR introduces `DynSend / DynSync` trait and `FromDyn / IntoDyn` structure in rustc_data_structure::marker. `FromDyn` can dynamically check data structures for thread safety when switching to parallel environments (such as calling `par_for_each_in`). This happens only when `-Z threads > 1` so it doesn't affect single-threaded mode's compile efficiency. r? `@cjgillot`
2023-05-12Rollup merge of #111393 - klensy:win-0.48, r=oli-obkMatthias Krüger-3/+5
bump windows crate 0.46 -> 0.48 This drops duped version of crate(0.46), reduces `rustc_driver.dll` ~800kb and reduces exported functions number from 26k to 22k. Also while here, added `tidy-alphabetical` sorting to lists in tidy allowed lists.
2023-05-09bump windows crate 0.46 -> 0.48 in workspaceklensy-3/+5
2023-05-09Rollup merge of #111252 - matthewjasper:min-spec-improvements, r=compiler-errorsDylan DPC-0/+2
Min specialization improvements - Don't allow specialization impls with no items, such implementations are probably not correct and only occur as mistakes in the compiler and standard library - Fix a missing normalization call - Adds spans for lifetime errors from overly general specializations Closes #79457 Closes #109815
2023-05-07Use smaller ints for bitflagsNilstrieb-1/+1
2023-05-06add `DynSend / DynSync` for `CopyTaggedPtr`SparrowLii-5/+8
2023-05-06correct import of owned_sliceSparrowLii-13/+6
2023-05-06correct literals for dyn thread safeSparrowLii-21/+24
2023-05-06rename relative names in `sync`SparrowLii-23/+28
2023-05-06fix `parallel!`SparrowLii-0/+7
2023-05-06fix some nitsSparrowLii-39/+27
2023-05-06introduce `DynSend` and `DynSync` auto traitSparrowLii-39/+468
2023-05-05Disallow (min) specialization imps with no itemsMatthew Jasper-0/+2
Such implementations are usually mistakes and are not used in the compiler or standard library (after this commit) so forbid them with `min_specialization`.
2023-04-30Use the full Fingerprint when stringifying SvhBen Kimock-5/+10
2023-04-27Auto merge of #107782 - Zoxc:worker-local, r=cjgillotbors-34/+188
Move the WorkerLocal type from the rustc-rayon fork into rustc_data_structures This PR moves the definition of the `WorkerLocal` type from `rustc-rayon` into `rustc_data_structures`. This is enabled by the introduction of the `Registry` type which allows you to group up threads to be used by `WorkerLocal` which is basically just an array with an per thread index. The `Registry` type mirrors the one in Rayon and each Rayon worker thread is also registered with the new `Registry`. Safety for `WorkerLocal` is ensured by having it keep a reference to the registry and checking on each access that we're still on the group of threads associated with the registry used to construct it. Accessing a `WorkerLocal` is micro-optimized due to it being hot since it's used for most arena allocations. Performance is slightly improved for the parallel compiler: <table><tr><td rowspan="2">Benchmark</td><td colspan="1"><b>Before</b></th><td colspan="2"><b>After</b></th></tr><tr><td align="right">Time</td><td align="right">Time</td><td align="right">%</th></tr><tr><td>🟣 <b>clap</b>:check</td><td align="right">1.9992s</td><td align="right">1.9949s</td><td align="right"> -0.21%</td></tr><tr><td>🟣 <b>hyper</b>:check</td><td align="right">0.2977s</td><td align="right">0.2970s</td><td align="right"> -0.22%</td></tr><tr><td>🟣 <b>regex</b>:check</td><td align="right">1.1335s</td><td align="right">1.1315s</td><td align="right"> -0.18%</td></tr><tr><td>🟣 <b>syn</b>:check</td><td align="right">1.8235s</td><td align="right">1.8171s</td><td align="right"> -0.35%</td></tr><tr><td>🟣 <b>syntex_syntax</b>:check</td><td align="right">6.9047s</td><td align="right">6.8930s</td><td align="right"> -0.17%</td></tr><tr><td>Total</td><td align="right">12.1586s</td><td align="right">12.1336s</td><td align="right"> -0.21%</td></tr><tr><td>Summary</td><td align="right">1.0000s</td><td align="right">0.9977s</td><td align="right"> -0.23%</td></tr></table> cc `@SparrowLii`
2023-04-27Rollup merge of #110814 - WaffleLapkin:sprinkle_#inline, r=NilstriebMatthias Krüger-0/+17
Sprinkle some `#[inline]` in `rustc_data_structures::tagged_ptr` This is based on `nm --demangle (rustc +a --print sysroot)/lib/librustc_driver-*.so | rg CopyTaggedPtr` which shows many methods that should probably be inlined. May fix the regression in https://github.com/rust-lang/rust/pull/110795. r? ```@Nilstrieb```
2023-04-25Rollup merge of #110615 - WaffleLapkin:impl_tag, r=cjgillotMatthias Krüger-6/+204
Add `impl_tag!` macro to implement `Tag` for tagged pointer easily r? `@Nilstrieb` This should also lifts the need to think about safety from the callers (`impl_tag!` is robust (ish, see the macro issue)) and removes the possibility of making a "weird" `Tag` impl.
2023-04-25Add `#[inline]` in `impl_tag`Maybe Waffle-0/+2
2023-04-25Sprinkle some `#[inline]` in `rustc_data_structures::tagged_ptr`Maybe Waffle-0/+17
2023-04-25Rollup merge of #110681 - klensy:cut-dep, r=lcnrYuki Okushi-1/+0
drop few unused crates, gate libc under unix for rustc_codegen_ssa Small cleanup.
2023-04-24Switch `impl_tag!` from explicit tags to `${index()}`Maybe Waffle-47/+52
2023-04-24Split `{Idx, IndexVec, IndexSlice}` into their own modulesMaybe Waffle-15/+16
2023-04-22drop unused deps, gate libc under unix for one crateklensy-1/+0
2023-04-20Simplify `bits_for_tags` implMaybe Waffle-13/+3
2023-04-20Remove confusing commentMaybe Waffle-31/+0
2023-04-20Use `impl Tag for $T` syntax for `impl_tag!`Maybe Waffle-11/+11
2023-04-20Add `impl_tag!` macro to implement `Tag` for tagged pointer easilyMaybe Waffle-6/+238
2023-04-19`deny(unsafe_op_in_unsafe_fn)` in `rustc_data_structures`Maybe Waffle-101/+109
2023-04-18Auto merge of #110083 - saethlin:encode-hashes-as-bytes, r=cjgillotbors-36/+178
Encode hashes as bytes, not varint In a few places, we store hashes as `u64` or `u128` and then apply `derive(Decodable, Encodable)` to the enclosing struct/enum. It is more efficient to encode hashes directly than try to apply some varint encoding. This PR adds two new types `Hash64` and `Hash128` which are produced by `StableHasher` and replace every use of storing a `u64` or `u128` that represents a hash. Distribution of the byte lengths of leb128 encodings, from `x build --stage 2` with `incremental = true` Before: ``` ( 1) 373418203 (53.7%, 53.7%): 1 ( 2) 196240113 (28.2%, 81.9%): 3 ( 3) 108157958 (15.6%, 97.5%): 2 ( 4) 17213120 ( 2.5%, 99.9%): 4 ( 5) 223614 ( 0.0%,100.0%): 9 ( 6) 216262 ( 0.0%,100.0%): 10 ( 7) 15447 ( 0.0%,100.0%): 5 ( 8) 3633 ( 0.0%,100.0%): 19 ( 9) 3030 ( 0.0%,100.0%): 8 ( 10) 1167 ( 0.0%,100.0%): 18 ( 11) 1032 ( 0.0%,100.0%): 7 ( 12) 1003 ( 0.0%,100.0%): 6 ( 13) 10 ( 0.0%,100.0%): 16 ( 14) 10 ( 0.0%,100.0%): 17 ( 15) 5 ( 0.0%,100.0%): 12 ( 16) 4 ( 0.0%,100.0%): 14 ``` After: ``` ( 1) 372939136 (53.7%, 53.7%): 1 ( 2) 196240140 (28.3%, 82.0%): 3 ( 3) 108014969 (15.6%, 97.5%): 2 ( 4) 17192375 ( 2.5%,100.0%): 4 ( 5) 435 ( 0.0%,100.0%): 5 ( 6) 83 ( 0.0%,100.0%): 18 ( 7) 79 ( 0.0%,100.0%): 10 ( 8) 50 ( 0.0%,100.0%): 9 ( 9) 6 ( 0.0%,100.0%): 19 ``` The remaining 9 or 10 and 18 or 19 are `u64` and `u128` respectively that have the high bits set. As far as I can tell these are coming primarily from `SwitchTargets`.
2023-04-18Add #[inline] to some new functionsBen Kimock-0/+3
Co-authored-by: Camille Gillot <gillot.camille@gmail.com>
2023-04-18Document how the HashN types are different from FingerprintBen Kimock-4/+15
2023-04-18Store hashes in special types so they aren't accidentally encoded as numbersBen Kimock-37/+165
2023-04-18Rollup merge of #110417 - jsoref:spelling-compiler, r=NilstriebGuillaume Gomez-1/+1
Spelling compiler This is per https://github.com/rust-lang/rust/pull/110392#issuecomment-1510193656 I'm going to delay performing a squash because I really don't expect people to be perfectly happy w/ my changes, I really am a human and I really do make mistakes. r? Nilstrieb I'm going to be flying this evening, but I should be able to squash / respond to reviews w/in a day or two. I tried to be careful about dropping changes to `tests`, afaict only two files had changes that were likely related to the changes for a given commit (this is where not having eagerly squashed should have given me an advantage), but, that said, picking things apart can be error prone.
2023-04-18Auto merge of #110481 - matthiaskrgr:rollup-phkkgm9, r=matthiaskrgrbors-9/+52
Rollup of 7 pull requests Successful merges: - #109981 (Set commit information environment variables when building tools) - #110348 (Add list of supported disambiguators and suffixes for intra-doc links in the rustdoc book) - #110409 (Don't use `serde_json` to serialize a simple JSON object) - #110442 (Avoid including dry run steps in the build metrics) - #110450 (rustdoc: Fix invalid handling of nested items with `--document-private-items`) - #110461 (Use `Item::expect_*` and `ImplItem::expect_*` more) - #110465 (Assure everyone that `has_type_flags` is fast) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-04-18Rollup merge of #110409 - ↵Matthias Krüger-9/+52
Nilstrieb:some-manual-javascript-object-notationing, r=fee1-dead Don't use `serde_json` to serialize a simple JSON object This avoids `rustc_data_structures` depending on `serde_json` which allows it to be compiled much earlier, unlocking most of rustc. This used to not matter, but after #110407 we're not blocked on fluent anymore, which means that it's now a blocking edge. ![image](https://user-images.githubusercontent.com/48135649/232313178-e0150420-3020-4eb6-98d3-fe5294a8f947.png) This saves a few more seconds. cc ````@Zoxc```` who added it recently
2023-04-18Auto merge of #110410 - saethlin:hash-u128-as-u64s, r=oli-obkbors-1/+2
Implement StableHasher::write_u128 via write_u64 In https://github.com/rust-lang/rust/pull/110367#issuecomment-1510114777 the cachegrind diffs indicate that nearly all the regression is from this: ``` 22,892,558 ???:<rustc_data_structures::sip128::SipHasher128>::slice_write_process_buffer -9,502,262 ???:<rustc_data_structures::sip128::SipHasher128>::short_write_process_buffer::<8> ``` Which happens because the diff for that perf run swaps a `Hash::hash` of a `u64` to a `u128`. But `slice_write_process_buffer` is a `#[cold]` function, and is for handling hashes of arbitrary-length byte arrays. Using the much more optimizer-friendly `u64` path twice to hash a `u128` provides a nice perf boost in some benchmarks.
2023-04-17Auto merge of #110243 - WaffleLapkin:bless_tagged_pointers🙏, r=Nilstriebbors-215/+640
Tagged pointers, now with strict provenance! This is a big refactor of tagged pointers in rustc, with three main goals: 1. Porting the code to the strict provenance 2. Cleanup the code 3. Document the code (and safety invariants) better This PR has grown quite a bit (almost a complete rewrite at this point...), so I'm not sure what's the best way to review this, but reviewing commit-by-commit should be fine. r? `@Nilstrieb`
2023-04-17Spelling - compilerJosh Soref-1/+1
* account * achieved * advising * always * ambiguous * analysis * annotations * appropriate * build * candidates * cascading * category * character * clarification * compound * conceptually * constituent * consts * convenience * corresponds * debruijn * debug * debugable * debuggable * deterministic * discriminant * display * documentation * doesn't * ellipsis * erroneous * evaluability * evaluate * evaluation * explicitly * fallible * fulfill * getting * has * highlighting * illustrative * imported * incompatible * infringing * initialized * into * intrinsic * introduced * javascript * liveness * metadata * monomorphization * nonexistent * nontrivial * obligation * obligations * offset * opaque * opportunities * opt-in * outlive * overlapping * paragraph * parentheses * poisson * precisely * predecessors * predicates * preexisting * propagated * really * reentrant * referent * responsibility * rustonomicon * shortcircuit * simplifiable * simplifications * specify * stabilized * structurally * suggestibility * translatable * transmuting * two * unclosed * uninhabited * visibility * volatile * workaround Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-04-17Auto merge of #110367 - saethlin:no-truncations, r=oli-obkbors-28/+6
Remove some suspicious cast truncations These truncations were added a long time ago, and as best I can tell without a perf justification. And with rust-lang/rust#110410 it has become perf-neutral to not truncate anymore. We worked hard for all these bits, let's use them.
2023-04-16Remove some unnecessary hash truncationsBen Kimock-28/+6
2023-04-16Implement StableHasher::write_u128 via write_u64Ben Kimock-1/+2
2023-04-16Don't use `serde_json` to serialize a simple JSON objectNilstrieb-9/+52
This avoids `rustc_data_structures` depending on `serde_json` which allows it to be compiled much earlier, unlocking most of rustc.
2023-04-16fix clippy::toplevel_ref_arg and ::manual_mapMatthias Krüger-5/+2
2023-04-16Move the WorkerLocal type from the rustc-rayon fork into rustc_data_structuresJohn Kåre Alsaker-34/+188
2023-04-14fix broken intradoclinksMaybe Waffle-1/+3
2023-04-14Use `ptr::Alignment` for extra coolness pointsMaybe Waffle-25/+20
2023-04-14Test `CopyTaggedPtr`'s `HashStable` implMaybe Waffle-0/+26
2023-04-14Share `Tag2` impl between `CopyTaggedPtr` and `TaggedPtr` testsMaybe Waffle-62/+31