Skip to content

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

Closed

Description

@PurHur

Category

php-in-php

Problem

After #12982, all standalone preg_* except preg_replace_callback route through PregMatchRuntime + PregJitHelper PHP. lib/JIT/Builtin/StringPregMatchStandaloneLlvm.php remains ~1272 LOC with libpcre2-8 external calls — the largest remaining JIT LLVM monolith outside ArrayBuiltinHelper.

php-src reference

Repro

wc -l lib/JIT/Builtin/StringPregMatchStandaloneLlvm.php
grep implementReplaceCallbackOnly lib/JIT/Builtin/PregMatchRuntime.php

Scope

  • Add PregJitHelper::replaceCallbackArgv() delegating to VmPregNative
  • Route __compiler_preg_replace_callback through PHP bridge (embed + standalone)
  • Delete or reduce StringPregMatchStandaloneLlvm.php to thin ABI only

Done when

  • StringPregMatchStandaloneLlvm.php < 200 LOC or deleted
  • JIT/AOT preg_replace_callback compliance + repro green
  • PR lists LOC removed

Related

#9542 · #12982 · #1492

Activity

  1. added
    enhancementNew feature or request
    implementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claim
    on Jun 29, 2026
  2. PurHur commented on Jun 29, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Runtime → PHP — batch (#13736 blocked after #13735 merge)

    Status: blocked for this run — needs dedicated callback-ABI design.

    Investigation: StringPregMatchStandaloneLlvm (~1272 LOC) remains solely for __compiler_preg_replace_callback — libpcre2-8 match loop + VM callback invoke at runtime. PregMatchRuntime already routes all other preg_* through PregJitHelper PHP (#12982); only callback form still needs native PCRE + function-pointer ABI.

    Blocker: PregJitHelper has no replaceCallbackArgv() yet; VmPregReplaceCallback is VM-only. Embed JIT must invoke compiled user callbacks — JitPregReplaceCallback.php resolves callback to functions['name'] pointer. PHP-bridge path needs nested JIT compile of callback dispatch or thin trampoline preserving current ABI.

    Next step: Add PregJitHelper::replaceCallbackArgv() delegating to new VmPregNative::pregReplaceCallback() with match→callback loop in PHP, plus LLVM bridge for callback fn ptr (similar to ArrayMapRuntime closure path). Expect multi-file PR touching VmPregNative, PregMatchRuntime, delete implementReplaceCallbackOnly slice.

    Ref: lib/JIT/Builtin/StringPregMatchStandaloneLlvm.php:1249 (implementReplaceCallbackOnly)

  3. PurHur commented on Jun 29, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Runtime → PHP — batch (#13736)

  4. PurHur commented on Jun 29, 2026

    @PurHur
    OwnerAuthor

    Merged via #13743.

    Verification: JIT preg_replace_callback_jit compliance green; runtime-shrink unit tests green; make bootstrap-selfhost-vm-driver-execute-probe OK.

    LOC: deleted StringPregMatchStandaloneLlvm.php (1272 lines); net −1021 in PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:compilerCompiler / CFG / JITenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-0:FoundationPhase 0 – foundation & DevExphase-2:languagePhase 2 – language features

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions