Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: a09e68d41ee57705c2f983578869cf4d72964372
      
https://github.com/WebKit/WebKit/commit/a09e68d41ee57705c2f983578869cf4d72964372
  Author: Yusuke Suzuki <[email protected]>
  Date:   2023-11-13 (Mon, 13 Nov 2023)

  Changed paths:
    A JSTests/stress/typed-array-bigint64-sort.js
    M Source/JavaScriptCore/builtins/BuiltinNames.h
    M Source/JavaScriptCore/builtins/TypedArrayPrototype.js
    M Source/JavaScriptCore/bytecode/LinkTimeConstant.h
    M Source/JavaScriptCore/runtime/JSGenericTypedArrayView.h
    M Source/JavaScriptCore/runtime/JSGenericTypedArrayViewInlines.h
    M Source/JavaScriptCore/runtime/JSGenericTypedArrayViewPrototypeFunctions.h
    M Source/JavaScriptCore/runtime/JSGlobalObject.cpp
    M Source/JavaScriptCore/runtime/JSGlobalObject.h
    M Source/JavaScriptCore/runtime/JSTypedArrayViewPrototype.cpp
    M Source/JavaScriptCore/runtime/JSTypedArrayViewPrototype.h

  Log Message:
  -----------
  [JSC] Make TypedArray sort C++
https://bugs.webkit.org/show_bug.cgi?id=264789
rdar://118368873

Reviewed by Mark Lam.

Now, CachedCall gets much faster, so this patch moves TypedArray#sort 
implementation from JS to C++.
This is particularly good for TypedArray since they can just use Vector to 
allocate temporary buffer
for merge sort. When comparator is not specified, we use std::sort. But when it 
is specified, we use
our own merge sort function since std::sort will crash when values get changed 
during sorting.

We first copy TypedArray content, sorting, and then writing back to the 
original TypedArray. This is
because TypedArray can be detached or resized while executing comparator. So, 
for now, we just copy them
all so that it makes our algorithm simplified. It would be possible that we 
should reconsider using
our own quick sort for large TypedArray and checking detaching / resizing state 
every time executing
comparator.

* Source/JavaScriptCore/builtins/BuiltinNames.h:
* Source/JavaScriptCore/builtins/TypedArrayPrototype.js:
(at):
(linkTimeConstant.typedArrayMerge): Deleted.
(linkTimeConstant.typedArrayMergeSort): Deleted.
(sort): Deleted.
(toSorted): Deleted.
* Source/JavaScriptCore/bytecode/LinkTimeConstant.h:
* Source/JavaScriptCore/runtime/JSGenericTypedArrayView.h:
* Source/JavaScriptCore/runtime/JSGenericTypedArrayViewInlines.h:
(JSC::JSGenericTypedArrayView<Adaptor>::sort):
(JSC::JSGenericTypedArrayView<Adaptor>::sortFloat):
* Source/JavaScriptCore/runtime/JSGenericTypedArrayViewPrototypeFunctions.h:
(JSC::typedArrayMerge):
(JSC::typedArrayMergeSort):
(JSC::genericTypedArrayViewProtoFuncSortImpl):
(JSC::genericTypedArrayViewProtoFuncSort):
(JSC::genericTypedArrayViewProtoFuncToSorted):
(JSC::genericTypedArrayViewPrivateFuncClone): Deleted.
(JSC::genericTypedArrayViewPrivateFuncSort): Deleted.
* Source/JavaScriptCore/runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::init):
(JSC::JSGlobalObject::visitChildrenImpl):
* Source/JavaScriptCore/runtime/JSGlobalObject.h:
(JSC::JSGlobalObject::typedArrayProtoSort const): Deleted.
* Source/JavaScriptCore/runtime/JSTypedArrayViewPrototype.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
(JSC::JSTypedArrayViewPrototype::finishCreation):
* Source/JavaScriptCore/runtime/JSTypedArrayViewPrototype.h:

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


_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to