Skip to content

php-in-php: pack() JIT/AOT — delete lib/AOT/runtime/phpc_pack.c, lower from ext/standard/VmPack.php #5231

Closed

Description

@PurHur

Category

php-in-php / stdlib

Problem

pack() has PHP implementations in ext/standard/VmPack.php and ext/standard/JitPack.php, but JIT/AOT still call lib/AOT/runtime/phpc_pack.c (~500 lines of format-string logic). Self-host and PHP-in-PHP goals require native lowering without growing the C runtime.

php-src reference

Repro (C path today)

grep -l phpc_pack lib/JIT/Builtin/*.php lib/AOT/*.php 2>/dev/null | head
nm -g lib/AOT/runtime/phpc_pack.c 2>/dev/null | head -3 || true
./script/docker-exec.sh -- bash -lc '
  php -r "echo bin2hex(pack(\"C\", 255));"
  php bin/vm.php -r "echo bin2hex(pack(\"C\", 255));"
'

Behavior parity issues (#4532, #4676) are separate; this issue is delete C + wire JIT/AOT to PHP lowering.

Scope (this repo)

Area Path
VM ext/standard/VmPack.php
JIT ext/standard/JitPack.php, lib/JIT/Builtin/
Delete lib/AOT/runtime/phpc_pack.c (+ link symbols)
Tests extend test/compliance/cases/stdlib/pack*.phpt / AOT fixtures

Done when

  • phpc_pack.c removed from AOT link; no __compiler_pack (or renamed thin ABI only if unavoidable — document why)
  • JIT + AOT pack() use PHP lowering path; script/capability-matrix.php unchanged or notes updated
  • PR body lists lines removed from lib/AOT/runtime/

Activity

  1. added
    enhancementNew feature or request
    phase-4:stdlibPhase 4 – stdlib for web apps
    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 6, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Runtime → PHP — starting this run (#5231 pack: PackEngine VM + PackJitRuntime bitcode, delete lib/AOT/runtime/phpc_pack.c).

  3. PurHur commented on Jun 6, 2026

    @PurHur
    OwnerAuthor

    Merged via #6510.

    C runtime shrink: deleted lib/AOT/runtime/phpc_pack.c (~544 lines); removed from lib/AOT/Linker.php.

    PHP path: VM uses ext/standard/PackEngine.php (php-src ext/standard/pack.c); JIT/AOT links lib/JIT/Builtin/pack_jit_runtime.c via PackJitRuntime (follow-up: full LLVM from PackEngine, like #6306 for unpack).

    Verification:

    rg phpc_pack lib/AOT/runtime   # empty
    vendor/bin/phpunit test/unit/PackEngineTest.php           # OK (3/3)
    vendor/bin/phpunit test/unit/PackBuiltinTest.php --filter testVmPack  # OK (1/1)
    vendor/bin/phpunit test/unit/JIT/StringPackRuntimeStandaloneTest.php # OK (1/1)
    php script/bootstrap-inventory.php --check                # OK
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-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