Skip to content

Commit 681dabd

Browse files
committed
Post-release dependency version bump for v0.21.0
Bump the version of dependencies to their latest version. The "atomic" crate, since version 0.6.0, requires the `T` in `Atomic<T>` to implement `bytemuck::NoUnint`. It is a marker trait for types that satisfies some requirements. One requirement is that `T` must not have any padding bytes (in the middle or at the end). The derive macro `#[derive(NoUninit)]` can be used on custom types to automatically check if the type satisfies its requirements. Two notable types are: 1. `enum MMapStrategy`. It is missing a representation annotation which `NoUninit` requires. This PR adds `#[repr(u8)]` to fix this. 2. `WORKER_ORDINAL: Atomic<Option<ThreadId>>`. The `Option` type does have padding bytes, making it un-eligible for `Atomic<T>`. This PR changes it to `Atomic<ThreadId>`, with `ThreadId::max` representing the uninitialized value.
1 parent a87636c commit 681dabd

File tree

6 files changed

+26
-16
lines changed

6 files changed

+26
-16
lines changed

Cargo.toml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,18 @@ crate-type = ["rlib"]
1919
doctest = false
2020

2121
[dependencies]
22-
atomic = "0.5.1"
22+
atomic = "0.6.0"
2323
atomic_refcell = "0.1.7"
2424
atomic-traits = "0.3.0"
25+
bytemuck = { version = "1.14.0", features = ["derive"] }
2526
cfg-if = "1.0"
2627
crossbeam = "0.8.1"
27-
delegate = "0.9.0"
28+
delegate = "0.10.0"
2829
downcast-rs = "1.1.1"
2930
enum-map = "2.4.2"
3031
env_logger = "0.10.0"
3132
is-terminal = "0.4.7"
32-
itertools = "0.10.5"
33+
itertools = "0.12.0"
3334
jemalloc-sys = { version = "0.5.3", features = ["disable_initial_exec_tls"], optional = true }
3435
lazy_static = "1.1"
3536
libc = "0.2"
@@ -46,17 +47,16 @@ probe = "0.5"
4647
regex = "1.7.0"
4748
spin = "0.9.5"
4849
static_assertions = "1.1.0"
49-
strum = "0.24"
50-
strum_macros = "0.24"
50+
strum = "0.25"
51+
strum_macros = "0.25"
5152
sysinfo = "0.29"
5253

5354
[dev-dependencies]
5455
paste = "1.0.8"
5556
rand = "0.8.5"
5657

5758
[build-dependencies]
58-
# Fix to 0.6.0. Updating to 0.6.1 requires MSRV 1.64.
59-
built = { version = "=0.6.0", features = ["git2"] }
59+
built = { version = "0.7.1", features = ["git2"] }
6060

6161
[features]
6262
default = []

src/scheduler/worker.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,18 @@ pub type ThreadId = usize;
1919

2020
thread_local! {
2121
/// Current worker's ordinal
22-
static WORKER_ORDINAL: Atomic<Option<ThreadId>> = Atomic::new(None);
22+
static WORKER_ORDINAL: Atomic<ThreadId> = Atomic::new(ThreadId::MAX);
2323
}
2424

