Category
php-in-php · php-src-strict
Problem
preg_match(), preg_match_all(), preg_replace(), and friends have VM implementations in ext/standard/, but JIT/AOT emit ~3,000 lines of LLVM in lib/JIT/Builtin/StringPregMatchJit.php calling libpcre2-8 directly (mirrors deleted lib/AOT/runtime/preg_match.c). This duplicates offset capture, error codes, and PREG_* flag semantics — a frequent source of VM/JIT drift (#5289, #6639).
php-src reference
Repro
wc -l lib/JIT/Builtin/StringPregMatchJit.php
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php test/compliance/cases/stdlib/preg_match_basic.phpt
php bin/jit.php test/compliance/cases/stdlib/preg_match_basic.phpt
php bin/jit.php -r "var_export(preg_match(\"/(\d+)/\", \"abc123\", \$m)); echo PHP_EOL, \$m[1];"
'
| Symptom |
VM |
JIT today |
Capture offsets / PREG_OFFSET_CAPTURE |
PHP |
Separate LLVM pcre2 path |
preg_last_error() after JIT call |
shared helper? |
phpc_preg_last_error global |
Scope
| Layer |
Files |
| PHP helper |
New ext/standard/PregJitHelper.php wrapping VM preg engine |
| JIT |
lib/JIT/Builtin/StringPregMatchJit.php → thin compile + call |
| FFI |
Keep single pcre2 binding in PHP/VM layer; delete duplicate LLVM extern decls |
| Tests |
Existing preg compliance PHPTs + enum-case subject guards (#3568 family) |
Done when
Related
Category
php-in-php· php-src-strictProblem
preg_match(),preg_match_all(),preg_replace(), and friends have VM implementations inext/standard/, but JIT/AOT emit ~3,000 lines of LLVM inlib/JIT/Builtin/StringPregMatchJit.phpcalling libpcre2-8 directly (mirrors deletedlib/AOT/runtime/preg_match.c). This duplicates offset capture, error codes, andPREG_*flag semantics — a frequent source of VM/JIT drift (#5289, #6639).php-src reference
ext/pcre/php_pcre.c—php_pcre_match, error mappingext/standard/php_string.h— preg function exportsext/standard/preg_match.php,VmPreg.php(or equivalent)Repro
PREG_OFFSET_CAPTUREpreg_last_error()after JIT callphpc_preg_last_errorglobalScope
ext/standard/PregJitHelper.phpwrapping VM preg enginelib/JIT/Builtin/StringPregMatchJit.php→ thin compile + callDone when
StringPregMatchJit.php≤ thin wrapper; PR cites LLVM lines removedpreg_last_error()consistent VM/JIT after failed match./script/ci-fast.sh --filter preg_matchgreenRelated