Skip to content

Commit a248c2d

Browse files
committed
Remove nightly ARM flag. (Requires version bump)
Signed-off-by: Tom Kaitchuck <Tom.Kaitchuck@gmail.com>
1 parent e7481cd commit a248c2d

9 files changed

+33
-37
lines changed

Cargo.toml

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ahash"
3-
version = "0.8.8"
3+
version = "0.9.0"
44
authors = ["Tom Kaitchuck <Tom.Kaitchuck@gmail.com>"]
55
license = "MIT OR Apache-2.0"
66
description = "A non-cryptographic hash function using AES-NI for high performance"
@@ -12,7 +12,7 @@ edition = "2018"
1212
readme = "README.md"
1313
build = "./build.rs"
1414
exclude = ["/smhasher", "/benchmark_tools"]
15-
rust-version = "1.60.0"
15+
rust-version = "1.72.0"
1616

1717
[lib]
1818
name = "ahash"
@@ -44,9 +44,6 @@ no-rng = []
4444
# in case this is being used on an architecture lacking core::sync::atomic::AtomicUsize and friends
4545
atomic-polyfill = [ "dep:atomic-polyfill", "once_cell/atomic-polyfill"]
4646

47-
# Nightly-only support for AES intrinsics on 32-bit ARM
48-
nightly-arm-aes = []
49-
5047
[[bench]]
5148
name = "ahash"
5249
path = "tests/bench.rs"

README.md

-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ The aHash package has the following flags:
5757
This is done using the [getrandom](https://github.com/rust-random/getrandom) crate.
5858
* `compile-time-rng`: For OS targets without access to a random number generator, `compile-time-rng` provides an alternative.
5959
If `getrandom` is unavailable and `compile-time-rng` is enabled, aHash will generate random numbers at compile time and embed them in the binary.
60-
* `nightly-arm-aes`: To use AES instructions on 32-bit ARM, which requires nightly. This is not needed on AArch64.
6160
This allows for DOS resistance even if there is no random number generator available at runtime (assuming the compiled binary is not public).
6261
This makes the binary non-deterministic. (If non-determinism is a problem see [constrandom's documentation](https://github.com/tkaitchuck/constrandom#deterministic-builds))
6362

src/aes_hash.rs

+18-6
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,20 @@ impl AHasher {
100100
let result: [u64; 2] = aesdec(combined, combined).convert();
101101
result[0]
102102
}
103+
104+
#[inline]
105+
#[cfg(any(target_arch = "aarch64", target_arch = "arm"))]
106+
fn final_mix(&self) -> u128 {
107+
let sum = aesenc(self.sum, self.key);
108+
aesdec(aesdec(sum, self.enc), sum)
109+
}
110+
111+
#[inline]
112+
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
113+
fn final_mix(&self) -> u128 {
114+
let combined = aesenc(self.sum, self.enc);
115+
aesdec(aesdec(combined, self.key), combined)
116+
}
103117
}
104118

105119
/// Provides [Hasher] methods to hash all of the primitive types.
@@ -206,10 +220,10 @@ impl Hasher for AHasher {
206220
}
207221
}
208222
}
223+
209224
#[inline]
210225
fn finish(&self) -> u64 {
211-
let combined = aesenc(self.sum, self.enc);
212-
let result: [u64; 2] = aesdec(aesdec(combined, self.key), combined).convert();
226+
let result: [u64; 2] = self.final_mix().convert();
213227
result[0]
214228
}
215229
}
@@ -330,15 +344,13 @@ impl Hasher for AHasherStr {
330344
fn write(&mut self, bytes: &[u8]) {
331345
if bytes.len() > 8 {
332346
self.0.write(bytes);
333-
self.0.enc = aesenc(self.0.sum, self.0.enc);
334-
self.0.enc = aesdec(aesdec(self.0.enc, self.0.key), self.0.enc);
347+
self.0.enc = self.0.final_mix();
335348
} else {
336349
add_in_length(&mut self.0.enc, bytes.len() as u64);
337350

338351
let value = read_small(bytes).convert();
339352
self.0.sum = shuffle_and_add(self.0.sum, value);
340-
self.0.enc = aesenc(self.0.sum, self.0.enc);
341-
self.0.enc = aesdec(aesdec(self.0.enc, self.0.key), self.0.enc);
353+
self.0.enc = self.0.final_mix();
342354
}
343355
}
344356

src/hash_quality_test.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ mod fallback_tests {
440440
#[cfg(any(
441441
all(any(target_arch = "x86", target_arch = "x86_64"), target_feature = "aes", not(miri)),
442442
all(target_arch = "aarch64", target_feature = "aes", not(miri)),
443-
all(feature = "nightly-arm-aes", target_arch = "arm", target_feature = "aes", not(miri)),
443+
all(target_arch = "arm", target_feature = "aes", not(miri)),
444444
))]
445445
#[cfg(test)]
446446
mod aes_tests {

src/lib.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ Note the import of [HashMapExt]. This is needed for the constructor.
9898
#![allow(clippy::pedantic, clippy::cast_lossless, clippy::unreadable_literal)]
9999
#![cfg_attr(all(not(test), not(feature = "std")), no_std)]
100100
#![cfg_attr(feature = "specialize", feature(min_specialization))]
101-
#![cfg_attr(feature = "nightly-arm-aes", feature(stdarch_arm_neon_intrinsics))]
102101

103102
#[macro_use]
104103
mod convert;
@@ -108,8 +107,8 @@ mod fallback_hash;
108107
cfg_if::cfg_if! {
109108
if #[cfg(any(
110109
all(any(target_arch = "x86", target_arch = "x86_64"), target_feature = "aes", not(miri)),
111-
all(feature = "nightly-arm-aes", target_arch = "aarch64", target_feature = "aes", not(miri)),
112-
all(feature = "nightly-arm-aes", target_arch = "arm", target_feature = "aes", not(miri)),
110+
all(target_arch = "aarch64", target_feature = "aes", not(miri)),
111+
all(target_arch = "arm", target_feature = "aes", not(miri)),
113112
))] {
114113
mod aes_hash;
115114
pub use crate::aes_hash::AHasher;

src/operations.rs

+6-10
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ pub(crate) fn aesenc(value: u128, xor: u128) -> u128 {
112112
}
113113

114114
#[cfg(any(
115-
all(feature = "nightly-arm-aes", target_arch = "aarch64", target_feature = "aes", not(miri)),
116-
all(feature = "nightly-arm-aes", target_arch = "arm", target_feature = "aes", not(miri)),
115+
all(target_arch = "aarch64", target_feature = "aes", not(miri)),
116+
all(target_arch = "arm", target_feature = "aes", not(miri)),
117117
))]
118118
#[allow(unused)]
119119
#[inline(always)]
@@ -122,9 +122,7 @@ pub(crate) fn aesenc(value: u128, xor: u128) -> u128 {
122122
use core::arch::aarch64::*;
123123
#[cfg(target_arch = "arm")]
124124
use core::arch::arm::*;
125-
let res = unsafe { vaesmcq_u8(vaeseq_u8(transmute!(value), transmute!(0u128))) };
126-
let value: u128 = transmute!(res);
127-
xor ^ value
125+
unsafe { transmute!(vaeseq_u8(transmute!(value), transmute!(xor))) }
128126
}
129127

