[webkit-changes] [WebKit/WebKit] 2b9995: [JSC] Improve Object.entries runtime function perf...

Yusuke Suzuki noreply at github.com
Wed Oct 12 21:52:15 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 2b999503e6896bb9dc2557d8ae4c2d910ee32a4e
      https://github.com/WebKit/WebKit/commit/2b999503e6896bb9dc2557d8ae4c2d910ee32a4e
  Author: Yusuke Suzuki <ysuzuki at apple.com>
  Date:   2022-10-12 (Wed, 12 Oct 2022)

  Changed paths:
    M Source/JavaScriptCore/runtime/ObjectConstructor.cpp
    M Source/JavaScriptCore/runtime/ObjectConstructorInlines.h

  Log Message:
  -----------
  [JSC] Improve Object.entries runtime function performance
https://bugs.webkit.org/show_bug.cgi?id=246009
rdar://100783096

Reviewed by Justin Michaud.

This patch improves Object.entries performance.

1. We check structure bits and ensure that we do not have any getters / setters for the given object.
   And we ensure that any special properties do not exist. Then, we can do very fast iteration via Structure::forEachProperty.
2. We allocate exact size JSArray by first collecting everything via (1).
3. We look up Keys' CachedPropertyNames from Structure and reuse already allocated JSString if possible. And we also add a cache
   if this is called multiple times.

Existing microbenchmark (JSTests/microbenchmarks/object-entries.js) showed that we get 37% improvement.

                           ToT                     Patched

object-entries       34.1877+-0.0439     ^     25.1768+-0.0507        ^ definitely 1.3579x faster

* Source/JavaScriptCore/runtime/ObjectConstructor.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):

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




More information about the webkit-changes mailing list