Skip to content

Commit 85a12ea

Browse files
incr.comp.: Use 128-bit sip-hash instead of BLAKE2 for ICHs.
1 parent f927702 commit 85a12ea

File tree

5 files changed

+288
-62
lines changed

5 files changed

+288
-62
lines changed

src/Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/librustc/ich/fingerprint.rs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
// except according to those terms.
1010

1111
use rustc_data_structures::stable_hasher;
12-
use std::mem;
13-
use std::slice;
12+
// use std::mem;
13+
// use std::slice;
1414

1515
#[derive(Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Clone, Copy, RustcEncodable, RustcDecodable)]
1616
pub struct Fingerprint(u64, u64);
@@ -54,16 +54,10 @@ impl ::std::fmt::Display for Fingerprint {
5454
}
5555

5656
impl stable_hasher::StableHasherResult for Fingerprint {
57+
#[inline]
5758
fn finish(mut hasher: stable_hasher::StableHasher<Self>) -> Self {
58-
let hash_bytes: &[u8] = hasher.finalize();
59-
60-
assert!(hash_bytes.len() >= mem::size_of::<u64>() * 2);
61-
let hash_bytes: &[u64] = unsafe {
62-
slice::from_raw_parts(hash_bytes.as_ptr() as *const u64, 2)
63-
};
64-
65-
// The bytes returned bytes the Blake2B hasher are always little-endian.
66-
Fingerprint(u64::from_le(hash_bytes[0]), u64::from_le(hash_bytes[1]))
59+
let (_0, _1) = hasher.finalize();
60+
Fingerprint(_0, _1)
6761
}
6862
}
6963

src/librustc_data_structures/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ crate-type = ["dylib"]
1111
[dependencies]
1212
log = "0.3"
1313
serialize = { path = "../libserialize" }
14+
siphasher = "0.2.2"

src/librustc_data_structures/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#![feature(fn_traits)]
2929
#![feature(unsize)]
3030
#![feature(i128_type)]
31+
#![feature(i128)]
3132
#![feature(conservative_impl_trait)]
3233
#![feature(specialization)]
3334

@@ -41,6 +42,8 @@ extern crate serialize as rustc_serialize; // used by deriving
4142
#[cfg(unix)]
4243
extern crate libc;
4344

45+
extern crate siphasher;
46+
4447
pub use rustc_serialize::hex::ToHex;
4548

4649
pub mod array_vec;

0 commit comments

Comments
 (0)