-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
prepare for Intptrcast model #61781
prepare for Intptrcast model #61781
Conversation
This comment has been minimized.
This comment has been minimized.
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.
@RalfJung are you ok with us not nuking to_ptr
and to_bits
immediately? It would make the PR much more complex since we'd have to fiddle things through Allocation
(in librustc
where we don't know about the force*
methods or InterpCX
)
src/librustc_mir/interpret/memory.rs
Outdated
} | ||
} | ||
|
||
pub fn force_bits(&self, scalar: Scalar<M::PointerTag>) -> InterpResult<'tcx, u128> { |
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 know this PR isn't going to full intptrcast in one step, but I think it should still use force_bits
$somewhere. Maybe start with just
rust/src/librustc_mir/interpret/cast.rs
Line 251 in 24ddd16
Int(_) | Uint(_) => err!(ReadPointerAsBytes), cast_from_int
after you get the bits viaforce_bits
)rust/src/librustc_mir/interpret/place.rs
Line 472 in 24ddd16
let n = n.to_bits(self.tcx.data_layout.pointer_size)?; rust/src/librustc_mir/interpret/operator.rs
Line 313 in 24ddd16
let l = left.to_bits().expect("we checked is_ptr"); rust/src/librustc_mir/interpret/operator.rs
Line 350 in 24ddd16
let val = val.to_bits(layout.size)?;
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'll do these changes and add a commit :P
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.
No please don't do anything on casts! That's just a red herring, people can still transmute stuff. We need to do conversion lazily, nor eagerly.
I thought we had discussed in detail where force_ptr
is needed? Namely, the methods in "place.rs" and "operand.rs" that access memory. And then for force_bits
, that would arise only inside Miri in the newest plan, in ptr_op
.
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 wait, that cast stuff is for non-ptr-sized casts. Hm. Okay we should eventually force_bits
there.
But that should be properly deduplicated with the int-to-int cass, so I don't think that method is the right place. Maybe let's keep that one for later.
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.
D: ok I haven't committed anything. What should I do next then?
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.
Ok, I've already substituted to_ptr
by force_ptr
in the last commit, if the bin_op
change is going to happen in miri
, are we done here?
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 also force_bits
shouldn't assume pointer size, that makes it rather inconvenient to use. It should take the size as argument, like to_bits
does.
But it can assert that if the size is NOT pointer size, it will never see a pointer value.
I've already substituted to_ptr by force_ptr in the last commit
I hope you mean "carefully replaced in a few places", not "substituted everywhere with sed
". ;)
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.
Hahaha, yeah I've just replaced them on the places with the @RalfJung approval seal.
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 sorry my bad, this was only about
force_bits
. I should learn to read. :(I agree with the following two:
rust/src/librustc_mir/interpret/place.rs
Line 472 in 24ddd16
let n = n.to_bits(self.tcx.data_layout.pointer_size)?; rust/src/librustc_mir/interpret/operator.rs
Line 350 in 24ddd16
let val = val.to_bits(layout.size)?; But this one makes no sense to change as it already panics if there are no bits there.
I'm going to do those changes then
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 also
force_bits
shouldn't assume pointer size, that makes it rather inconvenient to use. It should take the size as argument, liketo_bits
does.
I'm going to do this change before the other ones then and will do a couple commits in a few minutes
Absolutely, I didn't even necessarily expect them to be nuked at all. |
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.
LGTM. :) @oli-obk any objections?
I believe CI needs to be invoked again, or force bors to do the merge test |
Why that? Travis is green, and Azure can be ignored. ;) |
I had the impression bors won't do its work until both CI pipelines are green |
bors will start even if all CI is red. |
Man these bots like to live dangerously :P |
@bors r+ go live dangerously |
📌 Commit 212f233 has been approved by |
…=oli-obk prepare for Intptrcast model rust-lang#61668 done right (I hope so). r? @RalfJung @oli-obk
…=oli-obk prepare for Intptrcast model rust-lang#61668 done right (I hope so). r? @RalfJung @oli-obk
…=oli-obk prepare for Intptrcast model rust-lang#61668 done right (I hope so). r? @RalfJung @oli-obk
@bors r- This seems to break Miri. And we should get at least one nightly with a working Miri, because currently the latest distributed Miri is broken. |
Ok problem fixed, miri tests are passing in local now |
Awesome! @bors r=oli-obk,RalfJung |
📌 Commit 1e38870 has been approved by |
💔 Test failed - checks-travis |
The job 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 timeout |
☀️ Test successful - checks-travis, status-appveyor |
#61668 done right (I hope so). r? @RalfJung @oli-obk