Skip to content

Commit 61dc080

Browse files
committed
adjust const alloc interning partial hash comments
1 parent b1f31f8 commit 61dc080

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

compiler/rustc_middle/src/mir/interpret/allocation.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ use crate::ty;
2626
/// Its public API is rather low-level, working directly with allocation offsets and a custom error
2727
/// type to account for the lack of an AllocId on this level. The Miri/CTFE core engine `memory`
2828
/// module provides higher-level access.
29+
// Note: for performance reasons when interning, some of the `Allocation` fields can be partially
30+
// hashed. (see the `Hash` impl below for more details), so the impl is not derived.
2931
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord, TyEncodable, TyDecodable)]
3032
#[derive(HashStable)]
3133
pub struct Allocation<Tag = AllocId, Extra = ()> {
@@ -50,13 +52,13 @@ pub struct Allocation<Tag = AllocId, Extra = ()> {
5052
pub extra: Extra,
5153
}
5254

53-
/// This is the maximum size we will hash at a time from these two structures, when interning. Note,
54-
/// we hash that amount of bytes twice: at the start, and at the end of a buffer. Used when an
55-
/// `Allocation` and its `InitMask` are large: we only partially hash the larger fields in that
55+
/// This is the maximum size we will hash at a time, when interning an `Allocation` and its
56+
/// `InitMask`. Note, we hash that amount of bytes twice: at the start, and at the end of a buffer.
57+
/// Used when these two structures are large: we only partially hash the larger fields in that
5658
/// situation. See the comment at the top of their respective `Hash` impl for more details.
5759
const MAX_BYTES_TO_HASH: usize = 64;
5860

59-
/// This is the maximum size (in bytes) for which a buffer will be fully hashed when interning.
61+
/// This is the maximum size (in bytes) for which a buffer will be fully hashed, when interning.
6062
/// Otherwise, it will be partially hashed in 2 slices, requiring at least 2 `MAX_BYTES_TO_HASH`
6163
/// bytes.
6264
const MAX_HASHED_BUFFER_LEN: usize = 2 * MAX_BYTES_TO_HASH;
@@ -681,6 +683,8 @@ type Block = u64;
681683

682684
/// A bitmask where each bit refers to the byte with the same index. If the bit is `true`, the byte
683685
/// is initialized. If it is `false` the byte is uninitialized.
686+
// Note: for performance reasons when interning, some of the `InitMask` fields can be partially
687+
// hashed. (see the `Hash` impl below for more details), so the impl is not derived.
684688
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord, TyEncodable, TyDecodable)]
685689
#[derive(HashStable)]
686690
pub struct InitMask {

0 commit comments

Comments
 (0)