Skip to content

php-in-php: JIT CastHelper — route (array)/(object) cast LLVM through VmCast PHP not ~125-line monolith (#1492) #10244

Description

@PurHur

Category

php-in-php · language · compile/JIT

Problem

(array) / (object) / (unset) casts have VM semantics in lib/VM/CastSupport.php and ext/standard/JitGetObjectVars.php, but JIT still lowers through lib/JIT/CastHelper.php (~125 LOC) with inline LLVM branches (HashTableHelper, CastArrayRuntime, JitGetObjectVars).

This duplicates enum/object/array cast rules already tracked in parity issues (#9659, #9950, #10046) and blocks shrinking JIT monoliths per #1492.

php-src reference

Repro (architect baseline)

wc -l lib/JIT/CastHelper.php lib/VM/CastSupport.php
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/jit.php -r "var_export((array) new stdClass());" 2>&1
php bin/jit.php -r "var_export((object) [\"a\"=>1]);" 2>&1
'

Today JIT path uses CastHelper LLVM; VM -r works via interpreter.

Scope (this repo)

Path Work
lib/JIT/CastHelper.php Replace body with trampoline to VmCast / CastJitHelper PHP entry
lib/VM/CastJitHelper.php Shared SSOT callable from JIT (mirror VmCoalesce pattern #10171)
lib/JIT/Builtin/CastArrayRuntime.php Delete or thin after PHP path owns behavior

PHP-in-PHP first — delete LLVM cast branches when VM PHP path is hot enough; no new runtime/*.c.

Done when

Related

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 / JITenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-0:FoundationPhase 0 – foundation & DevExphase-2:languagePhase 2 – language features

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions