[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 01:45:13 UTC 2010
The following commit has been merged in the webkit-1.2 branch:
commit 0fabb55f8e1c6a3a4945b7f59e2f89445a501fed
Author: ggaren at apple.com <ggaren at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Thu Feb 11 21:28:52 2010 +0000
JavaScriptCore: Added an SPI for asking about all the different live objects on the heap.
Useful for memory debugging.
Reviewed by Oliver Hunt.
* JavaScriptCore.exp: Export the new SPI.
* runtime/Collector.cpp:
(JSC::typeName): Use a little capitalization. Don't crash in the case of
a non-object cell, since it might just be an uninitialized cell.
(JSC::Heap::objectTypeCounts): The new SPI.
* runtime/Collector.h:
* runtime/CollectorHeapIterator.h:
(JSC::CollectorHeapIterator::advance):
(JSC::LiveObjectIterator::operator++):
(JSC::DeadObjectIterator::operator++):
(JSC::ObjectIterator::operator++): Made 2 tweaks to these iterators:
(1) Skip the last cell in the block, since it's a dummy sentinel, and
we don't want it to confuse the object count; (2) Fixed a logic error
in LiveObjectIterator that could cause it to iterate dead objects if
m_block were equal to m_heap.nextBlock and m_cell were less than
m_heap.nextCell. No test for this since I can't think of a way that this
could make WebKit behave badly.
WebKit/mac: Exported some new JavaScript heap introspection.
Reviewed by Oliver Hunt.
* Misc/WebCoreStatistics.h:
* Misc/WebCoreStatistics.mm:
(+[WebCoreStatistics javaScriptObjectTypeCounts]): Just like
javaScriptProtectedObjectTypeCounts, except this function enumerates all
live objects, not just protected objects.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@54672 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index e10a0cd..4333187 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,3 +1,31 @@
+2010-02-10 Geoffrey Garen <ggaren at apple.com>
+
+ Reviewed by Oliver Hunt.
+
+ Added an SPI for asking about all the different live objects on the heap.
+ Useful for memory debugging.
+
+ * JavaScriptCore.exp: Export the new SPI.
+
+ * runtime/Collector.cpp:
+ (JSC::typeName): Use a little capitalization. Don't crash in the case of
+ a non-object cell, since it might just be an uninitialized cell.
+
+ (JSC::Heap::objectTypeCounts): The new SPI.
+
+ * runtime/Collector.h:
+ * runtime/CollectorHeapIterator.h:
+ (JSC::CollectorHeapIterator::advance):
+ (JSC::LiveObjectIterator::operator++):
+ (JSC::DeadObjectIterator::operator++):
+ (JSC::ObjectIterator::operator++): Made 2 tweaks to these iterators:
+ (1) Skip the last cell in the block, since it's a dummy sentinel, and
+ we don't want it to confuse the object count; (2) Fixed a logic error
+ in LiveObjectIterator that could cause it to iterate dead objects if
+ m_block were equal to m_heap.nextBlock and m_cell were less than
+ m_heap.nextCell. No test for this since I can't think of a way that this
+ could make WebKit behave badly.
+
2010-02-11 Steve Block <steveblock at google.com>
Reviewed by Darin Adler.
diff --git a/JavaScriptCore/JavaScriptCore.exp b/JavaScriptCore/JavaScriptCore.exp
index 8b3e8f3..f562b52 100644
--- a/JavaScriptCore/JavaScriptCore.exp
+++ b/JavaScriptCore/JavaScriptCore.exp
@@ -190,6 +190,7 @@ __ZN3JSC35createInterruptedExecutionExceptionEPNS_12JSGlobalDataE
__ZN3JSC3NaNE
__ZN3JSC4Heap14primaryHeapEndEv
__ZN3JSC4Heap15recordExtraCostEm
+__ZN3JSC4Heap16objectTypeCountsEv
__ZN3JSC4Heap16primaryHeapBeginEv
__ZN3JSC4Heap17collectAllGarbageEv
__ZN3JSC4Heap17globalObjectCountEv
@@ -299,6 +300,7 @@ __ZN3JSCgtERKNS_7UStringES2_
__ZN3JSCltERKNS_7UStringES2_
__ZN3WTF10fastCallocEmm
__ZN3WTF10fastMallocEm
+__ZN3WTF10fastStrDupEPKc
__ZN3WTF11currentTimeEv
__ZN3WTF11fastReallocEPvm
__ZN3WTF12createThreadEPFPvS0_ES0_
@@ -347,10 +349,9 @@ __ZN3WTF8Collator18setOrderLowerFirstEb
__ZN3WTF8CollatorC1EPKc
__ZN3WTF8CollatorD1Ev
__ZN3WTF8fastFreeEPv
-__ZN3WTF10fastStrDupEPKc
__ZN3WTF8msToYearEd
-__ZN3WTF9dayInYearEdi
__ZN3WTF9ByteArray6createEm
+__ZN3WTF9dayInYearEdi
__ZNK3JSC10JSFunction23isHostFunctionNonInlineEv
__ZNK3JSC11Interpreter14retrieveCallerEPNS_9ExecStateEPNS_16InternalFunctionE
__ZNK3JSC11Interpreter18retrieveLastCallerEPNS_9ExecStateERiRlRNS_7UStringERNS_7JSValueE
diff --git a/JavaScriptCore/runtime/Collector.cpp b/JavaScriptCore/runtime/Collector.cpp
index 63139a2..a391d26 100644
--- a/JavaScriptCore/runtime/Collector.cpp
+++ b/JavaScriptCore/runtime/Collector.cpp
@@ -1197,12 +1197,13 @@ static const char* typeName(JSCell* cell)
return "number";
#endif
if (cell->isGetterSetter())
- return "gettersetter";
+ return "Getter-Setter";
if (cell->isAPIValueWrapper())
- return "value wrapper";
+ return "API wrapper";
if (cell->isPropertyNameIterator())
- return "for-in iterator";
- ASSERT(cell->isObject());
+ return "For-in iterator";
+ if (!cell->isObject())
+ return "[empty cell]";
const ClassInfo* info = cell->classInfo();
return info ? info->className : "Object";
}
@@ -1218,6 +1219,18 @@ HashCountedSet<const char*>* Heap::protectedObjectTypeCounts()
return counts;
}
+HashCountedSet<const char*>* Heap::objectTypeCounts()
+{
+ HashCountedSet<const char*>* counts = new HashCountedSet<const char*>;
+
+ LiveObjectIterator it = primaryHeapBegin();
+ LiveObjectIterator heapEnd = primaryHeapEnd();
+ for ( ; it != heapEnd; ++it)
+ counts->add(typeName(*it));
+
+ return counts;
+}
+
bool Heap::isBusy()
{
return m_heap.operationInProgress != NoOperation;
diff --git a/JavaScriptCore/runtime/Collector.h b/JavaScriptCore/runtime/Collector.h
index 7f7a679..82aa8a1 100644
--- a/JavaScriptCore/runtime/Collector.h
+++ b/JavaScriptCore/runtime/Collector.h
@@ -100,6 +100,7 @@ namespace JSC {
size_t protectedObjectCount();
size_t protectedGlobalObjectCount();
HashCountedSet<const char*>* protectedObjectTypeCounts();
+ HashCountedSet<const char*>* objectTypeCounts();
void registerThread(); // Only needs to be called by clients that can use the same heap from multiple threads.
diff --git a/JavaScriptCore/runtime/CollectorHeapIterator.h b/JavaScriptCore/runtime/CollectorHeapIterator.h
index e4f2f91..be6f3c9 100644
--- a/JavaScriptCore/runtime/CollectorHeapIterator.h
+++ b/JavaScriptCore/runtime/CollectorHeapIterator.h
@@ -38,7 +38,7 @@ namespace JSC {
protected:
CollectorHeapIterator(CollectorHeap&, size_t startBlock, size_t startCell);
- void advance(size_t cellsPerBlock);
+ void advance(size_t max);
CollectorHeap& m_heap;
size_t m_block;
@@ -80,10 +80,12 @@ namespace JSC {
return reinterpret_cast<JSCell*>(m_heap.blocks[m_block]->cells + m_cell);
}
- inline void CollectorHeapIterator::advance(size_t cellsPerBlock)
+ // Iterators advance up to the next-to-last -- and not the last -- cell in a
+ // block, since the last cell is a dummy sentinel.
+ inline void CollectorHeapIterator::advance(size_t max)
{
++m_cell;
- if (m_cell == cellsPerBlock) {
+ if (m_cell == max) {
m_cell = 0;
++m_block;
}
@@ -97,14 +99,12 @@ namespace JSC {
inline LiveObjectIterator& LiveObjectIterator::operator++()
{
- if (m_block < m_heap.nextBlock || m_cell < m_heap.nextCell) {
- advance(HeapConstants::cellsPerBlock);
+ advance(HeapConstants::cellsPerBlock - 1);
+ if (m_block < m_heap.nextBlock || (m_block == m_heap.nextBlock && m_cell < m_heap.nextCell))
return *this;
- }
- do {
- advance(HeapConstants::cellsPerBlock);
- } while (m_block < m_heap.usedBlocks && !m_heap.blocks[m_block]->marked.get(m_cell));
+ while (m_block < m_heap.usedBlocks && !m_heap.blocks[m_block]->marked.get(m_cell))
+ advance(HeapConstants::cellsPerBlock - 1);
return *this;
}
@@ -117,7 +117,7 @@ namespace JSC {
inline DeadObjectIterator& DeadObjectIterator::operator++()
{
do {
- advance(HeapConstants::cellsPerBlock);
+ advance(HeapConstants::cellsPerBlock - 1);
ASSERT(m_block > m_heap.nextBlock || (m_block == m_heap.nextBlock && m_cell >= m_heap.nextCell));
} while (m_block < m_heap.usedBlocks && m_heap.blocks[m_block]->marked.get(m_cell));
return *this;
@@ -131,7 +131,7 @@ namespace JSC {
inline ObjectIterator& ObjectIterator::operator++()
{
- advance(HeapConstants::cellsPerBlock);
+ advance(HeapConstants::cellsPerBlock - 1);
return *this;
}
diff --git a/WebKit/mac/ChangeLog b/WebKit/mac/ChangeLog
index a1b808b..5e6271a 100644
--- a/WebKit/mac/ChangeLog
+++ b/WebKit/mac/ChangeLog
@@ -1,3 +1,15 @@
+2010-02-10 Geoffrey Garen <ggaren at apple.com>
+
+ Reviewed by Oliver Hunt.
+
+ Exported some new JavaScript heap introspection.
+
+ * Misc/WebCoreStatistics.h:
+ * Misc/WebCoreStatistics.mm:
+ (+[WebCoreStatistics javaScriptObjectTypeCounts]): Just like
+ javaScriptProtectedObjectTypeCounts, except this function enumerates all
+ live objects, not just protected objects.
+
2010-02-08 Maciej Stachowiak <mjs at apple.com>
Reviewed by Cameron Zwarich.
diff --git a/WebKit/mac/Misc/WebCoreStatistics.h b/WebKit/mac/Misc/WebCoreStatistics.h
index 73d5f80..d205083 100644
--- a/WebKit/mac/Misc/WebCoreStatistics.h
+++ b/WebKit/mac/Misc/WebCoreStatistics.h
@@ -43,6 +43,7 @@
+ (size_t)javaScriptProtectedObjectsCount;
+ (size_t)javaScriptProtectedGlobalObjectsCount;
+ (NSCountedSet *)javaScriptProtectedObjectTypeCounts;
++ (NSCountedSet *)javaScriptObjectTypeCounts;
+ (void)garbageCollectJavaScriptObjects;
+ (void)garbageCollectJavaScriptObjectsOnAlternateThreadForDebugging:(BOOL)waitUntilDone;
diff --git a/WebKit/mac/Misc/WebCoreStatistics.mm b/WebKit/mac/Misc/WebCoreStatistics.mm
index c59d66c..9e8ae05 100644
--- a/WebKit/mac/Misc/WebCoreStatistics.mm
+++ b/WebKit/mac/Misc/WebCoreStatistics.mm
@@ -93,6 +93,21 @@ using namespace WebCore;
return result;
}
++ (NSCountedSet *)javaScriptObjectTypeCounts
+{
+ JSLock lock(SilenceAssertionsOnly);
+
+ NSCountedSet *result = [NSCountedSet set];
+
+ OwnPtr<HashCountedSet<const char*> > counts(JSDOMWindow::commonJSGlobalData()->heap.objectTypeCounts());
+ HashCountedSet<const char*>::iterator end = counts->end();
+ for (HashCountedSet<const char*>::iterator it = counts->begin(); it != end; ++it)
+ for (unsigned i = 0; i < it->second; ++i)
+ [result addObject:[NSString stringWithUTF8String:it->first]];
+
+ return result;
+}
+
+ (void)garbageCollectJavaScriptObjects
{
gcController().garbageCollectNow();
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list