Skip to content

refactor(allocator): remove conversions to/from NonNull pointers#21737

Merged
graphite-app[bot] merged 1 commit intomainfrom
om/04-24-refactor_allocator_remove_conversions_to_from_nonnull_pointers
Apr 25, 2026
Merged

refactor(allocator): remove conversions to/from NonNull pointers#21737
graphite-app[bot] merged 1 commit intomainfrom
om/04-24-refactor_allocator_remove_conversions_to_from_nonnull_pointers

Conversation

@overlookmotel
Copy link
Copy Markdown
Member

@overlookmotel overlookmotel commented Apr 25, 2026

Refactor to Arena. Simplify code and reduce unsafe by avoiding round-trip conversions between NonNull and *mut pointers.

Copy link
Copy Markdown
Member Author

overlookmotel commented Apr 25, 2026


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
Copy link
Copy Markdown

codspeed-hq Bot commented Apr 25, 2026

Merging this PR will not alter performance

✅ 48 untouched benchmarks
⏩ 3 skipped benchmarks1


Comparing om/04-24-refactor_allocator_remove_conversions_to_from_nonnull_pointers (3aadfcd) 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 (3aadfcd) 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 08:50
Copilot AI review requested due to automatic review settings April 25, 2026 08:50
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Refactors oxc_allocator::arena pointer handling to reduce unsafe complexity by avoiding round-trip conversions between NonNull<T> and raw pointers while keeping allocation semantics unchanged.

Changes:

  • Replace several raw-pointer operations (ptr::eq, ptr::write, ptr::copy*, slice_from_raw_parts_mut) with NonNull-native APIs (from_ref, write, copy_from*, slice_from_raw_parts).
  • Introduce round_nonnull_ptr_up_to_unchecked to perform alignment rounding directly on NonNull<u8>.
  • Simplify chunk footer creation/initialization by keeping pointer arithmetic in NonNull space.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
crates/oxc_allocator/src/arena/utils.rs Adds round_nonnull_ptr_up_to_unchecked to align NonNull<u8> without converting to/from raw pointers.
crates/oxc_allocator/src/arena/mod.rs Uses NonNull::from_ref equality for empty-chunk sentinel detection.
crates/oxc_allocator/src/arena/from_raw_parts.rs Switches cursor validation to NonNull comparisons and shared alignment helper.
crates/oxc_allocator/src/arena/create.rs Builds footer/cursor pointers and writes ChunkFooter using NonNull methods.
crates/oxc_allocator/src/arena/chunks.rs Uses NonNull-based pointer math/ordering for chunk iteration and length computation.
crates/oxc_allocator/src/arena/alloc_impl.rs Replaces raw pointer arithmetic and ptr::copy* with NonNull equivalents; updates allocator slice construction.
crates/oxc_allocator/src/arena/alloc.rs Uses NonNull writing/slice construction helpers to reduce raw pointer usage during initialization/copying.

@graphite-app
Copy link
Copy Markdown
Contributor

graphite-app Bot commented Apr 25, 2026

Merge activity

…21737)

Refactor to `Arena`. Simplify code and reduce unsafe by avoiding round-trip conversions between `NonNull` and `*mut` pointers.
@graphite-app graphite-app Bot force-pushed the om/04-24-refactor_allocator_remove_conversions_to_from_nonnull_pointers branch from 98805a7 to 3aadfcd Compare April 25, 2026 11:22
@graphite-app graphite-app Bot merged commit 3aadfcd into main Apr 25, 2026
36 checks passed
@graphite-app graphite-app Bot deleted the om/04-24-refactor_allocator_remove_conversions_to_from_nonnull_pointers branch April 25, 2026 11:27
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