Category
language
Problem
#3331 closed VM dispatch for ArrayAccess — $obj[$key] read/write/isset/unset calls offsetGet/Set/Exists/Unset. JIT = no, AOT = no in docs/capabilities-syntax.md.
JIT currently deopts to VM (requiresVmLowering) for TYPE_ARRAY_DIM_FETCH on non-array objects.
php-src reference
Repro (today)
<?php
class Bag implements ArrayAccess {
private array $a = [];
public function offsetExists(mixed $k): bool { return isset($this->a[$k]); }
public function offsetGet(mixed $k): mixed { return $this->a[$k]; }
public function offsetSet(mixed $k, mixed $v): void { $this->a[$k] = $v; }
public function offsetUnset(mixed $k): void { unset($this->a[$k]); }
}
$b = new Bag();
$b['x'] = 1;
echo $b['x'], "\n";
var_export(isset($b['y']));
echo "\n";
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php repro_arrayaccess.php'
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/jit.php repro_arrayaccess.php'
| Runtime |
Expected |
| Zend |
1 then false |
| VM |
same |
| JIT/AOT |
same without VM fallback |
Scope (this repo)
| Area |
Files |
| VM |
lib/VM.php — object dim fetch/write paths (reference) |
| JIT |
lib/JIT/Builtin/Type/Object_.php, array-dim helpers — offsetGet/offsetSet method dispatch |
| Tests |
test/compliance/cases/language/arrayaccess_offset.phpt (+ jit/aot variants) |
| Matrix |
array_access_interface row |
Done when
Verification
./script/ci-fast.sh --filter arrayaccess
Links
Category
languageProblem
#3331 closed VM dispatch for
ArrayAccess—$obj[$key]read/write/isset/unset callsoffsetGet/Set/Exists/Unset. JIT = no, AOT = no indocs/capabilities-syntax.md.JIT currently deopts to VM (
requiresVmLowering) forTYPE_ARRAY_DIM_FETCHon non-array objects.php-src reference
Zend/zend_object_handlers.c—zend_std_read_dimension,zend_std_write_dimensionZend/zend_interfaces.h—zend_class_implements_interface(..., zend_ce_arrayaccess)Repro (today)
1thenfalseScope (this repo)
lib/VM.php— object dim fetch/write paths (reference)lib/JIT/Builtin/Type/Object_.php, array-dim helpers —offsetGet/offsetSetmethod dispatchtest/compliance/cases/language/arrayaccess_offset.phpt(+ jit/aot variants)array_access_interfacerowDone when
ArrayAccessuser classArrayAccessobjects still throw Zend-parityError(not silent wrong results)Verification
Links