Skip to content

[JSC] DFGLoopUnrollingPhase: Enforce tail and exit block unification for safe unrolling#43925

Merged
webkit-commit-queue merged 1 commit intoWebKit:mainfrom
hyjorc1:eng/JSC-DFGLoopUnrollingPhase-Enforce-tail-and-exit-block-unification-for-safe-unrolling
Apr 11, 2025
Merged

[JSC] DFGLoopUnrollingPhase: Enforce tail and exit block unification for safe unrolling#43925
webkit-commit-queue merged 1 commit intoWebKit:mainfrom
hyjorc1:eng/JSC-DFGLoopUnrollingPhase-Enforce-tail-and-exit-block-unification-for-safe-unrolling

Conversation

@hyjorc1
Copy link
Copy Markdown
Contributor

@hyjorc1 hyjorc1 commented Apr 10, 2025

1eb0a41

[JSC] DFGLoopUnrollingPhase: Enforce tail and exit block unification for safe unrolling
https://bugs.webkit.org/show_bug.cgi?id=291393
rdar://149023954

Reviewed by Yusuke Suzuki.

This patch tightens the eligibility criteria for loop unrolling by requiring
that the loop tail (block that branches back to the header) and the loop exit
block (block that exits the loop) must be the same.

This restriction ensures the loop follows a simple and well-structured control
flow pattern, making it safe for full unrolling without introducing correctness
issues or complex edge handling.

Specifically:
1. Identifies the tail block by looking for a unique predecessor of the header that dominates it.
2. Identifies the exit block as a loop body block with a successor outside the loop.
3. Skips unrolling if multiple tails, multiple exits, or mismatched tail and exit blocks are found.

This change is a preparatory step for broader loop unrolling support in the future.

* Source/JavaScriptCore/dfg/DFGLoopUnrollingPhase.cpp:
(JSC::DFG::LoopUnrollingPhase::locateTail):

Canonical link: https://commits.webkit.org/293588@main

7a13b13

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ❌ 🛠 wpe 🛠 win
✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug ❌ 🧪 wpe-wk2 🧪 win-tests
✅ 🧪 webkitperl 🧪 ios-wk2 🧪 api-mac ❌ 🧪 api-wpe
🧪 ios-wk2-wpt 🧪 mac-wk1 🛠 wpe-cairo
🛠 🧪 jsc 🧪 api-ios 🧪 mac-wk2 ✅ 🛠 gtk
🛠 🧪 jsc-arm64 ✅ 🛠 vision 🧪 mac-AS-debug-wk2 🧪 gtk-wk2
✅ 🛠 vision-sim 🧪 mac-wk2-stress 🧪 api-gtk
🧪 vision-wk2 🧪 mac-intel-wk2 🛠 playstation
✅ 🛠 🧪 unsafe-merge 🛠 tv 🛠 mac-safer-cpp ✅ 🛠 jsc-armv7
🛠 tv-sim 🧪 jsc-armv7-tests
🛠 watch
🛠 watch-sim

@hyjorc1 hyjorc1 requested a review from a team as a code owner April 10, 2025 23:13
@hyjorc1 hyjorc1 self-assigned this Apr 10, 2025
@hyjorc1 hyjorc1 added the JavaScriptCore For bugs in JavaScriptCore, the JS engine used by WebKit, other than kxmlcore issues. label Apr 10, 2025
Copy link
Copy Markdown
Member

@Constellation Constellation left a comment

Choose a reason for hiding this comment

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

r=me if you ensure that this does not break the existing cases in JS2.

@hyjorc1 hyjorc1 added safe-merge-queue Applied to automatically send a pull-request to merge-queue after passing EWS checks and removed safe-merge-queue Applied to automatically send a pull-request to merge-queue after passing EWS checks labels Apr 11, 2025
@hyjorc1 hyjorc1 force-pushed the eng/JSC-DFGLoopUnrollingPhase-Enforce-tail-and-exit-block-unification-for-safe-unrolling branch from 0281b14 to 7a13b13 Compare April 11, 2025 19:03
@hyjorc1 hyjorc1 added unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing and removed safe-merge-queue Applied to automatically send a pull-request to merge-queue after passing EWS checks labels Apr 11, 2025
…for safe unrolling

https://bugs.webkit.org/show_bug.cgi?id=291393
rdar://149023954

Reviewed by Yusuke Suzuki.

This patch tightens the eligibility criteria for loop unrolling by requiring
that the loop tail (block that branches back to the header) and the loop exit
block (block that exits the loop) must be the same.

This restriction ensures the loop follows a simple and well-structured control
flow pattern, making it safe for full unrolling without introducing correctness
issues or complex edge handling.

Specifically:
1. Identifies the tail block by looking for a unique predecessor of the header that dominates it.
2. Identifies the exit block as a loop body block with a successor outside the loop.
3. Skips unrolling if multiple tails, multiple exits, or mismatched tail and exit blocks are found.

This change is a preparatory step for broader loop unrolling support in the future.

* Source/JavaScriptCore/dfg/DFGLoopUnrollingPhase.cpp:
(JSC::DFG::LoopUnrollingPhase::locateTail):

Canonical link: https://commits.webkit.org/293588@main
@webkit-commit-queue webkit-commit-queue force-pushed the eng/JSC-DFGLoopUnrollingPhase-Enforce-tail-and-exit-block-unification-for-safe-unrolling branch from 7a13b13 to 1eb0a41 Compare April 11, 2025 19:06
@webkit-commit-queue
Copy link
Copy Markdown
Collaborator

Committed 293588@main (1eb0a41): https://commits.webkit.org/293588@main

Reviewed commits have been landed. Closing PR #43925 and removing active labels.

@webkit-commit-queue webkit-commit-queue merged commit 1eb0a41 into WebKit:main Apr 11, 2025
@webkit-commit-queue webkit-commit-queue removed the unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing label Apr 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

JavaScriptCore For bugs in JavaScriptCore, the JS engine used by WebKit, other than kxmlcore issues.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants