Skip to content

php-in-php: JIT StringPregMatchJit — route preg_match/preg_replace through ext/pcre PHP not libpcre2 LLVM (#1492) #9135

Description

@PurHur

Category

php-in-php · php-src-strict

Problem

VM preg_match() / preg_replace() / related PCRE builtins run through ext/pcre/ PHP (VmPcre.php, per-function wrappers). JIT/AOT still ship a ~3k-line LLVM runtime in lib/JIT/Builtin/StringPregMatchJit.php calling libpcre2-8 directly — duplicating error codes, offset capture, enum-subject guards (#9029), and JIT stack limits already handled in PHP.

This grows native link surface and diverges from the VM path workers fix for parity issues.

php-src reference

Repro

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php -r "var_export(preg_match(\"/\\\\d+/\", \"abc123\")); echo PHP_EOL;"
php bin/jit.php -r "var_export(preg_match(\"/\\\\d+/\", \"abc123\")); echo PHP_EOL;"
# JIT: StringPregMatchJit.php libpcre2 LLVM (issue #5289)'

Scope

Layer Path
JIT LLVM lib/JIT/Builtin/StringPregMatchJit.php — shrink to trampoline into compiled PHP
Lowering ext/pcre/JitPreg*.php handlers
No new runtime/*.c — delete/shrink pcre2 LLVM when PHP path suffices
Pairs enum/subject parity issues #9029, #9025–#9026

Done when

  • JIT/AOT preg_match/preg_replace/preg_split match VM + Zend on compliance pcre PHPTs
  • Default JIT build does not link libpcre2 LLVM helpers for core preg builtins
  • PR cites php-src + PHP implementation; notes LLVM lines / symbols removed
  • Enum-subject TypeError guards shared with VM (php-src-strict)

Ref: #1492, #5289, #9029

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