Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: ecc19320f35ab186fd51bc558b871367f53814e6
      
https://github.com/WebKit/WebKit/commit/ecc19320f35ab186fd51bc558b871367f53814e6
  Author: Yusuke Suzuki <[email protected]>
  Date:   2022-10-26 (Wed, 26 Oct 2022)

  Changed paths:
    M JSTests/stress/unshiftCountSlowCase-correct-postCapacity.js
    M Source/JavaScriptCore/runtime/ArrayPrototype.cpp
    M Source/JavaScriptCore/runtime/JSArray.cpp
    M Source/JavaScriptCore/runtime/JSArray.h

  Log Message:
  -----------
  [JSC] Prefer array move in unshift
https://bugs.webkit.org/show_bug.cgi?id=247027
rdar://101561203

Reviewed by Michael Saboff.

It turned out that we should always use array-move based unshift for non 
ArrayStorage arrays.
Converting normal arrays with ArrayStorage is too costly since it penaltizes 
many code having optimized
path for non ArrayStorage arrays. Plus, unshift operation is adding an element: 
this means we frequently
move elements to grow an array. So the balance between ArrayStorage based 
implementation v.s. array-move
is different from Array#shift. And using array-move based unshift is more 
efficient in most cases.

We also modified JSTests/stress/unshiftCountSlowCase-correct-postCapacity.js to 
make it ArrayStorage to align
the original test purpose. This test pass when memory is exhausted. Because of 
this change, this test gets
optimized, and it cannot exhaust the memory until the timeout now.

JetStream2/coffeescript-wtb gets 8.01% improvement and JetStream2/uglifyjs-wtb 
gets 4.50% improvement.

* Source/JavaScriptCore/runtime/ArrayPrototype.cpp:
(JSC::shift):
(JSC::unshift):
(JSC::JSC_DEFINE_HOST_FUNCTION):
* Source/JavaScriptCore/runtime/JSArray.cpp:
(JSC::JSArray::shiftCountWithAnyIndexingType):
(JSC::JSArray::unshiftCountWithAnyIndexingType):
* Source/JavaScriptCore/runtime/JSArray.h:
(JSC::JSArray::unshiftCount):
(JSC::JSArray::unshiftCountForShift): Deleted.
(JSC::JSArray::unshiftCountForSplice): Deleted.

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


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

Reply via email to