-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Wrap write_bytes in a function. Move docs #57997
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @KodrAus (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
r? @RalfJung |
src/libcore/intrinsics.rs
Outdated
/// | ||
/// // Now the box is fine | ||
/// assert_eq!(*v, 42); | ||
/// ``` | ||
#[stable(feature = "rust1", since = "1.0.0")] |
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 should then also be removed, I think.
EDIT: Uh, never mind. This is public.
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.
Oh never mind. I did not know the functions in this module are pub
. What the heck, why do we have public intrinsics?!?
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.
That's what I was surprised about when writing the wrapper :D
Cc @rust-lang/libs Please advise: we'd like to replace fn main() {
let mut x = 2;
unsafe {
core::intrinsics::write_bytes(&mut x, 0, 1);
}
} That's quite bad, obviously, because it allows direct access to the intrinsic. I am seriously surprised that anything in So we could either move this one intrinsic to a submodule, meaning |
That In fact I’d be in favor of actively unstabilizing everything in |
I added the |
Wrapping raw intrinsics in new functions has historically caused a noticeable impact to compile times. I'd recommend holding off on landing a PR that wraps everything until we have a perf run at least to evaluate the impact. |
@alexcrichton That's okay with me. How do I trigger a perf run? Or is it just going to come eventually from the CI? |
Oh triggering a perf run currently is still pretty manual. @nitnelave do you want to wrap a few more functions or just this one? Afterwards it's just |
What do we gain from separating this? Anyway this PR currently removes the doc comment from a public stable function, I don't think that's a good idea (don't we have a lint against undocumented functions?).
Hm, I don't see the connection to that issue. EDIT: Oh, I @alexcrichton wrote "The intrinsics module is unstable but the function is stable because it's reexported in std::ptr". I thought we could attach a stability attribute to the reexport, but that doesn't seem to work then.
Ah, that's great! I think it is impossible for |
I guess we'll eventually also wrap |
Yes please do. That'll also make the perf impact bigger (if it exists) and hence easier to measure. I'd even use |
Thanks! Let's see what the timing says. @bors try |
Wrap write_bytes in a function. Move docs This will allow us to add debug assertions. See issue #53871.
Yes, but going "through" an unstable module in a path such as |
@rustc-perf |
I'm trying to run a benchmark, how do I trigger that? @RalfJung |
@nitnelave Try
|
Insufficient permissions to issue commands to rust-timer. |
1 similar comment
Insufficient permissions to issue commands to rust-timer. |
It shouldn't, but we're trying to assess that, see #57997 (comment)
Who does? Who can I ask? |
Ah, yeah!
If you're not in the whitelist and try to run the timer, the timer will complain. I will try to cc @RalfJung . |
@rust-timer build 4f8466b |
Success: Queued 4f8466b with parent 43b4c4a, comparison URL. |
💔 Test failed - checks-travis |
Your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem. Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
@bors retry -- apparently we can't clone the repo anymore on macOS |
This comment has been minimized.
This comment has been minimized.
Wrap write_bytes in a function. Move docs This will allow us to add debug assertions. See issue rust-lang#53871.
Wrap write_bytes in a function. Move docs This will allow us to add debug assertions. See issue rust-lang#53871.
Wrap write_bytes in a function. Move docs This will allow us to add debug assertions. See issue #53871.
☀️ Test successful - checks-travis, status-appveyor |
☀️ Test successful - checks-travis, status-appveyor |
Yay! \o\ \o\ /o/ /o/ |
The interface, though marked stable, is actually not. See rust-lang/rust#57997.
directly expose copy and copy_nonoverlapping intrinsics This effectively un-does rust-lang#57997. That should help with `ptr::read` codegen in debug builds (and any other of these low-level functions that bottoms out at `copy`/`copy_nonoverlapping`), where the wrapper function will not get inlined. See the discussion in rust-lang#80290 and rust-lang#81163. Cc `@bjorn3` `@therealprof`
directly expose copy and copy_nonoverlapping intrinsics This effectively un-does rust-lang/rust#57997. That should help with `ptr::read` codegen in debug builds (and any other of these low-level functions that bottoms out at `copy`/`copy_nonoverlapping`), where the wrapper function will not get inlined. See the discussion in rust-lang/rust#80290 and rust-lang/rust#81163. Cc `@bjorn3` `@therealprof`
This will allow us to add debug assertions.
See issue #53871.