Category
php-in-php — shrink json_decode LLVM duplicate (#9267 covers json_encode only)
Problem
json_encode() migration is tracked in #9267, but json_decode() / json_validate() still use StringJsonDecodeJit.php (~2,128 lines of hand-written LLVM implementing __compiler_json_decode / validation paths, mirroring phpc_json_decode.c).
VM paths already use PHP scanners in ext/json/ — JIT/AOT should call the same PHP helpers, not maintain a second parser in LLVM.
php-src reference
Repro
# VM (PHP scanner) works for basic decode:
./script/docker-exec.sh -- php bin/vm.php -r '
var_export(json_decode("{\"a\":1}", true));
'
# array ('a' => 1,)
# LLVM duplicate footprint:
wc -l lib/JIT/Builtin/StringJsonDecodeJit.php
# JIT must match VM after migration:
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/jit.php -r "
var_export(json_decode(\"{\\\"a\\\":1}\", true));
"'
# json_validate flags path (coordinate #8748 enum TypeError separately):
./script/docker-exec.sh -- php bin/vm.php -r '
var_export(json_validate("{}"));
var_export(json_validate("{"));
'
Scope (this repo)
| Path |
Work |
ext/json/VmJson*.php |
SSOT decode/validate |
lib/JIT/Builtin/StringJsonDecodeJit.php |
Replace with PHP bridge |
lib/JIT/Builtin/StringJsonDecode.php |
Wire bridge |
ext/standard/json_validate.php |
Share scanner with decode |
| Tests |
Extend existing json compliance PHPTs for JIT path |
Done when
Related
Category
php-in-php— shrink json_decode LLVM duplicate (#9267 covers json_encode only)Problem
json_encode()migration is tracked in #9267, butjson_decode()/json_validate()still useStringJsonDecodeJit.php(~2,128 lines of hand-written LLVM implementing__compiler_json_decode/ validation paths, mirroringphpc_json_decode.c).VM paths already use PHP scanners in
ext/json/— JIT/AOT should call the same PHP helpers, not maintain a second parser in LLVM.php-src reference
ext/json/php_json.c—php_json_decode(),php_json_decode_ex()ext/json/php_json_parser.cRepro
Scope (this repo)
ext/json/VmJson*.phplib/JIT/Builtin/StringJsonDecodeJit.phplib/JIT/Builtin/StringJsonDecode.phpext/standard/json_validate.phpDone when
StringJsonDecodeJit.phpshrinks to thin ABI (>80% line reduction target)JSON_THROW_ON_ERRORbehavior follows Stdlib: json_decode()/json_encode() with JSON_THROW_ON_ERROR must throw JsonException (ext/json/php_json.c) #9032 once landed (do not regress)./script/ci-local.sh --filter JsonDecodegreenRelated