[webkit-changes] [WebKit/WebKit] 76449f: [JSC] Remove distinct tail bucket in JSMap / JSSet

Yusuke Suzuki noreply at github.com
Mon Aug 14 12:01:00 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 76449f2142c4ac0525718c83016c7e4c122dea0e
      https://github.com/WebKit/WebKit/commit/76449f2142c4ac0525718c83016c7e4c122dea0e
  Author: Yusuke Suzuki <ysuzuki at apple.com>
  Date:   2023-08-14 (Mon, 14 Aug 2023)

  Changed paths:
    M Source/JavaScriptCore/runtime/HashMapImpl.h
    M Source/JavaScriptCore/runtime/HashMapImplInlines.h

  Log Message:
  -----------
  [JSC] Remove distinct tail bucket in JSMap / JSSet
https://bugs.webkit.org/show_bug.cgi?id=260117
rdar://113791351

Reviewed by Michael Saboff.

JSMap / JSSet's m_tail can just point to the same entry to the head initially.
And we can keep this head's next() as nullptr.
So,

1. Iterating entries is just doing it until we hit nullptr.
2. Adding a entry is chaining a new entry after m_tail and replace m_tail with this new entry.
3. Removing a entry is unchaining from this linked-list. But we must correctly update m_tail when removing a entry which is pointed by m_tail too.

Then, we do not need to have distinct tail entry for JSMap and JSSet.

* Source/JavaScriptCore/runtime/HashMapImplInlines.h:
(JSC::HashMapImpl<HashMapBucketType>::removeNormalized):
(JSC::HashMapImpl<HashMapBucketType>::clear):
(JSC::HashMapImpl<HashMapBucketType>::setUpHeadAndTail):
(JSC::HashMapImpl<HashMapBucketType>::addNormalizedInternal):
(JSC::HashMapImpl<HashMapBucketType>::rehash):
(JSC::HashMapImpl<HashMapBucketType>::checkConsistency const):

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




More information about the webkit-changes mailing list