Skip to content

Stdlib: preg_replace_callback_array() JIT/AOT via PregJitHelper (#3568) - #18107

Merged
PurHur merged 2 commits into
masterfrom
agent/stdlib-preg-replace-callback-array-aot
Jul 11, 2026
Merged

PurHur merged 2 commits into
masterfrom
agent/stdlib-preg-replace-callback-array-aot

Conversation

@PurHur

@PurHur PurHur commented Jul 11, 2026

Copy link
Copy Markdown
Owner

Summary

  • Remove the permanent LogicException stub in JitPregReplaceCallbackArray — JIT/AOT now lower through PregReplaceCallbackArrayRuntime → PregJitHelper::replaceCallbackArrayArgv() → VmPregReplaceCallbackArray (php-src: ext/pcre/php_pcre.c).
  • PHP-in-PHP: no new C runtime; reuses existing PregMatchRuntime helper compile cache.
  • Adds AOT fixture + shrink unit test; updates capability matrix note.

Root cause

preg_replace_callback_array() VM parity landed in #3568, but JitPregReplaceCallbackArray::invoke() still threw unconditionally, blocking native AOT binaries that call the builtin.

Verification

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php test/repro/maintainer_gap_preg_replace_callback_array_closure.php
# bx

php bin/jit.php -r "
\$out = preg_replace_callback_array([\"/\d+/\" => fn(array \$m): string => \"[\" . \$m[0] . \"]\"], \"a1b2\");
echo \$out, \"\n\";
"
# a[1]b[2]

php -d memory_limit=1536M vendor/bin/phpunit --filter PregReplaceCallbackArray
# OK (4 tests)

php script/bootstrap-inventory.php --check
# OK 4542/4542

./script/check-generated-docs.sh
# all generated docs in sync
'

Note: phpc build for preg-family scripts still OOMs at 1536M in this harness (pre-existing; preg_replace_callback AOT hits the same ceiling). JIT exercises the same LLVM lowering path; AOT fixture test/fixtures/aot/cases/preg_replace_callback_array.phpt guards the compile hook.

Closes #3568 (AOT deferred portion)

Made with Cursor

PurHur and others added 2 commits July 11, 2026 22:52
Replace the LogicException stub with PregReplaceCallbackArrayRuntime
bridging to VmPregReplaceCallbackArray through PregJitHelper PHP-in-PHP
lowering (ext/pcre/php_pcre.c parity). VM/JIT verified; AOT fixture added.

Co-authored-by: Cursor <cursoragent@cursor.com>
Regenerate bootstrap-inventory.md after conflict resolution.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur
PurHur merged commit 6248c8d into master Jul 11, 2026
@PurHur
PurHur deleted the agent/stdlib-preg-replace-callback-array-aot branch July 11, 2026 22:53
PurHur added a commit that referenced this pull request Jul 12, 2026
#18093)

Sync bootstrap spine coverage for new lib/PHPTypes unit and upstream
PregReplaceCallbackArrayRuntime from #18107.

Co-authored-by: Cursor <cursoragent@cursor.com>
PurHur added a commit that referenced this pull request Jul 12, 2026
#18093)

Sync bootstrap spine coverage for new lib/PHPTypes unit and upstream
PregReplaceCallbackArrayRuntime from #18107.

Co-authored-by: Cursor <cursoragent@cursor.com>
PurHur added a commit that referenced this pull request Jul 12, 2026
… (#18112)

* Language: CompilerTypeReconstructor for dynamic Class::{$name} (#18093)

Move TypeReconstructor guard for PHP 8.3+ dynamic class const fetch from
vendor patch into lib/PHPTypes/CompilerTypeReconstructor.php. Relocate
compliance guard under test/compliance/cases/language/class_const/.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Spine: add CompilerTypeReconstructor + PregReplaceCallbackArrayRuntime (#18093)

Sync bootstrap spine coverage for new lib/PHPTypes unit and upstream
PregReplaceCallbackArrayRuntime from #18107.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Spine: add Utf8EndecDeprecation from master (#18093)

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: PurHur <PurHur@users.noreply.github.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stdlib: preg_replace_callback_array() — multi-pattern callback replace (ext/pcre/php_pcre.c parity)

1 participant