WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
225108
Copy-on-write semantics should be an internal implementation detail of StorageMap
https://bugs.webkit.org/show_bug.cgi?id=225108
Summary
Copy-on-write semantics should be an internal implementation detail of Storag...
Chris Dumez
Reported
2021-04-27 09:04:41 PDT
Copy-on-write semantics should be an internal implementation details of StorageMap, instead of requiring the client to replace its storageMap explicitly.
Attachments
Patch
(29.94 KB, patch)
2021-04-27 09:39 PDT
,
Chris Dumez
no flags
Details
Formatted Diff
Diff
Patch
(29.82 KB, patch)
2021-04-27 12:28 PDT
,
Chris Dumez
no flags
Details
Formatted Diff
Diff
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
Chris Dumez
Comment 1
2021-04-27 09:39:25 PDT
Created
attachment 427157
[details]
Patch
Sihui Liu
Comment 2
2021-04-27 11:58:52 PDT
Comment on
attachment 427157
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=427157&action=review
> Source/WebKit/ChangeLog:17 > + Instead of making the StorageMap RefCounted and requiring the client to potentially > + replace its StorageMap whenever it calls functions that modify the StorageMap, the > + copy-on-write semantics in now an internal implementation detail of StorageMap. > + > + To achieve this, the following changes were made: > + - StorageMap is no longer RefCounted. Instead, it has an internal Impl data member > + that is RefCounted. > + - The internal Impl data member is the one that gets copied on write. > + - Functions that modify the StorageMap no longer need to return a StorageMap. > + - Add a clear() function for convenience.
These seem to belong to WebCore/ChangeLog
> Source/WebKitLegacy/ChangeLog:17 > + Instead of making the StorageMap RefCounted and requiring the client to potentially > + replace its StorageMap whenever it calls functions that modify the StorageMap, the > + copy-on-write semantics in now an internal implementation detail of StorageMap. > + > + To achieve this, the following changes were made: > + - StorageMap is no longer RefCounted. Instead, it has an internal Impl data member > + that is RefCounted. > + - The internal Impl data member is the one that gets copied on write. > + - Functions that modify the StorageMap no longer need to return a StorageMap. > + - Add a clear() function for convenience.
Ditto
> Source/WebCore/storage/StorageMap.h:57 > + bool isShared() const { return !m_impl->hasOneRef(); }
(Maybe a silly question) Is this possible to return true with current implementation?
Chris Dumez
Comment 3
2021-04-27 12:02:17 PDT
(In reply to Sihui Liu from
comment #2
)
> Comment on
attachment 427157
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=427157&action=review
> > > Source/WebKit/ChangeLog:17 > > + Instead of making the StorageMap RefCounted and requiring the client to potentially > > + replace its StorageMap whenever it calls functions that modify the StorageMap, the > > + copy-on-write semantics in now an internal implementation detail of StorageMap. > > + > > + To achieve this, the following changes were made: > > + - StorageMap is no longer RefCounted. Instead, it has an internal Impl data member > > + that is RefCounted. > > + - The internal Impl data member is the one that gets copied on write. > > + - Functions that modify the StorageMap no longer need to return a StorageMap. > > + - Add a clear() function for convenience. > > These seem to belong to WebCore/ChangeLog > > > Source/WebKitLegacy/ChangeLog:17 > > + Instead of making the StorageMap RefCounted and requiring the client to potentially > > + replace its StorageMap whenever it calls functions that modify the StorageMap, the > > + copy-on-write semantics in now an internal implementation detail of StorageMap. > > + > > + To achieve this, the following changes were made: > > + - StorageMap is no longer RefCounted. Instead, it has an internal Impl data member > > + that is RefCounted. > > + - The internal Impl data member is the one that gets copied on write. > > + - Functions that modify the StorageMap no longer need to return a StorageMap. > > + - Add a clear() function for convenience. > > Ditto > > > Source/WebCore/storage/StorageMap.h:57 > > + bool isShared() const { return !m_impl->hasOneRef(); } > > (Maybe a silly question) Is this possible to return true with current > implementation?
Sure. See SessionStorageNamespace::cloneTo() and StorageArea::clone(). There are cases where we clone the session data (window.open() & link with target=_blank iirc). In such cases, we initially share the same HashMap to save memory. If one of the 2 pages start modifying the HashMap though, we copy-on-write.
Chris Dumez
Comment 4
2021-04-27 12:28:29 PDT
Created
attachment 427182
[details]
Patch
Chris Dumez
Comment 5
2021-04-27 13:55:11 PDT
Comment on
attachment 427182
[details]
Patch Clearing flags on attachment: 427182 Committed
r276659
(
237086@main
): <
https://commits.webkit.org/237086@main
>
Chris Dumez
Comment 6
2021-04-27 13:55:13 PDT
All reviewed patches have been landed. Closing bug.
Radar WebKit Bug Importer
Comment 7
2021-04-27 13:56:22 PDT
<
rdar://problem/77228667
>
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