<div dir="ltr">I agree with Phil, we should just use unsigned consistently. For very large memory allocations Vector is probably not the right type to use.<br><div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:13px">  antti</span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Nov 19, 2014 at 10:32 PM, Filip Pizlo <span dir="ltr">&lt;<a href="mailto:fpizlo@apple.com" target="_blank">fpizlo@apple.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>Whatever we do, the clients of Vector should be consistent about what type they use.  I&#39;m actually fine with Vector internally using unsigned even if the API uses size_t, but right now we have lots of code that uses a mix of size_t and unsigned when indexing into Vectors.  That&#39;s confusing.</div><div><br></div>If I picked one type to use for all Vector indices, it would be unsigned rather than size_t.  Vector being limited to unsigned doesn&#39;t imply 4GB unless you do Vector&lt;char&gt;.  Usually we have Vectors of pointer-width things, which means 32GB on 64-bit systems (UINT_MAX * sizeof(void*)).  Even in a world where we had more than 32GB of memory to use within a single web process, I would hope that we wouldn&#39;t use it all on a single Vector and that if we did, we would treat that one specially for a bunch of other sensible reasons (among them being that allocating a contiguous slab of virtual memory of that size is rather taxing).  So, size_t would buy us almost nothing since if we had a vector grow large enough to need it, we would be having a bad time already.<div><br></div><div>I wonder: are there cases that anyone remembers where we have tried to use Vector to store more than UINT_MAX things?  Another interesting question is: What&#39;s the largest number of things that we store into any Vector?  We could use such a metric to project how big Vectors might get in the future.<br><div><br></div><div>-Filip<br><div><div><br></div><div><br><div><blockquote type="cite"><div><div class="h5"><div>On Nov 19, 2014, at 12:20 PM, Chris Dumez &lt;<a href="mailto:cdumez@apple.com" target="_blank">cdumez@apple.com</a>&gt; wrote:</div><br></div></div><div><div><div class="h5"><div style="word-wrap:break-word">Hi all,<br><br>I recently started updating the WTF::Vector API to use unsigned types instead of size_t [1][2], because:<br>- WTF::Vector is already using unsigned type for size/capacity internally to save memory on 64-bit, causing a mismatch between the API and the internal representation [3]<br>- Some reviewers have asked me to use unsigned for loop counters iterating over vectors (which looks unsafe as the Vector API, e.g. size(), returns a size_t).<br>- I heard from Joseph that this type mismatch is forcing us (and other projects using WTF) to disable some build time warnings<br>- The few people I talked to before making that change said we should do it<br><br>However, Alexey recently raised concerns about this change. it doesn&#39;t &quot;strike him as the right direction. 4Gb is not much, and we should have more of WebKit work with the right data types, not less.”.<br>I did not initially realize that this change was controversial, but now that it seems it is, I thought I would raise the question on webkit-dev to see what people think about this.<br><br>Kr,<br><div>
<div style="letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word"><div>--</div><div>Chris Dumez - Apple Inc.</div><div>Cupertino, CA</div><div><br></div></div><br>[1] <a href="http://trac.webkit.org/changeset/176275" target="_blank">http://trac.webkit.org/changeset/176275</a><br>[2] <a href="http://trac.webkit.org/changeset/176293" target="_blank">http://trac.webkit.org/changeset/176293</a><br>[3] <a href="http://trac.webkit.org/changeset/148891" target="_blank">http://trac.webkit.org/changeset/148891</a>

</div>
<br></div></div></div>_______________________________________________<br>webkit-dev mailing list<br><a href="mailto:webkit-dev@lists.webkit.org" target="_blank">webkit-dev@lists.webkit.org</a><br><a href="https://lists.webkit.org/mailman/listinfo/webkit-dev" target="_blank">https://lists.webkit.org/mailman/listinfo/webkit-dev</a><br></div></blockquote></div><br></div></div></div></div></div><br>_______________________________________________<br>
webkit-dev mailing list<br>
<a href="mailto:webkit-dev@lists.webkit.org">webkit-dev@lists.webkit.org</a><br>
<a href="https://lists.webkit.org/mailman/listinfo/webkit-dev" target="_blank">https://lists.webkit.org/mailman/listinfo/webkit-dev</a><br>
<br></blockquote></div><br></div>