Skip to content

Stdlib: AOT filesize/filemtime via libc stat fields (#27013) - #27876

Merged
PurHur merged 1 commit into
masterfrom
agent/stdlib-27013-aot-filesize
Aug 5, 2026
Merged

PurHur merged 1 commit into
masterfrom
agent/stdlib-27013-aot-filesize

Conversation

@PurHur

@PurHur PurHur commented Aug 5, 2026

Copy link
Copy Markdown
Owner

Summary

  • Fixes AOT filesize() / filemtime() / sibling long fields returning garbage (type-tag 1 or pointer-sized ints) while VM/JIT matched Zend.
  • Root cause: thin AOT NestedJIT of StatFieldsJitHelper::longField → VmStatCache arrays mis-reads values; path predicates already used libc via JitStatKernel.
  • Long-field ABI bridge now reads glibc struct stat offsets through JitStatKernel::longField (peer #19215 mode kernel / FtokRuntime).

Closes #27013

php-src reference

  • ext/standard/filestat.c — PHP_FUNCTION(filesize) / php_stat
  • Implementation: ext/standard/JitStatKernel.php, ext/standard/JitStatPathKernel.php

Test plan

  • Issue repro (VM/JIT/AOT):
    ./script/docker-exec.sh -- bash -lc '
    php bin/vm.php test/repro/issue_27013_aot_filesize.php
    php bin/jit.php test/repro/issue_27013_aot_filesize.php 2>/dev/null | grep -v Deprecated
    php bin/compile.php -o /tmp/aot_27013 test/repro/issue_27013_aot_filesize.php && /tmp/aot_27013
    '
    → all print 2
  • AOT repeat: 10/10 runs print 2
  • Sibling fields on /etc/hostname match Zend under AOT
  • vendor/bin/phpunit --filter 'FilesizeBuiltinTest|StatPathRuntimeShrinkTest' → OK
  • Not covered: full ci-local / compliance sweep; unrelated helper-runtime KeySort/ValueSort prelink staleness

Gate snapshot (before claim)

  • docker info: OK
  • release-readiness: blocked by unrelated stale KeySort/ValueSort helper prelink; gen0-driver-functional ok

Made with Cursor

Thin AOT NestedJIT of VmStatCache arrays returned type-tag/pointer
garbage for filesize and sibling long fields. Emit glibc struct stat
offsets through JitStatKernel (peer path-mode kernel / FtokRuntime).

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur
PurHur merged commit eb0e29e into master Aug 5, 2026
1 check failed
@PurHur
PurHur deleted the agent/stdlib-27013-aot-filesize branch August 5, 2026 19:44
PurHur added a commit that referenced this pull request Aug 5, 2026
Rebuild prelinked/bootstrap-gen0 argv driver so lowering_source_fingerprint
matches tip (03437367ebe7…) after #27864 merge raced with later stdlib landings.

Co-authored-by: Cursor <cursoragent@cursor.com>
PurHur added a commit that referenced this pull request Aug 5, 2026
#27869)

Rebuild prelinked/bootstrap-gen0 argv driver so lowering_source_fingerprint
matches tip (03437367ebe7…) after #27864 merge raced with later stdlib landings.

Co-authored-by: PurHur <PurHur@users.noreply.github.com>
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.

Regression: AOT filesize() returns wrong size — VM/JIT match Zend (ext/standard/filestat.c)

1 participant