WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
226872
Add WeakHashMap
https://bugs.webkit.org/show_bug.cgi?id=226872
Summary
Add WeakHashMap
Ryosuke Niwa
Reported
2021-06-10 04:05:02 PDT
Add the basic version of WeakHashMap which replies on lazy deletion of key & value.
Attachments
Patch
(53.71 KB, patch)
2021-06-10 04:18 PDT
,
Ryosuke Niwa
no flags
Details
Formatted Diff
Diff
Fixed the builds
(53.71 KB, patch)
2021-06-10 11:43 PDT
,
Ryosuke Niwa
no flags
Details
Formatted Diff
Diff
Added amortized deletion
(60.72 KB, patch)
2021-06-11 04:20 PDT
,
Ryosuke Niwa
no flags
Details
Formatted Diff
Diff
Show Obsolete
(2)
View All
Add attachment
proposed patch, testcase, etc.
Ryosuke Niwa
Comment 1
2021-06-10 04:18:01 PDT
Created
attachment 431061
[details]
Patch
Geoffrey Garen
Comment 2
2021-06-10 09:44:15 PDT
Pending ews, this approach looks good to me. But I also think we should add a counter, so that after N operations on a weak map, we iterate and clear all nulls. Such a counter maintains the average case amortized O(1) guarantee. And that way, when we talk about the need for a more intrusive way to clear nulls, we’ll compare against the best possible baseline and avoid premature optimization.
Ryosuke Niwa
Comment 3
2021-06-10 11:43:44 PDT
(In reply to Geoffrey Garen from
comment #2
)
> Pending ews, this approach looks good to me. > > But I also think we should add a counter, so that after N operations on a > weak map, we iterate and clear all nulls. Such a counter maintains the > average case amortized O(1) guarantee. And that way, when we talk about the > need for a more intrusive way to clear nulls, we’ll compare against the best > possible baseline and avoid premature optimization.
Which operations though? If done natively, that seems like it's gonna bloat the code size everywhere.
Ryosuke Niwa
Comment 4
2021-06-10 11:43:57 PDT
Created
attachment 431100
[details]
Fixed the builds
Geoffrey Garen
Comment 5
2021-06-10 13:04:26 PDT
> > But I also think we should add a counter, so that after N operations on a > > weak map, we iterate and clear all nulls. Such a counter maintains the > > average case amortized O(1) guarantee. And that way, when we talk about the > > need for a more intrusive way to clear nulls, we’ll compare against the best > > possible baseline and avoid premature optimization. > > Which operations though? If done natively, that seems like it's gonna bloat > the code size everywhere.
My straw man proposal would be all insertion, removal, and lookup operations. If that has a significant impact on code size, my second straw man proposal would be not to mark those functions inline. (I seriously doubt their value as inline functions on modern processors, since the cost is always going to be in the out of line lookup function.)
Geoffrey Garen
Comment 6
2021-06-10 13:05:08 PDT
Note that I'm proposing an increment, a branch, and a function call. So, yes, a few bytes of code, but not a ton.
Ryosuke Niwa
Comment 7
2021-06-11 04:20:20 PDT
Created
attachment 431187
[details]
Added amortized deletion
Geoffrey Garen
Comment 8
2021-06-11 09:27:05 PDT
Comment on
attachment 431187
[details]
Added amortized deletion r=me
Ryosuke Niwa
Comment 9
2021-06-11 18:42:13 PDT
Comment on
attachment 431187
[details]
Added amortized deletion Clearing flags on attachment: 431187 Committed
r278803
(
238760@main
): <
https://commits.webkit.org/238760@main
>
Ryosuke Niwa
Comment 10
2021-06-11 18:42:16 PDT
All reviewed patches have been landed. Closing bug.
Radar WebKit Bug Importer
Comment 11
2021-06-11 18:43:37 PDT
<
rdar://problem/79227218
>
Fujii Hironori
Comment 12
2021-06-16 17:07:55 PDT
Filed:
Bug 227102
– [Win] TestWTF.WTF_WeakPtr.WeakHashMapIterators is crashing
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug