Diff
Modified: trunk/Source/WTF/ChangeLog (143912 => 143913)
--- trunk/Source/WTF/ChangeLog 2013-02-25 13:21:10 UTC (rev 143912)
+++ trunk/Source/WTF/ChangeLog 2013-02-25 13:37:35 UTC (rev 143913)
@@ -1,3 +1,25 @@
+2013-02-23 Ilya Tikhonovsky <[email protected]>
+
+ Web Inspector: Native Memory Instrumentation: replace String with const char* in MemoryObjectInfo
+ https://bugs.webkit.org/show_bug.cgi?id=110599
+
+ Reviewed by Yury Semikhatsky.
+
+ Due to potentially dynamic nature of names and classNames we need to make a copy of the strings
+ that were given us via MemoryInstrumentation calls.
+ So I extended client api with registerString method that pushes the strings
+ down to the serializer.
+
+ * wtf/MemoryInstrumentation.h:
+ (MemoryInstrumentationClient):
+ * wtf/MemoryObjectInfo.h:
+ (WTF::MemoryObjectInfo::MemoryObjectInfo):
+ (WTF::MemoryObjectInfo::setClassName):
+ (WTF::MemoryObjectInfo::classNameId):
+ (WTF::MemoryObjectInfo::setName):
+ (WTF::MemoryObjectInfo::nameId):
+ (MemoryObjectInfo):
+
2013-02-21 Brady Eidson <[email protected]>
Move fastlog2() to WTF/MathExtras.h so it can be used from multiple projects.
Modified: trunk/Source/WTF/wtf/MemoryInstrumentation.h (143912 => 143913)
--- trunk/Source/WTF/wtf/MemoryInstrumentation.h 2013-02-25 13:21:10 UTC (rev 143912)
+++ trunk/Source/WTF/wtf/MemoryInstrumentation.h 2013-02-25 13:37:35 UTC (rev 143913)
@@ -66,6 +66,7 @@
virtual void reportEdge(const void* target, const char* edgeName, MemberType) = 0;
virtual void reportLeaf(const MemoryObjectInfo&, const char* edgeName) = 0;
virtual void reportBaseAddress(const void* base, const void* real) = 0;
+ virtual int registerString(const char*) = 0;
};
class MemoryInstrumentation {
Modified: trunk/Source/WTF/wtf/MemoryObjectInfo.h (143912 => 143913)
--- trunk/Source/WTF/wtf/MemoryObjectInfo.h 2013-02-25 13:21:10 UTC (rev 143912)
+++ trunk/Source/WTF/wtf/MemoryObjectInfo.h 2013-02-25 13:37:35 UTC (rev 143913)
@@ -32,7 +32,6 @@
#define MemoryObjectInfo_h
#include <wtf/MemoryInstrumentation.h>
-#include <wtf/text/WTFString.h>
namespace WTF {
@@ -51,6 +50,8 @@
, m_firstVisit(true)
, m_customAllocation(false)
, m_isRoot(false)
+ , m_classNameId(0)
+ , m_nameId(0)
{ }
typedef MemoryClassInfo ClassInfo;
@@ -62,18 +63,18 @@
bool customAllocation() const { return m_customAllocation; }
void setCustomAllocation(bool customAllocation) { m_customAllocation = customAllocation; }
- void setClassName(const String& className)
+ void setClassName(const char* className)
{
- if (m_className.isEmpty())
- m_className = className;
+ if (!m_classNameId)
+ m_classNameId = m_memoryInstrumentation->m_client->registerString(className);
}
- const String& className() const { return m_className; }
- void setName(const String& name)
+ int classNameId() const { return m_classNameId; }
+ void setName(const char* name)
{
- if (m_name.isEmpty())
- m_name = name;
+ if (!m_nameId)
+ m_nameId = m_memoryInstrumentation->m_client->registerString(name);
}
- const String& name() const { return m_name; }
+ int nameId() const { return m_nameId; }
bool isRoot() const { return m_isRoot; }
void markAsRoot() { m_isRoot = true; }
@@ -102,8 +103,8 @@
bool m_firstVisit;
bool m_customAllocation;
bool m_isRoot;
- String m_className;
- String m_name;
+ int m_classNameId;
+ int m_nameId;
};
} // namespace WTF
Modified: trunk/Source/WebCore/ChangeLog (143912 => 143913)
--- trunk/Source/WebCore/ChangeLog 2013-02-25 13:21:10 UTC (rev 143912)
+++ trunk/Source/WebCore/ChangeLog 2013-02-25 13:37:35 UTC (rev 143913)
@@ -1,3 +1,33 @@
+2013-02-23 Ilya Tikhonovsky <[email protected]>
+
+ Web Inspector: Native Memory Instrumentation: replace String with const char* in MemoryObjectInfo
+ https://bugs.webkit.org/show_bug.cgi?id=110599
+
+ Reviewed by Yury Semikhatsky.
+
+ Due to potentially dynamic nature of names and classNames we need to make a copy of the strings
+ that were given us via MemoryInstrumentation calls.
+ So I extended client api with registerString method that pushes the strings
+ down to the serializer.
+
+ * css/InspectorCSSOMWrappers.h:
+ * inspector/HeapGraphSerializer.cpp:
+ (WebCore::HeapGraphSerializer::HeapGraphSerializer):
+ (WebCore::HeapGraphSerializer::reportNodeImpl):
+ (WebCore::HeapGraphSerializer::reportEdgeImpl):
+ (WebCore::HeapGraphSerializer::registerString):
+ (WebCore::HeapGraphSerializer::registerTypeString):
+ (WebCore::HeapGraphSerializer::addRootNode):
+ * inspector/HeapGraphSerializer.h:
+ (HeapGraphSerializer):
+ * inspector/MemoryInstrumentationImpl.cpp:
+ (WebCore::MemoryInstrumentationClientImpl::registerString):
+ (WebCore):
+ * inspector/MemoryInstrumentationImpl.h:
+ (MemoryInstrumentationClientImpl):
+ * loader/cache/CachedResource.cpp:
+ (WebCore::CachedResource::reportMemoryUsage):
+
2013-02-25 Keishi Hattori <[email protected]>
Add a scrollbar class for the new calendar picker
Modified: trunk/Source/WebCore/css/InspectorCSSOMWrappers.h (143912 => 143913)
--- trunk/Source/WebCore/css/InspectorCSSOMWrappers.h 2013-02-25 13:21:10 UTC (rev 143912)
+++ trunk/Source/WebCore/css/InspectorCSSOMWrappers.h 2013-02-25 13:37:35 UTC (rev 143913)
@@ -23,10 +23,11 @@
#ifndef InspectorCSSOMWrappers_h
#define InspectorCSSOMWrappers_h
+#include <wtf/Forward.h>
#include <wtf/HashMap.h>
#include <wtf/HashSet.h>
-#include <wtf/MemoryObjectInfo.h>
#include <wtf/RefPtr.h>
+#include <wtf/Vector.h>
namespace WebCore {
Modified: trunk/Source/WebCore/inspector/HeapGraphSerializer.cpp (143912 => 143913)
--- trunk/Source/WebCore/inspector/HeapGraphSerializer.cpp 2013-02-25 13:21:10 UTC (rev 143912)
+++ trunk/Source/WebCore/inspector/HeapGraphSerializer.cpp 2013-02-25 13:37:35 UTC (rev 143913)
@@ -64,7 +64,7 @@
// FIXME: It is used as a magic constant for 'object' node type.
registerTypeString("object");
- m_unknownClassNameId = addString("unknown");
+ m_unknownClassNameId = registerString("unknown");
}
HeapGraphSerializer::~HeapGraphSerializer()
@@ -116,9 +116,9 @@
int HeapGraphSerializer::reportNodeImpl(const WTF::MemoryObjectInfo& info, int edgesCount)
{
int nodeId = toNodeId(info.reportedPointer());
-
- m_nodes->addItem(info.className().isEmpty() ? m_unknownClassNameId : addString(info.className()));
- m_nodes->addItem(addString(info.name()));
+ int classNameId = info.classNameId();
+ m_nodes->addItem(classNameId ? classNameId : m_unknownClassNameId);
+ m_nodes->addItem(info.nameId());
m_nodes->addItem(nodeId);
m_nodes->addItem(info.objectSize());
m_nodes->addItem(edgesCount);
@@ -139,7 +139,7 @@
ASSERT(memberType < WTF::LastMemberTypeEntry);
m_edges->addItem(memberType);
- m_edges->addItem(addString(name));
+ m_edges->addItem(registerString(name));
m_edges->addItem(toNodeId);
++m_nodeEdgesCount;
@@ -209,19 +209,22 @@
info.ignoreMember(m_roots);
}
-int HeapGraphSerializer::addString(const String& string)
+int HeapGraphSerializer::registerString(const char* string)
{
- if (string.isEmpty())
+ if (!string)
return 0;
- StringMap::AddResult result = m_stringToIndex.add(string.left(256), m_stringToIndex.size() + 1);
+ int length = strlen(string);
+ if (length > 256)
+ length = 256;
+ StringMap::AddResult result = m_stringToIndex.add(String(string, length), m_stringToIndex.size() + 1);
if (result.isNewEntry)
m_strings->addItem(string);
return result.iterator->value;
}
-int HeapGraphSerializer::registerTypeString(const String& string)
+int HeapGraphSerializer::registerTypeString(const char* string)
{
- int stringId = addString(string);
+ int stringId = registerString(string);
m_typeStrings->setNumber(string, stringId);
return stringId;
}
@@ -240,7 +243,7 @@
for (size_t i = 0; i < m_roots.size(); i++)
reportEdgeImpl(toNodeId(m_roots[i]), 0, m_edgeTypes[WTF::PointerMember]);
- m_nodes->addItem(addString("Root"));
+ m_nodes->addItem(registerString("Root"));
m_nodes->addItem(0);
m_nodes->addItem(s_firstNodeId + m_address2NodeIdMap.size() + m_leafCount);
m_nodes->addItem(0);
Modified: trunk/Source/WebCore/inspector/HeapGraphSerializer.h (143912 => 143913)
--- trunk/Source/WebCore/inspector/HeapGraphSerializer.h 2013-02-25 13:21:10 UTC (rev 143912)
+++ trunk/Source/WebCore/inspector/HeapGraphSerializer.h 2013-02-25 13:37:35 UTC (rev 143913)
@@ -59,6 +59,7 @@
void reportEdge(const void*, const char*, WTF::MemberType);
void reportLeaf(const WTF::MemoryObjectInfo&, const char*);
void reportBaseAddress(const void*, const void*);
+ int registerString(const char*);
PassRefPtr<InspectorObject> finish();
@@ -70,9 +71,8 @@
int toNodeId(const void*);
- int addString(const String&);
void addRootNode();
- int registerTypeString(const String&);
+ int registerTypeString(const char*);
void reportEdgeImpl(const int toNodeId, const char* name, int memberType);
int reportNodeImpl(const WTF::MemoryObjectInfo&, int edgesCount);
Modified: trunk/Source/WebCore/inspector/MemoryInstrumentationImpl.cpp (143912 => 143913)
--- trunk/Source/WebCore/inspector/MemoryInstrumentationImpl.cpp 2013-02-25 13:21:10 UTC (rev 143912)
+++ trunk/Source/WebCore/inspector/MemoryInstrumentationImpl.cpp 2013-02-25 13:37:35 UTC (rev 143913)
@@ -119,6 +119,13 @@
m_graphSerializer->reportBaseAddress(base, real);
}
+int MemoryInstrumentationClientImpl::registerString(const char* string)
+{
+ if (m_graphSerializer)
+ return m_graphSerializer->registerString(string);
+ return -1;
+}
+
void MemoryInstrumentationClientImpl::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::InspectorMemoryAgent);
Modified: trunk/Source/WebCore/inspector/MemoryInstrumentationImpl.h (143912 => 143913)
--- trunk/Source/WebCore/inspector/MemoryInstrumentationImpl.h 2013-02-25 13:21:10 UTC (rev 143912)
+++ trunk/Source/WebCore/inspector/MemoryInstrumentationImpl.h 2013-02-25 13:37:35 UTC (rev 143913)
@@ -89,6 +89,7 @@
virtual void reportEdge(const void*, const char*, MemberType) OVERRIDE;
virtual void reportLeaf(const MemoryObjectInfo&, const char*) OVERRIDE;
virtual void reportBaseAddress(const void*, const void*) OVERRIDE;
+ virtual int registerString(const char*) OVERRIDE;
void reportMemoryUsage(MemoryObjectInfo*) const;
Modified: trunk/Source/WebCore/loader/cache/CachedResource.cpp (143912 => 143913)
--- trunk/Source/WebCore/loader/cache/CachedResource.cpp 2013-02-25 13:21:10 UTC (rev 143912)
+++ trunk/Source/WebCore/loader/cache/CachedResource.cpp 2013-02-25 13:37:35 UTC (rev 143913)
@@ -943,7 +943,7 @@
void CachedResource::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CachedResource);
- memoryObjectInfo->setName(url().string());
+ memoryObjectInfo->setName(url().string().utf8().data());
info.addMember(m_resourceRequest, "resourceRequest");
info.addMember(m_fragmentIdentifierForRequest, "fragmentIdentifierForRequest");
info.addMember(m_clients, "clients");
Modified: trunk/Tools/ChangeLog (143912 => 143913)
--- trunk/Tools/ChangeLog 2013-02-25 13:21:10 UTC (rev 143912)
+++ trunk/Tools/ChangeLog 2013-02-25 13:37:35 UTC (rev 143913)
@@ -1,3 +1,22 @@
+2013-02-23 Ilya Tikhonovsky <[email protected]>
+
+ Web Inspector: Native Memory Instrumentation: replace String with const char* in MemoryObjectInfo
+ https://bugs.webkit.org/show_bug.cgi?id=110599
+
+ Reviewed by Yury Semikhatsky.
+
+ Due to potentially dynamic nature of names and classNames we need to make a copy of the strings
+ that were given us via MemoryInstrumentation calls.
+ So I extended client api with registerString method that pushes the strings
+ down to the serializer.
+
+ * TestWebKitAPI/Tests/WTF/MemoryInstrumentationTest.cpp:
+ * TestWebKitAPI/Tests/WebCore/HeapGraphSerializerTest.cpp:
+ (TestWebKitAPI::Helper::Helper):
+ (Helper):
+ (TestWebKitAPI::Helper::addNode):
+ (TestWebKitAPI::TEST):
+
2013-02-25 Nico Weber <[email protected]>
Make ScriptError not crash when args is a tuple
Modified: trunk/Tools/TestWebKitAPI/Tests/WTF/MemoryInstrumentationTest.cpp (143912 => 143913)
--- trunk/Tools/TestWebKitAPI/Tests/WTF/MemoryInstrumentationTest.cpp 2013-02-25 13:21:10 UTC (rev 143912)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/MemoryInstrumentationTest.cpp 2013-02-25 13:37:35 UTC (rev 143913)
@@ -111,6 +111,7 @@
++m_links[WTF::OwnPtrMember];
}
virtual void reportBaseAddress(const void*, const void*) OVERRIDE { }
+ virtual int registerString(const char*) OVERRIDE { return -1; }
size_t visitedObjects() const { return m_visitedObjects.size(); }
size_t totalSize(const MemoryObjectType objectType) const
Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/HeapGraphSerializerTest.cpp (143912 => 143913)
--- trunk/Tools/TestWebKitAPI/Tests/WebCore/HeapGraphSerializerTest.cpp 2013-02-25 13:21:10 UTC (rev 143912)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/HeapGraphSerializerTest.cpp 2013-02-25 13:37:35 UTC (rev 143913)
@@ -177,10 +177,16 @@
class Helper {
public:
- Helper(HeapGraphSerializer* serializer) : m_serializer(serializer), m_currentPointer(0) { }
+ Helper(HeapGraphSerializer* serializer)
+ : m_serializer(serializer)
+ , m_memoryInstrumentationClient(serializer)
+ , m_memoryInstrumentation(&m_memoryInstrumentationClient)
+ , m_currentPointer(0)
+ { }
+
void* addNode(const char* className, const char* name, bool isRoot)
{
- WTF::MemoryObjectInfo info(0, g_defaultObjectType, ++m_currentPointer);
+ WTF::MemoryObjectInfo info(&m_memoryInstrumentation, g_defaultObjectType, ++m_currentPointer);
info.setClassName(className);
info.setName(name);
if (isRoot)
@@ -201,6 +207,8 @@
private:
HeapGraphSerializer* m_serializer;
+ MemoryInstrumentationClientImpl m_memoryInstrumentationClient;
+ MemoryInstrumentationImpl m_memoryInstrumentation;
class Object {
public:
@@ -276,8 +284,8 @@
memoryInstrumentation.addRootObject(&owner);
receiver.serializer()->finish();
receiver.printGraph();
- EXPECT_EQ(String("[5,0,1,0,0,8,0,4,0,3,9,0,3,0,0,9,0,2,0,0,10,0,5,0,1]"), receiver.dumpNodes());
- EXPECT_EQ(String("[2,6,1,1,7,2,1,7,3,1,0,4]"), receiver.dumpEdges());
+ EXPECT_EQ(String("[6,0,1,0,0,5,0,4,0,3,9,0,3,0,0,9,0,2,0,0,10,0,5,0,1]"), receiver.dumpNodes());
+ EXPECT_EQ(String("[2,7,1,1,8,2,1,8,3,1,0,4]"), receiver.dumpEdges());
EXPECT_EQ(String("[]"), receiver.dumpBaseToRealNodeId());
}