Skip to content

php-in-php: route preg_* JIT embed through PregJitHelper (#9542) - #12034

Merged
PurHur merged 1 commit into
masterfrom
agent/issue-9542-preg-match-php
Jun 26, 2026
Merged

PurHur merged 1 commit into
masterfrom
agent/issue-9542-preg-match-php

Conversation

@PurHur

@PurHur PurHur commented Jun 26, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add ext/standard/PregJitHelper.php as SSOT over VmPregNative for embed JIT/AOT preg builtins
  • Add lib/JIT/Builtin/PregMatchRuntime.php with LLVM bridges to compiled PHP helpers
  • Shrink StringPregMatchJit.php to a 68-line dispatcher; quarantine pcre2 LLVM to StringPregMatchStandaloneLlvm.php (standalone AOT only)
  • preg_replace_callback embed still uses a thin LLVM slice from standalone until callback ABI is PHP-hosted

Closes #9542

LLVM shrink

File Before After
StringPregMatchJit.php (embed dispatch) ~3250 68
pcre2 monolith inline StringPregMatchStandaloneLlvm.php (standalone only)

php-src reference

  • ext/pcre/php_pcre.c — behavior via existing VmPregNative / VmPregMatches

Verification

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
vendor/bin/phpunit --filter "PregMatchRuntimeShrinkTest|PregExpandRuntimeShrinkTest|RuntimeShrinkCloseoutTest"
# OK (6+3 tests)

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];"
# 1 / 1 / 1 / 123

for f in preg_match_flags_offset_jit.phpt preg_last_error_jit.phpt preg_replace_backref_jit.phpt preg_split_flags_jit.phpt; do
  php bin/jit.php test/compliance/cases/stdlib/$f
done
# all green

php script/check-selfhost-spine-coverage-sync.php
make bootstrap-selfhost-vm-driver-execute-probe
# OK
'

Made with Cursor

…olith (#9542)

Embed JIT/AOT now bridges __compiler_preg_* to VmPregNative via PregJitHelper;
StringPregMatchJit is a thin dispatcher (68 LOC) with the pcre2 LLVM body
quarantined to StringPregMatchStandaloneLlvm for standalone AOT only.

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.

php-in-php: JIT StringPregMatchJit — route preg_* through VmPreg PHP not ~3k-line LLVM/pcre2 (#1492)

1 participant