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

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: Fixed the issues pointed out. 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
« src/splay-tree-inl.h ('K') | « src/v8globals.h ('k') | src/zone-inl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/zone.h
diff --git a/src/zone.h b/src/zone.h
index 864846553a234d82cfd88c3e527f1f5c7416e654..d8f71433b4d411474c44b0326d1d6e64efe4aa91 100644
--- a/src/zone.h
+++ b/src/zone.h
@@ -164,38 +164,46 @@ 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) { }
+// De-allocation attempts are silently ignored.
+class ZoneDeallocator {
+ public:
+ INLINE(void Delete(void* ptr)) { }
};
+// The ZoneAllocationPolicy is used to specialize the generic List
+// implementation to allocate ZoneLists and their elements in the
+// Zone.
+struct ZoneAllocationPolicy {
+ typedef ZoneAllocator Allocator;
+ typedef ZoneDeallocator Deallocator;
+};
+
// 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 +240,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
« src/splay-tree-inl.h ('K') | « src/v8globals.h ('k') | src/zone-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698