feat(allocator): TakeIn trait with AllocatorAccessor#11201
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. |
There was a problem hiding this comment.
Pull Request Overview
Adds an AllocatorAccessor trait to abstract over allocator ownership and updates all .take_in(ctx.ast.allocator) calls to use the new generic take_in(ctx.ast) API.
- Introduce
AllocatorAccessortrait with implementations for&AllocatorandAstBuilder - Change
TakeIn::take_into accept anyAllocatorAccessorinstead of a raw&Allocator - Bulk-update all peephole passes and builders to call
take_in(ctx.ast)rather thantake_in(ctx.ast.allocator)
Reviewed Changes
Copilot reviewed 50 out of 50 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| crates/oxc_allocator/src/accessor.rs | New trait AllocatorAccessor for allocator access |
| crates/oxc_allocator/src/take_in.rs | Updated TakeIn::take_in to use AllocatorAccessor |
| crates/oxc_ast/src/ast_builder_impl.rs | Impl AllocatorAccessor for AstBuilder |
All crates/oxc_minifier/src/peephole/*.rs |
Replaced .take_in(ctx.ast.allocator) with .take_in(ctx.ast) |
| crates/oxc_isolated_declarations/src/module.rs | One replacement in isolated declarations module |
Comments suppressed due to low confidence (2)
crates/oxc_allocator/src/take_in.rs:8
- [nitpick] Doc comment for the updated
take_inmethod signature should explain that it now takes anAllocatorAccessorrather than a raw&Allocator.
pub trait TakeIn<'a>: Dummy<'a> {
crates/oxc_allocator/src/accessor.rs:9
- [nitpick] Consider adding a small unit test to verify that
AllocatorAccessorworks correctly with both&AllocatorandAstBuilderimplementations.
impl<'a> AllocatorAccessor<'a> for &'a Allocator {
CodSpeed Instrumentation Performance ReportMerging #11201 will degrade performances by 12.71%Comparing Summary
Benchmarks breakdown
|
Merge activity
|
6df3a47 to
80c1be3
Compare
80c1be3 to
03390ad
Compare

closes #10314