Skip to content

php-in-php: route json_decode JIT through JsonDecodeJitHelper PHP (#9359) - #11918

Merged
PurHur merged 1 commit into
masterfrom
agent/issue-9359-json-decode-php
Jun 26, 2026
Merged

PurHur merged 1 commit into
masterfrom
agent/issue-9359-json-decode-php

Conversation

@PurHur

@PurHur PurHur commented Jun 26, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add ext/standard/JsonDecodeJitHelper.php as SSOT for runtime json_decode() / json_validate() / json_last_error* in compiled JIT modules (delegates to VmJsonFormat, VmJsonScanner, VmJson).
  • Rewrite lib/JIT/Builtin/StringJsonDecode.php to thin LLVM bridges (pattern from #9267 encode / #9163 unserialize); standalone AOT still uses StringJsonDecodeJit (~2128 LOC LLVM quarantine).
  • StringJsonDecode.php grows from 41 → ~230 lines of bridge glue; JIT decode path no longer calls StringJsonDecodeJit::implement() on embed builds.

php-src ref: ext/json/php_json.c — php_json_decode_ex, php_json_validate

C/LLVM shrink: JIT/normal __compiler_json_decode no longer emits StringJsonDecodeJit parser LLVM (~2.1k lines bypassed on embed path; monolith retained for standalone only).

Closes #9359

Test plan

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
./vendor/bin/phpunit --filter JsonDecodeRuntimeShrinkTest
./vendor/bin/phpunit --filter StringJsonDecodeRuntimeStandaloneTest
./vendor/bin/phpunit --filter "json_decode\.phpt|json_decode_jit|json_last_error" test/compliance/
php bin/vm.php -r "var_export(json_decode(\"{\\\"a\\\":1}\", true)); echo \"\n\";"
php bin/jit.php -r "var_export(json_decode(\"{\\\"a\\\":1}\", true)); echo \"\n\";"
'
make bootstrap-selfhost-vm-driver-execute-probe

Results (2026-06-26):

  • JsonDecodeRuntimeShrinkTest — OK (3 tests)
  • StringJsonDecodeRuntimeStandaloneTest — OK (3 tests)
  • Compliance filter json_decode|json_last_error — OK (17 tests)
  • VM/JIT repro json_decode('{"a":1}', true) — array ('a' => 1,)
  • make bootstrap-selfhost-vm-driver-execute-probe — OK

Made with Cursor

)

JIT/normal modules now bridge __compiler_json_decode/validate/last_error to
compiled VmJson PHP helpers; standalone AOT keeps StringJsonDecodeJit LLVM.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

php-in-php: JIT StringJsonDecodeJit — route json_decode()/json_validate() through VmJson PHP not ~2.1k-line LLVM (#1492)

1 participant