-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
miri: avoid making a full copy of all new allocations #125633
Conversation
The Miri subtree was changed cc @rust-lang/miri Some changes occurred to the CTFE / Miri engine cc @rust-lang/miri Some changes occurred to the CTFE / Miri engine cc @rust-lang/miri |
5e03c8f
to
14801af
Compare
// The default implementation does a copy; CTFE machines have a more efficient implementation | ||
// based on their particular choice for `Provenance`, `AllocExtra`, and `Bytes`. | ||
let kind = Self::GLOBAL_KIND | ||
.expect("if GLOBAL_KIND is None, adjust_global_allocation must be overwritten"); |
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.
🤨 So the implementation that Miri needs is the default, and the const fn
interpreter overrides with something simpler? Don't we usually do things the other way around?
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.
Yeah, but the other way around does not work here and the const-eval interpreter impl is not well-typed in general, in relies on specific choices for the associated type. And meanwhile it seems nice that a default impl is possible.
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 see. It's always ironic when we run into loose typing implementing Rust.
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.
To me this is actually a sign of a pretty powerful type system -- in the const-eval implementation we of course know more about the concrete choice of types than in the general trait definition, and that lets us safely convert between types that are in general inequal, but are known to be equal in this concrete instance.
@bors r+ |
miri: avoid making a full copy of all new allocations Hopefully fixes rust-lang/miri#3637 r? `@saethlin`
Rollup of 8 pull requests Successful merges: - rust-lang#124251 (Add an intrinsic for `ptr::metadata`) - rust-lang#124320 (Add `--print=check-cfg` to get the expected configs) - rust-lang#125226 (Make more of the test suite run on Mac Catalyst) - rust-lang#125381 (Silence some resolve errors when there have been glob import errors) - rust-lang#125633 (miri: avoid making a full copy of all new allocations) - rust-lang#125638 (Rewrite `lto-smoke`, `simple-rlib` and `mixing-deps` `run-make` tests in `rmake.rs` format) - rust-lang#125639 (Support `./x doc run-make-support --open`) - rust-lang#125664 (Tweak relations to no longer rely on `TypeTrace`) r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 8 pull requests Successful merges: - rust-lang#124251 (Add an intrinsic for `ptr::metadata`) - rust-lang#124320 (Add `--print=check-cfg` to get the expected configs) - rust-lang#125226 (Make more of the test suite run on Mac Catalyst) - rust-lang#125381 (Silence some resolve errors when there have been glob import errors) - rust-lang#125633 (miri: avoid making a full copy of all new allocations) - rust-lang#125638 (Rewrite `lto-smoke`, `simple-rlib` and `mixing-deps` `run-make` tests in `rmake.rs` format) - rust-lang#125639 (Support `./x doc run-make-support --open`) - rust-lang#125664 (Tweak relations to no longer rely on `TypeTrace`) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#125633 - RalfJung:miri-no-copy, r=saethlin miri: avoid making a full copy of all new allocations Hopefully fixes rust-lang/miri#3637 r? ``@saethlin``
Add a benchmark for creating large uninit allocations Extracted from #3637 I used this program to confirm that rust-lang/rust#125633 has the desired effect.
Add a benchmark for creating large uninit allocations Extracted from rust-lang/miri#3637 I used this program to confirm that rust-lang#125633 has the desired effect.
Hopefully fixes rust-lang/miri#3637
r? @saethlin