Skip to content

WIP: DOM PHP 8.4 instance methods — JIT/AOT bridge (#17130)#17331

Open
PurHur wants to merge 1 commit into
masterfrom
agent/stdlib-dom-aot-batch-17130
Open

WIP: DOM PHP 8.4 instance methods — JIT/AOT bridge (#17130)#17331
PurHur wants to merge 1 commit into
masterfrom
agent/stdlib-dom-aot-batch-17130

Conversation

@PurHur

@PurHur PurHur commented Jul 7, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add per-arity DOM instance-method JIT bridge (DomInstanceMethodRuntimeVmDomInstanceInvokeVmDomJitDispatch) for loadHTML, getElementById, and existing token-list/create/append paths (Stdlib: ext/dom PHP 8.4 Living Standard — JIT/AOT compliance batch (DOMTokenList, insertAdjacent*, innerHTML) #17130).
  • Register helper unit for ext/dom/VmDomInstanceInvoke.php via COMPILED_HELPERS (helper-runtime emit/prelink path).
  • Fix VmDomJitFrame to use Superglobals::getActiveContext() (AOT has no executing PHP frame).
  • Add missing nested-JIT handler Variable::toObject() (VariableToObject + NestedVmVariableMethodLlvm).
  • Add VM repro, AOT fixture (compile-only guard), and wiring unit tests.

php-src reference

  • ext/dom/php_dom.cDOMDocument::loadHTML, DOMDocument::getElementById

PHP implementation

  • ext/dom/VmDomInstanceInvoke.php, VmDomJitDispatch.php, VmDomJitFrame.php
  • lib/JIT/Builtin/DomInstanceMethodRuntime.php, lib/JIT/Call/DomInstanceMethod.php, lib/JIT/DomInstanceMethodJit.php

Verification (2026-07-07)

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
export PHP_COMPILER_PROFILE=8.4
php bin/vm.php test/repro/aot_dom_loadhtml_probe.php'
# div_ok

php bin/jit.php test/repro/aot_dom_loadhtml_probe.php
# div_ok

php vendor/bin/phpunit test/unit/DomLoadHtmlJitDispatchTest.php --no-configuration
# OK

php bin/compile.php -o /tmp/dom_probe test/repro/aot_dom_loadhtml_probe.php
# phpc build: helper-runtime cache hit … (#15889) — compile OK

/tmp/dom_probe
# Aborted (exit 134) — AOT runtime still fails in nested helper TU

Blocker (not merge-ready)

AOT compile succeeds and links DOM bridge LLVM, but runtime aborts when the first DOM instance method runs. Root cause is incomplete nested-helper corpus: after Variable::resolveIndirect() / toObject(), dispatch still needs ObjectEntry/ClassEntry property access that is not lowered for split-compilation helper objects (same class of failure as method_exists($object) under AOT — baseline repro also aborts).

Next step: class-id-based dispatch bridge (read __object__.class_id in LLVM, call VM lookup without PHP ObjectEntry property reads) or complete #16075 extern binding for helper TUs; then refresh prelinked/helper-runtime/.../ext_dom_VmDomInstanceInvoke_php/.

Progress on #17130 — not closing yet.

Made with Cursor

…17130)

Wire ext/dom instance calls through per-arity VmDomInstanceInvoke helpers,
helper-runtime discovery (COMPILED_HELPERS), and Superglobals-based frame
lookup. Add Variable::toObject nested JIT handler. VM and JIT repros pass;
AOT compile succeeds but runtime still aborts in nested helper TU (follow-up:
ObjectEntry/class_id dispatch without PHP ObjectEntry property reads).

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur

PurHur commented Jul 8, 2026

Copy link
Copy Markdown
Owner Author

Maintainer triage 2026-07-08: bootstrap link+helloworld green. AOT runtime abort noted — not merging until execute path green. Keep WIP.

@PurHur

PurHur commented Jul 8, 2026

Copy link
Copy Markdown
Owner Author

Advanced stdlib triage (2026-07-08)

Re-verified blocker on current branch HEAD (adfce02b9):

source script/php-env.sh
php bin/vm.php test/repro/aot_dom_loadhtml_probe.php   # div_ok
php bin/jit.php test/repro/aot_dom_loadhtml_probe.php  # div_ok
php bin/compile.php -o /tmp/dom_probe test/repro/aot_dom_loadhtml_probe.php  # compile OK
/tmp/dom_probe  # Aborted (exit 134)

Same class of failure on master for already-merged DOM JIT paths:

php bin/compile.php -o /tmp/dom_create test/repro/maintainer_gap_dom_create_element_aot.php
/tmp/dom_create  # phpc: fatal signal (segfault) after c:main_before_php — exit 139

Disabling helper-runtime cache (PHP_COMPILER_HELPER_RUNTIME_O=0) does not fix the segfault.

Root cause (unchanged): user-script standalone AOT cannot run nested VmDomInstanceInvoke helper TUs — VariableObject::entry() / ObjectEntry property reads in split-compilation helpers need extern binding or per-unit llvm.global_ctors (#16075 step 4/5). VM+JIT paths are green; AOT compile+link succeeds; runtime init aborts before user PHP.

Next step: DomInstanceMethodRuntime::ensureStandaloneBodies() defer path (VM callback trampoline for user AOT, like StringHtmlspecialcharsUserScriptLlvm) OR complete helper ABI registry (#16075) before extending loadHTML/getElementById in this PR.

PR remains WIP — not merge-ready.

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.

1 participant