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

Unified Diff: third_party/WebKit/Source/platform/heap/HeapAllocator.h

Issue 1985473002: Simplify HeapVectorBacking<> usage. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/heap/HeapAllocator.h
diff --git a/third_party/WebKit/Source/platform/heap/HeapAllocator.h b/third_party/WebKit/Source/platform/heap/HeapAllocator.h
index 31441f1f08e99b1af055122b42ff52ce607fb0b2..8fa22d83be17b12ddbbb5a0a5333069dce2937c1 100644
--- a/third_party/WebKit/Source/platform/heap/HeapAllocator.h
+++ b/third_party/WebKit/Source/platform/heap/HeapAllocator.h
@@ -21,6 +21,20 @@
namespace blink {
+template<typename T, typename Traits = WTF::VectorTraits<T>> class HeapVectorBacking {
+ DISALLOW_NEW();
+public:
+ static void finalize(void* pointer);
+ void finalizeGarbageCollectedObject() { finalize(this); }
+};
+
+template<typename Table> class HeapHashTableBacking {
+ DISALLOW_NEW();
+public:
+ static void finalize(void* pointer);
+ void finalizeGarbageCollectedObject() { finalize(this); }
+};
+
// This is a static-only class used as a trait on collections to make them heap
// allocated. However see also HeapListHashSetAllocator.
class PLATFORM_EXPORT HeapAllocator {
@@ -40,7 +54,7 @@ public:
{
ThreadState* state = ThreadStateFor<ThreadingTrait<T>::Affinity>::state();
ASSERT(state->isAllocationAllowed());
- size_t gcInfoIndex = GCInfoTrait<HeapVectorBacking<T, VectorTraits<T>>>::index();
+ size_t gcInfoIndex = GCInfoTrait<HeapVectorBacking<T>>::index();
NormalPageArena* arena = static_cast<NormalPageArena*>(state->vectorBackingArena(gcInfoIndex));
return reinterpret_cast<T*>(arena->allocateObject(ThreadHeap::allocationSizeFromSize(size), gcInfoIndex));
}
@@ -49,7 +63,7 @@ public:
{
ThreadState* state = ThreadStateFor<ThreadingTrait<T>::Affinity>::state();
ASSERT(state->isAllocationAllowed());
- size_t gcInfoIndex = GCInfoTrait<HeapVectorBacking<T, VectorTraits<T>>>::index();
+ size_t gcInfoIndex = GCInfoTrait<HeapVectorBacking<T>>::index();
NormalPageArena* arena = static_cast<NormalPageArena*>(state->expandedVectorBackingArena(gcInfoIndex));
return reinterpret_cast<T*>(arena->allocateObject(ThreadHeap::allocationSizeFromSize(size), gcInfoIndex));
}
@@ -59,11 +73,9 @@ public:
template <typename T>
static T* allocateInlineVectorBacking(size_t size)
{
- size_t gcInfoIndex = GCInfoTrait<HeapVectorBacking<T, VectorTraits<T>>>::index();
+ size_t gcInfoIndex = GCInfoTrait<HeapVectorBacking<T>>::index();
ThreadState* state = ThreadStateFor<ThreadingTrait<T>::Affinity>::state();
-#define COMMA ,
- const char* typeName = WTF_HEAP_PROFILER_TYPE_NAME(HeapVectorBacking<T COMMA VectorTraits<T>>);
-#undef COMMA
+ const char* typeName = WTF_HEAP_PROFILER_TYPE_NAME(HeapVectorBacking<T>);
return reinterpret_cast<T*>(ThreadHeap::allocateOnArenaIndex(state, size, BlinkGC::InlineVectorArenaIndex, gcInfoIndex, typeName));
}
static void freeInlineVectorBacking(void*);
@@ -246,13 +258,6 @@ public:
}
};
-template<typename T, typename Traits = WTF::VectorTraits<T>> class HeapVectorBacking {
- DISALLOW_NEW();
-public:
- static void finalize(void* pointer);
- void finalizeGarbageCollectedObject() { finalize(this); }
-};
-
template<typename T, typename Traits>
void HeapVectorBacking<T, Traits>::finalize(void* pointer)
{
@@ -284,13 +289,6 @@ void HeapVectorBacking<T, Traits>::finalize(void* pointer)
}
}
-template<typename Table> class HeapHashTableBacking {
- DISALLOW_NEW();
-public:
- static void finalize(void* pointer);
- void finalizeGarbageCollectedObject() { finalize(this); }
-};
-
template<typename Table>
void HeapHashTableBacking<Table>::finalize(void* pointer)
{
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698