Skip to content

Stdlib/JIT: array_udiff/array_uintersect/array_*_u* — native JIT lowering still throws (VM interpreter fallback only) #9155

Description

@PurHur

Category

stdlib

Problem

User-comparator array builtins registered in #5644 work on VM, and bin/jit.php can produce correct output today via interpreter fallback. However each handler's call() method still throws LogicException('… is VM-only in this compiler build') — e.g. ext/standard/array_udiff.php, array_uintersect.php, array_diff_ukey.php, …

Native JIT lowering is required for self-host/AOT performance and to match other array builtins (usort, array_map closure JIT). Without it, compiled hot paths pay full interpreter dispatch per call.

php-src reference

Repro

<?php
$a = [1, 2, 3];
$b = [2, 3, 4];
print_r(array_udiff($a, $b, fn ($x, $y) => $x <=> $y));
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php repro.php
php bin/jit.php repro.php
# Inspect: ext/standard/array_udiff.php call() still throws if invoked directly from JIT compile path
grep -n "VM-only" ext/standard/array_udiff.php
'
Builtin call() today VM JIT (2026-06-17)
array_udiff throws LogicException OK OK via fallback
array_uintersect throws OK fallback
array_diff_ukey throws OK fallback

Scope

Path Work
ext/standard/array_udiff.php, array_uintersect.php, array_diff_u*.php, array_intersect_u*.php Implement call() using shared JitArrayUserComparator helper
lib/JIT/ New helper modeled on VmArrayUserSetOps + closure/string callback policies
docs/stdlib-jit-audit.md Regenerate after lowering
Tests test/compliance/cases/stdlib/array_udiff_jit.phpt — assert native JIT (no interpreter-only marker)

PHP-in-PHP: comparator loop in PHP compiled through normal pipeline; no new runtime/*.c.

Done when

  • array_udiff / array_uintersect / array_diff_ukey (minimum batch) implement call() without throwing
  • JIT execute compliance green; AOT fixture optional v1
  • ./script/ci-fast.sh --filter array_udiff_jit green
  • script/audit-stdlib-jit.php no longer lists these as missing/deferred

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 / JITimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web apps

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions