Skip to content

refactor(allocator/fixed-size): return Result from allocation instead of panicking#17022

Merged
overlookmotel merged 2 commits intomainfrom
c/12-17-refactor_allocator_fixed-size_return_result_from_allocation_instead_of_panicking
Dec 18, 2025
Merged

refactor(allocator/fixed-size): return Result from allocation instead of panicking#17022
overlookmotel merged 2 commits intomainfrom
c/12-17-refactor_allocator_fixed-size_return_result_from_allocation_instead_of_panicking

Conversation

@camc314
Copy link
Contributor

@camc314 camc314 commented Dec 17, 2025

No description provided.

@github-actions github-actions bot added the C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior label Dec 17, 2025
Copy link
Contributor Author

camc314 commented Dec 17, 2025


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 hot fixes, skip the queue and merge this PR next

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.

@camc314 camc314 marked this pull request as ready for review December 17, 2025 23:09
Copilot AI review requested due to automatic review settings December 17, 2025 23:09
@camc314 camc314 changed the title refactor(allocator/fixed-size)!: return Result from allocation instead of panicking refactor(allocator/fixed-size): return Result from allocation instead of panicking Dec 17, 2025
Copy link
Contributor Author

@camc314 camc314 left a comment

Choose a reason for hiding this comment

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

I didn't mark this as breaking as I don't believe FixedSizeAllocator is public

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

This PR refactors the fixed-size allocator to return a Result from allocation instead of panicking directly, making error handling more explicit while maintaining backward compatibility through immediate unwrapping at call sites. The change introduces a new AllocError type that captures allocation layout information for better error reporting.

Key Changes

  • Introduced AllocError struct with Display and Error trait implementations for descriptive allocation failure messages
  • Converted FixedSizeAllocator::new() to try_new() returning Result<Self, AllocError>
  • Updated panic documentation in the public API to reflect allocation failure conditions

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
crates/oxc_allocator/src/pool/mod.rs Updated documentation for the public get() method to document panic conditions for fixed-size allocator allocation failures
crates/oxc_allocator/src/pool/fixed_size.rs Added AllocError type, refactored new() to try_new() returning Result, and removed direct panic via alloc::handle_alloc_error()

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codspeed-hq
Copy link

codspeed-hq bot commented Dec 17, 2025

CodSpeed Performance Report

Merging #17022 will not alter performance

Comparing c/12-17-refactor_allocator_fixed-size_return_result_from_allocation_instead_of_panicking (63c3286) with main (005ec25)

Summary

✅ 42 untouched
⏩ 3 skipped1

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.

@camc314 camc314 force-pushed the c/12-17-refactor_allocator_fixed-size_return_result_from_allocation_instead_of_panicking branch 2 times, most recently from 4f715fe to 477d0fd Compare December 18, 2025 00:05
@camc314 camc314 force-pushed the c/12-17-refactor_allocator_fixed-size_return_result_from_allocation_instead_of_panicking branch from 49217f5 to efa712a Compare December 18, 2025 11:32
Copy link
Member

@overlookmotel overlookmotel left a comment

Choose a reason for hiding this comment

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

Pushed a nit commit. Otherwise, all good.

@overlookmotel overlookmotel merged commit 1e2d011 into main Dec 18, 2025
28 checks passed
@overlookmotel overlookmotel deleted the c/12-17-refactor_allocator_fixed-size_return_result_from_allocation_instead_of_panicking branch December 18, 2025 22:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-linter-plugins Area - Linter JS plugins 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.

3 participants