Skip to content

feat(allocator): TakeIn trait with AllocatorAccessor#11201

Merged
graphite-app[bot] merged 1 commit intomainfrom
05-20-feat_allocator_takein_trait_with_allocatoraccessor_
May 21, 2025
Merged

feat(allocator): TakeIn trait with AllocatorAccessor#11201
graphite-app[bot] merged 1 commit intomainfrom
05-20-feat_allocator_takein_trait_with_allocatoraccessor_

Conversation

@Boshen
Copy link
Member

@Boshen Boshen commented May 21, 2025

closes #10314

Copilot AI review requested due to automatic review settings May 21, 2025 01:59
@github-actions github-actions bot added A-parser Area - Parser A-minifier Area - Minifier A-ast Area - AST A-transformer Area - Transformer / Transpiler A-isolated-declarations Isolated Declarations C-enhancement Category - New feature or request labels May 21, 2025
Copy link
Member Author

Boshen commented May 21, 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.

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

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 AllocatorAccessor trait with implementations for &Allocator and AstBuilder
  • Change TakeIn::take_in to accept any AllocatorAccessor instead of a raw &Allocator
  • Bulk-update all peephole passes and builders to call take_in(ctx.ast) rather than take_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_in method signature should explain that it now takes an AllocatorAccessor rather 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 AllocatorAccessor works correctly with both &Allocator and AstBuilder implementations.
impl<'a> AllocatorAccessor<'a> for &'a Allocator {

@codspeed-hq
Copy link

codspeed-hq bot commented May 21, 2025

CodSpeed Instrumentation Performance Report

Merging #11201 will degrade performances by 12.71%

Comparing 05-20-feat_allocator_takein_trait_with_allocatoraccessor_ (03390ad) with main (23182b8)

Summary

❌ 1 regressions
✅ 37 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark BASE HEAD Change
mangler[cal.com.tsx] 3 ms 3.5 ms -12.71%

@Boshen Boshen added the 0-merge Merge with Graphite Merge Queue label May 21, 2025
@graphite-app
Copy link
Contributor

graphite-app bot commented May 21, 2025

Merge activity

graphite-app bot pushed a commit that referenced this pull request May 21, 2025
@graphite-app graphite-app bot force-pushed the 05-20-feat_allocator_takein_trait_with_allocatoraccessor_ branch from 6df3a47 to 80c1be3 Compare May 21, 2025 03:14
@graphite-app graphite-app bot force-pushed the 05-20-feat_allocator_takein_trait_with_allocatoraccessor_ branch from 80c1be3 to 03390ad Compare May 21, 2025 03:20
@graphite-app graphite-app bot merged commit 03390ad into main May 21, 2025
25 checks passed
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label May 21, 2025
@graphite-app graphite-app bot deleted the 05-20-feat_allocator_takein_trait_with_allocatoraccessor_ branch May 21, 2025 03:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-ast Area - AST A-isolated-declarations Isolated Declarations A-minifier Area - Minifier A-parser Area - Parser A-transformer Area - Transformer / Transpiler C-enhancement Category - New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add AstBuilder::take method

2 participants