Skip to content

php-in-php: route preg_replace_callback through PregJitHelper PHP (#13736) - #13743

Merged
PurHur merged 1 commit into
masterfrom
agent/issue-13736-preg-replace-callback-php
Jun 29, 2026
Merged

PurHur merged 1 commit into
masterfrom
agent/issue-13736-preg-replace-callback-php

Conversation

@PurHur

@PurHur PurHur commented Jun 29, 2026

Copy link
Copy Markdown
Owner

Summary

  • Delete StringPregMatchStandaloneLlvm.php (1272 LOC libpcre2 LLVM monolith) — all preg_* including preg_replace_callback now route through PregMatchRuntime + PHP helpers.
  • Add PregJitHelper::replaceCallbackArgv() delegating to VmPregNative::pregReplaceCallbackJit() (pure-PHP match loop via VmPregPure).
  • Thin LLVM callback trampoline: PregCallbackInvokeJitHelper::invoke (function-pointer ABI preserved for JitPregReplaceCallback shims).

php-src ref: ext/pcre/php_pcre.c — php_pcre_replace_impl callback form

LOC removed: lib/JIT/Builtin/StringPregMatchStandaloneLlvm.php deleted (−1272); net −1021 lines in PR.

Closes #13736

Test plan

# Issue repro — JIT preg_replace_callback
./script/docker-exec.sh php vendor/bin/phpunit --filter 'JITTest::testCases.*preg_replace_callback_jit'
# OK (1 test)

# Runtime-shrink guards
./script/docker-exec.sh php vendor/bin/phpunit test/unit/PregMatchRuntimeShrinkTest.php test/unit/RuntimeShrinkCloseoutTest.php test/unit/PregExpandRuntimeShrinkTest.php
# OK (7 tests, 92 assertions)

# VM preg_replace_callback smoke
./script/docker-exec.sh php vendor/bin/phpunit test/unit/PregReplaceCallbackBuiltinTest.php
# OK

# Bootstrap probe (spine touch)
make bootstrap-selfhost-vm-driver-execute-probe
# bootstrap-selfhost-vm-driver-execute-probe: OK

Made with Cursor

…3736)

Delete StringPregMatchStandaloneLlvm (~1272 LOC libpcre2 LLVM monolith);
match loop lives in VmPregNative::pregReplaceCallbackJit with a thin LLVM
callback invoke trampoline in PregMatchRuntime.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur
PurHur merged commit 92534d0 into master Jun 29, 2026
@PurHur
PurHur deleted the agent/issue-13736-preg-replace-callback-php branch June 29, 2026 18:30
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.

php-in-php: delete StringPregMatchStandaloneLlvm preg_replace_callback slice — route through PregJitHelper PHP (#1492)

1 participant