about summary refs log tree commit diff
path: root/compiler/rustc_query_impl/src/plumbing.rs
AgeCommit message (Collapse)AuthorLines
2022-09-09Remove unnecessary `TRY_LOAD_FROM_DISK` constantJoshua Nelson-4/+1
2022-09-09Move `TRY_LOAD_FROM_DISK` out of `rustc_queries` to `rustc_query_impl`Joshua Nelson-0/+3
We want to refer to `crate::plumbing::try_load_from_disk` in the const, but hard-coding it in rustc_queries, where we don't yet know the crate this macro will be called in, seems kind of hacky. Do it in query_impl instead.
2022-09-09Remove `cache_on_disk` from `QueryVTable`Joshua Nelson-2/+1
This is not only simpler, but removes a generic function and unwrap. I have hope it will see compile time and bootstrap time improvements.
2022-09-09Don't create a new `try_load_from_disk` closure for each queryJoshua Nelson-0/+24
Instead, define a single function, parameterized only by the return type.
2022-09-06Get rid of the emitted `rustc_query_names` and `rustc_cached_queries` macroJoshua Nelson-4/+16
We can avoid these by adding slightly more information to `rustc_query_append` instead.
2022-09-06Move `Queries::new` out of the macroJoshua Nelson-15/+20
2022-09-06Make `HandleCycleError` an enum instead of a macro-generated closureJoshua Nelson-13/+11
- Add a `HandleCycleError` enum to rustc_query_system, along with a `handle_cycle_error` function - Move `Value` to rustc_query_system, so `handle_cycle_error` can use it - Move the `Value` impls from rustc_query_impl to rustc_middle. This is necessary due to orphan rules.
2022-09-01Don't create two new closures for each queryJoshua Nelson-30/+21
- Parameterize DepKindStruct over `'tcx` This allows passing in an invariant function pointer in `query_callback`, rather than having to try and make it work for any lifetime. - Add a new `execute_query` function to `QueryDescription` so we can call `tcx.$name` without needing to be in a macro context
2022-09-01Simplify `try_load_from_on_disk_cache`Joshua Nelson-8/+9
2022-09-01Move almost all of the function in `query_callbacks` to a generic functionJoshua Nelson-28/+47
2022-09-01Get rid of `fn recover`Joshua Nelson-18/+8
2022-09-01Move `force_with_dep_node` outside the giant macroJoshua Nelson-16/+26
2022-09-01Move `try_on_disk_cache` out of the giant macroJoshua Nelson-11/+19
2022-09-01Get rid of `make_query` moduleJoshua Nelson-13/+6
2022-09-01tracing::instrument cleanupOli Scherer-1/+1
2022-08-29Replace `rustc_data_structures::thin_vec::ThinVec` with `thin_vec::ThinVec`.Nicholas Nethercote-6/+4
`rustc_data_structures::thin_vec::ThinVec` looks like this: ``` pub struct ThinVec<T>(Option<Box<Vec<T>>>); ``` It's just a zero word if the vector is empty, but requires two allocations if it is non-empty. So it's only usable in cases where the vector is empty most of the time. This commit removes it in favour of `thin_vec::ThinVec`, which is also word-sized, but stores the length and capacity in the same allocation as the elements. It's good in a wider variety of situation, e.g. in enum variants where the vector is usually/always non-empty. The commit also: - Sorts some `Cargo.toml` dependency lists, to make additions easier. - Sorts some `use` item lists, to make additions easier. - Changes `clean_trait_ref_with_bindings` to take a `ThinVec<TypeBinding>` rather than a `&[TypeBinding]`, because this avoid some unnecessary allocations.
2022-08-27Auto merge of #100946 - jyn514:query-system-3, r=cjgillotbors-1/+1
Simplify the arguments to macros generated by the `rustc_queries` proc macro Very small cleanup. Based on https://github.com/rust-lang/rust/pull/100436 which modifies some of the same code. r? `@cjgillot`
2022-08-25Auto merge of #100748 - SparrowLii:query_depth, r=cjgillotbors-1/+19
add `depth_limit` in `QueryVTable` to avoid entering a new tcx in `layout_of` Fixes #49735 Updates #48685 The `layout_of` query needs to check whether it overflows the depth limit, and the current implementation needs to create a new `ImplicitCtxt` inside `layout_of`. However, `start_query` will already create a new `ImplicitCtxt`, so we can check the depth limit in `start_query`. We can tell whether we need to check the depth limit simply by whether the return value of `to_debug_str` of the query is `layout_of`. But I think adding the `depth_limit` field in `QueryVTable` may be more elegant and more scalable.
2022-08-24Remove the `$tcx:tt` parameter from `rustc_query_description`Joshua Nelson-1/+1
It's unnecessary.
2022-08-23Move most of `make_query` into a generic function, away from the macroJoshua Nelson-41/+56
This should both make the code easier to read and also greatly reduce the amount of codegen the compiler has to do, since it only needs to monomorphize `create_query_frame` for each new key and not for each query.
2022-08-23Get rid of some usages of `query_keys`Joshua Nelson-7/+6
Rustdoc documents these with the name of the type alias instead of normalizing them to the underlying type. Use associated types instead so that the generated docs for nightly-rustc are easier to read.
2022-08-23Remove `$tcx` metavariable from `rustc_query_append`Joshua Nelson-31/+27
It's not actually necessary and it makes the code harder to read.
2022-08-24add `depth_limit` in `QueryVTable`SparrowLii-1/+19
2022-08-15Remove usages of opt_remap_env_constnessMiguel Guarniz-3/+0
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-08-15Remove opt_remap_env_constness from rustc_query_implMiguel Guarniz-11/+1
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-07-20consistently use VTable over Vtable (matching stable stdlib API RawWakerVTable)Ralf Jung-2/+2
2022-07-06Use a dedicated DepKind for the forever-red node.Camille GILLOT-0/+11
2022-07-06Allow to create definitions inside the query system.Camille GILLOT-5/+6
2022-07-06Rollup merge of #98881 - cjgillot:q-def-kind, r=fee1-deadDylan DPC-5/+8
Only compute DefKind through the query.
2022-07-05Clarify the behaviour from inside the query system.Camille GILLOT-5/+8
2022-07-04Only compute DefKind through the query.Camille GILLOT-1/+1
2022-06-29get rid of `tcx` in deadlock handler when parallel compilationSparrowLii-5/+0
2022-06-16Move `finish` out of the `Encoder` trait.Nicholas Nethercote-2/+1
This simplifies things, but requires making `CacheEncoder` non-generic. (This was previously merged as commit 4 in #94732 and then was reverted in #97905 because it caused a perf regression.)
2022-06-10Revert dc08bc51f2c58a0f5f815a07f9bb3d671153b5a1.Nicholas Nethercote-1/+2
2022-06-08Move `finish` out of the `Encoder` trait.Nicholas Nethercote-2/+1
This simplifies things, but requires making `CacheEncoder` non-generic.
2022-06-08Use delayed error handling for `Encodable` and `Encoder` infallible.Nicholas Nethercote-4/+2
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-20Remove `crate` visibility usage in compilerJacob Pratt-1/+1
2022-05-04Enable tracing for all queryiesOli Scherer-0/+3
2022-02-27Auto merge of #94084 - Mark-Simulacrum:drop-sharded, r=cjgillotbors-3/+2
Avoid query cache sharding code in single-threaded mode In non-parallel compilers, this is just adding needless overhead at compilation time (since there is only one shard statically anyway). This amounts to roughly ~10 seconds reduction in bootstrap time, with overall neutral (some wins, some losses) performance results. Parallel compiler performance should be largely unaffected by this PR; sharding is kept there.
2022-02-21Auto merge of #94066 - Mark-Simulacrum:factor-out-simple-def-kind, r=davidtwcobors-6/+4
Remove SimpleDefKind Now that rustc_query_system depends on rustc_hir, we can just directly make use of the regular DefKind.
2022-02-20Delete QueryLookupMark Rousskov-2/+1
This was largely just caching the shard value at this point, which is not particularly useful -- in the use sites the key was being hashed nearby anyway.
2022-02-20Move Sharded maps into each QueryCache implMark Rousskov-1/+1
2022-02-17Remove SimpleDefKindMark Rousskov-6/+4
2022-02-16Move ty::print methods to Drop-based scope guardsMark Rousskov-4/+5
2022-02-09Auto merge of #93741 - Mark-Simulacrum:global-job-id, r=cjgillotbors-12/+21
Refactor query system to maintain a global job id counter This replaces the per-shard counters with a single global counter, simplifying the JobId struct down to just a u64 and removing the need to pipe a DepKind generic through a bunch of code. The performance implications on non-parallel compilers are likely minimal (this switches to `Cell<u64>` as the backing storage over a `u64`, but the latter was already inside a `RefCell` so it's not really a significance divergence). On parallel compilers, the cost of a single global u64 counter may be more significant: it adds a serialization point in theory. On the other hand, we can imagine changing the counter to have a thread-local component if it becomes worrisome or some similar structure. The new design is sufficiently simpler that it warrants the potential for slight changes down the line if/when we get parallel compilation to be more of a default. A u64 counter, instead of u32 (the old per-shard width), is chosen to avoid possibly overflowing it and causing problems; it is effectively impossible that we would overflow a u64 counter in this context.
2022-02-08Switch QueryJobId to a single global counterMark Rousskov-12/+21
This replaces the per-shard counters with a single global counter, simplifying the JobId struct down to just a u64 and removing the need to pipe a DepKind generic through a bunch of code. The performance implications on non-parallel compilers are likely minimal (this switches to `Cell<u64>` as the backing storage over a `u64`, but the latter was already inside a `RefCell` so it's not really a significance divergence). On parallel compilers, the cost of a single global u64 counter may be more significant: it adds a serialization point in theory. On the other hand, we can imagine changing the counter to have a thread-local component if it becomes worrisome or some similar structure. The new design is sufficiently simpler that it warrants the potential for slight changes down the line if/when we get parallel compilation to be more of a default. A u64 counter, instead of u32 (the old per-shard width), is chosen to avoid possibly overflowing it and causing problems; it is effectively impossible that we would overflow a u64 counter in this context.
2022-02-0814956 -> 14952 exportsklensy-2/+2
2022-02-0715221 -> 14956 exportsklensy-1/+1
2021-12-14Remove `in_band_lifetimes` from `rustc_query_impl`LegionMammal978-4/+4
See #91867 for more information.
2021-12-12Query modifierDeadbeef-0/+12