<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>145369</bug_id>
          
          <creation_ts>2015-05-25 10:20:18 -0700</creation_ts>
          <short_desc>Clean up HashTable constructors</short_desc>
          <delta_ts>2015-11-30 09:37:55 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>New Bugs</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>WONTFIX</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          <dependson>145458</dependson>
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Zan Dobersek">zan</reporter>
          <assigned_to name="Zan Dobersek">zan</assigned_to>
          <cc>benjamin</cc>
    
    <cc>cmarcelo</cc>
    
    <cc>commit-queue</cc>
    
    <cc>darin</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1097246</commentid>
    <comment_count>0</comment_count>
    <who name="Zan Dobersek">zan</who>
    <bug_when>2015-05-25 10:20:18 -0700</bug_when>
    <thetext>Clean up HashTable constructors</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1097248</commentid>
    <comment_count>1</comment_count>
      <attachid>253686</attachid>
    <who name="Zan Dobersek">zan</who>
    <bug_when>2015-05-25 10:28:35 -0700</bug_when>
    <thetext>Created attachment 253686
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1097864</commentid>
    <comment_count>2</comment_count>
      <attachid>253686</attachid>
    <who name="Zan Dobersek">zan</who>
    <bug_when>2015-05-28 01:13:29 -0700</bug_when>
    <thetext>Comment on attachment 253686
Patch

Clearing flags on attachment: 253686

Committed r184949: &lt;http://trac.webkit.org/changeset/184949&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1097865</commentid>
    <comment_count>3</comment_count>
    <who name="Zan Dobersek">zan</who>
    <bug_when>2015-05-28 01:13:40 -0700</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1097921</commentid>
    <comment_count>4</comment_count>
      <attachid>253686</attachid>
    <who name="Darin Adler">darin</who>
    <bug_when>2015-05-28 11:57:46 -0700</bug_when>
    <thetext>Comment on attachment 253686
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=253686&amp;action=review

&gt; Source/WTF/wtf/HashTable.h:541
&gt; -        : m_table(0)
&gt; +        : m_table(nullptr)
&gt;          , m_tableSize(0)
&gt;          , m_tableSizeMask(0)
&gt;          , m_keyCount(0)
&gt;          , m_deletedCount(0)
&gt;  #if CHECK_HASHTABLE_ITERATORS
&gt; -        , m_iterators(0)
&gt; +        , m_iterators(nullptr)

I think an even better cleanup is to initialize these where they are defined instead of listing them in the constructor.

&gt; Source/WTF/wtf/HashTable.h:1201
&gt;      template&lt;typename Key, typename Value, typename Extractor, typename HashFunctions, typename Traits, typename KeyTraits&gt;
&gt;      inline HashTable&lt;Key, Value, Extractor, HashFunctions, Traits, KeyTraits&gt;::HashTable(HashTable&amp;&amp; other)
&gt; -#if CHECK_HASHTABLE_ITERATORS
&gt; -        : m_iterators(nullptr)
&gt; -        , m_mutex(std::make_unique&lt;std::mutex&gt;())
&gt; -#endif
&gt; +        : HashTable()
&gt;      {
&gt; -        other.invalidateIterators();
&gt; -
&gt; -        m_table = other.m_table;
&gt; -        m_tableSize = other.m_tableSize;
&gt; -        m_tableSizeMask = other.m_tableSizeMask;
&gt; -        m_keyCount = other.m_keyCount;
&gt; -        m_deletedCount = other.m_deletedCount;
&gt; -
&gt; -        other.m_table = nullptr;
&gt; -        other.m_tableSize = 0;
&gt; -        other.m_tableSizeMask = 0;
&gt; -        other.m_keyCount = 0;
&gt; -        other.m_deletedCount = 0;
&gt; -
&gt; -#if DUMP_HASHTABLE_STATS_PER_TABLE
&gt; -        m_stats = WTF::move(other.m_stats);
&gt; -        other.m_stats = nullptr;
&gt; -#endif
&gt; +        swap(other);
&gt;      }

