-
Notifications
You must be signed in to change notification settings - Fork 367
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
Remove the field
field from Lvalue::Local
#220
Conversation
src/eval_context.rs
Outdated
@@ -1353,7 +1347,12 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> { | |||
I128 => 16, | |||
Is => self.memory.pointer_size(), | |||
}; | |||
PrimVal::from_i128(self.memory.read_int(ptr, size)?) | |||
// if we cast a ptr to a usize reading it back into a primval shouldn't panic |
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.
What about isize?
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.
Whoops, copy paste.
src/eval_context.rs
Outdated
@@ -1366,7 +1365,12 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> { | |||
U128 => 16, | |||
Us => self.memory.pointer_size(), | |||
}; | |||
PrimVal::from_u128(self.memory.read_uint(ptr, size)?) | |||
if size == self.memory.pointer_size() { | |||
// if we cast a ptr to a usize reading it back into a primval shouldn't panic |
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.
What about isize?
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 is the usize cast ;)
@@ -24,8 +24,6 @@ pub enum Lvalue<'tcx> { | |||
Local { | |||
frame: usize, | |||
local: mir::Local, | |||
/// Optionally, this lvalue can point to a field of the stack value | |||
field: Option<(usize, Ty<'tcx>)>, |
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.
Yay. :D TBH I never understood this field
, so I'm happy I don't have to.
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.
The title of the PR is not entirely precise; this is really just about removing the field
, right?
Looks like |
@RalfJung Looks like |
Ah, GitHub fooled me. I pressed the "expand code" button and then what Is aw looked almost like a complete type, but it wasn't actually completely expanded. :/ |
field
field from Lvalue::Local
|
The |
I checked whether we could use the |
@@ -1353,7 +1347,12 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> { | |||
I128 => 16, | |||
Is => self.memory.pointer_size(), | |||
}; | |||
PrimVal::from_i128(self.memory.read_int(ptr, size)?) | |||
// if we cast a ptr to an isize, reading it back into a primval shouldn't panic |
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 am not sure I am happy about using the word "cast" here. This is doing a transmute, i.e., it is reading the same bytes at a different type. The rules for the two should be somewhat consistent, but they are clearly not the same right now (as they are implemented in two different files).
Fair enough. |
Undoes #146 and #139 because this was just a lot of overhead working with the field accesses. They also only "helped" when the lvalue that was produced was immediately read again.
We should move to doing an lvalue-read operation similar to https://github.com/solson/miri/pull/139/files#diff-3596aeeadedc2ed352f2c376852f8fb7L117 which optimizes through those cases where you don't want to have a pointer in the end, but only a primval. So basically primval rvalues?
I did not reinstate the mentioned lvalue-read, since i want to get this PR through first and then write a more advanced version that supports more cases.