Skip to content

Stdlib: thin AOT krsort/arsort via HashTable LLVM (#27227) - #27863

Merged
PurHur merged 1 commit into
masterfrom
agent/stdlib-27227-aot-krsort-arsort
Aug 5, 2026
Merged

PurHur merged 1 commit into
masterfrom
agent/stdlib-27227-aot-krsort-arsort

Conversation

@PurHur

@PurHur PurHur commented Aug 5, 2026

Copy link
Copy Markdown
Owner

Summary

  • Thin standalone AOT krsort() / arsort() failed module verify (1-arg bridge vs 2-arg NestedJIT helpers) and NestedJIT KeySortJitHelper / ValueSortJitHelper abort or corrupt arrays under thin AOT (HashTable method stubs).
  • Restore __hashtable__sortStringKeys* LLVM and route ksort/krsort/asort/arsort through Type\HashTable (NaturalSort Regression: AOT natsort()/natcasesort() abort after build — VM/JIT match Zend (ext/standard/array.c) #26975 pattern). Skip unconditional storeHashtableInArrayVariable on value-boxed arrays (that store corrupted thin-AOT counts/keys).
  • php-src: ext/standard/array.c — PHP_FUNCTION(krsort) / PHP_FUNCTION(arsort). VM SSOT remains VmArray::*Copy + *JitHelper for host unit tests.

Closes #27227

Test plan

  • php bin/vm.php test/repro/issue_27227_aot_krsort_arsort.php → c,b,a|3,2,1 / b,a,c|3,2,1
  • php bin/jit.php same
  • ./phpc build -o /tmp/aot_27227.bin test/repro/issue_27227_aot_krsort_arsort.php && /tmp/aot_27227.bin (10× match)
  • vendor/bin/phpunit --filter 'KeySortRuntimeShrinkTest|ValueSortRuntimeShrinkTest' → OK 8 tests
  • Side effect: asort/ksort AOT also green on same path (related Regression: AOT asort()/ksort() compile fails — Module verify arity (ext/standard/array.c) #27513 — not closed here)

Made with Cursor

NestedJIT KeySort/ValueSort helpers abort under thin standalone AOT
(HashTable method stubs). Restore __hashtable__sortStringKeys* and route
ksort/krsort/asort/arsort through Type\HashTable LLVM like NaturalSort,
avoiding unconditional HT storeback that corrupted value-boxed arrays.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur
PurHur force-pushed the agent/stdlib-27227-aot-krsort-arsort branch from e3139fd to 9faeb66 Compare August 5, 2026 18:58
@PurHur
PurHur merged commit ca03d8f into master Aug 5, 2026
@PurHur
PurHur deleted the agent/stdlib-27227-aot-krsort-arsort branch August 5, 2026 18:58
PurHur added a commit that referenced this pull request Aug 5, 2026
#27863/#27227 retired NestedJIT HELPER_PATH sites for ksort/krsort and
asort/arsort in favor of HashTable LLVM; fingerprint-stale committed
units made helper-runtime-prelink --strict fail release-readiness.

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

* Trust: honest gen-0 argv refresh after #27846–#27863 drift (#27860)

Rebuild prelinked/bootstrap-gen0 argv driver from current tip so
lowering_source_fingerprint matches live sources (no restamp).

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

* Trust: prune thin-AOT KeySort/ValueSort helper orphans (#27860)

#27863/#27227 retired NestedJIT HELPER_PATH sites for ksort/krsort and
asort/arsort in favor of HashTable LLVM; fingerprint-stale committed
units made helper-runtime-prelink --strict fail release-readiness.

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

---------

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 krsort()/arsort() compile fails — Module verify arity (ext/standard/array.c)

1 participant