Skip to content

Commit e9e907a

Browse files
committed
Reduce branch precision down to 64 bits
1 parent 3d475e5 commit e9e907a

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

compiler/rustc_data_structures/src/sync/branch_key.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
use std::cmp;
22

33
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
4-
pub struct BranchKey(u128);
4+
pub struct BranchKey(u64);
55

66
impl BranchKey {
77
pub const fn root() -> Self {
8-
Self(0x80000000_00000000_00000000_00000000)
8+
Self(0x80000000_00000000)
99
}
1010

11-
fn bits_branch(self, branch_num: u128, bits: u32) -> Result<Self, BranchNestingError> {
11+
fn bits_branch(self, branch_num: u64, bits: u32) -> Result<Self, BranchNestingError> {
1212
let trailing_zeros = self.0.trailing_zeros();
1313
let allocated_shift = trailing_zeros.checked_sub(bits).ok_or(BranchNestingError(()))?;
1414
Ok(BranchKey(
@@ -18,7 +18,7 @@ impl BranchKey {
1818
))
1919
}
2020

21-
pub fn branch(self, branch_num: u128, branch_space: u128) -> BranchKey {
21+
pub fn branch(self, branch_num: u64, branch_space: u64) -> BranchKey {
2222
debug_assert!(
2323
branch_num < branch_space,
2424
"branch_num = {branch_num} should be less than branch_space = {branch_space}"
@@ -35,7 +35,7 @@ impl BranchKey {
3535
pub fn nest(self, then: Self) -> Result<Self, BranchNestingError> {
3636
let trailing_zeros = then.0.trailing_zeros();
3737
let branch_num = then.0.wrapping_shr(trailing_zeros + 1);
38-
let bits = u128::BITS - trailing_zeros;
38+
let bits = u64::BITS - trailing_zeros;
3939
self.bits_branch(branch_num, bits)
4040
}
4141
}

compiler/rustc_middle/src/sync.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ macro_rules! parallel {
5656
}
5757

5858
// This function only works when `is_dyn_thread_safe()`.
59-
pub fn scope<'scope, OP, R>(spawn_limit: u128, op: OP) -> R
59+
pub fn scope<'scope, OP, R>(spawn_limit: u64, op: OP) -> R
6060
where
6161
OP: for<'a, 'tcx> FnOnce(Scope<'a, 'scope>) -> R + DynSend,
6262
R: DynSend,
@@ -70,8 +70,8 @@ where
7070

7171
pub struct Scope<'a, 'scope> {
7272
scope: &'a rustc_thread_pool::Scope<'scope>,
73-
branch_limit: u128,
74-
next_branch: u128,
73+
branch_limit: u64,
74+
next_branch: u64,
7575
}
7676

7777
impl<'a, 'scope> Scope<'a, 'scope> {

0 commit comments

Comments
 (0)