about summary refs log tree commit diff
path: root/compiler/rustc_data_structures/src
AgeCommit message (Collapse)AuthorLines
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-8/+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-8/+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-8/+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
2023-04-14Doc fixes from reviewMaybe Waffle-7/+26
2023-04-13Implement `Send`/`Sync` for `CopyTaggedPtr`Maybe Waffle-0/+20
2023-04-12doc fixesMaybe Waffle-3/+4
2023-04-12Document tagged pointers betterMaybe Waffle-31/+130
2023-04-12Add tests for tagged pointersMaybe Waffle-0/+222
2023-04-12Add `TaggedPtr::set_tag`Maybe Waffle-0/+4
2023-04-12Move code aroundMaybe Waffle-56/+57
2023-04-12Shorten `COMPARE_PACKED` => `CP` where it is not importantMaybe Waffle-14/+14
why can't I _ it :'(
2023-04-12Remove `pointer_{ref,mut}` from tagged pointersMaybe Waffle-20/+11
Just use `deref{,_mut}`!
2023-04-12Make tagged pointers debug impls print the pointerMaybe Waffle-12/+8
Does not really matter, but may be nicer in case the pointer has some specific debug impl.
2023-04-12Remove `Pointer::with_ref` in favour implementing it on tagged pointers directlyMaybe Waffle-40/+25
2023-04-12Lift `Pointer`'s requirement for the pointer to be thinMaybe Waffle-16/+44
fat pointers rule!
2023-04-12Remove useless parameter from ghostMaybe Waffle-2/+2
2023-04-11Fix doc testMaybe Waffle-2/+6
2023-04-11Refactor tagged ptr packing into a functionMaybe Waffle-23/+22
2023-04-11Bless tagged pointers (comply to strict provenance)Maybe Waffle-58/+78
2023-04-11Sprinkle some whitespace & usesMaybe Waffle-6/+25
2023-04-11Add `bits_for` helper for tagged pointers & fixup docsMaybe Waffle-15/+40
2023-04-11Use `SSO_ARRAY_SIZE` instead of `8` in `SsoHashMap` implMaybe Waffle-17/+17
2023-04-11Use `itertools::Either` instead of own `EitherIter` implMaybe Waffle-92/+18
2023-04-09Inline format_argsNilstrieb-1/+1
Co-authored-by: Michael Goulet <michael@errs.io>
2023-04-09Fix some clippy::complexityNilstrieb-15/+9
2023-04-09Allow `modulo_one` on function using cfg constsNilstrieb-0/+1
2023-04-09Some simple `clippy::perf` fixesNilstrieb-1/+1
2023-04-08Auto merge of #109971 - WaffleLapkin:yeet_ownership, r=Nilstriebbors-1980/+204
Yeet `owning_ref` Based on the discussions from https://github.com/rust-lang/rust/pull/109948 This replaces `owning_ref` with a far simpler & safer abstraction. Fixes #109974
2023-04-07Mark `OwnedSlice::{deref, borrow}` as `#[inline]`Maybe Waffle-0/+2
2023-04-06Support multithreaded mode in `OwnedSlice` testsMaybe Waffle-8/+14