130128
#[cfg(all(any(target_arch = "x86", target_arch = "x86_64"), target_feature = "aes", not(miri)))]
@@ -142,8 +140,8 @@ pub(crate) fn aesdec(value: u128, xor: u128) -> u128 {
142140
}
143141

144142
#[cfg(any(
145-
all(feature = "nightly-arm-aes", target_arch = "aarch64", target_feature = "aes", not(miri)),
146-
all(feature = "nightly-arm-aes", target_arch = "arm", target_feature = "aes", not(miri)),
143+
all(target_arch = "aarch64", target_feature = "aes", not(miri)),
144+
all(target_arch = "arm", target_feature = "aes", not(miri)),
147145
))]
148146
#[allow(unused)]
149147
#[inline(always)]
@@ -152,9 +150,7 @@ pub(crate) fn aesdec(value: u128, xor: u128) -> u128 {
152150
use core::arch::aarch64::*;
153151
#[cfg(target_arch = "arm")]
154152
use core::arch::arm::*;
155-
let res = unsafe { vaesimcq_u8(vaesdq_u8(transmute!(value), transmute!(0u128))) };
156-
let value: u128 = transmute!(res);
157-
xor ^ value
153+
unsafe { transmute!(vaesdq_u8(transmute!(value), transmute!(xor))) }
158154
}
159155

160156
#[allow(unused)]

src/random_state.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ use core::hash::Hash;
22
cfg_if::cfg_if! {
33
if #[cfg(any(
44
all(any(target_arch = "x86", target_arch = "x86_64"), target_feature = "aes", not(miri)),
5-
all(feature = "nightly-arm-aes", target_arch = "aarch64", target_feature = "aes", not(miri)),
6-
all(feature = "nightly-arm-aes", target_arch = "arm", target_feature = "aes", not(miri)),
5+
all(target_arch = "aarch64", target_feature = "aes", not(miri)),
6+
all(target_arch = "arm", target_feature = "aes", not(miri)),
77
))] {
88
use crate::aes_hash::*;
99
} else {

tests/bench.rs

+2-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![cfg_attr(feature = "specialize", feature(build_hasher_simple_hash_one))]
21

32
use ahash::{AHasher, RandomState};
43
use criterion::*;
@@ -14,13 +13,8 @@ const AHASH_IMPL: &str = if cfg!(any(
1413
target_feature = "aes",
1514
not(miri),
1615
),
17-
all(feature = "nightly-arm-aes", target_arch = "aarch64", target_feature = "aes", not(miri)),
18-
all(
19-
feature = "nightly-arm-aes",
20-
target_arch = "arm",
21-
target_feature = "aes",
22-
not(miri)
23-
),
16+
all(target_arch = "aarch64", target_feature = "aes", not(miri)),
17+
all(target_arch = "arm", target_feature = "aes", not(miri)),
2418
)) {
2519
"aeshash"
2620
} else {

tests/map_tests.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![cfg_attr(feature = "specialize", feature(build_hasher_simple_hash_one))]
21

32
use std::hash::{BuildHasher, Hash, Hasher};
43

0 commit comments

Comments
 (0)