WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
NEW
136934
Add a move operator and constructor override to HashSet
https://bugs.webkit.org/show_bug.cgi?id=136934
Summary
Add a move operator and constructor override to HashSet
Roger Fong
Reported
2014-09-18 16:56:22 PDT
We do this to ensure that the Hashtable fields are zero'ed out when performing a move operation. fast\dom\html-collections-named-getter.html fails in debug builds without this do a failing assertion that a hashset is empty.
Attachments
patch
(2.92 KB, patch)
2014-09-18 17:03 PDT
,
Roger Fong
no flags
Details
Formatted Diff
Diff
patch
(2.99 KB, patch)
2014-09-18 18:01 PDT
,
Roger Fong
no flags
Details
Formatted Diff
Diff
patch
(2.88 KB, patch)
2014-09-18 18:53 PDT
,
Roger Fong
darin
: review-
Details
Formatted Diff
Diff
Show Obsolete
(2)
View All
Add attachment
proposed patch, testcase, etc.
Roger Fong
Comment 1
2014-09-18 17:03:58 PDT
Created
attachment 238337
[details]
patch
Roger Fong
Comment 2
2014-09-18 18:01:30 PDT
Created
attachment 238342
[details]
patch
Roger Fong
Comment 3
2014-09-18 18:53:00 PDT
Created
attachment 238347
[details]
patch
Darin Adler
Comment 4
2014-09-19 08:53:40 PDT
Comment on
attachment 238347
[details]
patch View in context:
https://bugs.webkit.org/attachment.cgi?id=238347&action=review
review- because the EWS compiles failed; I think you are on the right track here, though
> Source/WTF/wtf/HashSet.h:114 > + HashSet(HashSet&&); > + HashSet& operator=(HashSet&&);
We need to add regression tests for this. The file Tools/TestWebKitAPI/Tests/WTF/HashSet.cpp already exists, so we should add tests to it. It should not be hard to test that the set moved from ends up empty and the set moved to ends up with the appropriate contents. I would have expected that adding these should not have been necessary because HashTable class already has a move constructor and assignment operator, but perhaps there’s something I’m missing. That test will really clear up the mystery.
> Source/WTF/wtf/HashSet.h:315 > + template<typename Value, typename HashFunctions, typename Traits> > + inline HashSet<typename Value, typename HashFunctions, typename Traits>::HashSet(HashSet&& other) > + { > + swap(other); > + }
This should instead be: ... : m_impl(WTF::move(other.m_impl)) { } The swap function does unnecessary work. I’m not sure the WTF::move is needed, by the way. Having a regression test is the key.
> Source/WTF/wtf/HashSet.h:323 > + template<typename T, typename U, typename V> > + inline auto HashSet<T, U, V>::operator=(HashSet&& other) -> HashSet& > + { > + HashSet temp = WTF::move(other); > + swap(temp); > + return *this; > + }
This should instead be: ... { m_impl = WTF::move(other.m_impl); } The swap function does unnecessary work. I’m not sure the WTF::move is needed, by the way. Having a regression test is the key.
Anders Carlsson
Comment 5
2014-09-19 10:40:44 PDT
We should also make this windows only as well; MSVC seems buggy in this regard - the move ctor and move assignment operator should be generated automatically.
Darin Adler
Comment 6
2014-09-19 10:49:31 PDT
(In reply to
comment #5
)
> We should also make this windows only as well; MSVC seems buggy in this regard - the move ctor and move assignment operator should be generated automatically.
So it should be: #if COMPILER(MSVC) And be documented as a workaround for a compiler bug.
Anders Carlsson
Comment 7
2014-09-19 10:54:27 PDT
(In reply to
comment #6
)
> (In reply to
comment #5
) > > We should also make this windows only as well; MSVC seems buggy in this regard - the move ctor and move assignment operator should be generated automatically. > > So it should be: > > #if COMPILER(MSVC) > > And be documented as a workaround for a compiler bug.
Looking at
http://blogs.msdn.com/b/vcblog/archive/2014/06/11/c-11-14-feature-tables-for-visual-studio-14-ctp1.aspx
it's likely that it's been fixed in VS 2014, so I think we should check for VS2013 explicitly.
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