Skip to content

php-in-php: strrchr() JIT via StrrchrJitHelper PHP — drop libc LLVM (#1492) #15406

Description

@PurHur

Category

php-in-php · php-src-strict

Problem

strrchr() JIT still calls libc via lookupFunction('strrchr') in ext/standard/JitStrrchr.php; VM SSOT is VmString::strrchr(). Sibling readlink() already uses ReadlinkJitHelper + StringReadlink PHP bridges (#15353).

php-src reference

Repro

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php test/compliance/cases/stdlib/strrchr.phpt
php bin/jit.php test/compliance/cases/stdlib/strrchr_jit.phpt'

Implementation (PHP-in-PHP)

  • ext/standard/StrrchrJitHelper.php — delegate to VmString::strrchr()
  • lib/JIT/Builtin/StringStrrchr.php — LLVM bridge (__phpc_jit_strrchr)
  • Shrink ext/standard/JitStrrchr.php to thin wrapper (drop libc strrchr + manual slice)
  • Compliance guards exist (strrchr.phpt, strrchr_jit.phpt)

Done when

  • JIT strrchr no longer calls libc strrchr in JitStrrchr.php
  • VM/JIT compliance green
  • StrrchrRuntimeShrinkTest + spine bundle includes helper

Related

Activity

  1. added
    implementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claim
    on Jul 3, 2026
  2. PurHur commented on Jul 3, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Runtime → PHP — starting this run.

  3. PurHur commented on Jul 3, 2026

    @PurHur
    OwnerAuthor

    Merged via #15407.

    PHP-in-PHP: StrrchrJitHelper + StringStrrchr LLVM bridge; JitStrrchr.php shrunk from 73 → 22 lines (dropped libc strrchr(3) + manual slice).

    Verification (green):

    • phpunit test/unit/StrrchrRuntimeShrinkTest.php — OK (4 tests)
    • php bin/vm.php test/compliance/cases/stdlib/strrchr.phpt — OK
    • php bin/jit.php test/compliance/cases/stdlib/strrchr_jit.phpt — OK
    • php script/check-selfhost-spine-coverage-sync.php — OK
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

    implementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claim

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions