[webkit-changes] [WebKit/WebKit] f67fff: [JSC] Optimize Dictionary access

Yusuke Suzuki noreply at github.com
Fri May 12 19:48:14 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: f67fffe90284d8a2213dcabf8afd53b2284780a5
      https://github.com/WebKit/WebKit/commit/f67fffe90284d8a2213dcabf8afd53b2284780a5
  Author: Yusuke Suzuki <ysuzuki at apple.com>
  Date:   2023-05-12 (Fri, 12 May 2023)

  Changed paths:
    A JSTests/microbenchmarks/dictionary-addition.js
    M Source/JavaScriptCore/runtime/JSObject.cpp
    M Source/JavaScriptCore/runtime/JSObject.h
    M Source/JavaScriptCore/runtime/JSObjectInlines.h
    M Source/JavaScriptCore/runtime/PropertyTable.h
    M Source/JavaScriptCore/runtime/Structure.cpp
    M Source/JavaScriptCore/runtime/Structure.h
    M Source/JavaScriptCore/runtime/StructureInlines.h

  Log Message:
  -----------
  [JSC] Optimize Dictionary access
https://bugs.webkit.org/show_bug.cgi?id=256688
rdar://109250549

Reviewed by Justin Michaud.

For simplicity, we were searching dictionary twice when adding a property to the dictionary.
We should avoid this. This patch carefully split PropertyTable operation into two, taking
a lock at appropriate time (we need it only when updating the table), and avoiding dictionary
lookup twice.

                                    ToT                     Patched

    dictionary-addition      118.8175+-0.5511     ^    113.7027+-0.5406        ^ definitely 1.0450x faster

* JSTests/microbenchmarks/dictionary-addition.js: Added.
(test):
* Source/JavaScriptCore/runtime/JSObject.cpp:
(JSC::JSObject::putDirectToDictionaryWithoutExtensibility):
* Source/JavaScriptCore/runtime/JSObject.h:
* Source/JavaScriptCore/runtime/JSObjectInlines.h:
(JSC::JSObject::putDirectInternal):
* Source/JavaScriptCore/runtime/PropertyTable.h:
(JSC::PropertyTable::add):
(JSC::PropertyTable::addAfterFind):
(JSC::PropertyTable::takeDeletedOffset):
(JSC::PropertyTable::nextOffset):
(JSC::PropertyTable::getDeletedOffset): Deleted.
* Source/JavaScriptCore/runtime/Structure.h:
* Source/JavaScriptCore/runtime/StructureInlines.h:
(JSC::Structure::addOrReplacePropertyWithoutTransition):

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




More information about the webkit-changes mailing list