Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (153246 => 153247)
--- trunk/Source/_javascript_Core/ChangeLog 2013-07-25 04:03:44 UTC (rev 153246)
+++ trunk/Source/_javascript_Core/ChangeLog 2013-07-25 04:03:46 UTC (rev 153247)
@@ -1,3 +1,27 @@
+2013-06-24 Filip Pizlo <[email protected]>
+
+ fourthTier: Count external memory usage towards heap footprint
+ https://bugs.webkit.org/show_bug.cgi?id=117948
+
+ Reviewed by Geoffrey Garen.
+
+ Currently just count strings. Strings get counted in such a way that we won't re-count strings
+ that are aliased, by dividing by the reference count. This then ups the GC footprint and allows
+ the collector to appropriately amortize itself.
+
+ * heap/Heap.cpp:
+ (JSC::Heap::Heap):
+ (JSC::Heap::size):
+ (JSC::Heap::collect):
+ * heap/Heap.h:
+ (Heap):
+ * heap/SlotVisitor.h:
+ * heap/SlotVisitorInlines.h:
+ (JSC::SlotVisitor::reportExtraMemoryUsage):
+ (JSC):
+ * runtime/JSString.cpp:
+ (JSC::JSString::visitChildren):
+
2013-06-23 Filip Pizlo <[email protected]>
fourthTier: DFG should optimize identifier string equality
Modified: trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj (153246 => 153247)
--- trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj 2013-07-25 04:03:44 UTC (rev 153246)
+++ trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj 2013-07-25 04:03:46 UTC (rev 153247)
@@ -2107,9 +2107,9 @@
034768DFFF38A50411DB9C8B /* Products */ = {
isa = PBXGroup;
children = (
- 932F5BE10822A1C700736975 /* jsc */,
0FF922CF14F46B130041A24E /* JSCLLIntOffsetsExtractor */,
932F5BD90822A1C700736975 /* _javascript_Core.framework */,
+ 932F5BE10822A1C700736975 /* jsc */,
141211200A48793C00480255 /* minidom */,
14BD59BF0A3E8F9000BAF59C /* testapi */,
6511230514046A4C002B101D /* testRegExp */,
@@ -2205,7 +2205,6 @@
0FEA09FC1705137F00BB722C /* ftl */ = {
isa = PBXGroup;
children = (
- A7FCC26C17A0B6AA00786D1A /* FTLSwitchCase.h */,
0FDB2CC7173DA51E007B3C1B /* FTLAbbreviatedTypes.h */,
0FEA09FD170513DB00BB722C /* FTLAbbreviations.h */,
0FEA0A171708B00700BB722C /* FTLAbstractHeap.cpp */,
@@ -2251,6 +2250,7 @@
0FEA0A06170513DB00BB722C /* FTLOutput.h */,
0FEA0A151706BB9000BB722C /* FTLState.cpp */,
0FEA0A07170513DB00BB722C /* FTLState.h */,
+ A7FCC26C17A0B6AA00786D1A /* FTLSwitchCase.h */,
0F235BCB17178E1C00690C7F /* FTLThunks.cpp */,
0F235BCC17178E1C00690C7F /* FTLThunks.h */,
0FEA0A1B1708B00700BB722C /* FTLTypedPointer.h */,
@@ -3527,6 +3527,7 @@
0F235BE017178E1C00690C7F /* FTLOSRExitCompiler.h in Headers */,
0FEA0A11170513DB00BB722C /* FTLOutput.h in Headers */,
0FEA0A12170513DB00BB722C /* FTLState.h in Headers */,
+ A7FCC26D17A0B6AA00786D1A /* FTLSwitchCase.h in Headers */,
0F235BE217178E1C00690C7F /* FTLThunks.h in Headers */,
0FEA0A201708B00700BB722C /* FTLTypedPointer.h in Headers */,
0F235BE417178E1C00690C7F /* FTLValueFormat.h in Headers */,
@@ -3572,7 +3573,6 @@
86CCEFDE0F413F8900FD7F9E /* JITCode.h in Headers */,
0F0776BF14FF002B00102332 /* JITCompilationEffort.h in Headers */,
0FAF7EFE165BA91F000C8455 /* JITDisassembler.h in Headers */,
- A7FCC26D17A0B6AA00786D1A /* FTLSwitchCase.h in Headers */,
0F21C26814BE5F6800ADC64B /* JITDriver.h in Headers */,
0F46808214BA572D00BFE272 /* JITExceptions.h in Headers */,
86CC85A10EE79A4700288682 /* JITInlines.h in Headers */,
Modified: trunk/Source/_javascript_Core/heap/Heap.cpp (153246 => 153247)
--- trunk/Source/_javascript_Core/heap/Heap.cpp 2013-07-25 04:03:44 UTC (rev 153246)
+++ trunk/Source/_javascript_Core/heap/Heap.cpp 2013-07-25 04:03:46 UTC (rev 153247)
@@ -254,6 +254,7 @@
, m_blockAllocator()
, m_objectSpace(this)
, m_storageSpace(this)
+ , m_extraMemoryUsage(0)
, m_machineThreads(this)
, m_sharedData(vm)
, m_slotVisitor(m_sharedData)
@@ -622,7 +623,7 @@
size_t Heap::size()
{
- return m_objectSpace.size() + m_storageSpace.size();
+ return m_objectSpace.size() + m_storageSpace.size() + m_extraMemoryUsage;
}
size_t Heap::capacity()
@@ -721,6 +722,7 @@
m_deferralDepth--; // Decrement deferal manually, so we don't GC when we do so, since we are already GCing!.
m_operationInProgress = Collection;
+ m_extraMemoryUsage = 0;
m_activityCallback->willCollect();
Modified: trunk/Source/_javascript_Core/heap/Heap.h (153246 => 153247)
--- trunk/Source/_javascript_Core/heap/Heap.h 2013-07-25 04:03:44 UTC (rev 153246)
+++ trunk/Source/_javascript_Core/heap/Heap.h 2013-07-25 04:03:46 UTC (rev 153247)
@@ -244,6 +244,7 @@
BlockAllocator m_blockAllocator;
MarkedSpace m_objectSpace;
CopiedSpace m_storageSpace;
+ size_t m_extraMemoryUsage;
#if ENABLE(SIMPLE_HEAP_PROFILING)
VTableSpectrum m_destroyedTypeCounts;
Modified: trunk/Source/_javascript_Core/heap/SlotVisitor.h (153246 => 153247)
--- trunk/Source/_javascript_Core/heap/SlotVisitor.h 2013-07-25 04:03:44 UTC (rev 153246)
+++ trunk/Source/_javascript_Core/heap/SlotVisitor.h 2013-07-25 04:03:46 UTC (rev 153247)
@@ -85,6 +85,8 @@
void copyLater(JSCell*, void*, size_t);
+ void reportExtraMemoryUsage(size_t size);
+
#if ENABLE(SIMPLE_HEAP_PROFILING)
VTableSpectrum m_visitedTypeCounts;
#endif
Modified: trunk/Source/_javascript_Core/heap/SlotVisitorInlines.h (153246 => 153247)
--- trunk/Source/_javascript_Core/heap/SlotVisitorInlines.h 2013-07-25 04:03:44 UTC (rev 153246)
+++ trunk/Source/_javascript_Core/heap/SlotVisitorInlines.h 2013-07-25 04:03:46 UTC (rev 153247)
@@ -222,6 +222,21 @@
block->reportLiveBytes(owner, bytes);
}
+inline void SlotVisitor::reportExtraMemoryUsage(size_t size)
+{
+ size_t* counter = &m_shared.m_vm->heap.m_extraMemoryUsage;
+
+#if ENABLE(COMPARE_AND_SWAP)
+ for (;;) {
+ size_t oldSize = *counter;
+ if (WTF::weakCompareAndSwapSize(counter, oldSize, oldSize + size))
+ return;
+ }
+#else
+ (*counter) += size;
+#endif
+}
+
} // namespace JSC
#endif // SlotVisitorInlines_h
Modified: trunk/Source/_javascript_Core/runtime/JSString.cpp (153246 => 153247)
--- trunk/Source/_javascript_Core/runtime/JSString.cpp 2013-07-25 04:03:44 UTC (rev 153246)
+++ trunk/Source/_javascript_Core/runtime/JSString.cpp 2013-07-25 04:03:46 UTC (rev 153247)
@@ -71,6 +71,11 @@
if (thisObject->isRope())
static_cast<JSRopeString*>(thisObject)->visitFibers(visitor);
+ else {
+ StringImpl* impl = thisObject->m_value.impl();
+ ASSERT(impl);
+ visitor.reportExtraMemoryUsage(impl->costDuringGC());
+ }
}
void JSRopeString::visitFibers(SlotVisitor& visitor)
Modified: trunk/Source/WTF/ChangeLog (153246 => 153247)
--- trunk/Source/WTF/ChangeLog 2013-07-25 04:03:44 UTC (rev 153246)
+++ trunk/Source/WTF/ChangeLog 2013-07-25 04:03:46 UTC (rev 153247)
@@ -1,3 +1,23 @@
+2013-06-24 Filip Pizlo <[email protected]>
+
+ fourthTier: Count external memory usage towards heap footprint
+ https://bugs.webkit.org/show_bug.cgi?id=117948
+
+ Reviewed by Geoffrey Garen.
+
+ Expose some functionality needed for properly measuring StringImpl footprint.
+
+ * wtf/Atomics.h:
+ (WTF::weakCompareAndSwapSize):
+ (WTF):
+ * wtf/MathExtras.h:
+ (divideRoundedUp):
+ * wtf/text/StringImpl.h:
+ (WTF::StringImpl::cost):
+ (StringImpl):
+ (WTF::StringImpl::costDuringGC):
+ (WTF::StringImpl::refCount):
+
2013-06-23 Filip Pizlo <[email protected]>
fourthTier: DFG should optimize identifier string equality
Modified: trunk/Source/WTF/wtf/Atomics.h (153246 => 153247)
--- trunk/Source/WTF/wtf/Atomics.h 2013-07-25 04:03:44 UTC (rev 153246)
+++ trunk/Source/WTF/wtf/Atomics.h 2013-07-25 04:03:46 UTC (rev 153247)
@@ -203,6 +203,11 @@
return weakCompareAndSwap(reinterpret_cast<void*volatile*>(location), reinterpret_cast<void*>(expected), reinterpret_cast<void*>(newValue));
}
+inline bool weakCompareAndSwapSize(volatile size_t* location, size_t expected, size_t newValue)
+{
+ return weakCompareAndSwap(reinterpret_cast<void*volatile*>(location), reinterpret_cast<void*>(expected), reinterpret_cast<void*>(newValue));
+}
+
// Just a compiler fence. Has no effect on the hardware, but tells the compiler
// not to move things around this call. Should not affect the compiler's ability
// to do things like register allocation and code motion over pure operations.
Modified: trunk/Source/WTF/wtf/MathExtras.h (153246 => 153247)
--- trunk/Source/WTF/wtf/MathExtras.h 2013-07-25 04:03:44 UTC (rev 153246)
+++ trunk/Source/WTF/wtf/MathExtras.h 2013-07-25 04:03:46 UTC (rev 153247)
@@ -336,6 +336,11 @@
return result;
}
+template<typename T> inline T divideRoundedUp(T a, T b)
+{
+ return (a + b - 1) / b;
+}
+
template<typename T> inline T timesThreePlusOneDividedByTwo(T value)
{
// Mathematically equivalent to:
Modified: trunk/Source/WTF/wtf/text/StringImpl.h (153246 => 153247)
--- trunk/Source/WTF/wtf/text/StringImpl.h 2013-07-25 04:03:44 UTC (rev 153246)
+++ trunk/Source/WTF/wtf/text/StringImpl.h 2013-07-25 04:03:46 UTC (rev 153247)
@@ -27,6 +27,7 @@
#include <wtf/ASCIICType.h>
#include <wtf/CompilationThread.h>
#include <wtf/Forward.h>
+#include <wtf/MathExtras.h>
#include <wtf/StdLibExtras.h>
#include <wtf/StringHasher.h>
#include <wtf/Vector.h>
@@ -510,8 +511,22 @@
return 0;
m_hashAndFlags |= s_hashFlagDidReportCost;
- return m_length;
+ size_t result = m_length;
+ if (!is8Bit())
+ result <<= 1;
+ return result;
}
+
+ size_t costDuringGC()
+ {
+ if (bufferOwnership() == BufferSubstring)
+ return divideRoundedUp(m_substringBuffer->costDuringGC(), refCount());
+
+ size_t result = m_length;
+ if (!is8Bit())
+ result <<= 1;
+ return divideRoundedUp(result, refCount());
+ }
WTF_EXPORT_STRING_API size_t sizeInBytes() const;
@@ -598,6 +613,11 @@
return hashSlowCase();
}
+ inline size_t refCount() const
+ {
+ return m_refCount / s_refCountIncrement;
+ }
+
inline bool hasOneRef() const
{
return m_refCount == s_refCountIncrement;