Category
Regression · AOT · DOM · re-#31396 / peer RuntimeIndirect vs SimpleXML FALIAS
Problem
DOMDocument::saveXML(1) / saveHTML(1) / saveXML('x') inside try fail at AOT compile with:
SimpleXMLElement::asXML() user-script AOT requires a compile-time constructed tree (#19306)
Zend and VM catch TypeError as expected. Without try, thin AOT compiles and raises the TypeError at runtime. Inside try, the receiver operand loses TYPE_OBJECT, so RuntimeIndirectInstanceMethodCall builds candidates for every class that defines saveXML — including SimpleXMLElement's FALIAS of asXML. Emitting the SXE arm throws at compile time even though the runtime class_id would select DOMDocument.
| Repro |
Zend / VM |
AOT (master @ 8c55585) |
try { $d->saveXML(1); } catch … |
TypeError caught |
compile exit 2 (SXE asXML) |
bare $d->saveXML(1); |
TypeError fatal |
TypeError fatal (OK) |
php-src reference
PHP implementation target
lib/JIT.php — early-bind domdocument::savexml / savehtml before RuntimeIndirect when Dom kernel is active (peer appendChild / c14n)
lib/JIT/Call/RuntimeIndirectInstanceMethodCall.php — do not let one candidate's compile-time LogicException abort the whole module
Repro
./script/aot-smoke.sh
./script/docker-exec.sh -- bash -lc 'php test/repro/aot_dom_savexml_int_typeerror.php'
./script/docker-exec.sh -- bash -lc 'php bin/vm.php test/repro/aot_dom_savexml_int_typeerror.php'
./script/docker-exec.sh -- bash -lc 'PHP_COMPILER_HELPER_RUNTIME_O=0 php bin/compile.php -o /tmp/t test/repro/aot_dom_savexml_int_typeerror.php && /tmp/t'
./script/phpunit.sh --filter DomSaveXmlIntTypeErrorAotTest
Done when
Category
Regression· AOT · DOM · re-#31396 / peer RuntimeIndirect vs SimpleXML FALIASProblem
DOMDocument::saveXML(1)/saveHTML(1)/saveXML('x')insidetryfail at AOT compile with:SimpleXMLElement::asXML() user-script AOT requires a compile-time constructed tree (#19306)Zend and VM catch
TypeErroras expected. Withouttry, thin AOT compiles and raises the TypeError at runtime. Insidetry, the receiver operand losesTYPE_OBJECT, soRuntimeIndirectInstanceMethodCallbuilds candidates for every class that definessaveXML— including SimpleXMLElement's FALIAS ofasXML. Emitting the SXE arm throws at compile time even though the runtimeclass_idwould selectDOMDocument.try { $d->saveXML(1); } catch …$d->saveXML(1);php-src reference
ext/dom/php_dom.stub.php—saveXML(?DOMNode $node = null)ext/simplexml/sxe.c—saveXMLFALIAS ofasXMLPHP implementation target
lib/JIT.php— early-binddomdocument::savexml/savehtmlbefore RuntimeIndirect when Dom kernel is active (peer appendChild / c14n)lib/JIT/Call/RuntimeIndirectInstanceMethodCall.php— do not let one candidate's compile-timeLogicExceptionabort the whole moduleRepro
Done when
./script/aot-smoke.shstays 8/8DomSaveXmlIntTypeErrorAotTestgreen