Skip to content

Language: list destructuring spread — JIT/AOT TYPE_LIST_SPREAD_ASSIGN (phase 2 of #4835) #4885

Description

@PurHur

Category

language

Problem

PHP 8.1+ list assignment with spread ([$head, ...$tail] = $array) is VM-complete after #4835 (OpCode::TYPE_LIST_SPREAD_ASSIGN in lib/VM.php). lib/JIT.php has no case OpCode::TYPE_LIST_SPREAD_ASSIGN, so bin/jit.php / AOT cannot execute scripts using spread destructuring without VM fallback.

test/compliance/JITTest.php skips list_destructuring_spread.phpt for MCJIT execute.

php-src reference

Repro — VM (baseline, should already pass)

<?php
$src = [1, 2, 3, 4];
[$a, ...$rest] = $src;
echo $a, ':', implode(',', $rest), "\n";
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php repro_list_spread.php'
# Expected: 1:2,3,4

Repro — JIT gap (today)

Same script via JIT:

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
export PHP_COMPILER_LLVM_PATH=/opt/llvm9
export LD_LIBRARY_PATH=/opt/llvm9
php bin/jit.php repro_list_spread.php
'

VM matches Zend; JIT compile/execute fails or diverges until TYPE_LIST_SPREAD_ASSIGN is lowered.

String-key tail guard (VM already enforces):

<?php
try {
    [$a, ...$b] = ['k' => 1, 'x' => 2];
} catch (TypeError $e) {
    echo $e->getMessage(), "\n";
}

Zend: Cannot unpack array with string keys.

Scope (this repo)

Area Files
JIT lib/JIT.php — case OpCode::TYPE_LIST_SPREAD_ASSIGN (reuse HashTable::sliceCopy / list unpack helpers)
Reference VM lib/VM.php lines ~1258–1286
Compiler lib/Compiler.php — spread assign emission (~3676)
Tests test/compliance/cases/language/list_destructuring_spread.phpt; unskip in JITTest.php
Patches script/apply-patches.sh — listSpreadRhs php-cfg overlay (required for compile)

Done when

  • JIT + AOT execute list_destructuring_spread.phpt without VM fallback
  • Spread on non-list array throws TypeError with Zend message
  • ./script/ci-fast.sh --filter list_destructuring_spread green (VM + JIT)

Links

Activity

  1. added
    enhancementNew feature or request
    area:vmVirtual machine
    implementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claim
    on Jun 3, 2026
  2. PurHur commented on Jun 3, 2026

    @PurHur
    OwnerAuthor

    Implemented MCJIT lowering in PR #4963. VM repro green; LLVM module verify via ListSpreadAssignJitCompileTest. MCJIT execute still skipped in JITTest (harness bin/jit.php segfaults on this host — same class as #2114 list-unpack execute gaps).

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