Title: [209664] trunk/Source/WTF
Revision
209664
Author
[email protected]
Date
2016-12-10 10:04:09 -0800 (Sat, 10 Dec 2016)

Log Message

Avoid calling shrink() in the Vector destructor
https://bugs.webkit.org/show_bug.cgi?id=165675

Reviewed by Daniel Bates.

Avoid calling shrink() in the Vector destructor to avoid function call
overhead and unnecessarily reseting m_size to 0.

* wtf/Vector.h:
(WTF::Vector::~Vector):
(WTF::Vector::asanSetBufferSizeToFullCapacity):
(WTF::minCapacity>::asanSetBufferSizeToFullCapacity):

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (209663 => 209664)


--- trunk/Source/WTF/ChangeLog	2016-12-10 14:13:10 UTC (rev 209663)
+++ trunk/Source/WTF/ChangeLog	2016-12-10 18:04:09 UTC (rev 209664)
@@ -1,3 +1,18 @@
+2016-12-10  Chris Dumez  <[email protected]>
+
+        Avoid calling shrink() in the Vector destructor
+        https://bugs.webkit.org/show_bug.cgi?id=165675
+
+        Reviewed by Daniel Bates.
+
+        Avoid calling shrink() in the Vector destructor to avoid function call
+        overhead and unnecessarily reseting m_size to 0.
+
+        * wtf/Vector.h:
+        (WTF::Vector::~Vector):
+        (WTF::Vector::asanSetBufferSizeToFullCapacity):
+        (WTF::minCapacity>::asanSetBufferSizeToFullCapacity):
+
 2016-12-09  Michael Saboff  <[email protected]>
 
         JSVALUE64: Pass arguments in platform argument registers when making _javascript_ calls

Modified: trunk/Source/WTF/wtf/Vector.h (209663 => 209664)


--- trunk/Source/WTF/wtf/Vector.h	2016-12-10 14:13:10 UTC (rev 209663)
+++ trunk/Source/WTF/wtf/Vector.h	2016-12-10 18:04:09 UTC (rev 209664)
@@ -628,9 +628,9 @@
     ~Vector()
     {
         if (m_size)
-            shrink(0);
+            TypeOperations::destruct(begin(), end());
 
-        asanSetBufferSizeToFullCapacity();
+        asanSetBufferSizeToFullCapacity(0);
     }
 
     Vector(const Vector&);
@@ -789,7 +789,9 @@
     template<typename... Args> bool tryConstructAndAppendSlowCase(Args&&...);
 
     void asanSetInitialBufferSizeTo(size_t);
-    void asanSetBufferSizeToFullCapacity();
+    void asanSetBufferSizeToFullCapacity(size_t);
+    void asanSetBufferSizeToFullCapacity() { asanSetBufferSizeToFullCapacity(size()); }
+
     void asanBufferSizeWillChangeTo(size_t);
 
     using Base::m_size;
@@ -1056,7 +1058,7 @@
 }
 
 template<typename T, size_t inlineCapacity, typename OverflowHandler, size_t minCapacity>
-inline void Vector<T, inlineCapacity, OverflowHandler, minCapacity>::asanSetBufferSizeToFullCapacity()
+inline void Vector<T, inlineCapacity, OverflowHandler, minCapacity>::asanSetBufferSizeToFullCapacity(size_t size)
 {
 #if ASAN_ENABLED
     if (!buffer())
@@ -1063,7 +1065,9 @@
         return;
 
     // ASan requires that the annotation is returned to its initial state before deallocation.
-    __sanitizer_annotate_contiguous_container(buffer(), endOfBuffer(), buffer() + size(), endOfBuffer());
+    __sanitizer_annotate_contiguous_container(buffer(), endOfBuffer(), buffer() + size, endOfBuffer());
+#else
+    UNUSED_PARAM(size);
 #endif
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to