Skip to content
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

Merged
merged 22 commits into from
Apr 17, 2023

Conversation

WaffleLapkin
Copy link
Member

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

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 12, 2023
@rust-log-analyzer

This comment has been minimized.

@rust-cloud-vms rust-cloud-vms bot force-pushed the bless_tagged_pointers branch from f9cd8b5 to c155d51 Compare April 13, 2023 16:51
Copy link
Member

@Noratrieb Noratrieb left a 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!

compiler/rustc_data_structures/src/tagged_ptr.rs Outdated Show resolved Hide resolved
///
/// No more than `BITS` least significant bits may be set in the returned usize.
/// [`BITS`]: Tag::BITS
pub unsafe trait Tag: Copy {
Copy link
Member

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.

Copy link
Member

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).

compiler/rustc_data_structures/src/tagged_ptr.rs Outdated Show resolved Hide resolved
compiler/rustc_data_structures/src/tagged_ptr/copy.rs Outdated Show resolved Hide resolved
compiler/rustc_data_structures/src/tagged_ptr/copy.rs Outdated Show resolved Hide resolved
compiler/rustc_data_structures/src/tagged_ptr/copy.rs Outdated Show resolved Hide resolved
@WaffleLapkin WaffleLapkin added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 13, 2023
}

const TAG_BIT_SHIFT: usize = usize::BITS as usize - T::BITS;
const ASSERTION: () = { assert!(T::BITS <= P::BITS) };
Copy link
Member

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 👍

@bors
Copy link
Contributor

bors commented Apr 14, 2023

⌛ Trying commit 5571dd0 with merge 9d28dbbaf465174d2a9b082af86bace14c32a9b9...

@bors
Copy link
Contributor

bors commented Apr 14, 2023

☀️ Try build successful - checks-actions
Build commit: 9d28dbbaf465174d2a9b082af86bace14c32a9b9 (9d28dbbaf465174d2a9b082af86bace14c32a9b9)

@rust-timer

This comment has been minimized.

@WaffleLapkin WaffleLapkin removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Apr 14, 2023
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (9d28dbbaf465174d2a9b082af86bace14c32a9b9): comparison URL.

Overall result: ❌ regressions - no action needed

Benchmarking 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
@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.8% [0.7%, 1.3%] 7
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Max RSS (memory usage)

This benchmark run did not return any relevant results for this metric.

Cycles

Results

This 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.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
2.9% [2.9%, 2.9%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.2% [-2.3%, -2.2%] 2
All ❌✅ (primary) - - 0

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Apr 15, 2023
@Noratrieb
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Apr 17, 2023

📌 Commit 5571dd0 has been approved by Nilstrieb

It is now in the queue for this repository.

@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Apr 17, 2023
@bors
Copy link
Contributor

bors commented Apr 17, 2023

⌛ Testing commit 5571dd0 with merge c95c09c48438d37071735988dcb412d29557a811...

@bors
Copy link
Contributor

bors commented Apr 17, 2023

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Apr 17, 2023
@Noratrieb
Copy link
Member

the server was not having a happy day
@bors retry

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 17, 2023
@rust-log-analyzer
Copy link
Collaborator

A job failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)

@bors
Copy link
Contributor

bors commented Apr 17, 2023

⌛ Testing commit 5571dd0 with merge 7908a1d...

@bors
Copy link
Contributor

bors commented Apr 17, 2023

☀️ Test successful - checks-actions
Approved by: Nilstrieb
Pushing 7908a1d to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Apr 17, 2023
@bors bors merged commit 7908a1d into rust-lang:master Apr 17, 2023
@rustbot rustbot added this to the 1.71.0 milestone Apr 17, 2023
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (7908a1d): comparison URL.

Overall result: ❌✅ regressions and improvements - no action needed

@rustbot label: -perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.6% [0.5%, 0.7%] 4
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.5% [-0.5%, -0.5%] 1
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results

This 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.

mean range count
Regressions ❌
(primary)
3.9% [3.9%, 3.9%] 1
Regressions ❌
(secondary)
1.9% [1.9%, 1.9%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.6% [-3.6%, -3.6%] 1
All ❌✅ (primary) 3.9% [3.9%, 3.9%] 1

Cycles

This benchmark run did not return any relevant results for this metric.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants