Skip to content

feat(minifier): exit point optimization#23914

Draft
armano2 wants to merge 24 commits into
oxc-project:mainfrom
armano2:fix/drop-statements
Draft

feat(minifier): exit point optimization#23914
armano2 wants to merge 24 commits into
oxc-project:mainfrom
armano2:fix/drop-statements

Conversation

@armano2

@armano2 armano2 commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

expanded version of break/continue/return optimization

  • break/continue with label is ignored (i will implement it after this)
  • this pr focuses only on removal of safe elements thus, there is no rewriting of conditions
    for (x in y) { if (a()) {b(); continue;} else; c(); }
  • expanded logic from switch optimization PR

@armano2 armano2 changed the title fix: implement exit point optimization feat(minifier): implement exit point optimization Jun 29, 2026
@armano2
armano2 requested a review from camc314 as a code owner June 29, 2026 00:48
@armano2
armano2 marked this pull request as draft June 29, 2026 00:54
@codspeed-hq

codspeed-hq Bot commented Jun 29, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 67 untouched benchmarks
⏩ 9 skipped benchmarks1


Comparing armano2:fix/drop-statements (9474b97) with main (661b1be)2

Open in CodSpeed

Footnotes

  1. 9 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.

  2. No successful run was found on main (3446ee7) during the generation of this report, so 661b1be was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@armano2
armano2 marked this pull request as ready for review June 29, 2026 02:02
@armano2 armano2 changed the title feat(minifier): implement exit point optimization feat(minifier): Exit point optimization Jun 29, 2026
@armano2 armano2 changed the title feat(minifier): Exit point optimization feat(minifier): exit point optimization Jun 29, 2026
@camc314 camc314 added the A-minifier Area - Minifier label Jun 30, 2026
@Dunqing Dunqing self-assigned this Jul 2, 2026
@Dunqing

Dunqing commented Jul 2, 2026

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bbf37e7315

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/oxc_minifier/src/peephole/minimize_exit_points.rs Outdated
@armano2

armano2 commented Jul 4, 2026

Copy link
Copy Markdown
Contributor Author

@Dunqing let me know if you see anything wrong

@armano2

armano2 commented Jul 15, 2026

Copy link
Copy Markdown
Contributor Author

i'm actually debating if this is correct way to implement this, doing recursive loop over all child's is not ideal, this could be done way cleaner if we could trace up, or we would store information if current statement block is last within scope

@armano2

armano2 commented Jul 18, 2026

Copy link
Copy Markdown
Contributor Author

sadly there is no way to check this with ancestry, as we can't in safe way check if an last element :(

@armano2

armano2 commented Jul 19, 2026

Copy link
Copy Markdown
Contributor Author

after further investigation, it looks like this should not be needed,
as long as we correctly rewrite conditions we do not have to do deeply check's

eg. #24672

Dunqing pushed a commit that referenced this pull request Jul 20, 2026
After many trial and errors, this seem to be the best way to remove
break stmts in switch cases,

This change targets only last break in last case of switch smts if its
unlabelled

this change differs from #23914 as its no longer targets all branches as
that should not be no longer necessary if all cases are correctly
rewritten

#24672

-----

cases like `switch (a) { case 3: if (b) break; }` are not changed

-----

ref: #17544
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-minifier Area - Minifier

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants