Skip to content

php-in-php: JIT StringSimilarTextJit — route similar_text() through VmString PHP not ~420-line LLVM (#1492) #9731

Description

@PurHur

Category

php-in-php | stdlib

Problem

similar_text() has a PHP VM implementation (ext/standard/similar_text.php, VmString::similarText), but JIT/AOT standalone still lowers through lib/JIT/Builtin/StringSimilarTextJit.php (~420 lines of hand-written LLVM). This duplicates logic already expressible in PHP and blocks self-host shrinking of emit-helper C/LLVM tables.

php-src reference

Repro (LLVM path active today)

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php -r "echo similar_text(\"hello\", \"hallo\", \$p), \" \", \$p, PHP_EOL;"   # VM PHP path OK
wc -l lib/JIT/Builtin/StringSimilarTextJit.php'
# StringSimilarTextJit.php ~420 lines; AOT standalone links LLVM symbol __compiler_similar_text

Standalone inventory includes StringSimilarTextJit.php on bootstrap spine (docs/bootstrap-inventory.md).

Scope (this repo)

Piece Path
PHP helper ext/standard/SimilarTextJitHelper.php (new) wrapping VmString::similarText
JIT entry replace StringSimilarTextJit::implement body with PHP trampoline
Delete/shrink lib/JIT/Builtin/StringSimilarTextJit.php LLVM emitter
Tests existing test/compliance/cases/stdlib/similar_text*.phpt; test/unit/JIT/*SimilarText*

Done when

  • JIT + AOT standalone similar_text() output matches VM/Zend (percent + optional by-ref)
  • StringSimilarTextJit.php LLVM line count reduced ≥80% (thin trampoline only)
  • test/unit/AotRuntimeInventoryTest.php / runtime shrink tests updated
  • ./script/ci-fast.sh --filter similar_text green

Links

Pattern: #9496 (CtypeJitHelper), #9626 (PregReplacementExpand) · #1492

Activity

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-4:stdlibPhase 4 – stdlib for web appsstdlib

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions