Skip to content

Stdlib/AOT: ob_get_contents/get_length/end_clean user-script link (#4914) - #17653

Merged
PurHur merged 1 commit into
masterfrom
agent/stdlib-issue-4914-ob-aot-read
Jul 10, 2026
Merged

PurHur merged 1 commit into
masterfrom
agent/stdlib-issue-4914-ob-aot-read

Conversation

@PurHur

@PurHur PurHur commented Jul 10, 2026

Copy link
Copy Markdown
Owner

Summary

  • User-script AOT (PHP_COMPILER_AOT_USER_SCRIPT=1) lowered ob_get_contents(), ob_get_length(), ob_end_clean(), and ob_get_level() but link failed with undefined __phpc_ob_* symbols — JIT/VM were already green via ObOutputJitHelper / nested JIT.
  • Extend ObOutputExecCaptureLlvm (php-src ext/standard/output.c parity) with LLVM bridges on the existing ObStorageGlobals char-buffer stack for read/discard ABI symbols.
  • Lazy-link from JitObGetContents / JitObGetLength / JitObEndClean / JitObGetLevel through ObOutputRuntime::ensureObStackLinked().

php-src reference

  • ext/standard/output.c — php_ob_get_contents, php_ob_get_length, php_ob_end_clean, php_ob_get_level

PHP implementation

  • lib/JIT/Builtin/ObOutputExecCaptureLlvm.php — LLVM emit (no new C runtime)
  • lib/JIT/Builtin/ObOutputRuntime.php — lazy read-API link for deferred nested-JIT user-script AOT
  • ext/standard/JitOb*.php — ensure stack linked before ABI lookup

Verification

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php -d memory_limit=1536M vendor/bin/phpunit --filter ob_get_contents'
# OK (3 tests, 7 assertions) — includes AOT fixture ob_get_contents.phpt

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/jit.php -r "ob_start(); echo \"hello\"; \$c=ob_get_contents(); \$l=ob_get_length(); ob_end_clean(); echo \$c,\$l,ob_get_level(),\"\n\";"'
# hello50

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php -d memory_limit=1536M vendor/bin/phpunit --filter ObOutputRuntimeShrinkTest'
# OK (3 tests, 33 assertions)

Closes #4914

Made with Cursor

…#4914)

Extend ObOutputExecCaptureLlvm with LLVM bridges for the ob read/discard
ABI symbols that user-script AOT already lowered but never linked, and
lazy-link them from JitOb* lowering via ObOutputRuntime.

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.

Stdlib: ob_get_contents()/ob_get_length()/ob_end_clean() — JIT/AOT lowering (phase 2 of #3236)

1 participant