forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#112400 - WaffleLapkin:vtable_stats, r=compile…
…r-errors Collect VTable stats & add `-Zprint-vtable-sizes` This is a bit hacky/buggy, but I'm not entirely sure how to fix it, so I want to ask reviewers for help... To try this, use either of those: - `cargo clean && RUSTFLAGS="-Zprint-vtable-sizes" cargo +toolchain b` - `cargo clean && cargo rustc +toolchain -Zprint-vtable-sizes` - `rustc +toolchain -Zprint-vtable-sizes ./file.rs`
- Loading branch information
Showing
10 changed files
with
232 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// check-pass | ||
// compile-flags: -Z print-vtable-sizes | ||
#![crate_type = "lib"] | ||
|
||
trait A<T: help::V>: AsRef<[T::V]> + AsMut<[T::V]> {} | ||
|
||
trait B<T>: AsRef<T> + AsRef<T> + AsRef<T> + AsRef<T> {} | ||
|
||
trait C { | ||
fn x() {} // not object safe, shouldn't be reported | ||
} | ||
|
||
// This ideally should not have any upcasting cost, | ||
// but currently does due to a bug | ||
trait D: Send + Sync + help::MarkerWithSuper {} | ||
|
||
// This can't have no cost without reordering, | ||
// because `Super::f`. | ||
trait E: help::MarkerWithSuper + Send + Sync {} | ||
|
||
trait F { | ||
fn a(&self); | ||
fn b(&self); | ||
fn c(&self); | ||
|
||
fn d() -> Self | ||
where | ||
Self: Sized; | ||
} | ||
|
||
trait G: AsRef<u8> + AsRef<u16> + help::MarkerWithSuper { | ||
fn a(&self); | ||
fn b(&self); | ||
fn c(&self); | ||
fn d(&self); | ||
fn e(&self); | ||
|
||
fn f() -> Self | ||
where | ||
Self: Sized; | ||
} | ||
|
||
// Traits with the same name | ||
const _: () = { | ||
trait S {} | ||
}; | ||
const _: () = { | ||
trait S {} | ||
}; | ||
|
||
mod help { | ||
pub trait V { | ||
type V; | ||
} | ||
|
||
pub trait MarkerWithSuper: Super {} | ||
|
||
pub trait Super { | ||
fn f(&self); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
print-vtable-sizes { "crate_name": "<UNKNOWN_CRATE>", "trait_name": "D", "entries": "7", "entries_ignoring_upcasting": "4", "entries_for_upcasting": "3", "upcasting_cost_percent": "75" } | ||
print-vtable-sizes { "crate_name": "<UNKNOWN_CRATE>", "trait_name": "E", "entries": "6", "entries_ignoring_upcasting": "4", "entries_for_upcasting": "2", "upcasting_cost_percent": "50" } | ||
print-vtable-sizes { "crate_name": "<UNKNOWN_CRATE>", "trait_name": "G", "entries": "14", "entries_ignoring_upcasting": "11", "entries_for_upcasting": "3", "upcasting_cost_percent": "27.27272727272727" } | ||
print-vtable-sizes { "crate_name": "<UNKNOWN_CRATE>", "trait_name": "A", "entries": "6", "entries_ignoring_upcasting": "5", "entries_for_upcasting": "1", "upcasting_cost_percent": "20" } | ||
print-vtable-sizes { "crate_name": "<UNKNOWN_CRATE>", "trait_name": "B", "entries": "4", "entries_ignoring_upcasting": "4", "entries_for_upcasting": "0", "upcasting_cost_percent": "0" } | ||
print-vtable-sizes { "crate_name": "<UNKNOWN_CRATE>", "trait_name": "F", "entries": "6", "entries_ignoring_upcasting": "6", "entries_for_upcasting": "0", "upcasting_cost_percent": "0" } | ||
print-vtable-sizes { "crate_name": "<UNKNOWN_CRATE>", "trait_name": "_::S", "entries": "3", "entries_ignoring_upcasting": "3", "entries_for_upcasting": "0", "upcasting_cost_percent": "0" } | ||
print-vtable-sizes { "crate_name": "<UNKNOWN_CRATE>", "trait_name": "_::S", "entries": "3", "entries_ignoring_upcasting": "3", "entries_for_upcasting": "0", "upcasting_cost_percent": "0" } | ||
print-vtable-sizes { "crate_name": "<UNKNOWN_CRATE>", "trait_name": "help::MarkerWithSuper", "entries": "4", "entries_ignoring_upcasting": "4", "entries_for_upcasting": "0", "upcasting_cost_percent": "0" } | ||
print-vtable-sizes { "crate_name": "<UNKNOWN_CRATE>", "trait_name": "help::Super", "entries": "4", "entries_ignoring_upcasting": "4", "entries_for_upcasting": "0", "upcasting_cost_percent": "0" } | ||
print-vtable-sizes { "crate_name": "<UNKNOWN_CRATE>", "trait_name": "help::V", "entries": "3", "entries_ignoring_upcasting": "3", "entries_for_upcasting": "0", "upcasting_cost_percent": "0" } |