Repository navigation
php-in-php: JIT HashTableHelper — route hashtable LLVM through VmHashTable PHP not ~2.6k-line monolith (#1492) #10031
Description
Category
php-in-php · compile/runtime shared
Problem
lib/JIT/HashTableHelper.php is a ~2.6k-line LLVM monolith that lowers PHP array/hash operations directly to hashtable pointer manipulation, type probes, and abort paths. The same semantics already exist (or should exist) on the VM side via PHPCompiler\VM\HashTable and array builtins in ext/standard/VmArray.php.
Per #1492 PHP-in-PHP strategy, hashtable behavior should live in PHP (lib/VM/, ext/) with JIT emitting thin trampolines to those helpers — not growing permanent C/LLVM tables.
Consumers today include lib/JIT/Builtin/DefineRuntime.php, lib/JIT/Builtin/Type/Object_.php, lib/JIT/Context.php, lib/JIT/ClassConstFetchHelper.php, and dozens of array builtin JIT paths.
php-src reference (semantics only)
- php/php-src
Zend/zend_hash.c— reference hashtable behavior - php/php-src
Zend/zend_hash.h
Port semantics into PHP this repo owns; treat php-src C as reference, not a copy target.
Repro (baseline — no user-visible failure)
Migration is measured by LLVM line shrink + JIT/VM agreement on array/hash builtins:
wc -l lib/JIT/HashTableHelper.php # ~2617 today
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
vendor/bin/phpunit --filter ArrayBuiltin
vendor/bin/phpunit --filter VMTest --filter array_
'Pick one high-traffic slice first (e.g. setAtStringKey / alloc used by DefineRuntime).
Scope (this repo)
| Path | Work |
|---|---|
lib/VM/HashTable.php |
Expand shared PHP helpers callable from JIT |
ext/standard/VmArray.php |
Array mutation helpers reused by JIT |
lib/JIT/HashTableHelper.php |
Shrink — delegate to PHP helpers via JIT trampoline |
lib/JIT/Builtin/DefineRuntime.php |
First consumer migration |
| Tests | Existing array compliance + JIT PHPT must stay green |
Forbidden: new permanent logic in runtime/*.c or duplicate hash tables in LLVM when PHP path suffices.
Done when (v1 slice — claimable)
- One documented consumer (
DefineRuntimeorClassConstFetchHelper) routes throughVmHashTablePHP helper -
HashTableHelper.phpline count reduced ≥200 lines with no compliance regression - PR body cites php-src
zend_hash.creference + PHP implementation path -
./script/ci-fast.sh --filter DefineRuntime/ array builtin subset green
Related
- php-in-php: JIT Builtin\Type.php — shrink ~1.4k-line zval type LLVM monolith via VmValue PHP helpers (#1492) #9976 Type.php LLVM shrink · php-in-php: JIT FunctionExistsRuntime — route function_exists() through BuiltinRegistry PHP not LLVM hashtable (#1492) #9239 FunctionExistsRuntime · Epic: Self-host critical path — compiler compiles itself (M3→M5) #1492
Activity
PurHur commentedon Jun 26, 2026
claim: PHP Runtime → PHP — batch (issues #10031, #9663) — HashTableHelper v1 slice: DefineRuntime + write LLVM split.
php-in-php: HashTableHelper v1 slice — DefineRuntime + read/write LLV…
PurHur commentedon Jun 26, 2026
Merged via #11995.
Verification:
PurHur commentedon Jun 28, 2026
claim: PHP Runtime → PHP — batch (issues #10031 v1 slice follow-up, #10323)
php-in-php: HashTableHelper v2 — value-box dim isset/read LLVM to Has…
PurHur commentedon Jul 10, 2026
claim: PHP Runtime → PHP — starting this run (HashTableHelper v4: move offsetIsSetDim/readDimToValueBox/offsetUnset/writableObjectKeyValueBox LLVM to Read/WriteLlvm; #10031).
php-in-php: HashTableHelper v4 — dim isset/read/unset LLVM to Read/Wr…
PurHur commentedon Jul 10, 2026
Merged via #17755
Shrink (v4 slice)
lib/JIT/HashTableHelper.php: 1788 → 1657 lines (−131)HashTableReadLlvm:offsetIsSetDim,readDimToValueBoxHashTableWriteLlvm:offsetUnset,writableObjectKeyValueBoxVerification
vendor/bin/phpunit --filter HashTableHelperShrinkTest— OK (9 tests, 36 assertions)$a[$k]fetch,unset($a[$k]),isset($a['b'])— match$_GET['missing'] ?? 'd'—dmake bootstrap-selfhost-vm-driver-execute-probe— OKNo new
runtime/*.clogic.php-in-php: HashTableHelper v8 — move init/load/materialize LLVM to R…
php-in-php: HashTableHelper v9 — move call-arg/coerce/illegal-offset …