-
Notifications
You must be signed in to change notification settings - Fork 13.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tagged pointers, now with strict provenance! #110243
The head ref may contain hidden characters: "bless_tagged_pointers\u{1F64F}"
Conversation
fat pointers rule!
Does not really matter, but may be nicer in case the pointer has some specific debug impl.
Just use `deref{,_mut}`!
why can't I _ it :'(
This comment has been minimized.
This comment has been minimized.
f9cd8b5
to
c155d51
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to see a few more tests for Eq
, Hash
and HasStable
(asserting that a packed ptr and tag hash the same as (ptr, tag)
.
I have a few other comments, but this looks great!
/// | ||
/// No more than `BITS` least significant bits may be set in the returned usize. | ||
/// [`BITS`]: Tag::BITS | ||
pub unsafe trait Tag: Copy { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder whether it would be worth it to make this trait safe with an assert!(value.into_usize() < (1 << BITS))
. That should be optimized away from all the uses I can imagine, although it would have to be tested.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could even assert this at compile time using extremely ugly beautiful hacks like https://godbolt.org/z/fobx1szMq, although I am not sure whether this would be a good idea (almost certainly not).
} | ||
|
||
const TAG_BIT_SHIFT: usize = usize::BITS as usize - T::BITS; | ||
const ASSERTION: () = { assert!(T::BITS <= P::BITS) }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a nice example of a reasonable non-local error 👍
⌛ Trying commit 5571dd0 with merge 9d28dbbaf465174d2a9b082af86bace14c32a9b9... |
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (9d28dbbaf465174d2a9b082af86bace14c32a9b9): comparison URL. Overall result: ❌ regressions - no action neededBenchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf. @bors rollup=never Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)This benchmark run did not return any relevant results for this metric. CyclesResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
|
@bors r+ |
⌛ Testing commit 5571dd0 with merge c95c09c48438d37071735988dcb412d29557a811... |
💔 Test failed - checks-actions |
the server was not having a happy day |
☀️ Test successful - checks-actions |
Finished benchmarking commit (7908a1d): comparison URL. Overall result: ❌✅ regressions and improvements - no action needed@rustbot label: -perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesThis benchmark run did not return any relevant results for this metric. |
This is a big refactor of tagged pointers in rustc, with three main goals:
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