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

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: Merge Allocator and Deallocator and simplify. 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
« no previous file with comments | « 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..9bcbbf689d43b5eb99a75f2ef1648847eaa2c7ca 100644
--- a/src/zone.h
+++ b/src/zone.h
@@ -164,16 +164,11 @@ class ZoneObject {
};
-// The ZoneListAllocationPolicy is used to specialize the GenericList
-// implementation to allocate ZoneLists and their elements in the
-// Zone.
-class ZoneListAllocationPolicy {
- public:
- // Allocate 'size' bytes of memory in the zone.
- static void* New(int size);
-
- // De-allocation attempts are silently ignored.
- static void Delete(void* p) { }
+// The ZoneAllocationPolicy is used to specialize the generic data
+// structures to allocate themselves and their elements in the Zone.
+struct ZoneAllocationPolicy {
+ INLINE(void* New(size_t size));
+ INLINE(static void Delete(void *pointer)) { }
};
@@ -182,20 +177,20 @@ class ZoneListAllocationPolicy {
// 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, ZoneAllocationPolicy allocator)
+ : List<T, ZoneAllocationPolicy>(other.length()) {
+ AddAll(other, allocator);
}
void operator delete(void* pointer) { UNREACHABLE(); }
@@ -232,15 +227,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
« no previous file with comments | « src/v8globals.h ('k') | src/zone-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698