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

Unified Diff: src/zone.h

Issue 7374002: Refactor allocation policies. Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 5 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/x64/regexp-macro-assembler-x64.cc ('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 af9c916d7005d3bd42d405d2219218b273ead7de..ce7a25024b01882238c4ecbcebef44c091f5cfac 100644
--- a/src/zone.h
+++ b/src/zone.h
@@ -158,16 +158,21 @@ class AssertNoZoneAllocation {
};
-// The ZoneListAllocationPolicy is used to specialize the GenericList
+// The ZoneListAllocator is used to specialize the GenericList
// implementation to allocate ZoneLists and their elements in the
// Zone.
-class ZoneListAllocationPolicy {
+class ZoneListAllocator {
public:
+ explicit ZoneListAllocator(Zone* zone) : zone_(zone) {}
+
// Allocate 'size' bytes of memory in the zone.
- static void* New(int size);
+ void* New(int size);
// De-allocation attempts are silently ignored.
- static void Delete(void* p) { }
+ void Delete(void* p) { }
+
+ private:
+ Zone* zone_;
};
@@ -176,21 +181,32 @@ 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, ZoneListAllocator> {
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) { }
+ ZoneList(Zone* zone, int capacity)
+ : List<T, ZoneListAllocator>(capacity, ZoneListAllocator(zone)),
+ zone_(zone) { }
// Construct a new ZoneList by copying the elements of the given ZoneList.
explicit ZoneList(const ZoneList<T>& other)
- : List<T, ZoneListAllocationPolicy>(other.length()) {
+ : List<T, ZoneListAllocator>(other.length(), ZoneListAllocator(zone)),
+ zone_(other.zone()) {
AddAll(other);
}
+
+ static ZoneList* New(Zone* zone, int capacity);
+
+ Zone* zone() { return zone_; }
+
+ private:
+ // Malloc'ing a zone list doesn't make much sense.
+ void* operator new(size_t size);
+
+ Zone* zone_;
};
@@ -227,10 +243,10 @@ 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, ZoneListAllocator> {
public:
- ZoneSplayTree()
- : SplayTree<Config, ZoneListAllocationPolicy>() {}
+ explicit ZoneSplayTree(Zone* zone)
+ : SplayTree<Config, ZoneListAllocator>(ZoneListAllocator(zone)) {}
~ZoneSplayTree();
};
« no previous file with comments | « src/x64/regexp-macro-assembler-x64.cc ('k') | src/zone-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698