Is there any performance difference?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1098110</commentid>
    <comment_count>5</comment_count>
      <attachid>253686</attachid>
    <who name="Zan Dobersek">zan</who>
    <bug_when>2015-05-29 08:07:53 -0700</bug_when>
    <thetext>Comment on attachment 253686
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=253686&amp;action=review

&gt;&gt; Source/WTF/wtf/HashTable.h:1201
&gt;&gt;      }
&gt; 
&gt; Is there any performance difference?

The generated code is significantly larger, so I&apos;ll be rolling this out.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1098112</commentid>
    <comment_count>6</comment_count>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2015-05-29 08:14:14 -0700</bug_when>
    <thetext>Re-opened since this is blocked by bug 145458</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1098123</commentid>
    <comment_count>7</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2015-05-29 09:19:45 -0700</bug_when>
    <thetext>Another way to &quot;clean up&quot; the HashTable move assignment operator is to use std::exchange instead of using separate assignment statements and nulling for each data member.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1120870</commentid>
    <comment_count>8</comment_count>
      <attachid>253686</attachid>
    <who name="Zan Dobersek">zan</who>
    <bug_when>2015-08-26 00:05:33 -0700</bug_when>
    <thetext>Comment on attachment 253686
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=253686&amp;action=review

&gt;&gt;&gt; Source/WTF/wtf/HashTable.h:1201
&gt;&gt;&gt;      }
&gt;&gt; 
&gt;&gt; Is there any performance difference?
&gt; 
&gt; The generated code is significantly larger, so I&apos;ll be rolling this out.

Calling swap() in the move constructor instead of manually nulling out all the members on the &apos;other&apos; object disables using SIMD registers, bloating up the generated code. Will avoid that.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1144776</commentid>
    <comment_count>9</comment_count>
      <attachid>253686</attachid>
    <who name="Zan Dobersek">zan</who>
    <bug_when>2015-11-30 09:25:44 -0800</bug_when>
    <thetext>Comment on attachment 253686
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=253686&amp;action=review

&gt;&gt; Source/WTF/wtf/HashTable.h:541
&gt;&gt; +        , m_iterators(nullptr)
&gt; 
&gt; I think an even better cleanup is to initialize these where they are defined instead of listing them in the constructor.

As it stands, the compilers generate the first initialization even if the member variable is reassigned in the actual constructor. So in the copy and move constructors some of these variables would be at first initialized, and then immediately reassigned with new values.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1144777</commentid>
    <comment_count>10</comment_count>
    <who name="Zan Dobersek">zan</who>
    <bug_when>2015-11-30 09:27:53 -0800</bug_when>
    <thetext>While the proposed changes would clean up the constructor code to some degree, the size of the generated code would increase as well. Given that this is utility-level library code, I think the verbosity should be preferred in this case.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1144783</commentid>
    <comment_count>11</comment_count>
      <attachid>253686</attachid>
    <who name="Darin Adler">darin</who>
    <bug_when>2015-11-30 09:37:55 -0800</bug_when>
    <thetext>Comment on attachment 253686
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=253686&amp;action=review

&gt;&gt;&gt; Source/WTF/wtf/HashTable.h:541
&gt;&gt;&gt; +        , m_iterators(nullptr)
&gt;&gt; 
&gt;&gt; I think an even better cleanup is to initialize these where they are defined instead of listing them in the constructor.
&gt; 
&gt; As it stands, the compilers generate the first initialization even if the member variable is reassigned in the actual constructor. So in the copy and move constructors some of these variables would be at first initialized, and then immediately reassigned with new values.

No dead store optimization? That’s quite surprising!</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>253686</attachid>
            <date>2015-05-25 10:28:35 -0700</date>
            <delta_ts>2015-05-28 01:13:29 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>bug-145369-20150525192824.patch</filename>
            <type>text/plain</type>
            <size>3787</size>
            <attacher name="Zan Dobersek">zan</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMTg0ODUxCmRpZmYgLS1naXQgYS9Tb3VyY2UvV1RGL0NoYW5n
