Repository navigation
php-in-php: preg_replace_callback()/preg_split() JIT — delete LLVM stubs, wire real lowering (ext/pcre/php_pcre.c) #6639
Description
Activity
- addedenhancementNew feature or requestNew feature or requestphase-0:FoundationPhase 0 – foundation & DevExPhase 0 – foundation & DevExphase-4:stdlibPhase 4 – stdlib for web appsPhase 4 – stdlib for web appsarea:compilerCompiler / CFG / JITCompiler / CFG / JITarea:vmVirtual machineVirtual machineimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimSpec complete: repro, php-src ref, done-when — safe for workers to claim
on Jun 6, 2026 claim: PHP Runtime → PHP — starting this run (#6639: replace preg_replace_callback/preg_split LLVM stubs in StringPregMatchJit with real lowering from JitPregReplaceCallback/JitPregSplit).
Unclaiming #6639 this run: picked #5303 closure (phpc_weakref.c migration already merged #5684). #6639 handoff: fix __compiler_preg_replace_callback ABI (declareFunction param order vs JitPregReplaceCallback), replace emitReplaceCallbackStub/emitSplitStub with real LLVM from emitReplaceInternal pattern; AOT preg_replace_callback.phpt currently fails compile with "runtime callback type is not a function pointer".
claim: PHP Runtime → PHP — starting this run (#6639: replace preg_replace_callback/preg_split LLVM stubs, fix __compiler_preg_replace_callback ABI param order).
- added a commit that references this issue
on Jun 8, 2026 Merged via PR #7662.
PHP path:
StringPregMatchJit::emitReplaceCallback+emitSplitreplace BAD_REGEX/NULL stubs;__compiler_preg_replace_callbackABI fixed to (pattern, subject, callback fn*); indirect callback viaLLVMBuildCall2.Verification (VM+JIT green):
vendor/bin/phpunit test/unit/JIT/StringPregMatchRuntimeStandaloneTest.php— OK--filter preg_replace_callback_jit/preg_split_jit/stdlib/preg_replace_callback— OK
Note: AOT
preg_replace_callback/preg_splitfixtures still hit pre-existing standalone module verify duringbin/compile.php(reproduces on master); handoff for a follow-up AOT link gate.
Category
php-in-php·stdlib· JIT/AOT regressionProblem
VM
preg_replace_callback()/preg_split()work viaext/standard/VmPreg.php, but MCJIT/AOT still emit stub bodies for__compiler_preg_replace_callbackand__compiler_preg_splitinlib/JIT/Builtin/StringPregMatchJit.php(returns NULL / BAD_REGEX). Closed #1177 / #1178 covered initial wiring; stubs remain.php-src reference
ext/pcre/php_pcre.c—php_pcre_replace_impl,php_pcre_splitext/standard/basic_functions.stub.phpRepro (JIT)
Observed: NULL / empty or VM fallback depending on probe flags.
Expected:
aBaunder MCJIT when JIT path selected.preg_splitwithPREG_SPLIT_NO_EMPTYsimilarly fails in JIT when__compiler_preg_splitstub is linked.Scope (this repo)
lib/JIT/Builtin/StringPregMatchJit.phpemitReplaceCallbackStub/emitSplitStubwith real PCRE2 lowering (mirroremitReplace/emitMatch)ext/standard/JitPregReplaceCallback.php,JitPregSplit.phpVmPregReplaceCallbackext/standard/preg_*.phptest/compliance/cases/stdlib/preg_replace_callback_jit.phpt,preg_split_jit.phptPHP-in-PHP: keep PCRE logic in PHP-generated LLVM + thin libpcre2 ABI; do not grow
runtime/*.c.Done when
preg_replace_callbackJIT compliance case matches Zend outputpreg_splitwith flags/limit JIT-lowers (phase with Stdlib: preg_split() $limit / $flags — JIT/AOT lowering (phase 2 of #3639) #4078 if needed)StringPregMatchJit.phphas no stub emitters for callback/split./script/ci-local.sh --filter preg_replace_callback_jitgreen (or fast filter while iterating)Strictness
php-src-strict for user scripts; enum-case operands per #5999.
Related