-
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
Allow Size
to be any valid u64
#50916
Conversation
LLVM doesn't support allocations or types larger than half the address space (and I am not sure about exactly half the address space). Is there any risk of those coming up after this patch? |
We do have tests for these kinds of types. Not sure how to do tests for allocations of such sizes xD |
src/librustc/mir/interpret/mod.rs
Outdated
@@ -117,6 +117,10 @@ impl<'tcx> MemoryPointer { | |||
MemoryPointer { alloc_id, offset } | |||
} | |||
|
|||
pub fn zero(alloc_id: AllocId) -> Self { |
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.
Shouldn't this be a From
impl?
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 considered that. But i think being explicit is better. I don't feel too strongly about that though, so if you want I'll change it
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 think zero
is misleading, I initially assumed it'd be a null pointer.
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.
Also, random thought: maybe MemoryPointer
should be AllocPointer
or AbstractPointer
?
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.
We could just name it Pointer and rename the current Pointer struct to PrimvalPointer
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 seems worse. Maybe this?
enum Scalar {
Undef,
Bits(u128),
Ptr(Pointer),
}
enum Value {
Scalar(Scalar),
ScalarPair(Scalar, Scalar),
ByRef(Pointer, Align),
}
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 the current struct Pointer(Primval)
type? It's just a wrapper around a PrimVal, but helps us not confuse normal PrimVals with those whose type is a pointer type.
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 type doesn't really matter, the value does (unless there are pointer-specific methods on the wrapper?). And I prefer Scalar
over Primval
, but I also forgot the latter is really a thing.
cc @alexcrichton @nagisa @arielb1 @rkruppe |
Hm I don't recall myself, but others might! |
@bors r+ |
📌 Commit 9f79a19 has been approved by |
Allow `Size` to be any valid `u64` cc rust-lang/miri#378 (comment) The alternative is to make mir::interpret's pointer offsets not be `Size` fixes #50917 r? @eddyb
☀️ Test successful - status-appveyor, status-travis |
cc rust-lang/miri#378 (comment)
The alternative is to make mir::interpret's pointer offsets not be
Size
fixes #50917
r? @eddyb