2525
/// Get current worker ordinal. Return `None` if the current thread is not a worker.
26-
pub fn current_worker_ordinal() -> Option<ThreadId> {
27-
WORKER_ORDINAL.with(|x| x.load(Ordering::Relaxed))
26+
pub fn current_worker_ordinal() -> ThreadId {
27+
let ordinal = WORKER_ORDINAL.with(|x| x.load(Ordering::Relaxed));
28+
debug_assert_ne!(
29+
ordinal,
30+
ThreadId::MAX,
31+
"Thread-local variable WORKER_ORDINAL not set yet."
32+
);
33+
ordinal
2834
}
2935

3036
/// The part shared between a GCWorker and the scheduler.
@@ -360,7 +366,7 @@ impl<VM: VMBinding> GCWorker<VM> {
360366
/// Each worker will keep polling and executing work packets in a loop.
361367
pub fn run(&mut self, tls: VMWorkerThread, mmtk: &'static MMTK<VM>) {
362368
probe!(mmtk, gcworker_run);
363-
WORKER_ORDINAL.with(|x| x.store(Some(self.ordinal), Ordering::SeqCst));
369+
WORKER_ORDINAL.with(|x| x.store(self.ordinal, Ordering::SeqCst));
364370
self.scheduler.resolve_affinity(self.ordinal);
365371
self.tls = tls;
366372
self.copy = crate::plan::create_gc_worker_context(tls, mmtk);

src/util/address.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use atomic_traits::Atomic;
2+
use bytemuck::NoUninit;
23

34
use std::fmt;
45
use std::mem;
@@ -18,7 +19,7 @@ pub type ByteOffset = isize;
1819
/// (memory wise and time wise). The idea is from the paper
1920
/// High-level Low-level Programming (VEE09) and JikesRVM.
2021
#[repr(transparent)]
21-
#[derive(Copy, Clone, Eq, Hash, PartialOrd, Ord, PartialEq)]
22+
#[derive(Copy, Clone, Eq, Hash, PartialOrd, Ord, PartialEq, NoUninit)]
2223
pub struct Address(usize);
2324

2425
/// Address + ByteSize (positive)
@@ -477,7 +478,7 @@ use crate::vm::VMBinding;
477478
/// methods in [`crate::vm::ObjectModel`]. Major refactoring is needed in MMTk to allow
478479
/// the opaque `ObjectReference` type, and we haven't seen a use case for now.
479480
#[repr(transparent)]
480-
#[derive(Copy, Clone, Eq, Hash, PartialOrd, Ord, PartialEq)]
481+
#[derive(Copy, Clone, Eq, Hash, PartialOrd, Ord, PartialEq, NoUninit)]
481482
pub struct ObjectReference(usize);
482483

483484
impl ObjectReference {

src/util/heap/blockpageresource.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ impl<B: Region> BlockPool<B> {
309309
/// Push a block to the thread-local queue
310310
pub fn push(&self, block: B) {
311311
self.count.fetch_add(1, Ordering::SeqCst);
312-
let id = crate::scheduler::current_worker_ordinal().unwrap();
312+
let id = crate::scheduler::current_worker_ordinal();
313313
let failed = unsafe {
314314
self.worker_local_freed_blocks[id]
315315
.push_relaxed(block)

src/util/heap/layout/mmapper.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use crate::util::memory::*;
33
use crate::util::rust_util::rev_group::RevisitableGroupByForIterator;
44
use crate::util::Address;
55
use atomic::{Atomic, Ordering};
6+
use bytemuck::NoUninit;
67
use std::io::Result;
78

89
/// Generic mmap and protection functionality
@@ -65,7 +66,7 @@ pub trait Mmapper: Sync {
6566

6667
/// The mmap state of a mmap chunk.
6768
#[repr(u8)]
68-
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
69+
#[derive(Copy, Clone, PartialEq, Eq, Debug, NoUninit)]
6970
pub(super) enum MapState {
7071
/// The chunk is unmapped and not managed by MMTk.
7172
Unmapped,

src/util/memory.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use crate::util::alloc::AllocationError;
22
use crate::util::opaque_pointer::*;
33
use crate::util::Address;
44
use crate::vm::{Collection, VMBinding};
5+
use bytemuck::NoUninit;
56
use libc::{PROT_EXEC, PROT_NONE, PROT_READ, PROT_WRITE};
67
use std::io::{Error, Result};
78
use sysinfo::{RefreshKind, System, SystemExt};
@@ -61,7 +62,8 @@ const MMAP_FLAGS: libc::c_int = libc::MAP_ANON | libc::MAP_PRIVATE | libc::MAP_F
6162
/// This currently supports switching between different huge page allocation
6263
/// methods. However, this can later be refactored to reduce other code
6364
/// repetition.
64-
#[derive(Debug, Copy, Clone)]
65+
#[repr(u8)]
66+
#[derive(Debug, Copy, Clone, NoUninit)]
6567
pub enum MmapStrategy {
6668
/// The default mmap strategy.
6769
Normal,

0 commit comments

Comments
 (0)