Stdlib: uasort/array_uasort JIT lowering via UsortRuntime (#5698) - #18678
Merged
Merged
Conversation
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>
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes incorrect JIT/AOT routing for
uasort()/array_uasort()—uasort_::call()previously invokedSortRuntime::sortPacked()(packedsort()semantics, wrong for key-preserving value sort).php-src reference
ext/standard/array.c—php_array_uasort/php_array_usortPHP implementation
lib/JIT/Builtin/UsortRuntime.php— newuasortValues(): strcmp →__hashtable__sortStringKeyValues(assoc string keys) orSortRuntime::sortPacked(packed lists); closure →UsortJitHelper::sortValuesWithClosurebridgeext/standard/uasort_.php—call()delegates toUsortRuntime::uasortValuesext/standard/UsortJitHelper.php—sortValuesWithClosure;exportKeyValuePairsfor nested JIT (php-in-php: delete StringStrtrStandaloneLlvm — route standalone AOT through StrtrArrayJitHelper PHP (#9392 completion) #12908)ext/standard/ValueSortJitHelper.php—exportKeyValuePairsin apply pathVerification
Output:
AOT note:
php bin/compile.phpcurrently fails LLVM module verify in this environment (pre-existing__value__writeHashtablemismatch, includingecho 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 underbin/vm.phpwhile directuasort()/uksort()work — separate dispatch bug; compliancearray_uasort_uksort.phptfails on VM.Closes #5698
Made with Cursor