Title: [179751] trunk/Source
Revision
179751
Author
[email protected]
Date
2015-02-06 12:25:05 -0800 (Fri, 06 Feb 2015)

Log Message

Unreviewed, rolling out r179743.
https://bugs.webkit.org/show_bug.cgi?id=141335

caused missing symbols in non-WebKit clients of WTF::Vector
(Requested by kling on #webkit).

Reverted changeset:

"Remove WTF::fastMallocGoodSize()."
https://bugs.webkit.org/show_bug.cgi?id=141020
http://trac.webkit.org/changeset/179743

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (179750 => 179751)


--- trunk/Source/_javascript_Core/ChangeLog	2015-02-06 18:56:48 UTC (rev 179750)
+++ trunk/Source/_javascript_Core/ChangeLog	2015-02-06 20:25:05 UTC (rev 179751)
@@ -1,3 +1,17 @@
+2015-02-06  Commit Queue  <[email protected]>
+
+        Unreviewed, rolling out r179743.
+        https://bugs.webkit.org/show_bug.cgi?id=141335
+
+        caused missing symbols in non-WebKit clients of WTF::Vector
+        (Requested by kling on #webkit).
+
+        Reverted changeset:
+
+        "Remove WTF::fastMallocGoodSize()."
+        https://bugs.webkit.org/show_bug.cgi?id=141020
+        http://trac.webkit.org/changeset/179743
+
 2015-02-04  Filip Pizlo  <[email protected]>
 
         Remove BytecodeGenerator::preserveLastVar() and replace it with a more robust mechanism for preserving non-temporary registers

Modified: trunk/Source/_javascript_Core/assembler/AssemblerBuffer.h (179750 => 179751)


--- trunk/Source/_javascript_Core/assembler/AssemblerBuffer.h	2015-02-06 18:56:48 UTC (rev 179750)
+++ trunk/Source/_javascript_Core/assembler/AssemblerBuffer.h	2015-02-06 20:25:05 UTC (rev 179751)
@@ -68,9 +68,9 @@
         }
 
         AssemblerData(unsigned initialCapacity)
-            : m_buffer(static_cast<char*>(fastMalloc(initialCapacity)))
-            , m_capacity(initialCapacity)
         {
+            m_capacity = fastMallocGoodSize(initialCapacity);
+            m_buffer = static_cast<char*>(fastMalloc(m_capacity));
         }
 
         AssemblerData(AssemblerData&& other)
@@ -101,7 +101,7 @@
 
         void grow(unsigned extraCapacity = 0)
         {
-            m_capacity = m_capacity + m_capacity / 2 + extraCapacity;
+            m_capacity = fastMallocGoodSize(m_capacity + m_capacity / 2 + extraCapacity);
             m_buffer = static_cast<char*>(fastRealloc(m_buffer, m_capacity));
         }
 

Modified: trunk/Source/WTF/ChangeLog (179750 => 179751)


--- trunk/Source/WTF/ChangeLog	2015-02-06 18:56:48 UTC (rev 179750)
+++ trunk/Source/WTF/ChangeLog	2015-02-06 20:25:05 UTC (rev 179751)
@@ -1,3 +1,17 @@
+2015-02-06  Commit Queue  <[email protected]>
+
+        Unreviewed, rolling out r179743.
+        https://bugs.webkit.org/show_bug.cgi?id=141335
+
+        caused missing symbols in non-WebKit clients of WTF::Vector
+        (Requested by kling on #webkit).
+
+        Reverted changeset:
+
+        "Remove WTF::fastMallocGoodSize()."
+        https://bugs.webkit.org/show_bug.cgi?id=141020
+        http://trac.webkit.org/changeset/179743
+
 2015-02-06  Andreas Kling  <[email protected]>
 
         Remove WTF::fastMallocGoodSize().

Modified: trunk/Source/WTF/wtf/Compression.cpp (179750 => 179751)


--- trunk/Source/WTF/wtf/Compression.cpp	2015-02-06 18:56:48 UTC (rev 179750)
+++ trunk/Source/WTF/wtf/Compression.cpp	2015-02-06 20:25:05 UTC (rev 179751)
@@ -69,7 +69,7 @@
     stream.next_in = const_cast<uint8_t*>(data);
 
     size_t currentOffset = OBJECT_OFFSETOF(GenericCompressedData, m_data);
-    size_t currentCapacity = MinimumSize;
+    size_t currentCapacity = fastMallocGoodSize(MinimumSize);
     Bytef* compressedData = static_cast<Bytef*>(fastMalloc(currentCapacity));
     memset(compressedData, 0, sizeof(GenericCompressedData));
     stream.next_out = compressedData + currentOffset;
@@ -94,6 +94,7 @@
                 // data in the future.
                 newCapacity = std::max(static_cast<size_t>(expectedSize + 8), currentCapacity + 8);
             }
+            newCapacity = fastMallocGoodSize(newCapacity);
             if (newCapacity >= dataLength)
                 goto fail;
             compressedData = static_cast<Bytef*>(fastRealloc(compressedData, newCapacity));

Modified: trunk/Source/WTF/wtf/FastMalloc.cpp (179750 => 179751)


--- trunk/Source/WTF/wtf/FastMalloc.cpp	2015-02-06 18:56:48 UTC (rev 179750)
+++ trunk/Source/WTF/wtf/FastMalloc.cpp	2015-02-06 20:25:05 UTC (rev 179751)
@@ -153,6 +153,15 @@
 
 namespace WTF {
 
+size_t fastMallocGoodSize(size_t bytes)
+{
+#if OS(DARWIN)
+    return malloc_good_size(bytes);
+#else
+    return bytes;
+#endif
+}
+
 #if OS(WINDOWS)
 
 void* fastAlignedMalloc(size_t alignment, size_t size) 
@@ -286,7 +295,12 @@
 {
     return 1;
 }
-
+    
+size_t fastMallocGoodSize(size_t size)
+{
+    return size;
+}
+    
 void* fastAlignedMalloc(size_t alignment, size_t size) 
 {
     return bmalloc::api::memalign(alignment, size);
@@ -2753,6 +2767,13 @@
 
 #define pageheap getPageHeap()
 
+size_t fastMallocGoodSize(size_t bytes)
+{
+    if (!phinited)
+        TCMalloc_ThreadCache::InitModule();
+    return AllocationSize(bytes);
+}
+
 #if USE_BACKGROUND_THREAD_TO_SCAVENGE_MEMORY
 
 #if HAVE(DISPATCH_H) || OS(WINDOWS)

Modified: trunk/Source/WTF/wtf/FastMalloc.h (179750 => 179751)


--- trunk/Source/WTF/wtf/FastMalloc.h	2015-02-06 18:56:48 UTC (rev 179750)
+++ trunk/Source/WTF/wtf/FastMalloc.h	2015-02-06 20:25:05 UTC (rev 179751)
@@ -35,6 +35,7 @@
     WTF_EXPORT_PRIVATE void* fastRealloc(void*, size_t);
     WTF_EXPORT_PRIVATE char* fastStrDup(const char*);
     WTF_EXPORT_PRIVATE size_t fastMallocSize(const void*);
+    WTF_EXPORT_PRIVATE size_t fastMallocGoodSize(size_t);
 
     // Allocations from fastAlignedMalloc() must be freed using fastAlignedFree().
     WTF_EXPORT_PRIVATE void* fastAlignedMalloc(size_t alignment, size_t);
@@ -98,6 +99,7 @@
 using WTF::fastCalloc;
 using WTF::fastFree;
 using WTF::fastMalloc;
+using WTF::fastMallocGoodSize;
 using WTF::fastMallocSize;
 using WTF::fastRealloc;
 using WTF::fastStrDup;

Modified: trunk/Source/WTF/wtf/Vector.h (179750 => 179751)


--- trunk/Source/WTF/wtf/Vector.h	2015-02-06 18:56:48 UTC (rev 179750)
+++ trunk/Source/WTF/wtf/Vector.h	2015-02-06 20:25:05 UTC (rev 179751)
@@ -264,8 +264,9 @@
         ASSERT(newCapacity);
         if (newCapacity > std::numeric_limits<unsigned>::max() / sizeof(T))
             CRASH();
-        m_capacity = newCapacity;
-        m_buffer = static_cast<T*>(fastMalloc(newCapacity * sizeof(T)));
+        size_t sizeToAllocate = fastMallocGoodSize(newCapacity * sizeof(T));
+        m_capacity = sizeToAllocate / sizeof(T);
+        m_buffer = static_cast<T*>(fastMalloc(sizeToAllocate));
     }
 
     bool tryAllocateBuffer(size_t newCapacity)
@@ -274,9 +275,10 @@
         if (newCapacity > std::numeric_limits<unsigned>::max() / sizeof(T))
             return false;
 
+        size_t sizeToAllocate = fastMallocGoodSize(newCapacity * sizeof(T));
         T* newBuffer;
-        if (tryFastMalloc(newCapacity * sizeof(T)).getValue(newBuffer)) {
-            m_capacity = newCapacity;
+        if (tryFastMalloc(sizeToAllocate).getValue(newBuffer)) {
+            m_capacity = sizeToAllocate / sizeof(T);
             m_buffer = newBuffer;
             return true;
         }
@@ -293,8 +295,9 @@
         ASSERT(shouldReallocateBuffer(newCapacity));
         if (newCapacity > std::numeric_limits<size_t>::max() / sizeof(T))
             CRASH();
-        m_capacity = newCapacity;
-        m_buffer = static_cast<T*>(fastRealloc(m_buffer, newCapacity * sizeof(T)));
+        size_t sizeToAllocate = fastMallocGoodSize(newCapacity * sizeof(T));
+        m_capacity = sizeToAllocate / sizeof(T);
+        m_buffer = static_cast<T*>(fastRealloc(m_buffer, sizeToAllocate));
     }
 
     void deallocateBuffer(T* bufferToDeallocate)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to