about summary refs log tree commit diff
path: root/compiler/rustc_metadata/src/rmeta/table.rs
AgeCommit message (Collapse)AuthorLines
2023-12-21Encode CoroutineKind directlyMichael Goulet-0/+15
2023-12-10remove redundant importssurechen-6/+1
detects redundant imports that can be eliminated. for #117772 : In order to facilitate review and modification, split the checking code and removing redundant imports code into two PR.
2023-11-26merge `DefKind::Coroutine` into `DefKind::Closure`bohan-1/+0
2023-11-22Rollup merge of #118147 - Nilstrieb:no-redundant-casts, r=WaffleLapkinMichael Goulet-1/+1
Fix some unnecessary casts `x clippy compiler -Aclippy::all -Wclippy::unnecessary_cast --fix` with some manual review to ensure every fix is correct.
2023-11-21Fix some unnecessary castsNilstrieb-1/+1
`x clippy compiler -Aclippy::all -Wclippy::unnecessary_cast --fix` with some manual review to ensure every fix is correct.
2023-11-21Fix `clippy::needless_borrow` in the compilerNilstrieb-2/+2
`x clippy compiler -Aclippy::all -Wclippy::needless_borrow --fix`. Then I had to remove a few unnecessary parens and muts that were exposed now.
2023-10-20s/Generator/Coroutine/Oli Scherer-1/+1
2023-10-17Automatically enable cross-crate inlining for small functionsBen Kimock-0/+24
2023-09-26Don't store lazyness in DefKindMichael Goulet-2/+1
2023-09-21Record asyncness span in HIRMichael Goulet-3/+3
2023-09-10Reimplement FileEncoder with a small-write optimizationBen Kimock-2/+4
2023-08-30Auto merge of #113542 - saethlin:adaptive-tables, r=b-naberbors-40/+104
Adapt table sizes to the contents This is an implementation of https://github.com/rust-lang/compiler-team/issues/666 The objective of this PR is to permit the rmeta format to accommodate larger crates that need offsets larger than a `u32` can store without compromising performance for crates that do not need such range. The second commit is a number of tiny optimization opportunities I noticed while looking at perf recordings of the first commit. The rmeta tables need to have fixed-size elements to permit lazy random access. But the size only needs to be fixed _per table_, not per element type. This PR adds another `usize` to the table header which indicates the table element size. As each element of a table is set, we keep track of the widest encoded table value, then don't bother encoding all the unused trailing bytes on each value. When decoding table elements, we copy them to a full-width array if they are not already full-width. `LazyArray` needs some special treatment. Most other values that are encoded in tables are indexes or offsets, and those tend to be small so we get to drop a lot of zero bytes off the end. But `LazyArray` encodes _two_ small values in a fixed-width table element: A position of the table and the length of the table. The treatment described above could trim zero bytes off the table length, but any nonzero length shields the position bytes from the optimization. To improve this, we interleave the bytes of position and length. This change is responsible for about half of the crate metadata win on many crates. Fixes https://github.com/rust-lang/rust/issues/112934 (probably) Fixes https://github.com/rust-lang/rust/issues/103607
2023-08-29Document in the code how this scheme worksBen Kimock-14/+22
2023-08-07Store the laziness of type aliases in the DefKindLeón Orell Valerian Liehr-1/+2
2023-07-14Micro-optimizeBen Kimock-4/+7
2023-07-13Adapt table sizes to the contentsBen Kimock-38/+91
2023-07-12Re-format let-else per rustfmt updateMark Rousskov-3/+3
2023-07-08Replace RPITIT current impl with new strategy that lowers as a GATSantiago Pastorino-1/+0
2023-05-30Lower the tracing level of some very verbose messagesOli Scherer-1/+1
2023-04-24Split `{Idx, IndexVec, IndexSlice}` into their own modulesMaybe Waffle-1/+1
2023-04-17Make `IndexVec::ensure_contains_elem` return a reference to the elementMaybe Waffle-2/+2
2023-03-18Implement FixedSizeEncoding for UnusedGenericParams.Camille GILLOT-1/+26
2023-02-14Add `of_trait` to DefKind::Impl.Camille GILLOT-1/+2
2023-02-05rustc_metadata: Encode/decode `DefPathHash`es without an `Option`Vadim Petrochenkov-7/+10
2023-02-05rustc_metadata: Support encoding/decoding `LazyArray` without an `Option`Vadim Petrochenkov-14/+48
2023-02-05rustc_metadata: Refactor lazy table reading/writingVadim Petrochenkov-33/+80
Change wording from "nullable" to "default". Introduce a trait `IsDefault` for detecting values that are encoded as zeros or not encoded at all. Add panics to impossible cases. Some other minor cleanups.
2023-01-23rustc_metadata: Support non-`Option` nullable values in metadata tablesVadim Petrochenkov-42/+30
This is a convenience feature for cases in which "no value in the table" and "default value in the table" are equivalent. Tables using `Table<DefIndex, ()>` are migrated in this PR, some other cases can be migrated later. This helps `DocFlags` in https://github.com/rust-lang/rust/pull/107136 in particular.
2023-01-21rustc_metadata: Encode `doc(hidden)` flag to metadataVadim Petrochenkov-0/+14
To retrieve these flags rustdoc currently has to mass decode full attributes for items in the whole crate tree, so it's better to pre-compute it in advance. This is especially for short-term performance of https://github.com/rust-lang/rust/pull/107054 because resolver cannot use memoization of query results yet.
2022-12-10compiler: remove unnecessary imports and qualified pathsKaDiWa-1/+0
2022-11-21Unreserve braced enum variants in value namespaceVadim Petrochenkov-2/+0
2022-09-09RPITIT placeholder itemsMichael Goulet-0/+1
2022-09-01Auto merge of #98960 - cjgillot:entry-kind, r=estebankbors-1/+16
Remove EntryKind from metadata. This PR continues the refactor of metadata emission to be more systematic, iterating on definitions and filtering based on each definition's `DefKind`. This allows to remove the large `EntryKind` enum, replaced by linear tables in metadata.
2022-09-01Always import all tracing macros for the entire crate instead of piecemeal ↵Oli Scherer-1/+0
by module
2022-08-30Fix the panic message.Camille GILLOT-1/+1
2022-08-30Use tables for macros.Camille GILLOT-0/+8
2022-08-30Move AssocContainer to a metadata table.Camille GILLOT-0/+7
2022-07-27Update mentions to `rustc_metadata::rmeta::Lazy`Yuki Okushi-2/+2
Signed-off-by: Yuki Okushi <jtitor@2k36.org>
2022-07-02use rustc_serialize::opaque::FileEncoderYoshiki Matsuda-3/+3
2022-06-14Rename rustc_serialize::opaque::Encoder as MemEncoder.Nicholas Nethercote-3/+3
This avoids the name clash with `rustc_serialize::Encoder` (a trait), and allows lots qualifiers to be removed and imports to be simplified (e.g. fewer `as` imports). (This was previously merged as commit 5 in #94732 and then was reverted in #97905 because of a perf regression caused by commit 4 in #94732.)
2022-06-10Revert b983e42936feab29f6333e9835913afc6b4a394e.Nicholas Nethercote-3/+3
2022-06-08Rename `rustc_serialize::opaque::Encoder` as `MemEncoder`.Nicholas Nethercote-3/+3
This avoids the name clash with `rustc_serialize::Encoder` (a trait), and allows lots qualifiers to be removed and imports to be simplified (e.g. fewer `as` imports).
2022-06-08Use delayed error handling for `Encodable` and `Encoder` infallible.Nicholas Nethercote-1/+1
There are two impls of the `Encoder` trait: `opaque::Encoder` and `opaque::FileEncoder`. The former encodes into memory and is infallible, the latter writes to file and is fallible. Currently, standard `Result`/`?`/`unwrap` error handling is used, but this is a bit verbose and has non-trivial cost, which is annoying given how rare failures are (especially in the infallible `opaque::Encoder` case). This commit changes how `Encoder` fallibility is handled. All the `emit_*` methods are now infallible. `opaque::Encoder` requires no great changes for this. `opaque::FileEncoder` now implements a delayed error handling strategy. If a failure occurs, it records this via the `res` field, and all subsequent encoding operations are skipped if `res` indicates an error has occurred. Once encoding is complete, the new `finish` method is called, which returns a `Result`. In other words, there is now a single `Result`-producing method instead of many of them. This has very little effect on how any file errors are reported if `opaque::FileEncoder` has any failures. Much of this commit is boring mechanical changes, removing `Result` return values and `?` or `unwrap` from expressions. The more interesting parts are as follows. - serialize.rs: The `Encoder` trait gains an `Ok` associated type. The `into_inner` method is changed into `finish`, which returns `Result<Vec<u8>, !>`. - opaque.rs: The `FileEncoder` adopts the delayed error handling strategy. Its `Ok` type is a `usize`, returning the number of bytes written, replacing previous uses of `FileEncoder::position`. - Various methods that take an encoder now consume it, rather than being passed a mutable reference, e.g. `serialize_query_result_cache`.
2022-05-24Make Lazy not care about lifetimes until decodeMichael Goulet-4/+5
2022-05-23refine comments, disambiguate len for array and tablesMichael Goulet-6/+9
2022-05-23split out the various responsibilities of LazyMichael Goulet-37/+13
2022-04-19rustc_metadata: Store a flag telling whether an item may have doc links in ↵Vadim Petrochenkov-0/+14
its attributes This should be cheap on rustc side, but it's significant optimization for rustdoc that won't need to decode and process attributes unnecessarily
2022-04-10Simplify FixedSizeEncoding using const generics.Camille GILLOT-107/+85
2022-04-10Directly encode DefId in metadata.Camille GILLOT-0/+28
2022-04-10Directly encode DefPathHash in metadata.Camille GILLOT-0/+19
2022-04-10Directly encode DefKind in metadata.Camille GILLOT-0/+46