Skip to content

php-in-php: StringGetenvAll drop JitEnvironMirrorKernel inline — EnvironMirrorRuntime + EnvironMirrorNativeJitHelper (#1492) #21579

Closed

Description

@PurHur

Category

php-in-php · runtime-shrink (#1492, peer #19215 / #18984 / #20758)

Problem

lib/JIT/Builtin/StringGetenvAll.php still inlines ~100 lines of libc environ walk via JitEnvironMirrorKernel::mirrorIntoHashtablePtr into __compiler_getenv_all, even though EnvironMirrorRuntime already routes the same mirror through NestedJIT EnvironMirrorNativeJitHelper for $_SERVER refresh (#18984 / #19157).

Comment in-tree claims NestedJIT is empty under HELPER_RUNTIME_O=0, but JitSuperglobalRefreshKernel already uses EnvironMirrorRuntime::emitFillCall on the thin-standalone path.

php-src reference

PHP implementation target

  • lib/JIT/Builtin/StringGetenvAll.php — replace JitEnvironMirrorKernel::mirrorIntoHashtablePtr with EnvironMirrorRuntime::emitFillCall; keep GetenvJitHelper::mergeLocalOverlayIntoNative
  • test/unit/GetenvJitRuntimeShrinkTest.php — assert EnvironMirrorRuntime, no JitEnvironMirrorKernel in StringGetenvAll
  • Do not delete JitEnvironMirrorKernel yet — still required by phpc_native_environ_mirror_into_ht NestedJIT leaf

Repro

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
vendor/bin/phpunit --filter GetenvJitRuntimeShrinkTest
vendor/bin/phpunit --filter StringGetenvAllRuntimeStandaloneTest
vendor/bin/phpunit --filter getenv_all
'

Done when

  • StringGetenvAll no longer references JitEnvironMirrorKernel
  • Zero-arg getenv() AOT fixture / compliance green
  • make bootstrap-selfhost-vm-driver-execute-probe green
  • PR body cites LLVM bridge lines removed from getenv_all path

Refs #1492, #18984, #19215, #20758

Activity

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

    @PurHur
    OwnerAuthor

    claim: PHP Runtime → PHP — starting this run

    Pillar 1 probes (this workspace):

    • bootstrap-inventory --check → OK 6197/6197
    • release-readiness --json → user_release_ready: yes (inventory, spine, root-readme, north-star5-fast, vm-driver-probe all ok)
    • First failing command: none

    Migrating StringGetenvAll off inline JitEnvironMirrorKernel onto EnvironMirrorRuntime::emitFillCall (peer #18984 / #19215).

  3. PurHur commented on Jul 20, 2026

    @PurHur
    OwnerAuthor

    Blocker (php-src-strict AOT) — not merging this run

    Attempted StringGetenvAll → EnvironMirrorRuntime::ensureLinked + __superglobals__mirror_process_environ ABI call (same shape as $_SERVER refresh).

    Evidence

    # ours (EnvironMirrorRuntime path)
    type=array
    count=0
    has_PATH=0
    has_MARKER=0
    
    # origin/master (inline JitEnvironMirrorKernel::mirrorIntoHashtablePtr)
    type=array
    count=152
    has_PATH=1
    has_MARKER=1
    

    Commands:

    ./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
    ./phpc build -o /tmp/gdump test/repro/issue_21579_dump.php && /tmp/gdump'

    Unit shrink tests green; VM getenv() ok; AOT zero-arg getenv() returns empty array — NestedJIT EnvironMirrorNativeJitHelper / phpc_native_environ_mirror_into_ht leaf does not populate a freshly allocated HT under thin standalone AOT (matches in-tree warning about NestedJIT empty under HELPER_RUNTIME_O=0, #20758 / #19157).

    Next step

    Either:

    1. Fix NestedJIT environ-mirror so a local __hashtable__* fill matches libc walk (then resume php-in-php: StringGetenvAll drop JitEnvironMirrorKernel inline — EnvironMirrorRuntime + EnvironMirrorNativeJitHelper (#1492) #21579), or
    2. Keep inline JitEnvironMirrorKernel for getenv_all until (1) is green — do not route getenv_all through EnvironMirrorRuntime yet.

    Releasing claim for this run; not pushing a regressing AOT change.

  4. PurHur commented on Jul 20, 2026

    @PurHur
    OwnerAuthor

    Merged #21585

    What landed: StringGetenvAll no longer inlines JitEnvironMirrorKernel; thin AOT uses shared EnvironMirrorRuntime ABI with libc kernel body; embed keeps NestedJIT helper.

    Verification

    • shrink + standalone unit filters green
    • AOT zero-arg getenv repro: array/nonempty/has/production EXIT:0
    • make bootstrap-selfhost-vm-driver-execute-probe OK
    • inventory OK 6197/6197

    Full JitEnvironMirrorKernel delete remains blocked (NestedJIT /proc empty — see #21580).

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 & DevEx

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions