Skip to content

php-in-php: drop Context ensureMinimalUserStandaloneBodies always-on JitReturnPending — lazy at try/finally (peer #34612) #34621

Description

@PurHur

Category

Foundation · php-in-php · runtime-shrink · cold-build / #32122 class

Problem

Context::ensureMinimalUserStandaloneBodies() still eagerly NestedJIT/links JitReturnPending on every thin AOT user-script init (hello-world / aot-smoke path), even when the script never uses try/finally return-through-finally:

  • JitReturnPending::ensureStandaloneBodies → ReturnPendingRuntime → JitHelperAbiBridge::implement (ends with clearInsertionPosition())

Same always-on NestedJIT vs Runtime ABI drift / cold-build surface class as closed #34612 / #34605 / #32122 .1-mint risk.

Call sites already ensure before use:

  • lib/JIT/TryCatchHelper.php — beginTry / return-through-finally → JitReturnPending::ensureLinked
  • lib/JIT.php — emitPendingReturnResume → JitReturnPending::ensureLinked

JitHelperAbiBridge::implement must capture/restore builder insert (peer ErrorHandlerJitRuntime / #34612) so mid-{main} ensureLinked is safe — today it always clearInsertionPosition(), which is why this stayed always-on.

php-src reference

PHP implementation target

Repro

./script/aot-smoke.sh
./script/docker-exec.sh -- bash -lc 'script/cold-build-check.sh'
./script/phpunit.sh --filter 'ContextMinimalStandaloneLazyReturnPending|ContextMinimalStandaloneLazyHtmlErrorHandler|ExamplesHelloWorldAot'
./script/docker-exec.sh -- bash -lc 'printf "%s\n" "<?php function f(){ try { return 1; } finally { echo \"f\"; } } echo f(), \"\n\";" >/tmp/rp.php && php bin/compile.php -o /tmp/rp.bin /tmp/rp.php && /tmp/rp.bin'

Done when

  • ensureMinimalUserStandaloneBodies does not eagerly link JitReturnPending
  • JitHelperAbiBridge::implement restores insert when one was active
  • aot-smoke 8/8 + cold-build-check stay green
  • try/finally return-through-finally AOT still matches Zend
  • No new hand-written C under lib/AOT/runtime/

Parent

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:compilerCompiler / CFG / JITenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-0:FoundationPhase 0 – foundation & DevEx

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions