Bug 207184 - [WTF] Introduce FrozenHashMap
Summary: [WTF] Introduce FrozenHashMap
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Yusuke Suzuki
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-02-03 22:25 PST by Yusuke Suzuki
Modified: 2020-02-06 16:06 PST (History)
14 users (show)

See Also:


Attachments
Patch (43.28 KB, patch)
2020-02-04 22:53 PST, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (45.90 KB, patch)
2020-02-04 23:00 PST, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (46.40 KB, patch)
2020-02-06 15:41 PST, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (46.48 KB, patch)
2020-02-06 16:06 PST, Yusuke Suzuki
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Yusuke Suzuki 2020-02-03 22:25:31 PST
Introduce FrozenHashMap. This is space-efficient, non-modifiable HashMap.
The relationship is something like,

1. RefCountedArray <-> Vector
2. FrozenHashMap <-> HashMap

Idea,

1. For small sized hash-map, we transparently convert it to associative-vector and perform binary searching.
2. For medium / large sized hash-map, we recalculate best-fit-size and make HashTable allocated.
Comment 1 Yusuke Suzuki 2020-02-03 22:26:58 PST
(In reply to Yusuke Suzuki from comment #0)
> Introduce FrozenHashMap. This is space-efficient, non-modifiable HashMap.
> The relationship is something like,
> 
> 1. RefCountedArray <-> Vector
> 2. FrozenHashMap <-> HashMap
> 
> Idea,
> 
> 1. For small sized hash-map, we transparently convert it to
> associative-vector and perform binary searching.

I'm planning to add lower-tier for HashMap, which is, like, up to 8 elements, we use linear search. But I don't want to make them sorted since this involves many moves.
So, for normal HashMap, we just append it in an insertion order, and doing linear search.
But once it is converted to FrozenHashMap, we should construct sorted vector and perform binary-search.

> 2. For medium / large sized hash-map, we recalculate best-fit-size and make
> HashTable allocated.
Comment 2 Yusuke Suzuki 2020-02-04 22:53:09 PST
Created attachment 389771 [details]
Patch
Comment 3 Yusuke Suzuki 2020-02-04 23:00:25 PST
Created attachment 389772 [details]
Patch
Comment 4 Yusuke Suzuki 2020-02-06 15:41:16 PST
Created attachment 390016 [details]
Patch
Comment 5 Yusuke Suzuki 2020-02-06 16:06:28 PST
Created attachment 390017 [details]
Patch