Skip to content

Use bytemuck::Zeroable for zeroable types.#1371

Merged
wks merged 1 commit intommtk:masterfrom
wks:feature/use-zeroable
Aug 15, 2025
Merged

Use bytemuck::Zeroable for zeroable types.#1371
wks merged 1 commit intommtk:masterfrom
wks:feature/use-zeroable

Conversation

@wks
Copy link
Copy Markdown
Collaborator

@wks wks commented Aug 14, 2025

Our utility function zeroed_alloc::new_zeroed_vec<T> now requires the element type <T> to implement bytemuck::Zeroable, a marker trait which means the type can be safely initialized with all zero bits. new_zeroed_vec is no longer unsafe.

SpaceDescriptor now implements Zeroable because a zero value represents SpaceDescriptor::UNINITIALIZED.

Map32 now uses new_zeroed_vec for allocating the descriptor_map because when used on 64-bit machines (usually with compressed pointers), the number of chunks can still be large.

Our utility function `zeroed_alloc::new_zeroed_vec<T>` now requires the
element type `<T>` to implement `bytemuck::Zeroable`, a marker trait
which means the type can be safely initialized with all zero bits.
`new_zeroed_vec` is no longer `unsafe`.

`SpaceDescriptor` now implements `Zeroable` because a zero value
represents `SpaceDescriptor::UNINITIALIZED`.

`Map32` now uses `new_zeroed_vec` for allocating the `descriptor_map`
because when used on 64-bit machines (usually with compressed pointers),
the number of chunks can still be large.
@wks wks requested a review from qinsoon August 14, 2025 10:01
Copy link
Copy Markdown
Member

@qinsoon qinsoon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@wks wks added this pull request to the merge queue Aug 15, 2025
Merged via the queue into mmtk:master with commit 0721d12 Aug 15, 2025
32 checks passed
@wks wks deleted the feature/use-zeroable branch August 15, 2025 01:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants