refactor(allocator): is_pointer_aligned_to take any pointer#21740
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
0930b77 to
faed9a1
Compare
Merging this PR will not alter performance
Comparing Footnotes
|
There was a problem hiding this comment.
Pull request overview
This PR refactors the arena::utils::is_pointer_aligned_to helper to accept multiple pointer representations (*const, *mut, NonNull) via a small trait, simplifying call sites across the arena allocator implementation.
Changes:
- Introduce a
Pointertrait inarena::utilsto abstract extracting a pointer address. - Update
is_pointer_aligned_toto be generic overPointer. - Replace
*.as_ptr()conversions at call sites with directNonNull<T>usage.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| crates/oxc_allocator/src/arena/utils.rs | Adds Pointer trait and updates is_pointer_aligned_to signature to accept multiple pointer types. |
| crates/oxc_allocator/src/arena/from_raw_parts.rs | Simplifies debug alignment assertions by passing NonNull directly. |
| crates/oxc_allocator/src/arena/drop.rs | Simplifies alignment assertion by passing NonNull directly. |
| crates/oxc_allocator/src/arena/create.rs | Uses direct NonNull arguments in alignment debug assertions. |
| crates/oxc_allocator/src/arena/alloc_impl.rs | Simplifies alignment checks (including a non-debug alignment branch) by passing NonNull directly. |
Merge activity
|
Make `is_pointer_aligned_to` helper function take any pointer (`*const`, `*mut`, `NonNull`). This shortens code at call sites, making it easier to see what's being checked.
cecb127 to
b9bf239
Compare
faed9a1 to
2e2bb90
Compare

Make
is_pointer_aligned_tohelper function take any pointer (*const,*mut,NonNull). This shortens code at call sites, making it easier to see what's being checked.