Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(283)

Unified Diff: third_party/WebKit/Source/platform/graphics/ContiguousContainer.h

Issue 1609423002: Adjust heap profiler integration for ContiguousContainer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/graphics/ContiguousContainer.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/graphics/ContiguousContainer.h
diff --git a/third_party/WebKit/Source/platform/graphics/ContiguousContainer.h b/third_party/WebKit/Source/platform/graphics/ContiguousContainer.h
index cd752420bf4c45d18cabb2390704e52f47709292..32f293d6a531fcef27128f599eb86dfc07ccd59b 100644
--- a/third_party/WebKit/Source/platform/graphics/ContiguousContainer.h
+++ b/third_party/WebKit/Source/platform/graphics/ContiguousContainer.h
@@ -41,8 +41,7 @@ class PLATFORM_EXPORT ContiguousContainerBase {
DISALLOW_NEW();
WTF_MAKE_NONCOPYABLE(ContiguousContainerBase);
protected:
- explicit ContiguousContainerBase(size_t maxObjectSize, const char* typeName);
- ContiguousContainerBase(size_t maxObjectSize, size_t initialSizeBytes, const char* typeName);
+ explicit ContiguousContainerBase(size_t maxObjectSize);
~ContiguousContainerBase();
size_t size() const { return m_elements.size(); }
@@ -52,6 +51,7 @@ protected:
size_t memoryUsageInBytes() const;
// These do not invoke constructors or destructors.
+ void reserveInitialCapacity(size_t, const char* typeName);
void* allocate(size_t objectSize, const char* typeName);
void removeLast();
void clear();
@@ -108,10 +108,13 @@ public:
using reverse_iterator = IteratorWrapper<Vector<void*>::reverse_iterator, BaseElementType>;
using const_reverse_iterator = IteratorWrapper<Vector<void*>::const_reverse_iterator, const BaseElementType>;
- explicit ContiguousContainer(size_t maxObjectSize)
- : ContiguousContainerBase(align(maxObjectSize), WTF_HEAP_PROFILER_TYPE_NAME(BaseElementType)) {}
+ explicit ContiguousContainer(size_t maxObjectSize) : ContiguousContainerBase(align(maxObjectSize)) {}
+
ContiguousContainer(size_t maxObjectSize, size_t initialSizeBytes)
- : ContiguousContainerBase(align(maxObjectSize), initialSizeBytes, WTF_HEAP_PROFILER_TYPE_NAME(BaseElementType)) {}
+ : ContiguousContainer(maxObjectSize)
+ {
+ reserveInitialCapacity(std::max(maxObjectSize, initialSizeBytes), WTF_HEAP_PROFILER_TYPE_NAME(BaseElementType));
+ }
~ContiguousContainer()
{
@@ -151,7 +154,7 @@ public:
static_assert(alignment % WTF_ALIGN_OF(DerivedElementType) == 0,
"Derived type requires stronger alignment.");
size_t allocSize = align(sizeof(DerivedElementType));
- return *new (allocate(allocSize, WTF_HEAP_PROFILER_TYPE_NAME(DerivedElementType))) DerivedElementType(std::forward<Args>(args)...);
+ return *new (allocate(allocSize)) DerivedElementType(std::forward<Args>(args)...);
Ruud van Asseldonk 2016/01/21 10:23:23 So now instead of reporting the type as |DerivedEl
jbroman 2016/01/21 14:23:18 Right.
}
void removeLast()
@@ -177,13 +180,18 @@ public:
BaseElementType& appendByMoving(BaseElementType& item, size_t size)
{
ASSERT(size >= sizeof(BaseElementType));
- void* newItem = allocate(size, WTF_HEAP_PROFILER_TYPE_NAME(BaseElementType));
+ void* newItem = allocate(size);
memcpy(newItem, static_cast<void*>(&item), size);
new (&item) BaseElementType;
return *static_cast<BaseElementType*>(newItem);
}
private:
+ void* allocate(size_t objectSize)
+ {
+ return ContiguousContainerBase::allocate(objectSize, WTF_HEAP_PROFILER_TYPE_NAME(BaseElementType));
+ }
+
static size_t align(size_t size)
{
size_t alignedSize = alignment * ((size + alignment - 1) / alignment);
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/graphics/ContiguousContainer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698