Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 798d1789439ab19b30559051cd834481ec7220ac
      
https://github.com/WebKit/WebKit/commit/798d1789439ab19b30559051cd834481ec7220ac
  Author: Alexey Shvayka <[email protected]>
  Date:   2024-03-14 (Thu, 14 Mar 2024)

  Changed paths:
    A JSTests/stress/sorting-boolean-result-comparator-typedarray.js
    M Source/JavaScriptCore/runtime/JSGenericTypedArrayViewPrototypeFunctions.h

  Log Message:
  -----------
  [JSC] TypedArray sorting methods should have a special-case for comparator 
returning `false`
https://bugs.webkit.org/show_bug.cgi?id=268075
<rdar://problem/122093956>

Reviewed by Yusuke Suzuki and Justin Michaud.

This change aligns TypedArray sorting methods with Array.prototype.sort() to 
treat `false`,
returned from comparator function, like smallest negative number rather than 
zero, which is a long-time
web reality quirk [1] to allow lexicographical comparison: `["c", "b", 
"a"].sort((a, b) => a > b)`.

The spec [2] still lacks normative steps on how to handle comparator return 
value in the common case.

This patch aligns JSC with V8 and SpiderMonkey.
However, it appears that V8 have recently removed the special-case for `false` 
in Array sorting methods.

[1]: https://bugs.webkit.org/show_bug.cgi?id=47825
[2]: https://tc39.es/ecma262/#sec-sortindexedproperties (step 4)

* JSTests/stress/sorting-boolean-result-comparator-typedarray.js: Added.
* Source/JavaScriptCore/runtime/JSGenericTypedArrayViewPrototypeFunctions.h:
(JSC::coerceComparatorResultToBoolean):
(JSC::genericTypedArrayViewProtoFuncSortImpl):

Canonical link: https://commits.webkit.org/276130@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to