Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (197378 => 197379)
--- trunk/Source/_javascript_Core/ChangeLog 2016-03-01 01:36:09 UTC (rev 197378)
+++ trunk/Source/_javascript_Core/ChangeLog 2016-03-01 02:07:12 UTC (rev 197379)
@@ -1,3 +1,92 @@
+2016-02-29 Joseph Pecoraro <pecor...@apple.com>
+
+ Add new MethodTable method to get an estimated size for a cell
+ https://bugs.webkit.org/show_bug.cgi?id=154838
+
+ Reviewed by Filip Pizlo.
+
+ The new class method estimatedSize(JSCell*) estimates the size for a single cell.
+ As the name implies, this is meant to be an approximation. It is more important
+ that big objects report a large size, then to get perfect size information for
+ all objects in the heap.
+
+ Base implementation (JSCell):
+ - returns the MarkedBlock bucket size for this cell.
+ - This gets us the object size include inline storage. Basically a better sizeof.
+
+ Subclasses with "Extra Memory Cost":
+ - Any class that reports extra memory (reportExtraMemoryVisited) should include that in the estimated size.
+ - E.g. CodeBlock, JSGenericTypedArrayView, WeakMapData, etc.
+
+ Subclasses with "Copied Space" storage:
+ - Any class with data in copied space (copyBackingStore) should include that in the estimated size.
+ - E.g. JSObject, JSGenericTypedArrayView, JSMap, JSSet, DirectArguments, etc.
+
+ Add reportExtraMemoryVisited for UnlinkedCodeBlock's compressed unlinked
+ instructions because this can be larger than 1kb, which is significant.
+
+ This has one special case for RegExp generated bytecode / JIT code, which
+ does not currently fall into the extra memory cost or copied space storage.
+ In practice I haven't seen this grow to a significant cost.
+
+ * runtime/ClassInfo.h:
+ Add the new estimatedSize method to the table.
+
+ * bytecode/UnlinkedCodeBlock.cpp:
+ (JSC::UnlinkedCodeBlock::visitChildren):
+ (JSC::UnlinkedCodeBlock::estimatedSize):
+ (JSC::UnlinkedCodeBlock::setInstructions):
+ * bytecode/UnlinkedCodeBlock.h:
+ Report an extra memory cost for unlinked code blocks like
+ we do for linked code blocks.
+
+ * bytecode/CodeBlock.cpp:
+ (JSC::CodeBlock::estimatedSize):
+ * bytecode/CodeBlock.h:
+ * bytecode/UnlinkedInstructionStream.cpp:
+ (JSC::UnlinkedInstructionStream::sizeInBytes):
+ * bytecode/UnlinkedInstructionStream.h:
+ * runtime/DirectArguments.cpp:
+ (JSC::DirectArguments::estimatedSize):
+ * runtime/DirectArguments.h:
+ * runtime/JSCell.cpp:
+ (JSC::JSCell::estimatedSizeInBytes):
+ (JSC::JSCell::estimatedSize):
+ * runtime/JSCell.h:
+ * runtime/JSGenericTypedArrayView.h:
+ * runtime/JSGenericTypedArrayViewInlines.h:
+ (JSC::JSGenericTypedArrayView<Adaptor>::estimatedSize):
+ * runtime/JSMap.cpp:
+ (JSC::JSMap::estimatedSize):
+ * runtime/JSMap.h:
+ * runtime/JSObject.cpp:
+ (JSC::JSObject::visitButterfly):
+ * runtime/JSObject.h:
+ * runtime/JSSet.cpp:
+ (JSC::JSSet::estimatedSize):
+ * runtime/JSSet.h:
+ * runtime/JSString.cpp:
+ (JSC::JSString::estimatedSize):
+ * runtime/JSString.h:
+ * runtime/MapData.h:
+ (JSC::MapDataImpl::capacityInBytes):
+ * runtime/WeakMapData.cpp:
+ (JSC::WeakMapData::estimatedSize):
+ (JSC::WeakMapData::visitChildren):
+ * runtime/WeakMapData.h:
+ Implement estimated size following the pattern of reporting
+ extra visited size, or copy space memory.
+
+ * runtime/RegExp.cpp:
+ (JSC::RegExp::estimatedSize):
+ * runtime/RegExp.h:
+ * yarr/YarrInterpreter.h:
+ (JSC::Yarr::ByteDisjunction::estimatedSizeInBytes):
+ (JSC::Yarr::BytecodePattern::estimatedSizeInBytes):
+ * yarr/YarrJIT.h:
+ (JSC::Yarr::YarrCodeBlock::size):
+ Include generated bytecode / JITCode to a RegExp's size.
+
2016-02-29 Filip Pizlo <fpi...@apple.com>
SpeculatedType should be easier to edit
Modified: trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp (197378 => 197379)
--- trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp 2016-03-01 01:36:09 UTC (rev 197378)
+++ trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp 2016-03-01 02:07:12 UTC (rev 197379)
@@ -2462,6 +2462,15 @@
#endif // ENABLE(DFG_JIT)
}
+size_t CodeBlock::estimatedSize(JSCell* cell)
+{
+ CodeBlock* thisObject = jsCast<CodeBlock*>(cell);
+ size_t extraMemoryAllocated = thisObject->m_instructions.size() * sizeof(Instruction);
+ if (thisObject->m_jitCode)
+ extraMemoryAllocated += thisObject->m_jitCode->size();
+ return Base::estimatedSize(cell) + extraMemoryAllocated;
+}
+
void CodeBlock::visitChildren(JSCell* cell, SlotVisitor& visitor)
{
CodeBlock* thisObject = jsCast<CodeBlock*>(cell);
Modified: trunk/Source/_javascript_Core/bytecode/CodeBlock.h (197378 => 197379)
--- trunk/Source/_javascript_Core/bytecode/CodeBlock.h 2016-03-01 01:36:09 UTC (rev 197378)
+++ trunk/Source/_javascript_Core/bytecode/CodeBlock.h 2016-03-01 02:07:12 UTC (rev 197379)
@@ -179,6 +179,7 @@
// https://bugs.webkit.org/show_bug.cgi?id=123677
CodeBlock* baselineVersion();
+ static size_t estimatedSize(JSCell*);
static void visitChildren(JSCell*, SlotVisitor&);
void visitChildren(SlotVisitor&);
void visitWeakly(SlotVisitor&);
Modified: trunk/Source/_javascript_Core/bytecode/UnlinkedCodeBlock.cpp (197378 => 197379)
--- trunk/Source/_javascript_Core/bytecode/UnlinkedCodeBlock.cpp 2016-03-01 01:36:09 UTC (rev 197378)
+++ trunk/Source/_javascript_Core/bytecode/UnlinkedCodeBlock.cpp 2016-03-01 02:07:12 UTC (rev 197379)
@@ -99,12 +99,21 @@
for (FunctionExpressionVector::iterator ptr = thisObject->m_functionExprs.begin(), end = thisObject->m_functionExprs.end(); ptr != end; ++ptr)
visitor.append(ptr);
visitor.appendValues(thisObject->m_constantRegisters.data(), thisObject->m_constantRegisters.size());
+ if (thisObject->m_unlinkedInstructions)
+ visitor.reportExtraMemoryVisited(thisObject->m_unlinkedInstructions->sizeInBytes());
if (thisObject->m_rareData) {
for (size_t i = 0, end = thisObject->m_rareData->m_regexps.size(); i != end; i++)
visitor.append(&thisObject->m_rareData->m_regexps[i]);
}
}
+size_t UnlinkedCodeBlock::estimatedSize(JSCell* cell)
+{
+ UnlinkedCodeBlock* thisObject = jsCast<UnlinkedCodeBlock*>(cell);
+ size_t extraSize = thisObject->m_unlinkedInstructions ? thisObject->m_unlinkedInstructions->sizeInBytes() : 0;
+ return Base::estimatedSize(cell) + extraSize;
+}
+
int UnlinkedCodeBlock::lineNumberForBytecodeOffset(unsigned bytecodeOffset)
{
ASSERT(bytecodeOffset < instructions().count());
@@ -343,7 +352,9 @@
void UnlinkedCodeBlock::setInstructions(std::unique_ptr<UnlinkedInstructionStream> instructions)
{
+ ASSERT(instructions);
m_unlinkedInstructions = WTFMove(instructions);
+ Heap::heap(this)->reportExtraMemoryAllocated(m_unlinkedInstructions->sizeInBytes());
}
const UnlinkedInstructionStream& UnlinkedCodeBlock::instructions() const
Modified: trunk/Source/_javascript_Core/bytecode/UnlinkedCodeBlock.h (197378 => 197379)
--- trunk/Source/_javascript_Core/bytecode/UnlinkedCodeBlock.h 2016-03-01 01:36:09 UTC (rev 197378)
+++ trunk/Source/_javascript_Core/bytecode/UnlinkedCodeBlock.h 2016-03-01 02:07:12 UTC (rev 197379)
@@ -454,6 +454,7 @@
protected:
static void visitChildren(JSCell*, SlotVisitor&);
+ static size_t estimatedSize(JSCell*);
public:
DECLARE_INFO;
Modified: trunk/Source/_javascript_Core/bytecode/UnlinkedInstructionStream.cpp (197378 => 197379)
--- trunk/Source/_javascript_Core/bytecode/UnlinkedInstructionStream.cpp 2016-03-01 01:36:09 UTC (rev 197378)
+++ trunk/Source/_javascript_Core/bytecode/UnlinkedInstructionStream.cpp 2016-03-01 02:07:12 UTC (rev 197379)
@@ -102,6 +102,11 @@
m_data = RefCountedArray<unsigned char>(buffer);
}
+size_t UnlinkedInstructionStream::sizeInBytes() const
+{
+ return m_data.size() * sizeof(unsigned char);
+}
+
#ifndef NDEBUG
const RefCountedArray<UnlinkedInstruction>& UnlinkedInstructionStream::unpackForDebugging() const
{
Modified: trunk/Source/_javascript_Core/bytecode/UnlinkedInstructionStream.h (197378 => 197379)
--- trunk/Source/_javascript_Core/bytecode/UnlinkedInstructionStream.h 2016-03-01 01:36:09 UTC (rev 197378)
+++ trunk/Source/_javascript_Core/bytecode/UnlinkedInstructionStream.h 2016-03-01 02:07:12 UTC (rev 197379)
@@ -38,6 +38,7 @@
explicit UnlinkedInstructionStream(const Vector<UnlinkedInstruction, 0, UnsafeVectorOverflow>&);
unsigned count() const { return m_instructionCount; }
+ size_t sizeInBytes() const;
class Reader {
public:
Modified: trunk/Source/_javascript_Core/runtime/ClassInfo.h (197378 => 197379)
--- trunk/Source/_javascript_Core/runtime/ClassInfo.h 2016-03-01 01:36:09 UTC (rev 197378)
+++ trunk/Source/_javascript_Core/runtime/ClassInfo.h 2016-03-01 02:07:12 UTC (rev 197379)
@@ -105,6 +105,9 @@
typedef void (*DumpToStreamFunctionPtr)(const JSCell*, PrintStream&);
DumpToStreamFunctionPtr dumpToStream;
+
+ typedef size_t (*EstimatedSizeFunctionPtr)(JSCell*);
+ EstimatedSizeFunctionPtr estimatedSize;
};
#define CREATE_MEMBER_CHECKER(member) \
@@ -151,7 +154,8 @@
&ClassName::defineOwnProperty, \
&ClassName::slowDownAndWasteMemory, \
&ClassName::getTypedArrayImpl, \
- &ClassName::dumpToStream \
+ &ClassName::dumpToStream, \
+ &ClassName::estimatedSize \
}, \
ClassName::TypedArrayStorageType
Modified: trunk/Source/_javascript_Core/runtime/DirectArguments.cpp (197378 => 197379)
--- trunk/Source/_javascript_Core/runtime/DirectArguments.cpp 2016-03-01 01:36:09 UTC (rev 197378)
+++ trunk/Source/_javascript_Core/runtime/DirectArguments.cpp 2016-03-01 02:07:12 UTC (rev 197379)
@@ -85,6 +85,13 @@
return result;
}
+size_t DirectArguments::estimatedSize(JSCell* cell)
+{
+ DirectArguments* thisObject = jsCast<DirectArguments*>(cell);
+ size_t overridesSize = thisObject->m_overrides ? thisObject->overridesSize() : 0;
+ return Base::estimatedSize(cell) + overridesSize;
+}
+
void DirectArguments::visitChildren(JSCell* thisCell, SlotVisitor& visitor)
{
DirectArguments* thisObject = static_cast<DirectArguments*>(thisCell);
Modified: trunk/Source/_javascript_Core/runtime/DirectArguments.h (197378 => 197379)
--- trunk/Source/_javascript_Core/runtime/DirectArguments.h 2016-03-01 01:36:09 UTC (rev 197378)
+++ trunk/Source/_javascript_Core/runtime/DirectArguments.h 2016-03-01 02:07:12 UTC (rev 197379)
@@ -55,7 +55,8 @@
// Creates an arguments object by copying the argumnets from the stack.
static DirectArguments* createByCopying(ExecState*);
-
+
+ static size_t estimatedSize(JSCell*);
static void visitChildren(JSCell*, SlotVisitor&);
static void copyBackingStore(JSCell*, CopyVisitor&, CopyToken);
Modified: trunk/Source/_javascript_Core/runtime/JSCell.cpp (197378 => 197379)
--- trunk/Source/_javascript_Core/runtime/JSCell.cpp 2016-03-01 01:36:09 UTC (rev 197378)
+++ trunk/Source/_javascript_Core/runtime/JSCell.cpp 2016-03-01 02:07:12 UTC (rev 197379)
@@ -51,6 +51,16 @@
out.printf("<%p, %s>", cell, cell->className());
}
+size_t JSCell::estimatedSizeInBytes() const
+{
+ return methodTable()->estimatedSize(const_cast<JSCell*>(this));
+}
+
+size_t JSCell::estimatedSize(JSCell* cell)
+{
+ return MarkedBlock::blockFor(cell)->cellSize();
+}
+
void JSCell::copyBackingStore(JSCell*, CopyVisitor&, CopyToken)
{
}
Modified: trunk/Source/_javascript_Core/runtime/JSCell.h (197378 => 197379)
--- trunk/Source/_javascript_Core/runtime/JSCell.h 2016-03-01 01:36:09 UTC (rev 197378)
+++ trunk/Source/_javascript_Core/runtime/JSCell.h 2016-03-01 02:07:12 UTC (rev 197379)
@@ -134,6 +134,10 @@
void dump(PrintStream&) const;
JS_EXPORT_PRIVATE static void dumpToStream(const JSCell*, PrintStream&);
+
+ size_t estimatedSizeInBytes() const;
+ JS_EXPORT_PRIVATE static size_t estimatedSize(JSCell*);
+
static void visitChildren(JSCell*, SlotVisitor&);
JS_EXPORT_PRIVATE static void copyBackingStore(JSCell*, CopyVisitor&, CopyToken);
Modified: trunk/Source/_javascript_Core/runtime/JSGenericTypedArrayView.h (197378 => 197379)
--- trunk/Source/_javascript_Core/runtime/JSGenericTypedArrayView.h 2016-03-01 01:36:09 UTC (rev 197378)
+++ trunk/Source/_javascript_Core/runtime/JSGenericTypedArrayView.h 2016-03-01 02:07:12 UTC (rev 197379)
@@ -283,7 +283,8 @@
static bool deletePropertyByIndex(JSCell*, ExecState*, unsigned propertyName);
static void getOwnPropertyNames(JSObject*, ExecState*, PropertyNameArray&, EnumerationMode);
-
+
+ static size_t estimatedSize(JSCell*);
static void visitChildren(JSCell*, SlotVisitor&);
static void copyBackingStore(JSCell*, CopyVisitor&, CopyToken);
Modified: trunk/Source/_javascript_Core/runtime/JSGenericTypedArrayViewInlines.h (197378 => 197379)
--- trunk/Source/_javascript_Core/runtime/JSGenericTypedArrayViewInlines.h 2016-03-01 01:36:09 UTC (rev 197378)
+++ trunk/Source/_javascript_Core/runtime/JSGenericTypedArrayViewInlines.h 2016-03-01 02:07:12 UTC (rev 197379)
@@ -406,6 +406,19 @@
}
template<typename Adaptor>
+size_t JSGenericTypedArrayView<Adaptor>::estimatedSize(JSCell* cell)
+{
+ JSGenericTypedArrayView* thisObject = jsCast<JSGenericTypedArrayView*>(cell);
+
+ if (thisObject->m_mode == OversizeTypedArray)
+ return Base::estimatedSize(thisObject) + thisObject->byteSize();
+ if (thisObject->m_mode == FastTypedArray && thisObject->m_vector)
+ return Base::estimatedSize(thisObject) + thisObject->byteSize();
+
+ return Base::estimatedSize(thisObject);
+}
+
+template<typename Adaptor>
void JSGenericTypedArrayView<Adaptor>::visitChildren(JSCell* cell, SlotVisitor& visitor)
{
JSGenericTypedArrayView* thisObject = jsCast<JSGenericTypedArrayView*>(cell);
Modified: trunk/Source/_javascript_Core/runtime/JSMap.cpp (197378 => 197379)
--- trunk/Source/_javascript_Core/runtime/JSMap.cpp 2016-03-01 01:36:09 UTC (rev 197378)
+++ trunk/Source/_javascript_Core/runtime/JSMap.cpp 2016-03-01 02:07:12 UTC (rev 197379)
@@ -43,6 +43,13 @@
thisObject->JSMap::~JSMap();
}
+size_t JSMap::estimatedSize(JSCell* cell)
+{
+ JSMap* thisObject = jsCast<JSMap*>(cell);
+ size_t mapDataSize = thisObject->m_mapData.capacityInBytes();
+ return Base::estimatedSize(cell) + mapDataSize;
+}
+
void JSMap::visitChildren(JSCell* cell, SlotVisitor& visitor)
{
Base::visitChildren(cell, visitor);
Modified: trunk/Source/_javascript_Core/runtime/JSMap.h (197378 => 197379)
--- trunk/Source/_javascript_Core/runtime/JSMap.h 2016-03-01 01:36:09 UTC (rev 197378)
+++ trunk/Source/_javascript_Core/runtime/JSMap.h 2016-03-01 02:07:12 UTC (rev 197379)
@@ -122,6 +122,7 @@
}
static void destroy(JSCell*);
+ static size_t estimatedSize(JSCell*);
static void visitChildren(JSCell*, SlotVisitor&);
static void copyBackingStore(JSCell*, CopyVisitor&, CopyToken);
Modified: trunk/Source/_javascript_Core/runtime/JSObject.cpp (197378 => 197379)
--- trunk/Source/_javascript_Core/runtime/JSObject.cpp 2016-03-01 01:36:09 UTC (rev 197378)
+++ trunk/Source/_javascript_Core/runtime/JSObject.cpp 2016-03-01 02:07:12 UTC (rev 197379)
@@ -197,6 +197,13 @@
}
}
+size_t JSObject::estimatedSize(JSCell* cell)
+{
+ JSObject* thisObject = jsCast<JSObject*>(cell);
+ size_t butterflyOutOfLineSize = thisObject->m_butterfly ? thisObject->structure()->outOfLineSize() : 0;
+ return Base::estimatedSize(cell) + butterflyOutOfLineSize;
+}
+
void JSObject::visitChildren(JSCell* cell, SlotVisitor& visitor)
{
JSObject* thisObject = jsCast<JSObject*>(cell);
Modified: trunk/Source/_javascript_Core/runtime/JSObject.h (197378 => 197379)
--- trunk/Source/_javascript_Core/runtime/JSObject.h 2016-03-01 01:36:09 UTC (rev 197378)
+++ trunk/Source/_javascript_Core/runtime/JSObject.h 2016-03-01 02:07:12 UTC (rev 197379)
@@ -94,7 +94,8 @@
public:
typedef JSCell Base;
-
+
+ JS_EXPORT_PRIVATE static size_t estimatedSize(JSCell*);
JS_EXPORT_PRIVATE static void visitChildren(JSCell*, SlotVisitor&);
JS_EXPORT_PRIVATE static void copyBackingStore(JSCell*, CopyVisitor&, CopyToken);
Modified: trunk/Source/_javascript_Core/runtime/JSSet.cpp (197378 => 197379)
--- trunk/Source/_javascript_Core/runtime/JSSet.cpp 2016-03-01 01:36:09 UTC (rev 197378)
+++ trunk/Source/_javascript_Core/runtime/JSSet.cpp 2016-03-01 02:07:12 UTC (rev 197379)
@@ -43,6 +43,13 @@
thisObject->JSSet::~JSSet();
}
+size_t JSSet::estimatedSize(JSCell* cell)
+{
+ JSSet* thisObject = jsCast<JSSet*>(cell);
+ size_t setDataSize = thisObject->m_setData.capacityInBytes();
+ return Base::estimatedSize(cell) + setDataSize;
+}
+
void JSSet::visitChildren(JSCell* cell, SlotVisitor& visitor)
{
Base::visitChildren(cell, visitor);
Modified: trunk/Source/_javascript_Core/runtime/JSSet.h (197378 => 197379)
--- trunk/Source/_javascript_Core/runtime/JSSet.h 2016-03-01 01:36:09 UTC (rev 197378)
+++ trunk/Source/_javascript_Core/runtime/JSSet.h 2016-03-01 02:07:12 UTC (rev 197379)
@@ -117,6 +117,7 @@
}
static void destroy(JSCell*);
+ static size_t estimatedSize(JSCell*);
static void visitChildren(JSCell*, SlotVisitor&);
static void copyBackingStore(JSCell*, CopyVisitor&, CopyToken);
Modified: trunk/Source/_javascript_Core/runtime/JSString.cpp (197378 => 197379)
--- trunk/Source/_javascript_Core/runtime/JSString.cpp 2016-03-01 01:36:09 UTC (rev 197378)
+++ trunk/Source/_javascript_Core/runtime/JSString.cpp 2016-03-01 02:07:12 UTC (rev 197379)
@@ -72,6 +72,14 @@
out.printf(">");
}
+size_t JSString::estimatedSize(JSCell* cell)
+{
+ JSString* thisObject = jsCast<JSString*>(cell);
+ if (thisObject->isRope())
+ return Base::estimatedSize(cell);
+ return Base::estimatedSize(cell) + thisObject->m_value.impl()->costDuringGC();
+}
+
void JSString::visitChildren(JSCell* cell, SlotVisitor& visitor)
{
JSString* thisObject = jsCast<JSString*>(cell);
Modified: trunk/Source/_javascript_Core/runtime/JSString.h (197378 => 197379)
--- trunk/Source/_javascript_Core/runtime/JSString.h 2016-03-01 01:36:09 UTC (rev 197378)
+++ trunk/Source/_javascript_Core/runtime/JSString.h 2016-03-01 02:07:12 UTC (rev 197379)
@@ -181,6 +181,7 @@
DECLARE_EXPORT_INFO;
static void dumpToStream(const JSCell*, PrintStream&);
+ static size_t estimatedSize(JSCell*);
static void visitChildren(JSCell*, SlotVisitor&);
enum {
Modified: trunk/Source/_javascript_Core/runtime/MapData.h (197378 => 197379)
--- trunk/Source/_javascript_Core/runtime/MapData.h 2016-03-01 01:36:09 UTC (rev 197378)
+++ trunk/Source/_javascript_Core/runtime/MapData.h 2016-03-01 02:07:12 UTC (rev 197379)
@@ -111,6 +111,8 @@
void visitChildren(JSCell* owner, SlotVisitor&);
void copyBackingStore(CopyVisitor&, CopyToken);
+ size_t capacityInBytes() const { return m_capacity * sizeof(Entry); }
+
private:
typedef WTF::UnsignedWithZeroKeyHashTraits<int32_t> IndexTraits;
@@ -119,8 +121,6 @@
typedef HashMap<StringImpl*, int32_t, typename WTF::DefaultHash<StringImpl*>::Hash, WTF::HashTraits<StringImpl*>, IndexTraits> StringKeyedMap;
typedef HashMap<SymbolImpl*, int32_t, typename WTF::PtrHash<SymbolImpl*>, WTF::HashTraits<SymbolImpl*>, IndexTraits> SymbolKeyedMap;
- size_t capacityInBytes() { return m_capacity * sizeof(Entry); }
-
ALWAYS_INLINE Entry* find(ExecState*, KeyType);
ALWAYS_INLINE Entry* add(ExecState*, JSCell* owner, KeyType);
template <typename Map, typename Key> ALWAYS_INLINE Entry* add(ExecState*, JSCell* owner, Map&, Key, KeyType);
Modified: trunk/Source/_javascript_Core/runtime/RegExp.cpp (197378 => 197379)
--- trunk/Source/_javascript_Core/runtime/RegExp.cpp 2016-03-01 01:36:09 UTC (rev 197378)
+++ trunk/Source/_javascript_Core/runtime/RegExp.cpp 2016-03-01 02:07:12 UTC (rev 197379)
@@ -256,6 +256,16 @@
thisObject->RegExp::~RegExp();
}
+size_t RegExp::estimatedSize(JSCell* cell)
+{
+ RegExp* thisObject = static_cast<RegExp*>(cell);
+ size_t regexDataSize = thisObject->m_regExpBytecode ? thisObject->m_regExpBytecode->estimatedSizeInBytes() : 0;
+#if ENABLE(YARR_JIT)
+ regexDataSize += thisObject->m_regExpJITCode.size();
+#endif
+ return Base::estimatedSize(cell) + regexDataSize;
+}
+
RegExp* RegExp::createWithoutCaching(VM& vm, const String& patternString, RegExpFlags flags)
{
RegExp* regExp = new (NotNull, allocateCell<RegExp>(vm.heap)) RegExp(vm, patternString, flags);
Modified: trunk/Source/_javascript_Core/runtime/RegExp.h (197378 => 197379)
--- trunk/Source/_javascript_Core/runtime/RegExp.h 2016-03-01 01:36:09 UTC (rev 197378)
+++ trunk/Source/_javascript_Core/runtime/RegExp.h 2016-03-01 02:07:12 UTC (rev 197379)
@@ -50,6 +50,7 @@
JS_EXPORT_PRIVATE static RegExp* create(VM&, const String& pattern, RegExpFlags);
static const bool needsDestruction = true;
static void destroy(JSCell*);
+ static size_t estimatedSize(JSCell*);
bool global() const { return m_flags & FlagGlobal; }
bool ignoreCase() const { return m_flags & FlagIgnoreCase; }
Modified: trunk/Source/_javascript_Core/runtime/WeakMapData.cpp (197378 => 197379)
--- trunk/Source/_javascript_Core/runtime/WeakMapData.cpp 2016-03-01 01:36:09 UTC (rev 197378)
+++ trunk/Source/_javascript_Core/runtime/WeakMapData.cpp 2016-03-01 02:07:12 UTC (rev 197379)
@@ -54,6 +54,12 @@
static_cast<WeakMapData*>(cell)->~WeakMapData();
}
+size_t WeakMapData::estimatedSize(JSCell* cell)
+{
+ WeakMapData* thisObj = jsCast<WeakMapData*>(cell);
+ return Base::estimatedSize(cell) + (thisObj->m_map.capacity() * (sizeof(JSObject*) + sizeof(WriteBarrier<Unknown>)));
+}
+
void WeakMapData::visitChildren(JSCell* cell, SlotVisitor& visitor)
{
Base::visitChildren(cell, visitor);
@@ -63,7 +69,7 @@
// Rough approximation of the external storage needed for the hashtable.
// This isn't exact, but it is close enough, and proportional to the actual
- // external mermory usage.
+ // external memory usage.
visitor.reportExtraMemoryVisited(thisObj->m_map.capacity() * (sizeof(JSObject*) + sizeof(WriteBarrier<Unknown>)));
}
Modified: trunk/Source/_javascript_Core/runtime/WeakMapData.h (197378 => 197379)
--- trunk/Source/_javascript_Core/runtime/WeakMapData.h 2016-03-01 01:36:09 UTC (rev 197378)
+++ trunk/Source/_javascript_Core/runtime/WeakMapData.h 2016-03-01 02:07:12 UTC (rev 197379)
@@ -70,6 +70,7 @@
private:
WeakMapData(VM&);
static void destroy(JSCell*);
+ static size_t estimatedSize(JSCell*);
static void visitChildren(JSCell*, SlotVisitor&);
void finishCreation(VM&);
Modified: trunk/Source/_javascript_Core/yarr/YarrInterpreter.h (197378 => 197379)
--- trunk/Source/_javascript_Core/yarr/YarrInterpreter.h 2016-03-01 01:36:09 UTC (rev 197378)
+++ trunk/Source/_javascript_Core/yarr/YarrInterpreter.h 2016-03-01 02:07:12 UTC (rev 197379)
@@ -327,6 +327,8 @@
{
}
+ size_t estimatedSizeInBytes() const { return terms.capacity() * sizeof(ByteTerm); }
+
Vector<ByteTerm> terms;
unsigned m_numSubpatterns;
unsigned m_frameSize;
@@ -353,6 +355,8 @@
m_userCharacterClasses.shrinkToFit();
}
+ size_t estimatedSizeInBytes() const { return m_body->estimatedSizeInBytes(); }
+
std::unique_ptr<ByteDisjunction> m_body;
bool m_ignoreCase;
bool m_multiline;
Modified: trunk/Source/_javascript_Core/yarr/YarrJIT.h (197378 => 197379)
--- trunk/Source/_javascript_Core/yarr/YarrJIT.h 2016-03-01 01:36:09 UTC (rev 197378)
+++ trunk/Source/_javascript_Core/yarr/YarrJIT.h 2016-03-01 02:07:12 UTC (rev 197379)
@@ -141,6 +141,11 @@
}
#endif
+ size_t size() const
+ {
+ return m_ref8.size() + m_ref16.size() + m_matchOnly8.size() + m_matchOnly16.size();
+ }
+
void clear()
{
m_ref8 = MacroAssemblerCodeRef();