Skip to content

Fix AOT try/catch for empty user classes (#2157) - #2181

Merged
PurHur merged 1 commit into
masterfrom
fix/2157-trycatch-aot-collect-catch-ops
May 25, 2026
Merged

Fix AOT try/catch for empty user classes (#2157)#2181
PurHur merged 1 commit into
masterfrom
fix/2157-trycatch-aot-collect-catch-ops

Conversation

@PurHur

@PurHur PurHur commented May 25, 2026

Copy link
Copy Markdown
Owner

Summary

  • Fix TryCatchHelper::collectCatchOps() to skip TYPE_JUMP opcodes between TYPE_TRY and TYPE_CATCH so nested CFG (e.g. 007-ThrowsWeb) registers catch arms instead of falling through to abort().
  • Pre-compile merge bodies before dispatch, split merge entry vs body basic blocks, and lower catch blocks via compileIncludedAtEntry() at the match BB so catch bodies (echo/assign) are reachable in native AOT.
  • Reuse existing JIT class ids in declareClass() and add throws_user_class AOT fixture plus TryCatchCollectOpsTest.

Test plan

  • vendor/bin/phpunit --filter throws_user_class
  • THROWSWEB_AOT_SMOKE_GATE=1 vendor/bin/phpunit test/unit/ThrowsWebAotExecuteTest.php
  • Manual: ./phpc build --project examples/007-ThrowsWeb + POST email=bad prints invalid
  • Note: in-process bin/jit.php try/catch execute still segfaults on master and this branch (AOT/native path is green).

Closes #2157

Made with Cursor

Skip CFG jumps when collecting catch arms, wire merge entry/body before dispatch, compile catch at the match basic block, and reuse declared class ids so 007-ThrowsWeb AOT execute reaches the caught invalid path.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur
PurHur merged commit 299dfab into master May 25, 2026
@PurHur
PurHur deleted the fix/2157-trycatch-aot-collect-catch-ops branch May 25, 2026 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Language: AOT throw/catch with user-defined class (007 ValidationError execute)

1 participant