Skip to content

refactor(allocator): reduce scope of unsafe blocks in Arena::new_chunk#21863

Merged
graphite-app[bot] merged 1 commit into
mainfrom
om/04-26-refactor_allocator_reduce_scope_of_unsafe_blocks_in_arena_new_chunk_
Apr 27, 2026
Merged

refactor(allocator): reduce scope of unsafe blocks in Arena::new_chunk#21863
graphite-app[bot] merged 1 commit into
mainfrom
om/04-26-refactor_allocator_reduce_scope_of_unsafe_blocks_in_arena_new_chunk_

Conversation

@overlookmotel

@overlookmotel overlookmotel commented Apr 27, 2026

Copy link
Copy Markdown
Member

Refactor Arena::new_chunk. Previously there was a single large unsafe { ... } block. Split it into smaller blocks wrapping only statements that require an unsafe block, and document the safety conditions.

overlookmotel commented Apr 27, 2026

Copy link
Copy Markdown
Member Author

@codspeed-hq

codspeed-hq Bot commented Apr 27, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 48 untouched benchmarks
⏩ 3 skipped benchmarks1


Comparing om/04-26-refactor_allocator_reduce_scope_of_unsafe_blocks_in_arena_new_chunk_ (2de093c) with main (e7f8d55)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 (2de093c) during the generation of this report, so e7f8d55 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

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

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

Refactors Arena::new_chunk in oxc_allocator to reduce the scope of unsafe by splitting one large unsafe { ... } block into smaller, statement-level unsafe blocks with accompanying safety documentation.

Changes:

  • Split allocation, pointer arithmetic, and footer initialization into separate unsafe blocks.
  • Added/updated safety comments documenting preconditions for each unsafe operation.
  • Added an additional debug assertion related to allocation size.

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

graphite-app Bot commented Apr 27, 2026

Copy link
Copy Markdown
Contributor

Merge activity

…hunk` (#21863)

Refactor `Arena::new_chunk`. Previously there was a single large `unsafe { ... }` block. Split it into smaller blocks wrapping only statements that require an `unsafe` block, and document the safety conditions.
@graphite-app graphite-app Bot force-pushed the om/04-26-refactor_allocator_reduce_scope_of_unsafe_blocks_in_arena_new_chunk_ branch from a480bcb to 2de093c Compare April 27, 2026 23:31
@graphite-app graphite-app Bot merged commit 2de093c into main Apr 27, 2026
36 checks passed
@graphite-app graphite-app Bot deleted the om/04-26-refactor_allocator_reduce_scope_of_unsafe_blocks_in_arena_new_chunk_ branch April 27, 2026 23:37
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