Skip to content

php-in-php: JIT StringUnserialize — route unserialize() through VmUnserializeFormat PHP not __compiler_unserialize LLVM (#1492) #9163

Description

@PurHur

Category

php-in-php · php-src-strict (runtime semantics from PHP VM path)

Problem

unserialize() VM lowering uses PHP (ext/standard/VmUnserializeFormat.php), but JIT/AOT still emit native __compiler_unserialize LLVM cloned from runtime/phpc_unserialize.c (lib/JIT/Builtin/StringUnserializeJit.php). This duplicates semantics in C, blocks self-host shrink, and risks VM/JIT drift on object refs, allowed_classes, and session decode paths.

php-src reference

Repro (JIT divergence probe)

<?php
$data = serialize(['a' => 1, 'b' => 2]);
echo unserialize($data)['b'], "\n";
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php repro.php
php bin/jit.php repro.php
# JIT must match VM; today JIT uses __compiler_unserialize C helper
'

Scope (this repo)

Layer Work
JIT Replace StringUnserializeJit C calls with call into compiled VmUnserializeFormat / shared PHP helper
AOT Same entry as JIT
C shrink Delete or bypass __compiler_unserialize / phpc_unserialize.c symbols when PHP path covers JIT builds
Tests Extend test/compliance/cases/stdlib/unserialize*.phpt with JIT rows

Done when

  • JIT/AOT unserialize() results match VM on compliance vectors (scalars, arrays, allowed_classes subset)
  • No new runtime/*.c logic — note lines removed from C in PR body
  • script/capability-matrix.php notes shared PHP lowering

Ref: #1492 · #5991 · #1175

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-4:stdlibPhase 4 – stdlib for web apps

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions