Skip to content

Stdlib: uasort/array_uasort JIT lowering via UsortRuntime (#5698) - #18678

Merged
PurHur merged 1 commit into
masterfrom
agent/stdlib-uasort-aot-5698
Jul 13, 2026
Merged

PurHur merged 1 commit into
masterfrom
agent/stdlib-uasort-aot-5698

Conversation

@PurHur

@PurHur PurHur commented Jul 13, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes incorrect JIT/AOT routing for uasort() / array_uasort()uasort_::call() previously invoked SortRuntime::sortPacked() (packed sort() semantics, wrong for key-preserving value sort).

php-src reference

PHP implementation

Verification

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/jit.php test/repro/agent_aot_uasort_strcmp.php
php bin/jit.php test/repro/agent_aot_array_uasort.php
php bin/jit.php test/compliance/cases/stdlib/uasort_jit.phpt
'
php vendor/bin/phpunit --filter UsortRuntimeShrinkTest
php vendor/bin/phpunit --filter ValueSortRuntimeShrinkTest

Output:

a:apple
c:mango
b:zebra
array (
  'a' => 1,
  'b' => 2,
)
apple,mango,zebra
OK (2 tests, 27 assertions)
OK (3 tests, 9 assertions)

AOT note: php bin/compile.php currently fails LLVM module verify in this environment (pre-existing __value__writeHashtable mismatch, including echo 42). AOT fixtures added (uasort_assoc_strcmp.phpt, array_uasort_closure.phpt) for when that regression is fixed.

Follow-up: VM array_uasort()/array_uksort() aliases still no-op under bin/vm.php while direct uasort()/uksort() work — separate dispatch bug; compliance array_uasort_uksort.phpt fails on VM.

Closes #5698

Made with Cursor

Replace incorrect SortRuntime::sortPacked routing in uasort_::call() with
UsortRuntime::uasortValues: strcmp uses __hashtable__sortStringKeyValues for
string-key tables and SortRuntime for packed lists; closure comparators use a
new UsortJitHelper::sortValuesWithClosure bridge. Use exportKeyValuePairs in
sort helpers for nested JIT/AOT compatibility (#12908).

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: register array_uasort/array_uksort/array_udiff* aliases in Module.php (ext/standard array.c names)

1 participant