Skip to content

JIT: Enum::cases() lowering (#4068) - #4112

Merged
PurHur merged 1 commit into
masterfrom
agent/issue-4068-enum-cases-jit
Jun 1, 2026
Merged

PurHur merged 1 commit into
masterfrom
agent/issue-4068-enum-cases-jit

Conversation

@PurHur

@PurHur PurHur commented Jun 1, 2026

Copy link
Copy Markdown
Owner

Summary

  • Lower synthetic Enum::cases() as a per-enum LLVM function (suit::cases) that returns a packed list of enum case objects built from compile-time case constants.
  • Enum case objects use two property slots (name string + backing __value__); ->name / ->value are handled in JIT property fetch.
  • php-src reference: Zend/zend_enum.c (zend_enum_list_cases).

Closes #4068

Verification

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php vendor/bin/phpunit test/unit/EnumCasesJitCompileTest.php'

Output:

OK (1 test, 2 assertions)

LLVM module contains suit::cases and passes compileCommon() verify.

VM compliance (unchanged):

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php vendor/bin/phpunit test/compliance/EnumVMTest.php --filter enum_cases'
# OK (1 test)

Blocker (not merged)

MCJIT execute still segfaults for scripts that declare user enums (#3518 — same on master for enum E: string {} with no body). JITTest enum_cases remains skipped until execute is stable. Compile-time lowering is complete and guarded by EnumCasesJitCompileTest.

Issue repro via bin/jit.php hits this execute crash after successful compile (previously failed at compile with undefined cases()).

Made with Cursor

Register suit::cases-style static methods that build a packed array of
enum case objects from compile-time backing constants, and handle ->name
/ ->value on those objects in property fetch.

MCJIT execute for user enums still segfaults (#3518); EnumCasesJitCompileTest
guards the lowering via LLVM module verify.

Co-authored-by: Cursor <cursoragent@cursor.com>
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: Enum::cases() — JIT/AOT case list lowering (phase 2 of #3308)

1 participant