Skip to content

Conversation

@overlookmotel
Copy link
Member

@overlookmotel overlookmotel commented Nov 5, 2025

We are generally using Address::from_ptr to get the Address of a reference, relying on &T dereferencing to *const T.

Add an explicit method Address::from_ref for this, and document its pitfalls (which are the same as Address::from_ptr).

Update all uses of from_ptr to from_ref, except those in oxc_traverse, where creating references is not possible due to aliasing rules.

Once that problem is solved, we can make from_ptr take a NonNull<T> instead of *const T, and make Address's inner type a NonZeroUsize, which will give Address a niche, and reduce Option<Address> from 16 bytes to 8.

@github-actions github-actions bot added A-linter Area - Linter A-semantic Area - Semantic A-ast Area - AST A-transformer Area - Transformer / Transpiler A-ast-tools Area - AST tools A-formatter Area - Formatter labels Nov 5, 2025
Copy link
Member Author

overlookmotel commented Nov 5, 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.

@github-actions github-actions bot added the C-enhancement Category - New feature or request label Nov 5, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented Nov 5, 2025

CodSpeed Performance Report

Merging #15318 will not alter performance

Comparing 11-05-feat_allocator_add_address_from_ref_method (52cf6a3) with main (977a6a0)1

Summary

✅ 37 untouched

Footnotes

  1. No successful run was found on 11-05-chore_deps_bump_msrv_to_1.89.0 (971f718) during the generation of this report, so main (977a6a0) 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 November 5, 2025 12:13
@overlookmotel overlookmotel self-assigned this Nov 5, 2025
@overlookmotel overlookmotel added the 0-merge Merge with Graphite Merge Queue label Nov 5, 2025
Copy link
Member Author

overlookmotel commented Nov 5, 2025

Merge activity

We are generally using `Address::from_ptr` to get the `Address` of a reference, relying on `&T` dereferencing to `*const T`.

Add an explicit method `Address::from_ref` for this, and document its pitfalls (which are the same as `Address::from_ptr`).

Update all uses of `from_ptr` to `from_ref`, except those in `oxc_traverse`, where creating references is not possible due to aliasing rules.

Once that problem is solved, we can make `from_ptr` take a `NonNull<T>` instead of `*const T`, and make `Address`'s inner type a `NonZeroUsize`, which will give `Address` a niche, and reduce `Option<Address>` from 16 bytes to 8.
@graphite-app graphite-app bot force-pushed the 11-05-chore_deps_bump_msrv_to_1.89.0 branch from 971f718 to a64cf11 Compare November 5, 2025 12:16
@graphite-app graphite-app bot force-pushed the 11-05-feat_allocator_add_address_from_ref_method branch from 52cf6a3 to 8d69661 Compare November 5, 2025 12:17
Base automatically changed from 11-05-chore_deps_bump_msrv_to_1.89.0 to main November 5, 2025 12:22
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Nov 5, 2025
@graphite-app graphite-app bot merged commit 8d69661 into main Nov 5, 2025
22 checks passed
@graphite-app graphite-app bot deleted the 11-05-feat_allocator_add_address_from_ref_method branch November 5, 2025 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-ast Area - AST A-ast-tools Area - AST tools A-formatter Area - Formatter A-linter Area - Linter A-semantic Area - Semantic 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.

2 participants