Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: bde9f45eabd5205808b2ae36791b669bdd4fe61a
      
https://github.com/WebKit/WebKit/commit/bde9f45eabd5205808b2ae36791b669bdd4fe61a
  Author: Yusuke Suzuki <[email protected]>
  Date:   2025-11-12 (Wed, 12 Nov 2025)

  Changed paths:
    M Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp
    M Source/JavaScriptCore/dfg/DFGOperations.cpp
    M Source/JavaScriptCore/inspector/JSInjectedScriptHost.cpp
    M Source/JavaScriptCore/runtime/JSMapIterator.cpp
    M Source/JavaScriptCore/runtime/JSMapIterator.h
    M Source/JavaScriptCore/runtime/JSSetIterator.cpp
    M Source/JavaScriptCore/runtime/JSSetIterator.h
    M Source/JavaScriptCore/runtime/MapPrototype.cpp
    M Source/JavaScriptCore/runtime/OrderedHashTable.h
    M Source/JavaScriptCore/runtime/OrderedHashTableHelper.h
    M Source/JavaScriptCore/runtime/SetPrototype.cpp
    M Source/WebCore/bindings/js/SerializedScriptValue.cpp

  Log Message:
  -----------
  [JSC] Optimize Map / Set iteration
https://bugs.webkit.org/show_bug.cgi?id=302382
rdar://164537076

Reviewed by Sosuke Suzuki.

This patch improves two things in Map / Set iterations.

1. OrderedHashTable should not load used capacity information. It turned
   out this unnecessary load is causing a bit of cache stall (according
   to the profiler data). Since entries are always ending with JSEmpty
   keys (we are extending hash table before reaching to full entries.
   Thus it is guaranteed that these entries are having unused slots at
   the end.
2. JSMapIterator and JSSetIterator are always materializing Storage of
   Map / Set even for empty Map and Set. But this is not great since
   it can throw an error in the constructor of JSSetIterator /
   JSMapIterator. Also this unnecessarily allocates memory for empty Map
   and Set. Instead, JSSetIterator / JSMapIterator's next operations
   should handle initial state of JSMapIterator and JSSetIterator
   appropriately. If they are having empty storage, and iterated object
   is having empty storage too, then it means that both are empty and we
   finished the iteration. If iterated object is having a storage, then
   we can grab it and start iterating. This avoids many unnecessary
   allocations when Map / Set are empty.

* Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp:
(JSC::DFG::ByteCodeParser::handleIntrinsicCall):
* Source/JavaScriptCore/dfg/DFGOperations.cpp:
(JSC::DFG::JSC_DEFINE_JIT_OPERATION):
* Source/JavaScriptCore/inspector/JSInjectedScriptHost.cpp:
(Inspector::cloneMapIteratorObject):
(Inspector::cloneSetIteratorObject):
* Source/JavaScriptCore/runtime/JSMapIterator.cpp:
(JSC::JSMapIterator::finishCreation):
(JSC::JSC_DEFINE_HOST_FUNCTION):
* Source/JavaScriptCore/runtime/JSMapIterator.h:
* Source/JavaScriptCore/runtime/JSSetIterator.cpp:
(JSC::JSSetIterator::finishCreation):
(JSC::JSC_DEFINE_HOST_FUNCTION):
* Source/JavaScriptCore/runtime/JSSetIterator.h:
* Source/JavaScriptCore/runtime/MapPrototype.cpp:
(JSC::createMapIteratorObject):
* Source/JavaScriptCore/runtime/OrderedHashTable.h:
(JSC::OrderedHashTable::storage):
* Source/JavaScriptCore/runtime/OrderedHashTableHelper.h:
(JSC::OrderedHashTableHelper::copyImpl):
(JSC::OrderedHashTableHelper::transitAndNext):
* Source/JavaScriptCore/runtime/SetPrototype.cpp:
(JSC::createSetIteratorObject):
* Source/WebCore/bindings/js/SerializedScriptValue.cpp:
(WebCore::CloneSerializer::serialize):

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



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to