Category
php-in-php · language
Problem
ArrayAccess offset syntax $obj[$key] (read/write) lowers through lib/JIT/ArrayAccessHelper.php (~301 LOC) with LLVM interface checks and indirect offsetGet/offsetSet calls. VM dispatches via PHP (lib/VM.php + user methods).
Duplicated logic risks drift vs php-src read_dimension / write_dimension on objects implementing ArrayAccess (#3331, #4012).
php-src reference
Repro
wc -l lib/JIT/ArrayAccessHelper.php
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/jit.php -r "
class C implements ArrayAccess {
private array \$d = [];
public function offsetExists(\$k): bool { return isset(\$this->d[\$k]); }
public function offsetGet(\$k): mixed { return \$this->d[\$k]; }
public function offsetSet(\$k, \$v): void { \$this->d[\$k] = \$v; }
public function offsetUnset(\$k): void { unset(\$this->d[\$k]); }
}
\$c = new C(); \$c[\"x\"] = 1; echo \$c[\"x\"];
" 2>&1
'
Scope (PHP-in-PHP)
| Path |
Work |
lib/JIT/ArrayAccessHelper.php |
Replace LLVM monolith with VmArrayAccess trampoline |
lib/VM/ArrayAccessDispatch.php (new or existing) |
SSOT for offsetGet/Set/Exists/Unset |
lib/JIT/Call/RuntimeIndirectInstanceMethodCall.php |
Reuse where possible |
Done when
Related
Category
php-in-php·languageProblem
ArrayAccessoffset syntax$obj[$key](read/write) lowers throughlib/JIT/ArrayAccessHelper.php(~301 LOC) with LLVM interface checks and indirectoffsetGet/offsetSetcalls. VM dispatches via PHP (lib/VM.php+ user methods).Duplicated logic risks drift vs php-src
read_dimension/write_dimensionon objects implementingArrayAccess(#3331, #4012).php-src reference
Zend/zend_execute.c—ZEND_FETCH_OBJ_R, ArrayAccess dimension handlersZend/zend_interfaces.c—zend_call_known_instance_methodforoffsetGet/offsetSetRepro
Scope (PHP-in-PHP)
lib/JIT/ArrayAccessHelper.phpVmArrayAccesstrampolinelib/VM/ArrayAccessDispatch.php(new or existing)lib/JIT/Call/RuntimeIndirectInstanceMethodCall.phpDone when
ArrayAccessHelper.php≤ ~50 LOC glue; monolithic LLVM removed./script/ci-fast.sh --filter ArrayAccessgreen (add JIT smoke if missing)Related