Category
bug · AOT NestedJIT · leftover of #3075 / peer #34338 mb_scrub · Pillar Correctness
Problem
mb_detect_encoding() JIT only compile-time-folds the 1-arg literal form. A runtime haystack (chr(0xE2).chr(0x82).chr(0xAC)) or any encodings-list argument throws:
mb_detect_encoding() JIT requires a compile-time string literal (1-arg) in this compiler build
VM/Zend return UTF-8 / ASCII. Same leftover shape as #34338 / #34309 (NestedJIT helper, no VmMbstring from thin AOT).
Verified on master @ b3cbdaf036 (aot-smoke 8/8):
| Repro |
Zend 8.2 / VM |
AOT thin |
$s=chr(0xE2).chr(0x82).chr(0xAC); echo mb_detect_encoding($s); |
UTF-8 |
LogicException (compile rc=2) |
echo mb_detect_encoding('café', ['UTF-8','ASCII'], true); |
UTF-8 |
same LogicException |
echo mb_detect_encoding('hello'); (literal) |
ASCII |
ASCII (fold) |
php-src reference
PHP implementation target
ext/mbstring/JitMbDetectEncoding.php — NestedJIT for runtime $string; encodings list + $strict remain compile-time (peer JitMbScrub)
ext/mbstring/MbDetectEncodingJitHelper.php — ASCII / UTF-8 / ISO-8859-1 / 8BIT leaf; no VmMbstring / MbstringState (NestedJIT abort)
lib/JIT/Builtin/MbDetectEncodingRuntime.php — lazy JitVmHelperLink (not Type::initialize)
Repro
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php test/repro/aot_mb_detect_encoding_runtime.php
php bin/compile.php -o /tmp/det.bin test/repro/aot_mb_detect_encoding_runtime.php && /tmp/det.bin'
Done when
Related
Category
bug· AOT NestedJIT · leftover of #3075 / peer #34338 mb_scrub · Pillar CorrectnessProblem
mb_detect_encoding()JIT only compile-time-folds the 1-arg literal form. A runtime haystack (chr(0xE2).chr(0x82).chr(0xAC)) or any encodings-list argument throws:mb_detect_encoding() JIT requires a compile-time string literal (1-arg) in this compiler buildVM/Zend return
UTF-8/ASCII. Same leftover shape as #34338 / #34309 (NestedJIT helper, noVmMbstringfrom thin AOT).Verified on master @
b3cbdaf036(aot-smoke8/8):$s=chr(0xE2).chr(0x82).chr(0xAC); echo mb_detect_encoding($s);UTF-8echo mb_detect_encoding('café', ['UTF-8','ASCII'], true);UTF-8echo mb_detect_encoding('hello');(literal)ASCIIASCII(fold)php-src reference
ext/mbstring/mbstring.c—PHP_FUNCTION(mb_detect_encoding)PHP implementation target
ext/mbstring/JitMbDetectEncoding.php— NestedJIT for runtime$string; encodings list +$strictremain compile-time (peerJitMbScrub)ext/mbstring/MbDetectEncodingJitHelper.php— ASCII / UTF-8 / ISO-8859-1 / 8BIT leaf; noVmMbstring/MbstringState(NestedJIT abort)lib/JIT/Builtin/MbDetectEncodingRuntime.php— lazyJitVmHelperLink(notType::initialize)Repro
Done when
./script/aot-smoke.shstill 8/8runtime/*.cRelated
mb_scrubNestedJIT leftover patternmb_convert_encodingNestedJIT leftover pattern