Skip to content

php-in-php: JIT ProcessRuntime — route shell_exec/escapeshell* through VmProcess PHP not ~1.3k-line LLVM (#1492) #9337

Description

@PurHur

Category

php-in-php | stdlib

Problem

lib/JIT/Builtin/ProcessRuntime.php (~1,332 lines) reimplements process helpers in LLVM (__compiler_shell_exec, __compiler_escapeshellarg, __compiler_escapeshellcmd, __compiler_process_exec_capture, __phpc_process_*). VM paths already use PHP (ext/standard/VmProcess*.php, VmExecNative.php).

JIT/AOT should call the existing PHP builtins (or shared VmProcess helpers) via the normal compile pipeline — same pattern as #9268 ObOutputRuntime, #9247 StreamIoJit.

php-src reference

Repro (LLVM duplication today)

wc -l lib/JIT/Builtin/ProcessRuntime.php
grep -c '__compiler_' lib/JIT/Builtin/ProcessRuntime.php
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit test/unit/ExecJitRuntimeShrinkTest.php test/unit/JIT/ProcessRuntimeStandaloneTest.php'

Done signal: JIT link uses PHP lowering stubs; ProcessRuntime.php shrinks to thin registration (target >80% line reduction).

Scope

Module Path
Delete/shrink LLVM lib/JIT/Builtin/ProcessRuntime.php, lib/JIT/Builtin/ProcessOpenJit.php (capture only if duplicated)
PHP VM (keep/extend) ext/standard/shell_exec.php, escapeshellarg.php, escapeshellcmd.php, VmExecNative.php
JIT registration lib/JIT/Builtin/Type.php — route to compiled PHP handlers
Self-host spine test/selfhost/compiler_lib_spine_smoke/main.php if symbols drop
Tests existing exec/shell JIT PHPTs + shrink tests

No new runtime/*.c. If libc FFI is unavoidable for a hot path, document proof in PR; default is PHP VmProcess + existing FFI wrappers in ext/.

Done when

  • shell_exec / escapeshellarg / escapeshellcmd JIT/AOT call PHP implementation (no __compiler_shell_exec body in LLVM module)
  • test/unit/ExecJitRuntimeShrinkTest.php updated — asserts LLVM symbol count drop
  • make north-star5-verify-fast green; self-host spine sync if main.php changes
  • PR notes lines removed from ProcessRuntime.php

Related

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