Skip to content

Language: Enum::cases() — JIT/AOT case list lowering (phase 2 of #3308) #4068

Description

@PurHur

Category

language

Problem (phase 2 of #3308)

UnitEnum::cases() / backed Enum::cases() work on VM via lib/VM/Builtin/EnumCases.php. JIT skips enum static calls (test/compliance/JITTest.php — "Enum::cases() is VM-only until JIT enum case lowering (#3308)").

Self-host and enum-heavy code needs compile-time/lowering of Suit::cases() without VM deopt.

php-src reference

Repro (JIT failure today)

<?php
enum Suit: string { case Hearts = 'H'; case Spades = 'S'; }
$cases = Suit::cases();
echo count($cases), ':', $cases[0]->name, "\n";
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php repro.php'
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/jit.php repro.php'

Zend / VM: 2:Hearts
JIT (today): VM fallback or compile skip for cases() static call.

Scope

Done when

  • Repro prints 2:Hearts under bin/jit.php without VM fallback
  • Unit enum (no backing type) and backed enum both covered
  • JITTest enum-cases skip removed
  • Syntax matrix: note Enum::cases() JIT yes

Links

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:compilerCompiler / CFG / JITarea:vmVirtual machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-2:languagePhase 2 – language features

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions