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

Implement core::ptr::Unique on top of NonNull #96010

Merged
merged 7 commits into from
Apr 17, 2022

Conversation

eduardosm
Copy link
Contributor

Removes the use rustc_layout_scalar_valid_range_start and some unsafe blocks.

@rustbot rustbot added the T-libs Relevant to the library team, which will review and decide on the PR/issue. label Apr 13, 2022
@rust-highfive
Copy link
Collaborator

Hey! It looks like you've submitted a new PR for the library teams!

If this PR contains changes to any rust-lang/rust public library APIs then please comment with r? rust-lang/libs-api @rustbot label +T-libs-api to request review from a libs-api team reviewer. If you're unsure where your change falls no worries, just leave it as is and the reviewer will take a look and make a decision to forward on if necessary.

Examples of T-libs-api changes:

  • a stabilization of a library feature
  • introducing new or changes existing unstable library APIs
  • changes to public documentation in ways that create new stability guarantees

@rust-highfive
Copy link
Collaborator

r? @thomcc

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 13, 2022
@eduardosm

This comment was marked as resolved.

@eduardosm eduardosm changed the title Implement core::ptr::Unique on top of NonNull [Help wanted] Implement core::ptr::Unique on top of NonNull Apr 13, 2022
@tmiasko
Copy link
Contributor

tmiasko commented Apr 13, 2022

You probably need to change the code generation by adding one additional extract_field / project_field when dereferencing a box (those correspond to the first field Box, the first field of Unique, and now in addition to that the first field of NonNull):

if cg_base.layout.ty.is_box() && !cg_base.layout.field(cx, 1).is_zst() {
let ptr = cg_base.extract_field(bx, 0).extract_field(bx, 0);
ptr.deref(bx.cx())
} else {

// a box with a non-zst allocator should not be directly dereferenced
if cg_base.layout.ty.is_box() && !cg_base.layout.field(cx, 1).is_zst() {
let ptr = cg_base.project_field(bx, 0).project_field(bx, 0);
bx.load_operand(ptr).deref(bx.cx())

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@eduardosm
Copy link
Contributor Author

You probably need to change the code generation by adding one additional extract_field / project_field when dereferencing a box (those correspond to the first field Box, the first field of Unique, and now in addition to that the first field of NonNull):

Thanks for the tip

@eduardosm

This comment was marked as resolved.

@eduardosm eduardosm changed the title [Help wanted] Implement core::ptr::Unique on top of NonNull Implement core::ptr::Unique on top of NonNull Apr 13, 2022
@eduardosm eduardosm marked this pull request as ready for review April 13, 2022 20:23
@thomcc
Copy link
Member

thomcc commented Apr 14, 2022

Hmm, yeah, never really did understand what the deal with Unique was, so I'm gonna to punt this to someone else. Naïvely, it looks fine.

r? rust-lang/libs

@m-ou-se m-ou-se assigned m-ou-se and unassigned thomcc Apr 14, 2022
@m-ou-se
Copy link
Member

m-ou-se commented Apr 14, 2022

@bors r+

@bors
Copy link
Contributor

bors commented Apr 14, 2022

📌 Commit a22a9a9 has been approved by m-ou-se

@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 14, 2022
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Apr 14, 2022
… r=m-ou-se

Implement `core::ptr::Unique` on top of `NonNull`

Removes the use `rustc_layout_scalar_valid_range_start` and some `unsafe` blocks.
@tmiasko
Copy link
Contributor

tmiasko commented Apr 14, 2022

FYI: @antoyo, @bjorn3 this pull request modifies Box, in case mini_core or other backends need matching changes.

@eduardosm
Copy link
Contributor Author

Can we run MSVC CI on this PR to test CDB without waiting for rollup?

@m-ou-se
Copy link
Member

m-ou-se commented Apr 14, 2022

Can we run MSVC CI on this PR to test CDB without waiting for rollup?

It's possible, but there's no bot command or something to do that. You'd have to temporarily modify src/ci/github-actions/ci.yml in this PR to include that test runner in the ones that run on PRs. (And run ./x.py run src/tools/expand-yaml-anchors/ to update .github/workflows/ci.yml.)

@eduardosm eduardosm changed the title Implement core::ptr::Unique on top of NonNull [Do not merge yet] Implement core::ptr::Unique on top of NonNull Apr 14, 2022
@eduardosm eduardosm marked this pull request as draft April 14, 2022 13:56
@eduardosm eduardosm changed the title [Do not merge yet] Implement core::ptr::Unique on top of NonNull Implement core::ptr::Unique on top of NonNull Apr 14, 2022
@eduardosm eduardosm marked this pull request as ready for review April 14, 2022 18:21
@eduardosm
Copy link
Contributor Author

MSVC tests have finally passed, reverted PR CI changes

@klensy
Copy link
Contributor

klensy commented Apr 14, 2022

MSVC tests have finally passed, reverted PR CI changes

You can squash commits a little, instead of having unrelated ones in history.

@eduardosm
Copy link
Contributor Author

You can squash commits a little, instead of having unrelated ones in history.

Done

@eduardosm
Copy link
Contributor Author

@rustbot label -S-waiting-on-bors +S-waiting-on-review

@rustbot rustbot 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 15, 2022
@tmiasko
Copy link
Contributor

tmiasko commented Apr 16, 2022

@bors r=m-ou-se,tmiasko rollup=never

@bors
Copy link
Contributor

bors commented Apr 16, 2022

📌 Commit 7ba0292 has been approved by m-ou-se,tmiasko

@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 16, 2022
@bors
Copy link
Contributor

bors commented Apr 17, 2022

⌛ Testing commit 7ba0292 with merge ac8b118...

@bors
Copy link
Contributor

bors commented Apr 17, 2022

☀️ Test successful - checks-actions
Approved by: m-ou-se,tmiasko
Pushing ac8b118 to master...

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

Finished benchmarking commit (ac8b118): comparison url.

Summary:

  • Primary benchmarks: 😿 relevant regressions found
  • Secondary benchmarks: mixed results
Regressions 😿
(primary)
Regressions 😿
(secondary)
Improvements 🎉
(primary)
Improvements 🎉
(secondary)
All 😿 🎉
(primary)
count1 20 10 0 6 20
mean2 0.6% 1.3% N/A -0.4% 0.6%
max 1.2% 2.5% N/A -0.5% 1.2%

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

Next Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please open an issue or create a new PR that fixes the regressions, add a comment linking to the newly created issue or PR, and then add the perf-regression-triaged label to this PR.

@rustbot label: +perf-regression

Footnotes

  1. number of relevant changes

  2. the arithmetic mean of the percent change

@rustbot rustbot added the perf-regression Performance regression. label Apr 17, 2022
@eduardosm eduardosm deleted the Unique-on-top-of-NonNull branch April 17, 2022 10:14
@pnkfelix
Copy link
Member

  • This seems like it introduced a regression into the compilation times for a lot of important crates.
  • I'm not clear on what its buying us, it seems like internal code cleanup? That doesn't justify a >=1% compile-time regression to webrender and syn.

@eduardosm or @m-ou-se , do either of you have time to look into the cause of this? I'm tempted to suggest we revert it, unless someone can present an argument for why we need it.

@pnkfelix pnkfelix added the I-libs-nominated Nominated for discussion during a libs team meeting. label Apr 21, 2022
@pnkfelix
Copy link
Member

nominating for attention from T-libs, in the hopes that someone can address my concerns above.

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

Successfully merging this pull request may close these issues.