Skip to content

refactor(ast_tools): simplify struct field reordering#20587

Merged
graphite-app[bot] merged 1 commit intomainfrom
om/02-15-refactor_ast_tools_simplify_struct_field_reordering
Mar 20, 2026
Merged

refactor(ast_tools): simplify struct field reordering#20587
graphite-app[bot] merged 1 commit intomainfrom
om/02-15-refactor_ast_tools_simplify_struct_field_reordering

Conversation

@overlookmotel
Copy link
Copy Markdown
Member

@overlookmotel overlookmotel commented Mar 20, 2026

Follow-on after #20584. Simplify implementation of struct field ordering in ast_tools. This change does not alter any layouts, just shortens the code by taking a simpler approach to handling ZST fields.

Copy link
Copy Markdown
Member Author

overlookmotel commented Mar 20, 2026


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 changes, fast-track this PR to the front of 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.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Mar 20, 2026

Merging this PR will not alter performance

✅ 53 untouched benchmarks
⏩ 3 skipped benchmarks1


Comparing om/02-15-refactor_ast_tools_simplify_struct_field_reordering (3a94ef2) with om/02-15-perf_ast_mark_astkind_address_as_inline_ (79deba6)

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.

@overlookmotel overlookmotel marked this pull request as ready for review March 20, 2026 21:43
Copilot AI review requested due to automatic review settings March 20, 2026 21:43
Copy link
Copy Markdown
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

Refactors ast_tools’ struct field reordering logic by explicitly tracking field layout order (including ZSTs), simplifying how layout assertions and #[ast] field-reorder metadata are derived without changing computed sizes/alignments.

Changes:

  • Add layout_index to Offset to represent deterministic memory layout order even when ZST offsets collide.
  • Simplify struct layout calculation by removing the “collect ZSTs then append last” path and assigning layout order during field placement.
  • Update struct-details generation and assertions to sort/emit by layout_index (reflected in regenerated STRUCTS, e.g. Span).

Reviewed changes

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

File Description
tasks/ast_tools/src/schema/extensions/layout.rs Extends Offset with layout_index to disambiguate layout ordering when offsets aren’t unique.
tasks/ast_tools/src/generators/assert_layouts.rs Assigns layout_index during layout calculation; uses it for assertion ordering and StructDetails emission.
crates/oxc_ast_macros/src/generated/structs.rs Regenerated struct reorder table based on the updated layout-ordering logic.

@overlookmotel overlookmotel self-assigned this Mar 20, 2026
@overlookmotel overlookmotel force-pushed the om/02-15-refactor_ast_tools_simplify_struct_field_reordering branch from 99eaa38 to 3a94ef2 Compare March 20, 2026 22:02
@overlookmotel overlookmotel force-pushed the om/02-15-perf_ast_mark_astkind_address_as_inline_ branch from d7bf984 to 79deba6 Compare March 20, 2026 22:02
@overlookmotel overlookmotel added the 0-merge Merge with Graphite Merge Queue label Mar 20, 2026
Copy link
Copy Markdown
Member Author

overlookmotel commented Mar 20, 2026

Merge activity

Follow-on after #20584. Simplify implementation of struct field ordering in `ast_tools`. This change does not alter any layouts, just shortens the code by taking a simpler approach to handling ZST fields.
@graphite-app graphite-app bot force-pushed the om/02-15-perf_ast_mark_astkind_address_as_inline_ branch from 79deba6 to 89946e1 Compare March 20, 2026 22:21
@graphite-app graphite-app bot requested review from camc314 and leaysgur as code owners March 20, 2026 22:21
@graphite-app graphite-app bot force-pushed the om/02-15-refactor_ast_tools_simplify_struct_field_reordering branch from 3a94ef2 to 5c385af Compare March 20, 2026 22:21
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Mar 20, 2026
Base automatically changed from om/02-15-perf_ast_mark_astkind_address_as_inline_ to main March 20, 2026 22:31
@graphite-app graphite-app bot merged commit 5c385af into main Mar 20, 2026
26 checks passed
@graphite-app graphite-app bot deleted the om/02-15-refactor_ast_tools_simplify_struct_field_reordering branch March 20, 2026 22:32
costajohnt pushed a commit to costajohnt/oxc that referenced this pull request Mar 22, 2026
)

Follow-on after oxc-project#20584. Simplify implementation of struct field ordering in `ast_tools`. This change does not alter any layouts, just shortens the code by taking a simpler approach to handling ZST fields.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-ast-tools Area - AST tools 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