[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373

ggaren at apple.com ggaren at apple.com
Thu Apr 8 02:19:04 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit 17dc50b1378ad60577368a2d4da1aa9d0c3a1a7a
Author: ggaren at apple.com <ggaren at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Mar 10 23:11:10 2010 +0000

    Refactored fastCheckConsistency to match some review comments:
        - renamed fastCheckConsistency to fastMallocSize, and changed ValueCheck
          to ASSERT that a pointer's fastMallocSize is not 0.
        - implemented a version of fastMallocSize for tcmalloc.
    
    Reviewed by Alexey Proskuryakov, Darin Adler, and Sam Weinig.
    
    Also moved some pre-existing code around to avoid a problem related to
    mismatched #define/#undef of malloc/free in this source file.
    
    * JavaScriptCore.exp:
    * wtf/FastMalloc.cpp:
    (WTF::fastMallocSize): Renamed. Fixed indentation.
    
    (WTF::TCMalloc_PageHeap::scavenge): Removed an incorrect ASSERT that
    got in the way of testing the tcmalloc implementation. (More information
    on why this ASSERT is incorrect is in <rdar://problem/7165917>.)
    
    (WTF::TCMallocStats::fastMallocSize): Implemented for tcmalloc.
    
    * wtf/FastMalloc.h: Updated for rename.
    
    * wtf/ValueCheck.h:
    (WTF::): Moved the ASSERT that used to be in fastCheckConsistency here.
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@55811 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index db6d3d9..7f90a48 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,3 +1,30 @@
+2010-03-09  Geoffrey Garen  <ggaren at apple.com>
+
+        Reviewed by Alexey Proskuryakov, Darin Adler, and Sam Weinig.
+
+        Refactored fastCheckConsistency to match some review comments:
+            - renamed fastCheckConsistency to fastMallocSize, and changed ValueCheck
+              to ASSERT that a pointer's fastMallocSize is not 0.
+            - implemented a version of fastMallocSize for tcmalloc.
+            
+        Also moved some pre-existing code around to avoid a problem related to
+        mismatched #define/#undef of malloc/free in this source file.
+
+        * JavaScriptCore.exp:
+        * wtf/FastMalloc.cpp:
+        (WTF::fastMallocSize): Renamed. Fixed indentation.
+
+        (WTF::TCMalloc_PageHeap::scavenge): Removed an incorrect ASSERT that
+        got in the way of testing the tcmalloc implementation. (More information
+        on why this ASSERT is incorrect is in <rdar://problem/7165917>.)
+
+        (WTF::TCMallocStats::fastMallocSize): Implemented for tcmalloc.
+
+        * wtf/FastMalloc.h: Updated for rename.
+
+        * wtf/ValueCheck.h:
+        (WTF::): Moved the ASSERT that used to be in fastCheckConsistency here.
+
 2010-03-10  Kevin Ollivier  <kevino at theolliviers.com>
 
         Reviewed by Eric Seidel.
diff --git a/JavaScriptCore/JavaScriptCore.exp b/JavaScriptCore/JavaScriptCore.exp
index 375f395..d171746 100644
--- a/JavaScriptCore/JavaScriptCore.exp
+++ b/JavaScriptCore/JavaScriptCore.exp
@@ -316,6 +316,7 @@ __ZN3WTF12randomNumberEv
 __ZN3WTF13currentThreadEv
 __ZN3WTF13tryFastCallocEmm
 __ZN3WTF13tryFastMallocEm
+__ZN3WTF14fastMallocSizeEPKv
 __ZN3WTF15ThreadCondition4waitERNS_5MutexE
 __ZN3WTF15ThreadCondition6signalEv
 __ZN3WTF15ThreadCondition9broadcastEv
@@ -327,7 +328,6 @@ __ZN3WTF16fastZeroedMallocEm
 __ZN3WTF18dateToDaysFrom1970Eiii
 __ZN3WTF18monthFromDayInYearEib
 __ZN3WTF19initializeThreadingEv
-__ZN3WTF20fastCheckConsistencyEPKv
 __ZN3WTF20fastMallocStatisticsEv
 __ZN3WTF21RefCountedLeakCounter16suppressMessagesEPKc
 __ZN3WTF21RefCountedLeakCounter24cancelMessageSuppressionEPKc
diff --git a/JavaScriptCore/wtf/FastMalloc.cpp b/JavaScriptCore/wtf/FastMalloc.cpp
index d1a4d28..00d6023 100644
--- a/JavaScriptCore/wtf/FastMalloc.cpp
+++ b/JavaScriptCore/wtf/FastMalloc.cpp
@@ -379,14 +379,14 @@ FastMallocStatistics fastMallocStatistics()
     return statistics;
 }
 
-void fastCheckConsistency(const void* p)
+size_t fastMallocSize(const void* p)
 {
-#if (defined(USE_SYSTEM_MALLOC) && USE_SYSTEM_MALLOC) || !defined(NDEBUG)
 #if OS(DARWIN)
-        ASSERT(malloc_size(p));
+    return malloc_size(p);
 #elif COMPILER(MSVC)
-        ASSERT(_msize(const_cast<void*>(p)));
-#endif
+    return _msize(const_cast<void*>(p));
+#else
+    return 1;
 #endif
 }
 
@@ -481,7 +481,7 @@ namespace WTF {
 #define CHECK_CONDITION ASSERT
 
 #if OS(DARWIN)
-class Span;
+struct Span;
 class TCMalloc_Central_FreeListPadded;
 class TCMalloc_PageHeap;
 class TCMalloc_ThreadCache;
@@ -1548,7 +1548,6 @@ void TCMalloc_PageHeap::scavenge()
         }
     }
 
-    ASSERT(!shouldContinueScavenging());
     pages_committed_since_last_scavenge_ = 0;
 }
 
@@ -4112,7 +4111,62 @@ void *(*__memalign_hook)(size_t, size_t, const void *) = MemalignOverride;
 
 #endif
 
-#if defined(WTF_CHANGES) && OS(DARWIN)
+#ifdef WTF_CHANGES
+void releaseFastMallocFreeMemory()
+{
+    // Flush free pages in the current thread cache back to the page heap.
+    // Low watermark mechanism in Scavenge() prevents full return on the first pass.
+    // The second pass flushes everything.
+    if (TCMalloc_ThreadCache* threadCache = TCMalloc_ThreadCache::GetCacheIfPresent()) {
+        threadCache->Scavenge();
+        threadCache->Scavenge();
+    }
+
+    SpinLockHolder h(&pageheap_lock);
+    pageheap->ReleaseFreePages();
+}
+    
+FastMallocStatistics fastMallocStatistics()
+{
+    FastMallocStatistics statistics;
+
+    SpinLockHolder lockHolder(&pageheap_lock);
+    statistics.reservedVMBytes = static_cast<size_t>(pageheap->SystemBytes());
+    statistics.committedVMBytes = statistics.reservedVMBytes - pageheap->ReturnedBytes();
+
+    statistics.freeListBytes = 0;
+    for (unsigned cl = 0; cl < kNumClasses; ++cl) {
+        const int length = central_cache[cl].length();
+        const int tc_length = central_cache[cl].tc_length();
+
+        statistics.freeListBytes += ByteSizeForClass(cl) * (length + tc_length);
+    }
+    for (TCMalloc_ThreadCache* threadCache = thread_heaps; threadCache ; threadCache = threadCache->next_)
+        statistics.freeListBytes += threadCache->Size();
+
+    return statistics;
+}
+
+size_t fastMallocSize(const void* ptr)
+{
+    const PageID p = reinterpret_cast<uintptr_t>(ptr) >> kPageShift;
+    Span* span = pageheap->GetDescriptorEnsureSafe(p);
+
+    if (!span || span->free)
+        return 0;
+
+    for (void* free = span->objects; free != NULL; free = *((void**) free)) {
+        if (ptr == free)
+            return 0;
+    }
+
+    if (size_t cl = span->sizeclass)
+        return ByteSizeForClass(cl);
+
+    return span->length << kPageShift;
+}
+
+#if OS(DARWIN)
 
 class FreeObjectFinder {
     const RemoteMemoryReader& m_reader;
@@ -4429,49 +4483,9 @@ void FastMallocZone::init()
     static FastMallocZone zone(pageheap, &thread_heaps, static_cast<TCMalloc_Central_FreeListPadded*>(central_cache), &span_allocator, &threadheap_allocator);
 }
 
-#endif
-
-#ifdef WTF_CHANGES
-void releaseFastMallocFreeMemory()
-{
-    // Flush free pages in the current thread cache back to the page heap.
-    // Low watermark mechanism in Scavenge() prevents full return on the first pass.
-    // The second pass flushes everything.
-    if (TCMalloc_ThreadCache* threadCache = TCMalloc_ThreadCache::GetCacheIfPresent()) {
-        threadCache->Scavenge();
-        threadCache->Scavenge();
-    }
-
-    SpinLockHolder h(&pageheap_lock);
-    pageheap->ReleaseFreePages();
-}
-    
-FastMallocStatistics fastMallocStatistics()
-{
-    FastMallocStatistics statistics;
-
-    SpinLockHolder lockHolder(&pageheap_lock);
-    statistics.reservedVMBytes = static_cast<size_t>(pageheap->SystemBytes());
-    statistics.committedVMBytes = statistics.reservedVMBytes - pageheap->ReturnedBytes();
-
-    statistics.freeListBytes = 0;
-    for (unsigned cl = 0; cl < kNumClasses; ++cl) {
-        const int length = central_cache[cl].length();
-        const int tc_length = central_cache[cl].tc_length();
-
-        statistics.freeListBytes += ByteSizeForClass(cl) * (length + tc_length);
-    }
-    for (TCMalloc_ThreadCache* threadCache = thread_heaps; threadCache ; threadCache = threadCache->next_)
-        statistics.freeListBytes += threadCache->Size();
-
-    return statistics;
-}
-
-void fastCheckConsistency(const void*)
-{
-}
+#endif // OS(DARWIN)
 
 } // namespace WTF
-#endif
+#endif // WTF_CHANGES
 
 #endif // FORCE_SYSTEM_MALLOC
diff --git a/JavaScriptCore/wtf/FastMalloc.h b/JavaScriptCore/wtf/FastMalloc.h
index 876791c..9f82275 100644
--- a/JavaScriptCore/wtf/FastMalloc.h
+++ b/JavaScriptCore/wtf/FastMalloc.h
@@ -34,7 +34,7 @@ namespace WTF {
     void* fastCalloc(size_t numElements, size_t elementSize);
     void* fastRealloc(void*, size_t);
     char* fastStrDup(const char*);
-    void fastCheckConsistency(const void*);
+    size_t fastMallocSize(const void*);
 
     struct TryMallocReturnValue {
         TryMallocReturnValue(void* data)
diff --git a/JavaScriptCore/wtf/ValueCheck.h b/JavaScriptCore/wtf/ValueCheck.h
index 63ea2bd..2a86eb0 100644
--- a/JavaScriptCore/wtf/ValueCheck.h
+++ b/JavaScriptCore/wtf/ValueCheck.h
@@ -42,7 +42,7 @@ template<typename P> struct ValueCheck<P*> {
     {
         if (!p)
             return;
-        fastCheckConsistency(p);
+        ASSERT(fastMallocSize(p));
         ValueCheck<P>::checkConsistency(*p);
     }
 };

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list