[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.19-1-708-g9923a0e
Gustavo Noronha Silva
kov at debian.org
Thu Feb 4 21:34:22 UTC 2010
The following commit has been merged in the debian/unstable branch:
commit 61071b208f821771b9e29c57ef734bc64d76e914
Merge: 3f8f9b1351179105c392b65a9fbdd9aff4b03467 e5415e919b2182d5d5d26a0414b53290f14d41d8
Author: Gustavo Noronha Silva <kov at debian.org>
Date: Thu Feb 4 19:24:47 2010 -0200
Merge branch 'webkit-1.1' into debian/unstable
Conflicts:
WebKit/gtk/WebCoreSupport/PasteboardHelperGtk.cpp
diff --combined JavaScriptCore/wtf/FastMalloc.cpp
index db6cd62,7b14809..63a3191
--- a/JavaScriptCore/wtf/FastMalloc.cpp
+++ b/JavaScriptCore/wtf/FastMalloc.cpp
@@@ -179,6 -179,17 +179,17 @@@ void* fastZeroedMalloc(size_t n
memset(result, 0, n);
return result;
}
+
+ char* fastStrDup(const char* src)
+ {
+ int len = strlen(src) + 1;
+ char* dup = static_cast<char*>(fastMalloc(len));
+
+ if (dup)
+ memcpy(dup, src, len);
+
+ return dup;
+ }
TryMallocReturnValue tryFastZeroedMalloc(size_t n)
{
@@@ -391,6 -402,10 +402,10 @@@ extern "C" const int jscore_fastmalloc_
#include <wtf/HashSet.h>
#include <wtf/Vector.h>
#endif
+ #if HAVE(DISPATCH_H)
+ #include <dispatch/dispatch.h>
+ #endif
+
#ifndef PRIuS
#define PRIuS "zu"
@@@ -1372,21 -1387,29 +1387,29 @@@ class TCMalloc_PageHeap
#endif
#if USE_BACKGROUND_THREAD_TO_SCAVENGE_MEMORY
- static NO_RETURN void* runScavengerThread(void*);
+ void initializeScavenger();
+ ALWAYS_INLINE void signalScavenger();
+ void scavenge();
+ ALWAYS_INLINE bool shouldContinueScavenging() const;
+ #if !HAVE(DISPATCH_H)
+ static NO_RETURN void* runScavengerThread(void*);
NO_RETURN void scavengerThread();
- void scavenge();
-
- inline bool shouldContinueScavenging() const;
+ // Keeps track of whether the background thread is actively scavenging memory every kScavengeTimerDelayInSeconds, or
+ // it's blocked waiting for more pages to be deleted.
+ bool m_scavengeThreadActive;
pthread_mutex_t m_scavengeMutex;
-
pthread_cond_t m_scavengeCondition;
+ #else // !HAVE(DISPATCH_H)
+ void periodicScavenge();
+
+ dispatch_queue_t m_scavengeQueue;
+ dispatch_source_t m_scavengeTimer;
+ bool m_scavengingScheduled;
+ #endif
- // Keeps track of whether the background thread is actively scavenging memory every kScavengeTimerDelayInSeconds, or
- // it's blocked waiting for more pages to be deleted.
- bool m_scavengeThreadActive;
#endif // USE_BACKGROUND_THREAD_TO_SCAVENGE_MEMORY
};
@@@ -1414,15 -1437,23 +1437,23 @@@ void TCMalloc_PageHeap::init(
}
#if USE_BACKGROUND_THREAD_TO_SCAVENGE_MEMORY
+ initializeScavenger();
+ #endif // USE_BACKGROUND_THREAD_TO_SCAVENGE_MEMORY
+ }
+
+ #if USE_BACKGROUND_THREAD_TO_SCAVENGE_MEMORY
+
+ #if !HAVE(DISPATCH_H)
+
+ void TCMalloc_PageHeap::initializeScavenger()
+ {
pthread_mutex_init(&m_scavengeMutex, 0);
pthread_cond_init(&m_scavengeCondition, 0);
m_scavengeThreadActive = true;
pthread_t thread;
pthread_create(&thread, 0, runScavengerThread, this);
- #endif // USE_BACKGROUND_THREAD_TO_SCAVENGE_MEMORY
}
- #if USE_BACKGROUND_THREAD_TO_SCAVENGE_MEMORY
void* TCMalloc_PageHeap::runScavengerThread(void* context)
{
static_cast<TCMalloc_PageHeap*>(context)->scavengerThread();
@@@ -1432,6 -1463,34 +1463,34 @@@
#endif
}
+ ALWAYS_INLINE void TCMalloc_PageHeap::signalScavenger()
+ {
+ if (!m_scavengeThreadActive && shouldContinueScavenging())
+ pthread_cond_signal(&m_scavengeCondition);
+ }
+
+ #else // !HAVE(DISPATCH_H)
+
+ void TCMalloc_PageHeap::initializeScavenger()
+ {
+ m_scavengeQueue = dispatch_queue_create("com.apple.JavaScriptCore.FastMallocSavenger", NULL);
+ m_scavengeTimer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, m_scavengeQueue);
+ dispatch_time_t startTime = dispatch_time(DISPATCH_TIME_NOW, kScavengeTimerDelayInSeconds * NSEC_PER_SEC);
+ dispatch_source_set_timer(m_scavengeTimer, startTime, kScavengeTimerDelayInSeconds * NSEC_PER_SEC, 1000 * NSEC_PER_USEC);
+ dispatch_source_set_event_handler(m_scavengeTimer, ^{ periodicScavenge(); });
+ m_scavengingScheduled = false;
+ }
+
+ ALWAYS_INLINE void TCMalloc_PageHeap::signalScavenger()
+ {
+ if (!m_scavengingScheduled && shouldContinueScavenging()) {
+ m_scavengingScheduled = true;
+ dispatch_resume(m_scavengeTimer);
+ }
+ }
+
+ #endif
+
void TCMalloc_PageHeap::scavenge()
{
// If we have to commit memory in the last 5 seconds, it means we don't have enough free committed pages
@@@ -1467,7 -1526,7 +1526,7 @@@
free_committed_pages_ -= pagesDecommitted;
}
- inline bool TCMalloc_PageHeap::shouldContinueScavenging() const
+ ALWAYS_INLINE bool TCMalloc_PageHeap::shouldContinueScavenging() const
{
return free_committed_pages_ > kMinimumFreeCommittedPageCount;
}
@@@ -1729,8 -1788,7 +1788,7 @@@ inline void TCMalloc_PageHeap::Delete(S
}
// Make sure the scavenge thread becomes active if we have enough freed pages to release some back to the system.
- if (!m_scavengeThreadActive && shouldContinueScavenging())
- pthread_cond_signal(&m_scavengeCondition);
+ signalScavenger();
#else
IncrementalScavenge(n);
#endif
@@@ -2254,13 -2312,13 +2312,13 @@@ static TCMalloc_Central_FreeListPadded
// Page-level allocator
static SpinLock pageheap_lock = SPINLOCK_INITIALIZER;
-static void* pageheap_memory[(sizeof(TCMalloc_PageHeap) + sizeof(void*) - 1) / sizeof(void*)];
+static uint64_t pageheap_memory[(sizeof(TCMalloc_PageHeap) + sizeof(uint64_t) - 1) / sizeof(uint64_t)];
static bool phinited = false;
// Avoid extra level of indirection by making "pageheap" be just an alias
// of pageheap_memory.
typedef union {
- void* m_memory;
+ uint64_t* m_memory;
TCMalloc_PageHeap* m_pageHeap;
} PageHeapUnion;
@@@ -2273,6 -2331,8 +2331,8 @@@ static inline TCMalloc_PageHeap* getPag
#define pageheap getPageHeap()
#if USE_BACKGROUND_THREAD_TO_SCAVENGE_MEMORY
+
+ #if !HAVE(DISPATCH_H)
#if OS(WINDOWS)
static void sleep(unsigned seconds)
{
@@@ -2302,6 -2362,23 +2362,23 @@@ void TCMalloc_PageHeap::scavengerThread
}
}
}
+
+ #else
+
+ void TCMalloc_PageHeap::periodicScavenge()
+ {
+ {
+ SpinLockHolder h(&pageheap_lock);
+ pageheap->scavenge();
+ }
+
+ if (!shouldContinueScavenging()) {
+ m_scavengingScheduled = false;
+ dispatch_suspend(m_scavengeTimer);
+ }
+ }
+ #endif // HAVE(DISPATCH_H)
+
#endif
// If TLS is available, we also store a copy
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list