-
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
debuginfo: Use TypeIdHasher for generating global debuginfo type IDs. #37336
Conversation
r? @eddyb (rust_highfive has picked a reviewer for you, use r? to override) |
} | ||
fn write_usize(&mut self, i: usize) { | ||
self.inner.write_u64(i as u64) | ||
self.inner.write_u64((i as u64).to_le()) |
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, and isize
should probably not have the to_le()
.
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.
Why? That would be true if they were calling self.write_u64
and not self.inner.write_u64
.
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.
Really? I'm not sure I follow why (they call the inner write_u64
at least rather than the outer one)... Could you elaborate?
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.
Ahhh, didn't read that code carefully enough 😞 I still remembered that usize
would delegate to u64
and didn't expect to go directly to the inner.
👍 |
} | ||
fn write_usize(&mut self, i: usize) { | ||
self.inner.write_u64(i as u64) | ||
self.inner.write_u64((i as u64).to_le()) |
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.
Why? That would be true if they were calling self.write_u64
and not self.inner.write_u64
.
struct WidenUsizeHasher<H> { | ||
// | ||
// The same goes for endianess: We always convert multi-byte integers to little | ||
// endian before hashing. |
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.
Can we turn this into a doc comment? Maybe even make it public, seems useful elsewhere.
Fixed the failing test case. |
@bors r+ |
📌 Commit 025b27d has been approved by |
…, r=eddyb debuginfo: Use TypeIdHasher for generating global debuginfo type IDs. The only requirement for debuginfo type IDs is that they are globally unique. The `TypeIdHasher` (which is used for `std::intrinsic::type_id()` provides that, so we can get rid of some redundancy by re-using it for debuginfo. Values produced by the `TypeIdHasher` are also more stable than the current `UniqueTypeId` generation algorithm produces -- these incorporate the `NodeId`s, which is not good for incremental compilation. @alexcrichton @eddyb : Could you take a look at the endianess adaptations that I made to the `TypeIdHasher`? Also, are we sure that a 64 bit hash is wide enough for something that is supposed to be globally unique? For debuginfo I'm using 160 bits to make sure that we don't run into conflicts there.
The only requirement for debuginfo type IDs is that they are globally unique. The
TypeIdHasher
(which is used forstd::intrinsic::type_id()
provides that, so we can get rid of some redundancy by re-using it for debuginfo. Values produced by theTypeIdHasher
are also more stable than the currentUniqueTypeId
generation algorithm produces -- these incorporate theNodeId
s, which is not good for incremental compilation.@alexcrichton @eddyb : Could you take a look at the endianess adaptations that I made to the
TypeIdHasher
?Also, are we sure that a 64 bit hash is wide enough for something that is supposed to be globally unique? For debuginfo I'm using 160 bits to make sure that we don't run into conflicts there.