Skip to content

refactor(allocator): is_pointer_aligned_to take any pointer#21740

Merged
graphite-app[bot] merged 1 commit into
mainfrom
om/04-25-refactor_allocator_is_pointer_aligned_to_take_any_pointer
Apr 25, 2026
Merged

refactor(allocator): is_pointer_aligned_to take any pointer#21740
graphite-app[bot] merged 1 commit into
mainfrom
om/04-25-refactor_allocator_is_pointer_aligned_to_take_any_pointer

Conversation

@overlookmotel

@overlookmotel overlookmotel commented Apr 25, 2026

Copy link
Copy Markdown
Member

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.

overlookmotel commented Apr 25, 2026

Copy link
Copy Markdown
Member Author

How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent changes, fast-track this PR to the front of 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.

@codspeed-hq

codspeed-hq Bot commented Apr 25, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 48 untouched benchmarks
⏩ 3 skipped benchmarks1


Comparing om/04-25-refactor_allocator_is_pointer_aligned_to_take_any_pointer (2e2bb90) with main (1b97124)2

Open in CodSpeed

Footnotes

  1. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

  2. No successful run was found on main (2e2bb90) during the generation of this report, so 1b97124 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@overlookmotel overlookmotel self-assigned this Apr 25, 2026
@overlookmotel overlookmotel added C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior A-allocator Area - Allocator labels Apr 25, 2026
@overlookmotel
overlookmotel marked this pull request as ready for review April 25, 2026 09:37
Copilot AI review requested due to automatic review settings April 25, 2026 09:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 Pointer trait in arena::utils to abstract extracting a pointer address.
  • Update is_pointer_aligned_to to be generic over Pointer.
  • Replace *.as_ptr() conversions at call sites with direct NonNull<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.

Comment thread crates/oxc_allocator/src/arena/utils.rs
@graphite-app

graphite-app Bot commented Apr 25, 2026

Copy link
Copy Markdown
Contributor

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.
@graphite-app
graphite-app Bot force-pushed the om/04-24-fix_allocator_fix_ub_in_arena_grow_zeroed_ branch from cecb127 to b9bf239 Compare April 25, 2026 11:23
@graphite-app
graphite-app Bot force-pushed the om/04-25-refactor_allocator_is_pointer_aligned_to_take_any_pointer branch from faed9a1 to 2e2bb90 Compare April 25, 2026 11:24
Base automatically changed from om/04-24-fix_allocator_fix_ub_in_arena_grow_zeroed_ to main April 25, 2026 11:29
@graphite-app
graphite-app Bot merged commit 2e2bb90 into main Apr 25, 2026
37 checks passed
@graphite-app
graphite-app Bot deleted the om/04-25-refactor_allocator_is_pointer_aligned_to_take_any_pointer branch April 25, 2026 11:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-allocator Area - Allocator C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants