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

Unified Diff: src/zone.h

Issue 10448007: Split an allocation policy into an allocator and a deallocator. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Make TemplateHashMapImpl consistent with the rest of the approach. Created 8 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
Index: src/zone.h
diff --git a/src/zone.h b/src/zone.h
index 864846553a234d82cfd88c3e527f1f5c7416e654..efe9bf9e6813565f4eb1c52cfd34d4c23f76c154 100644
--- a/src/zone.h
+++ b/src/zone.h
@@ -164,38 +164,42 @@ class ZoneObject {
};
-// The ZoneListAllocationPolicy is used to specialize the GenericList
-// implementation to allocate ZoneLists and their elements in the
-// Zone.
-class ZoneListAllocationPolicy {
+class ZoneAllocator {
public:
- // Allocate 'size' bytes of memory in the zone.
- static void* New(int size);
+ INLINE(void* New(int size));
+};
+
- // De-allocation attempts are silently ignored.
- static void Delete(void* p) { }
+class ZoneDeallocator {
+ public:
+ INLINE(void Delete(void* ptr)) { }
};
+struct ZoneAllocationPolicy {
+ typedef ZoneAllocator Alloc;
danno 2012/05/25 11:03:37 Please use the full words for "Allocator" and "Dea
+ typedef ZoneDeallocator Dealloc;
+};
+
// ZoneLists are growable lists with constant-time access to the
// elements. The list itself and all its elements are allocated in the
// Zone. ZoneLists cannot be deleted individually; you can delete all
// objects in the Zone by calling Zone::DeleteAll().
template<typename T>
-class ZoneList: public List<T, ZoneListAllocationPolicy> {
+class ZoneList: public List<T, ZoneAllocationPolicy> {
public:
- INLINE(void* operator new(size_t size));
- INLINE(void* operator new(size_t size, Zone* zone));
-
// Construct a new ZoneList with the given capacity; the length is
// always zero. The capacity must be non-negative.
explicit ZoneList(int capacity)
- : List<T, ZoneListAllocationPolicy>(capacity) { }
+ : List<T, ZoneAllocationPolicy>(capacity) { }
+
+ INLINE(void* operator new(size_t size, Zone* zone));
+ INLINE(void* operator new(size_t size));
// Construct a new ZoneList by copying the elements of the given ZoneList.
- explicit ZoneList(const ZoneList<T>& other)
- : List<T, ZoneListAllocationPolicy>(other.length()) {
- AddAll(other);
+ explicit ZoneList(const ZoneList<T>& other, ZoneAllocator alloc)
+ : List<T, ZoneAllocationPolicy>(other.length()) {
+ AddAll(other, alloc);
}
void operator delete(void* pointer) { UNREACHABLE(); }
@@ -232,15 +236,15 @@ class ZoneScope BASE_EMBEDDED {
// different configurations of a concrete splay tree (see splay-tree.h).
// The tree itself and all its elements are allocated in the Zone.
template <typename Config>
-class ZoneSplayTree: public SplayTree<Config, ZoneListAllocationPolicy> {
+class ZoneSplayTree: public SplayTree<Config, ZoneAllocationPolicy> {
public:
ZoneSplayTree()
- : SplayTree<Config, ZoneListAllocationPolicy>() {}
+ : SplayTree<Config, ZoneAllocationPolicy>() {}
~ZoneSplayTree();
};
-typedef TemplateHashMapImpl<ZoneListAllocationPolicy> ZoneHashMap;
+typedef TemplateHashMapImpl<ZoneAllocationPolicy> ZoneHashMap;
} } // namespace v8::internal

Powered by Google App Engine
This is Rietveld 408576698