Skip to content

php-in-php: JIT StringStrtokJit — route strtok() through VmString PHP not ~480-line phpc_strtok LLVM (#1492) #9812

Description

@PurHur

Category

php-in-php · php-src-strict runtime semantics

Problem

strtok() VM semantics live in ext/standard/strtok.php / VmString::strtok(), but JIT/AOT still link lib/JIT/Builtin/StringStrtokJit.php (~480 lines) emitting phpc_strtok / __phpc_strtok_* LLVM with a fixed 64KiB global buffer — duplicating PHP logic and blocking C-runtime shrink.

php-src reference

Repro (parity guard)

Save as test/repro/maintainer_strtok_jit_parity.php:

<?php
$s = "a,b,c";
echo strtok($s, ","), "\n";
echo strtok(","), "\n";
echo strtok(","), "\n";
echo var_export(strtok(","), true), "\n";
strtok("x:y", ":");
echo strtok(":"), "\n";
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php test/repro/maintainer_strtok_jit_parity.php
php bin/vm.php test/repro/maintainer_strtok_jit_parity.php
php bin/jit.php test/repro/maintainer_strtok_jit_parity.php
'

VM today matches Zend; JIT/AOT must call the same PHP helper after migration (no second strtok walk in LLVM).

Scope (this repo)

Path Work
ext/standard/StrtokJitHelper.php (new) or extend JitStrtok.php Compiled PHP SSOT callable from JIT bridge
lib/JIT/Builtin/StringStrtokJit.php Thin ABI: delegate to helper; delete buffer/table LLVM
lib/JIT/Builtin/JitStrtok.php Wire bridge
AOT standalone link Prefer compiled helper over phpc_strtok symbol
Tests test/compliance/cases/stdlib/strtok_jit.phpt

Done when

  • JIT + AOT repro output matches VM/Zend
  • StringStrtokJit.php shrinks to bridge-only (target: −400+ LLVM lines)
  • No new symbols in lib/AOT/runtime/*.c
  • ./script/ci-fast.sh --filter strtok green (or targeted PHPUnit filter above)

Related

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