ZUxvZyBiL1NvdXJjZS9XVEYvQ2hhbmdlTG9nCmluZGV4IDA1YWM5MmM3YTEwOGZkNDkzNDFiODcx
YTQ2ODY1YWM1OGJjNDJjYzcuLmI5YjAwNDA1ZWFiNDVhNGQxNjc4MWJiMDFlOTNmNjRhYzZkMDA1
ZmMgMTAwNjQ0Ci0tLSBhL1NvdXJjZS9XVEYvQ2hhbmdlTG9nCisrKyBiL1NvdXJjZS9XVEYvQ2hh
bmdlTG9nCkBAIC0xLDMgKzEsMTkgQEAKKzIwMTUtMDUtMjUgIFphbiBEb2JlcnNlayAgPHpkb2Jl
cnNla0BpZ2FsaWEuY29tPgorCisgICAgICAgIENsZWFuIHVwIEhhc2hUYWJsZSBjb25zdHJ1Y3Rv
cnMKKyAgICAgICAgaHR0cHM6Ly9idWdzLndlYmtpdC5vcmcvc2hvd19idWcuY2dpP2lkPTE0NTM2
OQorCisgICAgICAgIFJldmlld2VkIGJ5IE5PQk9EWSAoT09QUyEpLgorCisgICAgICAgIFVzZSBu
dWxscHRyIHRvIGluaXRpYWxpemUgcG9pbnRlciBtZW1iZXIgdmFyaWFibGVzIGluIHRoZSBIYXNo
VGFibGUKKyAgICAgICAgZGVmYXVsdCBjb25zdHJ1Y3Rvci4gQ29weSBhbmQgbW92ZSBjb25zdHJ1
Y3RvcnMgY2FuIHVzZSBjb25zdHJ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hudWxscHRyKQotICAgICAgICAsIG1fbXV0ZXgoc3RkOjptYWtl
X3VuaXF1ZTxzdGQ6Om11dGV4PigpKQotI2VuZGlmCisgICAgICAgIDogSGFzaFRhYmxlKCkKICAg
ICB7Ci0gICAgICAgIG90aGVyLmludmFsaWRhdGVJdGVyYXRvcnMoKTsKLQotICAgICAgICBtX3Rh
YmxlID0gb3RoZXIubV90YWJsZTsKLSAgICAgICAgbV90YWJsZVNpemUgPSBvdGhlci5tX3RhYmxl
U2l6ZTsKLSAgICAgICAgbV90YWJsZVNpemVNYXNrID0gb3RoZXIubV90YWJsZVNpemVNYXNrOwot
ICAgICAgICBtX2tleUNvdW50ID0gb3RoZXIubV9rZXlDb3VudDsKLSAgICAgICAgbV9kZWxldGVk
Q291bnQgPSBvdGhlci5tX2RlbGV0ZWRDb3VudDsKLQotICAgICAgICBvdGhlci5tX3RhYmxlID0g
bnVsbHB0cjsKLSAgICAgICAgb3RoZXIubV90YWJsZVNpemUgPSAwOwotICAgICAgICBvdGhlci5t
X3RhYmxlU2l6ZU1hc2sgPSAwOwotICAgICAgICBvdGhlci5tX2tleUNvdW50ID0gMDsKLSAgICAg
ICAgb3RoZXIubV9kZWxldGVkQ291bnQgPSAwOwotCi0jaWYgRFVNUF9IQVNIVEFCTEVfU1RBVFNf
UEVSX1RBQkxFCi0gICAgICAgIG1fc3RhdHMgPSBXVEY6Om1vdmUob3RoZXIubV9zdGF0cyk7Ci0g
ICAgICAgIG90aGVyLm1fc3RhdHMgPSBudWxscHRyOwotI2VuZGlmCisgICAgICAgIHN3YXAob3Ro
ZXIpOwogICAgIH0KIAogICAgIHRlbXBsYXRlPHR5cGVuYW1lIEtleSwgdHlwZW5hbWUgVmFsdWUs
IHR5cGVuYW1lIEV4dHJhY3RvciwgdHlwZW5hbWUgSGFzaEZ1bmN0aW9ucywgdHlwZW5hbWUgVHJh
aXRzLCB0eXBlbmFtZSBLZXlUcmFpdHM+Cg==
</data>

          </attachment>
      

    </bug>

</bugzilla>