<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">We almost always perform bounds checking in our use of Vector — the default behaviour bounds checks every access, it is a negligible cost, and in most cases the remaining non-checked instances of Vector&lt;&gt; can probably actually be made checked.<div class=""><br class=""></div><div class="">The current bounds checked iterator on <a href="http://bugs.webkit.org" class="">bugs.webkit.org</a> also has no performance impact, and it is having to do bounds and overflow checking. We really need to be careful about saying release checking is expensive, if even in our core vector type bounds checking is fine it’s unlikely most other simple tests will be fine. For example JSC has been steadily moving towards RELEASE_ASSERT for everything.</div><div class=""><br class=""></div><div class="">—Oliver</div><div class=""><br class=""><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Nov 19, 2014, at 5:06 PM, Alex Christensen &lt;<a href="mailto:alex.christensen@flexsim.com" class="">alex.christensen@flexsim.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Has anybody done any performance benchmarking on this?&nbsp; I imagine the changes would be significant based on how hot the vector code is.&nbsp; There are 8 cases I see that would be worth looking into: unsigned and size_t, with and without bounds checking, 32-bit and 64-bit architectures.&nbsp; The performance gains of not doing bounds checking would be worth being extra careful in some cases.<div class=""><br class=""></div><div class=""><div class=""><div class="gmail_extra">Alex</div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Wed, Nov 19, 2014 at 4:13 PM, Chris Dumez <span dir="ltr" class="">&lt;<a href="mailto:cdumez@apple.com" target="_blank" class="">cdumez@apple.com</a>&gt;</span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div style="word-wrap:break-word" class="">If we don’t want to crash on overflow, the callers can use the try*() API I believe (e.g. tryAppend()). This returns false (and does not resize the vector) instead of crashing, when we reach the size limit.<span class=""><br class=""><div class="">
<div style="letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; word-wrap: break-word;" class=""><div class=""><br class=""></div><div class="">Kr,</div><div class="">--</div><div class="">Chris Dumez - Apple Inc.</div><div class="">Cupertino, CA</div><div class=""><br class=""></div></div><br class=""><br class="">

</div>
<br class=""></span><div class=""><div class="h5"><div class=""><blockquote type="cite" class=""><div class="">On Nov 19, 2014, at 2:58 PM, Alexey Proskuryakov &lt;<a href="mailto:ap@webkit.org" target="_blank" class="">ap@webkit.org</a>&gt; wrote:</div><br class=""><div class=""><div style="word-wrap:break-word" class=""><br class=""><div class=""><div class="">19 нояб. 2014 г., в 13:58, Filip Pizlo &lt;<a href="mailto:fpizlo@apple.com" target="_blank" class="">fpizlo@apple.com</a>&gt; написал(а):</div><br class=""><blockquote type="cite" class=""><div style="word-wrap:break-word" class=""><blockquote type="cite" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class=""><div class=""><div style="word-wrap:break-word" class=""><div class="">With Vector though, I don't know how we would differentiate code paths that need large allocations from ones that don't. Nearly anything that is exposed as a JS API or deals with external world can hit sizes over 4Gb. That's not out of reach in most scenarios, not even for resources loaded from network.</div></div></div></blockquote><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class=""><br class=""></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class="">Can you provide an example?</div></div></blockquote><br class=""></div><div class="">Yes. XMLHttpRequest::m_binaryResponseBuilder keeps the downloaded data in a Vector, so any time there is much data, something bad will happen. This is a case that we should support, and not just crash as we would when we think that only exploits would try to use as much memory.</div><div class=""><br class=""></div><div class="">All code that is Blob related also uses Vectors, and of course Blobs can legitimately be large.</div><div class=""><br class=""></div><div class="">Crypto code uses Vectors internally for the data.</div><div class=""><br class=""></div><div class="">These and related uses are all over the place - see also Vectors in&nbsp;FormDataBuilder, data returned from FrameLoader::loadResourceSynchronously, plug-in code that loads from network, SharedBuffer etc.</div><div class=""><br class=""></div><div class="">
<div style="letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word" class=""><div class="">- Alexey</div><div class=""><br class=""></div></div></div></div></div></blockquote></div><br class=""></div></div></div><br class="">_______________________________________________<br class="">
webkit-dev mailing list<br class="">
<a href="mailto:webkit-dev@lists.webkit.org" class="">webkit-dev@lists.webkit.org</a><br class="">
<a href="https://lists.webkit.org/mailman/listinfo/webkit-dev" target="_blank" class="">https://lists.webkit.org/mailman/listinfo/webkit-dev</a><br class="">
<br class=""></blockquote></div><br class=""><br clear="all" class=""><div class=""><br class=""></div>-- <br class=""><div class="gmail_signature"><div class="">&nbsp;<br class="webkit-block-placeholder"></div><p class="">Alex Christensen</p><p class="">FlexSim Software Products, Inc.</p><p class=""><i class=""><span style="font-size:10pt" class="">1577 North Technology Way | Building A | Suite 2300 | Orem, Utah 84097</span></i></p><p class=""><i class=""><span style="font-size:10pt" class="">Voice:&nbsp;<a value="+18012246914" style="color:rgb(17,85,204)" class="">801-224-6914</a>&nbsp;| Fax:&nbsp;<a value="+18012246984" style="color:rgb(17,85,204)" class="">801-224-6984</a></span></i></p><p class=""><i class=""><span style="font-size:10pt" class="">Email:</span></i><span style="font-size:10pt" class="">&nbsp;</span><a href="mailto:kimw@flexsim.com" style="color:rgb(17,85,204)" target="_blank" class=""><span style="font-size:10pt;color:blue" class="">alexc@flexsim.com</span></a><span style="font-size:10pt" class=""></span></p><p class=""><i class=""><span style="font-size:10pt" class="">URL:</span></i><span style="font-size:10pt" class="">&nbsp;</span><a href="http://www.flexsim.com/" style="color:rgb(17,85,204)" target="_blank" class=""><span style="font-size:10pt;color:blue" class="">www.flexsim.com</span></a><span style="font-size:10pt" class=""></span></p><div class="">&nbsp;<br class="webkit-block-placeholder"></div><p class=""><span style="font-size:10pt" class="">----------------------------------------------------------------------------------------</span><span style="font-size:12pt" class="">&nbsp;<br class=""></span><span style="font-size:10pt" class="">This message may contain confidential information, and is</span><span style="font-size:12pt" class="">&nbsp;</span><span style="font-size:10pt" class="">intended</span></p><p class=""><span style="font-size:10pt" class="">only for the use of the individual(s) to whom it is</span><span style="font-size:12pt" class="">&nbsp;</span><span style="font-size:10pt" class="">addressed.</span><span style="font-size:12pt" class="">&nbsp;<br class=""></span><span style="font-size:10pt" class="">----------------------------------------------------------------------------------------</span></p></div>
</div></div></div></div>
_______________________________________________<br class="">webkit-dev mailing list<br class=""><a href="mailto:webkit-dev@lists.webkit.org" class="">webkit-dev@lists.webkit.org</a><br class="">https://lists.webkit.org/mailman/listinfo/webkit-dev<br class=""></div></blockquote></div><br class=""></div></div></body></html>