Category
php-in-php · shrink LLVM · php-src-strict
Problem
Synthetic Enum::cases() lowering lives in lib/JIT/EnumCasesHelper.php with inline HashTableHelper::alloc + per-case LLVM stores (#3308, #4068). VM enum case lists are already specified in lib/VM/EnumSupport.php / BackedEnumFromJit territory (#10273), but EnumCasesHelper still duplicates ordering/materialization in JIT-only glue.
Route JIT/AOT through VmEnum::casesList() (or shared PHP helper) with thin ABI — same strategy as #10273 BackedEnumFromJit.
php-src reference
Repro (drift guard)
<?php
enum Color: string { case Red = 'r'; case Green = 'g'; case Blue = 'b'; }
$cases = Color::cases();
echo count($cases), ':', $cases[0]->name, ':', $cases[2]->name, "\n";
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php -r "enum Color: string { case Red=\"r\"; case Green=\"g\"; case Blue=\"b\"; } \$c=Color::cases(); echo count(\$c),\":\",\$c[0]->name,\":\",\$c[2]->name,PHP_EOL;"
php bin/vm.php -r "enum Color: string { case Red=\"r\"; case Green=\"g\"; case Blue=\"b\"; } \$c=Color::cases(); echo count(\$c),\":\",\$c[0]->name,\":\",\$c[2]->name,PHP_EOL;"
php bin/jit.php -r "enum Color: string { case Red=\"r\"; case Green=\"g\"; case Blue=\"b\"; } \$c=Color::cases(); echo count(\$c),\":\",\$c[0]->name,\":\",\$c[2]->name,PHP_EOL;" 2>/dev/null || true
'
| Check |
VM/JIT must match |
| Count |
3 |
| Order |
declaration order (Red … Blue) |
| Case type |
enum case objects, not backing scalars |
Scope (this repo)
| Path |
Work |
lib/VM/EnumSupport.php |
SSOT casesForClass() callable from JIT |
lib/JIT/EnumCasesHelper.php |
shrink to trampoline |
lib/JIT/BackedEnumFromJit.php |
share case materialization with #10273 |
| Tests |
test/compliance/cases/language/enum_cases.phpt |
Done when
Related
Category
php-in-php· shrink LLVM · php-src-strictProblem
Synthetic
Enum::cases()lowering lives inlib/JIT/EnumCasesHelper.phpwith inlineHashTableHelper::alloc+ per-case LLVM stores (#3308, #4068). VM enum case lists are already specified inlib/VM/EnumSupport.php/BackedEnumFromJitterritory (#10273), butEnumCasesHelperstill duplicates ordering/materialization in JIT-only glue.Route JIT/AOT through
VmEnum::casesList()(or shared PHP helper) with thin ABI — same strategy as #10273BackedEnumFromJit.php-src reference
Zend/zend_enum.c—zend_enum_list_casesZend/zend_interfaces.c— case object orderRepro (drift guard)
3Red…Blue)Scope (this repo)
lib/VM/EnumSupport.phpcasesForClass()callable from JITlib/JIT/EnumCasesHelper.phplib/JIT/BackedEnumFromJit.phptest/compliance/cases/language/enum_cases.phptDone when
EnumCasesHelper.phpno longer duplicates enum order logic from VM./script/ci-fast.sh --filter enum_casesgreenRelated