-
Notifications
You must be signed in to change notification settings - Fork 530
Document min pointer width. #834
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
Conversation
If the lang team is not ready to make the min-size commitment, I can easily just remove the addition to |
I don't think we should add this without a very large caveat that it's entirely reasonable for 16-bit pointers to have limited support, and that many libraries may assume that usize is at least 32-bit. 16-bit pointer support is something I'd expect to require explicit care and acknowledgement of in a library crate that supports it, much like From a language point of view, yes, |
Thanks for taking a look! I've updated with a note. |
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'd recommend clarifying whether pointer widths that aren't powers of 2 are permitted. I explicitly mention 24-bit because what I work on deals with pointers that are really 24-bit.
|
||
* `"16"` | ||
* `"32"` | ||
* `"64"` |
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.
Would this allow targets where pointers are really 24-bits, such as the 65816?
Technically speaking, I forcibly extend pointers to 32-bit, but they only have 24 significant bits.
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.
There are two separate questions to answer here, I think.
First, whether pointer size here refers to the "significant bits" or the actual size of a pointer value. I think it refers to the latter, so even if you only have 24 significant bits, if you extend pointers to 32-bit then the pointer size is 32-bit.
But if you don't extend pointers, then that raises an interesting question. I don't see a fundamental reason why (for instance) we couldn't support systems with 80-bit pointers and 80-bit usize
, or why it would have to be rounded up to 128-bit, as long as LLVM (or whatever backend we used for the platform) supported those 80-bit values.
If we add mentions of such cases, though, then I think we'd need to change the clarifying note I suggested to say that "Many pieces of Rust code may assume that pointers, usize
, and isize
are either 32-bit or 64-bit". Because a system with 40-bit or 48-bit or 56-bit pointers would likely run into many of the same difficulties and limited library support as a system with 16-bit or 24-bit or 80-bit or 128-bit pointes.
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 extend pointer size to a multiple of the alignment, 4-bytes. However I treat the 4th byte as padding, rather than treat it as part of the value.
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 listed values are only intended as examples, not something exhaustive. However, rustc currently only supports 16, 32, and 64. It seems like to me that the language definition does not need to take a stance on anything other than the minimum, at least for now.
Co-authored-by: Josh Triplett <[email protected]>
Closes #643.